/[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 782 - (hide annotations)
Tue Jul 18 00:47:47 2006 UTC (12 years, 9 months ago) by bcumming
File MIME type: text/plain
File size: 12716 byte(s)
Large number of changes to Finley for meshing in MPI.

- optimisation and neatening up of rectcanglular mesh generation code
- first and second order 1D, 2D and 3D rectangular meshes are now
  available in finley and escript using MPI.
- reduced meshes now generated in MPI, and interpolation to and from 
  reduced data types now supported.  

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26