SheafSystem  0.0.0.0
integrable_section_evaluator.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 section_evaluator
19 
20 #include "SheafSystem/integrable_section_evaluator.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/block.h"
24 #include "SheafSystem/sec_vd.h"
25 
26 using namespace fiber_bundle; // Workaround for MS C++ bug.
27 
28 // ===========================================================
29 // INTEGRABLE_SECTION_EVALUATOR FACET
30 // ===========================================================
31 
35 {
36  // Preconditions:
37 
38  // Body:
39 
40  // No action required.
41 
42  // Postconditions:
43 
44  ensure(invariant());
45 
46  return;
47 }
48 
52 {
53  // Preconditions:
54 
55  // Body:
56 
57  // Postconditions:
58 
59  ensure(invariant());
60 
61  return;
62 }
63 
64 
68 volume(const dof_type xcoord_dofs[],
69  size_type xcoord_dofs_ub,
70  size_type xdf)
71 {
72  // Preconditions:
73 
74  require(xcoord_dofs != 0);
75  require(xcoord_dofs_ub >= 0);
76 
77  // Body:
78 
79  is_abstract();
80 
81  value_type result = 0.0;
82 
83  // Postconditions:
84 
85  ensure(invariant());
86 
87  // Exit:
88 
89  return result;
90 }
91 
93 void
95 integrate(const dof_type xcoord_dofs[],
96  size_type xcoord_dofs_ub,
97  size_type xdf,
98  const dof_type xintegrands[],
99  size_type xintegrands_ub,
100  value_type xresult_integrals[],
101  size_type xresult_integrals_ub)
102 {
104 
105  // Preconditions:
106 
107  require(xcoord_dofs != 0);
108  require(xcoord_dofs_ub >= 0);
109  require(xintegrands != 0);
110  require(xintegrands_ub >= 0);
111  require(xresult_integrals != 0);
112  require(xresult_integrals_ub > 0);
113 
114  // Body:
115 
116  is_abstract();
117 
118  // Postconditions:
119 
120  ensure(invariant());
121 
122  // Exit:
123 
124  return;
125 }
126 
128 void
130 integrate(const dof_type xcoord_dofs[],
131  size_type xcoord_dofs_ub,
132  size_type xdf,
133  const dof_type xintegrand,
134  value_type xresult_integrals[],
135  size_type xresult_integrals_ub)
136 {
138 
139  // Preconditions:
140 
141  require(xcoord_dofs != 0);
142  require(xcoord_dofs_ub >= 0);
143  require(xresult_integrals != 0);
144  require(xresult_integrals_ub >= 0);
145 
146  // Body:
147 
148  integrate(xcoord_dofs, xcoord_dofs_ub, xdf, &xintegrand, 1, xresult_integrals, xresult_integrals_ub);
149 
150  // Postconditions:
151 
152  ensure(invariant());
153 
154  // Exit:
155 
156  return;
157 }
158 
160 void
163  coord_type xresult[],
164  size_type xresult_ub)
165 {
166  // Preconditions:
167 
168  require((0 <= xindex) && (xindex < dof_ct()));
169  require(xresult_ub >= db());
170 
171  // Body:
172 
173  is_abstract();
174 
175  // Postconditions:
176 
177  ensure(in_standard_domain(xresult, xresult_ub));
178  ensure(invariant());
179 
180  // Exit:
181 
182  return;
183 }
184 
188 {
189  // Preconditions:
190 
191  // Body:
192 
193  // Postconditions:
194 
195  ensure(invariant());
196 
197  return;
198 }
199 
200 // ===========================================================
201 // DOMAIN FACET
202 // ===========================================================
203 
204 // ===========================================================
205 // ANY FACET
206 // ===========================================================
207 
208 
212 clone() const
213 {
214  integrable_section_evaluator* result = 0;
215 
216  // Preconditions:
217 
218  // Body:
219 
220  is_abstract();
221 
222  // Postconditions:
223 
224  ensure(result != 0);
225  ensure(is_same_type(result));
226 
227  // Exit:
228 
229  return result;
230 }
231 
232 
237 {
238  // Preconditions:
239 
240  require(is_ancestor_of(&xother));
241 
242  // Body:
243 
244  not_implemented();
245 
246  // Postconditions:
247 
248  ensure(invariant());
249 
250  // Exit
251 
252  return *this;
253 }
254 
256 bool
258 invariant() const
259 {
260  bool result = true;
261 
262  // Preconditions:
263 
264  // Body:
265 
266  // Must satisfy base class invariant.
267 
268  result = result && any::invariant();
269 
270  if(invariant_check())
271  {
272  // Prevent recursive calls to invariant.
273 
274  disable_invariant_check();
275 
276  // Finished, turn invariant checking back on.
277 
278  enable_invariant_check();
279  }
280 
281  // Postconditions:
282 
283  return result;
284 }
285 
287 bool
289 is_ancestor_of(const any* xother) const
290 {
291 
292  // Preconditions:
293 
294  require(xother != 0);
295 
296  // Body:
297 
298  // True if other conforms to this
299 
300  bool result = dynamic_cast<const integrable_section_evaluator*>(xother) != 0;
301 
302  // Postconditions:
303 
304  return result;
305 
306 }
307 
308 
309 // ===========================================================
310 // NON-MEMBER FUNCTIONS
311 // ===========================================================
312 
313 size_t
314 fiber_bundle::
315 deep_size(const integrable_section_evaluator& xe, bool xinclude_shallow)
316 {
317  size_t result;
318 
319  // Preconditions:
320 
321  // Body:
322 
325 
326  result = 0;
327 
328  // Postconditions:
329 
330  ensure(result == 0);
331  //ensure(result >= 0);
332 
333  // Exit
334 
335  return result;
336 }
337 
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
Definition: any.cc:153
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual value_type volume(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf)=0
Volume for specified coordinate dofs xcoord_dofs and fiber space dimension xdf.
sec_vd_dof_type dof_type
The type of degree of freedom.
virtual bool invariant() const
Class invariant.
virtual integrable_section_evaluator * clone() const =0
Virtual constructor, makes a new instance of the same type as this.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual void gauss_point(pod_index_type xindex, coord_type xresult[], size_type xresult_ub)=0
The local coordinates of the gauss point with index xindex.
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 integrable_section_evaluator & operator=(const integrable_section_evaluator &xother)
Assignment operator.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual void integrate(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf, const dof_type xintegrands[], size_type xintegrands_ub, value_type xresult_integrals[], size_type xresult_integrals_ub)=0
Computes the value of the integral of the integrand array...
An abstract section evaluator with a bounded domain that supports integration (volume calculation) as...
Namespace for the fiber_bundles component of the sheaf system.