/[escript]/branches/arrexp_2137_win_merge/escript/src/NullDomain.cpp
ViewVC logotype

Contents of /branches/arrexp_2137_win_merge/escript/src/NullDomain.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2087 - (show annotations)
Mon Nov 24 04:51:30 2008 UTC (10 years, 9 months ago) by jfenwick
Original Path: trunk/escript/src/NullDomain.cpp
File size: 3861 byte(s)
Addressing mantis issue #221.
Interpolation.. and probeInterpolation.. now "work" for the NullDomain.
Work means throw a descriptive exception if you try to move into or out 
of the NullDomain.
The bad_cast exception related to this has been fixed.


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 "NullDomain.h"
17 #include "Data.h"
18
19 namespace escript {
20
21 namespace {
22 int defaultList[1]={0}; // an array to return in borrowListOfTagsInUse();
23 int NullDomainFS=1; // Null domains only support 1 functionspace type.
24 // The choice of =1 as the value is arbitrary
25 }
26
27
28 NullDomain::NullDomain() {
29 }
30
31 bool NullDomain::isValidFunctionSpaceType(int functionSpaceType) const
32 {
33 return (functionSpaceType==NullDomainFS);
34 }
35
36 std::string NullDomain::getDescription() const
37 {
38 return "NullDomain";
39 }
40
41 std::string NullDomain::functionSpaceTypeAsString(int functionSpaceType) const
42 {
43 return "Default_FunctionSpace";
44 }
45
46 void NullDomain::interpolateOnDomain(Data& target,const Data& source) const
47 {
48 if (source.getFunctionSpace().getDomain().get()!=this)
49 throw DomainException("Error - Illegal domain of interpolant.");
50 if (target.getFunctionSpace().getDomain().get()!=this)
51 throw DomainException("Error - Illegal domain of interpolation target.");
52 target=source;
53 }
54
55 bool NullDomain::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
56 {
57 if ((functionSpaceType_source!=functionSpaceType_target) || (functionSpaceType_target!=NullDomainFS))
58 {
59 throw DomainException("Error - Illegal function type for NullDomain.");
60 }
61 return true;
62 }
63
64 void NullDomain::interpolateACross(Data& target, const Data& source) const
65 {
66 throw DomainException("Error - interpolation to the NullDomain not supported.");
67 }
68
69 bool NullDomain::probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const
70 {
71 return false;
72 }
73
74 int NullDomain::getContinuousFunctionCode() const
75 {
76 return NullDomainFS;
77 }
78
79 int NullDomain::getFunctionCode() const
80 {
81 return NullDomainFS;
82 }
83
84 int NullDomain::getFunctionOnBoundaryCode() const
85 {
86 return NullDomainFS;
87 }
88
89 int NullDomain::getFunctionOnContactZeroCode() const
90 {
91 return NullDomainFS;
92 }
93
94 int NullDomain::getFunctionOnContactOneCode() const
95 {
96 return NullDomainFS;
97 }
98
99 int NullDomain::getSolutionCode() const
100 {
101 return NullDomainFS;
102 }
103
104 int NullDomain::getReducedSolutionCode() const
105 {
106 return NullDomainFS;
107 }
108
109 int NullDomain::getDiracDeltaFunctionCode() const
110 {
111 return NullDomainFS;
112 }
113
114 std::pair<int,int> NullDomain::getDataShape(int functionSpaceCode) const
115 {
116 //
117 // return an arbitary value
118 return std::pair<int,int>(1,1);
119 }
120
121 int NullDomain::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
122 {
123 //
124 // return an arbitary value
125 return 1;
126 }
127
128 int referenceID=10;
129
130 int* NullDomain::borrowSampleReferenceIDs(int functionSpaceType) const
131 {
132 //
133 // return an arbitary value
134 return &(referenceID);
135 }
136
137 int NullDomain::getDim() const
138 {
139 //
140 // return an arbitary value
141 return 1;
142 }
143
144 bool NullDomain::operator==(const AbstractDomain& other) const
145 {
146 const NullDomain* temp=dynamic_cast<const NullDomain*>(&other);
147 if (temp!=0) {
148 return true;
149 } else {
150 return false;
151 }
152 }
153
154 bool NullDomain::operator!=(const AbstractDomain& other) const
155 {
156 return(!(*this==other));
157 }
158
159
160
161 bool NullDomain::canTag(int functionSpaceCode) const
162 {
163 return true;
164 }
165
166 int NullDomain::getNumberOfTagsInUse(int functionSpaceCode) const
167 {
168 return 1; // this is not arbitrary. It allows us to report that the default tag is in use
169 }
170
171 int* NullDomain::borrowListOfTagsInUse(int functionSpaceCode) const
172 {
173 return defaultList;
174 }
175
176
177
178 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26