Overture  Version 25
MappingRC.h
Go to the documentation of this file.
1 #ifndef MAPPING_RC_H
2 #define MAPPING_RC_H "MappingRC.h"
3 
4 #include "Mapping.h"
5 
7 
8 //=================================================================
9 // Reference Counted Class for class Mapping
10 //
11 // Use this class to hold a pointer to a mapping. An object of this
12 // class behaves in many ways like a Mapping since all the member
13 // functions of the base class are directly available. This class is
14 // needed since the Mapping class is not have full support for
15 // reference counting since we want to simplify the process of
16 // writing new Mappings by derivation.
17 //
18 //
19 // Examples
20 //
21 // SquareMapping square; // here is a regular mapping
22 // MappingRC maprc(square); // make a MappingRC that points to square
23 // ...
24 // maprc.map(r,x,xr ); // evaluate like a regular mapping
25 //
26 // MappingRC maprc2("SquareMapping"); // make a mapping with the given class name
27 // maprc2=square; // deep copy
28 // maprc2=maprc3; // deep copy
29 //
30 // MappingRC maprc3;
31 // maprc3.reference(square); // reference to a Mapping
32 // maprc3.reference(maprc2); // reference to a MappingRC
33 // ...
34 // maprc3.breakReference();
35 //
36 //
37 //================================================================
44 
46 {
47  public:
48 
50  {
53  };
54 
55 
56  static int setDataBaseMode(DataBaseModeEnum mode);
58 
60 
61  // construct a mapping with the given Class name, standard Mapping by default
63 
64  MappingRC( Mapping & map ); // constructor, assign pointer to the given mapping
65 
66  ~MappingRC();
67 
68  // ----- copy constructor, deep copy by default----
69  MappingRC( const MappingRC & maprc, const CopyType copyType=DEEP );
70 
71  // ---Assignment operator : deep copy ---
72  virtual MappingRC & operator=( const MappingRC & maprc );
73 
74  // ---Assignment operator : deep copy ---
75  virtual MappingRC & operator=( const Mapping & maprc );
76 
77  // reference to another MappingRC
78  virtual void reference( const MappingRC & maprc );
79  // reference to a Mapping
80  virtual void reference( const Mapping & map );
81 
82  //-----------------------------------------------------------------------------------
83  // To break a reference we make a new copy!
84  //---------------------------------------------------------------------------------
85  virtual void breakReference();
86 
87  // This function is used to create a new member of the Class provided the
88  // mappingClassName is equal to the name of the class
89  virtual Mapping *make( const aString & mappingClassName );
90 
91  // Map the domain r to the range x
92  virtual void map( const realArray & r, realArray & x, realArray &xr = Overture::nullRealDistributedArray(),
94 
95  // Map the range x back to the domain r
96  virtual void inverseMap( const realArray & x, realArray & r, realArray & rx =Overture::nullRealDistributedArray(),
98 
99  virtual void basicInverse( const realArray & x, realArray & r, realArray & rx =Overture::nullRealDistributedArray(),
101 
102  virtual void mapGrid(const realArray & r,
103  realArray & x,
106 
107  // Here are versions of map and inverseMap needed by some compilers (IBM:xlC) that don't like passing
108  // views of arrays to non-const references, as in mapping.mapC(r(I),x(I),xr(I))
109  virtual void mapC( const realArray & r, const realArray & x, const realArray &xr = Overture::nullRealDistributedArray(),
111  virtual void inverseMapC( const realArray & x, const realArray & r, const realArray & rx =Overture::nullRealDistributedArray(),
113 
114  // Map the domain r to the range x
115  virtual void mapS( const RealArray & r, RealArray & x, RealArray &xr = Overture::nullRealArray(),
117 
118  // Map the range x back to the domain r
119  virtual void inverseMapS( const RealArray & x, RealArray & r, RealArray & rx =Overture::nullRealArray(),
121 
122  // If you know the inverse of your mapping supply this next function,
123  // and set basicInverseOption=canInvert
124  // If you don't know the inverse but know how to determine if a point is not in the
125  // range (better than a bounding box) then set supply this function,
126  // and set basicInverseOption=canDetermineOutside
127  virtual void basicInverseS(const RealArray & x,
128  RealArray & r,
131 
132  // Here are versions of map and inverseMap needed by some compilers (IBM:xlC) that don't like passing
133  // views of arrays to non-const references, as in mapping.mapC(r(I),x(I),xr(I))
134  virtual void mapCS( const RealArray & r, const RealArray & x, const RealArray &xr = Overture::nullRealArray(),
136  virtual void inverseMapCS( const RealArray & x, const RealArray & r, const RealArray & rx =Overture::nullRealArray(),
138 
139  // map a grid of points: r(0:n1,1), or r(0:n1,0:n2,2) or r((0:n1,0:n2,0:n3,3) for 1, 2 or 3d
140  virtual void mapGridS(const RealArray & r,
141  RealArray & x,
144 
145  // inverse map a grid of points
146  virtual void inverseMapGridS(const RealArray & x,
147  RealArray & r,
150 
151 
152  // return size of this object
153  virtual real sizeOf(FILE *file = NULL ) const;
154 
155  virtual void update( MappingInformation & mapInfo ); // update mapping, change parameters interactively
156 
157  virtual void display( const aString & label ) const;
158 
159  int checkMapping(); // Check the mapping - check derivatives and inverse, return 0 if ok
160 
161 //--------------Access Functions-----------------------------
162 
164  int getBoundaryCondition( const int side, const int axis ) const;
165  virtual aString getClassName() const;
167  Bound getDomainBound( const int side, const int axis ) const;
169  Bound getDomainCoordinateSystemBound( const int side, const int axis ) const;
170  int getDomainDimension() const;
172  int getGridDimensions( const int axis ) const;
174  int getID() const;
175  int getInvertible() const;
176  aString getName( const Mapping::mappingItemName item ) const;
177  periodicType getIsPeriodic( const int axis ) const;
178  real getPeriodVector( const int axis, const int direction ) const;
179  int getRangeDimension() const;
180  Bound getRangeBound( const int side, const int axis ) const;
182  Bound getRangeCoordinateSystemBound( const int side, const int axis ) const;
183  mappingSpace getRangeSpace() const;
184  int getShare( const int side, const int axis ) const;
185  real getSignForJacobian() const;
186  topologyEnum getTopology( const int side, const int axis ) const;
187  coordinateSingularity getTypeOfCoordinateSingularity( const int side, const int axis ) const ;
188 
189 
190 // --------------set functions-------------------------
191 
192  void setBasicInverseOption( const basicInverseOptions option );
193  void setBoundaryCondition( const int side, const int axis, const int bc );
194  void setCoordinateEvaluationType( const Mapping::coordinateSystem type, const int trueOrFalse );
195  void setDomainDimension( const int domainDimension );
196  void setDomainBound( const int side, const int axis, const Bound domainBound );
197  void setDomainCoordinateSystem( const Mapping::coordinateSystem domainCoordinateSystem );
198  void setDomainCoordinateSystemBound( const int side, const int axis,
199  const Bound domainCoordinateSystemBound );
200  void setDomainSpace( const Mapping::mappingSpace domainSpace );
201  void setGrid(realArray & grid, IntegerArray & gridIndexRange);
202  void setGridDimensions( const int axis, const int dim );
203  void setInvertible( const int invertible );
204  void setID();
205  void setIsPeriodic( const int axis, const Mapping::periodicType isPeriodic );
206  void setName( const Mapping::mappingItemName item, const aString & name );
207  void setPeriodVector( const int axis, const int direction, const real periodVectorComponent );
208  void setRangeDimension( const int rangeDimension );
209  void setRangeSpace( const Mapping::mappingSpace rangeSpace );
210  void setRangeCoordinateSystem( const Mapping::coordinateSystem rangeCoordinateSystem );
211  void setRangeBound( const int side, const int axis, const Bound rangeBound );
212  void setRangeCoordinateSystemBound( const int side, const int axis,
213  const Bound rangeCoordinateSystemBound );
214  void setShare( const int side, const int axis, const int share );
215  void setSignForJacobian( const real signForJac );
216  void setTopology( const int side, const int axis, const topologyEnum topo );
217 
218  void setTypeOfCoordinateSingularity( const int side, const int axis,
219  const Mapping::coordinateSingularity type );
220 
221  bool usesDistributedInverse() const;
222  void useRobustInverse(const bool trueOrFalse=TRUE );
223 
224 
225  // get from a database file: (optionally supply the partition to use in the Mapping)
226  virtual int get( const GenericDataBase & dir, const aString & name, Partitioning_Type *partition=NULL);
227  virtual int put( GenericDataBase & dir, const aString & name) const; // put to a database file
228 
229  // return a reference to the Mapping, an error occurs if there is no Mapping
230  Mapping & getMapping() const;
231 
232  private :
233  int uncountedReferencesMayExist; // =1 if Mapping is not reference counted
234  void initialize( const aString & mappingClassName );
235 
236  static DataBaseModeEnum dataBaseMode;
237 
238  private:
239  //
240  // Virtual member functions used only through class ReferenceCounting:
241  //
243  { return operator=(*(MappingRC*)&x); }
244  virtual void reference(const ReferenceCounting& x)
245  { reference((MappingRC &) x); }
246  virtual ReferenceCounting* virtualConstructor( const CopyType ct = DEEP ) const
247  { return ::new MappingRC(*this, ct); }
248 
249 };
250 
251 #endif