/[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 1044 - (hide annotations)
Mon Mar 19 07:29:31 2007 UTC (12 years ago) by gross
File MIME type: text/plain
File size: 13393 byte(s)
clear name tagging is supported now.
1 jgs 102 // $Id$
2 jgs 82 /*
3 elspeth 626 ************************************************************
4     * Copyright 2006 by ACcESS MNRF *
5     * *
6     * http://www.access.edu.au *
7     * Primary Business: Queensland, Australia *
8     * Licensed under the Open Software License version 3.0 *
9     * http://www.opensource.org/licenses/osl-3.0.php *
10     * *
11     ************************************************************
12 jgs 82 */
13    
14 jgs 149 #if !defined finley_MeshAdapter_20040526_H
15 jgs 82 #define finley_MeshAdapter_20040526_H
16 woo409 757 #include "system_dep.h"
17 jgs 82
18     extern "C" {
19 robwdcock 682 #include "../Mesh.h"
20     #include "../Finley.h"
21     #include "../Assemble.h"
22     #include "paso/SystemMatrix.h"
23 jgs 82 }
24 jgs 472
25     #include "FinleyError.h"
26     #include "FinleyAdapterException.h"
27 jgs 149
28 jgs 480 #include "SystemMatrixAdapter.h"
29 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
30     #include "escript/FunctionSpace.h"
31     #include "escript/FunctionSpaceFactory.h"
32 jgs 472
33 jgs 82 #include <boost/shared_ptr.hpp>
34 jgs 153 #include <boost/python/dict.hpp>
35 jgs 472 #include <boost/python/extract.hpp>
36    
37 jgs 82 #include <map>
38     #include <vector>
39     #include <string>
40 jgs 472 #include <sstream>
41 jgs 82
42 jgs 480 //
43     // forward declarations
44     class Data;
45    
46     //using namespace escript;
47    
48 jgs 82 namespace finley {
49    
50 jgs 123 struct null_deleter
51     {
52     void operator()(void const *ptr) const
53     {
54     }
55     };
56    
57    
58 jgs 82 /**
59     \brief
60     MeshAdapter implements the AbstractContinuousDomain
61     interface for the Finley library.
62    
63     Description:
64     MeshAdapter implements the AbstractContinuousDomain
65     interface for the Finley library.
66     */
67    
68 jgs 480 class MeshAdapter : public escript::AbstractContinuousDomain {
69 jgs 82
70     public:
71    
72     //
73     // Codes for function space types supported
74     static const int DegreesOfFreedom;
75     static const int ReducedDegreesOfFreedom;
76     static const int Nodes;
77     static const int Elements;
78     static const int FaceElements;
79     static const int Points;
80     static const int ContactElementsZero;
81     static const int ContactElementsOne;
82    
83     /**
84     \brief
85     Constructor for MeshAdapter
86    
87     Description:
88     Constructor for MeshAdapter. The pointer passed to MeshAdapter
89     is deleted using a call to Finley_Mesh_deallocate in the
90     MeshAdapter destructor.
91    
92     Throws:
93     May throw an exception derived from EsysException
94    
95     \param finleyMesh Input - A pointer to the externally constructed
96     finley mesh.The pointer passed to MeshAdapter
97     is deleted using a call to
98     Finley_Mesh_deallocate in the MeshAdapter
99     destructor.
100     */
101 woo409 757 FINLEY_DLL_API
102 jgs 82 MeshAdapter(Finley_Mesh* finleyMesh=0);
103 jgs 149
104 jgs 82 /**
105     \brief
106     Copy constructor.
107     */
108 woo409 757 FINLEY_DLL_API
109 jgs 82 MeshAdapter(const MeshAdapter& in);
110 jgs 149
111 jgs 82 /**
112     \brief
113     Destructor for MeshAdapter. As specified in the constructor
114 jgs 149 this calls Finley_Mesh_deallocate for the pointer given to the
115 jgs 82 constructor.
116     */
117 woo409 757 FINLEY_DLL_API
118 jgs 82 ~MeshAdapter();
119 jgs 149
120 jgs 82 /**
121     \brief
122     return this as an AbstractContinuousDomain.
123     */
124     inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
125     {
126     return *(static_cast<const AbstractContinuousDomain*>(this));
127     }
128    
129     /**
130     \brief
131     return this as an AbstractDomain.
132     */
133     inline const AbstractDomain& asAbstractDomain() const
134     {
135     return *(static_cast<const AbstractDomain*>(this));
136     }
137 jgs 149
138 jgs 82 /**
139     \brief
140     Write the current mesh to a file with the given name.
141     \param fileName Input - The name of the file to write to.
142     */
143 woo409 757 FINLEY_DLL_API
144 jgs 82 void write(const std::string& fileName) const;
145 jgs 149
146 jgs 82 /**
147     \brief
148 jgs 149 return the pointer to the underlying finley mesh structure
149 jgs 82 */
150 woo409 757 FINLEY_DLL_API
151 jgs 82 Finley_Mesh* getFinley_Mesh() const;
152 jgs 149
153 jgs 110 /**
154     \brief
155     Return the tag key for the given sample number.
156     \param functionSpaceType Input - The function space type.
157     \param sampleNo Input - The sample number.
158     */
159 woo409 757 FINLEY_DLL_API
160 jgs 110 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
161 jgs 149
162 jgs 110 /**
163     \brief
164     Return the reference number of the given sample number.
165     \param functionSpaceType Input - The function space type.
166     */
167 woo409 757 FINLEY_DLL_API
168 gross 964 int* borrowSampleReferenceIDs(int functionSpaceType) const;
169 jgs 110
170     /**
171     \brief
172 jgs 82 Returns true if the given integer is a valid function space type
173     for this domain.
174     */
175 woo409 757 FINLEY_DLL_API
176 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
177 jgs 149
178 jgs 82 /**
179     \brief
180     Return a description for this domain
181     */
182 woo409 757 FINLEY_DLL_API
183 jgs 82 virtual std::string getDescription() const;
184 jgs 149
185 jgs 82 /**
186     \brief
187     Return a description for the given function space type code
188     */
189 woo409 757 FINLEY_DLL_API
190 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
191 jgs 110
192 jgs 82 /**
193     \brief
194     Build the table of function space type names
195     */
196 woo409 757 FINLEY_DLL_API
197 jgs 82 void setFunctionSpaceTypeNames();
198 jgs 149
199 jgs 82 /**
200     \brief
201     Return a continuous FunctionSpace code
202     */
203 woo409 757 FINLEY_DLL_API
204 jgs 82 virtual int getContinuousFunctionCode() const;
205 jgs 149
206 jgs 82 /**
207     \brief
208     Return a functon FunctionSpace code
209     */
210 woo409 757 FINLEY_DLL_API
211 jgs 82 virtual int getFunctionCode() const;
212 jgs 149
213 jgs 82 /**
214     \brief
215     Return a function on boundary FunctionSpace code
216     */
217 woo409 757 FINLEY_DLL_API
218 jgs 82 virtual int getFunctionOnBoundaryCode() const;
219 jgs 149
220 jgs 82 /**
221     \brief
222     Return a FunctionOnContactZero code
223     */
224 woo409 757 FINLEY_DLL_API
225 jgs 82 virtual int getFunctionOnContactZeroCode() const;
226 jgs 149
227 jgs 82 /**
228     \brief
229     Return a FunctionOnContactOne code
230     */
231 woo409 757 FINLEY_DLL_API
232 jgs 82 virtual int getFunctionOnContactOneCode() const;
233 jgs 149
234 jgs 82 /**
235     \brief
236     Return a Solution code
237     */
238 woo409 757 FINLEY_DLL_API
239 jgs 82 virtual int getSolutionCode() const;
240 jgs 149
241 jgs 82 /**
242     \brief
243     Return a ReducedSolution code
244     */
245 woo409 757 FINLEY_DLL_API
246 jgs 82 virtual int getReducedSolutionCode() const;
247 jgs 149
248 jgs 82 /**
249     \brief
250     Return a DiracDeltaFunction code
251     */
252 woo409 757 FINLEY_DLL_API
253 jgs 82 virtual int getDiracDeltaFunctionCode() const;
254 jgs 149
255     /**
256 bcumming 782 5B
257 jgs 149 \brief
258     */
259 jgs 82 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
260 jgs 149
261 jgs 82 /**
262     \brief
263     */
264 woo409 757 FINLEY_DLL_API
265 jgs 82 virtual int getDim() const;
266 jgs 149
267     /**
268 jgs 82 \brief
269     Return the number of data points per sample, and the number of samples as a pair.
270 jgs 121 \param functionSpaceCode Input -
271 jgs 82 */
272 woo409 757 FINLEY_DLL_API
273 jgs 82 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
274    
275     /**
276     \brief
277     copies the location of data points into arg. The domain of arg has to match this.
278     has to be implemented by the actual Domain adapter.
279     */
280 woo409 757 FINLEY_DLL_API
281 jgs 82 virtual void setToX(escript::Data& arg) const;
282 jgs 149
283 jgs 82 /**
284     \brief
285 gross 1044 sets a map from a clear tag name to a tag key
286     \param name Input - tag name.
287     \param tag Input - tag key.
288     */
289     FINLEY_DLL_API
290     virtual void setTagMap(const std::string& name, int tag);
291    
292     /**
293     \brief
294     Return the tag key for tag name.
295     \param name Input - tag name
296     */
297     FINLEY_DLL_API
298     virtual int getTag(const std::string& name) const;
299    
300     /**
301     \brief
302     Returns true if name is a defined tage name.
303     \param name Input - tag name to be checked.
304     */
305     FINLEY_DLL_API
306     virtual bool isValidTagName(const std::string& name) const;
307    
308     /**
309     \brief
310     Returns all tag names in a single string sperated by commas
311     */
312     FINLEY_DLL_API
313     virtual std::string showTagNames() const;
314    
315     /**
316     \brief
317 jgs 82 assigns new location to the domain
318     */
319 woo409 757 FINLEY_DLL_API
320 jgs 82 virtual void setNewX(const escript::Data& arg);
321 jgs 149
322 jgs 82 /**
323     \brief
324     interpolates data given on source onto target where source and target have to be given on the same domain.
325     */
326 woo409 757 FINLEY_DLL_API
327 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
328 woo409 757 FINLEY_DLL_API
329 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
330 jgs 149
331 jgs 82 /**
332     \brief
333     interpolates data given on source onto target where source and target are given on different domains.
334     has to be implemented by the actual Domain adapter.
335     */
336 woo409 757 FINLEY_DLL_API
337 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
338 woo409 757 FINLEY_DLL_API
339 jgs 82 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
340 jgs 149
341 jgs 82 /**
342     \brief
343 jgs 149 copies the surface normals at data points into out. The actual function space to be considered
344 jgs 82 is defined by out. out has to be defined on this.
345     */
346 woo409 757 FINLEY_DLL_API
347 jgs 82 virtual void setToNormal(escript::Data& out) const;
348 jgs 149
349 jgs 82 /**
350     \brief
351     copies the size of samples into out. The actual function space to be considered
352     is defined by out. out has to be defined on this.
353     */
354 woo409 757 FINLEY_DLL_API
355 jgs 82 virtual void setToSize(escript::Data& out) const;
356    
357     /**
358     \brief
359     copies the gradient of arg into grad. The actual function space to be considered
360     for the gradient is defined by grad. arg and grad have to be defined on this.
361     */
362 woo409 757 FINLEY_DLL_API
363 jgs 82 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
364    
365     /**
366     \brief
367     copies the integrals of the function defined by arg into integrals.
368     arg has to be defined on this.
369     */
370 woo409 757 FINLEY_DLL_API
371 jgs 82 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
372    
373 jgs 149 /**
374 jgs 102 \brief
375 jgs 150 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
376 jgs 102 and symmetric matrix is used.
377     \param solver
378     \param symmetry
379     */
380 woo409 757 FINLEY_DLL_API
381 jgs 150 virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
382 jgs 102
383 jgs 82 /**
384     \brief
385     returns true if data on this domain and a function space of type functionSpaceCode has to
386     considered as cell centered data.
387     */
388 woo409 757 FINLEY_DLL_API
389 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
390 jgs 149
391 jgs 82 /**
392     \brief
393 jgs 153 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
394    
395     This has to be implemented by the actual Domain adapter.
396 jgs 82 */
397 woo409 757 FINLEY_DLL_API
398 jgs 153 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
399 jgs 149
400 jgs 153
401 jgs 82 /**
402     \brief
403 jgs 153 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
404    
405     This has to be implemented by the actual Domain adapter.
406 jgs 110 */
407 woo409 757 FINLEY_DLL_API
408 jgs 153 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
409 jgs 149
410 jgs 110 /**
411     \brief
412 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
413     as a vtkObject.
414     */
415     // vtkObject createVtkObject(int functionSpaceCode) const;
416 jgs 149
417 jgs 82 /**
418     \brief
419     adds a PDE onto the stiffness matrix mat and a rhs
420     */
421 woo409 757 FINLEY_DLL_API
422 jgs 82 virtual void addPDEToSystem(
423     SystemMatrixAdapter& mat, escript::Data& rhs,
424     const escript::Data& A, const escript::Data& B, const escript::Data& C,
425 jgs 102 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
426     const escript::Data& d, const escript::Data& y,
427     const escript::Data& d_contact, const escript::Data& y_contact) const;
428 jgs 149
429 jgs 82 /**
430     \brief
431 jgs 102 adds a PDE onto the stiffness matrix mat and a rhs
432 jgs 82 */
433 woo409 757 FINLEY_DLL_API
434 jgs 102 virtual void addPDEToRHS(escript::Data& rhs,
435     const escript::Data& X, const escript::Data& Y,
436     const escript::Data& y, const escript::Data& y_contact) const;
437 jgs 149
438 jgs 82 /**
439     \brief
440     creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
441     */
442 woo409 757 FINLEY_DLL_API
443 jgs 82 SystemMatrixAdapter newSystemMatrix(
444     const int row_blocksize,
445     const escript::FunctionSpace& row_functionspace,
446     const int column_blocksize,
447     const escript::FunctionSpace& column_functionspace,
448 jgs 102 const int type) const;
449 jgs 82
450 jgs 102 /**
451     \brief returns locations in the FEM nodes
452     */
453 woo409 757 FINLEY_DLL_API
454 jgs 102 virtual escript::Data getX() const;
455 jgs 149
456 jgs 102 /**
457     \brief return boundary normals at the quadrature point on the face elements
458     */
459 woo409 757 FINLEY_DLL_API
460 jgs 102 virtual escript::Data getNormal() const;
461 jgs 149
462 jgs 102 /**
463     \brief returns the element size
464     */
465 woo409 757 FINLEY_DLL_API
466 jgs 102 virtual escript::Data getSize() const;
467    
468 jgs 149 /**
469     \brief comparison operators
470     */
471 woo409 757 FINLEY_DLL_API
472 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
473 woo409 757 FINLEY_DLL_API
474 jgs 121 virtual bool operator!=(const AbstractDomain& other) const;
475 jgs 102
476 gross 767 /**
477     \brief assigns new tag newTag to all samples of functionspace with a positive
478     value of mask for any its sample point.
479    
480     */
481     FINLEY_DLL_API
482     virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
483    
484 jgs 82 protected:
485    
486     private:
487 jgs 149
488 jgs 82 //
489     // pointer to the externally created finley mesh
490     boost::shared_ptr<Finley_Mesh> m_finleyMesh;
491    
492     static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
493    
494     };
495    
496     } // end of namespace
497 jgs 149
498 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26