/[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 1326 - (hide annotations)
Mon Oct 1 08:10:41 2007 UTC (11 years, 6 months ago) by ksteube
File MIME type: text/plain
File size: 15134 byte(s)
Implemented domain.print_mesh_info() so we can see the distribution of elements & nodes.
Implemented -DBOUNDS_CHECK to catch an error with periodicN=True.

1 ksteube 1312
2     /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 149 #if !defined finley_MeshAdapter_20040526_H
17 jgs 82 #define finley_MeshAdapter_20040526_H
18 woo409 757 #include "system_dep.h"
19 jgs 82
20     extern "C" {
21 robwdcock 682 #include "../Mesh.h"
22     #include "../Finley.h"
23     #include "../Assemble.h"
24     #include "paso/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 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
32     #include "escript/FunctionSpace.h"
33     #include "escript/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 gross 1062 static const int ReducedNodes;
80 jgs 82 static const int Elements;
81 gross 1059 static const int ReducedElements;
82 jgs 82 static const int FaceElements;
83 gross 1059 static const int ReducedFaceElements;
84 jgs 82 static const int Points;
85     static const int ContactElementsZero;
86 gross 1059 static const int ReducedContactElementsZero;
87 jgs 82 static const int ContactElementsOne;
88 gross 1059 static const int ReducedContactElementsOne;
89 jgs 82
90     /**
91     \brief
92     Constructor for MeshAdapter
93    
94     Description:
95     Constructor for MeshAdapter. The pointer passed to MeshAdapter
96 ksteube 1312 is deleted using a call to Finley_Mesh_free in the
97 jgs 82 MeshAdapter destructor.
98    
99     Throws:
100     May throw an exception derived from EsysException
101    
102     \param finleyMesh Input - A pointer to the externally constructed
103     finley mesh.The pointer passed to MeshAdapter
104     is deleted using a call to
105 ksteube 1312 Finley_Mesh_free in the MeshAdapter
106 jgs 82 destructor.
107     */
108 woo409 757 FINLEY_DLL_API
109 jgs 82 MeshAdapter(Finley_Mesh* finleyMesh=0);
110 jgs 149
111 jgs 82 /**
112     \brief
113     Copy constructor.
114     */
115 woo409 757 FINLEY_DLL_API
116 jgs 82 MeshAdapter(const MeshAdapter& in);
117 jgs 149
118 jgs 82 /**
119     \brief
120     Destructor for MeshAdapter. As specified in the constructor
121 ksteube 1312 this calls Finley_Mesh_free for the pointer given to the
122 jgs 82 constructor.
123     */
124 woo409 757 FINLEY_DLL_API
125 jgs 82 ~MeshAdapter();
126 jgs 149
127 jgs 82 /**
128     \brief
129 ksteube 1312 return the number of processors used for this domain
130     */
131     FINLEY_DLL_API
132     virtual int getMPISize() const;
133     /**
134     \brief
135     return the number MPI rank of this processor
136     */
137    
138     FINLEY_DLL_API
139     virtual int getMPIRank() const;
140    
141     /**
142     \brief
143 jgs 82 return this as an AbstractContinuousDomain.
144     */
145     inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
146     {
147     return *(static_cast<const AbstractContinuousDomain*>(this));
148     }
149    
150     /**
151     \brief
152     return this as an AbstractDomain.
153     */
154     inline const AbstractDomain& asAbstractDomain() const
155     {
156     return *(static_cast<const AbstractDomain*>(this));
157     }
158 jgs 149
159 jgs 82 /**
160     \brief
161     Write the current mesh to a file with the given name.
162     \param fileName Input - The name of the file to write to.
163     */
164 woo409 757 FINLEY_DLL_API
165 jgs 82 void write(const std::string& fileName) const;
166 jgs 149
167 jgs 82 /**
168     \brief
169 ksteube 1326 Write the current mesh to a file with the given name.
170     \param fileName Input - The name of the file to write to.
171     */
172     FINLEY_DLL_API
173     void Print_Mesh_Info() const;
174    
175     /**
176     \brief
177 ksteube 1312 dumps the mesh to a file with the given name.
178     \param fileName Input - The name of the file
179     */
180     FINLEY_DLL_API
181     void dump(const std::string& fileName) const;
182    
183     /**
184     \brief
185 jgs 149 return the pointer to the underlying finley mesh structure
186 jgs 82 */
187 woo409 757 FINLEY_DLL_API
188 jgs 82 Finley_Mesh* getFinley_Mesh() const;
189 jgs 149
190 jgs 110 /**
191     \brief
192     Return the tag key for the given sample number.
193     \param functionSpaceType Input - The function space type.
194     \param sampleNo Input - The sample number.
195     */
196 woo409 757 FINLEY_DLL_API
197 jgs 110 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
198 jgs 149
199 jgs 110 /**
200     \brief
201     Return the reference number of the given sample number.
202     \param functionSpaceType Input - The function space type.
203     */
204 woo409 757 FINLEY_DLL_API
205 gross 964 int* borrowSampleReferenceIDs(int functionSpaceType) const;
206 jgs 110
207     /**
208     \brief
209 jgs 82 Returns true if the given integer is a valid function space type
210     for this domain.
211     */
212 woo409 757 FINLEY_DLL_API
213 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
214 jgs 149
215 jgs 82 /**
216     \brief
217     Return a description for this domain
218     */
219 woo409 757 FINLEY_DLL_API
220 jgs 82 virtual std::string getDescription() const;
221 jgs 149
222 jgs 82 /**
223     \brief
224     Return a description for the given function space type code
225     */
226 woo409 757 FINLEY_DLL_API
227 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
228 jgs 110
229 jgs 82 /**
230     \brief
231     Build the table of function space type names
232     */
233 woo409 757 FINLEY_DLL_API
234 jgs 82 void setFunctionSpaceTypeNames();
235 jgs 149
236 jgs 82 /**
237     \brief
238     Return a continuous FunctionSpace code
239     */
240 woo409 757 FINLEY_DLL_API
241 jgs 82 virtual int getContinuousFunctionCode() const;
242 jgs 149
243 jgs 82 /**
244     \brief
245 gross 1062 Return a continuous on reduced order nodes FunctionSpace code
246     */
247     FINLEY_DLL_API
248     virtual int getReducedContinuousFunctionCode() const;
249    
250     /**
251     \brief
252 gross 1059 Return a function FunctionSpace code
253 jgs 82 */
254 woo409 757 FINLEY_DLL_API
255 jgs 82 virtual int getFunctionCode() const;
256 jgs 149
257 jgs 82 /**
258     \brief
259 gross 1059 Return a function with reduced integration order FunctionSpace code
260     */
261     FINLEY_DLL_API
262     virtual int getReducedFunctionCode() const;
263    
264     /**
265     \brief
266 jgs 82 Return a function on boundary FunctionSpace code
267     */
268 woo409 757 FINLEY_DLL_API
269 jgs 82 virtual int getFunctionOnBoundaryCode() const;
270 jgs 149
271 jgs 82 /**
272     \brief
273 gross 1059 Return a function on boundary with reduced integration order FunctionSpace code
274     */
275     FINLEY_DLL_API
276     virtual int getReducedFunctionOnBoundaryCode() const;
277    
278     /**
279     \brief
280 jgs 82 Return a FunctionOnContactZero code
281     */
282 woo409 757 FINLEY_DLL_API
283 jgs 82 virtual int getFunctionOnContactZeroCode() const;
284 jgs 149
285 jgs 82 /**
286     \brief
287 gross 1059 Return a FunctionOnContactZero code with reduced integration order
288     */
289     FINLEY_DLL_API
290     virtual int getReducedFunctionOnContactZeroCode() const;
291    
292     /**
293     \brief
294 jgs 82 Return a FunctionOnContactOne code
295     */
296 woo409 757 FINLEY_DLL_API
297 jgs 82 virtual int getFunctionOnContactOneCode() const;
298 jgs 149
299 jgs 82 /**
300     \brief
301 gross 1059 Return a FunctionOnContactOne code with reduced integration order
302     */
303     FINLEY_DLL_API
304     virtual int getReducedFunctionOnContactOneCode() const;
305    
306     /**
307     \brief
308 jgs 82 Return a Solution code
309     */
310 woo409 757 FINLEY_DLL_API
311 jgs 82 virtual int getSolutionCode() const;
312 jgs 149
313 jgs 82 /**
314     \brief
315     Return a ReducedSolution code
316     */
317 woo409 757 FINLEY_DLL_API
318 jgs 82 virtual int getReducedSolutionCode() const;
319 jgs 149
320 jgs 82 /**
321     \brief
322     Return a DiracDeltaFunction code
323     */
324 woo409 757 FINLEY_DLL_API
325 jgs 82 virtual int getDiracDeltaFunctionCode() const;
326 jgs 149
327     /**
328 bcumming 782 5B
329 jgs 149 \brief
330     */
331 jgs 82 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
332 jgs 149
333 jgs 82 /**
334     \brief
335     */
336 woo409 757 FINLEY_DLL_API
337 jgs 82 virtual int getDim() const;
338 jgs 149
339     /**
340 jgs 82 \brief
341     Return the number of data points per sample, and the number of samples as a pair.
342 jgs 121 \param functionSpaceCode Input -
343 jgs 82 */
344 woo409 757 FINLEY_DLL_API
345 jgs 82 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
346    
347     /**
348     \brief
349     copies the location of data points into arg. The domain of arg has to match this.
350     has to be implemented by the actual Domain adapter.
351     */
352 woo409 757 FINLEY_DLL_API
353 jgs 82 virtual void setToX(escript::Data& arg) const;
354 jgs 149
355 jgs 82 /**
356     \brief
357 gross 1044 sets a map from a clear tag name to a tag key
358     \param name Input - tag name.
359     \param tag Input - tag key.
360     */
361     FINLEY_DLL_API
362     virtual void setTagMap(const std::string& name, int tag);
363    
364     /**
365     \brief
366     Return the tag key for tag name.
367     \param name Input - tag name
368     */
369     FINLEY_DLL_API
370     virtual int getTag(const std::string& name) const;
371    
372     /**
373     \brief
374     Returns true if name is a defined tage name.
375     \param name Input - tag name to be checked.
376     */
377     FINLEY_DLL_API
378     virtual bool isValidTagName(const std::string& name) const;
379    
380     /**
381     \brief
382     Returns all tag names in a single string sperated by commas
383     */
384     FINLEY_DLL_API
385     virtual std::string showTagNames() const;
386    
387     /**
388     \brief
389 jgs 82 assigns new location to the domain
390     */
391 woo409 757 FINLEY_DLL_API
392 jgs 82 virtual void setNewX(const escript::Data& arg);
393 jgs 149
394 jgs 82 /**
395     \brief
396     interpolates data given on source onto target where source and target have to be given on the same domain.
397     */
398 woo409 757 FINLEY_DLL_API
399 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
400 woo409 757 FINLEY_DLL_API
401 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
402 jgs 149
403 jgs 82 /**
404     \brief
405     interpolates data given on source onto target where source and target are given on different domains.
406     has to be implemented by the actual Domain adapter.
407     */
408 woo409 757 FINLEY_DLL_API
409 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
410 woo409 757 FINLEY_DLL_API
411 jgs 82 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
412 jgs 149
413 jgs 82 /**
414     \brief
415 jgs 149 copies the surface normals at data points into out. The actual function space to be considered
416 jgs 82 is defined by out. out has to be defined on this.
417     */
418 woo409 757 FINLEY_DLL_API
419 jgs 82 virtual void setToNormal(escript::Data& out) const;
420 jgs 149
421 jgs 82 /**
422     \brief
423     copies the size of samples into out. The actual function space to be considered
424     is defined by out. out has to be defined on this.
425     */
426 woo409 757 FINLEY_DLL_API
427 jgs 82 virtual void setToSize(escript::Data& out) const;
428    
429     /**
430     \brief
431     copies the gradient of arg into grad. The actual function space to be considered
432     for the gradient is defined by grad. arg and grad have to be defined on this.
433     */
434 woo409 757 FINLEY_DLL_API
435 jgs 82 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
436    
437     /**
438     \brief
439     copies the integrals of the function defined by arg into integrals.
440     arg has to be defined on this.
441     */
442 woo409 757 FINLEY_DLL_API
443 jgs 82 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
444    
445 jgs 149 /**
446 jgs 102 \brief
447 jgs 150 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
448 jgs 102 and symmetric matrix is used.
449     \param solver
450     \param symmetry
451     */
452 woo409 757 FINLEY_DLL_API
453 jgs 150 virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
454 jgs 102
455 jgs 82 /**
456     \brief
457     returns true if data on this domain and a function space of type functionSpaceCode has to
458     considered as cell centered data.
459     */
460 woo409 757 FINLEY_DLL_API
461 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
462 jgs 149
463 jgs 82 /**
464     \brief
465 jgs 153 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
466    
467     This has to be implemented by the actual Domain adapter.
468 jgs 82 */
469 woo409 757 FINLEY_DLL_API
470 jgs 153 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
471 jgs 149
472 jgs 153
473 jgs 82 /**
474     \brief
475 jgs 153 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
476    
477     This has to be implemented by the actual Domain adapter.
478 jgs 110 */
479 woo409 757 FINLEY_DLL_API
480 jgs 153 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
481 jgs 149
482 jgs 110 /**
483     \brief
484 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
485     as a vtkObject.
486     */
487     // vtkObject createVtkObject(int functionSpaceCode) const;
488 jgs 149
489 jgs 82 /**
490     \brief
491     adds a PDE onto the stiffness matrix mat and a rhs
492     */
493 woo409 757 FINLEY_DLL_API
494 jgs 82 virtual void addPDEToSystem(
495     SystemMatrixAdapter& mat, escript::Data& rhs,
496     const escript::Data& A, const escript::Data& B, const escript::Data& C,
497 jgs 102 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
498     const escript::Data& d, const escript::Data& y,
499     const escript::Data& d_contact, const escript::Data& y_contact) const;
500 gross 1204 /**
501     \brief
502     adds a PDE onto the lumped stiffness matrix matrix
503     */
504     FINLEY_DLL_API
505     virtual void addPDEToLumpedSystem(
506     escript::Data& mat,
507     const escript::Data& D,
508     const escript::Data& d) const;
509 jgs 149
510 jgs 82 /**
511     \brief
512 jgs 102 adds a PDE onto the stiffness matrix mat and a rhs
513 jgs 82 */
514 woo409 757 FINLEY_DLL_API
515 jgs 102 virtual void addPDEToRHS(escript::Data& rhs,
516     const escript::Data& X, const escript::Data& Y,
517     const escript::Data& y, const escript::Data& y_contact) const;
518 jgs 149
519 jgs 82 /**
520     \brief
521     creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
522     */
523 woo409 757 FINLEY_DLL_API
524 jgs 82 SystemMatrixAdapter newSystemMatrix(
525     const int row_blocksize,
526     const escript::FunctionSpace& row_functionspace,
527     const int column_blocksize,
528     const escript::FunctionSpace& column_functionspace,
529 jgs 102 const int type) const;
530 jgs 82
531 jgs 102 /**
532     \brief returns locations in the FEM nodes
533     */
534 woo409 757 FINLEY_DLL_API
535 jgs 102 virtual escript::Data getX() const;
536 jgs 149
537 jgs 102 /**
538     \brief return boundary normals at the quadrature point on the face elements
539     */
540 woo409 757 FINLEY_DLL_API
541 jgs 102 virtual escript::Data getNormal() const;
542 jgs 149
543 jgs 102 /**
544     \brief returns the element size
545     */
546 woo409 757 FINLEY_DLL_API
547 jgs 102 virtual escript::Data getSize() const;
548    
549 jgs 149 /**
550     \brief comparison operators
551     */
552 woo409 757 FINLEY_DLL_API
553 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
554 woo409 757 FINLEY_DLL_API
555 jgs 121 virtual bool operator!=(const AbstractDomain& other) const;
556 jgs 102
557 gross 767 /**
558     \brief assigns new tag newTag to all samples of functionspace with a positive
559     value of mask for any its sample point.
560    
561     */
562     FINLEY_DLL_API
563     virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
564    
565 jgs 82 protected:
566    
567     private:
568 jgs 149
569 jgs 82 //
570     // pointer to the externally created finley mesh
571     boost::shared_ptr<Finley_Mesh> m_finleyMesh;
572    
573     static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
574    
575     };
576    
577     } // end of namespace
578 jgs 149
579 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26