SheafSystem  0.0.0.0
edge_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/edge_centered_refiner_family.h"
23 
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/barycentric_quad_refiner.h"
26 #include "SheafSystem/barycentric_triangle_refiner.h"
27 #include "SheafSystem/base_space_member.h"
28 #include "SheafSystem/base_space_poset.h"
29 #include "SheafSystem/block.impl.h"
30 #include "SheafSystem/edge_centered_triangle_refiner.h"
31 #include "SheafSystem/factory.impl.h"
32 #include "SheafSystem/fiber_bundles_namespace.h"
33 #include "SheafSystem/poset.h"
34 #include "SheafSystem/zone_centered_segment_refiner.h"
35 
36 using namespace std;
37 using namespace fields; // Workaround for MS C++ bug.
38 
39 // ===========================================================
40 // EDGE_CENTERED_REFINER_FAMILY FACET
41 // ===========================================================
42 
43 // PUBLIC MEMBER FUNCTIONS
44 
45 fields::edge_centered_refiner_family::
46 edge_centered_refiner_family(const base_space_poset& xbase_space,
47  const field_refinement_policy& xpolicy)
48 {
49  // Preconditions:
50 
51  require(xbase_space.state_is_read_accessible());
52 
53  // Body:
54 
55  initialize(xbase_space, xpolicy);
56 
57  // Postconditions:
58 
59  ensure(invariant());
60  ensure(postcondition_of(initialize(xbase_space, xpolicy)));
61 
62  // Exit:
63 
64  return;
65 }
66 
67 fields::edge_centered_refiner_family::
68 edge_centered_refiner_family(const edge_centered_refiner_family& xother)
69  : field_refiner_family(xother)
70 {
71 
72  // Preconditions:
73 
74  // Body:
75 
76  // Nothing to do; base class does it all.
77 
78  // Postconditions:
79 
80  ensure(invariant());
81 
82  // Exit:
83 
84  return;
85 }
86 
87 
90 {
91 
92  // Preconditions:
93 
94  // Body:
95 
96  // Nothing to do; base class does it all.
97 
98  // Postconditions:
99 
100  // Exit:
101 
102  return;
103 }
104 
105 const std::string&
107 class_name() const
108 {
109  // Preconditions:
110 
111  // Body:
112 
113  const string& result = static_class_name();
114 
115  // Postconditions:
116 
117  ensure(!result.empty());
118 
119  // Exit:
120 
121  return result;
122 }
123 
124 const std::string&
127 {
128  // Preconditions:
129 
130  // Body:
131 
132  static const string result("edge_centered_refiner_family");
133 
134  // Postconditions:
135 
136  ensure(!result.empty());
137  ensure(result == "edge_centered_refiner_family");
138 
139  // Exit:
140 
141  return result;
142 }
143 
144 
145 // PRIVATE MEMBER FUNCTIONS
146 
147 fields::edge_centered_refiner_family::
148 edge_centered_refiner_family()
149 {
150 
151  // Preconditions:
152 
153  // Body:
154 
155  // Nothing to do; base class does it all.
156 
157  // Postconditions:
158 
159  ensure(invariant());
160 
161  // Exit:
162 
163  return;
164 }
165 
166 
167 bool
168 fields::edge_centered_refiner_family::
169 _has_prototype = make_prototype();
170 
171 bool
172 fields::edge_centered_refiner_family::
173 make_prototype()
174 {
175  bool result = true;
176 
177  // Preconditions:
178 
179 
180  // Body:
181 
183 
184  family_factory().insert_prototype(lproto);
185 
186  // Postconditions:
187 
188 
189  // Exit:
190 
191  return result;
192 }
193 
194 
195 // ===========================================================
196 // FIELD_REFINER_FAMILY FACET
197 // ===========================================================
198 
199 // PUBLIC MEMBER FUNCTIONS
200 
201 //
202 void
204 initialize(const base_space_poset& xbase_space, const field_refinement_policy& xpolicy)
205 {
206  // Preconditions:
207 
208  require(!is_initialized());
209  require(xbase_space.state_is_read_accessible());
210 
211  // Body:
212 
213  // Initialize the base class data members.
214 
215  field_refiner_family::initialize(xbase_space, xpolicy);
216 
217  // Get the type id of each member of the family and
218  // and create the appropriate entry in _members.
219 
220  local_field_refiner* lref;
221 
222  // Cell type "segment"; same as zone-centered.
223 
225  _members.force_item(xbase_space.prototype_type_id("segment"), lref);
226 
227  // Cell type "segment_complex"; same as zone-centered.
228 
230  _members.force_item(xbase_space.prototype_type_id("segment_complex"), lref);
231 
232  // Cell type "triangle".
233 
235  _members.force_item(xbase_space.prototype_type_id("triangle"), lref);
236 
237  // Cell type "triangle_nodes".
238 
240  _members.force_item(xbase_space.prototype_type_id("triangle_nodes"), lref);
241 
244 
245  // Cell type "quad"
246 
247  lref = new barycentric_quad_refiner(policy());
248  _members.force_item(xbase_space.prototype_type_id("quad"), lref);
249 
250  // Cell type "quad_nodes"
251 
252  lref = new barycentric_quad_refiner(policy());
253  _members.force_item(xbase_space.prototype_type_id("quad_nodes"), lref);
254 
255  // // Cell type "hex".
256 
257  // lref = new barycentric_hex_refiner(policy());
258  // _members.force_item(xbase_space.prototype_type_id("hex"), lref);
259 
260  // // Cell type "hex_nodes".
261 
262  // lref = new barycentric_hex_refiner(policy());
263  // _members.force_item(xbase_space.prototype_type_id("hex_nodes"), lref);
264 
265  // // Cell type "tetra".
266 
267  // lref = new barycentric_tet_refiner(policy());
268  // _members.force_item(xbase_space.prototype_type_id("tetra"), lref);
269 
270  // // Cell type "tetra_nodes".
271 
272  // lref = new barycentric_tet_refiner(policy());
273  // _members.force_item(xbase_space.prototype_type_id("tetra_nodes"), lref);
274 
275  // Postconditions:
276 
277  ensure(invariant());
278  ensure(is_initialized());
279  ensure_for_all(i, 0, size(), (member(i) != 0) ? (&member(i)->policy() == &policy()) : true);
280 
281  // Exit:
282 
283  return;
284 }
285 
286 
287 // ===========================================================
288 // ANY FACET
289 // ===========================================================
290 
291 // PUBLIC MEMBER FUNCTIONS
292 
295 clone() const
296 {
298 
299  // Preconditions:
300 
301  // Body:
302 
303  result = new edge_centered_refiner_family(*this);
304 
305  // Postconditions:
306 
307  ensure(result != 0);
308  ensure(is_same_type(result));
309 
310  // Exit:
311 
312  return result;
313 }
314 
315 
316 bool
318 invariant() const
319 {
320  bool result = true;
321 
322  // Preconditions:
323 
324  // Body:
325 
326  // Must satisfy base class invariant
327 
328  result = result && field_refiner_family::invariant();
329 
330  if(invariant_check())
331  {
332  // Prevent recursive calls to invariant
333 
335 
336  // Finished, turn invariant checking back on.
337 
339  }
340 
341  // Postconditions:
342 
343  // Exit
344 
345  return result;
346 }
347 
348 bool
350 is_ancestor_of(const any* xother) const
351 {
352 
353  // Preconditions:
354 
355  require(xother != 0);
356 
357  // Body:
358 
359  // True if other conforms to this
360 
361  bool result = dynamic_cast<const edge_centered_refiner_family*>(xother) != 0;
362 
363  // Postconditions:
364 
365  return result;
366 
367 }
368 
A field refiner that subdivides a triangle into 4 triangles by introducing a new vertex in the center...
virtual edge_centered_refiner_family * clone() const
Virtual constructor; makes a new instance of the same type as this.
static const std::string & static_class_name()
The name of this class of families.
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 const std::string & class_name() const
The name of this family.
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.
virtual bool invariant() const
Class invariant.
A field refiner that subdivides a quad into 4 quads by introducing a new vertex in the center of the ...
bool is_initialized() const
True if this has been populated with members.
A family of field refiners that introduce a new vertex in each edge, but avoid introducing new vertic...
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...
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.
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.
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 is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
virtual bool invariant() const
Class invariant.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
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.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87