/[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 2533 - (hide annotations)
Wed Jul 15 05:57:01 2009 UTC (9 years, 8 months ago) by gross
File MIME type: text/plain
File size: 18233 byte(s)
finley delivers now a status identifier of the mesh.
1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 jgs 149 #if !defined finley_MeshAdapter_20040526_H
16 jgs 82 #define finley_MeshAdapter_20040526_H
17 woo409 757 #include "system_dep.h"
18 jgs 82
19     extern "C" {
20 robwdcock 682 #include "../Mesh.h"
21     #include "../Finley.h"
22     #include "../Assemble.h"
23     #include "paso/SystemMatrix.h"
24 gross 1366 #include "paso/SolverFCT.h"
25 ksteube 1800 #include "paso/Paso_MPI.h"
26 jgs 82 }
27 jgs 472
28     #include "FinleyError.h"
29     #include "FinleyAdapterException.h"
30 jgs 149
31 jgs 480 #include "SystemMatrixAdapter.h"
32 gross 1366 #include "TransportProblemAdapter.h"
33 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
34     #include "escript/FunctionSpace.h"
35     #include "escript/FunctionSpaceFactory.h"
36 jgs 472
37 jgs 82 #include <boost/shared_ptr.hpp>
38 jgs 153 #include <boost/python/dict.hpp>
39 jgs 472 #include <boost/python/extract.hpp>
40    
41 jgs 82 #include <map>
42     #include <vector>
43     #include <string>
44 jgs 472 #include <sstream>
45 jgs 82
46 jgs 480 //
47     // forward declarations
48     class Data;
49    
50     //using namespace escript;
51    
52 jgs 82 namespace finley {
53    
54 jgs 123 struct null_deleter
55     {
56     void operator()(void const *ptr) const
57     {
58     }
59     };
60    
61    
62 jgs 82 /**
63     \brief
64     MeshAdapter implements the AbstractContinuousDomain
65     interface for the Finley library.
66    
67     Description:
68     MeshAdapter implements the AbstractContinuousDomain
69     interface for the Finley library.
70     */
71    
72 jgs 480 class MeshAdapter : public escript::AbstractContinuousDomain {
73 jgs 82
74     public:
75    
76     //
77     // Codes for function space types supported
78     static const int DegreesOfFreedom;
79     static const int ReducedDegreesOfFreedom;
80     static const int Nodes;
81 gross 1062 static const int ReducedNodes;
82 jgs 82 static const int Elements;
83 gross 1059 static const int ReducedElements;
84 jgs 82 static const int FaceElements;
85 gross 1059 static const int ReducedFaceElements;
86 jgs 82 static const int Points;
87     static const int ContactElementsZero;
88 gross 1059 static const int ReducedContactElementsZero;
89 jgs 82 static const int ContactElementsOne;
90 gross 1059 static const int ReducedContactElementsOne;
91 jgs 82
92     /**
93     \brief
94     Constructor for MeshAdapter
95    
96     Description:
97     Constructor for MeshAdapter. The pointer passed to MeshAdapter
98 ksteube 1312 is deleted using a call to Finley_Mesh_free in the
99 jgs 82 MeshAdapter destructor.
100    
101     Throws:
102     May throw an exception derived from EsysException
103    
104     \param finleyMesh Input - A pointer to the externally constructed
105     finley mesh.The pointer passed to MeshAdapter
106     is deleted using a call to
107 ksteube 1312 Finley_Mesh_free in the MeshAdapter
108 jgs 82 destructor.
109     */
110 woo409 757 FINLEY_DLL_API
111 jgs 82 MeshAdapter(Finley_Mesh* finleyMesh=0);
112 jgs 149
113 jgs 82 /**
114     \brief
115     Copy constructor.
116     */
117 woo409 757 FINLEY_DLL_API
118 jgs 82 MeshAdapter(const MeshAdapter& in);
119 jgs 149
120 jgs 82 /**
121     \brief
122     Destructor for MeshAdapter. As specified in the constructor
123 ksteube 1312 this calls Finley_Mesh_free for the pointer given to the
124 jgs 82 constructor.
125     */
126 woo409 757 FINLEY_DLL_API
127 jgs 82 ~MeshAdapter();
128 jgs 149
129 jgs 82 /**
130     \brief
131 ksteube 1312 return the number of processors used for this domain
132     */
133     FINLEY_DLL_API
134     virtual int getMPISize() const;
135     /**
136     \brief
137     return the number MPI rank of this processor
138     */
139    
140     FINLEY_DLL_API
141     virtual int getMPIRank() const;
142    
143     /**
144     \brief
145 ksteube 1877 If compiled for MPI then execute an MPI_Barrier, else do nothing
146     */
147    
148     FINLEY_DLL_API
149     virtual void MPIBarrier() const;
150    
151     /**
152     \brief
153     Return true if on MPI processor 0, else false
154     */
155    
156     FINLEY_DLL_API
157     virtual bool onMasterProcessor() const;
158    
159     /**
160     \brief
161 jgs 82 return this as an AbstractContinuousDomain.
162     */
163     inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
164     {
165     return *(static_cast<const AbstractContinuousDomain*>(this));
166     }
167    
168     /**
169     \brief
170     return this as an AbstractDomain.
171     */
172     inline const AbstractDomain& asAbstractDomain() const
173     {
174     return *(static_cast<const AbstractDomain*>(this));
175     }
176 jgs 149
177 jgs 82 /**
178     \brief
179     Write the current mesh to a file with the given name.
180     \param fileName Input - The name of the file to write to.
181     */
182 woo409 757 FINLEY_DLL_API
183 jgs 82 void write(const std::string& fileName) const;
184 jgs 149
185 jgs 82 /**
186     \brief
187 jfenwick 2519 \param full
188 ksteube 1326 */
189     FINLEY_DLL_API
190 jfenwick 2519 void Print_Mesh_Info(const bool full=false) const;
191 ksteube 1326
192     /**
193     \brief
194 ksteube 1312 dumps the mesh to a file with the given name.
195     \param fileName Input - The name of the file
196     */
197     FINLEY_DLL_API
198     void dump(const std::string& fileName) const;
199    
200     /**
201     \brief
202 jgs 149 return the pointer to the underlying finley mesh structure
203 jgs 82 */
204 woo409 757 FINLEY_DLL_API
205 jgs 82 Finley_Mesh* getFinley_Mesh() const;
206 jgs 149
207 jgs 110 /**
208     \brief
209     Return the tag key for the given sample number.
210     \param functionSpaceType Input - The function space type.
211     \param sampleNo Input - The sample number.
212     */
213 woo409 757 FINLEY_DLL_API
214 jgs 110 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
215 jgs 149
216 jgs 110 /**
217     \brief
218     Return the reference number of the given sample number.
219     \param functionSpaceType Input - The function space type.
220     */
221 woo409 757 FINLEY_DLL_API
222 jfenwick 2487 const int* borrowSampleReferenceIDs(int functionSpaceType) const;
223 jgs 110
224     /**
225     \brief
226 jgs 82 Returns true if the given integer is a valid function space type
227     for this domain.
228     */
229 woo409 757 FINLEY_DLL_API
230 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
231 jgs 149
232 jgs 82 /**
233     \brief
234     Return a description for this domain
235     */
236 woo409 757 FINLEY_DLL_API
237 jgs 82 virtual std::string getDescription() const;
238 jgs 149
239 jgs 82 /**
240     \brief
241     Return a description for the given function space type code
242     */
243 woo409 757 FINLEY_DLL_API
244 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
245 jgs 110
246 jgs 82 /**
247     \brief
248     Build the table of function space type names
249     */
250 woo409 757 FINLEY_DLL_API
251 jgs 82 void setFunctionSpaceTypeNames();
252 jgs 149
253 jgs 82 /**
254     \brief
255     Return a continuous FunctionSpace code
256     */
257 woo409 757 FINLEY_DLL_API
258 jgs 82 virtual int getContinuousFunctionCode() const;
259 jgs 149
260 jgs 82 /**
261     \brief
262 gross 1062 Return a continuous on reduced order nodes FunctionSpace code
263     */
264     FINLEY_DLL_API
265     virtual int getReducedContinuousFunctionCode() const;
266    
267     /**
268     \brief
269 gross 1059 Return a function FunctionSpace code
270 jgs 82 */
271 woo409 757 FINLEY_DLL_API
272 jgs 82 virtual int getFunctionCode() const;
273 jgs 149
274 jgs 82 /**
275     \brief
276 gross 1059 Return a function with reduced integration order FunctionSpace code
277     */
278     FINLEY_DLL_API
279     virtual int getReducedFunctionCode() const;
280    
281     /**
282     \brief
283 jgs 82 Return a function on boundary FunctionSpace code
284     */
285 woo409 757 FINLEY_DLL_API
286 jgs 82 virtual int getFunctionOnBoundaryCode() const;
287 jgs 149
288 jgs 82 /**
289     \brief
290 gross 1059 Return a function on boundary with reduced integration order FunctionSpace code
291     */
292     FINLEY_DLL_API
293     virtual int getReducedFunctionOnBoundaryCode() const;
294    
295     /**
296     \brief
297 jgs 82 Return a FunctionOnContactZero code
298     */
299 woo409 757 FINLEY_DLL_API
300 jgs 82 virtual int getFunctionOnContactZeroCode() const;
301 jgs 149
302 jgs 82 /**
303     \brief
304 gross 1059 Return a FunctionOnContactZero code with reduced integration order
305     */
306     FINLEY_DLL_API
307     virtual int getReducedFunctionOnContactZeroCode() const;
308    
309     /**
310     \brief
311 jgs 82 Return a FunctionOnContactOne code
312     */
313 woo409 757 FINLEY_DLL_API
314 jgs 82 virtual int getFunctionOnContactOneCode() const;
315 jgs 149
316 jgs 82 /**
317     \brief
318 gross 1059 Return a FunctionOnContactOne code with reduced integration order
319     */
320     FINLEY_DLL_API
321     virtual int getReducedFunctionOnContactOneCode() const;
322    
323     /**
324     \brief
325 jgs 82 Return a Solution code
326     */
327 woo409 757 FINLEY_DLL_API
328 jgs 82 virtual int getSolutionCode() const;
329 jgs 149
330 jgs 82 /**
331     \brief
332     Return a ReducedSolution code
333     */
334 woo409 757 FINLEY_DLL_API
335 jgs 82 virtual int getReducedSolutionCode() const;
336 jgs 149
337 jgs 82 /**
338     \brief
339     Return a DiracDeltaFunction code
340     */
341 woo409 757 FINLEY_DLL_API
342 jgs 82 virtual int getDiracDeltaFunctionCode() const;
343 jgs 149
344     /**
345 bcumming 782 5B
346 jgs 149 \brief
347     */
348 jgs 82 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
349 jgs 149
350 jgs 82 /**
351     \brief
352     */
353 woo409 757 FINLEY_DLL_API
354 jgs 82 virtual int getDim() const;
355 jgs 149
356     /**
357 jgs 82 \brief
358 gross 2533 Returns a status indicator of the domain. The status identifier should be unique over
359     the live time if the object but may be updated if changes to the domain happen, e.g.
360     modifications to its geometry.
361    
362     This has to be implemented by the actual Domain adapter.
363     */
364     FINLEY_DLL_API
365     virtual StatusType getStatus() const;
366    
367    
368     /**
369     \brief
370 ksteube 1754 Return the number of data points summed across all MPI processes
371     */
372     FINLEY_DLL_API
373     virtual int getNumDataPointsGlobal() const;
374    
375     /**
376     \brief
377 jgs 82 Return the number of data points per sample, and the number of samples as a pair.
378 jgs 121 \param functionSpaceCode Input -
379 jgs 82 */
380 woo409 757 FINLEY_DLL_API
381 jgs 82 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
382    
383     /**
384     \brief
385     copies the location of data points into arg. The domain of arg has to match this.
386     has to be implemented by the actual Domain adapter.
387     */
388 woo409 757 FINLEY_DLL_API
389 jgs 82 virtual void setToX(escript::Data& arg) const;
390 jgs 149
391 jgs 82 /**
392     \brief
393 gross 1044 sets a map from a clear tag name to a tag key
394     \param name Input - tag name.
395     \param tag Input - tag key.
396     */
397     FINLEY_DLL_API
398     virtual void setTagMap(const std::string& name, int tag);
399    
400     /**
401     \brief
402     Return the tag key for tag name.
403     \param name Input - tag name
404     */
405     FINLEY_DLL_API
406     virtual int getTag(const std::string& name) const;
407    
408     /**
409     \brief
410     Returns true if name is a defined tage name.
411     \param name Input - tag name to be checked.
412     */
413     FINLEY_DLL_API
414     virtual bool isValidTagName(const std::string& name) const;
415    
416     /**
417     \brief
418     Returns all tag names in a single string sperated by commas
419     */
420     FINLEY_DLL_API
421     virtual std::string showTagNames() const;
422    
423     /**
424     \brief
425 jgs 82 assigns new location to the domain
426     */
427 woo409 757 FINLEY_DLL_API
428 jgs 82 virtual void setNewX(const escript::Data& arg);
429 jgs 149
430 jgs 82 /**
431     \brief
432     interpolates data given on source onto target where source and target have to be given on the same domain.
433     */
434 woo409 757 FINLEY_DLL_API
435 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
436 jfenwick 2521
437    
438 woo409 757 FINLEY_DLL_API
439 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
440 jgs 149
441 jgs 82 /**
442     \brief
443     interpolates data given on source onto target where source and target are given on different domains.
444     has to be implemented by the actual Domain adapter.
445     */
446 woo409 757 FINLEY_DLL_API
447 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
448 jfenwick 2521
449     /**
450     \brief determines whether interpolation from source to target is possible.
451     Must be implemented by the actual Domain adapter
452     */
453 woo409 757 FINLEY_DLL_API
454 jfenwick 2521 virtual bool probeInterpolationACross(int functionSpaceType_source,const escript::AbstractDomain& targetDomain, int functionSpaceType_target) const;
455 jgs 149
456 jgs 82 /**
457     \brief
458 jgs 149 copies the surface normals at data points into out. The actual function space to be considered
459 jgs 82 is defined by out. out has to be defined on this.
460     */
461 woo409 757 FINLEY_DLL_API
462 jgs 82 virtual void setToNormal(escript::Data& out) const;
463 jgs 149
464 jgs 82 /**
465     \brief
466     copies the size of samples into out. The actual function space to be considered
467     is defined by out. out has to be defined on this.
468     */
469 woo409 757 FINLEY_DLL_API
470 jgs 82 virtual void setToSize(escript::Data& out) const;
471    
472     /**
473     \brief
474     copies the gradient of arg into grad. The actual function space to be considered
475     for the gradient is defined by grad. arg and grad have to be defined on this.
476     */
477 woo409 757 FINLEY_DLL_API
478 jgs 82 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
479    
480     /**
481     \brief
482     copies the integrals of the function defined by arg into integrals.
483     arg has to be defined on this.
484     */
485 woo409 757 FINLEY_DLL_API
486 jgs 82 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
487    
488 jgs 149 /**
489 jgs 102 \brief
490 gross 1859 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package, perconditioner,
491 jgs 102 and symmetric matrix is used.
492     \param solver
493 jfenwick 2519 \param preconditioner
494     \param package
495 jgs 102 \param symmetry
496     */
497 woo409 757 FINLEY_DLL_API
498 gross 1859 virtual int getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
499 jgs 102
500 jgs 82 /**
501     \brief
502 gross 1859 return the identifier of the transport problem type to be used when a particular solver, perconditioner, package
503     and symmetric matrix is used.
504     \param solver
505 jfenwick 2519 \param preconditioner
506     \param package
507 gross 1859 \param symmetry
508     */
509     FINLEY_DLL_API
510     virtual int getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
511    
512     /**
513     \brief
514 jgs 82 returns true if data on this domain and a function space of type functionSpaceCode has to
515     considered as cell centered data.
516     */
517 woo409 757 FINLEY_DLL_API
518 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
519 jgs 149
520 jgs 82 /**
521     \brief
522 jgs 153 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
523    
524     This has to be implemented by the actual Domain adapter.
525 jgs 82 */
526 woo409 757 FINLEY_DLL_API
527 jgs 153 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
528 jgs 149
529 jgs 153
530 jgs 82 /**
531     \brief
532 jgs 153 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
533    
534     This has to be implemented by the actual Domain adapter.
535 jgs 110 */
536 woo409 757 FINLEY_DLL_API
537 gross 2421 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg, const std::string& metadata, const std::string& metadata_schema) const;
538 jgs 149
539 jgs 110 /**
540     \brief
541 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
542     as a vtkObject.
543     */
544     // vtkObject createVtkObject(int functionSpaceCode) const;
545 jgs 149
546 jgs 82 /**
547     \brief
548     adds a PDE onto the stiffness matrix mat and a rhs
549     */
550 woo409 757 FINLEY_DLL_API
551 jgs 82 virtual void addPDEToSystem(
552     SystemMatrixAdapter& mat, escript::Data& rhs,
553     const escript::Data& A, const escript::Data& B, const escript::Data& C,
554 jgs 102 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
555     const escript::Data& d, const escript::Data& y,
556     const escript::Data& d_contact, const escript::Data& y_contact) const;
557 gross 1204 /**
558     \brief
559     adds a PDE onto the lumped stiffness matrix matrix
560     */
561     FINLEY_DLL_API
562     virtual void addPDEToLumpedSystem(
563     escript::Data& mat,
564     const escript::Data& D,
565     const escript::Data& d) const;
566 jgs 149
567 jgs 82 /**
568     \brief
569 jgs 102 adds a PDE onto the stiffness matrix mat and a rhs
570 jgs 82 */
571 woo409 757 FINLEY_DLL_API
572 jgs 102 virtual void addPDEToRHS(escript::Data& rhs,
573     const escript::Data& X, const escript::Data& Y,
574     const escript::Data& y, const escript::Data& y_contact) const;
575 gross 1367 /**
576     \brief
577     adds a PDE onto a transport problem
578     */
579 jgs 149
580 gross 1367 FINLEY_DLL_API
581     virtual void addPDEToTransportProblem(
582     TransportProblemAdapter& tp, escript::Data& source,
583     const escript::Data& M,
584     const escript::Data& A, const escript::Data& B, const escript::Data& C,const escript::Data& D,
585     const escript::Data& X,const escript::Data& Y,
586     const escript::Data& d, const escript::Data& y,
587     const escript::Data& d_contact,const escript::Data& y_contact) const;
588    
589    
590 jgs 82 /**
591     \brief
592 gross 1366 creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros:
593 jgs 82 */
594 woo409 757 FINLEY_DLL_API
595 jgs 82 SystemMatrixAdapter newSystemMatrix(
596     const int row_blocksize,
597     const escript::FunctionSpace& row_functionspace,
598     const int column_blocksize,
599     const escript::FunctionSpace& column_functionspace,
600 jgs 102 const int type) const;
601 gross 1366 /**
602     \brief
603     creates a TransportProblemAdapter
604 jgs 82
605 gross 1366 */
606    
607     FINLEY_DLL_API
608     TransportProblemAdapter newTransportProblem(
609     const double theta,
610     const int blocksize,
611     const escript::FunctionSpace& functionspace,
612     const int type) const;
613    
614 jgs 102 /**
615     \brief returns locations in the FEM nodes
616     */
617 woo409 757 FINLEY_DLL_API
618 jgs 102 virtual escript::Data getX() const;
619 jgs 149
620 jgs 102 /**
621     \brief return boundary normals at the quadrature point on the face elements
622     */
623 woo409 757 FINLEY_DLL_API
624 jgs 102 virtual escript::Data getNormal() const;
625 jgs 149
626 jgs 102 /**
627     \brief returns the element size
628     */
629 woo409 757 FINLEY_DLL_API
630 jgs 102 virtual escript::Data getSize() const;
631    
632 jgs 149 /**
633     \brief comparison operators
634     */
635 woo409 757 FINLEY_DLL_API
636 jfenwick 2521 virtual bool operator==(const escript::AbstractDomain& other) const;
637 woo409 757 FINLEY_DLL_API
638 jfenwick 2521 virtual bool operator!=(const escript::AbstractDomain& other) const;
639 jgs 102
640 gross 767 /**
641     \brief assigns new tag newTag to all samples of functionspace with a positive
642     value of mask for any its sample point.
643    
644     */
645     FINLEY_DLL_API
646     virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
647    
648 gross 1716 /**
649     \brief
650     return the number of tags in use and a pointer to an array with the number of tags in use
651     */
652     FINLEY_DLL_API
653     virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
654    
655     FINLEY_DLL_API
656 jfenwick 2487 virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
657 gross 1716
658 jfenwick 1802
659     /**
660     \brief Checks if this domain allows tags for the specified functionSpaceCode.
661     */
662     FINLEY_DLL_API
663     virtual
664     bool canTag(int functionSpaceCode) const;
665    
666    
667 jgs 82 protected:
668    
669     private:
670 caltinay 2151 void extractArgsFromDict(const boost::python::dict& arg, int& numData,
671     char**& names, escriptDataC*& data,
672     escriptDataC**& dataPtr) const;
673 jgs 149
674 jgs 82 //
675     // pointer to the externally created finley mesh
676     boost::shared_ptr<Finley_Mesh> m_finleyMesh;
677    
678     static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
679    
680     };
681    
682     } // end of namespace
683 jgs 149
684 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26