/[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 1801 - (hide annotations)
Fri Sep 19 01:37:09 2008 UTC (10 years, 6 months ago) by ksteube
File MIME type: text/plain
File size: 16601 byte(s)
Fixed serialization of I/O for MPI...code didn't compile without MPI

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26