/[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 1312 - (show annotations)
Mon Sep 24 06:18:44 2007 UTC (11 years, 4 months ago) by ksteube
File MIME type: text/plain
File size: 14939 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26