/[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 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 5 months ago) by ksteube
File MIME type: text/plain
File size: 16734 byte(s)
Copyright updated in all files

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 jgs 82 return this as an AbstractContinuousDomain.
146     */
147     inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
148     {
149     return *(static_cast<const AbstractContinuousDomain*>(this));
150     }
151    
152     /**
153     \brief
154     return this as an AbstractDomain.
155     */
156     inline const AbstractDomain& asAbstractDomain() const
157     {
158     return *(static_cast<const AbstractDomain*>(this));
159     }
160 jgs 149
161 jgs 82 /**
162     \brief
163     Write the current mesh to a file with the given name.
164     \param fileName Input - The name of the file to write to.
165     */
166 woo409 757 FINLEY_DLL_API
167 jgs 82 void write(const std::string& fileName) const;
168 jgs 149
169 jgs 82 /**
170     \brief
171 ksteube 1326 Write the current mesh to a file with the given name.
172     \param fileName Input - The name of the file to write to.
173     */
174     FINLEY_DLL_API
175 ksteube 1339 void Print_Mesh_Info(const bool) const;
176 ksteube 1326
177     /**
178     \brief
179 ksteube 1312 dumps the mesh to a file with the given name.
180     \param fileName Input - The name of the file
181     */
182     FINLEY_DLL_API
183     void dump(const std::string& fileName) const;
184    
185     /**
186     \brief
187 jgs 149 return the pointer to the underlying finley mesh structure
188 jgs 82 */
189 woo409 757 FINLEY_DLL_API
190 jgs 82 Finley_Mesh* getFinley_Mesh() const;
191 jgs 149
192 jgs 110 /**
193     \brief
194     Return the tag key for the given sample number.
195     \param functionSpaceType Input - The function space type.
196     \param sampleNo Input - The sample number.
197     */
198 woo409 757 FINLEY_DLL_API
199 jgs 110 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
200 jgs 149
201 jgs 110 /**
202     \brief
203     Return the reference number of the given sample number.
204     \param functionSpaceType Input - The function space type.
205     */
206 woo409 757 FINLEY_DLL_API
207 gross 964 int* borrowSampleReferenceIDs(int functionSpaceType) const;
208 jgs 110
209     /**
210     \brief
211 jgs 82 Returns true if the given integer is a valid function space type
212     for this domain.
213     */
214 woo409 757 FINLEY_DLL_API
215 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
216 jgs 149
217 jgs 82 /**
218     \brief
219     Return a description for this domain
220     */
221 woo409 757 FINLEY_DLL_API
222 jgs 82 virtual std::string getDescription() const;
223 jgs 149
224 jgs 82 /**
225     \brief
226     Return a description for the given function space type code
227     */
228 woo409 757 FINLEY_DLL_API
229 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
230 jgs 110
231 jgs 82 /**
232     \brief
233     Build the table of function space type names
234     */
235 woo409 757 FINLEY_DLL_API
236 jgs 82 void setFunctionSpaceTypeNames();
237 jgs 149
238 jgs 82 /**
239     \brief
240     Return a continuous FunctionSpace code
241     */
242 woo409 757 FINLEY_DLL_API
243 jgs 82 virtual int getContinuousFunctionCode() const;
244 jgs 149
245 jgs 82 /**
246     \brief
247 gross 1062 Return a continuous on reduced order nodes FunctionSpace code
248     */
249     FINLEY_DLL_API
250     virtual int getReducedContinuousFunctionCode() const;
251    
252     /**
253     \brief
254 gross 1059 Return a function FunctionSpace code
255 jgs 82 */
256 woo409 757 FINLEY_DLL_API
257 jgs 82 virtual int getFunctionCode() const;
258 jgs 149
259 jgs 82 /**
260     \brief
261 gross 1059 Return a function with reduced integration order FunctionSpace code
262     */
263     FINLEY_DLL_API
264     virtual int getReducedFunctionCode() const;
265    
266     /**
267     \brief
268 jgs 82 Return a function on boundary FunctionSpace code
269     */
270 woo409 757 FINLEY_DLL_API
271 jgs 82 virtual int getFunctionOnBoundaryCode() const;
272 jgs 149
273 jgs 82 /**
274     \brief
275 gross 1059 Return a function on boundary with reduced integration order FunctionSpace code
276     */
277     FINLEY_DLL_API
278     virtual int getReducedFunctionOnBoundaryCode() const;
279    
280     /**
281     \brief
282 jgs 82 Return a FunctionOnContactZero code
283     */
284 woo409 757 FINLEY_DLL_API
285 jgs 82 virtual int getFunctionOnContactZeroCode() const;
286 jgs 149
287 jgs 82 /**
288     \brief
289 gross 1059 Return a FunctionOnContactZero code with reduced integration order
290     */
291     FINLEY_DLL_API
292     virtual int getReducedFunctionOnContactZeroCode() const;
293    
294     /**
295     \brief
296 jgs 82 Return a FunctionOnContactOne code
297     */
298 woo409 757 FINLEY_DLL_API
299 jgs 82 virtual int getFunctionOnContactOneCode() const;
300 jgs 149
301 jgs 82 /**
302     \brief
303 gross 1059 Return a FunctionOnContactOne code with reduced integration order
304     */
305     FINLEY_DLL_API
306     virtual int getReducedFunctionOnContactOneCode() const;
307    
308     /**
309     \brief
310 jgs 82 Return a Solution code
311     */
312 woo409 757 FINLEY_DLL_API
313 jgs 82 virtual int getSolutionCode() const;
314 jgs 149
315 jgs 82 /**
316     \brief
317     Return a ReducedSolution code
318     */
319 woo409 757 FINLEY_DLL_API
320 jgs 82 virtual int getReducedSolutionCode() const;
321 jgs 149
322 jgs 82 /**
323     \brief
324     Return a DiracDeltaFunction code
325     */
326 woo409 757 FINLEY_DLL_API
327 jgs 82 virtual int getDiracDeltaFunctionCode() const;
328 jgs 149
329     /**
330 bcumming 782 5B
331 jgs 149 \brief
332     */
333 jgs 82 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
334 jgs 149
335 jgs 82 /**
336     \brief
337     */
338 woo409 757 FINLEY_DLL_API
339 jgs 82 virtual int getDim() const;
340 jgs 149
341     /**
342 jgs 82 \brief
343 ksteube 1754 Return the number of data points summed across all MPI processes
344     */
345     FINLEY_DLL_API
346     virtual int getNumDataPointsGlobal() const;
347    
348     /**
349     \brief
350 jgs 82 Return the number of data points per sample, and the number of samples as a pair.
351 jgs 121 \param functionSpaceCode Input -
352 jgs 82 */
353 woo409 757 FINLEY_DLL_API
354 jgs 82 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
355    
356     /**
357     \brief
358     copies the location of data points into arg. The domain of arg has to match this.
359     has to be implemented by the actual Domain adapter.
360     */
361 woo409 757 FINLEY_DLL_API
362 jgs 82 virtual void setToX(escript::Data& arg) const;
363 jgs 149
364 jgs 82 /**
365     \brief
366 gross 1044 sets a map from a clear tag name to a tag key
367     \param name Input - tag name.
368     \param tag Input - tag key.
369     */
370     FINLEY_DLL_API
371     virtual void setTagMap(const std::string& name, int tag);
372    
373     /**
374     \brief
375     Return the tag key for tag name.
376     \param name Input - tag name
377     */
378     FINLEY_DLL_API
379     virtual int getTag(const std::string& name) const;
380    
381     /**
382     \brief
383     Returns true if name is a defined tage name.
384     \param name Input - tag name to be checked.
385     */
386     FINLEY_DLL_API
387     virtual bool isValidTagName(const std::string& name) const;
388    
389     /**
390     \brief
391     Returns all tag names in a single string sperated by commas
392     */
393     FINLEY_DLL_API
394     virtual std::string showTagNames() const;
395    
396     /**
397     \brief
398 jgs 82 assigns new location to the domain
399     */
400 woo409 757 FINLEY_DLL_API
401 jgs 82 virtual void setNewX(const escript::Data& arg);
402 jgs 149
403 jgs 82 /**
404     \brief
405     interpolates data given on source onto target where source and target have to be given on the same domain.
406     */
407 woo409 757 FINLEY_DLL_API
408 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
409 woo409 757 FINLEY_DLL_API
410 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
411 jgs 149
412 jgs 82 /**
413     \brief
414     interpolates data given on source onto target where source and target are given on different domains.
415     has to be implemented by the actual Domain adapter.
416     */
417 woo409 757 FINLEY_DLL_API
418 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
419 woo409 757 FINLEY_DLL_API
420 jgs 82 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
421 jgs 149
422 jgs 82 /**
423     \brief
424 jgs 149 copies the surface normals at data points into out. The actual function space to be considered
425 jgs 82 is defined by out. out has to be defined on this.
426     */
427 woo409 757 FINLEY_DLL_API
428 jgs 82 virtual void setToNormal(escript::Data& out) const;
429 jgs 149
430 jgs 82 /**
431     \brief
432     copies the size of samples into out. The actual function space to be considered
433     is defined by out. out has to be defined on this.
434     */
435 woo409 757 FINLEY_DLL_API
436 jgs 82 virtual void setToSize(escript::Data& out) const;
437    
438     /**
439     \brief
440     copies the gradient of arg into grad. The actual function space to be considered
441     for the gradient is defined by grad. arg and grad have to be defined on this.
442     */
443 woo409 757 FINLEY_DLL_API
444 jgs 82 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
445    
446     /**
447     \brief
448     copies the integrals of the function defined by arg into integrals.
449     arg has to be defined on this.
450     */
451 woo409 757 FINLEY_DLL_API
452 jgs 82 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
453    
454 jgs 149 /**
455 jgs 102 \brief
456 jgs 150 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
457 jgs 102 and symmetric matrix is used.
458     \param solver
459     \param symmetry
460     */
461 woo409 757 FINLEY_DLL_API
462 jgs 150 virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
463 jgs 102
464 jgs 82 /**
465     \brief
466     returns true if data on this domain and a function space of type functionSpaceCode has to
467     considered as cell centered data.
468     */
469 woo409 757 FINLEY_DLL_API
470 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
471 jgs 149
472 jgs 82 /**
473     \brief
474 jgs 153 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
475    
476     This has to be implemented by the actual Domain adapter.
477 jgs 82 */
478 woo409 757 FINLEY_DLL_API
479 jgs 153 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
480 jgs 149
481 jgs 153
482 jgs 82 /**
483     \brief
484 jgs 153 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
485    
486     This has to be implemented by the actual Domain adapter.
487 jgs 110 */
488 woo409 757 FINLEY_DLL_API
489 jgs 153 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
490 jgs 149
491 jgs 110 /**
492     \brief
493 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
494     as a vtkObject.
495     */
496     // vtkObject createVtkObject(int functionSpaceCode) const;
497 jgs 149
498 jgs 82 /**
499     \brief
500     adds a PDE onto the stiffness matrix mat and a rhs
501     */
502 woo409 757 FINLEY_DLL_API
503 jgs 82 virtual void addPDEToSystem(
504     SystemMatrixAdapter& mat, escript::Data& rhs,
505     const escript::Data& A, const escript::Data& B, const escript::Data& C,
506 jgs 102 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
507     const escript::Data& d, const escript::Data& y,
508     const escript::Data& d_contact, const escript::Data& y_contact) const;
509 gross 1204 /**
510     \brief
511     adds a PDE onto the lumped stiffness matrix matrix
512     */
513     FINLEY_DLL_API
514     virtual void addPDEToLumpedSystem(
515     escript::Data& mat,
516     const escript::Data& D,
517     const escript::Data& d) const;
518 jgs 149
519 jgs 82 /**
520     \brief
521 jgs 102 adds a PDE onto the stiffness matrix mat and a rhs
522 jgs 82 */
523 woo409 757 FINLEY_DLL_API
524 jgs 102 virtual void addPDEToRHS(escript::Data& rhs,
525     const escript::Data& X, const escript::Data& Y,
526     const escript::Data& y, const escript::Data& y_contact) const;
527 gross 1367 /**
528     \brief
529     adds a PDE onto a transport problem
530     */
531 jgs 149
532 gross 1367 FINLEY_DLL_API
533     virtual void addPDEToTransportProblem(
534     TransportProblemAdapter& tp, escript::Data& source,
535     const escript::Data& M,
536     const escript::Data& A, const escript::Data& B, const escript::Data& C,const escript::Data& D,
537     const escript::Data& X,const escript::Data& Y,
538     const escript::Data& d, const escript::Data& y,
539     const escript::Data& d_contact,const escript::Data& y_contact) const;
540    
541    
542 jgs 82 /**
543     \brief
544 gross 1366 creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros:
545 jgs 82 */
546 woo409 757 FINLEY_DLL_API
547 jgs 82 SystemMatrixAdapter newSystemMatrix(
548     const int row_blocksize,
549     const escript::FunctionSpace& row_functionspace,
550     const int column_blocksize,
551     const escript::FunctionSpace& column_functionspace,
552 jgs 102 const int type) const;
553 gross 1366 /**
554     \brief
555     creates a TransportProblemAdapter
556 jgs 82
557 gross 1366 */
558    
559     FINLEY_DLL_API
560     TransportProblemAdapter newTransportProblem(
561     const double theta,
562     const int blocksize,
563     const escript::FunctionSpace& functionspace,
564     const int type) const;
565    
566 jgs 102 /**
567     \brief returns locations in the FEM nodes
568     */
569 woo409 757 FINLEY_DLL_API
570 jgs 102 virtual escript::Data getX() const;
571 jgs 149
572 jgs 102 /**
573     \brief return boundary normals at the quadrature point on the face elements
574     */
575 woo409 757 FINLEY_DLL_API
576 jgs 102 virtual escript::Data getNormal() const;
577 jgs 149
578 jgs 102 /**
579     \brief returns the element size
580     */
581 woo409 757 FINLEY_DLL_API
582 jgs 102 virtual escript::Data getSize() const;
583    
584 jgs 149 /**
585     \brief comparison operators
586     */
587 woo409 757 FINLEY_DLL_API
588 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
589 woo409 757 FINLEY_DLL_API
590 jgs 121 virtual bool operator!=(const AbstractDomain& other) const;
591 jgs 102
592 gross 767 /**
593     \brief assigns new tag newTag to all samples of functionspace with a positive
594     value of mask for any its sample point.
595    
596     */
597     FINLEY_DLL_API
598     virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
599    
600 gross 1716 /**
601     \brief
602     return the number of tags in use and a pointer to an array with the number of tags in use
603     */
604     FINLEY_DLL_API
605     virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
606    
607     FINLEY_DLL_API
608     virtual int* borrowListOfTagsInUse(int functionSpaceCode) const;
609    
610 jfenwick 1802
611     /**
612     \brief Checks if this domain allows tags for the specified functionSpaceCode.
613     */
614     FINLEY_DLL_API
615     virtual
616     bool canTag(int functionSpaceCode) const;
617    
618    
619 jgs 82 protected:
620    
621     private:
622 jgs 149
623 jgs 82 //
624     // pointer to the externally created finley mesh
625     boost::shared_ptr<Finley_Mesh> m_finleyMesh;
626    
627     static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
628    
629     };
630    
631     } // end of namespace
632 jgs 149
633 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26