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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (hide annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years ago) by jfenwick
File MIME type: text/plain
File size: 12840 byte(s)
Merging dudley and scons updates from branches

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26