1 |
jgs |
82 |
/* |
2 |
|
|
****************************************************************************** |
3 |
|
|
* * |
4 |
|
|
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
5 |
|
|
* * |
6 |
|
|
* This software is the property of ACcESS. No part of this code * |
7 |
|
|
* may be copied in any form or by any means without the expressed written * |
8 |
|
|
* consent of ACcESS. Copying, use or modification of this software * |
9 |
|
|
* by any unauthorised person is illegal unless that person has a software * |
10 |
|
|
* license agreement with ACcESS. * |
11 |
|
|
* * |
12 |
|
|
****************************************************************************** |
13 |
|
|
*/ |
14 |
|
|
|
15 |
|
|
#if !defined finley_MeshAdapter_20040526_H |
16 |
|
|
#define finley_MeshAdapter_20040526_H |
17 |
|
|
|
18 |
|
|
#include "escript/Data/AbstractContinuousDomain.h" |
19 |
|
|
#include "escript/Data/Data.h" |
20 |
|
|
#include "escript/Data/FunctionSpace.h" |
21 |
|
|
extern "C" { |
22 |
|
|
#include "finley/finleyC/Mesh.h" |
23 |
|
|
} |
24 |
|
|
#include "finley/CPPAdapter/SystemMatrixAdapter.h" |
25 |
|
|
#include <boost/shared_ptr.hpp> |
26 |
|
|
#include <boost/python/object.hpp> |
27 |
|
|
#include <map> |
28 |
|
|
#include <vector> |
29 |
|
|
#include <string> |
30 |
|
|
|
31 |
|
|
namespace finley { |
32 |
|
|
|
33 |
|
|
/** |
34 |
|
|
\brief |
35 |
|
|
MeshAdapter implements the AbstractContinuousDomain |
36 |
|
|
interface for the Finley library. |
37 |
|
|
|
38 |
|
|
Description: |
39 |
|
|
MeshAdapter implements the AbstractContinuousDomain |
40 |
|
|
interface for the Finley library. |
41 |
|
|
*/ |
42 |
|
|
|
43 |
|
|
class MeshAdapter:public escript::AbstractContinuousDomain { |
44 |
|
|
|
45 |
|
|
public: |
46 |
|
|
|
47 |
|
|
// |
48 |
|
|
// Codes for function space types supported |
49 |
|
|
static const int DegreesOfFreedom; |
50 |
|
|
static const int ReducedDegreesOfFreedom; |
51 |
|
|
static const int Nodes; |
52 |
|
|
static const int Elements; |
53 |
|
|
static const int FaceElements; |
54 |
|
|
static const int Points; |
55 |
|
|
static const int ContactElementsZero; |
56 |
|
|
static const int ContactElementsOne; |
57 |
|
|
|
58 |
|
|
/** |
59 |
|
|
\brief |
60 |
|
|
Constructor for MeshAdapter |
61 |
|
|
|
62 |
|
|
Description: |
63 |
|
|
Constructor for MeshAdapter. The pointer passed to MeshAdapter |
64 |
|
|
is deleted using a call to Finley_Mesh_deallocate in the |
65 |
|
|
MeshAdapter destructor. |
66 |
|
|
|
67 |
|
|
Throws: |
68 |
|
|
May throw an exception derived from EsysException |
69 |
|
|
|
70 |
|
|
\param finleyMesh Input - A pointer to the externally constructed |
71 |
|
|
finley mesh.The pointer passed to MeshAdapter |
72 |
|
|
is deleted using a call to |
73 |
|
|
Finley_Mesh_deallocate in the MeshAdapter |
74 |
|
|
destructor. |
75 |
|
|
*/ |
76 |
|
|
MeshAdapter(Finley_Mesh* finleyMesh=0); |
77 |
|
|
/** |
78 |
|
|
\brief |
79 |
|
|
Copy constructor. |
80 |
|
|
*/ |
81 |
|
|
MeshAdapter(const MeshAdapter& in); |
82 |
|
|
/** |
83 |
|
|
\brief |
84 |
|
|
Destructor for MeshAdapter. As specified in the constructor |
85 |
|
|
this calls Finley_Mesh_deallocate for the pointer given to the |
86 |
|
|
constructor. |
87 |
|
|
*/ |
88 |
|
|
~MeshAdapter(); |
89 |
|
|
/** |
90 |
|
|
\brief |
91 |
|
|
return this as an AbstractContinuousDomain. |
92 |
|
|
*/ |
93 |
|
|
inline const AbstractContinuousDomain& asAbstractContinuousDomain() const |
94 |
|
|
{ |
95 |
|
|
return *(static_cast<const AbstractContinuousDomain*>(this)); |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
/** |
99 |
|
|
\brief |
100 |
|
|
return this as an AbstractDomain. |
101 |
|
|
*/ |
102 |
|
|
inline const AbstractDomain& asAbstractDomain() const |
103 |
|
|
{ |
104 |
|
|
return *(static_cast<const AbstractDomain*>(this)); |
105 |
|
|
} |
106 |
|
|
/** |
107 |
|
|
\brief |
108 |
|
|
Write the current mesh to a file with the given name. |
109 |
|
|
\param fileName Input - The name of the file to write to. |
110 |
|
|
*/ |
111 |
|
|
void write(const std::string& fileName) const; |
112 |
|
|
/** |
113 |
|
|
\brief |
114 |
|
|
return the pointer of the underlying finley mesh structure |
115 |
|
|
*/ |
116 |
|
|
Finley_Mesh* getFinley_Mesh() const; |
117 |
|
|
/** |
118 |
|
|
\brief |
119 |
|
|
Return the tag list indexed by sampleNo. |
120 |
|
|
\param functionSpaceType Input |
121 |
|
|
\param tagList Output |
122 |
|
|
\param numTags Output |
123 |
|
|
*/ |
124 |
|
|
|
125 |
|
|
void getTagList(int functionSpaceType, int** tagList, |
126 |
|
|
int* numTags) const; |
127 |
|
|
/** |
128 |
|
|
\brief |
129 |
|
|
Returns true if the given integer is a valid function space type |
130 |
|
|
for this domain. |
131 |
|
|
*/ |
132 |
|
|
virtual bool isValidFunctionSpaceType(int functionSpaceType) const; |
133 |
|
|
/** |
134 |
|
|
\brief |
135 |
|
|
Return a description for this domain |
136 |
|
|
*/ |
137 |
|
|
virtual std::string getDescription() const; |
138 |
|
|
/** |
139 |
|
|
\brief |
140 |
|
|
Return a description for the given function space type code |
141 |
|
|
*/ |
142 |
|
|
virtual std::string functionSpaceTypeAsString(int functionSpaceType) const; |
143 |
|
|
/** |
144 |
|
|
\brief |
145 |
|
|
Return the tag key for the given sample number. |
146 |
|
|
\param functionSpaceType Input - The function space type. |
147 |
|
|
\param sampleNo Input - The sample number. |
148 |
|
|
*/ |
149 |
|
|
virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const; |
150 |
|
|
/** |
151 |
|
|
\brief |
152 |
|
|
Build the table of function space type names |
153 |
|
|
*/ |
154 |
|
|
void setFunctionSpaceTypeNames(); |
155 |
|
|
/** |
156 |
|
|
\brief |
157 |
|
|
Return a continuous FunctionSpace code |
158 |
|
|
*/ |
159 |
|
|
virtual int getContinuousFunctionCode() const; |
160 |
|
|
/** |
161 |
|
|
\brief |
162 |
|
|
Return a functon FunctionSpace code |
163 |
|
|
*/ |
164 |
|
|
virtual int getFunctionCode() const; |
165 |
|
|
/** |
166 |
|
|
\brief |
167 |
|
|
Return a function on boundary FunctionSpace code |
168 |
|
|
*/ |
169 |
|
|
virtual int getFunctionOnBoundaryCode() const; |
170 |
|
|
/** |
171 |
|
|
\brief |
172 |
|
|
Return a FunctionOnContactZero code |
173 |
|
|
*/ |
174 |
|
|
virtual int getFunctionOnContactZeroCode() const; |
175 |
|
|
/** |
176 |
|
|
\brief |
177 |
|
|
Return a FunctionOnContactOne code |
178 |
|
|
*/ |
179 |
|
|
virtual int getFunctionOnContactOneCode() const; |
180 |
|
|
/** |
181 |
|
|
\brief |
182 |
|
|
Return a Solution code |
183 |
|
|
*/ |
184 |
|
|
virtual int getSolutionCode() const; |
185 |
|
|
/** |
186 |
|
|
\brief |
187 |
|
|
Return a ReducedSolution code |
188 |
|
|
*/ |
189 |
|
|
virtual int getReducedSolutionCode() const; |
190 |
|
|
/** |
191 |
|
|
\brief |
192 |
|
|
Return a DiracDeltaFunction code |
193 |
|
|
*/ |
194 |
|
|
virtual int getDiracDeltaFunctionCode() const; |
195 |
|
|
// |
196 |
|
|
// |
197 |
|
|
typedef std::map<int, std::string> FunctionSpaceNamesMapType; |
198 |
|
|
/** |
199 |
|
|
\brief |
200 |
|
|
*/ |
201 |
|
|
virtual int getDim() const; |
202 |
|
|
/** |
203 |
|
|
\brief |
204 |
|
|
Return the number of data points per sample, and the number of samples as a pair. |
205 |
|
|
\param functionSpace Input - |
206 |
|
|
*/ |
207 |
|
|
virtual std::pair<int,int> getDataShape(int functionSpaceCode) const; |
208 |
|
|
|
209 |
|
|
/** |
210 |
|
|
\brief |
211 |
|
|
copies the location of data points into arg. The domain of arg has to match this. |
212 |
|
|
has to be implemented by the actual Domain adapter. |
213 |
|
|
*/ |
214 |
|
|
virtual void setToX(escript::Data& arg) const; |
215 |
|
|
/** |
216 |
|
|
\brief |
217 |
|
|
assigns new location to the domain |
218 |
|
|
*/ |
219 |
|
|
virtual void setNewX(const escript::Data& arg); |
220 |
|
|
/** |
221 |
|
|
\brief |
222 |
|
|
interpolates data given on source onto target where source and target have to be given on the same domain. |
223 |
|
|
*/ |
224 |
|
|
virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const; |
225 |
|
|
virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const; |
226 |
|
|
/** |
227 |
|
|
\brief |
228 |
|
|
interpolates data given on source onto target where source and target are given on different domains. |
229 |
|
|
has to be implemented by the actual Domain adapter. |
230 |
|
|
*/ |
231 |
|
|
virtual void interpolateACross(escript::Data& target, const escript::Data& source) const; |
232 |
|
|
virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const; |
233 |
|
|
/** |
234 |
|
|
\brief |
235 |
|
|
copies the surface normals at data points into out. The actual function space to be considered |
236 |
|
|
is defined by out. out has to be defined on this. |
237 |
|
|
*/ |
238 |
|
|
virtual void setToNormal(escript::Data& out) const; |
239 |
|
|
/** |
240 |
|
|
\brief |
241 |
|
|
copies the size of samples into out. The actual function space to be considered |
242 |
|
|
is defined by out. out has to be defined on this. |
243 |
|
|
*/ |
244 |
|
|
virtual void setToSize(escript::Data& out) const; |
245 |
|
|
|
246 |
|
|
/** |
247 |
|
|
\brief |
248 |
|
|
copies the gradient of arg into grad. The actual function space to be considered |
249 |
|
|
for the gradient is defined by grad. arg and grad have to be defined on this. |
250 |
|
|
*/ |
251 |
|
|
virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const; |
252 |
|
|
|
253 |
|
|
/** |
254 |
|
|
\brief |
255 |
|
|
copies the integrals of the function defined by arg into integrals. |
256 |
|
|
arg has to be defined on this. |
257 |
|
|
*/ |
258 |
|
|
virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const; |
259 |
|
|
|
260 |
|
|
/** |
261 |
|
|
\brief |
262 |
|
|
returns true if data on this domain and a function space of type functionSpaceCode has to |
263 |
|
|
considered as cell centered data. |
264 |
|
|
*/ |
265 |
|
|
virtual bool isCellOriented(int functionSpaceCode) const; |
266 |
|
|
/** |
267 |
|
|
\brief |
268 |
|
|
saves data arg to a OpenDX input file. |
269 |
|
|
considered as cell centered data. |
270 |
|
|
*/ |
271 |
|
|
virtual void saveDX(const std::string& filename,const escript::Data& arg) const; |
272 |
|
|
/** |
273 |
|
|
\brief |
274 |
|
|
returns the function space representation of the type functionSpaceCode on this domain |
275 |
|
|
as a vtkObject. |
276 |
|
|
*/ |
277 |
|
|
// vtkObject createVtkObject(int functionSpaceCode) const; |
278 |
|
|
/** |
279 |
|
|
\brief |
280 |
|
|
adds a PDE onto the stiffness matrix mat and a rhs |
281 |
|
|
*/ |
282 |
|
|
virtual void addPDEToSystem( |
283 |
|
|
SystemMatrixAdapter& mat, escript::Data& rhs, |
284 |
|
|
const escript::Data& A, const escript::Data& B, const escript::Data& C, |
285 |
|
|
const escript::Data& D, const escript::Data& X, const escript::Data& Y) const; |
286 |
|
|
|
287 |
|
|
/** |
288 |
|
|
\brief |
289 |
|
|
adds a Robin boundary condition onto the stiffness matrix mat and a rhs |
290 |
|
|
*/ |
291 |
|
|
virtual void addRobinConditionsToSystem( |
292 |
|
|
SystemMatrixAdapter& mat, escript::Data& rhs, |
293 |
|
|
const escript::Data& d, const escript::Data& y) const; |
294 |
|
|
|
295 |
|
|
/** |
296 |
|
|
\brief |
297 |
|
|
adds a contact condition onto the stiffness matrix mat and a rhs |
298 |
|
|
*/ |
299 |
|
|
virtual void addContactToSystem( |
300 |
|
|
SystemMatrixAdapter& mat, escript::Data& rhs, |
301 |
|
|
const escript::Data& d, const escript::Data& y) const; |
302 |
|
|
|
303 |
|
|
/** |
304 |
|
|
\brief |
305 |
|
|
creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros: |
306 |
|
|
*/ |
307 |
|
|
SystemMatrixAdapter newSystemMatrix( |
308 |
|
|
const int row_blocksize, |
309 |
|
|
const escript::FunctionSpace& row_functionspace, |
310 |
|
|
const int column_blocksize, |
311 |
|
|
const escript::FunctionSpace& column_functionspace, |
312 |
|
|
const int type, |
313 |
|
|
const bool sym) const; |
314 |
|
|
|
315 |
|
|
// `virtual bool operator==(const escript::AbstractDomain& other) const; |
316 |
|
|
bool operator==(const MeshAdapter& other) const; |
317 |
|
|
bool operator!=(const MeshAdapter& other) const; |
318 |
|
|
protected: |
319 |
|
|
|
320 |
|
|
private: |
321 |
|
|
// |
322 |
|
|
// pointer to the externally created finley mesh |
323 |
|
|
boost::shared_ptr<Finley_Mesh> m_finleyMesh; |
324 |
|
|
|
325 |
|
|
static FunctionSpaceNamesMapType m_functionSpaceTypeNames; |
326 |
|
|
|
327 |
|
|
}; |
328 |
|
|
|
329 |
|
|
} // end of namespace |
330 |
|
|
#endif |