Overture
Version 25
Main Page
Namespaces
Classes
Files
File List
File Members
Overture.v25.d
include
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
6
class
MappingInformation
;
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
//================================================================
38
typedef
Mapping::coordinateSystem
coordinateSystem
;
39
typedef
Mapping::mappingSpace
mappingSpace
;
40
typedef
Mapping::periodicType
periodicType
;
41
typedef
Mapping::coordinateSingularity
coordinateSingularity
;
42
typedef
Mapping::basicInverseOptions
basicInverseOptions
;
43
typedef
Mapping::topologyEnum
topologyEnum
;
44
45
class
MappingRC
:
public
ReferenceCounting
46
{
47
public
:
48
49
enum
DataBaseModeEnum
50
{
51
doNotLinkMappings
=0,
52
linkMappings
53
};
54
55
56
static
int
setDataBaseMode
(
DataBaseModeEnum
mode);
57
static
DataBaseModeEnum
getDataBaseMode
();
58
59
Mapping
*
mapPointer
;
60
61
// construct a mapping with the given Class name, standard Mapping by default
62
MappingRC
(
const
aString
&
mappingClassName
=
nullString
);
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
(),
93
MappingParameters
& params =
Overture::nullMappingParameters
() );
94
95
// Map the range x back to the domain r
96
virtual
void
inverseMap
(
const
realArray
& x,
realArray
& r,
realArray
& rx =
Overture::nullRealDistributedArray
(),
97
MappingParameters
& params=
Overture::nullMappingParameters
() );
98
99
virtual
void
basicInverse
(
const
realArray
& x,
realArray
& r,
realArray
& rx =
Overture::nullRealDistributedArray
(),
100
MappingParameters
& params=
Overture::nullMappingParameters
() );
101
102
virtual
void
mapGrid
(
const
realArray
& r,
103
realArray
& x,
104
realArray
& xr =
Overture::nullRealDistributedArray
(),
105
MappingParameters
& params=
Overture::nullMappingParameters
() );
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
(),
110
MappingParameters
& params =
Overture::nullMappingParameters
());
111
virtual
void
inverseMapC
(
const
realArray
& x,
const
realArray
& r,
const
realArray
& rx =
Overture::nullRealDistributedArray
(),
112
MappingParameters
& params =
Overture::nullMappingParameters
());
113
114
// Map the domain r to the range x
115
virtual
void
mapS
(
const
RealArray
& r,
RealArray
& x,
RealArray
&xr =
Overture::nullRealArray
(),
116
MappingParameters
& params =
Overture::nullMappingParameters
());
117
118
// Map the range x back to the domain r
119
virtual
void
inverseMapS
(
const
RealArray
& x,
RealArray
& r,
RealArray
& rx =
Overture::nullRealArray
(),
120
MappingParameters
& params =
Overture::nullMappingParameters
());
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,
129
RealArray
& rx =
Overture::nullRealArray
(),
130
MappingParameters
& params =
Overture::nullMappingParameters
());
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
(),
135
MappingParameters
& params =
Overture::nullMappingParameters
());
136
virtual
void
inverseMapCS
(
const
RealArray
& x,
const
RealArray
& r,
const
RealArray
& rx =
Overture::nullRealArray
(),
137
MappingParameters
& params =
Overture::nullMappingParameters
());
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,
142
RealArray
& xr =
Overture::nullRealArray
(),
143
MappingParameters
& params=
Overture::nullMappingParameters
() );
144
145
// inverse map a grid of points
146
virtual
void
inverseMapGridS
(
const
RealArray
& x,
147
RealArray
& r,
148
RealArray
& rx =
Overture::nullRealArray
(),
149
MappingParameters
& params=
Overture::nullMappingParameters
() );
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
163
basicInverseOptions
getBasicInverseOption
()
const
;
164
int
getBoundaryCondition
(
const
int
side,
const
int
axis )
const
;
165
virtual
aString
getClassName
()
const
;
166
int
getCoordinateEvaluationType
(
const
Mapping::coordinateSystem
type )
const
;
167
Bound
getDomainBound
(
const
int
side,
const
int
axis )
const
;
168
coordinateSystem
getDomainCoordinateSystem
()
const
;
169
Bound
getDomainCoordinateSystemBound
(
const
int
side,
const
int
axis )
const
;
170
int
getDomainDimension
()
const
;
171
mappingSpace
getDomainSpace
()
const
;
172
int
getGridDimensions
(
const
int
axis )
const
;
173
virtual
const
realArray
&
getGrid
(
MappingParameters
& params=
Overture::nullMappingParameters
());
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
;
181
coordinateSystem
getRangeCoordinateSystem
()
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
//
242
virtual
ReferenceCounting
&
operator=
(
const
ReferenceCounting
& x)
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
Generated on Fri Jan 4 2013 10:17:55 for Overture by
1.8.3