/[escript]/branches/ripleygmg_from_3668/ripley/src/RipleyDomain.h
ViewVC logotype

Contents of /branches/ripleygmg_from_3668/ripley/src/RipleyDomain.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3746 - (show annotations)
Thu Dec 15 00:02:22 2011 UTC (7 years, 10 months ago) by caltinay
File MIME type: text/plain
File size: 19896 byte(s)
In Ripley Solution==ContinuousFunction and ReducedSolution==ReducedCF now.
Removed a test in escript that relied on failure when trying to tag Data on
Solution/ReducedSolution.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2011 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 #ifndef __RIPLEY_DOMAIN_H__
15 #define __RIPLEY_DOMAIN_H__
16
17 #include <ripley/Ripley.h>
18 #include <ripley/RipleyException.h>
19 #include <escript/AbstractContinuousDomain.h>
20 #include <escript/Data.h>
21 #include <escript/FunctionSpace.h>
22
23 struct Paso_SystemMatrixPattern;
24
25 namespace ripley {
26
27 /**
28 \brief
29 RipleyDomain extends the AbstractContinuousDomain interface
30 for the Ripley library and is the base class for Rectangle and Brick.
31 */
32
33 class RipleyDomain : public escript::AbstractContinuousDomain
34 {
35 public:
36
37 /**
38 \brief recovers mesh from a file created with the dump() method
39 \param filename the name of the file
40 */
41 RIPLEY_DLL_API
42 static escript::Domain_ptr loadMesh(const std::string& filename);
43
44 /**
45 \brief reads a mesh from a file created with the write() method
46 \param filename the name of the file
47 */
48 RIPLEY_DLL_API
49 static escript::Domain_ptr readMesh(const std::string& filename);
50
51 /**
52 \brief
53 Constructor with number of dimensions. Allocates MPI info structure.
54 */
55 RIPLEY_DLL_API
56 RipleyDomain(dim_t dim);
57
58 /**
59 \brief
60 Destructor for RipleyDomain
61 */
62 RIPLEY_DLL_API
63 ~RipleyDomain();
64
65 /**
66 \brief
67 returns a description for this domain
68 */
69 RIPLEY_DLL_API
70 virtual std::string getDescription() const;
71
72 /**
73 \brief
74 returns the number of processors used for this domain
75 */
76 RIPLEY_DLL_API
77 virtual int getMPISize() const { return m_mpiInfo->size; }
78
79 /**
80 \brief
81 returns the MPI rank of this processor
82 */
83 RIPLEY_DLL_API
84 virtual int getMPIRank() const { return m_mpiInfo->rank; }
85
86 /**
87 \brief
88 if compiled for MPI then executes an MPI_Barrier, else does nothing
89 */
90 RIPLEY_DLL_API
91 virtual void MPIBarrier() const {
92 #ifdef ESYS_MPI
93 MPI_Barrier(m_mpiInfo->comm);
94 #endif
95 }
96
97 /**
98 \brief
99 returns true if on MPI processor 0, else false
100 */
101 RIPLEY_DLL_API
102 virtual bool onMasterProcessor() const { return getMPIRank()==0; }
103
104 /**
105 \brief
106 returns the MPI communicator
107 */
108 RIPLEY_DLL_API
109 #ifdef ESYS_MPI
110 MPI_Comm
111 #else
112 unsigned int
113 #endif
114 getMPIComm() const {
115 #ifdef ESYS_MPI
116 return m_mpiInfo->comm;
117 #else
118 return 0;
119 #endif
120 }
121
122 /**
123 \brief
124 returns true if the argument is a valid function space type for this
125 domain
126 */
127 RIPLEY_DLL_API
128 virtual bool isValidFunctionSpaceType(int fsType) const;
129
130 /**
131 \brief
132 returns a description for the given function space type code
133 */
134 RIPLEY_DLL_API
135 virtual std::string functionSpaceTypeAsString(int fsType) const;
136
137 /**
138 \brief
139 returns the number of spatial dimensions of the domain
140 */
141 RIPLEY_DLL_API
142 virtual int getDim() const { return m_numDim; }
143
144 /**
145 \brief equality operator
146 */
147 RIPLEY_DLL_API
148 virtual bool operator==(const escript::AbstractDomain& other) const;
149
150 /**
151 \brief inequality operator
152 */
153 RIPLEY_DLL_API
154 virtual bool operator!=(const escript::AbstractDomain& other) const {
155 return !(operator==(other));
156 }
157
158 /**
159 \brief
160 writes the current mesh to a file with the given name
161 \param filename The name of the file to write to
162 */
163 RIPLEY_DLL_API
164 void write(const std::string& filename) const;
165
166 /**
167 \brief
168 dumps the mesh to a file with the given name
169 \param filename The name of the output file
170 */
171 RIPLEY_DLL_API
172 void dump(const std::string& filename) const;
173
174 /**
175 \brief
176 returns the number of data points per sample, and the number of samples
177 as a pair.
178 \param fsType The function space type
179 */
180 RIPLEY_DLL_API
181 virtual std::pair<int,int> getDataShape(int fsType) const;
182
183 /**
184 \brief
185 returns the tag key for the given sample number
186 \param fsType The function space type
187 \param sampleNo The sample number
188 */
189 RIPLEY_DLL_API
190 int getTagFromSampleNo(int fsType, int sampleNo) const;
191
192 /**
193 \brief
194 sets a map from a clear tag name to a tag key
195 \param name tag name
196 \param tag tag key
197 */
198 RIPLEY_DLL_API
199 virtual void setTagMap(const std::string& name, int tag) {
200 m_tagMap[name] = tag;
201 }
202
203 /**
204 \brief
205 returns the tag key for tag name
206 \param name tag name
207 */
208 RIPLEY_DLL_API
209 virtual int getTag(const std::string& name) const {
210 if (m_tagMap.find(name) != m_tagMap.end()) {
211 return m_tagMap.find(name)->second;
212 } else {
213 throw RipleyException("getTag(): Invalid tag name");
214 }
215 }
216
217 /**
218 \brief
219 returns true if name is a defined tag name
220 \param name tag name to be checked
221 */
222 RIPLEY_DLL_API
223 virtual bool isValidTagName(const std::string& name) const {
224 return (m_tagMap.find(name)!=m_tagMap.end());
225 }
226
227 /**
228 \brief
229 returns all tag names in a single string separated by commas
230 */
231 RIPLEY_DLL_API
232 virtual std::string showTagNames() const;
233
234 /**
235 \brief
236 returns the array of reference numbers for a function space type
237 \param fsType The function space type
238 */
239 RIPLEY_DLL_API
240 const int* borrowSampleReferenceIDs(int fsType) const;
241
242 /**
243 \brief
244 assigns new location to the domain.
245 \note This is not supported in Ripley
246 */
247 RIPLEY_DLL_API
248 virtual void setNewX(const escript::Data& arg);
249
250 /**
251 \brief
252 interpolates data given on source onto target where source and target
253 have to be given on the same domain
254 */
255 RIPLEY_DLL_API
256 virtual void interpolateOnDomain(escript::Data& target, const escript::Data& source) const;
257
258 /**
259 \brief
260 returns true if data on fsType_source can be interpolated onto
261 fsType_target, false otherwise
262 */
263 RIPLEY_DLL_API
264 virtual bool probeInterpolationOnDomain(int fsType_source, int fsType_target) const;
265
266 /**
267 \brief
268 given a vector of FunctionSpace type codes, passes back a code which all
269 can be interpolated to
270 \return true if result is valid, false if not
271 */
272 RIPLEY_DLL_API
273 bool
274 commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
275
276 /**
277 \brief
278 interpolates data given on source onto target where source and target
279 are given on different domains
280 */
281 RIPLEY_DLL_API
282 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
283
284 /**
285 \brief
286 determines whether interpolation from source to target is possible
287 */
288 RIPLEY_DLL_API
289 virtual bool probeInterpolationACross(int, const escript::AbstractDomain&, int) const;
290
291 /**
292 \brief
293 returns locations in the FEM nodes
294 */
295 RIPLEY_DLL_API
296 virtual escript::Data getX() const;
297
298 /**
299 \brief
300 returns boundary normals at the quadrature point on the face elements
301 */
302 RIPLEY_DLL_API
303 virtual escript::Data getNormal() const;
304
305 /**
306 \brief returns the element size
307 */
308 RIPLEY_DLL_API
309 virtual escript::Data getSize() const;
310
311 /**
312 \brief
313 copies the location of data points into arg. The domain of arg has to
314 match this domain.
315 */
316 RIPLEY_DLL_API
317 virtual void setToX(escript::Data& arg) const;
318
319 /**
320 \brief
321 copies the surface normals at data points into out. The actual function
322 space to be considered is defined by out. out has to be defined on this
323 domain.
324 */
325 RIPLEY_DLL_API
326 virtual void setToNormal(escript::Data& out) const;
327
328 /**
329 \brief
330 copies the size of samples into out. The actual function space to be
331 considered is defined by out. out has to be defined on this domain.
332 */
333 RIPLEY_DLL_API
334 virtual void setToSize(escript::Data& out) const;
335
336 /**
337 \brief
338 copies the gradient of 'in' into 'out'. The actual function space to be
339 considered for the gradient is defined by 'in'. Both arguments have to
340 be defined on this domain.
341 */
342 RIPLEY_DLL_API
343 virtual void setToGradient(escript::Data& out, const escript::Data& in) const;
344
345 /**
346 \brief
347 returns true if this rank owns the sample id on given function space
348 */
349 RIPLEY_DLL_API
350 virtual bool ownSample(int fsType, index_t id) const;
351
352 /**
353 \brief
354 returns the number of data points summed across all MPI processes
355 */
356 RIPLEY_DLL_API
357 virtual int getNumDataPointsGlobal() const;
358
359 /**
360 \brief
361 assigns new tag newTag to all samples of given function space with a
362 positive value of mask for any of its sample points
363 */
364 RIPLEY_DLL_API
365 virtual void setTags(const int fsType, const int newTag, const escript::Data& mask) const;
366
367 /**
368 \brief
369 returns true if data on this domain and given function space type has
370 to be considered as cell centered data
371 */
372 RIPLEY_DLL_API
373 virtual bool isCellOriented(int fsType) const;
374
375 /**
376 \brief
377 returns a status indicator of the domain. The status identifier should
378 be unique over the lifetime of the object but may be updated if changes
379 to the domain happen, e.g. modifications to its geometry.
380 */
381 RIPLEY_DLL_API
382 virtual StatusType getStatus() const { return m_status; }
383
384 /**
385 \brief
386 returns the number of tags in use for a function space type
387 */
388 RIPLEY_DLL_API
389 virtual int getNumberOfTagsInUse(int fsType) const;
390
391 /**
392 \brief
393 returns a pointer to the list of tags in use for a function space type
394 */
395 RIPLEY_DLL_API
396 virtual const int* borrowListOfTagsInUse(int fsType) const;
397
398 /**
399 \brief
400 checks if this domain allows tags for the specified function space type
401 */
402 RIPLEY_DLL_API
403 virtual bool canTag(int fsType) const;
404
405 /**
406 \brief
407 returns the approximation order used for a function space
408 */
409 RIPLEY_DLL_API
410 virtual int getApproximationOrder(const int fsType) const { return 1; }
411
412 /**
413 \brief
414 returns true if this domain supports contact elements, false otherwise
415 */
416 RIPLEY_DLL_API
417 virtual bool supportsContactElements() const { return false; }
418
419 /**
420 \brief
421 returns a continuous FunctionSpace code
422 */
423 RIPLEY_DLL_API
424 virtual int getContinuousFunctionCode() const { return Nodes; }
425
426 /**
427 \brief
428 returns a continuous on reduced order nodes FunctionSpace code
429 */
430 RIPLEY_DLL_API
431 virtual int getReducedContinuousFunctionCode() const { return ReducedNodes; }
432
433 /**
434 \brief
435 returns a function FunctionSpace code
436 */
437 RIPLEY_DLL_API
438 virtual int getFunctionCode() const { return Elements; }
439
440 /**
441 \brief
442 returns a function with reduced integration order FunctionSpace code
443 */
444 RIPLEY_DLL_API
445 virtual int getReducedFunctionCode() const { return ReducedElements; }
446
447 /**
448 \brief
449 returns a function on boundary FunctionSpace code
450 */
451 RIPLEY_DLL_API
452 virtual int getFunctionOnBoundaryCode() const { return FaceElements; }
453
454 /**
455 \brief
456 returns a function on boundary with reduced integration order
457 FunctionSpace code
458 */
459 RIPLEY_DLL_API
460 virtual int getReducedFunctionOnBoundaryCode() const { return ReducedFaceElements; }
461
462 /**
463 \brief
464 return a FunctionOnContactZero code
465 */
466 RIPLEY_DLL_API
467 virtual int getFunctionOnContactZeroCode() const {
468 throw RipleyException("Ripley does not support contact elements");
469 }
470
471 /**
472 \brief
473 returns a FunctionOnContactZero code with reduced integration order
474 */
475 RIPLEY_DLL_API
476 virtual int getReducedFunctionOnContactZeroCode() const {
477 throw RipleyException("Ripley does not support contact elements");
478 }
479
480 /**
481 \brief
482 returns a FunctionOnContactOne code
483 */
484 RIPLEY_DLL_API
485 virtual int getFunctionOnContactOneCode() const {
486 throw RipleyException("Ripley does not support contact elements");
487 }
488
489 /**
490 \brief
491 returns a FunctionOnContactOne code with reduced integration order
492 */
493 RIPLEY_DLL_API
494 virtual int getReducedFunctionOnContactOneCode() const {
495 throw RipleyException("Ripley does not support contact elements");
496 }
497
498 /**
499 \brief
500 returns a Solution FunctionSpace code
501 */
502 RIPLEY_DLL_API
503 virtual int getSolutionCode() const { return Nodes; }
504
505 /**
506 \brief
507 returns a ReducedSolution FunctionSpace code
508 */
509 RIPLEY_DLL_API
510 virtual int getReducedSolutionCode() const { return ReducedNodes; }
511
512 /**
513 \brief
514 returns a DiracDeltaFunctions FunctionSpace code
515 */
516 RIPLEY_DLL_API
517 virtual int getDiracDeltaFunctionsCode() const { return Points; }
518
519 /**
520 \brief
521 returns the identifier of the matrix type to be used for the global
522 stiffness matrix when a particular solver, package, preconditioner,
523 and symmetric matrix is used
524 \param solver
525 \param preconditioner
526 \param package
527 \param symmetry
528 */
529 RIPLEY_DLL_API
530 virtual int getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
531
532 /**
533 \brief
534 returns the identifier of the transport problem type to be used when a
535 particular solver, preconditioner, package and symmetric matrix is used
536 \param solver
537 \param preconditioner
538 \param package
539 \param symmetry
540 */
541 RIPLEY_DLL_API
542 virtual int getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
543
544 /**
545 \brief
546 copies the integrals of the function defined by arg into integrals.
547 arg has to be defined on this domain.
548 */
549 RIPLEY_DLL_API
550 virtual void setToIntegrals(std::vector<double>& integrals, const escript::Data& arg) const;
551
552 /**
553 \brief
554 adds a PDE onto the stiffness matrix mat and rhs
555 */
556 RIPLEY_DLL_API
557 virtual void addPDEToSystem(escript::AbstractSystemMatrix& mat,
558 escript::Data& rhs, const escript::Data& A, const escript::Data& B,
559 const escript::Data& C, const escript::Data& D,
560 const escript::Data& X, const escript::Data& Y,
561 const escript::Data& d, const escript::Data& y,
562 const escript::Data& d_contact, const escript::Data& y_contact,
563 const escript::Data& d_dirac, const escript::Data& y_dirac) const;
564
565 /**
566 \brief
567 adds a PDE onto the lumped stiffness matrix mat
568 */
569 RIPLEY_DLL_API
570 virtual void addPDEToLumpedSystem(escript::Data& mat,
571 const escript::Data& D, const escript::Data& d,
572 const escript::Data& d_dirac, const bool useHRZ) const;
573
574 /**
575 \brief
576 adds a PDE onto rhs
577 */
578 RIPLEY_DLL_API
579 virtual void addPDEToRHS(escript::Data& rhs, const escript::Data& X,
580 const escript::Data& Y, const escript::Data& y,
581 const escript::Data& y_contact, const escript::Data& y_dirac) const;
582
583 /**
584 \brief
585 adds a PDE onto a transport problem
586 */
587 RIPLEY_DLL_API
588 virtual void addPDEToTransportProblem(escript::AbstractTransportProblem& tp,
589 escript::Data& source, const escript::Data& M,
590 const escript::Data& A, const escript::Data& B,
591 const escript::Data& C, const escript::Data& D,
592 const escript::Data& X, const escript::Data& Y,
593 const escript::Data& d, const escript::Data& y,
594 const escript::Data& d_contact, const escript::Data& y_contact,
595 const escript::Data& d_dirac, const escript::Data& y_dirac) const;
596
597
598 /**
599 \brief
600 creates a stiffness matrix and initializes it with zeros
601 */
602 RIPLEY_DLL_API
603 virtual escript::ASM_ptr newSystemMatrix(const int row_blocksize,
604 const escript::FunctionSpace& row_functionspace,
605 const int column_blocksize,
606 const escript::FunctionSpace& column_functionspace, const int type) const;
607
608 /**
609 \brief
610 creates a transport problem
611 */
612 RIPLEY_DLL_API
613 virtual escript::ATP_ptr newTransportProblem(const bool useBackwardEuler,
614 const int blocksize, const escript::FunctionSpace& functionspace,
615 const int type) const;
616
617 /**
618 \brief
619 writes information about the mesh to standard output
620 \param full whether to print additional data
621 */
622 RIPLEY_DLL_API
623 virtual void Print_Mesh_Info(const bool full=false) const;
624
625 /**
626 \brief
627 returns the number of nodes per MPI rank in each dimension
628 */
629 RIPLEY_DLL_API
630 virtual IndexVector getNumNodesPerDim() const;
631
632 /**
633 \brief
634 returns the number of elements per MPI rank in each dimension
635 */
636 RIPLEY_DLL_API
637 virtual IndexVector getNumElementsPerDim() const;
638
639 /**
640 \brief
641 returns the number of face elements in the order
642 (left,right,bottom,top,[front,back]) on current MPI rank
643 */
644 RIPLEY_DLL_API
645 virtual IndexVector getNumFacesPerBoundary() const;
646
647 /**
648 \brief
649 returns the node distribution vector
650 */
651 RIPLEY_DLL_API
652 virtual IndexVector getNodeDistribution() const;
653
654 /**
655 \brief
656 returns the first coordinate value and the node spacing along given
657 dimension as a pair
658 */
659 RIPLEY_DLL_API
660 virtual std::pair<double,double> getFirstCoordAndSpacing(dim_t dim) const;
661
662 protected:
663 /// returns the number of nodes per MPI rank
664 virtual dim_t getNumNodes() const;
665
666 /// returns the number of elements per MPI rank
667 virtual dim_t getNumElements() const;
668
669 /// returns the number of face elements on current MPI rank
670 virtual dim_t getNumFaceElements() const;
671
672 virtual void assembleCoordinates(escript::Data& arg) const;
673
674 virtual Paso_SystemMatrixPattern* getPattern(bool reducedRowOrder,
675 bool reducedColOrder) const;
676
677 /// interpolates data on nodes in 'in' onto (reduced) elements in 'out'
678 virtual void interpolateNodesOnElements(escript::Data& out,
679 escript::Data& in, bool reduced) const;
680
681 /// interpolates data on nodes in 'in' onto (reduced) face elements in 'out'
682 virtual void interpolateNodesOnFaces(escript::Data& out, escript::Data& in,
683 bool reduced) const;
684
685 /// copies data in 'in' to 'out' (both must be on same function space)
686 virtual void copyData(escript::Data& out, escript::Data& in) const;
687
688 /// averages data in 'in' to 'out' (from non-reduced to reduced fs)
689 virtual void averageData(escript::Data& out, escript::Data& in) const;
690
691 // this is const because setTags is const
692 virtual void updateTagsInUse(int fsType) const;
693
694 dim_t m_numDim;
695 StatusType m_status;
696 Esys_MPIInfo *m_mpiInfo;
697 TagMap m_tagMap;
698 mutable IndexVector m_nodeTags, m_nodeTagsInUse;
699 mutable IndexVector m_elementTags, m_elementTagsInUse;
700 mutable IndexVector m_faceTags, m_faceTagsInUse;
701 };
702
703 } // end of namespace ripley
704
705 #endif // __RIPLEY_DOMAIN_H__
706

  ViewVC Help
Powered by ViewVC 1.1.26