SheafSystem  0.0.0.0
uniform_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 uniform_eval_family
19 
20 
21 #include "SheafSystem/base_space_member.h"
22 #include "SheafSystem/factory.h"
23 #include "SheafSystem/fiber_bundles_namespace.h"
24 #include "SheafSystem/int_set.h"
25 #include "SheafSystem/namespace_poset.h"
26 #include "SheafSystem/sheaf.h"
27 #include "SheafSystem/assert_contract.h"
28 #include "SheafSystem/uniform_1d.h"
29 #include "SheafSystem/uniform_2d.h"
30 #include "SheafSystem/uniform_3d.h"
31 #include "SheafSystem/uniform_eval_family.h"
32 
33 using namespace std;
34 using namespace fiber_bundle; // Workaround for MS C++ bug.
35 
36 // PUBLIC MEMBER FUNCTIONS
37 
38 // CANONICAL MEMBERS
39 
40 
41 
43 fiber_bundle::uniform_eval_family::
44 uniform_eval_family(const uniform_eval_family& xother)
45  : eval_family(xother)
46 {
47 
48  // Preconditions:
49 
50  // Body:
51 
52  // Postconditions:
53 
54  ensure(invariant());
55 
56  // Exit:
57 }
58 
59 
60 
64 clone() const
65 {
66  uniform_eval_family* result;
67 
68  // Preconditions:
69 
70  // Body:
71 
72  result = new uniform_eval_family(*this);
73 
74  // Postconditions:
75 
76  ensure(result != 0);
77  ensure(is_same_type(result));
78 
79  // Exit:
80 
81  return result;
82 }
83 
84 
88 {
89 
90  // Preconditions:
91 
92  // Body:
93 
94  // Postconditions:
95 
96  // Exit:
97 
98  return;
99 }
100 
101 
103 bool
105 invariant() const
106 {
107  bool result = true;
108 
109  // Preconditions:
110 
111  // Body:
112 
113  // Must satisfy base class invariant
114 
115  result = result && eval_family::invariant();
116 
117  if(invariant_check())
118  {
119  // Prevent recursive calls to invariant
120 
122 
123  // Finished, turn invariant checking back on.
124 
126  }
127 
128  // Postconditions:
129 
130  // Exit
131 
132  return result;
133 }
134 
136 bool
138 is_ancestor_of(const any* xother) const
139 {
140 
141  // Preconditions:
142 
143  require(xother != 0);
144 
145  // Body:
146 
147  // True if other conforms to this
148 
149  bool result = dynamic_cast<const uniform_eval_family*>(xother) != 0;
150 
151  // Postconditions:
152 
153  return result;
154 
155 }
156 
157 
158 
159 // DLINEAR_FAMILY FACET
160 
161 
163 fiber_bundle::uniform_eval_family::
164 uniform_eval_family(const namespace_poset& xname_space)
165 {
166 
167  // Preconditions:
168 
169  require(xname_space.state_is_read_accessible());
171 
172  // Body:
173 
174  initialize(xname_space);
175 
176  // Postconditions:
177 
178  ensure(invariant());
179 }
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("uniform");
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  // Body:
235 
236  eval_family::initialize(xname_space);
237 
238  // The type codes used here must be the same as those used
239  // in fiber_bundles_namespace::make_base_space_member_prototypes().
240 
241  poset* lhost = &xname_space.member_poset<poset>(base_space_member::prototypes_poset_name(), false);
242  lhost->get_read_access();
243 
244  // Allocate enough storage for the members.
245 
247 
248  // Get the type id of each member of the family and
249  // and create the appropriate entry in _members.
250 
251  base_space_member lmbr;
252  lmbr.attach_to_state(lhost, "structured_block_1d");
253  _members.force_item(lmbr.type_id(), new uniform_1d);
254 
255  lmbr.attach_to_state(lhost, "structured_block_2d");
256  _members.force_item(lmbr.type_id(), new uniform_2d);
257 
258  lmbr.attach_to_state(lhost, "structured_block_3d");
259  _members.force_item(lmbr.type_id(), new uniform_3d);
260 
261  lmbr.detach_from_state();
262  lhost->release_access();
263 
264  // Postconditions:
265 
266  ensure(invariant());
267  ensure(is_initialized());
268 
269  // Exit:
270 
271  return;
272 }
273 
275 bool
278 {
279  return true;
280 }
281 
283 bool
286 {
287  return true;
288 }
289 
290 
291 // ===========================================================
292 // PRIVATE MEMBERS
293 // ===========================================================
294 
296 fiber_bundle::uniform_eval_family::
297 uniform_eval_family()
298  : eval_family()
299 {
300 
301  // Preconditions:
302 
303  // Body:
304 
305  // Nothing to do; base class does it all.
306 
307  // Postconditions:
308 
309  ensure(invariant());
310 
311  // Exit:
312 
313  return;
314 }
315 
virtual const std::string & class_name() const
The name of this family.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
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
virtual bool extrema_are_dofs() const
True if the extrema (minima or maxima) of the members of this family occur at the discretization poin...
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.
A section evaluator using trilinear interpolation over a cubic 3D domain. Intended for use with unifo...
Definition: uniform_3d.h:39
eval_family()
Default constructor.
Definition: eval_family.cc:429
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 client handle for a member of a base space poset.
static const std::string & static_class_name()
The name of this class of families.
Abstract base class with useful features for all objects.
Definition: any.h:39
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 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
A family of evaluators for uniform meshes.
virtual ~uniform_eval_family()
Destructor.
virtual bool invariant() const
Class invariant.
virtual void initialize(const namespace_poset &xname_space)
Initializes this to contain members for name space xname_space.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
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..
A section evaluator using bilinear interpolation over a square 2D domain. Intended for use with unifo...
Definition: uniform_2d.h:39
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 1D domain which is refined into a uniform mesh...
Definition: uniform_1d.h:39
virtual scoped_index member_index_ub() const
The upper bound on the member_index;.
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.
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
virtual uniform_eval_family * clone() const
Virtual constructor; makes a new instance of the same type as this.