1 |
// $Id$ |
2 |
/* |
3 |
****************************************************************************** |
4 |
* * |
5 |
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
6 |
* * |
7 |
* This software is the property of ACcESS. No part of this code * |
8 |
* may be copied in any form or by any means without the expressed written * |
9 |
* consent of ACcESS. Copying, use or modification of this software * |
10 |
* by any unauthorised person is illegal unless that person has a software * |
11 |
* license agreement with ACcESS. * |
12 |
* * |
13 |
****************************************************************************** |
14 |
*/ |
15 |
|
16 |
#if !defined finley_MeshAdapter_20040526_H |
17 |
#define finley_MeshAdapter_20040526_H |
18 |
|
19 |
#ifdef MSVC |
20 |
#ifdef FINLEY_EXPORTS |
21 |
#define FINLEY_DLL __declspec(dllexport) |
22 |
#else |
23 |
#define FINLEY_DLL __declspec(dllimport) |
24 |
#endif |
25 |
#else |
26 |
#define FINLEY_DLL |
27 |
#endif |
28 |
#include "escript/Data/AbstractContinuousDomain.h" |
29 |
#include "escript/Data/Data.h" |
30 |
#include "escript/Data/FunctionSpace.h" |
31 |
extern "C" { |
32 |
#include "finley/finleyC/Mesh.h" |
33 |
} |
34 |
#include "finley/CPPAdapter/SystemMatrixAdapter.h" |
35 |
|
36 |
#include <boost/shared_ptr.hpp> |
37 |
#include <boost/python/object.hpp> |
38 |
#include <boost/python/dict.hpp> |
39 |
#include <map> |
40 |
#include <vector> |
41 |
#include <string> |
42 |
|
43 |
namespace finley { |
44 |
|
45 |
struct null_deleter |
46 |
{ |
47 |
void operator()(void const *ptr) const |
48 |
{ |
49 |
} |
50 |
}; |
51 |
|
52 |
|
53 |
/** |
54 |
\brief |
55 |
MeshAdapter implements the AbstractContinuousDomain |
56 |
interface for the Finley library. |
57 |
|
58 |
Description: |
59 |
MeshAdapter implements the AbstractContinuousDomain |
60 |
interface for the Finley library. |
61 |
*/ |
62 |
|
63 |
class FINLEY_DLL MeshAdapter:public escript::AbstractContinuousDomain { |
64 |
|
65 |
public: |
66 |
|
67 |
// |
68 |
// Codes for function space types supported |
69 |
static const int DegreesOfFreedom; |
70 |
static const int ReducedDegreesOfFreedom; |
71 |
static const int Nodes; |
72 |
static const int Elements; |
73 |
static const int FaceElements; |
74 |
static const int Points; |
75 |
static const int ContactElementsZero; |
76 |
static const int ContactElementsOne; |
77 |
|
78 |
/** |
79 |
\brief |
80 |
Constructor for MeshAdapter |
81 |
|
82 |
Description: |
83 |
Constructor for MeshAdapter. The pointer passed to MeshAdapter |
84 |
is deleted using a call to Finley_Mesh_deallocate in the |
85 |
MeshAdapter destructor. |
86 |
|
87 |
Throws: |
88 |
May throw an exception derived from EsysException |
89 |
|
90 |
\param finleyMesh Input - A pointer to the externally constructed |
91 |
finley mesh.The pointer passed to MeshAdapter |
92 |
is deleted using a call to |
93 |
Finley_Mesh_deallocate in the MeshAdapter |
94 |
destructor. |
95 |
*/ |
96 |
MeshAdapter(Finley_Mesh* finleyMesh=0); |
97 |
|
98 |
/** |
99 |
\brief |
100 |
Copy constructor. |
101 |
*/ |
102 |
MeshAdapter(const MeshAdapter& in); |
103 |
|
104 |
/** |
105 |
\brief |
106 |
Destructor for MeshAdapter. As specified in the constructor |
107 |
this calls Finley_Mesh_deallocate for the pointer given to the |
108 |
constructor. |
109 |
*/ |
110 |
~MeshAdapter(); |
111 |
|
112 |
/** |
113 |
\brief |
114 |
return this as an AbstractContinuousDomain. |
115 |
*/ |
116 |
inline const AbstractContinuousDomain& asAbstractContinuousDomain() const |
117 |
{ |
118 |
return *(static_cast<const AbstractContinuousDomain*>(this)); |
119 |
} |
120 |
|
121 |
/** |
122 |
\brief |
123 |
return this as an AbstractDomain. |
124 |
*/ |
125 |
inline const AbstractDomain& asAbstractDomain() const |
126 |
{ |
127 |
return *(static_cast<const AbstractDomain*>(this)); |
128 |
} |
129 |
|
130 |
/** |
131 |
\brief |
132 |
Write the current mesh to a file with the given name. |
133 |
\param fileName Input - The name of the file to write to. |
134 |
*/ |
135 |
void write(const std::string& fileName) const; |
136 |
|
137 |
/** |
138 |
\brief |
139 |
return the pointer to the underlying finley mesh structure |
140 |
*/ |
141 |
Finley_Mesh* getFinley_Mesh() const; |
142 |
|
143 |
/** |
144 |
\brief |
145 |
Return the tag list indexed by sampleNo. |
146 |
\param functionSpaceType Input |
147 |
\param tagList Output |
148 |
\param numTags Output |
149 |
*/ |
150 |
void getTagList(int functionSpaceType, int** tagList, |
151 |
int* numTags) const; |
152 |
/** |
153 |
\brief |
154 |
Return the reference number list indexed by sampleNo. |
155 |
\param functionSpaceType Input |
156 |
\param referenceNoList Output |
157 |
\param numReferenceNo Output |
158 |
*/ |
159 |
void getReferenceNoList(int functionSpaceType, int** referenceNoList, |
160 |
int* numReferenceNo) const; |
161 |
|
162 |
/** |
163 |
\brief |
164 |
Return the tag key for the given sample number. |
165 |
\param functionSpaceType Input - The function space type. |
166 |
\param sampleNo Input - The sample number. |
167 |
*/ |
168 |
int getTagFromSampleNo(int functionSpaceType, int sampleNo) const; |
169 |
|
170 |
/** |
171 |
\brief |
172 |
Return the reference number of the given sample number. |
173 |
\param functionSpaceType Input - The function space type. |
174 |
\param sampleNo Input - The sample number. |
175 |
*/ |
176 |
int getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const; |
177 |
|
178 |
/** |
179 |
\brief |
180 |
Returns true if the given integer is a valid function space type |
181 |
for this domain. |
182 |
*/ |
183 |
virtual bool isValidFunctionSpaceType(int functionSpaceType) const; |
184 |
|
185 |
/** |
186 |
\brief |
187 |
Return a description for this domain |
188 |
*/ |
189 |
virtual std::string getDescription() const; |
190 |
|
191 |
/** |
192 |
\brief |
193 |
Return a description for the given function space type code |
194 |
*/ |
195 |
virtual std::string functionSpaceTypeAsString(int functionSpaceType) const; |
196 |
|
197 |
/** |
198 |
\brief |
199 |
Build the table of function space type names |
200 |
*/ |
201 |
void setFunctionSpaceTypeNames(); |
202 |
|
203 |
/** |
204 |
\brief |
205 |
Return a continuous FunctionSpace code |
206 |
*/ |
207 |
virtual int getContinuousFunctionCode() const; |
208 |
|
209 |
/** |
210 |
\brief |
211 |
Return a functon FunctionSpace code |
212 |
*/ |
213 |
virtual int getFunctionCode() const; |
214 |
|
215 |
/** |
216 |
\brief |
217 |
Return a function on boundary FunctionSpace code |
218 |
*/ |
219 |
virtual int getFunctionOnBoundaryCode() const; |
220 |
|
221 |
/** |
222 |
\brief |
223 |
Return a FunctionOnContactZero code |
224 |
*/ |
225 |
virtual int getFunctionOnContactZeroCode() const; |
226 |
|
227 |
/** |
228 |
\brief |
229 |
Return a FunctionOnContactOne code |
230 |
*/ |
231 |
virtual int getFunctionOnContactOneCode() const; |
232 |
|
233 |
/** |
234 |
\brief |
235 |
Return a Solution code |
236 |
*/ |
237 |
virtual int getSolutionCode() const; |
238 |
|
239 |
/** |
240 |
\brief |
241 |
Return a ReducedSolution code |
242 |
*/ |
243 |
virtual int getReducedSolutionCode() const; |
244 |
|
245 |
/** |
246 |
\brief |
247 |
Return a DiracDeltaFunction code |
248 |
*/ |
249 |
virtual int getDiracDeltaFunctionCode() const; |
250 |
|
251 |
/** |
252 |
\brief |
253 |
*/ |
254 |
typedef std::map<int, std::string> FunctionSpaceNamesMapType; |
255 |
|
256 |
/** |
257 |
\brief |
258 |
*/ |
259 |
virtual int getDim() const; |
260 |
|
261 |
/** |
262 |
\brief |
263 |
Return the number of data points per sample, and the number of samples as a pair. |
264 |
\param functionSpaceCode Input - |
265 |
*/ |
266 |
virtual std::pair<int,int> getDataShape(int functionSpaceCode) const; |
267 |
|
268 |
/** |
269 |
\brief |
270 |
copies the location of data points into arg. The domain of arg has to match this. |
271 |
has to be implemented by the actual Domain adapter. |
272 |
*/ |
273 |
virtual void setToX(escript::Data& arg) const; |
274 |
|
275 |
/** |
276 |
\brief |
277 |
assigns new location to the domain |
278 |
*/ |
279 |
virtual void setNewX(const escript::Data& arg); |
280 |
|
281 |
/** |
282 |
\brief |
283 |
interpolates data given on source onto target where source and target have to be given on the same domain. |
284 |
*/ |
285 |
virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const; |
286 |
virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const; |
287 |
|
288 |
/** |
289 |
\brief |
290 |
interpolates data given on source onto target where source and target are given on different domains. |
291 |
has to be implemented by the actual Domain adapter. |
292 |
*/ |
293 |
virtual void interpolateACross(escript::Data& target, const escript::Data& source) const; |
294 |
virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const; |
295 |
|
296 |
/** |
297 |
\brief |
298 |
copies the surface normals at data points into out. The actual function space to be considered |
299 |
is defined by out. out has to be defined on this. |
300 |
*/ |
301 |
virtual void setToNormal(escript::Data& out) const; |
302 |
|
303 |
/** |
304 |
\brief |
305 |
copies the size of samples into out. The actual function space to be considered |
306 |
is defined by out. out has to be defined on this. |
307 |
*/ |
308 |
virtual void setToSize(escript::Data& out) const; |
309 |
|
310 |
/** |
311 |
\brief |
312 |
copies the gradient of arg into grad. The actual function space to be considered |
313 |
for the gradient is defined by grad. arg and grad have to be defined on this. |
314 |
*/ |
315 |
virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const; |
316 |
|
317 |
/** |
318 |
\brief |
319 |
copies the integrals of the function defined by arg into integrals. |
320 |
arg has to be defined on this. |
321 |
*/ |
322 |
virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const; |
323 |
|
324 |
/** |
325 |
\brief |
326 |
return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package |
327 |
and symmetric matrix is used. |
328 |
\param solver |
329 |
\param symmetry |
330 |
*/ |
331 |
virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const; |
332 |
|
333 |
/** |
334 |
\brief |
335 |
returns true if data on this domain and a function space of type functionSpaceCode has to |
336 |
considered as cell centered data. |
337 |
*/ |
338 |
virtual bool isCellOriented(int functionSpaceCode) const; |
339 |
|
340 |
/** |
341 |
\brief |
342 |
Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier |
343 |
|
344 |
This has to be implemented by the actual Domain adapter. |
345 |
*/ |
346 |
virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const; |
347 |
|
348 |
|
349 |
/** |
350 |
\brief |
351 |
Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier |
352 |
|
353 |
This has to be implemented by the actual Domain adapter. |
354 |
*/ |
355 |
virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const; |
356 |
|
357 |
/** |
358 |
\brief |
359 |
returns the function space representation of the type functionSpaceCode on this domain |
360 |
as a vtkObject. |
361 |
*/ |
362 |
// vtkObject createVtkObject(int functionSpaceCode) const; |
363 |
|
364 |
/** |
365 |
\brief |
366 |
adds a PDE onto the stiffness matrix mat and a rhs |
367 |
*/ |
368 |
virtual void addPDEToSystem( |
369 |
SystemMatrixAdapter& mat, escript::Data& rhs, |
370 |
const escript::Data& A, const escript::Data& B, const escript::Data& C, |
371 |
const escript::Data& D, const escript::Data& X, const escript::Data& Y, |
372 |
const escript::Data& d, const escript::Data& y, |
373 |
const escript::Data& d_contact, const escript::Data& y_contact) const; |
374 |
|
375 |
/** |
376 |
\brief |
377 |
adds a PDE onto the stiffness matrix mat and a rhs |
378 |
*/ |
379 |
virtual void addPDEToRHS(escript::Data& rhs, |
380 |
const escript::Data& X, const escript::Data& Y, |
381 |
const escript::Data& y, const escript::Data& y_contact) const; |
382 |
|
383 |
/** |
384 |
\brief |
385 |
creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros: |
386 |
*/ |
387 |
SystemMatrixAdapter newSystemMatrix( |
388 |
const int row_blocksize, |
389 |
const escript::FunctionSpace& row_functionspace, |
390 |
const int column_blocksize, |
391 |
const escript::FunctionSpace& column_functionspace, |
392 |
const int type) const; |
393 |
|
394 |
/** |
395 |
\brief returns locations in the FEM nodes |
396 |
*/ |
397 |
virtual escript::Data getX() const; |
398 |
|
399 |
/** |
400 |
\brief return boundary normals at the quadrature point on the face elements |
401 |
*/ |
402 |
virtual escript::Data getNormal() const; |
403 |
|
404 |
/** |
405 |
\brief returns the element size |
406 |
*/ |
407 |
virtual escript::Data getSize() const; |
408 |
|
409 |
/** |
410 |
\brief comparison operators |
411 |
*/ |
412 |
virtual bool operator==(const AbstractDomain& other) const; |
413 |
virtual bool operator!=(const AbstractDomain& other) const; |
414 |
|
415 |
protected: |
416 |
|
417 |
private: |
418 |
|
419 |
// |
420 |
// pointer to the externally created finley mesh |
421 |
boost::shared_ptr<Finley_Mesh> m_finleyMesh; |
422 |
|
423 |
static FunctionSpaceNamesMapType m_functionSpaceTypeNames; |
424 |
|
425 |
}; |
426 |
|
427 |
} // end of namespace |
428 |
|
429 |
#endif |