SheafSystem  0.0.0.0
constant_hex.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Implementation for class constant_hex
19 
20 #include "SheafSystem/constant_hex.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/error_message.h"
24 #include "SheafSystem/std_limits.h"
25 #include "SheafSystem/std_cmath.h"
26 
27 using namespace std;
28 using namespace fiber_bundle; // Workaround for MS C++ bug.
29 
30 //#define DIAGNOSTIC_OUTPUT
31 
32 // ===========================================================
33 // CONSTANT_HEX FACET
34 // ===========================================================
35 
39 {
40  // Preconditions:
41 
42  // Body:
43 
44  _basis_deriv_values = _basis_deriv_value_buffer;
45 
46  // Postconditions:
47 
48  ensure(invariant());
49 
50  return;
51 }
52 
53 
54 // Copy constructor.
57 constant_hex(const constant_hex& xother)
58  : constant_fcn_space(xother)
59 {
60  // Preconditions:
61 
62  // Body:
63 
65 
66  // Postconditions:
67 
68  ensure(invariant());
69 
70  return;
71 }
72 
73 
74 
75 
76 // Destructor.
80 {
81  // Preconditions:
82 
83  // Body:
84 
85  // Postconditions:
86 
87  ensure(invariant());
88 
89  return;
90 }
91 
92 // ===========================================================
93 // CONSTANT_FCN_SPACE FACET
94 // ===========================================================
95 
96 // ===========================================================
97 // LINEAR_FCN_SPACE FACET
98 // ===========================================================
99 
100 // ===========================================================
101 // INTEGRABLE_SECTION_EVALUATOR FACET
102 // ===========================================================
103 
107 volume(const dof_type xcoord_dofs[],
108  size_type xcoord_dofs_ub,
109  size_type xdf)
110 {
111  // Preconditions:
112 
113  require(xcoord_dofs != 0);
114  require(xcoord_dofs_ub >= 0);
115 
116  // Body:
117 
119 
120  not_implemented();
121 
122  value_type result = 0.0;
123 
124  // Postconditions:
125 
126  ensure(invariant());
127 
128  // Exit:
129 
130  return result;
131 }
132 
133 // ===========================================================
134 // DIFFERENTIABLE_SECTION_EVALUATOR FACET
135 // ===========================================================
136 
137 // ===========================================================
138 // DOMAIN FACET
139 // ===========================================================
140 
142 int
144 db() const
145 {
146  int result;
147 
148  // Preconditions:
149 
150 
151  // Body:
152 
153  result = 3;
154 
155  // Postconditions:
156 
157  ensure(result == 3);
158 
159  // Exit:
160 
161  return result;
162 }
163 
165 void
168  coord_type xresult[],
169  size_type xresult_ub) const
170 {
171  // Preconditions:
172 
173  require((0 <= xindex) && (xindex < dof_ct()));
174  require(xresult_ub >= db());
175 
176  // Body:
177 
178  center(xresult, xresult_ub);
179 
180  // Postconditions:
181 
182  ensure(in_standard_domain(xresult, xresult_ub));
183 
184  // Exit:
185 
186  return;
187 }
188 
190 bool
192 in_standard_domain(const dof_type xlocal_coords[],
193  size_type xlocal_coords_ub) const
194 {
195  // Preconditions:
196 
197  require(xlocal_coords != 0);
198  require(xlocal_coords_ub >= db());
199 
200  // Body:
201 
202  dof_type u = xlocal_coords[0];
203  dof_type v = xlocal_coords[1];
204  dof_type w = xlocal_coords[2];
205 
206  // "Extend" the bounds by the dof type epsilon (attempting
207  // to ensure that the boundary is included in the domain).
208 
209  dof_type one = 1.0 + 1000.0*numeric_limits<dof_type>::epsilon();
210 
211  bool result = (u >= -one) && (u <= one) &&
212  (v >= -one) && (v <= one) &&
213  (w >= -one) && (w <= one);
214 
215  // Postconditions:
216 
217  // Exit:
218 
219  return result;
220 
221 }
222 
223 // ===========================================================
224 // EVALUATION FACET
225 // ===========================================================
226 
227 // ===========================================================
228 // ANY FACET
229 // ===========================================================
230 
234 clone() const
235 {
236  constant_hex* result;
237 
238  // Preconditions:
239 
240  // Body:
241 
242  result = new constant_hex();
243 
244  // Postconditions:
245 
246  ensure(result != 0);
247  ensure(is_same_type(result));
248  //ensure(invariant());
249  ensure(result->invariant());
250 
251  return result;
252 }
253 
258 {
259  // Preconditions:
260 
261  require(is_ancestor_of(&xother));
262 
263  // Body:
264 
265  not_implemented();
266 
267  // Postconditions:
268 
269  ensure(invariant());
270 
271  return *this;
272 }
273 
277 operator=(const constant_hex& xother)
278 {
279 
280  // Preconditions:
281 
282  require(is_ancestor_of(&xother));
283 
284  // Body:
285 
286  not_implemented();
287 
288  // Postconditions:
289 
290  ensure(invariant());
291 
292  // Exit:
293 
294  return *this;
295 }
296 
298 bool
300 invariant() const
301 {
302  bool result = true;
303 
304  // Preconditions:
305 
306  // Body:
307 
308  // Must satisfy base class invariant.
309 
310  result = result && constant_fcn_space::invariant();
311 
312  if(invariant_check())
313  {
314  // Prevent recursive calls to invariant.
315 
317 
318  invariance(basis_values() != 0);
319 
320  // Finished, turn invariant checking back on.
321 
323  }
324 
325  // Postconditions:
326 
327  return result;
328 }
329 
331 bool
333 is_ancestor_of(const any* xother) const
334 {
335 
336  // Preconditions:
337 
338  require(xother != 0);
339 
340  // Body:
341 
342  // True if other conforms to this
343 
344  bool result = dynamic_cast<const constant_hex*>(xother) != 0;
345 
346  // Postconditions:
347 
348  return result;
349 
350 }
351 
352 
353 // ===========================================================
354 // PRIVATE MEMBERS
355 // ===========================================================
356 
virtual bool invariant() const
Class invariant.
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
virtual int db() const
The base dimension; the dimension of the local coordinates (independent variable).
virtual bool invariant() const
Class invariant.
STL namespace.
virtual ~constant_hex()
Destructor.
Definition: constant_hex.cc:79
value_type * _basis_deriv_values
The result of the preceding call to basis_derivs_at_coord.
sec_vd_dof_type dof_type
The type of degree of freedom.
virtual value_type volume(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf)
Volume for specified coordinate dofs xcoord_dofs and fiber space dimension xdf.
virtual size_type dof_ct() const
The number of dofs required for each component of the dependent variable.
constant_hex()
Default constructor.
Definition: constant_hex.cc:38
virtual bool in_standard_domain(const dof_type xlocal_coords[], size_type xlocal_coords_ub) const
Return true if the specified local coordinates are in the "standard" domain; otherwise return false...
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual constant_hex & operator=(const section_evaluator &xother)
Assignment operator.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual void center(coord_type xresult[], size_type xresult_ub) const
The local coordinates at the center of the evaluator.
chart_point_coord_type coord_type
The type of local coordinate; the scalar type for the local coordinate vector space.
vd_value_type value_type
The type of component in the value; the scalar type in the range vector space.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual void local_coordinates(pod_index_type xindex, coord_type xresult[], size_type xresult_ub) const
The local coordinates of the dof with local index xindex.
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
virtual constant_hex * clone() const
Virtual constructor, creates a new instance of the same type as this.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
value_type _basis_deriv_value_buffer[int(DB) *int(DL)]
Storage for the result of the preceeding call to basis_derivs_at_coord.
Definition: constant_hex.h:102
A section evaluator using trilinear interpolation over a cubic 3D domain.
Definition: constant_hex.h:38
const value_type * basis_values() const
The result of the preceding call to basis_at_coord.
An section evaluator with a constant value over an abstract domain.
Namespace for the fiber_bundles component of the sheaf system.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87