ESScript  Revision_4488
AbstractDomain.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 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 since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 
17 #if !defined escript_AbstractDomain_20040609_H
18 #define escript_AbstractDomain_20040609_H
19 
20 #ifdef BADPYTHONMACROS
21 // This hack is required for BSD/OSX builds with python 2.7
22 // (and possibly others). It must be the first include.
23 // From bug reports online it seems that python redefines
24 // some c macros that are functions in c++.
25 // c++ doesn't like that!
26 #include <Python.h>
27 #undef BADPYTHONMACROS
28 #endif
29 
30 
31 #include "system_dep.h"
32 
33 #include <vector>
34 #include <string>
35 #include <map>
36 #include <boost/python/dict.hpp>
37 #include <boost/python/list.hpp>
38 #include "esysUtils/Esys_MPI.h"
39 
40 
41 #include "Pointers.h"
42 
43 namespace escript {
44 // class forward declarations
45 class Data;
55 
58 
60 
61  public:
62 
70  Domain_ptr getPtr();
72  const_Domain_ptr getPtr() const;
73 
74  // structure holding values for X, size and normal
75  typedef int StatusType;
76  struct ValueBuffer
77  {
78  StatusType m_status;
79  boost::shared_ptr<Data> m_data;
80  };
81  typedef struct ValueBuffer ValueBuffer;
82 
83  //
84  // map from function space type code to value buffer
85  typedef std::map<int, ValueBuffer> BufferMapType;
86 
87 
109  AbstractDomain();
110 
119  virtual ~AbstractDomain();
120 
126  virtual int getMPISize() const;
133  virtual int getMPIRank() const;
134 
141  virtual void MPIBarrier() const;
148  virtual bool onMasterProcessor() const;
149 
156  virtual
157 #ifdef ESYS_MPI
158  MPI_Comm
159 #else
160  unsigned int
161 #endif
162  getMPIComm() const;
163 
170  virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
171 
177  virtual std::string getDescription() const;
178 
184  virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
185 
193  virtual int getDim() const;
194 
200  virtual bool operator==(const AbstractDomain& other) const;
202  virtual bool operator!=(const AbstractDomain& other) const;
203 
211  virtual void write(const std::string& filename) const;
212 
220  virtual void dump(const std::string& filename) const;
221 
232  virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
233 
241  virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
242 
250  virtual void setTagMap(const std::string& name, int tag);
251 
258  virtual int getTag(const std::string& name) const;
259 
266  virtual bool isValidTagName(const std::string& name) const;
267 
273  virtual std::string showTagNames() const;
274 
281  virtual const int* borrowSampleReferenceIDs(int functionSpaceType) const;
282 
290  virtual void setNewX(const escript::Data& arg);
291 
299  virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
300 
305  virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
306 
314  virtual signed char preferredInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
315 
322  virtual
323  bool
324  commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
325 
333  virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
335  virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
336 
342  virtual escript::Data getX() const;
343 
349  virtual escript::Data getNormal() const;
350 
356  virtual escript::Data getSize() const;
357 
367  virtual void setToX(escript::Data& out) const;
368 
378  virtual void setToNormal(escript::Data& out) const;
379 
389  virtual void setToSize(escript::Data& out) const;
390 
399  virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
400 
406  virtual bool ownSample(int fs_code, index_t id) const;
407 
414  virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
415 
424  virtual bool isCellOriented(int functionSpaceCode) const;
425 
435  virtual StatusType getStatus() const;
436 
443  void throwStandardException(const std::string& functionName) const;
444 
450  virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
451 
453  virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
454 
459  virtual bool canTag(int functionspacecode) const;
460 
466  virtual int getApproximationOrder(const int functionSpaceCode) const;
467 
469  virtual bool supportsContactElements() const;
470 
471  protected:
472 
473  private:
474 
475  // buffer for coordinates used by function spaces
476  BufferMapType m_x_buffer;
477 
478  // buffer for normal vectors used by function spaces
479  BufferMapType m_normal_buffer;
480 
481  // buffer for normal element size used by function spaces
482  BufferMapType m_size_buffer;
483 
484 };
485 
486 } // end of namespace
487 
488 #endif