/[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 480 - (show annotations)
Wed Feb 1 05:15:12 2006 UTC (12 years, 11 months ago) by jgs
File MIME type: text/plain
File size: 12545 byte(s)
rationalise #includes and forward declarations

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26