/[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 201 - (hide annotations)
Wed Nov 23 04:10:21 2005 UTC (13 years, 1 month ago) by jgs
Original Path: trunk/finley/src/finley/CPPAdapter/MeshAdapter.h
File MIME type: text/plain
File size: 12359 byte(s)
copy finleyC and CPPAdapter to finley and finley/CPPAdapter to
facilitate scons builds

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26