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

Contents of /branches/domexper/dudley/src/CPPAdapter/MeshAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3220 - (show annotations)
Wed Sep 29 00:33:16 2010 UTC (8 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 19176 byte(s)
Removing references to Quadrature.? and ShapeFns

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26