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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1877 - (hide annotations)
Tue Oct 14 02:58:39 2008 UTC (11 years, 2 months ago) by ksteube
File MIME type: text/plain
File size: 11638 byte(s)
convection.py checkpointing uses mkdir/rmdir, and under MPI there
was a race condition.

mkdir needs to be run on only one CPU and then a barrier to prevent
working processors from using the directory before it exists.

Added methods domain.MPIBarrier and domain.onMasterProcessor() to
implement this technique.

A more general solution might be possible in the future.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26