/[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 1059 - (show annotations)
Fri Mar 23 11:01:53 2007 UTC (12 years, 1 month ago) by gross
File MIME type: text/plain
File size: 14249 byte(s)
first steps toward reduced element integration order. The escript bit is done but the finley part still needs work.
1 // $Id$
2 /*
3 ************************************************************
4 * Copyright 2006 by ACcESS MNRF *
5 * *
6 * http://www.access.edu.au *
7 * Primary Business: Queensland, Australia *
8 * Licensed under the Open Software License version 3.0 *
9 * http://www.opensource.org/licenses/osl-3.0.php *
10 * *
11 ************************************************************
12 */
13
14 #if !defined finley_MeshAdapter_20040526_H
15 #define finley_MeshAdapter_20040526_H
16 #include "system_dep.h"
17
18 extern "C" {
19 #include "../Mesh.h"
20 #include "../Finley.h"
21 #include "../Assemble.h"
22 #include "paso/SystemMatrix.h"
23 }
24
25 #include "FinleyError.h"
26 #include "FinleyAdapterException.h"
27
28 #include "SystemMatrixAdapter.h"
29 #include "escript/AbstractContinuousDomain.h"
30 #include "escript/FunctionSpace.h"
31 #include "escript/FunctionSpaceFactory.h"
32
33 #include <boost/shared_ptr.hpp>
34 #include <boost/python/dict.hpp>
35 #include <boost/python/extract.hpp>
36
37 #include <map>
38 #include <vector>
39 #include <string>
40 #include <sstream>
41
42 //
43 // forward declarations
44 class Data;
45
46 //using namespace escript;
47
48 namespace finley {
49
50 struct null_deleter
51 {
52 void operator()(void const *ptr) const
53 {
54 }
55 };
56
57
58 /**
59 \brief
60 MeshAdapter implements the AbstractContinuousDomain
61 interface for the Finley library.
62
63 Description:
64 MeshAdapter implements the AbstractContinuousDomain
65 interface for the Finley library.
66 */
67
68 class MeshAdapter : public escript::AbstractContinuousDomain {
69
70 public:
71
72 //
73 // Codes for function space types supported
74 static const int DegreesOfFreedom;
75 static const int ReducedDegreesOfFreedom;
76 static const int Nodes;
77 static const int Elements;
78 static const int ReducedElements;
79 static const int FaceElements;
80 static const int ReducedFaceElements;
81 static const int Points;
82 static const int ContactElementsZero;
83 static const int ReducedContactElementsZero;
84 static const int ContactElementsOne;
85 static const int ReducedContactElementsOne;
86
87 /**
88 \brief
89 Constructor for MeshAdapter
90
91 Description:
92 Constructor for MeshAdapter. The pointer passed to MeshAdapter
93 is deleted using a call to Finley_Mesh_deallocate in the
94 MeshAdapter destructor.
95
96 Throws:
97 May throw an exception derived from EsysException
98
99 \param finleyMesh Input - A pointer to the externally constructed
100 finley mesh.The pointer passed to MeshAdapter
101 is deleted using a call to
102 Finley_Mesh_deallocate in the MeshAdapter
103 destructor.
104 */
105 FINLEY_DLL_API
106 MeshAdapter(Finley_Mesh* finleyMesh=0);
107
108 /**
109 \brief
110 Copy constructor.
111 */
112 FINLEY_DLL_API
113 MeshAdapter(const MeshAdapter& in);
114
115 /**
116 \brief
117 Destructor for MeshAdapter. As specified in the constructor
118 this calls Finley_Mesh_deallocate for the pointer given to the
119 constructor.
120 */
121 FINLEY_DLL_API
122 ~MeshAdapter();
123
124 /**
125 \brief
126 return this as an AbstractContinuousDomain.
127 */
128 inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
129 {
130 return *(static_cast<const AbstractContinuousDomain*>(this));
131 }
132
133 /**
134 \brief
135 return this as an AbstractDomain.
136 */
137 inline const AbstractDomain& asAbstractDomain() const
138 {
139 return *(static_cast<const AbstractDomain*>(this));
140 }
141
142 /**
143 \brief
144 Write the current mesh to a file with the given name.
145 \param fileName Input - The name of the file to write to.
146 */
147 FINLEY_DLL_API
148 void write(const std::string& fileName) const;
149
150 /**
151 \brief
152 return the pointer to the underlying finley mesh structure
153 */
154 FINLEY_DLL_API
155 Finley_Mesh* getFinley_Mesh() const;
156
157 /**
158 \brief
159 Return the tag key for the given sample number.
160 \param functionSpaceType Input - The function space type.
161 \param sampleNo Input - The sample number.
162 */
163 FINLEY_DLL_API
164 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
165
166 /**
167 \brief
168 Return the reference number of the given sample number.
169 \param functionSpaceType Input - The function space type.
170 */
171 FINLEY_DLL_API
172 int* borrowSampleReferenceIDs(int functionSpaceType) const;
173
174 /**
175 \brief
176 Returns true if the given integer is a valid function space type
177 for this domain.
178 */
179 FINLEY_DLL_API
180 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
181
182 /**
183 \brief
184 Return a description for this domain
185 */
186 FINLEY_DLL_API
187 virtual std::string getDescription() const;
188
189 /**
190 \brief
191 Return a description for the given function space type code
192 */
193 FINLEY_DLL_API
194 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
195
196 /**
197 \brief
198 Build the table of function space type names
199 */
200 FINLEY_DLL_API
201 void setFunctionSpaceTypeNames();
202
203 /**
204 \brief
205 Return a continuous FunctionSpace code
206 */
207 FINLEY_DLL_API
208 virtual int getContinuousFunctionCode() const;
209
210 /**
211 \brief
212 Return a function FunctionSpace code
213 */
214 FINLEY_DLL_API
215 virtual int getFunctionCode() const;
216
217 /**
218 \brief
219 Return a function with reduced integration order FunctionSpace code
220 */
221 FINLEY_DLL_API
222 virtual int getReducedFunctionCode() const;
223
224 /**
225 \brief
226 Return a function on boundary FunctionSpace code
227 */
228 FINLEY_DLL_API
229 virtual int getFunctionOnBoundaryCode() const;
230
231 /**
232 \brief
233 Return a function on boundary with reduced integration order FunctionSpace code
234 */
235 FINLEY_DLL_API
236 virtual int getReducedFunctionOnBoundaryCode() const;
237
238 /**
239 \brief
240 Return a FunctionOnContactZero code
241 */
242 FINLEY_DLL_API
243 virtual int getFunctionOnContactZeroCode() const;
244
245 /**
246 \brief
247 Return a FunctionOnContactZero code with reduced integration order
248 */
249 FINLEY_DLL_API
250 virtual int getReducedFunctionOnContactZeroCode() const;
251
252 /**
253 \brief
254 Return a FunctionOnContactOne code
255 */
256 FINLEY_DLL_API
257 virtual int getFunctionOnContactOneCode() const;
258
259 /**
260 \brief
261 Return a FunctionOnContactOne code with reduced integration order
262 */
263 FINLEY_DLL_API
264 virtual int getReducedFunctionOnContactOneCode() const;
265
266 /**
267 \brief
268 Return a Solution code
269 */
270 FINLEY_DLL_API
271 virtual int getSolutionCode() const;
272
273 /**
274 \brief
275 Return a ReducedSolution code
276 */
277 FINLEY_DLL_API
278 virtual int getReducedSolutionCode() const;
279
280 /**
281 \brief
282 Return a DiracDeltaFunction code
283 */
284 FINLEY_DLL_API
285 virtual int getDiracDeltaFunctionCode() const;
286
287 /**
288 5B
289 \brief
290 */
291 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
292
293 /**
294 \brief
295 */
296 FINLEY_DLL_API
297 virtual int getDim() const;
298
299 /**
300 \brief
301 Return the number of data points per sample, and the number of samples as a pair.
302 \param functionSpaceCode Input -
303 */
304 FINLEY_DLL_API
305 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
306
307 /**
308 \brief
309 copies the location of data points into arg. The domain of arg has to match this.
310 has to be implemented by the actual Domain adapter.
311 */
312 FINLEY_DLL_API
313 virtual void setToX(escript::Data& arg) const;
314
315 /**
316 \brief
317 sets a map from a clear tag name to a tag key
318 \param name Input - tag name.
319 \param tag Input - tag key.
320 */
321 FINLEY_DLL_API
322 virtual void setTagMap(const std::string& name, int tag);
323
324 /**
325 \brief
326 Return the tag key for tag name.
327 \param name Input - tag name
328 */
329 FINLEY_DLL_API
330 virtual int getTag(const std::string& name) const;
331
332 /**
333 \brief
334 Returns true if name is a defined tage name.
335 \param name Input - tag name to be checked.
336 */
337 FINLEY_DLL_API
338 virtual bool isValidTagName(const std::string& name) const;
339
340 /**
341 \brief
342 Returns all tag names in a single string sperated by commas
343 */
344 FINLEY_DLL_API
345 virtual std::string showTagNames() const;
346
347 /**
348 \brief
349 assigns new location to the domain
350 */
351 FINLEY_DLL_API
352 virtual void setNewX(const escript::Data& arg);
353
354 /**
355 \brief
356 interpolates data given on source onto target where source and target have to be given on the same domain.
357 */
358 FINLEY_DLL_API
359 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
360 FINLEY_DLL_API
361 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
362
363 /**
364 \brief
365 interpolates data given on source onto target where source and target are given on different domains.
366 has to be implemented by the actual Domain adapter.
367 */
368 FINLEY_DLL_API
369 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
370 FINLEY_DLL_API
371 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
372
373 /**
374 \brief
375 copies the surface normals at data points into out. The actual function space to be considered
376 is defined by out. out has to be defined on this.
377 */
378 FINLEY_DLL_API
379 virtual void setToNormal(escript::Data& out) const;
380
381 /**
382 \brief
383 copies the size of samples into out. The actual function space to be considered
384 is defined by out. out has to be defined on this.
385 */
386 FINLEY_DLL_API
387 virtual void setToSize(escript::Data& out) const;
388
389 /**
390 \brief
391 copies the gradient of arg into grad. The actual function space to be considered
392 for the gradient is defined by grad. arg and grad have to be defined on this.
393 */
394 FINLEY_DLL_API
395 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
396
397 /**
398 \brief
399 copies the integrals of the function defined by arg into integrals.
400 arg has to be defined on this.
401 */
402 FINLEY_DLL_API
403 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
404
405 /**
406 \brief
407 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
408 and symmetric matrix is used.
409 \param solver
410 \param symmetry
411 */
412 FINLEY_DLL_API
413 virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
414
415 /**
416 \brief
417 returns true if data on this domain and a function space of type functionSpaceCode has to
418 considered as cell centered data.
419 */
420 FINLEY_DLL_API
421 virtual bool isCellOriented(int functionSpaceCode) const;
422
423 /**
424 \brief
425 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
426
427 This has to be implemented by the actual Domain adapter.
428 */
429 FINLEY_DLL_API
430 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
431
432
433 /**
434 \brief
435 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
436
437 This has to be implemented by the actual Domain adapter.
438 */
439 FINLEY_DLL_API
440 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
441
442 /**
443 \brief
444 returns the function space representation of the type functionSpaceCode on this domain
445 as a vtkObject.
446 */
447 // vtkObject createVtkObject(int functionSpaceCode) const;
448
449 /**
450 \brief
451 adds a PDE onto the stiffness matrix mat and a rhs
452 */
453 FINLEY_DLL_API
454 virtual void addPDEToSystem(
455 SystemMatrixAdapter& mat, escript::Data& rhs,
456 const escript::Data& A, const escript::Data& B, const escript::Data& C,
457 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
458 const escript::Data& d, const escript::Data& y,
459 const escript::Data& d_contact, const escript::Data& y_contact) const;
460
461 /**
462 \brief
463 adds a PDE onto the stiffness matrix mat and a rhs
464 */
465 FINLEY_DLL_API
466 virtual void addPDEToRHS(escript::Data& rhs,
467 const escript::Data& X, const escript::Data& Y,
468 const escript::Data& y, const escript::Data& y_contact) const;
469
470 /**
471 \brief
472 creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
473 */
474 FINLEY_DLL_API
475 SystemMatrixAdapter newSystemMatrix(
476 const int row_blocksize,
477 const escript::FunctionSpace& row_functionspace,
478 const int column_blocksize,
479 const escript::FunctionSpace& column_functionspace,
480 const int type) const;
481
482 /**
483 \brief returns locations in the FEM nodes
484 */
485 FINLEY_DLL_API
486 virtual escript::Data getX() const;
487
488 /**
489 \brief return boundary normals at the quadrature point on the face elements
490 */
491 FINLEY_DLL_API
492 virtual escript::Data getNormal() const;
493
494 /**
495 \brief returns the element size
496 */
497 FINLEY_DLL_API
498 virtual escript::Data getSize() const;
499
500 /**
501 \brief comparison operators
502 */
503 FINLEY_DLL_API
504 virtual bool operator==(const AbstractDomain& other) const;
505 FINLEY_DLL_API
506 virtual bool operator!=(const AbstractDomain& other) const;
507
508 /**
509 \brief assigns new tag newTag to all samples of functionspace with a positive
510 value of mask for any its sample point.
511
512 */
513 FINLEY_DLL_API
514 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
515
516 protected:
517
518 private:
519
520 //
521 // pointer to the externally created finley mesh
522 boost::shared_ptr<Finley_Mesh> m_finleyMesh;
523
524 static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
525
526 };
527
528 } // end of namespace
529
530 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26