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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4114 - (show annotations)
Fri Dec 14 04:24:46 2012 UTC (6 years, 8 months ago) by caltinay
File MIME type: text/plain
File size: 12492 byte(s)
Time to remove deprecated saveVTK/DX methods from Data and Domain.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26