1 |
jgs |
102 |
// $Id$ |
2 |
jgs |
82 |
/* |
3 |
elspeth |
615 |
************************************************************ |
4 |
|
|
* Copyright 2006 by ACcESS MNRF * |
5 |
|
|
* * |
6 |
|
|
* http://www.access.edu.au * |
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 |
|
|
************************************************************ |
12 |
|
|
|
13 |
jgs |
82 |
*/ |
14 |
jgs |
115 |
|
15 |
|
|
#if !defined escript_AbstractDomain_20040609_H |
16 |
jgs |
82 |
#define escript_AbstractDomain_20040609_H |
17 |
jgs |
115 |
|
18 |
jgs |
82 |
#include <string> |
19 |
jgs |
153 |
#include <boost/python/dict.hpp> |
20 |
jgs |
82 |
|
21 |
|
|
namespace escript { |
22 |
|
|
|
23 |
jgs |
117 |
// |
24 |
jgs |
149 |
// forward declarations |
25 |
jgs |
117 |
class Data; |
26 |
jgs |
480 |
//class AbstractSystemMatrix; |
27 |
|
|
//class FunctionSpace; |
28 |
jgs |
115 |
|
29 |
jgs |
82 |
/** |
30 |
|
|
\brief |
31 |
|
|
Base class for all escript domains. |
32 |
|
|
|
33 |
|
|
Description: |
34 |
|
|
Base class for all escript domains. |
35 |
|
|
*/ |
36 |
jgs |
115 |
|
37 |
jgs |
82 |
class AbstractDomain { |
38 |
|
|
|
39 |
|
|
public: |
40 |
|
|
|
41 |
|
|
/** |
42 |
|
|
\brief |
43 |
jgs |
117 |
Default constructor for AbstractDomain. |
44 |
jgs |
82 |
|
45 |
|
|
Description: |
46 |
|
|
Default constructor for AbstractDomain. As the name suggests |
47 |
|
|
this is intended to be an abstract base class but by making it |
48 |
jgs |
117 |
constructable we avoid a boost.python wrapper class. A call to |
49 |
jgs |
82 |
almost any of the base class functions will throw an exception |
50 |
jgs |
115 |
as they are not intended to be used directly, but are overridden |
51 |
jgs |
117 |
by the underlying solver package which escript is linked to. |
52 |
jgs |
82 |
|
53 |
jgs |
115 |
By default, this class is overridden by the class NullDomain. |
54 |
|
|
|
55 |
jgs |
82 |
Preconditions: |
56 |
jgs |
117 |
Describe any preconditions. |
57 |
jgs |
82 |
|
58 |
|
|
Throws: |
59 |
jgs |
117 |
Describe any exceptions thrown. |
60 |
jgs |
82 |
*/ |
61 |
|
|
AbstractDomain(); |
62 |
jgs |
115 |
|
63 |
jgs |
82 |
/** |
64 |
|
|
\brief |
65 |
jgs |
117 |
Destructor for AbstractDomain. |
66 |
jgs |
82 |
|
67 |
|
|
Description: |
68 |
jgs |
117 |
Destructor for AbstractDomain. |
69 |
jgs |
82 |
*/ |
70 |
|
|
virtual ~AbstractDomain(); |
71 |
jgs |
115 |
|
72 |
jgs |
82 |
/** |
73 |
|
|
\brief |
74 |
|
|
Returns true if the given integer is a valid function space type |
75 |
|
|
for this domain. |
76 |
|
|
*/ |
77 |
|
|
virtual bool isValidFunctionSpaceType(int functionSpaceType) const; |
78 |
jgs |
115 |
|
79 |
jgs |
82 |
/** |
80 |
|
|
\brief |
81 |
jgs |
117 |
Return a description for this domain. |
82 |
jgs |
82 |
*/ |
83 |
|
|
virtual std::string getDescription() const; |
84 |
jgs |
115 |
|
85 |
jgs |
82 |
/** |
86 |
|
|
\brief |
87 |
jgs |
117 |
Return a description for the given function space type code. |
88 |
jgs |
82 |
*/ |
89 |
|
|
virtual std::string functionSpaceTypeAsString(int functionSpaceType) const; |
90 |
jgs |
115 |
|
91 |
jgs |
82 |
/** |
92 |
|
|
\brief |
93 |
jgs |
117 |
Returns the spatial dimension of the domain. |
94 |
jgs |
115 |
|
95 |
jgs |
117 |
This has to be implemented by the actual Domain adapter. |
96 |
jgs |
82 |
*/ |
97 |
|
|
virtual int getDim() const; |
98 |
|
|
|
99 |
|
|
/** |
100 |
jgs |
117 |
\brief |
101 |
|
|
Return true if given domains are equal. |
102 |
jgs |
82 |
*/ |
103 |
jgs |
121 |
virtual bool operator==(const AbstractDomain& other) const; |
104 |
|
|
virtual bool operator!=(const AbstractDomain& other) const; |
105 |
jgs |
115 |
|
106 |
jgs |
82 |
/** |
107 |
|
|
\brief |
108 |
jgs |
117 |
Writes the domain to an external file filename. |
109 |
|
|
|
110 |
jgs |
115 |
This has to be implemented by the actual Domain adapter. |
111 |
jgs |
82 |
*/ |
112 |
|
|
virtual void write(const std::string& filename) const; |
113 |
|
|
|
114 |
|
|
/** |
115 |
|
|
\brief |
116 |
|
|
Return the number of data points per sample, and the number of samples as a pair. |
117 |
jgs |
117 |
|
118 |
|
|
This has to be implemented by the actual Domain adapter. |
119 |
|
|
|
120 |
jgs |
82 |
\param functionSpaceCode Input - Code for the function space type. |
121 |
|
|
\return pair, first - number of data points per sample, second - number of samples |
122 |
|
|
*/ |
123 |
|
|
virtual std::pair<int,int> getDataShape(int functionSpaceCode) const; |
124 |
|
|
|
125 |
|
|
/** |
126 |
|
|
\brief |
127 |
|
|
Return the tag key for the given sample number. |
128 |
|
|
\param functionSpaceType Input - The function space type. |
129 |
|
|
\param sampleNo Input - The sample number. |
130 |
|
|
*/ |
131 |
|
|
virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const; |
132 |
jgs |
115 |
|
133 |
jgs |
82 |
/** |
134 |
|
|
\brief |
135 |
jgs |
115 |
Return the reference number of the given sample number. |
136 |
jgs |
110 |
\param functionSpaceType Input - The function space type. |
137 |
|
|
\param sampleNo Input - The sample number. |
138 |
|
|
*/ |
139 |
|
|
virtual int getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const; |
140 |
jgs |
115 |
|
141 |
jgs |
110 |
/** |
142 |
|
|
\brief |
143 |
jgs |
117 |
Assigns new location to the domain. |
144 |
|
|
|
145 |
|
|
This has to be implemented by the actual Domain adapter. |
146 |
jgs |
82 |
*/ |
147 |
|
|
virtual void setNewX(const escript::Data& arg); |
148 |
|
|
|
149 |
|
|
/** |
150 |
|
|
\brief |
151 |
jgs |
115 |
Interpolates data given on source onto target where source and target have to be given on the same domain. |
152 |
jgs |
117 |
|
153 |
|
|
This has to be implemented by the actual Domain adapter. |
154 |
jgs |
82 |
*/ |
155 |
|
|
virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const; |
156 |
|
|
virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const; |
157 |
jgs |
115 |
|
158 |
jgs |
82 |
/** |
159 |
|
|
\brief |
160 |
jgs |
115 |
Interpolates data given on source onto target where source and target are given on different domains. |
161 |
jgs |
117 |
|
162 |
|
|
This has to be implemented by the actual Domain adapter. |
163 |
jgs |
82 |
*/ |
164 |
|
|
virtual void interpolateACross(escript::Data& target, const escript::Data& source) const; |
165 |
|
|
virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const; |
166 |
|
|
|
167 |
|
|
/** |
168 |
jgs |
117 |
\brief |
169 |
|
|
Returns locations in the domain. The function space is chosen appropriately. |
170 |
jgs |
102 |
*/ |
171 |
|
|
virtual escript::Data getX() const; |
172 |
jgs |
115 |
|
173 |
jgs |
102 |
/** |
174 |
jgs |
117 |
\brief |
175 |
|
|
Return boundary normals. The function space is chosen appropriately. |
176 |
jgs |
102 |
*/ |
177 |
|
|
virtual escript::Data getNormal() const; |
178 |
jgs |
115 |
|
179 |
jgs |
102 |
/** |
180 |
jgs |
117 |
\brief |
181 |
|
|
Returns the local size of samples. The function space is chosen appropriately. |
182 |
jgs |
102 |
*/ |
183 |
|
|
virtual escript::Data getSize() const; |
184 |
|
|
|
185 |
|
|
/** |
186 |
jgs |
82 |
\brief |
187 |
jgs |
115 |
Copies the location of data points on the domain into out. |
188 |
|
|
The actual function space to be considered |
189 |
jgs |
82 |
is defined by out. out has to be defined on this. |
190 |
jgs |
117 |
|
191 |
|
|
This has to be implemented by the actual Domain adapter. |
192 |
jgs |
82 |
*/ |
193 |
|
|
virtual void setToX(escript::Data& out) const; |
194 |
jgs |
115 |
|
195 |
jgs |
82 |
/** |
196 |
|
|
\brief |
197 |
jgs |
115 |
Copies the surface normals at data points into out. |
198 |
|
|
The actual function space to be considered |
199 |
jgs |
82 |
is defined by out. out has to be defined on this. |
200 |
jgs |
117 |
|
201 |
|
|
This has to be implemented by the actual Domain adapter. |
202 |
jgs |
82 |
*/ |
203 |
|
|
virtual void setToNormal(escript::Data& out) const; |
204 |
jgs |
115 |
|
205 |
jgs |
82 |
/** |
206 |
|
|
\brief |
207 |
jgs |
115 |
Copies the size of samples into out. The actual |
208 |
|
|
function space to be considered |
209 |
jgs |
82 |
is defined by out. out has to be defined on this. |
210 |
jgs |
117 |
|
211 |
|
|
This has to be implemented by the actual Domain adapter. |
212 |
jgs |
82 |
*/ |
213 |
|
|
virtual void setToSize(escript::Data& out) const; |
214 |
|
|
|
215 |
|
|
/** |
216 |
|
|
\brief |
217 |
jgs |
115 |
Copies the gradient of arg into grad. The actual function space to be considered |
218 |
jgs |
82 |
for the gradient is defined by grad. arg and grad have to be defined on this. |
219 |
jgs |
117 |
|
220 |
|
|
This has to be implemented by the actual Domain adapter. |
221 |
jgs |
82 |
*/ |
222 |
|
|
virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const; |
223 |
|
|
/** |
224 |
|
|
\brief |
225 |
jgs |
153 |
Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier |
226 |
jgs |
117 |
|
227 |
|
|
This has to be implemented by the actual Domain adapter. |
228 |
jgs |
82 |
*/ |
229 |
jgs |
153 |
virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const; |
230 |
jgs |
110 |
|
231 |
jgs |
82 |
/** |
232 |
|
|
\brief |
233 |
jgs |
153 |
Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier |
234 |
jgs |
117 |
|
235 |
|
|
This has to be implemented by the actual Domain adapter. |
236 |
jgs |
110 |
*/ |
237 |
jgs |
153 |
virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const; |
238 |
jgs |
110 |
|
239 |
|
|
/** |
240 |
|
|
\brief |
241 |
jgs |
82 |
returns the function space representation of the type functionSpaceCode on this domain |
242 |
|
|
as a vtkObject. |
243 |
jgs |
117 |
|
244 |
|
|
This has to be implemented by the actual Domain adapter. |
245 |
jgs |
82 |
*/ |
246 |
|
|
//virtual vtkObject createVtkObject(int functionSpaceCode) const; |
247 |
|
|
|
248 |
jgs |
115 |
/** |
249 |
jgs |
82 |
\brief |
250 |
|
|
returns true if data on this domain and a function space of type functionSpaceCode has to |
251 |
|
|
considered as cell centered data. |
252 |
jgs |
117 |
|
253 |
|
|
This has to be implemented by the actual Domain adapter. |
254 |
jgs |
82 |
*/ |
255 |
|
|
virtual bool isCellOriented(int functionSpaceCode) const; |
256 |
|
|
|
257 |
jgs |
117 |
/** |
258 |
|
|
\brief |
259 |
|
|
Throw a standard exception. This function is called if any attempt |
260 |
|
|
is made to use a base class function. |
261 |
|
|
*/ |
262 |
|
|
void throwStandardException(const std::string& functionName) const; |
263 |
|
|
|
264 |
jgs |
82 |
protected: |
265 |
|
|
|
266 |
|
|
private: |
267 |
jgs |
115 |
|
268 |
jgs |
82 |
}; |
269 |
|
|
|
270 |
|
|
} // end of namespace |
271 |
jgs |
117 |
|
272 |
jgs |
82 |
#endif |