SheafSystem  0.0.0.0
zone_centered_refiner_family.cc
Go to the documentation of this file.
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 
20 
21 
22 #include "SheafSystem/zone_centered_refiner_family.h"
23 
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/base_space_member.h"
26 #include "SheafSystem/base_space_poset.h"
27 #include "SheafSystem/block.impl.h"
28 #include "SheafSystem/factory.impl.h"
29 #include "SheafSystem/fiber_bundles_namespace.h"
30 #include "SheafSystem/poset.h"
31 #include "SheafSystem/zone_centered_segment_refiner.h"
32 #include "SheafSystem/zone_centered_tet_refiner.h"
33 #include "SheafSystem/zone_centered_triangle_refiner.h"
34 
35 using namespace std;
36 using namespace fields; // Workaround for MS C++ bug.
37 
38 // ===========================================================
39 // ZONE_CENTERED_REFINER_FAMILY FACET
40 // ===========================================================
41 
42 // PUBLIC MEMBER FUNCTIONS
43 
44 fields::zone_centered_refiner_family::
45 zone_centered_refiner_family(const base_space_poset& xbase_space,
46  const field_refinement_policy& xpolicy)
47 {
48  // Preconditions:
49 
50  require(xbase_space.state_is_read_accessible());
51 
52  // Body:
53 
54  initialize(xbase_space, xpolicy);
55 
56  // Postconditions:
57 
58  ensure(invariant());
59  ensure(postcondition_of(initialize(xbase_space, xpolicy)));
60 
61  // Exit:
62 
63  return;
64 }
65 
66 fields::zone_centered_refiner_family::
67 zone_centered_refiner_family(const zone_centered_refiner_family& xother)
68  : field_refiner_family(xother)
69 {
70 
71  // Preconditions:
72 
73  // Body:
74 
75  // Nothing to do; base class does it all.
76 
77  // Postconditions:
78 
79  ensure(invariant());
80 
81  // Exit:
82 
83  return;
84 }
85 
86 
89 {
90 
91  // Preconditions:
92 
93  // Body:
94 
95  // Nothing to do; base class does it all.
96 
97  // Postconditions:
98 
99  // Exit:
100 
101  return;
102 }
103 
104 const std::string&
106 class_name() const
107 {
108  // Preconditions:
109 
110  // Body:
111 
112  const string& result = static_class_name();
113 
114  // Postconditions:
115 
116  ensure(!result.empty());
117 
118  // Exit:
119 
120  return result;
121 }
122 
123 const std::string&
126 {
127  // Preconditions:
128 
129  // Body:
130 
131  static const string result("zone_centered_refiner_family");
132 
133  // Postconditions:
134 
135  ensure(!result.empty());
136  ensure(result == "zone_centered_refiner_family");
137 
138  // Exit:
139 
140  return result;
141 }
142 
143 
144 // PRIVATE MEMBER FUNCTIONS
145 
146 fields::zone_centered_refiner_family::
147 zone_centered_refiner_family()
148 {
149 
150  // Preconditions:
151 
152  // Body:
153 
154  // Nothing to do; base class does it all.
155 
156  // Postconditions:
157 
158  ensure(invariant());
159 
160  // Exit:
161 
162  return;
163 }
164 
165 bool
166 fields::zone_centered_refiner_family::
167 _has_prototype = make_prototype();
168 
169 bool
170 fields::zone_centered_refiner_family::
171 make_prototype()
172 {
173  bool result = true;
174 
175  // Preconditions:
176 
177 
178  // Body:
179 
181 
182  family_factory().insert_prototype(lproto);
183 
184  // Postconditions:
185 
186 
187  // Exit:
188 
189  return result;
190 }
191 
192 
193 // ===========================================================
194 // FIELD_REFINER_FAMILY FACET
195 // ===========================================================
196 
197 // PUBLIC MEMBER FUNCTIONS
198 
199 void
201 initialize(const base_space_poset& xbase_space, const field_refinement_policy& xpolicy)
202 {
203  // Preconditions:
204 
205  require(!is_initialized());
206  require(xbase_space.state_is_read_accessible());
207 
208  // Body:
209 
210  // Initialize the base class data members.
211 
212  field_refiner_family::initialize(xbase_space, xpolicy);
213 
214  // Get the type id of each member of the family and
215  // and create the appropriate entry in _members.
216 
217  local_field_refiner* lref;
218 
219  // Cell type "segment".
220 
222  _members.force_item(xbase_space.prototype_type_id("segment"), lref);
223 
224  // Cell type "segment_complex".
225 
227  _members.force_item(xbase_space.prototype_type_id("segment_complex"), lref);
228 
229  // Cell type "triangle".
230 
232  _members.force_item(xbase_space.prototype_type_id("triangle"), lref);
233 
234  // Cell type "triangle_nodes".
235 
237  _members.force_item(xbase_space.prototype_type_id("triangle_nodes"), lref);
238 
241 
242  // // Cell type "quad"
243 
244  // lref = new zone_centered_quad_refiner(policy());
245  // _members.force_item(xbase_space.prototype_type_id("quad"), lref);
246 
247  // // Cell type "quad_nodes"
248 
249  // lref = new zone_centered_quad_refiner(policy());
250  // _members.force_item(xbase_space.prototype_type_id("quad_nodes"), lref);
251 
252  // // Cell type "hex".
253 
254  // lref = new zone_centered_hex_refiner(policy());
255  // _members.force_item(xbase_space.prototype_type_id("hex"), lref);
256 
257  // // Cell type "hex_nodes".
258 
259  // lref = new zone_centered_hex_refiner(policy());
260  // _members.force_item(xbase_space.prototype_type_id("hex_nodes"), lref);
261 
262  // Cell type "tetra".
263 
264  lref = new zone_centered_tet_refiner(policy());
265  _members.force_item(xbase_space.prototype_type_id("tetra"), lref);
266 
267  // Cell type "tetra_nodes".
268 
269  lref = new zone_centered_tet_refiner(policy());
270  _members.force_item(xbase_space.prototype_type_id("tetra_nodes"), lref);
271 
272  // Postconditions:
273 
274  ensure(invariant());
275  ensure(is_initialized());
276  ensure_for_all(i, 0, size(), (member(i) != 0) ? (&member(i)->policy() == &policy()) : true);
277 
278  // Exit:
279 
280  return;
281 }
282 
283 
284 // ===========================================================
285 // ANY FACET
286 // ===========================================================
287 
288 // PUBLIC MEMBER FUNCTIONS
289 
292 clone() const
293 {
295 
296  // Preconditions:
297 
298  // Body:
299 
300  result = new zone_centered_refiner_family(*this);
301 
302  // Postconditions:
303 
304  ensure(result != 0);
305  ensure(is_same_type(result));
306 
307  // Exit:
308 
309  return result;
310 }
311 
312 
313 bool
315 invariant() const
316 {
317  bool result = true;
318 
319  // Preconditions:
320 
321  // Body:
322 
323  // Must satisfy base class invariant
324 
325  result = result && field_refiner_family::invariant();
326 
327  if(invariant_check())
328  {
329  // Prevent recursive calls to invariant
330 
332 
333  // Finished, turn invariant checking back on.
334 
336  }
337 
338  // Postconditions:
339 
340  // Exit
341 
342  return result;
343 }
344 
345 bool
347 is_ancestor_of(const any* xother) const
348 {
349 
350  // Preconditions:
351 
352  require(xother != 0);
353 
354  // Body:
355 
356  // True if other conforms to this
357 
358  bool result = dynamic_cast<const zone_centered_refiner_family*>(xother) != 0;
359 
360  // Postconditions:
361 
362  return result;
363 
364 }
virtual bool invariant() const
Class invariant.
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
A field refiner that introduces a new vertex in the center of a triangle, but not in the edges...
static factory< field_refiner_family > & family_factory()
A factory for making field_refiner_family objects.
A family of compatible local_field_refiners, one for each member of some family of cell types; a map ...
virtual zone_centered_refiner_family * clone() const
Virtual constructor; makes a new instance of the same type as this.
A field refiner that introduces a new vertex in the center of a segment.
Namespace for fields component of sheaf system.
field_refinement_policy & policy() const
The refinement policy for this family.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
size_type size() const
The number of members of this family.
STL namespace.
bool is_initialized() const
True if this has been populated with members.
pod_index_type prototype_type_id(const std::string &xname, bool xauto_access=true) const
The type id of the base space member prototype with name xname.
Abstract base class with useful features for all objects.
Definition: any.h:39
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
virtual const std::string & class_name() const
The name of this family.
A family of field refiners that introduce a new vertex in the center of a zone, but not in the bounda...
local_field_refiner * member(pod_index_type xtype_id) const
The evaluator associated with cell type xtype_id. Note that the result may be void.
An abstract policy that determines the conditions under which a zone should be refined.
virtual void initialize(const base_space_poset &xbase_space, const field_refinement_policy &xpolicy)=0
Initializes this to contain members for base space xbase_space and using policy xpolicy.
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
block< local_field_refiner * > _members
The members of the family.
virtual void initialize(const base_space_poset &xbase_space, const field_refinement_policy &xpolicy)
Initializes this to contain members for base space xbase_space and using policy xpolicy.
An abstract refiner for a field over a local region (primitive cell) in the base space.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
virtual bool invariant() const
Class invariant.
A field refiner that subdivides a tet into 4 tets by introducing a new vertex in the center...
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