/[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 1800 - (hide annotations)
Thu Sep 18 05:28:20 2008 UTC (10 years, 6 months ago) by ksteube
File MIME type: text/plain
File size: 16715 byte(s)
Serialized parallel I/O when writing mesh or data to NetCDF file on multiple MPI processors.
Added domain method getMPIComm() to complement getMPISize() and getMPIRank().

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