/[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 1800 - (show annotations)
Thu Sep 18 05:28:20 2008 UTC (10 years, 7 months ago) by ksteube
File MIME type: text/plain
File size: 16715 byte(s)
Serialized parallel I/O when writing mesh or data to NetCDF file on multiple MPI processors.
Added domain method getMPIComm() to complement getMPISize() and getMPIRank().

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 #include "paso/SolverFCT.h"
26 #include "paso/Paso_MPI.h"
27 }
28
29 #include "FinleyError.h"
30 #include "FinleyAdapterException.h"
31
32 #include "SystemMatrixAdapter.h"
33 #include "TransportProblemAdapter.h"
34 #include "escript/AbstractContinuousDomain.h"
35 #include "escript/FunctionSpace.h"
36 #include "escript/FunctionSpaceFactory.h"
37
38 #include <boost/shared_ptr.hpp>
39 #include <boost/python/dict.hpp>
40 #include <boost/python/extract.hpp>
41
42 #include <map>
43 #include <vector>
44 #include <string>
45 #include <sstream>
46
47 //
48 // forward declarations
49 class Data;
50
51 //using namespace escript;
52
53 namespace finley {
54
55 struct null_deleter
56 {
57 void operator()(void const *ptr) const
58 {
59 }
60 };
61
62
63 /**
64 \brief
65 MeshAdapter implements the AbstractContinuousDomain
66 interface for the Finley library.
67
68 Description:
69 MeshAdapter implements the AbstractContinuousDomain
70 interface for the Finley library.
71 */
72
73 class MeshAdapter : public escript::AbstractContinuousDomain {
74
75 public:
76
77 //
78 // Codes for function space types supported
79 static const int DegreesOfFreedom;
80 static const int ReducedDegreesOfFreedom;
81 static const int Nodes;
82 static const int ReducedNodes;
83 static const int Elements;
84 static const int ReducedElements;
85 static const int FaceElements;
86 static const int ReducedFaceElements;
87 static const int Points;
88 static const int ContactElementsZero;
89 static const int ReducedContactElementsZero;
90 static const int ContactElementsOne;
91 static const int ReducedContactElementsOne;
92
93 /**
94 \brief
95 Constructor for MeshAdapter
96
97 Description:
98 Constructor for MeshAdapter. The pointer passed to MeshAdapter
99 is deleted using a call to Finley_Mesh_free in the
100 MeshAdapter destructor.
101
102 Throws:
103 May throw an exception derived from EsysException
104
105 \param finleyMesh Input - A pointer to the externally constructed
106 finley mesh.The pointer passed to MeshAdapter
107 is deleted using a call to
108 Finley_Mesh_free in the MeshAdapter
109 destructor.
110 */
111 FINLEY_DLL_API
112 MeshAdapter(Finley_Mesh* finleyMesh=0);
113
114 /**
115 \brief
116 Copy constructor.
117 */
118 FINLEY_DLL_API
119 MeshAdapter(const MeshAdapter& in);
120
121 /**
122 \brief
123 Destructor for MeshAdapter. As specified in the constructor
124 this calls Finley_Mesh_free for the pointer given to the
125 constructor.
126 */
127 FINLEY_DLL_API
128 ~MeshAdapter();
129
130 /**
131 \brief
132 return the number of processors used for this domain
133 */
134 FINLEY_DLL_API
135 virtual int getMPISize() const;
136 /**
137 \brief
138 return the number MPI rank of this processor
139 */
140
141 FINLEY_DLL_API
142 virtual int getMPIRank() const;
143
144 /**
145 \brief
146 return the MPI communicator
147 */
148
149 FINLEY_DLL_API
150 virtual MPI_Comm getMPIComm() const;
151
152 /**
153 \brief
154 return this as an AbstractContinuousDomain.
155 */
156 inline const AbstractContinuousDomain& asAbstractContinuousDomain() const
157 {
158 return *(static_cast<const AbstractContinuousDomain*>(this));
159 }
160
161 /**
162 \brief
163 return this as an AbstractDomain.
164 */
165 inline const AbstractDomain& asAbstractDomain() const
166 {
167 return *(static_cast<const AbstractDomain*>(this));
168 }
169
170 /**
171 \brief
172 Write the current mesh to a file with the given name.
173 \param fileName Input - The name of the file to write to.
174 */
175 FINLEY_DLL_API
176 void write(const std::string& fileName) const;
177
178 /**
179 \brief
180 Write the current mesh to a file with the given name.
181 \param fileName Input - The name of the file to write to.
182 */
183 FINLEY_DLL_API
184 void Print_Mesh_Info(const bool) const;
185
186 /**
187 \brief
188 dumps the mesh to a file with the given name.
189 \param fileName Input - The name of the file
190 */
191 FINLEY_DLL_API
192 void dump(const std::string& fileName) const;
193
194 /**
195 \brief
196 return the pointer to the underlying finley mesh structure
197 */
198 FINLEY_DLL_API
199 Finley_Mesh* getFinley_Mesh() const;
200
201 /**
202 \brief
203 Return the tag key for the given sample number.
204 \param functionSpaceType Input - The function space type.
205 \param sampleNo Input - The sample number.
206 */
207 FINLEY_DLL_API
208 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
209
210 /**
211 \brief
212 Return the reference number of the given sample number.
213 \param functionSpaceType Input - The function space type.
214 */
215 FINLEY_DLL_API
216 int* borrowSampleReferenceIDs(int functionSpaceType) const;
217
218 /**
219 \brief
220 Returns true if the given integer is a valid function space type
221 for this domain.
222 */
223 FINLEY_DLL_API
224 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
225
226 /**
227 \brief
228 Return a description for this domain
229 */
230 FINLEY_DLL_API
231 virtual std::string getDescription() const;
232
233 /**
234 \brief
235 Return a description for the given function space type code
236 */
237 FINLEY_DLL_API
238 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
239
240 /**
241 \brief
242 Build the table of function space type names
243 */
244 FINLEY_DLL_API
245 void setFunctionSpaceTypeNames();
246
247 /**
248 \brief
249 Return a continuous FunctionSpace code
250 */
251 FINLEY_DLL_API
252 virtual int getContinuousFunctionCode() const;
253
254 /**
255 \brief
256 Return a continuous on reduced order nodes FunctionSpace code
257 */
258 FINLEY_DLL_API
259 virtual int getReducedContinuousFunctionCode() const;
260
261 /**
262 \brief
263 Return a function FunctionSpace code
264 */
265 FINLEY_DLL_API
266 virtual int getFunctionCode() const;
267
268 /**
269 \brief
270 Return a function with reduced integration order FunctionSpace code
271 */
272 FINLEY_DLL_API
273 virtual int getReducedFunctionCode() const;
274
275 /**
276 \brief
277 Return a function on boundary FunctionSpace code
278 */
279 FINLEY_DLL_API
280 virtual int getFunctionOnBoundaryCode() const;
281
282 /**
283 \brief
284 Return a function on boundary with reduced integration order FunctionSpace code
285 */
286 FINLEY_DLL_API
287 virtual int getReducedFunctionOnBoundaryCode() const;
288
289 /**
290 \brief
291 Return a FunctionOnContactZero code
292 */
293 FINLEY_DLL_API
294 virtual int getFunctionOnContactZeroCode() const;
295
296 /**
297 \brief
298 Return a FunctionOnContactZero code with reduced integration order
299 */
300 FINLEY_DLL_API
301 virtual int getReducedFunctionOnContactZeroCode() const;
302
303 /**
304 \brief
305 Return a FunctionOnContactOne code
306 */
307 FINLEY_DLL_API
308 virtual int getFunctionOnContactOneCode() const;
309
310 /**
311 \brief
312 Return a FunctionOnContactOne code with reduced integration order
313 */
314 FINLEY_DLL_API
315 virtual int getReducedFunctionOnContactOneCode() const;
316
317 /**
318 \brief
319 Return a Solution code
320 */
321 FINLEY_DLL_API
322 virtual int getSolutionCode() const;
323
324 /**
325 \brief
326 Return a ReducedSolution code
327 */
328 FINLEY_DLL_API
329 virtual int getReducedSolutionCode() const;
330
331 /**
332 \brief
333 Return a DiracDeltaFunction code
334 */
335 FINLEY_DLL_API
336 virtual int getDiracDeltaFunctionCode() const;
337
338 /**
339 5B
340 \brief
341 */
342 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
343
344 /**
345 \brief
346 */
347 FINLEY_DLL_API
348 virtual int getDim() const;
349
350 /**
351 \brief
352 Return the number of data points summed across all MPI processes
353 */
354 FINLEY_DLL_API
355 virtual int getNumDataPointsGlobal() const;
356
357 /**
358 \brief
359 Return the number of data points per sample, and the number of samples as a pair.
360 \param functionSpaceCode Input -
361 */
362 FINLEY_DLL_API
363 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
364
365 /**
366 \brief
367 copies the location of data points into arg. The domain of arg has to match this.
368 has to be implemented by the actual Domain adapter.
369 */
370 FINLEY_DLL_API
371 virtual void setToX(escript::Data& arg) const;
372
373 /**
374 \brief
375 sets a map from a clear tag name to a tag key
376 \param name Input - tag name.
377 \param tag Input - tag key.
378 */
379 FINLEY_DLL_API
380 virtual void setTagMap(const std::string& name, int tag);
381
382 /**
383 \brief
384 Return the tag key for tag name.
385 \param name Input - tag name
386 */
387 FINLEY_DLL_API
388 virtual int getTag(const std::string& name) const;
389
390 /**
391 \brief
392 Returns true if name is a defined tage name.
393 \param name Input - tag name to be checked.
394 */
395 FINLEY_DLL_API
396 virtual bool isValidTagName(const std::string& name) const;
397
398 /**
399 \brief
400 Returns all tag names in a single string sperated by commas
401 */
402 FINLEY_DLL_API
403 virtual std::string showTagNames() const;
404
405 /**
406 \brief
407 assigns new location to the domain
408 */
409 FINLEY_DLL_API
410 virtual void setNewX(const escript::Data& arg);
411
412 /**
413 \brief
414 interpolates data given on source onto target where source and target have to be given on the same domain.
415 */
416 FINLEY_DLL_API
417 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
418 FINLEY_DLL_API
419 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
420
421 /**
422 \brief
423 interpolates data given on source onto target where source and target are given on different domains.
424 has to be implemented by the actual Domain adapter.
425 */
426 FINLEY_DLL_API
427 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
428 FINLEY_DLL_API
429 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
430
431 /**
432 \brief
433 copies the surface normals at data points into out. The actual function space to be considered
434 is defined by out. out has to be defined on this.
435 */
436 FINLEY_DLL_API
437 virtual void setToNormal(escript::Data& out) const;
438
439 /**
440 \brief
441 copies the size of samples into out. The actual function space to be considered
442 is defined by out. out has to be defined on this.
443 */
444 FINLEY_DLL_API
445 virtual void setToSize(escript::Data& out) const;
446
447 /**
448 \brief
449 copies the gradient of arg into grad. The actual function space to be considered
450 for the gradient is defined by grad. arg and grad have to be defined on this.
451 */
452 FINLEY_DLL_API
453 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
454
455 /**
456 \brief
457 copies the integrals of the function defined by arg into integrals.
458 arg has to be defined on this.
459 */
460 FINLEY_DLL_API
461 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
462
463 /**
464 \brief
465 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
466 and symmetric matrix is used.
467 \param solver
468 \param symmetry
469 */
470 FINLEY_DLL_API
471 virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
472
473 /**
474 \brief
475 returns true if data on this domain and a function space of type functionSpaceCode has to
476 considered as cell centered data.
477 */
478 FINLEY_DLL_API
479 virtual bool isCellOriented(int functionSpaceCode) const;
480
481 /**
482 \brief
483 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
484
485 This has to be implemented by the actual Domain adapter.
486 */
487 FINLEY_DLL_API
488 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
489
490
491 /**
492 \brief
493 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
494
495 This has to be implemented by the actual Domain adapter.
496 */
497 FINLEY_DLL_API
498 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
499
500 /**
501 \brief
502 returns the function space representation of the type functionSpaceCode on this domain
503 as a vtkObject.
504 */
505 // vtkObject createVtkObject(int functionSpaceCode) const;
506
507 /**
508 \brief
509 adds a PDE onto the stiffness matrix mat and a rhs
510 */
511 FINLEY_DLL_API
512 virtual void addPDEToSystem(
513 SystemMatrixAdapter& mat, escript::Data& rhs,
514 const escript::Data& A, const escript::Data& B, const escript::Data& C,
515 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
516 const escript::Data& d, const escript::Data& y,
517 const escript::Data& d_contact, const escript::Data& y_contact) const;
518 /**
519 \brief
520 adds a PDE onto the lumped stiffness matrix matrix
521 */
522 FINLEY_DLL_API
523 virtual void addPDEToLumpedSystem(
524 escript::Data& mat,
525 const escript::Data& D,
526 const escript::Data& d) const;
527
528 /**
529 \brief
530 adds a PDE onto the stiffness matrix mat and a rhs
531 */
532 FINLEY_DLL_API
533 virtual void addPDEToRHS(escript::Data& rhs,
534 const escript::Data& X, const escript::Data& Y,
535 const escript::Data& y, const escript::Data& y_contact) const;
536 /**
537 \brief
538 adds a PDE onto a transport problem
539 */
540
541 FINLEY_DLL_API
542 virtual void addPDEToTransportProblem(
543 TransportProblemAdapter& tp, escript::Data& source,
544 const escript::Data& M,
545 const escript::Data& A, const escript::Data& B, const escript::Data& C,const escript::Data& D,
546 const escript::Data& X,const escript::Data& Y,
547 const escript::Data& d, const escript::Data& y,
548 const escript::Data& d_contact,const escript::Data& y_contact) const;
549
550
551 /**
552 \brief
553 creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros:
554 */
555 FINLEY_DLL_API
556 SystemMatrixAdapter newSystemMatrix(
557 const int row_blocksize,
558 const escript::FunctionSpace& row_functionspace,
559 const int column_blocksize,
560 const escript::FunctionSpace& column_functionspace,
561 const int type) const;
562 /**
563 \brief
564 creates a TransportProblemAdapter
565
566 */
567
568 FINLEY_DLL_API
569 TransportProblemAdapter newTransportProblem(
570 const double theta,
571 const int blocksize,
572 const escript::FunctionSpace& functionspace,
573 const int type) const;
574
575 /**
576 \brief returns locations in the FEM nodes
577 */
578 FINLEY_DLL_API
579 virtual escript::Data getX() const;
580
581 /**
582 \brief return boundary normals at the quadrature point on the face elements
583 */
584 FINLEY_DLL_API
585 virtual escript::Data getNormal() const;
586
587 /**
588 \brief returns the element size
589 */
590 FINLEY_DLL_API
591 virtual escript::Data getSize() const;
592
593 /**
594 \brief comparison operators
595 */
596 FINLEY_DLL_API
597 virtual bool operator==(const AbstractDomain& other) const;
598 FINLEY_DLL_API
599 virtual bool operator!=(const AbstractDomain& other) const;
600
601 /**
602 \brief assigns new tag newTag to all samples of functionspace with a positive
603 value of mask for any its sample point.
604
605 */
606 FINLEY_DLL_API
607 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
608
609 /**
610 \brief
611 return the number of tags in use and a pointer to an array with the number of tags in use
612 */
613 FINLEY_DLL_API
614 virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
615
616 FINLEY_DLL_API
617 virtual int* borrowListOfTagsInUse(int functionSpaceCode) const;
618
619 protected:
620
621 private:
622
623 //
624 // pointer to the externally created finley mesh
625 boost::shared_ptr<Finley_Mesh> m_finleyMesh;
626
627 static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
628
629 };
630
631 } // end of namespace
632
633 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26