SheafSystem  0.0.0.0
differentiable_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/differentiable_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 // DIFFERENTIABLE_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 
65 void
67 dxi_local(size_type xlocal_coord_index,
68  const block<dof_type>& xsource_dofs,
69  block<dof_type>& xresult_dofs) const
70 {
71  // Preconditions:
72 
73 
74  require(precondition_of(dxi_local(xlocal_coord_index,
75  xsource_dofs.base(),
76  xsource_dofs.ct(),
77  xresult_dofs.base(),
78  xresult_dofs.ub())));
79 
80  // Body:
81 
82  dxi_local(xlocal_coord_index,
83  xsource_dofs.base(),
84  xsource_dofs.ct(),
85  xresult_dofs.base(),
86  xresult_dofs.ub());
87 
88  xresult_dofs.set_ct(xsource_dofs.ct());
89 
90  // Postconditions:
91 
92  ensure(postcondition_of(dxi_local(xlocal_coord_index,
93  xsource_dofs.base(),
94  xsource_dofs.ct(),
95  xresult_dofs.base(),
96  xresult_dofs.ub())));
97 
98  ensure(xresult_dofs.ct() == xsource_dofs.ct());
99 
100  // Exit:
101 
102  return;
103 }
104 
106 void
108 jacobian(const dof_type xcoord_dofs[],
109  size_type xcoord_dofs_ub,
110  size_type xdf,
111  const dof_type xlocal_coords[],
112  size_type xlocal_coords_ub)
113 {
114  // Preconditions:
115 
116  require(xcoord_dofs != 0);
117  require(xcoord_dofs_ub >= 0);
118  require(xlocal_coords != 0);
119  require(xlocal_coords_ub >= db());
120  require(jacobian_values() != 0);
121 
122  // Body:
123 
126 
127  not_implemented();
128 
129  // Postconditions:
130 
131  ensure(invariant());
132 
133  // Exit:
134 
135  return;
136 }
137 
142 {
143 
144  // Preconditions:
145 
146 
147  // Body:
148 
149  const value_type* result = _jacobian_values;
150 
151  // Postconditions:
152 
153 
154  // Exit:
155 
156  return result;
157 }
158 
162 jacobian_determinant(const dof_type xcoord_dofs[],
163  size_type xcoord_dofs_ub,
164  size_type xdf,
165  const coord_type xlocal_coords[],
166  size_type xlocal_coords_ub)
167 {
168  // Preconditions:
169 
170  require(xcoord_dofs != 0);
171  require(xcoord_dofs_ub >= 0);
172  require(xlocal_coords != 0);
173  require(xlocal_coords_ub >= db());
174  require(jacobian_values() != 0);
175 
176  // Body:
177 
178 
181 
182  not_implemented();
183 
184  value_type result = 0.0;
185 
186  // Postconditions:
187 
188  ensure(invariant());
189 
190  // Exit:
191 
192  return result;
193 }
194 
198 {
199  // Preconditions:
200 
201  // Body:
202 
203  // Postconditions:
204 
205  ensure(invariant());
206 
207  return;
208 }
209 
210 // ===========================================================
211 // ANY FACET
212 // ===========================================================
213 
214 
218 clone() const
219 {
221 
222  // Preconditions:
223 
224  // Body:
225 
226  is_abstract();
227 
228  // Postconditions:
229 
230  ensure(result != 0);
231  ensure(is_same_type(result));
232 
233  // Exit:
234 
235  return result;
236 }
237 
238 
243 {
244  // Preconditions:
245 
246  require(is_ancestor_of(&xother));
247 
248  // Body:
249 
250  not_implemented();
251 
252  // Postconditions:
253 
254  ensure(invariant());
255 
256  // Exit
257 
258  return *this;
259 }
260 
262 bool
264 invariant() const
265 {
266  bool result = true;
267 
268  // Preconditions:
269 
270  // Body:
271 
272  // Must satisfy base class invariant.
273 
274  result = result && any::invariant();
275 
276  if(invariant_check())
277  {
278  // Prevent recursive calls to invariant.
279 
280  disable_invariant_check();
281 
282  // Finished, turn invariant checking back on.
283 
284  enable_invariant_check();
285  }
286 
287  // Postconditions:
288 
289  return result;
290 }
291 
293 bool
295 is_ancestor_of(const any* xother) const
296 {
297 
298  // Preconditions:
299 
300  require(xother != 0);
301 
302  // Body:
303 
304  // True if other conforms to this
305 
306  bool result = dynamic_cast<const section_evaluator*>(xother) != 0;
307 
308  // Postconditions:
309 
310  return result;
311 
312 }
313 
314 // ===========================================================
315 // NON-MEMBER FUNCTIONS
316 // ===========================================================
317 
318 size_t
319 fiber_bundle::
320 deep_size(const differentiable_section_evaluator& xe, bool xinclude_shallow)
321 {
322  size_t result;
323 
324  // Preconditions:
325 
326  // Body:
327 
330 
331  result = 0;
332 
333  // Postconditions:
334 
335  ensure(result == 0);
336  //ensure(result >= 0);
337 
338  // Exit
339 
340  return result;
341 }
342 
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
Definition: any.cc:153
index_type ub() const
The upper bound on the storage array. The number of items current allocated in the storage array...
size_type ct() const
The number of items currently in use.
sec_vd_dof_type dof_type
The type of degree of freedom.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual value_type jacobian_determinant(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf, const coord_type xlocal_coords[], size_type xlocal_coords_ub)
Computes the the determinant of the jacobian matrix at local coordinates xlocal_coords with coordinat...
pointer_type base() const
The underlying storage array.
An abstract section evaluator that can be differentiated.
virtual differentiable_section_evaluator * clone() const =0
Virtual constructor, makes a new instance of the same type as this.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
const value_type * jacobian_values() const
The result of the preceding call to jacobian.
chart_point_coord_type coord_type
The type of local coordinate; the scalar type for the local coordinate vector space.
virtual void jacobian(const dof_type xcoord_dofs[], size_type xcoord_dofs_ub, size_type xdf, const dof_type xlocal_coords[], size_type xlocal_coords_ub)
Computes the the jacobian matrix at local coordinates xlocal_coords with coordinate dofs xcoord_dofs...
vd_value_type value_type
The type of component in the value; the scalar type in the range vector space.
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual void dxi_local(size_type xlocal_coord_index, const dof_type xsource_dofs[], size_type xsource_dofs_ub, dof_type xresult_dofs[], size_type xresult_dofs_ub) const =0
First partial derivative of this with respect to local coordinate xlocal_coord_index.
virtual differentiable_section_evaluator & operator=(const differentiable_section_evaluator &xother)
Assignment operator.
An auto_block with a no-initialization initialization policy.
Namespace for the fiber_bundles component of the sheaf system.