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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2635 - (show annotations)
Thu Aug 27 04:54:41 2009 UTC (10 years, 5 months ago) by jfenwick
File size: 4844 byte(s)
A bunch of changes related to saveDataCSV.
[Not completed or unit tested yet]

Added saveDataCSV to util.py
AbstractDomain (and MeshAdapter) have a commonFunctionSpace method to 
take a group of FunctionSpaces and return something they can all be interpolated to.

Added pointToStream() in DataTypes to help print points.

added actsConstant() to data - required because DataConstant doesn't store samples the same way other Data do.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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 ESCRIPT_DLL_API
88 bool TestDomain::commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const
89 {
90 for (int i=0;i<fs.size();++i)
91 {
92 if (fs[i]!=TestDomainFS)
93 {
94 return false;
95 }
96 }
97 resultcode=TestDomainFS;
98 return true;
99 }
100
101
102 int TestDomain::getDefaultCode() const
103 {
104 return TestDomainFS;
105 }
106
107 int TestDomain::getContinuousFunctionCode() const
108 {
109 return TestDomainFS;
110 }
111
112 int TestDomain::getFunctionCode() const
113 {
114 return TestDomainFS;
115 }
116
117 int TestDomain::getFunctionOnBoundaryCode() const
118 {
119 return TestDomainFS;
120 }
121
122 int TestDomain::getFunctionOnContactZeroCode() const
123 {
124 return TestDomainFS;
125 }
126
127 int TestDomain::getFunctionOnContactOneCode() const
128 {
129 return TestDomainFS;
130 }
131
132 int TestDomain::getSolutionCode() const
133 {
134 return TestDomainFS;
135 }
136
137 int TestDomain::getReducedSolutionCode() const
138 {
139 return TestDomainFS;
140 }
141
142 int TestDomain::getDiracDeltaFunctionCode() const
143 {
144 return TestDomainFS;
145 }
146
147 std::pair<int,int> TestDomain::getDataShape(int functionSpaceCode) const
148 {
149 return std::pair<int,int>(m_dpps,m_samples);
150 }
151
152 int TestDomain::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
153 {
154 //
155 // return an arbitary value
156 // - In this case I have chosen to return the deafult tag
157 return 0;
158 }
159
160 const int* TestDomain::borrowSampleReferenceIDs(int functionSpaceType) const
161 {
162 //
163 // return an arbitary value
164 return m_samplerefids;
165 }
166
167 int TestDomain::getDim() const
168 {
169 //
170 // return an arbitary value
171 // Since this domain doesn't really have structure I guess 1 seems sensible
172 return 1;
173 }
174
175 bool TestDomain::operator==(const AbstractDomain& other) const
176 {
177 const TestDomain* temp=dynamic_cast<const TestDomain*>(&other);
178 if (temp!=0) {
179 return true;
180 } else {
181 return false;
182 }
183 }
184
185 bool TestDomain::operator!=(const AbstractDomain& other) const
186 {
187 return(!(*this==other));
188 }
189
190
191
192 bool TestDomain::canTag(int functionSpaceCode) const
193 {
194 return false;
195 }
196
197 int TestDomain::getNumberOfTagsInUse(int functionSpaceCode) const
198 {
199 return 1; // this is not arbitrary. It allows us to report that the default tag is in use
200 }
201
202 const int* TestDomain::borrowListOfTagsInUse(int functionSpaceCode) const
203 {
204 return defaultList;
205 }
206
207 FunctionSpace
208 getTestDomainFunctionSpace(int dpps, int samples)
209 {
210 TestDomain* td=new TestDomain(dpps, samples);
211 Domain_ptr p=Domain_ptr(td);
212 return FunctionSpace(p, td->getDefaultCode());
213 }
214
215 } // end of namespace

  ViewVC Help
Powered by ViewVC 1.1.26