/[escript]/trunk/dudley/src/CPPAdapter/MeshAdapter.h
ViewVC logotype

Contents of /trunk/dudley/src/CPPAdapter/MeshAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3793 - (show annotations)
Wed Feb 1 07:39:43 2012 UTC (7 years, 8 months ago) by gross
File MIME type: text/plain
File size: 18134 byte(s)
new implementation of FCT solver with some modifications to the python interface
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #if !defined dudley_MeshAdapter_20040526_H
16 #define dudley_MeshAdapter_20040526_H
17 #include "system_dep.h"
18
19 extern "C" {
20 #include "dudley/Mesh.h"
21 #include "dudley/Dudley.h"
22 #include "dudley/Assemble.h"
23 #include "esysUtils/Esys_MPI.h"
24 }
25
26 #include "DudleyError.h"
27 #include "DudleyAdapterException.h"
28
29 #include <pasowrap/SystemMatrixAdapter.h>
30 #include <pasowrap/TransportProblemAdapter.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 namespace dudley {
45
46 struct null_deleter
47 {
48 void operator()(void const *ptr) const
49 {
50 }
51 };
52
53
54 /**
55 \brief
56 MeshAdapter implements the AbstractContinuousDomain
57 interface for the Dudley library.
58
59 Description:
60 MeshAdapter implements the AbstractContinuousDomain
61 interface for the Dudley library.
62 */
63
64 class MeshAdapter : public escript::AbstractContinuousDomain {
65
66 public:
67
68 //
69 // Codes for function space types supported
70 static const int DegreesOfFreedom;
71 static const int ReducedDegreesOfFreedom;
72 static const int Nodes;
73 static const int ReducedNodes;
74 static const int Elements;
75 static const int ReducedElements;
76 static const int FaceElements;
77 static const int ReducedFaceElements;
78 static const int Points;
79 static const int ContactElementsZero;
80 static const int ReducedContactElementsZero;
81 static const int ContactElementsOne;
82 static const int ReducedContactElementsOne;
83
84 /**
85 \brief
86 Constructor for MeshAdapter
87
88 Description:
89 Constructor for MeshAdapter. The pointer passed to MeshAdapter
90 is deleted using a call to Dudley_Mesh_free in the
91 MeshAdapter destructor.
92
93 Throws:
94 May throw an exception derived from EsysException
95
96 \param dudleyMesh Input - A pointer to the externally constructed
97 dudley mesh.The pointer passed to MeshAdapter
98 is deleted using a call to
99 Dudley_Mesh_free in the MeshAdapter
100 destructor.
101 */
102 DUDLEY_DLL_API
103 MeshAdapter(Dudley_Mesh* dudleyMesh=0);
104
105 /**
106 \brief
107 Copy constructor.
108 */
109 DUDLEY_DLL_API
110 MeshAdapter(const MeshAdapter& in);
111
112 /**
113 \brief
114 Destructor for MeshAdapter. As specified in the constructor
115 this calls Dudley_Mesh_free for the pointer given to the
116 constructor.
117 */
118 DUDLEY_DLL_API
119 ~MeshAdapter();
120
121 /**
122 \brief
123 return the number of processors used for this domain
124 */
125 DUDLEY_DLL_API
126 virtual int getMPISize() const;
127 /**
128 \brief
129 return the number MPI rank of this processor
130 */
131
132 DUDLEY_DLL_API
133 virtual int getMPIRank() const;
134
135 /**
136 \brief
137 If compiled for MPI then execute an MPI_Barrier, else do nothing
138 */
139
140 DUDLEY_DLL_API
141 virtual void MPIBarrier() const;
142
143 /**
144 \brief
145 Return true if on MPI processor 0, else false
146 */
147
148 DUDLEY_DLL_API
149 virtual bool onMasterProcessor() const;
150
151 DUDLEY_DLL_API
152 #ifdef ESYS_MPI
153 MPI_Comm
154 #else
155 unsigned int
156 #endif
157 getMPIComm() const;
158
159
160 /**
161 \brief
162 Write the current mesh to a file with the given name.
163 \param fileName Input - The name of the file to write to.
164 */
165 DUDLEY_DLL_API
166 void write(const std::string& fileName) const;
167
168 /**
169 \brief
170 \param full
171 */
172 DUDLEY_DLL_API
173 void Print_Mesh_Info(const bool full=false) 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 DUDLEY_DLL_API
181 void dump(const std::string& fileName) const;
182
183 /**
184 \brief
185 return the pointer to the underlying dudley mesh structure
186 */
187 DUDLEY_DLL_API
188 Dudley_Mesh* getDudley_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 DUDLEY_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 DUDLEY_DLL_API
205 const 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 DUDLEY_DLL_API
213 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
214
215 /**
216 \brief
217 Return a description for this domain
218 */
219 DUDLEY_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 DUDLEY_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 DUDLEY_DLL_API
234 void setFunctionSpaceTypeNames();
235
236 /**
237 \brief
238 Return a continuous FunctionSpace code
239 */
240 DUDLEY_DLL_API
241 virtual int getContinuousFunctionCode() const;
242
243 /**
244 \brief
245 Return a continuous on reduced order nodes FunctionSpace code
246 */
247 DUDLEY_DLL_API
248 virtual int getReducedContinuousFunctionCode() const;
249
250 /**
251 \brief
252 Return a function FunctionSpace code
253 */
254 DUDLEY_DLL_API
255 virtual int getFunctionCode() const;
256
257 /**
258 \brief
259 Return a function with reduced integration order FunctionSpace code
260 */
261 DUDLEY_DLL_API
262 virtual int getReducedFunctionCode() const;
263
264 /**
265 \brief
266 Return a function on boundary FunctionSpace code
267 */
268 DUDLEY_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 DUDLEY_DLL_API
276 virtual int getReducedFunctionOnBoundaryCode() const;
277
278 /**
279 \brief
280 Return a FunctionOnContactZero code
281 */
282 DUDLEY_DLL_API
283 virtual int getFunctionOnContactZeroCode() const;
284
285 /**
286 \brief
287 Return a FunctionOnContactZero code with reduced integration order
288 */
289 DUDLEY_DLL_API
290 virtual int getReducedFunctionOnContactZeroCode() const;
291
292 /**
293 \brief
294 Return a FunctionOnContactOne code
295 */
296 DUDLEY_DLL_API
297 virtual int getFunctionOnContactOneCode() const;
298
299 /**
300 \brief
301 Return a FunctionOnContactOne code with reduced integration order
302 */
303 DUDLEY_DLL_API
304 virtual int getReducedFunctionOnContactOneCode() const;
305
306 /**
307 \brief
308 Return a Solution code
309 */
310 DUDLEY_DLL_API
311 virtual int getSolutionCode() const;
312
313 /**
314 \brief
315 Return a ReducedSolution code
316 */
317 DUDLEY_DLL_API
318 virtual int getReducedSolutionCode() const;
319
320 /**
321 \brief
322 Return a DiracDeltaFunctions code
323 */
324 DUDLEY_DLL_API
325 virtual int getDiracDeltaFunctionsCode() const;
326
327 /**
328 5B
329 \brief
330 */
331 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
332
333 /**
334 \brief
335 */
336 DUDLEY_DLL_API
337 virtual int getDim() const;
338
339 /**
340 \brief
341 Returns a status indicator of the domain. The status identifier should be unique over
342 the live time if the object but may be updated if changes to the domain happen, e.g.
343 modifications to its geometry.
344
345 This has to be implemented by the actual Domain adapter.
346 */
347 DUDLEY_DLL_API
348 virtual StatusType getStatus() const;
349
350
351 /**
352 \brief
353 Return the number of data points summed across all MPI processes
354 */
355 DUDLEY_DLL_API
356 virtual int getNumDataPointsGlobal() const;
357
358 /**
359 \brief
360 Return the number of data points per sample, and the number of samples as a pair.
361 \param functionSpaceCode Input -
362 */
363 DUDLEY_DLL_API
364 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
365
366 /**
367 \brief
368 copies the location of data points into arg. The domain of arg has to match this.
369 has to be implemented by the actual Domain adapter.
370 */
371 DUDLEY_DLL_API
372 virtual void setToX(escript::Data& arg) const;
373
374 /**
375 \brief
376 sets a map from a clear tag name to a tag key
377 \param name Input - tag name.
378 \param tag Input - tag key.
379 */
380 DUDLEY_DLL_API
381 virtual void setTagMap(const std::string& name, int tag);
382
383 /**
384 \brief
385 Return the tag key for tag name.
386 \param name Input - tag name
387 */
388 DUDLEY_DLL_API
389 virtual int getTag(const std::string& name) const;
390
391 /**
392 \brief
393 Returns true if name is a defined tage name.
394 \param name Input - tag name to be checked.
395 */
396 DUDLEY_DLL_API
397 virtual bool isValidTagName(const std::string& name) const;
398
399 /**
400 \brief
401 Returns all tag names in a single string sperated by commas
402 */
403 DUDLEY_DLL_API
404 virtual std::string showTagNames() const;
405
406 /**
407 \brief
408 assigns new location to the domain
409 */
410 DUDLEY_DLL_API
411 virtual void setNewX(const escript::Data& arg);
412
413 /**
414 \brief
415 interpolates data given on source onto target where source and target have to be given on the same domain.
416 */
417 DUDLEY_DLL_API
418 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
419
420
421 DUDLEY_DLL_API
422 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
423
424 /**
425 \brief given a vector of FunctionSpace typecodes, pass back a code which then can all be interpolated to.
426 \return true is result is valid, false if not
427 */
428 DUDLEY_DLL_API
429 bool
430 commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
431
432 /**
433 \brief
434 interpolates data given on source onto target where source and target are given on different domains.
435 has to be implemented by the actual Domain adapter.
436 */
437 DUDLEY_DLL_API
438 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
439
440 /**
441 \brief determines whether interpolation from source to target is possible.
442 Must be implemented by the actual Domain adapter
443 */
444 DUDLEY_DLL_API
445 virtual bool probeInterpolationACross(int functionSpaceType_source,const escript::AbstractDomain& targetDomain, int functionSpaceType_target) const;
446
447 /**
448 \brief
449 copies the surface normals at data points into out. The actual function space to be considered
450 is defined by out. out has to be defined on this.
451 */
452 DUDLEY_DLL_API
453 virtual void setToNormal(escript::Data& out) const;
454
455 /**
456 \brief
457 copies the size of samples into out. The actual function space to be considered
458 is defined by out. out has to be defined on this.
459 */
460 DUDLEY_DLL_API
461 virtual void setToSize(escript::Data& out) const;
462
463 /**
464 \brief
465 copies the gradient of arg into grad. The actual function space to be considered
466 for the gradient is defined by grad. arg and grad have to be defined on this.
467 */
468 DUDLEY_DLL_API
469 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
470
471 /**
472 \brief
473 copies the integrals of the function defined by arg into integrals.
474 arg has to be defined on this.
475 */
476 DUDLEY_DLL_API
477 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
478
479 /**
480 \brief
481 return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package, perconditioner,
482 and symmetric matrix is used.
483 \param solver
484 \param preconditioner
485 \param package
486 \param symmetry
487 */
488 DUDLEY_DLL_API
489 virtual int getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
490
491 /**
492 \brief
493 return the identifier of the transport problem type to be used when a particular solver, perconditioner, package
494 and symmetric matrix is used.
495 \param solver
496 \param preconditioner
497 \param package
498 \param symmetry
499 */
500 DUDLEY_DLL_API
501 virtual int getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
502
503 /**
504 \brief
505 returns true if data on this domain and a function space of type functionSpaceCode has to
506 considered as cell centered data.
507 */
508 DUDLEY_DLL_API
509 virtual bool isCellOriented(int functionSpaceCode) const;
510
511 /**
512 \brief
513 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
514
515 This has to be implemented by the actual Domain adapter.
516 */
517 DUDLEY_DLL_API
518 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
519
520
521 DUDLEY_DLL_API
522 virtual bool ownSample(int fs_code, index_t id) const;
523
524 /**
525 \brief
526 returns the function space representation of the type functionSpaceCode on this domain
527 as a vtkObject.
528 */
529 // vtkObject createVtkObject(int functionSpaceCode) const;
530
531 /**
532 \brief
533 adds a PDE onto the stiffness matrix mat and a rhs
534 */
535 DUDLEY_DLL_API
536 virtual void addPDEToSystem(
537 escript::AbstractSystemMatrix& mat, escript::Data& rhs,
538 const escript::Data& A, const escript::Data& B, const escript::Data& C,
539 const escript::Data& D, const escript::Data& X, const escript::Data& Y,
540 const escript::Data& d, const escript::Data& y,
541 const escript::Data& d_contact, const escript::Data& y_contact,
542 const escript::Data& d_dirac, const escript::Data& y_dirac) const;
543
544
545 /**
546 \brief
547 adds a PDE onto the lumped stiffness matrix matrix
548 */
549 DUDLEY_DLL_API
550 virtual void addPDEToLumpedSystem(
551 escript::Data& mat,
552 const escript::Data& D,
553 const escript::Data& d,
554 const escript::Data& d_dirac,
555 const bool useHRZ) const;
556
557 /**
558 \brief
559 adds a PDE onto the stiffness matrix mat and a rhs
560 */
561 DUDLEY_DLL_API
562 virtual void addPDEToRHS(escript::Data& rhs,
563 const escript::Data& X, const escript::Data& Y,
564 const escript::Data& y, const escript::Data& y_contact, const escript::Data& y_dirac) const;
565 /**
566 \brief
567 adds a PDE onto a transport problem
568 */
569
570 DUDLEY_DLL_API
571 virtual void addPDEToTransportProblem(
572 escript::AbstractTransportProblem& tp, escript::Data& source,
573 const escript::Data& M,
574 const escript::Data& A, const escript::Data& B, const escript::Data& C,const escript::Data& D,
575 const escript::Data& X,const escript::Data& Y,
576 const escript::Data& d, const escript::Data& y,
577 const escript::Data& d_contact,const escript::Data& y_contact,
578 const escript::Data& d_dirac,const escript::Data& y_dirac) const;
579
580
581 /**
582 \brief
583 creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros:
584 */
585 DUDLEY_DLL_API
586 escript::ASM_ptr newSystemMatrix(
587 const int row_blocksize,
588 const escript::FunctionSpace& row_functionspace,
589 const int column_blocksize,
590 const escript::FunctionSpace& column_functionspace,
591 const int type) const;
592 /**
593 \brief
594 creates a TransportProblemAdapter
595
596 */
597
598 DUDLEY_DLL_API
599 escript::ATP_ptr newTransportProblem(
600 const int blocksize,
601 const escript::FunctionSpace& functionspace,
602 const int type) const;
603
604 /**
605 \brief returns locations in the FEM nodes
606 */
607 DUDLEY_DLL_API
608 virtual escript::Data getX() const;
609
610 /**
611 \brief return boundary normals at the quadrature point on the face elements
612 */
613 DUDLEY_DLL_API
614 virtual escript::Data getNormal() const;
615
616 /**
617 \brief returns the element size
618 */
619 DUDLEY_DLL_API
620 virtual escript::Data getSize() const;
621
622 /**
623 \brief comparison operators
624 */
625 DUDLEY_DLL_API
626 virtual bool operator==(const escript::AbstractDomain& other) const;
627 DUDLEY_DLL_API
628 virtual bool operator!=(const escript::AbstractDomain& other) const;
629
630 /**
631 \brief assigns new tag newTag to all samples of functionspace with a positive
632 value of mask for any its sample point.
633
634 */
635 DUDLEY_DLL_API
636 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
637
638 /**
639 \brief
640 return the number of tags in use and a pointer to an array with the number of tags in use
641 */
642 DUDLEY_DLL_API
643 virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
644
645 DUDLEY_DLL_API
646 virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
647
648
649 /**
650 \brief Checks if this domain allows tags for the specified functionSpaceCode.
651 */
652 DUDLEY_DLL_API
653 virtual
654 bool canTag(int functionSpaceCode) const;
655
656 /**
657 \brief returns the approximation order used for a function space functionSpaceCode
658 */
659
660 DUDLEY_DLL_API
661 virtual
662 int getApproximationOrder(const int functionSpaceCode) const;
663
664
665 DUDLEY_DLL_API
666 bool supportsContactElements() const;
667 protected:
668
669 private:
670 void extractArgsFromDict(const boost::python::dict& arg, int& numData,
671 char**& names, escriptDataC*& data,
672 escriptDataC**& dataPtr) const;
673
674 //
675 // pointer to the externally created dudley mesh
676 boost::shared_ptr<Dudley_Mesh> m_dudleyMesh;
677
678 static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
679
680 };
681
682 } // end of namespace
683
684 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26