/[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 3702 - (show annotations)
Fri Dec 2 06:12:32 2011 UTC (7 years, 11 months ago) by caltinay
File MIME type: text/plain
File size: 19081 byte(s)
Gradient for Rectangle elements.

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 return m_tagMap.find(name)->second;
211 }
212
213 /**
214 \brief
215 returns true if name is a defined tag name
216 \param name tag name to be checked
217 */
218 RIPLEY_DLL_API
219 virtual bool isValidTagName(const std::string& name) const {
220 return (m_tagMap.find(name)!=m_tagMap.end());
221 }
222
223 /**
224 \brief
225 returns all tag names in a single string separated by commas
226 */
227 RIPLEY_DLL_API
228 virtual std::string showTagNames() const;
229
230 /**
231 \brief
232 returns the array of reference numbers for a function space type
233 \param fsType The function space type
234 */
235 RIPLEY_DLL_API
236 const int* borrowSampleReferenceIDs(int fsType) const;
237
238 /**
239 \brief
240 assigns new location to the domain.
241 \note This is not supported in Ripley
242 */
243 RIPLEY_DLL_API
244 virtual void setNewX(const escript::Data& arg);
245
246 /**
247 \brief
248 interpolates data given on source onto target where source and target
249 have to be given on the same domain
250 */
251 RIPLEY_DLL_API
252 virtual void interpolateOnDomain(escript::Data& target, const escript::Data& source) const;
253
254 /**
255 \brief
256 returns true if data on fsType_source can be interpolated onto
257 fsType_target, false otherwise
258 */
259 RIPLEY_DLL_API
260 virtual bool probeInterpolationOnDomain(int fsType_source, int fsType_target) const;
261
262 /**
263 \brief
264 given a vector of FunctionSpace type codes, passes back a code which all
265 can be interpolated to
266 \return true if result is valid, false if not
267 */
268 RIPLEY_DLL_API
269 bool
270 commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
271
272 /**
273 \brief
274 interpolates data given on source onto target where source and target
275 are given on different domains
276 */
277 RIPLEY_DLL_API
278 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
279
280 /**
281 \brief
282 determines whether interpolation from source to target is possible
283 */
284 RIPLEY_DLL_API
285 virtual bool probeInterpolationACross(int, const escript::AbstractDomain&, int) const;
286
287 /**
288 \brief
289 returns locations in the FEM nodes
290 */
291 RIPLEY_DLL_API
292 virtual escript::Data getX() const;
293
294 /**
295 \brief
296 returns boundary normals at the quadrature point on the face elements
297 */
298 RIPLEY_DLL_API
299 virtual escript::Data getNormal() const;
300
301 /**
302 \brief returns the element size
303 */
304 RIPLEY_DLL_API
305 virtual escript::Data getSize() const;
306
307 /**
308 \brief
309 copies the location of data points into arg. The domain of arg has to
310 match this domain.
311 */
312 RIPLEY_DLL_API
313 virtual void setToX(escript::Data& arg) const;
314
315 /**
316 \brief
317 copies the surface normals at data points into out. The actual function
318 space to be considered is defined by out. out has to be defined on this
319 domain.
320 */
321 RIPLEY_DLL_API
322 virtual void setToNormal(escript::Data& out) const;
323
324 /**
325 \brief
326 copies the size of samples into out. The actual function space to be
327 considered is defined by out. out has to be defined on this domain.
328 */
329 RIPLEY_DLL_API
330 virtual void setToSize(escript::Data& out) const;
331
332 /**
333 \brief
334 copies the gradient of 'in' into 'out'. The actual function space to be
335 considered for the gradient is defined by 'in'. Both arguments have to
336 be defined on this domain.
337 */
338 RIPLEY_DLL_API
339 virtual void setToGradient(escript::Data& out, const escript::Data& in) const;
340
341 /**
342 \brief
343 returns true if this rank owns the sample id on given function space
344 */
345 RIPLEY_DLL_API
346 virtual bool ownSample(int fsType, index_t id) const;
347
348 /**
349 \brief
350 returns the number of data points summed across all MPI processes
351 */
352 RIPLEY_DLL_API
353 virtual int getNumDataPointsGlobal() const;
354
355 /**
356 \brief
357 assigns new tag newTag to all samples of given function space with a
358 positive value of mask for any of its sample points
359 */
360 RIPLEY_DLL_API
361 virtual void setTags(const int fsType, const int newTag, const escript::Data& mask) const;
362
363 /**
364 \brief
365 returns true if data on this domain and given function space type has
366 to be considered as cell centered data
367 */
368 RIPLEY_DLL_API
369 virtual bool isCellOriented(int fsType) const;
370
371 /**
372 \brief
373 returns a status indicator of the domain. The status identifier should
374 be unique over the lifetime of the object but may be updated if changes
375 to the domain happen, e.g. modifications to its geometry.
376 */
377 RIPLEY_DLL_API
378 virtual StatusType getStatus() const { return m_status; }
379
380 /**
381 \brief
382 returns the number of tags in use for a function space type
383 */
384 RIPLEY_DLL_API
385 virtual int getNumberOfTagsInUse(int fsType) const;
386
387 /**
388 \brief
389 returns a pointer to the list of tags in use for a function space type
390 */
391 RIPLEY_DLL_API
392 virtual const int* borrowListOfTagsInUse(int fsType) const;
393
394 /**
395 \brief
396 checks if this domain allows tags for the specified function space type
397 */
398 RIPLEY_DLL_API
399 virtual bool canTag(int fsType) const;
400
401 /**
402 \brief
403 returns the approximation order used for a function space
404 */
405 RIPLEY_DLL_API
406 virtual int getApproximationOrder(const int fsType) const { return 1; }
407
408 /**
409 \brief
410 returns true if this domain supports contact elements, false otherwise
411 */
412 RIPLEY_DLL_API
413 virtual bool supportsContactElements() const { return false; }
414
415 /**
416 \brief
417 returns a continuous FunctionSpace code
418 */
419 RIPLEY_DLL_API
420 virtual int getContinuousFunctionCode() const { return Nodes; }
421
422 /**
423 \brief
424 returns a continuous on reduced order nodes FunctionSpace code
425 */
426 RIPLEY_DLL_API
427 virtual int getReducedContinuousFunctionCode() const { return ReducedNodes; }
428
429 /**
430 \brief
431 returns a function FunctionSpace code
432 */
433 RIPLEY_DLL_API
434 virtual int getFunctionCode() const { return Elements; }
435
436 /**
437 \brief
438 returns a function with reduced integration order FunctionSpace code
439 */
440 RIPLEY_DLL_API
441 virtual int getReducedFunctionCode() const { return ReducedElements; }
442
443 /**
444 \brief
445 returns a function on boundary FunctionSpace code
446 */
447 RIPLEY_DLL_API
448 virtual int getFunctionOnBoundaryCode() const { return FaceElements; }
449
450 /**
451 \brief
452 returns a function on boundary with reduced integration order
453 FunctionSpace code
454 */
455 RIPLEY_DLL_API
456 virtual int getReducedFunctionOnBoundaryCode() const { return ReducedFaceElements; }
457
458 /**
459 \brief
460 return a FunctionOnContactZero code
461 */
462 RIPLEY_DLL_API
463 virtual int getFunctionOnContactZeroCode() const {
464 throw RipleyException("Ripley does not support contact elements");
465 }
466
467 /**
468 \brief
469 returns a FunctionOnContactZero code with reduced integration order
470 */
471 RIPLEY_DLL_API
472 virtual int getReducedFunctionOnContactZeroCode() const {
473 throw RipleyException("Ripley does not support contact elements");
474 }
475
476 /**
477 \brief
478 returns a FunctionOnContactOne code
479 */
480 RIPLEY_DLL_API
481 virtual int getFunctionOnContactOneCode() const {
482 throw RipleyException("Ripley does not support contact elements");
483 }
484
485 /**
486 \brief
487 returns a FunctionOnContactOne code with reduced integration order
488 */
489 RIPLEY_DLL_API
490 virtual int getReducedFunctionOnContactOneCode() const {
491 throw RipleyException("Ripley does not support contact elements");
492 }
493
494 /**
495 \brief
496 returns a Solution FunctionSpace code
497 */
498 RIPLEY_DLL_API
499 virtual int getSolutionCode() const { return DegreesOfFreedom; }
500
501 /**
502 \brief
503 returns a ReducedSolution FunctionSpace code
504 */
505 RIPLEY_DLL_API
506 virtual int getReducedSolutionCode() const { return ReducedDegreesOfFreedom; }
507
508 /**
509 \brief
510 returns a DiracDeltaFunctions FunctionSpace code
511 */
512 RIPLEY_DLL_API
513 virtual int getDiracDeltaFunctionsCode() const { return Points; }
514
515 /**
516 \brief
517 returns the identifier of the matrix type to be used for the global
518 stiffness matrix when a particular solver, package, preconditioner,
519 and symmetric matrix is used
520 \param solver
521 \param preconditioner
522 \param package
523 \param symmetry
524 */
525 RIPLEY_DLL_API
526 virtual int getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
527
528 /**
529 \brief
530 returns the identifier of the transport problem type to be used when a
531 particular solver, preconditioner, package and symmetric matrix is used
532 \param solver
533 \param preconditioner
534 \param package
535 \param symmetry
536 */
537 RIPLEY_DLL_API
538 virtual int getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const;
539
540 /**
541 \brief
542 copies the integrals of the function defined by arg into integrals.
543 arg has to be defined on this domain.
544 */
545 RIPLEY_DLL_API
546 virtual void setToIntegrals(std::vector<double>& integrals, const escript::Data& arg) const;
547
548 /**
549 \brief
550 adds a PDE onto the stiffness matrix mat and rhs
551 */
552 RIPLEY_DLL_API
553 virtual void addPDEToSystem(escript::AbstractSystemMatrix& mat,
554 escript::Data& rhs, const escript::Data& A, const escript::Data& B,
555 const escript::Data& C, const escript::Data& D,
556 const escript::Data& X, const escript::Data& Y,
557 const escript::Data& d, const escript::Data& y,
558 const escript::Data& d_contact, const escript::Data& y_contact,
559 const escript::Data& d_dirac, const escript::Data& y_dirac) const;
560
561 /**
562 \brief
563 adds a PDE onto the lumped stiffness matrix mat
564 */
565 RIPLEY_DLL_API
566 virtual void addPDEToLumpedSystem(escript::Data& mat,
567 const escript::Data& D, const escript::Data& d,
568 const escript::Data& d_dirac, const bool useHRZ) const;
569
570 /**
571 \brief
572 adds a PDE onto rhs
573 */
574 RIPLEY_DLL_API
575 virtual void addPDEToRHS(escript::Data& rhs, const escript::Data& X,
576 const escript::Data& Y, const escript::Data& y,
577 const escript::Data& y_contact, const escript::Data& y_dirac) const;
578
579 /**
580 \brief
581 adds a PDE onto a transport problem
582 */
583 RIPLEY_DLL_API
584 virtual void addPDEToTransportProblem(escript::AbstractTransportProblem& tp,
585 escript::Data& source, const escript::Data& M,
586 const escript::Data& A, const escript::Data& B,
587 const escript::Data& C, const escript::Data& D,
588 const escript::Data& X, const escript::Data& Y,
589 const escript::Data& d, const escript::Data& y,
590 const escript::Data& d_contact, const escript::Data& y_contact,
591 const escript::Data& d_dirac, const escript::Data& y_dirac) const;
592
593
594 /**
595 \brief
596 creates a stiffness matrix and initializes it with zeros
597 */
598 RIPLEY_DLL_API
599 virtual escript::ASM_ptr newSystemMatrix(const int row_blocksize,
600 const escript::FunctionSpace& row_functionspace,
601 const int column_blocksize,
602 const escript::FunctionSpace& column_functionspace, const int type) const;
603
604 /**
605 \brief
606 creates a transport problem
607 */
608 RIPLEY_DLL_API
609 virtual escript::ATP_ptr newTransportProblem(const bool useBackwardEuler,
610 const int blocksize, const escript::FunctionSpace& functionspace,
611 const int type) const;
612
613 /**
614 \brief
615 writes information about the mesh to standard output
616 \param full whether to print additional data
617 */
618 RIPLEY_DLL_API
619 virtual void Print_Mesh_Info(const bool full=false) const;
620
621 /**
622 \brief
623 returns the number of nodes per MPI rank in each dimension
624 */
625 RIPLEY_DLL_API
626 virtual IndexVector getNumNodesPerDim() const;
627
628 /**
629 \brief
630 returns the number of elements per MPI rank in each dimension
631 */
632 RIPLEY_DLL_API
633 virtual IndexVector getNumElementsPerDim() const;
634
635 /**
636 \brief
637 returns the number of face elements in the order
638 (left,right,bottom,top,[front,back]) on current MPI rank
639 */
640 RIPLEY_DLL_API
641 virtual IndexVector getNumFacesPerBoundary() const;
642
643 /**
644 \brief
645 returns the node distribution vector
646 */
647 RIPLEY_DLL_API
648 virtual IndexVector getNodeDistribution() const;
649
650 /**
651 \brief
652 returns the first coordinate value and the node spacing along given
653 dimension as a pair
654 */
655 RIPLEY_DLL_API
656 virtual std::pair<double,double> getFirstCoordAndSpacing(dim_t dim) const;
657
658 protected:
659 /// returns the number of nodes per MPI rank
660 virtual dim_t getNumNodes() const;
661
662 /// returns the number of elements per MPI rank
663 virtual dim_t getNumElements() const;
664
665 /// returns the number of face elements on current MPI rank
666 virtual dim_t getNumFaceElements() const;
667
668 virtual void assembleCoordinates(escript::Data& arg) const;
669
670 virtual Paso_SystemMatrixPattern* getPattern(bool reducedRowOrder,
671 bool reducedColOrder) const;
672
673 /// interpolates data on nodes in 'in' onto elements in 'out'
674 virtual void interpolateNodesOnElements(escript::Data& out, escript::Data& in) const;
675
676 /// interpolates data on nodes in 'in' onto face elements in 'out'
677 virtual void interpolateNodesOnFaces(escript::Data& out, escript::Data& in) const;
678
679 dim_t m_numDim;
680 StatusType m_status;
681 Esys_MPIInfo *m_mpiInfo;
682 TagMap m_tagMap;
683 };
684
685 } // end of namespace ripley
686
687 #endif // __RIPLEY_DOMAIN_H__
688

  ViewVC Help
Powered by ViewVC 1.1.26