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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26