/[escript]/branches/split/escriptcore/src/TestDomain.h
ViewVC logotype

Contents of /branches/split/escriptcore/src/TestDomain.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4773 - (show annotations)
Wed Mar 19 06:19:42 2014 UTC (3 years, 8 months ago) by jfenwick
File MIME type: text/plain
File size: 7108 byte(s)
Fixing Data to use the domain's communicator.
Like it should!


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 #if !defined escript_TestDomain_20090618_H
19 #define escript_TestDomain_20090618_H
20 #include "system_dep.h"
21
22 #include "AbstractDomain.h"
23 #include "FunctionSpace.h"
24
25 #include <string>
26
27 namespace escript {
28
29 /**
30 \brief
31 (Testing use only) Provides a domain to wrap a collection of values.
32
33 This domain provides more functionality than NullDomain in that it can
34 store varying numbers of samples and points per sample.
35
36 It currently supports a single function space which does not support tagging.
37 No effort has been made to make this work with MPI
38
39 \warning This class exists to support testing and should not be used
40 as a general domain without ensuring that it works the way you expect.
41 Also, other doco says that this class can be removed without notice.
42
43 */
44
45 class TestDomain : public AbstractDomain {
46
47 public:
48
49 /**
50 \brief
51 Default constructor for TestDomain.
52
53 Description:
54 Default constructor for TestDomain.
55
56 */
57 ESCRIPT_DLL_API
58 TestDomain(int pointspersample, int numsamples, int dpsize=1);
59
60 ESCRIPT_DLL_API
61 ~TestDomain();
62
63 /**
64 \brief get the communicator for this domain.
65 Returns 0 on non-MPI builds
66 Routine must be implemented by the DomainAdapter
67 */
68 ESCRIPT_DLL_API
69 virtual
70 #ifdef ESYS_MPI
71 MPI_Comm
72 #else
73 unsigned int
74 #endif
75 getMPIComm() const
76 {
77 #ifdef ESYS_MPI
78 return MPI_COMM_WORLD;
79 #else
80 return -1;
81 #endif
82 }
83
84 /**
85 \brief
86 Returns true if the given integer is a valid function space type
87 for this domain.
88 */
89 ESCRIPT_DLL_API
90 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
91
92 /**
93 \brief
94 Return a description for this domain.
95 */
96 ESCRIPT_DLL_API
97 virtual std::string getDescription() const;
98
99 /**
100 \brief
101 Return a description for the given function space type code.
102 */
103 ESCRIPT_DLL_API
104 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
105
106 /**
107 \brief
108 Interpolates data given on source onto target where source and target have to be given on the same domain.
109 TestDomain only has one FunctionSpace so this makes target a shallow copy of source.
110 */
111 ESCRIPT_DLL_API
112 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
113 ESCRIPT_DLL_API
114 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
115
116 ESCRIPT_DLL_API
117 bool
118 commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
119
120 /**
121 \brief
122 Returns locations in the domain.
123 */
124 ESCRIPT_DLL_API
125 virtual escript::Data getX() const;
126
127
128 /**
129 \brief
130 Interpolates data given on source onto target where source and target are given on different domains.
131 We do not permit interpolation into the TestDomain so this method always throws.
132 */
133 ESCRIPT_DLL_API
134 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
135 ESCRIPT_DLL_API
136 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
137
138
139 /**
140 \brief
141 Return a continuous FunctionSpace.
142 */
143 ESCRIPT_DLL_API
144 virtual int getDefaultCode() const;
145
146
147 /**
148 \brief
149 Return a continuous FunctionSpace.
150 */
151 ESCRIPT_DLL_API
152 virtual int getContinuousFunctionCode() const;
153
154 /**
155 \brief
156 Return a function FunctionSpace.
157 */
158 ESCRIPT_DLL_API
159 virtual int getFunctionCode() const;
160
161 /**
162 \brief
163 Return a function on boundary FunctionSpace.
164 */
165 ESCRIPT_DLL_API
166 virtual int getFunctionOnBoundaryCode() const;
167
168 /**
169 \brief
170 Return a FunctionSpace.
171 */
172 ESCRIPT_DLL_API
173 virtual int getFunctionOnContactZeroCode() const;
174
175 /**
176 \brief
177 Return a FunctionSpace.
178 */
179 ESCRIPT_DLL_API
180 virtual int getFunctionOnContactOneCode() const;
181
182 /**
183 \brief
184 Return a FunctionSpace.
185 */
186 ESCRIPT_DLL_API
187 virtual int getSolutionCode() const;
188
189 /**
190 \brief
191 Return a FunctionSpace.
192 */
193 ESCRIPT_DLL_API
194 virtual int getReducedSolutionCode() const;
195
196 /**
197 \brief
198 Return a FunctionSpace.
199 */
200 ESCRIPT_DLL_API
201 virtual int getDiracDeltaFunctionsCode() const;
202
203 /**
204 \brief
205 Return the number of data points per sample, and the number of samples as a pair.
206 \param functionSpaceCode Input - Code for the function space type.
207 \return pair, first - number of data points per sample, second - number of samples
208 */
209 ESCRIPT_DLL_API
210 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
211
212 /**
213 \brief
214 Return the tag key for the given sample number.
215 \param functionSpaceType Input - The function space type.
216 \param sampleNo Input - The sample number.
217 */
218 ESCRIPT_DLL_API
219 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
220
221 /**
222 \brief
223 Return a borrowed pointer to the sample reference number id list
224 \param functionSpaceType Input - The function space type.
225 */
226 ESCRIPT_DLL_API
227 virtual const int* borrowSampleReferenceIDs(int functionSpaceType) const;
228
229 /**
230 \brief
231 */
232 ESCRIPT_DLL_API
233 virtual int getDim() const;
234
235 /**
236 \brief
237 Return true if given domains are equal.
238 */
239 ESCRIPT_DLL_API
240 virtual bool operator==(const AbstractDomain& other) const;
241 ESCRIPT_DLL_API
242 virtual bool operator!=(const AbstractDomain& other) const;
243
244 /**
245 \brief Checks if this domain allows tags for the specified functionSpaceCode.
246 */
247 ESCRIPT_DLL_API
248 virtual
249 bool canTag(int functionSpaceCode) const;
250
251 /**
252 \brief
253 return the number of tags in use.
254 For this class the answer is always 1(the default tag).
255 */
256 ESCRIPT_DLL_API
257 virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
258
259 /**
260 \brief returns a pointer to an array with the tags used.
261 For this class the answer will always be {0}
262 */
263 ESCRIPT_DLL_API
264 virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
265
266 ESCRIPT_DLL_API
267 virtual escript::Data randomFill(const DataTypes::ShapeType& shape,
268 const FunctionSpace& what, long seed, const boost::python::tuple& filter) const;
269
270 protected:
271
272 private:
273 int m_samples; // number of samples
274 int m_dpps; // data points per sample
275 int m_dpsize; // how big are the datapoints?
276 int* m_samplerefids; // sample reference ids
277 };
278
279 ESCRIPT_DLL_API
280 FunctionSpace
281 getTestDomainFunctionSpace(int dpps, int samples, int dpsize);
282
283 } // end of namespace
284
285 #endif

  ViewVC Help
Powered by ViewVC 1.1.26