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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1800 - (show annotations)
Thu Sep 18 05:28:20 2008 UTC (10 years, 10 months ago) by ksteube
File MIME type: text/plain
File size: 10868 byte(s)
Serialized parallel I/O when writing mesh or data to NetCDF file on multiple MPI processors.
Added domain method getMPIComm() to complement getMPISize() and getMPIRank().

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26