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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2641 - (show annotations)
Mon Aug 31 07:41:49 2009 UTC (10 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 12344 byte(s)
Fixed some of my stupids related to MPI compile errors.

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 virtual
143 #ifdef PASO_MPI
144 MPI_Comm
145 #else
146 unsigned int
147 #endif
148 getMPIComm() const;
149
150 /**
151 \brief
152 Returns true if the given integer is a valid function space type
153 for this domain.
154 */
155 ESCRIPT_DLL_API
156 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
157
158 /**
159 \brief
160 Return a description for this domain.
161 */
162 ESCRIPT_DLL_API
163 virtual std::string getDescription() const;
164
165 /**
166 \brief
167 Return a description for the given function space type code.
168 */
169 ESCRIPT_DLL_API
170 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
171
172 /**
173 \brief
174 Returns the spatial dimension of the domain.
175
176 This has to be implemented by the actual Domain adapter.
177 */
178 ESCRIPT_DLL_API
179 virtual int getDim() const;
180
181 /**
182 \brief
183 Return true if given domains are equal.
184 */
185 ESCRIPT_DLL_API
186 virtual bool operator==(const AbstractDomain& other) const;
187 ESCRIPT_DLL_API
188 virtual bool operator!=(const AbstractDomain& other) const;
189
190 /**
191 \brief
192 Writes the domain to an external file filename.
193
194 This has to be implemented by the actual Domain adapter.
195 */
196 ESCRIPT_DLL_API
197 virtual void write(const std::string& filename) const;
198
199 /**
200 \brief
201 dumps the domain to an external file filename.
202
203 This has to be implemented by the actual Domain adapter.
204 */
205 ESCRIPT_DLL_API
206 virtual void dump(const std::string& filename) const;
207
208 /**
209 \brief
210 Return the number of data points per sample, and the number of samples as a pair.
211
212 This has to be implemented by the actual Domain adapter.
213
214 \param functionSpaceCode Input - Code for the function space type.
215 \return pair, first - number of data points per sample, second - number of samples
216 */
217 ESCRIPT_DLL_API
218 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
219
220 /**
221 \brief
222 Return the tag key for the given sample number.
223 \param functionSpaceType Input - The function space type.
224 \param sampleNo Input - The sample number.
225 */
226 ESCRIPT_DLL_API
227 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
228
229 /**
230 \brief
231 sets a map from a clear tag name to a tag key
232 \param name Input - tag name.
233 \param tag Input - tag key.
234 */
235 ESCRIPT_DLL_API
236 virtual void setTagMap(const std::string& name, int tag);
237
238 /**
239 \brief
240 Return the tag key for tag name.
241 \param name Input - tag name
242 */
243 ESCRIPT_DLL_API
244 virtual int getTag(const std::string& name) const;
245
246 /**
247 \brief
248 Returns True if name is a defined tag name
249 \param name Input - tag name
250 */
251 ESCRIPT_DLL_API
252 virtual bool isValidTagName(const std::string& name) const;
253
254 /**
255 \brief
256 Returns all tag names in a single string sperated by commas
257 */
258 ESCRIPT_DLL_API
259 virtual std::string showTagNames() const;
260
261 /**
262 \brief
263 Return a borrowed pointer to the sample reference number id list
264 \param functionSpaceType Input - The function space type.
265 */
266 ESCRIPT_DLL_API
267 virtual const int* borrowSampleReferenceIDs(int functionSpaceType) const;
268
269 /**
270 \brief
271 Assigns new location to the domain.
272
273 This has to be implemented by the actual Domain adapter.
274 */
275 ESCRIPT_DLL_API
276 virtual void setNewX(const escript::Data& arg);
277
278 /**
279 \brief
280 Interpolates data given on source onto target where source and target have to be given on the same domain.
281
282 This has to be implemented by the actual Domain adapter.
283 */
284 ESCRIPT_DLL_API
285 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
286 ESCRIPT_DLL_API
287 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
288
289 /**
290 \brief given a vector of FunctionSpace type codes, pass back a code which then can all be interpolated to.
291 \note This method must be called on the domain which the FunctionSpaces point to
292 \return true is result is valid, false if not
293 */
294 ESCRIPT_DLL_API
295 virtual
296 bool
297 commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
298
299 /**
300 \brief
301 Interpolates data given on source onto target where source and target are given on different domains.
302
303 This has to be implemented by the actual Domain adapter.
304 */
305 ESCRIPT_DLL_API
306 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
307 ESCRIPT_DLL_API
308 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
309
310 /**
311 \brief
312 Returns locations in the domain. The function space is chosen appropriately.
313 */
314 ESCRIPT_DLL_API
315 virtual escript::Data getX() const;
316
317 /**
318 \brief
319 Return boundary normals. The function space is chosen appropriately.
320 */
321 ESCRIPT_DLL_API
322 virtual escript::Data getNormal() const;
323
324 /**
325 \brief
326 Returns the local size of samples. The function space is chosen appropriately.
327 */
328 ESCRIPT_DLL_API
329 virtual escript::Data getSize() const;
330
331 /**
332 \brief
333 Copies the location of data points on the domain into out.
334 The actual function space to be considered
335 is defined by out. out has to be defined on this.
336
337 This has to be implemented by the actual Domain adapter.
338 */
339 ESCRIPT_DLL_API
340 virtual void setToX(escript::Data& out) const;
341
342 /**
343 \brief
344 Copies the surface normals at data points into out.
345 The actual function space to be considered
346 is defined by out. out has to be defined on this.
347
348 This has to be implemented by the actual Domain adapter.
349 */
350 ESCRIPT_DLL_API
351 virtual void setToNormal(escript::Data& out) const;
352
353 /**
354 \brief
355 Copies the size of samples into out. The actual
356 function space to be considered
357 is defined by out. out has to be defined on this.
358
359 This has to be implemented by the actual Domain adapter.
360 */
361 ESCRIPT_DLL_API
362 virtual void setToSize(escript::Data& out) const;
363
364 /**
365 \brief
366 Copies the gradient of arg into grad. The actual function space to be considered
367 for the gradient is defined by grad. arg and grad have to be defined on this.
368
369 This has to be implemented by the actual Domain adapter.
370 */
371 ESCRIPT_DLL_API
372 virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
373 /**
374 \brief
375 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
376
377 This has to be implemented by the actual Domain adapter.
378 */
379 ESCRIPT_DLL_API
380 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
381
382 /**
383 \brief
384 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier.
385 metadata is string representing some meta data to be added. metadata_schema assign schema to namespaces used in the meta data.
386
387 This has to be implemented by the actual Domain adapter.
388 */
389 ESCRIPT_DLL_API
390 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg, const std::string& metadata, const std::string& metadata_schema) const;
391
392 /**
393 \brief assigns new tag newTag to all samples of functionspace with a positive
394 value of mask for any its sample point.
395
396 */
397 ESCRIPT_DLL_API
398 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
399
400 /**
401 \brief
402 returns true if data on this domain and a function space of type functionSpaceCode has to
403 considered as cell centered data.
404
405 This has to be implemented by the actual Domain adapter.
406 */
407 ESCRIPT_DLL_API
408 virtual bool isCellOriented(int functionSpaceCode) const;
409
410 /**
411 \brief
412 Returns a status indicator of the domain. The status identifier should be unique over
413 the live time if the object but may be updated if changes to the domain happen, e.g.
414 modifications to its geometry.
415
416 This has to be implemented by the actual Domain adapter.
417 */
418 ESCRIPT_DLL_API
419 virtual StatusType getStatus() const;
420
421 /**
422 \brief
423 Throw a standard exception. This function is called if any attempt
424 is made to use a base class function.
425 */
426 ESCRIPT_DLL_API
427 void throwStandardException(const std::string& functionName) const;
428
429 /**
430 \brief
431 return the number of tags in use and a pointer to an array with the number of tags in use
432 */
433 ESCRIPT_DLL_API
434 virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
435
436 ESCRIPT_DLL_API
437 virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
438
439 /**
440 \brief Checks if this domain allows tags for the specified functionSpaceCode.
441 */
442 ESCRIPT_DLL_API
443 virtual bool canTag(int functionspacecode) const;
444
445 protected:
446
447 private:
448
449 // buffer for coordinates used by function spaces
450 BufferMapType m_x_buffer;
451
452 // buffer for normal vectors used by function spaces
453 BufferMapType m_normal_buffer;
454
455 // buffer for normal element size used by function spaces
456 BufferMapType m_size_buffer;
457
458 };
459
460 } // end of namespace
461
462 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26