/[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 1339 - (show annotations)
Wed Nov 7 01:53:12 2007 UTC (11 years, 2 months ago) by ksteube
File MIME type: text/plain
File size: 15144 byte(s)
Modified scons target release_src to include lib/ and include/ since
their presence is required for a build.  Modified
mydomain.print_mesh_info(True) to include more useful info about a
distributed domain.  Added mypde.getOperator().print_matrix_info(True)
to tell about a distributed matrix.


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 Write the current mesh to a file with the given name.
170 \param fileName Input - The name of the file to write to.
171 */
172 FINLEY_DLL_API
173 void Print_Mesh_Info(const bool) const;
174
175 /**
176 \brief
177 dumps the mesh to a file with the given name.
178 \param fileName Input - The name of the file
179 */
180 FINLEY_DLL_API
181 void dump(const std::string& fileName) const;
182
183 /**
184 \brief
185 return the pointer to the underlying finley mesh structure
186 */
187 FINLEY_DLL_API
188 Finley_Mesh* getFinley_Mesh() const;
189
190 /**
191 \brief
192 Return the tag key for the given sample number.
193 \param functionSpaceType Input - The function space type.
194 \param sampleNo Input - The sample number.
195 */
196 FINLEY_DLL_API
197 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
198
199 /**
200 \brief
201 Return the reference number of the given sample number.
202 \param functionSpaceType Input - The function space type.
203 */
204 FINLEY_DLL_API
205 int* borrowSampleReferenceIDs(int functionSpaceType) const;
206
207 /**
208 \brief
209 Returns true if the given integer is a valid function space type
210 for this domain.
211 */
212 FINLEY_DLL_API
213 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
214
215 /**
216 \brief
217 Return a description for this domain
218 */
219 FINLEY_DLL_API
220 virtual std::string getDescription() const;
221
222 /**
223 \brief
224 Return a description for the given function space type code
225 */
226 FINLEY_DLL_API
227 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
228
229 /**
230 \brief
231 Build the table of function space type names
232 */
233 FINLEY_DLL_API
234 void setFunctionSpaceTypeNames();
235
236 /**
237 \brief
238 Return a continuous FunctionSpace code
239 */
240 FINLEY_DLL_API
241 virtual int getContinuousFunctionCode() const;
242
243 /**
244 \brief
245 Return a continuous on reduced order nodes FunctionSpace code
246 */
247 FINLEY_DLL_API
248 virtual int getReducedContinuousFunctionCode() const;
249
250 /**
251 \brief
252 Return a function FunctionSpace code
253 */
254 FINLEY_DLL_API
255 virtual int getFunctionCode() const;
256
257 /**
258 \brief
259 Return a function with reduced integration order FunctionSpace code
260 */
261 FINLEY_DLL_API
262 virtual int getReducedFunctionCode() const;
263
264 /**
265 \brief
266 Return a function on boundary FunctionSpace code
267 */
268 FINLEY_DLL_API
269 virtual int getFunctionOnBoundaryCode() const;
270
271 /**
272 \brief
273 Return a function on boundary with reduced integration order FunctionSpace code
274 */
275 FINLEY_DLL_API
276 virtual int getReducedFunctionOnBoundaryCode() const;
277
278 /**
279 \brief
280 Return a FunctionOnContactZero code
281 */
282 FINLEY_DLL_API
283 virtual int getFunctionOnContactZeroCode() const;
284
285 /**
286 \brief
287 Return a FunctionOnContactZero code with reduced integration order
288 */
289 FINLEY_DLL_API
290 virtual int getReducedFunctionOnContactZeroCode() const;
291
292 /**
293 \brief
294 Return a FunctionOnContactOne code
295 */
296 FINLEY_DLL_API
297 virtual int getFunctionOnContactOneCode() const;
298
299 /**
300 \brief
301 Return a FunctionOnContactOne code with reduced integration order
302 */
303 FINLEY_DLL_API
304 virtual int getReducedFunctionOnContactOneCode() const;
305
306 /**
307 \brief
308 Return a Solution code
309 */
310 FINLEY_DLL_API
311 virtual int getSolutionCode() const;
312
313 /**
314 \brief
315 Return a ReducedSolution code
316 */
317 FINLEY_DLL_API
318 virtual int getReducedSolutionCode() const;
319
320 /**
321 \brief
322 Return a DiracDeltaFunction code
323 */
324 FINLEY_DLL_API
325 virtual int getDiracDeltaFunctionCode() const;
326
327 /**
328 5B
329 \brief
330 */
331 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
332
333 /**
334 \brief
335 */
336 FINLEY_DLL_API
337 virtual int getDim() const;
338
339 /**
340 \brief
341 Return the number of data points per sample, and the number of samples as a pair.
342 \param functionSpaceCode Input -
343 */
344 FINLEY_DLL_API
345 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
346
347 /**
348 \brief
349 copies the location of data points into arg. The domain of arg has to match this.
350 has to be implemented by the actual Domain adapter.
351 */
352 FINLEY_DLL_API
353 virtual void setToX(escript::Data& arg) const;
354
355 /**
356 \brief
357 sets a map from a clear tag name to a tag key
358 \param name Input - tag name.
359 \param tag Input - tag key.
360 */
361 FINLEY_DLL_API
362 virtual void setTagMap(const std::string& name, int tag);
363
364 /**
365 \brief
366 Return the tag key for tag name.
367 \param name Input - tag name
368 */
369 FINLEY_DLL_API
370 virtual int getTag(const std::string& name) const;
371
372 /**
373 \brief
374 Returns true if name is a defined tage name.
375 \param name Input - tag name to be checked.
376 */
377 FINLEY_DLL_API
378 virtual bool isValidTagName(const std::string& name) const;
379
380 /**
381 \brief
382 Returns all tag names in a single string sperated by commas
383 */
384 FINLEY_DLL_API
385 virtual std::string showTagNames() const;
386
387 /**
388 \brief
389 assigns new location to the domain
390 */
391 FINLEY_DLL_API
392 virtual void setNewX(const escript::Data& arg);
393
394 /**
395 \brief
396 interpolates data given on source onto target where source and target have to be given on the same domain.
397 */
398 FINLEY_DLL_API
399 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
400 FINLEY_DLL_API
401 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
402
403 /**
404 \brief
405 interpolates data given on source onto target where source and target are given on different domains.
406 has to be implemented by the actual Domain adapter.
407 */
408 FINLEY_DLL_API
409 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
410 FINLEY_DLL_API
411 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
412
413 /**
414 \brief
415 copies the surface normals at data points 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 setToNormal(escript::Data& out) const;
420
421 /**
422 \brief
423 copies the size of samples into out. The actual function space to be considered
424 is defined by out. out has to be defined on this.
425 */
426 FINLEY_DLL_API
427 virtual void setToSize(escript::Data& out) const;
428
429 /**
430 \brief
431 copies the gradient of arg into grad. The actual function space to be considered
432 for the gradient is defined by grad. arg and grad have to be defined on this.
433 */
434 FINLEY_DLL_API
435 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
436
437 /**
438 \brief
439 copies the integrals of the function defined by arg into integrals.
440 arg has to be defined on this.
441 */
442 FINLEY_DLL_API
443 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
444
445 /**
446 \brief
447 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
448 and symmetric matrix is used.
449 \param solver
450 \param symmetry
451 */
452 FINLEY_DLL_API
453 virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
454
455 /**
456 \brief
457 returns true if data on this domain and a function space of type functionSpaceCode has to
458 considered as cell centered data.
459 */
460 FINLEY_DLL_API
461 virtual bool isCellOriented(int functionSpaceCode) const;
462
463 /**
464 \brief
465 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
466
467 This has to be implemented by the actual Domain adapter.
468 */
469 FINLEY_DLL_API
470 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
471
472
473 /**
474 \brief
475 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
476
477 This has to be implemented by the actual Domain adapter.
478 */
479 FINLEY_DLL_API
480 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
481
482 /**
483 \brief
484 returns the function space representation of the type functionSpaceCode on this domain
485 as a vtkObject.
486 */
487 // vtkObject createVtkObject(int functionSpaceCode) const;
488
489 /**
490 \brief
491 adds a PDE onto the stiffness matrix mat and a rhs
492 */
493 FINLEY_DLL_API
494 virtual void addPDEToSystem(
495 SystemMatrixAdapter& mat, escript::Data& rhs,
496 const escript::Data& A, const escript::Data& B, const escript::Data& C,
497 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
498 const escript::Data& d, const escript::Data& y,
499 const escript::Data& d_contact, const escript::Data& y_contact) const;
500 /**
501 \brief
502 adds a PDE onto the lumped stiffness matrix matrix
503 */
504 FINLEY_DLL_API
505 virtual void addPDEToLumpedSystem(
506 escript::Data& mat,
507 const escript::Data& D,
508 const escript::Data& d) const;
509
510 /**
511 \brief
512 adds a PDE onto the stiffness matrix mat and a rhs
513 */
514 FINLEY_DLL_API
515 virtual void addPDEToRHS(escript::Data& rhs,
516 const escript::Data& X, const escript::Data& Y,
517 const escript::Data& y, const escript::Data& y_contact) const;
518
519 /**
520 \brief
521 creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
522 */
523 FINLEY_DLL_API
524 SystemMatrixAdapter newSystemMatrix(
525 const int row_blocksize,
526 const escript::FunctionSpace& row_functionspace,
527 const int column_blocksize,
528 const escript::FunctionSpace& column_functionspace,
529 const int type) const;
530
531 /**
532 \brief returns locations in the FEM nodes
533 */
534 FINLEY_DLL_API
535 virtual escript::Data getX() const;
536
537 /**
538 \brief return boundary normals at the quadrature point on the face elements
539 */
540 FINLEY_DLL_API
541 virtual escript::Data getNormal() const;
542
543 /**
544 \brief returns the element size
545 */
546 FINLEY_DLL_API
547 virtual escript::Data getSize() const;
548
549 /**
550 \brief comparison operators
551 */
552 FINLEY_DLL_API
553 virtual bool operator==(const AbstractDomain& other) const;
554 FINLEY_DLL_API
555 virtual bool operator!=(const AbstractDomain& other) const;
556
557 /**
558 \brief assigns new tag newTag to all samples of functionspace with a positive
559 value of mask for any its sample point.
560
561 */
562 FINLEY_DLL_API
563 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
564
565 protected:
566
567 private:
568
569 //
570 // pointer to the externally created finley mesh
571 boost::shared_ptr<Finley_Mesh> m_finleyMesh;
572
573 static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
574
575 };
576
577 } // end of namespace
578
579 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26