SheafSystem  0.0.0.0
dlinear_eval_family.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 dlinear_eval_family
19 
20 
21 #include "SheafSystem/assert_contract.h"
22 #include "SheafSystem/base_space_member.h"
23 #include "SheafSystem/bilinear_2d.h"
24 #include "SheafSystem/constant_point.h"
25 #include "SheafSystem/dlinear_eval_family.h"
26 #include "SheafSystem/factory.h"
27 #include "SheafSystem/fiber_bundles_namespace.h"
28 #include "SheafSystem/int_set.h"
29 #include "SheafSystem/linear_1d.h"
30 #include "SheafSystem/linear_2d.h"
31 #include "SheafSystem/linear_3d.h"
32 #include "SheafSystem/namespace_poset.h"
33 #include "SheafSystem/sheaf.h"
34 #include "SheafSystem/trilinear_3d.h"
35 
36 using namespace std;
37 using namespace fiber_bundle; // Workaround for MS C++ bug.
38 
39 // PUBLIC MEMBER FUNCTIONS
40 
41 // CANONICAL MEMBERS
42 
44 fiber_bundle::dlinear_eval_family::
45 dlinear_eval_family(const dlinear_eval_family& xother)
46  : eval_family(xother)
47 {
48 
49  // Preconditions:
50 
51  // Body:
52 
53  // Postconditions:
54 
55  ensure(invariant());
56 
57  // Exit:
58 }
59 
60 
61 
65 clone() const
66 {
67  dlinear_eval_family* result;
68 
69  // Preconditions:
70 
71  // Body:
72 
73  result = new dlinear_eval_family(*this);
74 
75  // Postconditions:
76 
77  ensure(result != 0);
78  ensure(is_same_type(result));
79 
80  // Exit:
81 
82  return result;
83 }
84 
85 
89 {
90 
91  // Preconditions:
92 
93  // Body:
94 
95  // Postconditions:
96 
97  // Exit:
98 
99  return;
100 }
101 
102 
104 bool
106 invariant() const
107 {
108  bool result = true;
109 
110  // Preconditions:
111 
112  // Body:
113 
114  // Must satisfy base class invariant
115 
116  result = result && eval_family::invariant();
117 
118  if(invariant_check())
119  {
120  // Prevent recursive calls to invariant
121 
123 
124  // Finished, turn invariant checking back on.
125 
127  }
128 
129  // Postconditions:
130 
131  // Exit
132 
133  return result;
134 }
135 
137 bool
139 is_ancestor_of(const any* xother) const
140 {
141 
142  // Preconditions:
143 
144  require(xother != 0);
145 
146  // Body:
147 
148  // True if other conforms to this
149 
150  bool result = dynamic_cast<const dlinear_eval_family*>(xother) != 0;
151 
152  // Postconditions:
153 
154  return result;
155 
156 }
157 
158 
159 
160 // DLINEAR_FAMILY FACET
161 
162 
164 fiber_bundle::dlinear_eval_family::
165 dlinear_eval_family(const namespace_poset& xname_space)
166 {
167 
168  // Preconditions:
169 
170  require(xname_space.state_is_read_accessible());
172 
173  // Body:
174 
175  initialize(xname_space);
176 
177  // Postconditions:
178 
179  ensure(invariant());
180 }
181 
183 const std::string&
185 class_name() const
186 {
187  // Preconditions:
188 
189  // Body:
190 
191  const string& result = static_class_name();
192 
193  // Postconditions:
194 
195  ensure(!result.empty());
196 
197  // Exit:
198 
199  return result;
200 }
201 
203 const std::string&
206 {
207  // Preconditions:
208 
209  // Body:
210 
211  static const string result("dlinear");
212 
213  // Postconditions:
214 
215  ensure(!result.empty());
216 
217  // Exit:
218 
219  return result;
220 }
221 
223 void
225 initialize(const namespace_poset& xname_space)
226 {
227 
228  // Preconditions:
229 
230  require(!is_initialized());
231  require(xname_space.state_is_read_accessible());
233 
234 
235  // Body:
236 
237  eval_family::initialize(xname_space);
238 
239  // The type codes used here must be the same as those used
240  // in fiber_bundles_namespace::make_base_space_member_prototypes().
241 
242  poset* lhost = &xname_space.member_poset<poset>(base_space_member::prototypes_poset_name(), false);
243  lhost->get_read_access();
244 
245  // Allocate enough storage for the members.
246 
248 
249  // Get the type id of each member of the family and
250  // and create the appropriate entry in _members.
251 
259 
260  base_space_member lmbr;
261  lmbr.attach_to_state(lhost, "point");
262  _members.force_item(lmbr.type_id(), new constant_point);
263 
264  lmbr.attach_to_state(lhost, "segment");
265  _members.force_item(lmbr.type_id(), new linear_1d);
266 
267  lmbr.attach_to_state(lhost, "segment_complex");
268  _members.force_item(lmbr.type_id(), new linear_1d);
269 
270  lmbr.attach_to_state(lhost, "triangle");
271  _members.force_item(lmbr.type_id(), new linear_2d);
272 
273  lmbr.attach_to_state(lhost, "triangle_nodes");
274  _members.force_item(lmbr.type_id(), new linear_2d);
275 
276  lmbr.attach_to_state(lhost, "triangle_complex");
277  _members.force_item(lmbr.type_id(), new linear_2d);
278 
279  lmbr.attach_to_state(lhost, "quad");
280  _members.force_item(lmbr.type_id(), new bilinear_2d);
281 
282  lmbr.attach_to_state(lhost, "quad_nodes");
283  _members.force_item(lmbr.type_id(), new bilinear_2d);
284 
285  lmbr.attach_to_state(lhost, "quad_complex");
286  _members.force_item(lmbr.type_id(), new bilinear_2d);
287 
288  lmbr.attach_to_state(lhost, "hex");
289  _members.force_item(lmbr.type_id(), new trilinear_3d);
290 
291  lmbr.attach_to_state(lhost, "hex_nodes");
292  _members.force_item(lmbr.type_id(), new trilinear_3d);
293 
294  lmbr.attach_to_state(lhost, "hex_complex");
295  _members.force_item(lmbr.type_id(), new trilinear_3d);
296 
297  lmbr.attach_to_state(lhost, "structured_block_1d");
298  _members.force_item(lmbr.type_id(), new linear_1d);
299 
300  lmbr.attach_to_state(lhost, "structured_block_2d");
301  _members.force_item(lmbr.type_id(), new bilinear_2d);
302 
303  lmbr.attach_to_state(lhost, "structured_block_3d");
304  _members.force_item(lmbr.type_id(), new trilinear_3d);
305 
306  lmbr.attach_to_state(lhost, "tetra");
307  _members.force_item(lmbr.type_id(), new linear_3d);
308 
309  lmbr.attach_to_state(lhost, "tetra_nodes");
310  _members.force_item(lmbr.type_id(), new linear_3d);
311 
312  lmbr.attach_to_state(lhost, "tetra_complex");
313  _members.force_item(lmbr.type_id(), new linear_3d);
314 
315  lmbr.detach_from_state();
316  lhost->release_access();
317 
318  // Postconditions:
319 
320  ensure(invariant());
321  ensure(is_initialized());
322 
323  // Exit:
324 
325  return;
326 }
327 
329 bool
332 {
333  return true;
334 }
335 
337 bool
340 {
341  return true;
342 }
343 
344 
345 // ===========================================================
346 // PRIVATE MEMBERS
347 // ===========================================================
348 
350 fiber_bundle::dlinear_eval_family::
351 dlinear_eval_family()
352 {
353 
354  // Preconditions:
355 
356  // Body:
357 
358  // Nothing to do; base class does it all.
359 
360  // Postconditions:
361 
362  ensure(invariant());
363 
364  // Exit:
365 
366  return;
367 }
virtual dlinear_eval_family * clone() const
Virtual constructor; makes a new instance of the same type as this.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
virtual bool invariant() const
Class invariant.
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
members_type _members
The members of the family.
Definition: eval_family.h:221
A section evaluator with a constant value over a 1D domain.
void force_item(index_type xindex, const_reference_type xitem)
Puts the item xitem at index xindex, resizing if necessary; any other new storage allocated is uninit...
STL namespace.
virtual bool extrema_are_dofs() const
True if the extrema (minima or maxima) of the members of this family occur at the discretization poin...
A family of section evaluators containing uni-, bi-, and tri-linear evaluators.
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
bool is_initialized() const
True if this has been populated with members.
Definition: eval_family.cc:418
static const std::string & prototypes_poset_name()
The name of the prototypes poset.
A section evaluator using linear interpolation over a tetrahedral 3D domain.
Definition: linear_3d.h:38
virtual const std::string & class_name() const
The name of this family.
A client handle for a member of a base space poset.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual ~dlinear_eval_family()
Destructor.
A section evaluator using trilinear interpolation over a cubic 3D domain.
Definition: trilinear_3d.h:38
A client handle for a mutable partially ordered set.
Definition: poset.h:40
A family of compatible section evaluators, one for each member of some family of cell types; a map fr...
Definition: eval_family.h:67
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
virtual void initialize(const namespace_poset &xname_space)
Initializes this to contain members for name space xname_space.
static const std::string & static_class_name()
The name of this class of families.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
void initialize_members(size_type xmembers_ub)
Initialize storage for the members.
Definition: eval_family.cc:451
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
A section evaluator using linear interpolation over a triangular 2D domain.
Definition: linear_2d.h:39
virtual scoped_index member_index_ub() const
The upper bound on the member_index;.
virtual bool dofs_are_values() const
True if the dofs used by the members of this family are section values, that is, the evaluators are i...
A section evaluator using linear interpolation over a 1D domain.
Definition: linear_1d.h:37
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
virtual void get_read_access() const
Get read access to the state associated with this.
Namespace for the fiber_bundles component of the sheaf system.
A section evaluator using bilinear interpolation over a square 2D domain.
Definition: bilinear_2d.h:42
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
virtual bool invariant() const
Class invariant.
Definition: eval_family.cc:122
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
virtual void initialize(const namespace_poset &xname_space)=0
Initializes this to contain members for name space xname_space.
Definition: eval_family.cc:394