SheafSystem  0.0.0.0
constant_point.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_point
19 
20 #include "SheafSystem/constant_point.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_POINT 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 
69 // ===========================================================
70 // CONSTANT_FCN_SPACE FACET
71 // ===========================================================
72 
73 // ===========================================================
74 // LINEAR_FCN_SPACE FACET
75 // ===========================================================
76 
77 // ===========================================================
78 // INTEGRABLE_SECTION_EVALUATOR FACET
79 // ===========================================================
80 
81 
85 volume(const dof_type xcoord_dofs[],
86  size_type xcoord_dofs_ub,
87  size_type xdf)
88 {
89  // Preconditions:
90 
91  require(xcoord_dofs != 0);
92  require(xcoord_dofs_ub >= 0);
93 
94  // Body:
95 
96 
98 
99  not_implemented();
100 
101  value_type result = 0.0;
102 
103  // Postconditions:
104 
105  ensure(invariant());
106 
107  // Exit:
108 
109  return result;
110 }
111 
112 // ===========================================================
113 // DIFFERENTIABLE_SECTION_EVALUATOR FACET
114 // ===========================================================
115 
116 // ===========================================================
117 // DOMAIN FACET
118 // ===========================================================
119 
121 int
123 db() const
124 {
125  int result;
126 
127  // Preconditions:
128 
129 
130  // Body:
131 
132  result = 0;
133 
134  // Postconditions:
135 
136  ensure(result == 0);
137 
138  // Exit:
139 
140  return result;
141 }
142 
143 
145 void
148  coord_type xresult[],
149  size_type xresult_ub) const
150 {
151  // Preconditions:
152 
153  require((0 <= xindex) && (xindex < dof_ct()));
154  require(xresult_ub >= db());
155 
156  // Body:
157 
158  static const coord_type lcoords[DL] =
159  {
160  0.0
161  };
162 
163  xresult[0] = lcoords[xindex];
164 
165  // Postconditions:
166 
167  ensure(in_standard_domain(xresult, xresult_ub));
168 
169  // Exit:
170 
171  return;
172 }
173 
175 bool
177 in_standard_domain(const dof_type xlocal_coords[],
178  size_type xlocal_coords_ub) const
179 {
180  // Preconditions:
181 
182  require(xlocal_coords != 0);
183  require(xlocal_coords_ub >= db());
184 
185  // Body:
186 
187  dof_type u = xlocal_coords[0];
188 
189  // "Extend" the bounds by the dof type epsilon (attempting
190  // to ensure that the boundary is included in the domain).
191 
192  dof_type eps = 1000.0*numeric_limits<dof_type>::epsilon();
193 
194  bool result = (u >= -eps) && (u <= eps);
195 
196  // Postconditions:
197 
198  // Exit:
199 
200  return result;
201 
202 }
203 
204 // ===========================================================
205 // EVALUATION FACET
206 // ===========================================================
207 
208 // ===========================================================
209 // ANY FACET
210 // ===========================================================
211 
215 clone() const
216 {
217  constant_point* result;
218 
219  // Preconditions:
220 
221  // Body:
222 
223  result = new constant_point();
224 
225  // Postconditions:
226 
227  ensure(result != 0);
228  //ensure(invariant());
229  ensure(result->invariant());
230  ensure(is_same_type(result));
231 
232  return result;
233 }
234 
235 
240 {
241  // Preconditions:
242 
243  require(is_ancestor_of(&xother));
244 
245  // Body:
246 
247  not_implemented();
248 
249  // Postconditions:
250 
251  ensure(invariant());
252 
253  return *this;
254 }
255 
259 operator=(const constant_point& xother)
260 {
261 
262  // Preconditions:
263 
264  require(is_ancestor_of(&xother));
265 
266  // Body:
267 
268  not_implemented();
269 
270  // Postconditions:
271 
272  ensure(invariant());
273 
274  // Exit:
275 
276  return *this;
277 }
278 
279 
283 {
284  // Preconditions:
285 
286  // Body:
287 
288  // Postconditions:
289 
290  ensure(invariant());
291 
292  return;
293 }
294 
295 
297 bool
299 invariant() const
300 {
301  bool result = true;
302 
303  // Preconditions:
304 
305  // Body:
306 
307  // Must satisfy base class invariant.
308 
309  result = result && constant_fcn_space::invariant();
310 
311  if(invariant_check())
312  {
313  // Prevent recursive calls to invariant.
314 
316 
317  invariance(basis_values() != 0);
318 
319  // Finished, turn invariant checking back on.
320 
322  }
323 
324  // Postconditions:
325 
326  return result;
327 }
328 
330 bool
332 is_ancestor_of(const any* xother) const
333 {
334 
335  // Preconditions:
336 
337  require(xother != 0);
338 
339  // Body:
340 
341  // True if other conforms to this
342 
343  bool result = dynamic_cast<const constant_point*>(xother) != 0;
344 
345  // Postconditions:
346 
347  return result;
348 
349 }
350 
351 // ===========================================================
352 // PRIVATE MEMBERS
353 // ===========================================================
354 
355 
356 
virtual constant_point * clone() const
Virtual constructor, creates a new instance of the same type as this.
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
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...
virtual int db() const
The base dimension; the dimension of the local coordinates (independent variable).
A section evaluator with a constant value over a 1D domain.
virtual bool invariant() const
Class invariant.
STL namespace.
virtual bool invariant() const
Class invariant.
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 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 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_point()
Default constructor.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual constant_point & operator=(const section_evaluator &xother)
Assignment operator.
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
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
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.
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
value_type _basis_deriv_value_buffer[DL]
Storage for the result of the preceeding call to basis_derivs_at_coord.
virtual ~constant_point()
Destructor.