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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 149 - (show annotations)
Thu Sep 1 03:31:39 2005 UTC (13 years, 6 months ago) by jgs
Original Path: trunk/esys2/finley/src/CPPAdapter/MeshAdapter.h
File MIME type: text/plain
File size: 11802 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-01

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26