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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4114 - (hide annotations)
Fri Dec 14 04:24:46 2012 UTC (6 years, 9 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 elspeth 615
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 3911 * Copyright (c) 2003-2012 by University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
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 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12     * Development since 2012 by School of Earth Sciences
13     *
14     *****************************************************************************/
15 ksteube 1312
16 ksteube 1811
17 jgs 115 #if !defined escript_AbstractDomain_20040609_H
18 jgs 82 #define escript_AbstractDomain_20040609_H
19 jgs 115
20 jfenwick 3961 #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 woo409 757 #include "system_dep.h"
32    
33 jfenwick 2635 #include <vector>
34 jgs 82 #include <string>
35 gross 797 #include <map>
36 jgs 153 #include <boost/python/dict.hpp>
37 gross 1716 #include <boost/python/list.hpp>
38 jfenwick 3259 #include "esysUtils/Esys_MPI.h"
39 jgs 82
40 jfenwick 1872
41     #include "Pointers.h"
42    
43 jgs 82 namespace escript {
44 gross 797 // class forward declarations
45 jgs 117 class Data;
46 jgs 82 /**
47     \brief
48     Base class for all escript domains.
49    
50     Description:
51     Base class for all escript domains.
52     */
53 jgs 115
54 jfenwick 1872 class AbstractDomain;
55 jgs 82
56 jfenwick 1872 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 jgs 82 public:
62    
63 jfenwick 1872 /**
64     \brief Returns smart pointer which is managing this object.
65     If one does not exist yet it creates one.
66 ksteube 1312
67 jfenwick 1872 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 gross 797 // structure holding values for X, size and normal
75     typedef int StatusType;
76 ksteube 1312 struct ValueBuffer
77     {
78     StatusType m_status;
79     boost::shared_ptr<Data> m_data;
80     };
81     typedef struct ValueBuffer ValueBuffer;
82 gross 797
83     //
84     // map from function space type code to value buffer
85 ksteube 1312 typedef std::map<int, ValueBuffer> BufferMapType;
86 gross 797
87    
88 jgs 82 /**
89     \brief
90 jgs 117 Default constructor for AbstractDomain.
91 jgs 82
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 jgs 117 constructable we avoid a boost.python wrapper class. A call to
96 jgs 82 almost any of the base class functions will throw an exception
97 jgs 115 as they are not intended to be used directly, but are overridden
98 jgs 117 by the underlying solver package which escript is linked to.
99 jgs 82
100 jgs 115 By default, this class is overridden by the class NullDomain.
101    
102 jgs 82 Preconditions:
103 jgs 117 Describe any preconditions.
104 jgs 82
105     Throws:
106 jgs 117 Describe any exceptions thrown.
107 jgs 82 */
108 woo409 757 ESCRIPT_DLL_API
109 jgs 82 AbstractDomain();
110 jgs 115
111 jgs 82 /**
112     \brief
113 jgs 117 Destructor for AbstractDomain.
114 jgs 82
115     Description:
116 jgs 117 Destructor for AbstractDomain.
117 jgs 82 */
118 woo409 757 ESCRIPT_DLL_API
119 jgs 82 virtual ~AbstractDomain();
120 jgs 115
121 jgs 82 /**
122     \brief
123 ksteube 1312 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 ksteube 1877 /**
136     \brief
137     If compiled for MPI then execute an MPI_Barrier, else do nothing
138     */
139 ksteube 1312
140 ksteube 1877 ESCRIPT_DLL_API
141     virtual void MPIBarrier() const;
142     /**
143     \brief
144     Return true if on MPI master, else false
145     */
146 ksteube 1312
147 ksteube 1877 ESCRIPT_DLL_API
148     virtual bool onMasterProcessor() const;
149    
150 jfenwick 2640 /**
151     \brief get the communicator for this domain.
152     Returns 0 on non-MPI builds
153 jfenwick 2644 Routine must be implemented by the DomainAdapter
154 jfenwick 2640 */
155     ESCRIPT_DLL_API
156 jfenwick 2641 virtual
157 jfenwick 3259 #ifdef ESYS_MPI
158 jfenwick 2640 MPI_Comm
159     #else
160     unsigned int
161     #endif
162     getMPIComm() const;
163 ksteube 1877
164 ksteube 1312 /**
165     \brief
166 jgs 82 Returns true if the given integer is a valid function space type
167     for this domain.
168     */
169 woo409 757 ESCRIPT_DLL_API
170 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
171 jgs 115
172 jgs 82 /**
173     \brief
174 jgs 117 Return a description for this domain.
175 jgs 82 */
176 woo409 757 ESCRIPT_DLL_API
177 jgs 82 virtual std::string getDescription() const;
178 jgs 115
179 jgs 82 /**
180     \brief
181 jgs 117 Return a description for the given function space type code.
182 jgs 82 */
183 woo409 757 ESCRIPT_DLL_API
184 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
185 jgs 115
186 jgs 82 /**
187     \brief
188 jgs 117 Returns the spatial dimension of the domain.
189 jgs 115
190 jgs 117 This has to be implemented by the actual Domain adapter.
191 jgs 82 */
192 woo409 757 ESCRIPT_DLL_API
193 jgs 82 virtual int getDim() const;
194    
195     /**
196 jgs 117 \brief
197     Return true if given domains are equal.
198 jgs 82 */
199 woo409 757 ESCRIPT_DLL_API
200 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
201 woo409 757 ESCRIPT_DLL_API
202 jgs 121 virtual bool operator!=(const AbstractDomain& other) const;
203 jgs 115
204 jgs 82 /**
205     \brief
206 jgs 117 Writes the domain to an external file filename.
207    
208 jgs 115 This has to be implemented by the actual Domain adapter.
209 jgs 82 */
210 woo409 757 ESCRIPT_DLL_API
211 jgs 82 virtual void write(const std::string& filename) const;
212    
213     /**
214     \brief
215 ksteube 1312 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 jgs 82 Return the number of data points per sample, and the number of samples as a pair.
225 jgs 117
226     This has to be implemented by the actual Domain adapter.
227    
228 jgs 82 \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 woo409 757 ESCRIPT_DLL_API
232 jgs 82 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 woo409 757 ESCRIPT_DLL_API
241 jgs 82 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
242 jgs 115
243 jgs 82 /**
244     \brief
245 gross 1044 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 gross 964 Return a borrowed pointer to the sample reference number id list
278 jgs 110 \param functionSpaceType Input - The function space type.
279     */
280 woo409 757 ESCRIPT_DLL_API
281 jfenwick 2487 virtual const int* borrowSampleReferenceIDs(int functionSpaceType) const;
282 jgs 115
283 jgs 110 /**
284     \brief
285 jgs 117 Assigns new location to the domain.
286    
287     This has to be implemented by the actual Domain adapter.
288 jgs 82 */
289 woo409 757 ESCRIPT_DLL_API
290 jgs 82 virtual void setNewX(const escript::Data& arg);
291    
292     /**
293     \brief
294 jgs 115 Interpolates data given on source onto target where source and target have to be given on the same domain.
295 jgs 117
296     This has to be implemented by the actual Domain adapter.
297 jgs 82 */
298 woo409 757 ESCRIPT_DLL_API
299 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
300 woo409 757 ESCRIPT_DLL_API
301 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
302 jgs 115
303 jgs 82 /**
304 jfenwick 2635 \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 jgs 82 \brief
315 jgs 115 Interpolates data given on source onto target where source and target are given on different domains.
316 jgs 117
317     This has to be implemented by the actual Domain adapter.
318 jgs 82 */
319 woo409 757 ESCRIPT_DLL_API
320 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
321 woo409 757 ESCRIPT_DLL_API
322 jgs 82 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
323    
324     /**
325 jgs 117 \brief
326     Returns locations in the domain. The function space is chosen appropriately.
327 jgs 102 */
328 woo409 757 ESCRIPT_DLL_API
329 jgs 102 virtual escript::Data getX() const;
330 jgs 115
331 jgs 102 /**
332 jgs 117 \brief
333     Return boundary normals. The function space is chosen appropriately.
334 jgs 102 */
335 woo409 757 ESCRIPT_DLL_API
336 jgs 102 virtual escript::Data getNormal() const;
337 jgs 115
338 jgs 102 /**
339 jgs 117 \brief
340     Returns the local size of samples. The function space is chosen appropriately.
341 jgs 102 */
342 woo409 757 ESCRIPT_DLL_API
343 jgs 102 virtual escript::Data getSize() const;
344    
345     /**
346 jgs 82 \brief
347 jgs 115 Copies the location of data points on the domain into out.
348     The actual function space to be considered
349 jgs 82 is defined by out. out has to be defined on this.
350 jgs 117
351     This has to be implemented by the actual Domain adapter.
352 jgs 82 */
353 woo409 757 ESCRIPT_DLL_API
354 jgs 82 virtual void setToX(escript::Data& out) const;
355 jgs 115
356 jgs 82 /**
357     \brief
358 jgs 115 Copies the surface normals at data points into out.
359     The actual function space to be considered
360 jgs 82 is defined by out. out has to be defined on this.
361 jgs 117
362     This has to be implemented by the actual Domain adapter.
363 jgs 82 */
364 woo409 757 ESCRIPT_DLL_API
365 jgs 82 virtual void setToNormal(escript::Data& out) const;
366 jgs 115
367 jgs 82 /**
368     \brief
369 jgs 115 Copies the size of samples into out. The actual
370     function space to be considered
371 jgs 82 is defined by out. out has to be defined on this.
372 jgs 117
373     This has to be implemented by the actual Domain adapter.
374 jgs 82 */
375 woo409 757 ESCRIPT_DLL_API
376 jgs 82 virtual void setToSize(escript::Data& out) const;
377    
378     /**
379     \brief
380 jgs 115 Copies the gradient of arg into grad. The actual function space to be considered
381 jgs 82 for the gradient is defined by grad. arg and grad have to be defined on this.
382 jgs 117
383     This has to be implemented by the actual Domain adapter.
384 jgs 82 */
385 woo409 757 ESCRIPT_DLL_API
386 jgs 82 virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
387 jgs 117
388 jgs 82 /**
389 jfenwick 2644 \brief True if this rank owns the sample(id)
390     Must be implemented by the Domain adapter
391     */
392 jfenwick 2642 ESCRIPT_DLL_API
393     virtual bool ownSample(int fs_code, index_t id) const;
394    
395 jgs 110 /**
396 gross 767 \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 jgs 82 \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 jgs 117
408     This has to be implemented by the actual Domain adapter.
409 jgs 82 */
410 woo409 757 ESCRIPT_DLL_API
411 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
412    
413 jgs 117 /**
414     \brief
415 gross 2533 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 gross 797
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 jgs 117 Throw a standard exception. This function is called if any attempt
427     is made to use a base class function.
428     */
429 woo409 757 ESCRIPT_DLL_API
430 jgs 117 void throwStandardException(const std::string& functionName) const;
431    
432 gross 1716 /**
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 jfenwick 2487 virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
441 gross 1716
442 jfenwick 1802 /**
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 gross 1716
448 gross 2856 /**
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 jfenwick 3259 ESCRIPT_DLL_API
456     virtual bool supportsContactElements() const;
457 gross 2856
458 jgs 82 protected:
459    
460     private:
461 jgs 115
462 gross 797 // buffer for coordinates used by function spaces
463 ksteube 1312 BufferMapType m_x_buffer;
464 gross 797
465     // buffer for normal vectors used by function spaces
466 ksteube 1312 BufferMapType m_normal_buffer;
467 gross 797
468     // buffer for normal element size used by function spaces
469 ksteube 1312 BufferMapType m_size_buffer;
470 gross 797
471 jgs 82 };
472    
473     } // end of namespace
474 jgs 117
475 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26