SheafSystem  0.0.0.0
barycentric_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/barycentric_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 // BARYCENTRIC_REFINER_FAMILY FACET
41 // ===========================================================
42 
43 // PUBLIC MEMBER FUNCTIONS
44 
45 fields::barycentric_refiner_family::
46 barycentric_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::barycentric_refiner_family::
68 barycentric_refiner_family(const barycentric_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 
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("barycentric_refiner_family");
132 
133  // Postconditions:
134 
135  ensure(!result.empty());
136  ensure(result == "barycentric_refiner_family");
137 
138  // Exit:
139 
140  return result;
141 }
142 
143 
144 // PRIVATE MEMBER FUNCTIONS
145 
146 fields::barycentric_refiner_family::
147 barycentric_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::barycentric_refiner_family::
167 _has_prototype = make_prototype();
168 
169 bool
170 fields::barycentric_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"; same as zone-centered.
220 
222  _members.force_item(xbase_space.prototype_type_id("segment"), lref);
223 
224  // Cell type "segment_complex"; same as zone-centered.
225 
227  _members.force_item(xbase_space.prototype_type_id("segment_complex"), lref);
228 
229  // Cell type "triangle".
230 
231  lref = new barycentric_triangle_refiner(policy());
232  _members.force_item(xbase_space.prototype_type_id("triangle"), lref);
233 
234  // Cell type "triangle_nodes".
235 
236  lref = new barycentric_triangle_refiner(policy());
237  _members.force_item(xbase_space.prototype_type_id("triangle_nodes"), lref);
238 
239  // // Cell type "quad"
240 
241  lref = new barycentric_quad_refiner(policy());
242  _members.force_item(xbase_space.prototype_type_id("quad"), lref);
243 
244  // Cell type "quad_nodes"
245 
246  lref = new barycentric_quad_refiner(policy());
247  _members.force_item(xbase_space.prototype_type_id("quad_nodes"), lref);
248 
251 
252  // // Cell type "hex".
253 
254  // lref = new barycentric_hex_refiner(policy());
255  // _members.force_item(xbase_space.prototype_type_id("hex"), lref);
256 
257  // // Cell type "hex_nodes".
258 
259  // lref = new barycentric_hex_refiner(policy());
260  // _members.force_item(xbase_space.prototype_type_id("hex_nodes"), lref);
261 
262  // // Cell type "tetra".
263 
264  // lref = new barycentric_tet_refiner(policy());
265  // _members.force_item(xbase_space.prototype_type_id("tetra"), lref);
266 
267  // // Cell type "tetra_nodes".
268 
269  // lref = new barycentric_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 barycentric_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 bool
314 invariant() const
315 {
316  bool result = true;
317 
318  // Preconditions:
319 
320  // Body:
321 
322  // Must satisfy base class invariant
323 
324  result = result && field_refiner_family::invariant();
325 
326  if(invariant_check())
327  {
328  // Prevent recursive calls to invariant
329 
331 
332  // Finished, turn invariant checking back on.
333 
335  }
336 
337  // Postconditions:
338 
339  // Exit
340 
341  return result;
342 }
343 
344 bool
346 is_ancestor_of(const any* xother) const
347 {
348 
349  // Preconditions:
350 
351  require(xother != 0);
352 
353  // Body:
354 
355  // True if other conforms to this
356 
357  bool result = dynamic_cast<const barycentric_refiner_family*>(xother) != 0;
358 
359  // Postconditions:
360 
361  return result;
362 
363 }
364 
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 ...
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.
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.
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
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 barycentric_refiner_family * clone() const
Virtual constructor; makes a new instance of the same type as this.
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.
virtual bool invariant() const
Class invariant.
An abstract policy that determines the conditions under which a zone should be refined.
static const std::string & static_class_name()
The name of this class of families.
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 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.
A field refiner that subdivides a triangle into 6 triangles by introducing a new vertex in the center...
virtual bool invariant() const
Class invariant.
A family of field refiners that introduce a new vertex in in the barycenter of each cell (zone...
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
virtual const std::string & class_name() const
The name of this family.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87