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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26