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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26