/[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 6144 - (show annotations)
Wed Apr 6 05:25:13 2016 UTC (2 years, 7 months ago) by caltinay
File MIME type: text/plain
File size: 16574 byte(s)
last round of namespacing defines.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26