/[escript]/trunk-mpi-branch/escript/src/AbstractDomain.h
ViewVC logotype

Contents of /trunk-mpi-branch/escript/src/AbstractDomain.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1223 - (show annotations)
Fri Aug 3 02:40:39 2007 UTC (11 years, 8 months ago) by gross
File MIME type: text/plain
File size: 10310 byte(s)
first attemt towards an improved MPI version.  

1 // $Id$
2 /*
3 ************************************************************
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 */
14
15 #if !defined escript_AbstractDomain_20040609_H
16 #define escript_AbstractDomain_20040609_H
17
18 #include "system_dep.h"
19
20 #include <string>
21 #include <map>
22 #include <boost/python/dict.hpp>
23
24 namespace escript {
25 // class forward declarations
26 class Data;
27 /**
28 \brief
29 Base class for all escript domains.
30
31 Description:
32 Base class for all escript domains.
33 */
34
35 class AbstractDomain {
36
37 public:
38
39
40 // structure holding values for X, size and normal
41 typedef int StatusType;
42 struct ValueBuffer
43 {
44 StatusType m_status;
45 boost::shared_ptr<Data> m_data;
46 };
47 typedef struct ValueBuffer ValueBuffer;
48
49 //
50 // map from function space type code to value buffer
51 typedef std::map<int, ValueBuffer> BufferMapType;
52
53
54 /**
55 \brief
56 Default constructor for AbstractDomain.
57
58 Description:
59 Default constructor for AbstractDomain. As the name suggests
60 this is intended to be an abstract base class but by making it
61 constructable we avoid a boost.python wrapper class. A call to
62 almost any of the base class functions will throw an exception
63 as they are not intended to be used directly, but are overridden
64 by the underlying solver package which escript is linked to.
65
66 By default, this class is overridden by the class NullDomain.
67
68 Preconditions:
69 Describe any preconditions.
70
71 Throws:
72 Describe any exceptions thrown.
73 */
74 ESCRIPT_DLL_API
75 AbstractDomain();
76
77 /**
78 \brief
79 Destructor for AbstractDomain.
80
81 Description:
82 Destructor for AbstractDomain.
83 */
84 ESCRIPT_DLL_API
85 virtual ~AbstractDomain();
86
87 /**
88 \brief
89 return the number of processors used for this domain
90 */
91 ESCRIPT_DLL_API
92 virtual int getMPISize() const;
93 /**
94 \brief
95 return the number MPI rank of this processor
96 */
97
98 ESCRIPT_DLL_API
99 virtual int getMPIRank() const;
100
101
102
103 /**
104 \brief
105 Returns true if the given integer is a valid function space type
106 for this domain.
107 */
108 ESCRIPT_DLL_API
109 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
110
111 /**
112 \brief
113 Return a description for this domain.
114 */
115 ESCRIPT_DLL_API
116 virtual std::string getDescription() const;
117
118 /**
119 \brief
120 Return a description for the given function space type code.
121 */
122 ESCRIPT_DLL_API
123 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
124
125 /**
126 \brief
127 Returns the spatial dimension of the domain.
128
129 This has to be implemented by the actual Domain adapter.
130 */
131 ESCRIPT_DLL_API
132 virtual int getDim() const;
133
134 /**
135 \brief
136 Return true if given domains are equal.
137 */
138 ESCRIPT_DLL_API
139 virtual bool operator==(const AbstractDomain& other) const;
140 ESCRIPT_DLL_API
141 virtual bool operator!=(const AbstractDomain& other) const;
142
143 /**
144 \brief
145 Writes the domain to an external file filename.
146
147 This has to be implemented by the actual Domain adapter.
148 */
149 ESCRIPT_DLL_API
150 virtual void write(const std::string& filename) const;
151
152 /**
153 \brief
154 Return the number of data points per sample, and the number of samples as a pair.
155
156 This has to be implemented by the actual Domain adapter.
157
158 \param functionSpaceCode Input - Code for the function space type.
159 \return pair, first - number of data points per sample, second - number of samples
160 */
161 ESCRIPT_DLL_API
162 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
163
164 /**
165 \brief
166 Return the tag key for the given sample number.
167 \param functionSpaceType Input - The function space type.
168 \param sampleNo Input - The sample number.
169 */
170 ESCRIPT_DLL_API
171 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
172
173 /**
174 \brief
175 sets a map from a clear tag name to a tag key
176 \param name Input - tag name.
177 \param tag Input - tag key.
178 */
179 ESCRIPT_DLL_API
180 virtual void setTagMap(const std::string& name, int tag);
181
182 /**
183 \brief
184 Return the tag key for tag name.
185 \param name Input - tag name
186 */
187 ESCRIPT_DLL_API
188 virtual int getTag(const std::string& name) const;
189
190 /**
191 \brief
192 Returns True if name is a defined tag name
193 \param name Input - tag name
194 */
195 ESCRIPT_DLL_API
196 virtual bool isValidTagName(const std::string& name) const;
197
198 /**
199 \brief
200 Returns all tag names in a single string sperated by commas
201 */
202 ESCRIPT_DLL_API
203 virtual std::string showTagNames() const;
204
205 /**
206 \brief
207 Return a borrowed pointer to the sample reference number id list
208 \param functionSpaceType Input - The function space type.
209 */
210 ESCRIPT_DLL_API
211 virtual int* borrowSampleReferenceIDs(int functionSpaceType) const;
212
213 /**
214 \brief
215 Assigns new location to the domain.
216
217 This has to be implemented by the actual Domain adapter.
218 */
219 ESCRIPT_DLL_API
220 virtual void setNewX(const escript::Data& arg);
221
222 /**
223 \brief
224 Interpolates data given on source onto target where source and target have to be given on the same domain.
225
226 This has to be implemented by the actual Domain adapter.
227 */
228 ESCRIPT_DLL_API
229 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
230 ESCRIPT_DLL_API
231 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
232
233 /**
234 \brief
235 Interpolates data given on source onto target where source and target are given on different domains.
236
237 This has to be implemented by the actual Domain adapter.
238 */
239 ESCRIPT_DLL_API
240 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
241 ESCRIPT_DLL_API
242 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
243
244 /**
245 \brief
246 Returns locations in the domain. The function space is chosen appropriately.
247 */
248 ESCRIPT_DLL_API
249 virtual escript::Data getX() const;
250
251 /**
252 \brief
253 Return boundary normals. The function space is chosen appropriately.
254 */
255 ESCRIPT_DLL_API
256 virtual escript::Data getNormal() const;
257
258 /**
259 \brief
260 Returns the local size of samples. The function space is chosen appropriately.
261 */
262 ESCRIPT_DLL_API
263 virtual escript::Data getSize() const;
264
265 /**
266 \brief
267 Copies the location of data points on the domain into out.
268 The actual function space to be considered
269 is defined by out. out has to be defined on this.
270
271 This has to be implemented by the actual Domain adapter.
272 */
273 ESCRIPT_DLL_API
274 virtual void setToX(escript::Data& out) const;
275
276 /**
277 \brief
278 Copies the surface normals at data points into out.
279 The actual function space to be considered
280 is defined by out. out has to be defined on this.
281
282 This has to be implemented by the actual Domain adapter.
283 */
284 ESCRIPT_DLL_API
285 virtual void setToNormal(escript::Data& out) const;
286
287 /**
288 \brief
289 Copies the size of samples into out. The actual
290 function space to be considered
291 is defined by out. out has to be defined on this.
292
293 This has to be implemented by the actual Domain adapter.
294 */
295 ESCRIPT_DLL_API
296 virtual void setToSize(escript::Data& out) const;
297
298 /**
299 \brief
300 Copies the gradient of arg into grad. The actual function space to be considered
301 for the gradient is defined by grad. arg and grad have to be defined on this.
302
303 This has to be implemented by the actual Domain adapter.
304 */
305 ESCRIPT_DLL_API
306 virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
307 /**
308 \brief
309 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
310
311 This has to be implemented by the actual Domain adapter.
312 */
313 ESCRIPT_DLL_API
314 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
315
316 /**
317 \brief
318 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
319
320 This has to be implemented by the actual Domain adapter.
321 */
322 ESCRIPT_DLL_API
323 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
324
325 /**
326 \brief
327 returns the function space representation of the type functionSpaceCode on this domain
328 as a vtkObject.
329
330 This has to be implemented by the actual Domain adapter.
331 */
332 //virtual vtkObject createVtkObject(int functionSpaceCode) const;
333
334 /**
335 \brief assigns new tag newTag to all samples of functionspace with a positive
336 value of mask for any its sample point.
337
338 */
339 ESCRIPT_DLL_API
340 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
341
342 /**
343 \brief
344 returns true if data on this domain and a function space of type functionSpaceCode has to
345 considered as cell centered data.
346
347 This has to be implemented by the actual Domain adapter.
348 */
349 ESCRIPT_DLL_API
350 virtual bool isCellOriented(int functionSpaceCode) const;
351
352 /**
353 \brief
354 returns status of the domain.
355
356 This has to be implemented by the actual Domain adapter.
357 */
358 ESCRIPT_DLL_API
359 virtual StatusType getStatus() const;
360
361 /**
362 \brief
363 Throw a standard exception. This function is called if any attempt
364 is made to use a base class function.
365 */
366 ESCRIPT_DLL_API
367 void throwStandardException(const std::string& functionName) const;
368
369 protected:
370
371 private:
372
373 // buffer for coordinates used by function spaces
374 BufferMapType m_x_buffer;
375
376 // buffer for normal vectors used by function spaces
377 BufferMapType m_normal_buffer;
378
379 // buffer for normal element size used by function spaces
380 BufferMapType m_size_buffer;
381
382 };
383
384 } // end of namespace
385
386 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26