/[escript]/temp_trunk_copy/finley/src/CPPAdapter/MeshAdapter.h
ViewVC logotype

Contents of /temp_trunk_copy/finley/src/CPPAdapter/MeshAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 201 - (show annotations)
Wed Nov 23 04:10:21 2005 UTC (13 years, 4 months ago) by jgs
Original Path: trunk/finley/src/finley/CPPAdapter/MeshAdapter.h
File MIME type: text/plain
File size: 12359 byte(s)
copy finleyC and CPPAdapter to finley and finley/CPPAdapter to
facilitate scons builds

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26