22 |
#include "escript/Data/Data.h" |
#include "escript/Data/Data.h" |
23 |
|
|
24 |
#include <string> |
#include <string> |
25 |
|
#include <vector> |
26 |
|
|
27 |
namespace bruce { |
namespace bruce { |
28 |
|
|
42 |
|
|
43 |
// |
// |
44 |
// Codes for function space types supported |
// Codes for function space types supported |
45 |
static const int Nodes; |
static const int ContinuousFunction; |
46 |
static const int Elements; |
static const int Function; |
47 |
|
|
48 |
|
// |
49 |
|
// Type of FunctionSpaceNamesMap |
50 |
|
typedef std::map<int, std::string> FunctionSpaceNamesMapType; |
51 |
|
|
52 |
|
// |
53 |
|
// Types for the dimension vectors |
54 |
|
typedef std::vector<double> DimVec; |
55 |
|
|
56 |
/** |
/** |
57 |
\brief |
\brief |
58 |
Constructor for Bruce. |
Default constructor for Bruce. |
59 |
|
|
60 |
Description: |
Description: |
61 |
Constructor for Bruce. |
Default constructor for Bruce. |
62 |
|
Creates a null Bruce object. |
63 |
*/ |
*/ |
64 |
Bruce(); |
Bruce(); |
65 |
|
|
66 |
/** |
/** |
67 |
\brief |
\brief |
68 |
|
Constructor for Bruce. |
69 |
|
|
70 |
|
Description: |
71 |
|
Constructor for Bruce. |
72 |
|
|
73 |
|
The point "origin" specifies the location of the origin |
74 |
|
of the domain specified by this object. The dimensionality of this |
75 |
|
point determines the dimensionality of the space the domain occupies. |
76 |
|
|
77 |
|
The vectors v0,v1,v2 specify the axis in |
78 |
|
of the domain of this Bruce object. If v2 is an empty vector, this |
79 |
|
object is a two dimensional domain. If v1 is also an empty vector, |
80 |
|
this object is a one dimensional domain. If v0 is also an empty |
81 |
|
vector, this is a point domain. |
82 |
|
|
83 |
|
The integers n0,n1,n2 specify the dumber of data-points along each |
84 |
|
axis in the domain. |
85 |
|
*/ |
86 |
|
Bruce(DimVec v0, DimVec v1, DimVec v2, |
87 |
|
int n0, int n1, int n2, |
88 |
|
DimVec origin); |
89 |
|
|
90 |
|
/** |
91 |
|
\brief |
92 |
Copy constructor. |
Copy constructor. |
93 |
*/ |
*/ |
94 |
Bruce(const Bruce& other); |
Bruce(const Bruce& other); |
107 |
const AbstractContinuousDomain& |
const AbstractContinuousDomain& |
108 |
asAbstractContinuousDomain() const |
asAbstractContinuousDomain() const |
109 |
{ |
{ |
110 |
return *(static_cast<const AbstractContinuousDomain*>(this)); |
return *(static_cast<const AbstractContinuousDomain*>(this)); |
111 |
} |
} |
112 |
|
|
113 |
/** |
/** |
118 |
const AbstractDomain& |
const AbstractDomain& |
119 |
asAbstractDomain() const |
asAbstractDomain() const |
120 |
{ |
{ |
121 |
return *(static_cast<const AbstractDomain*>(this)); |
return *(static_cast<const AbstractDomain*>(this)); |
122 |
} |
} |
123 |
|
|
124 |
/** |
/** |
125 |
\brief |
\brief |
126 |
|
Return a description for this domain. |
127 |
|
*/ |
128 |
|
virtual |
129 |
|
std::string |
130 |
|
getDescription() const; |
131 |
|
|
132 |
|
/** |
133 |
|
\brief |
134 |
Returns true if the given integer is a valid function space type |
Returns true if the given integer is a valid function space type |
135 |
for this domain. |
for this domain. |
136 |
*/ |
*/ |
137 |
virtual |
virtual |
138 |
bool |
bool |
139 |
isValidFunctionSpaceType(int functionSpaceType) const; |
isValidFunctionSpaceType(int functionSpaceCode) const; |
140 |
|
|
141 |
|
/** |
142 |
|
\brief |
143 |
|
Return a description for the given function space type code. |
144 |
|
*/ |
145 |
|
virtual |
146 |
|
std::string |
147 |
|
functionSpaceTypeAsString(int functionSpaceCode) const; |
148 |
|
|
149 |
|
/** |
150 |
|
\brief |
151 |
|
Return a continuous FunctionSpace code. |
152 |
|
*/ |
153 |
|
virtual |
154 |
|
int |
155 |
|
getContinuousFunctionCode() const; |
156 |
|
|
157 |
|
/** |
158 |
|
\brief |
159 |
|
Return a function FunctionSpace code. |
160 |
|
*/ |
161 |
|
virtual |
162 |
|
int |
163 |
|
getFunctionCode() const; |
164 |
|
|
165 |
/** |
/** |
166 |
\brief |
\brief |
189 |
|
|
190 |
/** |
/** |
191 |
\brief |
\brief |
192 |
|
Copies the location of data points on the domain into out. |
193 |
|
*/ |
194 |
|
virtual |
195 |
|
void |
196 |
|
setToX(escript::Data& out) const; |
197 |
|
|
198 |
|
/** |
199 |
|
\brief |
200 |
Returns the element size. |
Returns the element size. |
201 |
*/ |
*/ |
202 |
virtual |
virtual |
205 |
|
|
206 |
/** |
/** |
207 |
\brief |
\brief |
208 |
|
Copies the size of samples into out. |
209 |
|
*/ |
210 |
|
virtual |
211 |
|
void |
212 |
|
setToSize(escript::Data& out) const; |
213 |
|
|
214 |
|
/** |
215 |
|
\brief |
216 |
Comparison operators. |
Comparison operators. |
217 |
*/ |
*/ |
218 |
virtual bool operator==(const AbstractDomain& other) const; |
virtual bool operator==(const AbstractDomain& other) const; |
220 |
|
|
221 |
protected: |
protected: |
222 |
|
|
223 |
|
/** |
224 |
|
\brief |
225 |
|
Build the table of function space type names. |
226 |
|
*/ |
227 |
|
void |
228 |
|
setFunctionSpaceTypeNames(); |
229 |
|
|
230 |
|
/** |
231 |
|
\brief |
232 |
|
Ensure the parameters supplied to the constructor are valid. |
233 |
|
*/ |
234 |
|
bool |
235 |
|
checkParameters(); |
236 |
|
|
237 |
|
/** |
238 |
|
\brief |
239 |
|
Check if all components of vector are zero. |
240 |
|
*/ |
241 |
|
bool |
242 |
|
isZero(DimVec vec) const; |
243 |
|
|
244 |
private: |
private: |
245 |
|
|
246 |
|
// |
247 |
|
// vectors describing axis of the domain |
248 |
|
DimVec m_v0, m_v1, m_v2; |
249 |
|
|
250 |
|
// |
251 |
|
// number of data points in each axial direction of the domain |
252 |
|
int m_n0, m_n1, m_n2; |
253 |
|
|
254 |
|
// |
255 |
|
// the coordinates of the origin of the domain |
256 |
|
DimVec m_origin; |
257 |
|
|
258 |
|
// |
259 |
|
// map from FunctionSpace codes to names |
260 |
|
static FunctionSpaceNamesMapType m_functionSpaceTypeNames; |
261 |
|
|
262 |
}; |
}; |
263 |
|
|
264 |
} // end of namespace |
} // end of namespace |