/[escript]/trunk/escript/src/AbstractDomain.h
ViewVC logotype

Contents of /trunk/escript/src/AbstractDomain.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2640 - (show annotations)
Mon Aug 31 06:22:10 2009 UTC (10 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 12334 byte(s)
Adding getMPIComm

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
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 <vector>
21 #include <string>
22 #include <map>
23 #include <boost/python/dict.hpp>
24 #include <boost/python/list.hpp>
25 #include "paso/Paso_MPI.h"
26
27
28 #include "Pointers.h"
29
30 namespace escript {
31 // class forward declarations
32 class Data;
33 /**
34 \brief
35 Base class for all escript domains.
36
37 Description:
38 Base class for all escript domains.
39 */
40
41 class AbstractDomain;
42
43 typedef POINTER_WRAPPER_CLASS(AbstractDomain) Domain_ptr;
44 typedef POINTER_WRAPPER_CLASS(const AbstractDomain) const_Domain_ptr;
45
46 class AbstractDomain : public REFCOUNT_BASE_CLASS(AbstractDomain){
47
48 public:
49
50 /**
51 \brief Returns smart pointer which is managing this object.
52 If one does not exist yet it creates one.
53
54 Note: This is _not_ equivalent to weak_ptr::lock.
55 */
56 ESCRIPT_DLL_API
57 Domain_ptr getPtr();
58 ESCRIPT_DLL_API
59 const_Domain_ptr getPtr() const;
60
61 // structure holding values for X, size and normal
62 typedef int StatusType;
63 struct ValueBuffer
64 {
65 StatusType m_status;
66 boost::shared_ptr<Data> m_data;
67 };
68 typedef struct ValueBuffer ValueBuffer;
69
70 //
71 // map from function space type code to value buffer
72 typedef std::map<int, ValueBuffer> BufferMapType;
73
74
75 /**
76 \brief
77 Default constructor for AbstractDomain.
78
79 Description:
80 Default constructor for AbstractDomain. As the name suggests
81 this is intended to be an abstract base class but by making it
82 constructable we avoid a boost.python wrapper class. A call to
83 almost any of the base class functions will throw an exception
84 as they are not intended to be used directly, but are overridden
85 by the underlying solver package which escript is linked to.
86
87 By default, this class is overridden by the class NullDomain.
88
89 Preconditions:
90 Describe any preconditions.
91
92 Throws:
93 Describe any exceptions thrown.
94 */
95 ESCRIPT_DLL_API
96 AbstractDomain();
97
98 /**
99 \brief
100 Destructor for AbstractDomain.
101
102 Description:
103 Destructor for AbstractDomain.
104 */
105 ESCRIPT_DLL_API
106 virtual ~AbstractDomain();
107
108 /**
109 \brief
110 return the number of processors used for this domain
111 */
112 ESCRIPT_DLL_API
113 virtual int getMPISize() const;
114 /**
115 \brief
116 return the number MPI rank of this processor
117 */
118
119 ESCRIPT_DLL_API
120 virtual int getMPIRank() const;
121
122 /**
123 \brief
124 If compiled for MPI then execute an MPI_Barrier, else do nothing
125 */
126
127 ESCRIPT_DLL_API
128 virtual void MPIBarrier() const;
129 /**
130 \brief
131 Return true if on MPI master, else false
132 */
133
134 ESCRIPT_DLL_API
135 virtual bool onMasterProcessor() const;
136
137 /**
138 \brief get the communicator for this domain.
139 Returns 0 on non-MPI builds
140 */
141 ESCRIPT_DLL_API
142 #ifdef PASO_MPI
143 MPI_Comm
144 #else
145 unsigned int
146 #endif
147 getMPIComm() const;
148
149 /**
150 \brief
151 Returns true if the given integer is a valid function space type
152 for this domain.
153 */
154 ESCRIPT_DLL_API
155 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
156
157 /**
158 \brief
159 Return a description for this domain.
160 */
161 ESCRIPT_DLL_API
162 virtual std::string getDescription() const;
163
164 /**
165 \brief
166 Return a description for the given function space type code.
167 */
168 ESCRIPT_DLL_API
169 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
170
171 /**
172 \brief
173 Returns the spatial dimension of the domain.
174
175 This has to be implemented by the actual Domain adapter.
176 */
177 ESCRIPT_DLL_API
178 virtual int getDim() const;
179
180 /**
181 \brief
182 Return true if given domains are equal.
183 */
184 ESCRIPT_DLL_API
185 virtual bool operator==(const AbstractDomain& other) const;
186 ESCRIPT_DLL_API
187 virtual bool operator!=(const AbstractDomain& other) const;
188
189 /**
190 \brief
191 Writes the domain to an external file filename.
192
193 This has to be implemented by the actual Domain adapter.
194 */
195 ESCRIPT_DLL_API
196 virtual void write(const std::string& filename) const;
197
198 /**
199 \brief
200 dumps the domain to an external file filename.
201
202 This has to be implemented by the actual Domain adapter.
203 */
204 ESCRIPT_DLL_API
205 virtual void dump(const std::string& filename) const;
206
207 /**
208 \brief
209 Return the number of data points per sample, and the number of samples as a pair.
210
211 This has to be implemented by the actual Domain adapter.
212
213 \param functionSpaceCode Input - Code for the function space type.
214 \return pair, first - number of data points per sample, second - number of samples
215 */
216 ESCRIPT_DLL_API
217 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
218
219 /**
220 \brief
221 Return the tag key for the given sample number.
222 \param functionSpaceType Input - The function space type.
223 \param sampleNo Input - The sample number.
224 */
225 ESCRIPT_DLL_API
226 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
227
228 /**
229 \brief
230 sets a map from a clear tag name to a tag key
231 \param name Input - tag name.
232 \param tag Input - tag key.
233 */
234 ESCRIPT_DLL_API
235 virtual void setTagMap(const std::string& name, int tag);
236
237 /**
238 \brief
239 Return the tag key for tag name.
240 \param name Input - tag name
241 */
242 ESCRIPT_DLL_API
243 virtual int getTag(const std::string& name) const;
244
245 /**
246 \brief
247 Returns True if name is a defined tag name
248 \param name Input - tag name
249 */
250 ESCRIPT_DLL_API
251 virtual bool isValidTagName(const std::string& name) const;
252
253 /**
254 \brief
255 Returns all tag names in a single string sperated by commas
256 */
257 ESCRIPT_DLL_API
258 virtual std::string showTagNames() const;
259
260 /**
261 \brief
262 Return a borrowed pointer to the sample reference number id list
263 \param functionSpaceType Input - The function space type.
264 */
265 ESCRIPT_DLL_API
266 virtual const int* borrowSampleReferenceIDs(int functionSpaceType) const;
267
268 /**
269 \brief
270 Assigns new location to the domain.
271
272 This has to be implemented by the actual Domain adapter.
273 */
274 ESCRIPT_DLL_API
275 virtual void setNewX(const escript::Data& arg);
276
277 /**
278 \brief
279 Interpolates data given on source onto target where source and target have to be given on the same domain.
280
281 This has to be implemented by the actual Domain adapter.
282 */
283 ESCRIPT_DLL_API
284 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
285 ESCRIPT_DLL_API
286 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
287
288 /**
289 \brief given a vector of FunctionSpace type codes, pass back a code which then can all be interpolated to.
290 \note This method must be called on the domain which the FunctionSpaces point to
291 \return true is result is valid, false if not
292 */
293 ESCRIPT_DLL_API
294 virtual
295 bool
296 commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
297
298 /**
299 \brief
300 Interpolates data given on source onto target where source and target are given on different domains.
301
302 This has to be implemented by the actual Domain adapter.
303 */
304 ESCRIPT_DLL_API
305 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
306 ESCRIPT_DLL_API
307 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
308
309 /**
310 \brief
311 Returns locations in the domain. The function space is chosen appropriately.
312 */
313 ESCRIPT_DLL_API
314 virtual escript::Data getX() const;
315
316 /**
317 \brief
318 Return boundary normals. The function space is chosen appropriately.
319 */
320 ESCRIPT_DLL_API
321 virtual escript::Data getNormal() const;
322
323 /**
324 \brief
325 Returns the local size of samples. The function space is chosen appropriately.
326 */
327 ESCRIPT_DLL_API
328 virtual escript::Data getSize() const;
329
330 /**
331 \brief
332 Copies the location of data points on the domain into out.
333 The actual function space to be considered
334 is defined by out. out has to be defined on this.
335
336 This has to be implemented by the actual Domain adapter.
337 */
338 ESCRIPT_DLL_API
339 virtual void setToX(escript::Data& out) const;
340
341 /**
342 \brief
343 Copies the surface normals at data points into out.
344 The actual function space to be considered
345 is defined by out. out has to be defined on this.
346
347 This has to be implemented by the actual Domain adapter.
348 */
349 ESCRIPT_DLL_API
350 virtual void setToNormal(escript::Data& out) const;
351
352 /**
353 \brief
354 Copies the size of samples into out. The actual
355 function space to be considered
356 is defined by out. out has to be defined on this.
357
358 This has to be implemented by the actual Domain adapter.
359 */
360 ESCRIPT_DLL_API
361 virtual void setToSize(escript::Data& out) const;
362
363 /**
364 \brief
365 Copies the gradient of arg into grad. The actual function space to be considered
366 for the gradient is defined by grad. arg and grad have to be defined on this.
367
368 This has to be implemented by the actual Domain adapter.
369 */
370 ESCRIPT_DLL_API
371 virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
372 /**
373 \brief
374 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
375
376 This has to be implemented by the actual Domain adapter.
377 */
378 ESCRIPT_DLL_API
379 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
380
381 /**
382 \brief
383 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier.
384 metadata is string representing some meta data to be added. metadata_schema assign schema to namespaces used in the meta data.
385
386 This has to be implemented by the actual Domain adapter.
387 */
388 ESCRIPT_DLL_API
389 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg, const std::string& metadata, const std::string& metadata_schema) const;
390
391 /**
392 \brief assigns new tag newTag to all samples of functionspace with a positive
393 value of mask for any its sample point.
394
395 */
396 ESCRIPT_DLL_API
397 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
398
399 /**
400 \brief
401 returns true if data on this domain and a function space of type functionSpaceCode has to
402 considered as cell centered data.
403
404 This has to be implemented by the actual Domain adapter.
405 */
406 ESCRIPT_DLL_API
407 virtual bool isCellOriented(int functionSpaceCode) const;
408
409 /**
410 \brief
411 Returns a status indicator of the domain. The status identifier should be unique over
412 the live time if the object but may be updated if changes to the domain happen, e.g.
413 modifications to its geometry.
414
415 This has to be implemented by the actual Domain adapter.
416 */
417 ESCRIPT_DLL_API
418 virtual StatusType getStatus() const;
419
420 /**
421 \brief
422 Throw a standard exception. This function is called if any attempt
423 is made to use a base class function.
424 */
425 ESCRIPT_DLL_API
426 void throwStandardException(const std::string& functionName) const;
427
428 /**
429 \brief
430 return the number of tags in use and a pointer to an array with the number of tags in use
431 */
432 ESCRIPT_DLL_API
433 virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
434
435 ESCRIPT_DLL_API
436 virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
437
438 /**
439 \brief Checks if this domain allows tags for the specified functionSpaceCode.
440 */
441 ESCRIPT_DLL_API
442 virtual bool canTag(int functionspacecode) const;
443
444 protected:
445
446 private:
447
448 // buffer for coordinates used by function spaces
449 BufferMapType m_x_buffer;
450
451 // buffer for normal vectors used by function spaces
452 BufferMapType m_normal_buffer;
453
454 // buffer for normal element size used by function spaces
455 BufferMapType m_size_buffer;
456
457 };
458
459 } // end of namespace
460
461 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26