/[escript]/trunk/finley/src/CPPAdapter/MeshAdapter.h
ViewVC logotype

Annotation of /trunk/finley/src/CPPAdapter/MeshAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 149 - (hide annotations)
Thu Sep 1 03:31:39 2005 UTC (13 years, 7 months ago) by jgs
Original Path: trunk/esys2/finley/src/CPPAdapter/MeshAdapter.h
File MIME type: text/plain
File size: 11802 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-01

1 jgs 102 // $Id$
2 jgs 82 /*
3     ******************************************************************************
4     * *
5     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
6     * *
7     * This software is the property of ACcESS. No part of this code *
8     * may be copied in any form or by any means without the expressed written *
9     * consent of ACcESS. Copying, use or modification of this software *
10     * by any unauthorised person is illegal unless that person has a software *
11     * license agreement with ACcESS. *
12     * *
13     ******************************************************************************
14     */
15    
16 jgs 149 #if !defined finley_MeshAdapter_20040526_H
17 jgs 82 #define finley_MeshAdapter_20040526_H
18    
19     #include "escript/Data/AbstractContinuousDomain.h"
20     #include "escript/Data/Data.h"
21     #include "escript/Data/FunctionSpace.h"
22     extern "C" {
23     #include "finley/finleyC/Mesh.h"
24     }
25     #include "finley/CPPAdapter/SystemMatrixAdapter.h"
26 jgs 149
27 jgs 82 #include <boost/shared_ptr.hpp>
28     #include <boost/python/object.hpp>
29     #include <map>
30     #include <vector>
31     #include <string>
32    
33     namespace finley {
34    
35 jgs 123 struct null_deleter
36     {
37     void operator()(void const *ptr) const
38     {
39     }
40     };
41    
42    
43 jgs 82 /**
44     \brief
45     MeshAdapter implements the AbstractContinuousDomain
46     interface for the Finley library.
47    
48     Description:
49     MeshAdapter implements the AbstractContinuousDomain
50     interface for the Finley library.
51     */
52    
53     class MeshAdapter:public escript::AbstractContinuousDomain {
54    
55     public:
56    
57     //
58     // Codes for function space types supported
59     static const int DegreesOfFreedom;
60     static const int ReducedDegreesOfFreedom;
61     static const int Nodes;
62     static const int Elements;
63     static const int FaceElements;
64     static const int Points;
65     static const int ContactElementsZero;
66     static const int ContactElementsOne;
67    
68     /**
69     \brief
70     Constructor for MeshAdapter
71    
72     Description:
73     Constructor for MeshAdapter. The pointer passed to MeshAdapter
74     is deleted using a call to Finley_Mesh_deallocate in the
75     MeshAdapter destructor.
76    
77     Throws:
78     May throw an exception derived from EsysException
79    
80     \param finleyMesh Input - A pointer to the externally constructed
81     finley mesh.The pointer passed to MeshAdapter
82     is deleted using a call to
83     Finley_Mesh_deallocate in the MeshAdapter
84     destructor.
85     */
86     MeshAdapter(Finley_Mesh* finleyMesh=0);
87 jgs 149
88 jgs 82 /**
89     \brief
90     Copy constructor.
91     */
92     MeshAdapter(const MeshAdapter& in);
93 jgs 149
94 jgs 82 /**
95     \brief
96     Destructor for MeshAdapter. As specified in the constructor
97 jgs 149 this calls Finley_Mesh_deallocate for the pointer given to the
98 jgs 82 constructor.
99     */
100     ~MeshAdapter();
101 jgs 149
102 jgs 82 /**
103     \brief
104     return this as an AbstractContinuousDomain.
105     */
106     inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
107     {
108     return *(static_cast<const AbstractContinuousDomain*>(this));
109     }
110    
111     /**
112     \brief
113     return this as an AbstractDomain.
114     */
115     inline const AbstractDomain& asAbstractDomain() const
116     {
117     return *(static_cast<const AbstractDomain*>(this));
118     }
119 jgs 149
120 jgs 82 /**
121     \brief
122     Write the current mesh to a file with the given name.
123     \param fileName Input - The name of the file to write to.
124     */
125     void write(const std::string& fileName) const;
126 jgs 149
127 jgs 82 /**
128     \brief
129 jgs 149 return the pointer to the underlying finley mesh structure
130 jgs 82 */
131     Finley_Mesh* getFinley_Mesh() const;
132 jgs 149
133 jgs 82 /**
134     \brief
135     Return the tag list indexed by sampleNo.
136     \param functionSpaceType Input
137     \param tagList Output
138     \param numTags Output
139     */
140     void getTagList(int functionSpaceType, int** tagList,
141     int* numTags) const;
142     /**
143     \brief
144 jgs 110 Return the reference number list indexed by sampleNo.
145     \param functionSpaceType Input
146     \param referenceNoList Output
147     \param numReferenceNo Output
148     */
149     void getReferenceNoList(int functionSpaceType, int** referenceNoList,
150     int* numReferenceNo) const;
151    
152     /**
153     \brief
154     Return the tag key for the given sample number.
155     \param functionSpaceType Input - The function space type.
156     \param sampleNo Input - The sample number.
157     */
158     int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
159 jgs 149
160 jgs 110 /**
161     \brief
162     Return the reference number of the given sample number.
163     \param functionSpaceType Input - The function space type.
164     \param sampleNo Input - The sample number.
165     */
166     int getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const;
167    
168     /**
169     \brief
170 jgs 82 Returns true if the given integer is a valid function space type
171     for this domain.
172     */
173     virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
174 jgs 149
175 jgs 82 /**
176     \brief
177     Return a description for this domain
178     */
179     virtual std::string getDescription() const;
180 jgs 149
181 jgs 82 /**
182     \brief
183     Return a description for the given function space type code
184     */
185     virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
186 jgs 110
187 jgs 82 /**
188     \brief
189     Build the table of function space type names
190     */
191     void setFunctionSpaceTypeNames();
192 jgs 149
193 jgs 82 /**
194     \brief
195     Return a continuous FunctionSpace code
196     */
197     virtual int getContinuousFunctionCode() const;
198 jgs 149
199 jgs 82 /**
200     \brief
201     Return a functon FunctionSpace code
202     */
203     virtual int getFunctionCode() const;
204 jgs 149
205 jgs 82 /**
206     \brief
207     Return a function on boundary FunctionSpace code
208     */
209     virtual int getFunctionOnBoundaryCode() const;
210 jgs 149
211 jgs 82 /**
212     \brief
213     Return a FunctionOnContactZero code
214     */
215     virtual int getFunctionOnContactZeroCode() const;
216 jgs 149
217 jgs 82 /**
218     \brief
219     Return a FunctionOnContactOne code
220     */
221     virtual int getFunctionOnContactOneCode() const;
222 jgs 149
223 jgs 82 /**
224     \brief
225     Return a Solution code
226     */
227     virtual int getSolutionCode() const;
228 jgs 149
229 jgs 82 /**
230     \brief
231     Return a ReducedSolution code
232     */
233     virtual int getReducedSolutionCode() const;
234 jgs 149
235 jgs 82 /**
236     \brief
237     Return a DiracDeltaFunction code
238     */
239     virtual int getDiracDeltaFunctionCode() const;
240 jgs 149
241     /**
242     \brief
243     */
244 jgs 82 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
245 jgs 149
246 jgs 82 /**
247     \brief
248     */
249     virtual int getDim() const;
250 jgs 149
251     /**
252 jgs 82 \brief
253     Return the number of data points per sample, and the number of samples as a pair.
254 jgs 121 \param functionSpaceCode Input -
255 jgs 82 */
256     virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
257    
258     /**
259     \brief
260     copies the location of data points into arg. The domain of arg has to match this.
261     has to be implemented by the actual Domain adapter.
262     */
263     virtual void setToX(escript::Data& arg) const;
264 jgs 149
265 jgs 82 /**
266     \brief
267     assigns new location to the domain
268     */
269     virtual void setNewX(const escript::Data& arg);
270 jgs 149
271 jgs 82 /**
272     \brief
273     interpolates data given on source onto target where source and target have to be given on the same domain.
274     */
275     virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
276     virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
277 jgs 149
278 jgs 82 /**
279     \brief
280     interpolates data given on source onto target where source and target are given on different domains.
281     has to be implemented by the actual Domain adapter.
282     */
283     virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
284     virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
285 jgs 149
286 jgs 82 /**
287     \brief
288 jgs 149 copies the surface normals at data points into out. The actual function space to be considered
289 jgs 82 is defined by out. out has to be defined on this.
290     */
291     virtual void setToNormal(escript::Data& out) const;
292 jgs 149
293 jgs 82 /**
294     \brief
295     copies the size of samples into out. The actual function space to be considered
296     is defined by out. out has to be defined on this.
297     */
298     virtual void setToSize(escript::Data& out) const;
299    
300     /**
301     \brief
302     copies the gradient of arg into grad. The actual function space to be considered
303     for the gradient is defined by grad. arg and grad have to be defined on this.
304     */
305     virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
306    
307     /**
308     \brief
309     copies the integrals of the function defined by arg into integrals.
310     arg has to be defined on this.
311     */
312     virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
313    
314 jgs 149 /**
315 jgs 102 \brief
316     return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, preconditioner
317     and symmetric matrix is used.
318     \param solver
319     \param symmetry
320     */
321     virtual int getSystemMatrixTypeId(const int solver, const bool symmetry) const;
322    
323 jgs 82 /**
324     \brief
325     returns true if data on this domain and a function space of type functionSpaceCode has to
326     considered as cell centered data.
327     */
328     virtual bool isCellOriented(int functionSpaceCode) const;
329 jgs 149
330 jgs 82 /**
331     \brief
332 jgs 110 saves data arg to an OpenDX input file.
333 jgs 82 considered as cell centered data.
334     */
335     virtual void saveDX(const std::string& filename,const escript::Data& arg) const;
336 jgs 149
337 jgs 82 /**
338     \brief
339 jgs 110 saves data arg to a VTK input file.
340     considered as cell centered data.
341     */
342     virtual void saveVTK(const std::string& filename,const escript::Data& arg) const;
343 jgs 149
344 jgs 110 /**
345     \brief
346 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
347     as a vtkObject.
348     */
349     // vtkObject createVtkObject(int functionSpaceCode) const;
350 jgs 149
351 jgs 82 /**
352     \brief
353     adds a PDE onto the stiffness matrix mat and a rhs
354     */
355     virtual void addPDEToSystem(
356     SystemMatrixAdapter& mat, escript::Data& rhs,
357     const escript::Data& A, const escript::Data& B, const escript::Data& C,
358 jgs 102 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
359     const escript::Data& d, const escript::Data& y,
360     const escript::Data& d_contact, const escript::Data& y_contact) const;
361 jgs 149
362 jgs 82 /**
363     \brief
364 jgs 102 adds a PDE onto the stiffness matrix mat and a rhs
365 jgs 82 */
366 jgs 102 virtual void addPDEToRHS(escript::Data& rhs,
367     const escript::Data& X, const escript::Data& Y,
368     const escript::Data& y, const escript::Data& y_contact) const;
369 jgs 149
370 jgs 82 /**
371     \brief
372     creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
373     */
374     SystemMatrixAdapter newSystemMatrix(
375     const int row_blocksize,
376     const escript::FunctionSpace& row_functionspace,
377     const int column_blocksize,
378     const escript::FunctionSpace& column_functionspace,
379 jgs 102 const int type) const;
380 jgs 82
381 jgs 102 /**
382     \brief returns locations in the FEM nodes
383     */
384     virtual escript::Data getX() const;
385 jgs 149
386 jgs 102 /**
387     \brief return boundary normals at the quadrature point on the face elements
388     */
389     virtual escript::Data getNormal() const;
390 jgs 149
391 jgs 102 /**
392     \brief returns the element size
393     */
394     virtual escript::Data getSize() const;
395    
396 jgs 149 /**
397     \brief comparison operators
398     */
399 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
400     virtual bool operator!=(const AbstractDomain& other) const;
401 jgs 102
402 jgs 82 protected:
403    
404     private:
405 jgs 149
406 jgs 82 //
407     // pointer to the externally created finley mesh
408     boost::shared_ptr<Finley_Mesh> m_finleyMesh;
409    
410     static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
411    
412     };
413    
414     } // end of namespace
415 jgs 149
416 jgs 82 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26