SheafSystem  0.0.0.0
constant_tet.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_tet
19 
20 #include "SheafSystem/constant_tet.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/error_message.h"
24 #include "SheafSystem/std_limits.h"
25 
26 using namespace std;
27 using namespace fiber_bundle; // Workaround for MS C++ bug.
28 
29 // ===========================================================
30 // CONSTANT_TET FACET
31 // ===========================================================
32 
36 {
37  // Preconditions:
38 
39  // Body:
40 
41  _basis_deriv_values = _basis_deriv_value_buffer;
42 
43  // Postconditions:
44 
45  ensure(invariant());
46 
47  // Exit:
48 
49  return;
50 }
51 
52 
55 constant_tet(const constant_tet& xother)
56  : constant_fcn_space(xother)
57 {
58  // Preconditions:
59 
60  // Body:
61 
63 
64  // Postconditions:
65 
66  ensure(invariant());
67 
68  // Exit:
69 
70  return;
71 }
72 
73 
77 {
78  // Preconditions:
79 
80  // Body:
81 
82  // Postconditions:
83 
84  return;
85 }
86 
87 // ===========================================================
88 // CONSTANT_FCN_SPACE FACET
89 // ===========================================================
90 
91 // ===========================================================
92 // LINEAR_FCN_SPACE FACET
93 // ===========================================================
94 
95 // ===========================================================
96 // INTEGRABLE_SECTION_EVALUATOR FACET
97 // ===========================================================
98 
102 volume(const dof_type xcoord_dofs[],
103  size_type xcoord_dofs_ub,
104  size_type xdf)
105 {
106  // Preconditions:
107 
108  require(xcoord_dofs != 0);
109  require(xcoord_dofs_ub >= 0);
110 
111  // Body:
112 
113 
115 
116  not_implemented();
117 
118  value_type result = 0.0;
119 
120  // Postconditions:
121 
122  ensure(invariant());
123 
124  // Exit:
125 
126  return result;
127 }
128 
129 // ===========================================================
130 // DIFFERENTIABLE_SECTION_EVALUATOR FACET
131 // ===========================================================
132 
133 // ===========================================================
134 // DOMAIN FACET
135 // ===========================================================
136 
138 int
140 db() const
141 {
142  int result;
143 
144  // Preconditions:
145 
146 
147  // Body:
148 
149  result = 3;
150 
151  // Postconditions:
152 
153  ensure(result == 3);
154 
155  // Exit:
156 
157  return result;
158 }
159 
160 
162 void
165  coord_type xresult[],
166  size_type xresult_ub) const
167 {
168  // Preconditions:
169 
170  require((0 <= xindex) && (xindex < dof_ct()));
171  require(xresult_ub >= db());
172 
173  // Body:
174 
175  center(xresult, xresult_ub);
176 
177  // Postconditions:
178 
179  ensure(in_standard_domain(xresult, xresult_ub));
180 
181  // Exit:
182 
183  return;
184 }
185 
187 void
189 center(coord_type xresult[], size_type xresult_ub) const
190 {
191  // Preconditions:
192 
193  require(xresult != 0);
194  require(xresult_ub >= db());
195 
196  // Body:
197 
198  static coord_type one_fourth =
199  static_cast<coord_type>(1.0)/static_cast<coord_type>(4.0);
200 
201  xresult[0] = one_fourth;
202  xresult[1] = one_fourth;
203  xresult[2] = one_fourth;
204 
205  // Postconditions:
206 
207 
208  // Exit:
209 
210  return;
211 }
212 
214 bool
216 in_standard_domain(const dof_type xlocal_coords[],
217  size_type xlocal_coords_ub) const
218 {
219  // Preconditions:
220 
221  require(xlocal_coords != 0);
222  require(xlocal_coords_ub >= db());
223 
224  // Body:
225 
226  dof_type u = xlocal_coords[0];
227  dof_type v = xlocal_coords[1];
228  dof_type w = xlocal_coords[2];
229 
230  // "Extend" the bounds by the dof type epsilon (attempting
231  // to ensure that the boundary is included in the domain).
232 
233  dof_type zero = 0.0 - 1000.0*numeric_limits<dof_type>::epsilon();
234  dof_type one = 1.0 + 1000.0*numeric_limits<dof_type>::epsilon();
235 
236  bool result = (u >= zero) && (u <= one) &&
237  (v >= zero) && (v <= one) &&
238  (w >= zero) && (w <= one);
239 
240  // Postconditions:
241 
242  // Exit:
243 
244  return result;
245 
246 }
247 
248 // ===========================================================
249 // EVALUATION FACET
250 // ===========================================================
251 
252 // ===========================================================
253 // ANY FACET
254 // ===========================================================
255 
259 clone() const
260 {
261  constant_tet* result;
262 
263  // Preconditions:
264 
265  // Body:
266 
267  result = new constant_tet();
268 
269  // Postconditions:
270 
271  ensure(result != 0);
272  ensure(is_same_type(result));
273  //ensure(invariant());
274  ensure(result->invariant());
275 
276  return result;
277 }
278 
279 
284 {
285  // Preconditions:
286 
287  require(is_ancestor_of(&xother));
288 
289  // Body:
290 
291  not_implemented();
292 
293  // Postconditions:
294 
295  ensure(invariant());
296 
297  return *this;
298 }
299 
303 operator=(const constant_tet& xother)
304 {
305 
306  // Preconditions:
307 
308  require(is_ancestor_of(&xother));
309 
310  // Body:
311 
312  not_implemented();
313 
314  // Postconditions:
315 
316  ensure(invariant());
317 
318  // Exit:
319 
320  return *this;
321 }
322 
324 bool
326 invariant() const
327 {
328  bool result = true;
329 
330  // Preconditions:
331 
332  // Body:
333 
334  // Must satisfy base class invariant.
335 
336  result = result && constant_fcn_space::invariant();
337 
338  if(invariant_check())
339  {
340  // Prevent recursive calls to invariant.
341 
343 
344  invariance(basis_values() != 0);
345 
346  // Finished, turn invariant checking back on.
347 
349  }
350 
351  // Postconditions:
352 
353  return result;
354 }
355 
357 bool
359 is_ancestor_of(const any* xother) const
360 {
361 
362  // Preconditions:
363 
364  require(xother != 0);
365 
366  // Body:
367 
368  // True if other conforms to this
369 
370  bool result = dynamic_cast<const constant_tet*>(xother) != 0;
371 
372  // Postconditions:
373 
374  return result;
375 
376 }
377 
378 // ===========================================================
379 // PRIVATE MEMBERS
380 // ===========================================================
381 
virtual void center(coord_type xresult[], size_type xresult_ub) const
The local coordinates at the center of the evaluator.
virtual constant_tet * clone() const
Virtual constructor, creates a new instance of the same type as this.
virtual int db() const
The base dimension; the dimension of the local coordinates (independent variable).
virtual ~constant_tet()
Destructor.
Definition: constant_tet.cc:76
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.
constant_tet()
Default constructor.
Definition: constant_tet.cc:35
virtual bool invariant() const
Class invariant.
STL namespace.
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.
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_tet.h:103
virtual size_type dof_ct() const
The number of dofs required for each component of the dependent variable.
Abstract base class with useful features for all objects.
Definition: any.h:39
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
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.
virtual constant_tet & operator=(const section_evaluator &xother)
Assignment operator.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
virtual bool invariant() const
Class invariant.
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
A section evaluator with a constant value over a tetrahedral 3D domain.
Definition: constant_tet.h: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...
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
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
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.