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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5136 - (show annotations)
Tue Sep 9 07:13:55 2014 UTC (4 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 17903 byte(s)
ripley now supports paso solvers again and returns an appropriate matrix type
id. Changed the getSystemMatrixTypeId() method to take a full SolverBuddy
instance and made some other simplifications.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26