/[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 474 - (hide annotations)
Mon Jan 30 04:23:44 2006 UTC (13 years, 2 months ago) by jgs
File MIME type: text/plain
File size: 12600 byte(s)
restructure escript source tree
move src/Data/* -> src
remove inc
modify #includes and cpppath settings accordingly

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26