/[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 472 - (show annotations)
Fri Jan 27 01:50:59 2006 UTC (13 years, 2 months ago) by jgs
Original Path: trunk/finley/src/CPPAdapter/MeshAdapter.h
File MIME type: text/plain
File size: 12678 byte(s)
rationalise all #includes

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26