SheafSystem  0.0.0.0
constant_quad.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_quad
19 
20 #include "SheafSystem/constant_quad.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_QUAD 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  return;
48 }
49 
50 
54  : constant_fcn_space(xother)
55 {
56  // Preconditions:
57 
58  // Body:
59 
61 
62  // Postconditions:
63 
64  ensure(invariant());
65 
66  return;
67 }
68 
72 {
73  // Preconditions:
74 
75  // Body:
76 
77  // Postconditions:
78 
79  ensure(invariant());
80 
81  return;
82 }
83 
84 // ===========================================================
85 // CONSTANT_FCN_SPACE FACET
86 // ===========================================================
87 
88 // ===========================================================
89 // LINEAR_FCN_SPACE FACET
90 // ===========================================================
91 
92 // ===========================================================
93 // INTEGRABLE_SECTION_EVALUATOR FACET
94 // ===========================================================
95 
96 
100 volume(const dof_type xcoord_dofs[],
101  size_type xcoord_dofs_ub,
102  size_type xdf)
103 {
104  // Preconditions:
105 
106  require(xcoord_dofs != 0);
107  require(xcoord_dofs_ub >= 0);
108 
109  // Body:
110 
111 
113 
114  not_implemented();
115 
116  value_type result = 0.0;
117 
118  // Postconditions:
119 
120  ensure(invariant());
121 
122  // Exit:
123 
124  return result;
125 }
126 
127 // ===========================================================
128 // DIFFERENTIABLE_SECTION_EVALUATOR FACET
129 // ===========================================================
130 
131 // ===========================================================
132 // DOMAIN FACET
133 // ===========================================================
134 
136 int
138 db() const
139 {
140  int result;
141 
142  // Preconditions:
143 
144 
145  // Body:
146 
147  result = 2;
148 
149  // Postconditions:
150 
151  ensure(result == 2);
152 
153  // Exit:
154 
155  return result;
156 }
157 
158 
160 void
163  coord_type xresult[],
164  size_type xresult_ub) const
165 {
166  // Preconditions:
167 
168  require((0 <= xindex) && (xindex < dof_ct()));
169  require(xresult_ub >= db());
170 
171  // Body:
172 
173  center(xresult, xresult_ub);
174 
175  // Postconditions:
176 
177  ensure(in_standard_domain(xresult, xresult_ub));
178 
179  // Exit:
180 
181  return;
182 }
183 
185 bool
187 in_standard_domain(const dof_type xlocal_coords[],
188  size_type xlocal_coords_ub) const
189 {
190  // Preconditions:
191 
192  require(xlocal_coords != 0);
193  require(xlocal_coords_ub >= 2);
194 
195  // Body:
196 
197  dof_type u = xlocal_coords[0];
198  dof_type v = xlocal_coords[1];
199 
200  // "Extend" the bounds by the dof type epsilon (attempting
201  // to ensure that the boundary is included in the domain).
202 
203  dof_type one = 1.0 + 1000.0*numeric_limits<dof_type>::epsilon();
204 
205  bool result = (u >= -one) && (u <= one) && (v >= -one) && (v <= one);
206 
207  // Postconditions:
208 
209  // Exit:
210 
211  return result;
212 
213 }
214 
215 // ===========================================================
216 // EVALUATION FACET
217 // ===========================================================
218 
219 // ===========================================================
220 // ANY FACET
221 // ===========================================================
222 
226 clone() const
227 {
228  constant_quad* result;
229 
230  // Preconditions:
231 
232  // Body:
233 
234  result = new constant_quad();
235 
236  // Postconditions:
237 
238  ensure(result != 0);
239  ensure(is_same_type(result));
240  //ensure(invariant());
241  ensure(result->invariant());
242 
243  return result;
244 }
245 
246 
251 {
252  // Preconditions:
253 
254  require(is_ancestor_of(&xother));
255 
256  // Body:
257 
258  not_implemented();
259 
260  // Postconditions:
261 
262  ensure(invariant());
263 
264  return *this;
265 }
266 
270 operator=(const constant_quad& xother)
271 {
272 
273  // Preconditions:
274 
275  require(is_ancestor_of(&xother));
276 
277  // Body:
278 
279  not_implemented();
280 
281  // Postconditions:
282 
283  ensure(invariant());
284 
285  // Exit:
286 
287  return *this;
288 }
289 
290 
291 
293 bool
295 invariant() const
296 {
297  bool result = true;
298 
299  // Preconditions:
300 
301  // Body:
302 
303  // Must satisfy base class invariant.
304 
305  result = result && constant_fcn_space::invariant();
306 
307  if(invariant_check())
308  {
309  // Prevent recursive calls to invariant.
310 
312 
313  invariance(basis_values() != 0);
314 
315  // Finished, turn invariant checking back on.
316 
318  }
319 
320  // Postconditions:
321 
322  return result;
323 }
324 
326 bool
328 is_ancestor_of(const any* xother) const
329 {
330 
331  // Preconditions:
332 
333  require(xother != 0);
334 
335  // Body:
336 
337  // True if other conforms to this
338 
339  bool result = dynamic_cast<const constant_quad*>(xother) != 0;
340 
341  // Postconditions:
342 
343  return result;
344 
345 }
346 
347 // ===========================================================
348 // PRIVATE MEMBERS
349 // ===========================================================
350 
351 
constant_quad()
Default constructor.
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...
A section evaluator with a constant value over a square 2D domain.
Definition: constant_quad.h:38
virtual constant_quad & operator=(const section_evaluator &xother)
Assignment operator.
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.
virtual int db() const
The base dimension; the dimension of the local coordinates (independent variable).
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
virtual bool invariant() const
Class invariant.
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
virtual constant_quad * clone() const
Virtual constructor, creates a new instance of the same type as 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.
value_type _basis_deriv_value_buffer[int(DB) *int(DL)]
Storage for the result of the preceeding call to basis_derivs_at_coord.
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.
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
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
virtual ~constant_quad()
Destructor.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
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