/[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 1062 - (hide annotations)
Mon Mar 26 06:17:53 2007 UTC (12 years ago) by gross
File MIME type: text/plain
File size: 14446 byte(s)
reduced integration schemes are implemented now for grad, integrate, etc. Tests still to be added.
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 gross 1062 static const int ReducedNodes;
78 jgs 82 static const int Elements;
79 gross 1059 static const int ReducedElements;
80 jgs 82 static const int FaceElements;
81 gross 1059 static const int ReducedFaceElements;
82 jgs 82 static const int Points;
83     static const int ContactElementsZero;
84 gross 1059 static const int ReducedContactElementsZero;
85 jgs 82 static const int ContactElementsOne;
86 gross 1059 static const int ReducedContactElementsOne;
87 jgs 82
88     /**
89     \brief
90     Constructor for MeshAdapter
91    
92     Description:
93     Constructor for MeshAdapter. The pointer passed to MeshAdapter
94     is deleted using a call to Finley_Mesh_deallocate in the
95     MeshAdapter destructor.
96    
97     Throws:
98     May throw an exception derived from EsysException
99    
100     \param finleyMesh Input - A pointer to the externally constructed
101     finley mesh.The pointer passed to MeshAdapter
102     is deleted using a call to
103     Finley_Mesh_deallocate in the MeshAdapter
104     destructor.
105     */
106 woo409 757 FINLEY_DLL_API
107 jgs 82 MeshAdapter(Finley_Mesh* finleyMesh=0);
108 jgs 149
109 jgs 82 /**
110     \brief
111     Copy constructor.
112     */
113 woo409 757 FINLEY_DLL_API
114 jgs 82 MeshAdapter(const MeshAdapter& in);
115 jgs 149
116 jgs 82 /**
117     \brief
118     Destructor for MeshAdapter. As specified in the constructor
119 jgs 149 this calls Finley_Mesh_deallocate for the pointer given to the
120 jgs 82 constructor.
121     */
122 woo409 757 FINLEY_DLL_API
123 jgs 82 ~MeshAdapter();
124 jgs 149
125 jgs 82 /**
126     \brief
127     return this as an AbstractContinuousDomain.
128     */
129     inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
130     {
131     return *(static_cast<const AbstractContinuousDomain*>(this));
132     }
133    
134     /**
135     \brief
136     return this as an AbstractDomain.
137     */
138     inline const AbstractDomain& asAbstractDomain() const
139     {
140     return *(static_cast<const AbstractDomain*>(this));
141     }
142 jgs 149
143 jgs 82 /**
144     \brief
145     Write the current mesh to a file with the given name.
146     \param fileName Input - The name of the file to write to.
147     */
148 woo409 757 FINLEY_DLL_API
149 jgs 82 void write(const std::string& fileName) const;
150 jgs 149
151 jgs 82 /**
152     \brief
153 jgs 149 return the pointer to the underlying finley mesh structure
154 jgs 82 */
155 woo409 757 FINLEY_DLL_API
156 jgs 82 Finley_Mesh* getFinley_Mesh() const;
157 jgs 149
158 jgs 110 /**
159     \brief
160     Return the tag key for the given sample number.
161     \param functionSpaceType Input - The function space type.
162     \param sampleNo Input - The sample number.
163     */
164 woo409 757 FINLEY_DLL_API
165 jgs 110 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
166 jgs 149
167 jgs 110 /**
168     \brief
169     Return the reference number of the given sample number.
170     \param functionSpaceType Input - The function space type.
171     */
172 woo409 757 FINLEY_DLL_API
173 gross 964 int* borrowSampleReferenceIDs(int functionSpaceType) const;
174 jgs 110
175     /**
176     \brief
177 jgs 82 Returns true if the given integer is a valid function space type
178     for this domain.
179     */
180 woo409 757 FINLEY_DLL_API
181 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
182 jgs 149
183 jgs 82 /**
184     \brief
185     Return a description for this domain
186     */
187 woo409 757 FINLEY_DLL_API
188 jgs 82 virtual std::string getDescription() const;
189 jgs 149
190 jgs 82 /**
191     \brief
192     Return a description for the given function space type code
193     */
194 woo409 757 FINLEY_DLL_API
195 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
196 jgs 110
197 jgs 82 /**
198     \brief
199     Build the table of function space type names
200     */
201 woo409 757 FINLEY_DLL_API
202 jgs 82 void setFunctionSpaceTypeNames();
203 jgs 149
204 jgs 82 /**
205     \brief
206     Return a continuous FunctionSpace code
207     */
208 woo409 757 FINLEY_DLL_API
209 jgs 82 virtual int getContinuousFunctionCode() const;
210 jgs 149
211 jgs 82 /**
212     \brief
213 gross 1062 Return a continuous on reduced order nodes FunctionSpace code
214     */
215     FINLEY_DLL_API
216     virtual int getReducedContinuousFunctionCode() const;
217    
218     /**
219     \brief
220 gross 1059 Return a function FunctionSpace code
221 jgs 82 */
222 woo409 757 FINLEY_DLL_API
223 jgs 82 virtual int getFunctionCode() const;
224 jgs 149
225 jgs 82 /**
226     \brief
227 gross 1059 Return a function with reduced integration order FunctionSpace code
228     */
229     FINLEY_DLL_API
230     virtual int getReducedFunctionCode() const;
231    
232     /**
233     \brief
234 jgs 82 Return a function on boundary FunctionSpace code
235     */
236 woo409 757 FINLEY_DLL_API
237 jgs 82 virtual int getFunctionOnBoundaryCode() const;
238 jgs 149
239 jgs 82 /**
240     \brief
241 gross 1059 Return a function on boundary with reduced integration order FunctionSpace code
242     */
243     FINLEY_DLL_API
244     virtual int getReducedFunctionOnBoundaryCode() const;
245    
246     /**
247     \brief
248 jgs 82 Return a FunctionOnContactZero code
249     */
250 woo409 757 FINLEY_DLL_API
251 jgs 82 virtual int getFunctionOnContactZeroCode() const;
252 jgs 149
253 jgs 82 /**
254     \brief
255 gross 1059 Return a FunctionOnContactZero code with reduced integration order
256     */
257     FINLEY_DLL_API
258     virtual int getReducedFunctionOnContactZeroCode() const;
259    
260     /**
261     \brief
262 jgs 82 Return a FunctionOnContactOne code
263     */
264 woo409 757 FINLEY_DLL_API
265 jgs 82 virtual int getFunctionOnContactOneCode() const;
266 jgs 149
267 jgs 82 /**
268     \brief
269 gross 1059 Return a FunctionOnContactOne code with reduced integration order
270     */
271     FINLEY_DLL_API
272     virtual int getReducedFunctionOnContactOneCode() const;
273    
274     /**
275     \brief
276 jgs 82 Return a Solution code
277     */
278 woo409 757 FINLEY_DLL_API
279 jgs 82 virtual int getSolutionCode() const;
280 jgs 149
281 jgs 82 /**
282     \brief
283     Return a ReducedSolution code
284     */
285 woo409 757 FINLEY_DLL_API
286 jgs 82 virtual int getReducedSolutionCode() const;
287 jgs 149
288 jgs 82 /**
289     \brief
290     Return a DiracDeltaFunction code
291     */
292 woo409 757 FINLEY_DLL_API
293 jgs 82 virtual int getDiracDeltaFunctionCode() const;
294 jgs 149
295     /**
296 bcumming 782 5B
297 jgs 149 \brief
298     */
299 jgs 82 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
300 jgs 149
301 jgs 82 /**
302     \brief
303     */
304 woo409 757 FINLEY_DLL_API
305 jgs 82 virtual int getDim() const;
306 jgs 149
307     /**
308 jgs 82 \brief
309     Return the number of data points per sample, and the number of samples as a pair.
310 jgs 121 \param functionSpaceCode Input -
311 jgs 82 */
312 woo409 757 FINLEY_DLL_API
313 jgs 82 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
314    
315     /**
316     \brief
317     copies the location of data points into arg. The domain of arg has to match this.
318     has to be implemented by the actual Domain adapter.
319     */
320 woo409 757 FINLEY_DLL_API
321 jgs 82 virtual void setToX(escript::Data& arg) const;
322 jgs 149
323 jgs 82 /**
324     \brief
325 gross 1044 sets a map from a clear tag name to a tag key
326     \param name Input - tag name.
327     \param tag Input - tag key.
328     */
329     FINLEY_DLL_API
330     virtual void setTagMap(const std::string& name, int tag);
331    
332     /**
333     \brief
334     Return the tag key for tag name.
335     \param name Input - tag name
336     */
337     FINLEY_DLL_API
338     virtual int getTag(const std::string& name) const;
339    
340     /**
341     \brief
342     Returns true if name is a defined tage name.
343     \param name Input - tag name to be checked.
344     */
345     FINLEY_DLL_API
346     virtual bool isValidTagName(const std::string& name) const;
347    
348     /**
349     \brief
350     Returns all tag names in a single string sperated by commas
351     */
352     FINLEY_DLL_API
353     virtual std::string showTagNames() const;
354    
355     /**
356     \brief
357 jgs 82 assigns new location to the domain
358     */
359 woo409 757 FINLEY_DLL_API
360 jgs 82 virtual void setNewX(const escript::Data& arg);
361 jgs 149
362 jgs 82 /**
363     \brief
364     interpolates data given on source onto target where source and target have to be given on the same domain.
365     */
366 woo409 757 FINLEY_DLL_API
367 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
368 woo409 757 FINLEY_DLL_API
369 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
370 jgs 149
371 jgs 82 /**
372     \brief
373     interpolates data given on source onto target where source and target are given on different domains.
374     has to be implemented by the actual Domain adapter.
375     */
376 woo409 757 FINLEY_DLL_API
377 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
378 woo409 757 FINLEY_DLL_API
379 jgs 82 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
380 jgs 149
381 jgs 82 /**
382     \brief
383 jgs 149 copies the surface normals at data points into out. The actual function space to be considered
384 jgs 82 is defined by out. out has to be defined on this.
385     */
386 woo409 757 FINLEY_DLL_API
387 jgs 82 virtual void setToNormal(escript::Data& out) const;
388 jgs 149
389 jgs 82 /**
390     \brief
391     copies the size of samples into out. The actual function space to be considered
392     is defined by out. out has to be defined on this.
393     */
394 woo409 757 FINLEY_DLL_API
395 jgs 82 virtual void setToSize(escript::Data& out) const;
396    
397     /**
398     \brief
399     copies the gradient of arg into grad. The actual function space to be considered
400     for the gradient is defined by grad. arg and grad have to be defined on this.
401     */
402 woo409 757 FINLEY_DLL_API
403 jgs 82 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
404    
405     /**
406     \brief
407     copies the integrals of the function defined by arg into integrals.
408     arg has to be defined on this.
409     */
410 woo409 757 FINLEY_DLL_API
411 jgs 82 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
412    
413 jgs 149 /**
414 jgs 102 \brief
415 jgs 150 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
416 jgs 102 and symmetric matrix is used.
417     \param solver
418     \param symmetry
419     */
420 woo409 757 FINLEY_DLL_API
421 jgs 150 virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
422 jgs 102
423 jgs 82 /**
424     \brief
425     returns true if data on this domain and a function space of type functionSpaceCode has to
426     considered as cell centered data.
427     */
428 woo409 757 FINLEY_DLL_API
429 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
430 jgs 149
431 jgs 82 /**
432     \brief
433 jgs 153 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
434    
435     This has to be implemented by the actual Domain adapter.
436 jgs 82 */
437 woo409 757 FINLEY_DLL_API
438 jgs 153 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
439 jgs 149
440 jgs 153
441 jgs 82 /**
442     \brief
443 jgs 153 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
444    
445     This has to be implemented by the actual Domain adapter.
446 jgs 110 */
447 woo409 757 FINLEY_DLL_API
448 jgs 153 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
449 jgs 149
450 jgs 110 /**
451     \brief
452 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
453     as a vtkObject.
454     */
455     // vtkObject createVtkObject(int functionSpaceCode) const;
456 jgs 149
457 jgs 82 /**
458     \brief
459     adds a PDE onto the stiffness matrix mat and a rhs
460     */
461 woo409 757 FINLEY_DLL_API
462 jgs 82 virtual void addPDEToSystem(
463     SystemMatrixAdapter& mat, escript::Data& rhs,
464     const escript::Data& A, const escript::Data& B, const escript::Data& C,
465 jgs 102 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
466     const escript::Data& d, const escript::Data& y,
467     const escript::Data& d_contact, const escript::Data& y_contact) const;
468 jgs 149
469 jgs 82 /**
470     \brief
471 jgs 102 adds a PDE onto the stiffness matrix mat and a rhs
472 jgs 82 */
473 woo409 757 FINLEY_DLL_API
474 jgs 102 virtual void addPDEToRHS(escript::Data& rhs,
475     const escript::Data& X, const escript::Data& Y,
476     const escript::Data& y, const escript::Data& y_contact) const;
477 jgs 149
478 jgs 82 /**
479     \brief
480     creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
481     */
482 woo409 757 FINLEY_DLL_API
483 jgs 82 SystemMatrixAdapter newSystemMatrix(
484     const int row_blocksize,
485     const escript::FunctionSpace& row_functionspace,
486     const int column_blocksize,
487     const escript::FunctionSpace& column_functionspace,
488 jgs 102 const int type) const;
489 jgs 82
490 jgs 102 /**
491     \brief returns locations in the FEM nodes
492     */
493 woo409 757 FINLEY_DLL_API
494 jgs 102 virtual escript::Data getX() const;
495 jgs 149
496 jgs 102 /**
497     \brief return boundary normals at the quadrature point on the face elements
498     */
499 woo409 757 FINLEY_DLL_API
500 jgs 102 virtual escript::Data getNormal() const;
501 jgs 149
502 jgs 102 /**
503     \brief returns the element size
504     */
505 woo409 757 FINLEY_DLL_API
506 jgs 102 virtual escript::Data getSize() const;
507    
508 jgs 149 /**
509     \brief comparison operators
510     */
511 woo409 757 FINLEY_DLL_API
512 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
513 woo409 757 FINLEY_DLL_API
514 jgs 121 virtual bool operator!=(const AbstractDomain& other) const;
515 jgs 102
516 gross 767 /**
517     \brief assigns new tag newTag to all samples of functionspace with a positive
518     value of mask for any its sample point.
519    
520     */
521     FINLEY_DLL_API
522     virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
523    
524 jgs 82 protected:
525    
526     private:
527 jgs 149
528 jgs 82 //
529     // pointer to the externally created finley mesh
530     boost::shared_ptr<Finley_Mesh> m_finleyMesh;
531    
532     static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
533    
534     };
535    
536     } // end of namespace
537 jgs 149
538 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26