/[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 1312 - (hide annotations)
Mon Sep 24 06:18:44 2007 UTC (11 years, 6 months ago) by ksteube
File MIME type: text/plain
File size: 14939 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26