/[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 480 - (hide annotations)
Wed Feb 1 05:15:12 2006 UTC (13 years, 2 months ago) by jgs
File MIME type: text/plain
File size: 12545 byte(s)
rationalise #includes and forward declarations

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26