/[escript]/trunk/escript/src/TestDomain.cpp
ViewVC logotype

Contents of /trunk/escript/src/TestDomain.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 5 months ago) by jfenwick
File size: 5053 byte(s)
Don't panic.
Updating copyright stamps

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * 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
14
15 #include "DomainException.h"
16 #include "TestDomain.h"
17 #include "Data.h"
18 #include "Utils.h" // for MPI functions
19
20 namespace escript {
21
22 namespace {
23 const int defaultList[1]={0}; // an array to return in borrowListOfTagsInUse();
24 const int TestDomainFS=1; // Null domains only support 1 functionspace type.
25 // The choice of =1 as the value is arbitrary
26 }
27
28
29 TestDomain::TestDomain(int pointspersample, int numsamples)
30 : m_samples(numsamples), m_dpps(pointspersample)
31 {
32 #ifdef PASO_MPI
33 int world=getMPISizeWorld();
34 int rank=getMPIRankWorld();
35 m_samples/=world;
36 if (rank<(numsamples%world))
37 {
38 m_samples++;
39 }
40 #endif
41 m_samplerefids=new int[numsamples];
42 for (int i=0;i<numsamples;++i)
43 {
44 m_samplerefids[i]=i+10; // the +10 is arbitrary.
45 } // so these ids look different from others
46 }
47
48
49 TestDomain::~TestDomain()
50 {
51 delete[] m_samplerefids;
52 }
53
54 bool TestDomain::isValidFunctionSpaceType(int functionSpaceType) const
55 {
56 return (functionSpaceType==TestDomainFS);
57 }
58
59 std::string TestDomain::getDescription() const
60 {
61 return "TestDomain";
62 }
63
64 std::string TestDomain::functionSpaceTypeAsString(int functionSpaceType) const
65 {
66 return "Default_FunctionSpace";
67 }
68
69 void TestDomain::interpolateOnDomain(Data& target,const Data& source) const
70 {
71 if (source.getFunctionSpace().getDomain().get()!=this)
72 throw DomainException("Error - Illegal domain of interpolant.");
73 if (target.getFunctionSpace().getDomain().get()!=this)
74 throw DomainException("Error - Illegal domain of interpolation target.");
75 target=source;
76 }
77
78 bool TestDomain::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
79 {
80 if ((functionSpaceType_source!=functionSpaceType_target) || (functionSpaceType_target!=TestDomainFS))
81 {
82 throw DomainException("Error - Illegal function type for TestDomain.");
83 }
84 return true;
85 }
86
87 void TestDomain::interpolateACross(Data& target, const Data& source) const
88 {
89 throw DomainException("Error - interpolation to the TestDomain not supported.");
90 }
91
92 bool TestDomain::probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const
93 {
94 return false;
95 }
96
97 ESCRIPT_DLL_API
98 bool TestDomain::commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const
99 {
100 for (int i=0;i<fs.size();++i)
101 {
102 if (fs[i]!=TestDomainFS)
103 {
104 return false;
105 }
106 }
107 resultcode=TestDomainFS;
108 return true;
109 }
110
111
112 int TestDomain::getDefaultCode() const
113 {
114 return TestDomainFS;
115 }
116
117 int TestDomain::getContinuousFunctionCode() const
118 {
119 return TestDomainFS;
120 }
121
122 int TestDomain::getFunctionCode() const
123 {
124 return TestDomainFS;
125 }
126
127 int TestDomain::getFunctionOnBoundaryCode() const
128 {
129 return TestDomainFS;
130 }
131
132 int TestDomain::getFunctionOnContactZeroCode() const
133 {
134 return TestDomainFS;
135 }
136
137 int TestDomain::getFunctionOnContactOneCode() const
138 {
139 return TestDomainFS;
140 }
141
142 int TestDomain::getSolutionCode() const
143 {
144 return TestDomainFS;
145 }
146
147 int TestDomain::getReducedSolutionCode() const
148 {
149 return TestDomainFS;
150 }
151
152 int TestDomain::getDiracDeltaFunctionCode() const
153 {
154 return TestDomainFS;
155 }
156
157 std::pair<int,int> TestDomain::getDataShape(int functionSpaceCode) const
158 {
159 return std::pair<int,int>(m_dpps,m_samples);
160 }
161
162 int TestDomain::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
163 {
164 //
165 // return an arbitary value
166 // - In this case I have chosen to return the deafult tag
167 return 0;
168 }
169
170 const int* TestDomain::borrowSampleReferenceIDs(int functionSpaceType) const
171 {
172 //
173 // return an arbitary value
174 return m_samplerefids;
175 }
176
177 int TestDomain::getDim() const
178 {
179 //
180 // return an arbitary value
181 // Since this domain doesn't really have structure I guess 1 seems sensible
182 return 1;
183 }
184
185 bool TestDomain::operator==(const AbstractDomain& other) const
186 {
187 const TestDomain* temp=dynamic_cast<const TestDomain*>(&other);
188 if (temp!=0) {
189 return true;
190 } else {
191 return false;
192 }
193 }
194
195 bool TestDomain::operator!=(const AbstractDomain& other) const
196 {
197 return(!(*this==other));
198 }
199
200
201
202 bool TestDomain::canTag(int functionSpaceCode) const
203 {
204 return false;
205 }
206
207 int TestDomain::getNumberOfTagsInUse(int functionSpaceCode) const
208 {
209 return 1; // this is not arbitrary. It allows us to report that the default tag is in use
210 }
211
212 const int* TestDomain::borrowListOfTagsInUse(int functionSpaceCode) const
213 {
214 return defaultList;
215 }
216
217 FunctionSpace
218 getTestDomainFunctionSpace(int dpps, int samples)
219 {
220 TestDomain* td=new TestDomain(dpps, samples);
221 Domain_ptr p=Domain_ptr(td);
222 return FunctionSpace(p, td->getDefaultCode());
223 }
224
225 } // end of namespace

  ViewVC Help
Powered by ViewVC 1.1.26