SheafSystem  0.0.0.0
barycentric_quad_refiner.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 #include "SheafSystem/barycentric_quad_refiner.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/error_message.h"
25 #include "SheafSystem/wsv_block.h"
26 
27 using namespace std;
28 using namespace fields; // Workaround for MS C++ bug.
29 
30 // #define DIAGNOSTIC_OUTPUT 1
31 
32 // ===========================================================
33 // BARYCENTRIC_QUAD_REFINER FACET
34 // ===========================================================
35 
36 // PUBLIC MEMBER FUNCTIONS
37 
41 {
42  // Preconditions:
43 
44  // Body:
45 
47 
48  // Postconditions:
49 
50  ensure(invariant());
51  ensure(&policy() == &xpolicy);
52 
53  return;
54 }
55 
56 
60 {
61  // Preconditions:
62 
63  // Body:
64 
65  not_implemented();
66 
67  // Postconditions:
68 
69  ensure(invariant());
70 
71  return;
72 }
73 
74 
75 // PROTECTED MEMBERS FUNCTIONS
76 
79 {
80  // Preconditions:
81 
82  // Body:
83 
84  not_implemented();
85 
86  // Postconditions:
87 
88  ensure(invariant());
89 
90  return;
91 }
92 
96 {
97 
98  // Preconditions:
99 
100 
101  // Body:
102 
103  static size_type result = 4;
104 
105  // Postconditions:
106 
107 
108  // Exit:
109 
110  return result;
111 }
112 
116 {
117  size_type result;
118 
119  // Preconditions:
120 
121 
122  // Body:
123 
124  result = REFINED_ZONE_CT;
125 
126  // Postconditions:
127 
128  ensure(result > 1);
129 
130  // Exit:
131 
132  return result;
133 }
134 
135 bool
138 {
139  bool result;
140 
141  // Preconditions:
142 
143 
144  // Body:
145 
146  result = true;
147 
148  // Postconditions:
149 
150 
151  // Exit:
152 
153  return result;
154 }
155 
159 {
160 
161  // Preconditions:
162 
163 
164  // Body:
165 
166  // The vertices of the barycentric subdivision are original vertices,
167  // the center of each edge, and the center of the zone:
168  //
169  // 6*******5*******4
170  // * + *
171  // * + *
172  // * + *
173  // 7+++++++C+++++++3
174  // * + *
175  // * + *
176  // * + *
177  // 0*******1*******2
178  //
179  // The edge centers are the first vertex of each refined zone,
180  // and the first entry is duplicated at the end
181 
182  static const wsv_block<size_type> result("1 3 5 7 1");
183 
184  // Postconditions:
185 
186  ensure(result.ct() > 1);
187 
188  // Exit:
189 
190  return result;
191 }
192 
193 
194 // ===========================================================
195 // LOCAL_FIELD_REFINER FACET
196 // ===========================================================
197 
198 // PUBLIC MEMBER FUNCTIONS
199 
200 const std::string&
203 {
204  // Preconditions:
205 
206 
207  // Body:
208 
209  static const string result("quad_nodes");
210 
211  // Postconditions:
212 
213  ensure(!result.empty());
214 
215  // Exit:
216 
217  return result;
218 }
219 
223 {
224  // Preconditions:
225 
226  require(xi < refined_zone_ct());
227 
228  // Body:
229 
230  // Affine transformation u'[i] = T[i][j]*u[j] + T[i][db];
231  // with sum convention over 0 <= j < db.
232 
233  // Specifically:
234  //
235  // u' = a*u +b*v + c;
236  // v' = d*u _e*v + f.
237  //
238  // map = {a, b, c, d, e, f}
239  // One such map for each refined zone.
240 
241  // 6 = db*(db+1)
242 
243  static const chart_point_coord_type lmap[REFINED_ZONE_CT][6] =
244  {
245  {
246  0.5, 0.0, 0.5, 0.0, 0.5, -0.5
247  },
248  { 0.0, -0.5, 0.5, 0.5, 0.0, 0.5 },
249  { -0.5, 0.0, -0.5, 0.0, -0.5, 0.5 },
250  { 0.0, 0.5, -0.5, -0.5, 0.0, -0.5 }
251  };
252 
253 
254  const chart_point_coord_type* result = lmap[xi];
255 
256  // Postconditions:
257 
258  // Exit:
259 
260  return result;
261 }
262 
263 
264 // ===========================================================
265 // ANY FACET
266 // ===========================================================
267 
268 // PUBLIC MEMBER FUNCTIONS
269 
272 clone() const
273 {
274  barycentric_quad_refiner* result;
275 
276  // Preconditions:
277 
278  // Body:
279 
280  result = new barycentric_quad_refiner();
281 
282  // Postconditions:
283 
284  ensure(result != 0);
285  // ensure(invariant());
286  ensure(result->invariant());
287  ensure(is_same_type(result));
288 
289  return result;
290 }
291 
295 {
296  // Preconditions:
297 
298  require(is_ancestor_of(&xother));
299 
300  // Body:
301 
302  not_implemented();
303 
304  // Postconditions:
305 
306  ensure(invariant());
307 
308  return *this;
309 }
310 
315 {
316 
317  // Preconditions:
318 
319  require(is_ancestor_of(&xother));
320 
321  // Body:
322 
323  not_implemented();
324 
325  // Postconditions:
326 
327  ensure(invariant());
328 
329  // Exit:
330 
331  return *this;
332 }
333 
336 {
337  // Preconditions:
338 
339  // Body:
340 
341  // Postconditions:
342 
343  ensure(invariant());
344 
345  return;
346 }
347 
348 bool
350 invariant() const
351 {
352  bool result = true;
353 
354  // Preconditions:
355 
356  // Body:
357 
358  // Must satisfy base class invariant.
359 
360  result = result && edge_centered_polygon_refiner::invariant();
361 
362  if(invariant_check())
363  {
364  // Prevent recursive calls to invariant.
365 
367 
368  // Finished, turn invariant checking back on.
369 
371  }
372 
373  // Postconditions:
374 
375  return result;
376 }
377 
378 bool
380 is_ancestor_of(const any* xother) const
381 {
382 
383  // Preconditions:
384 
385  require(xother != 0);
386 
387  // Body:
388 
389  // True if other conforms to this
390 
391  bool result = dynamic_cast<const barycentric_quad_refiner*>(xother) != 0;
392 
393  // Postconditions:
394 
395  return result;
396 
397 }
398 
399 
400 // PRIVATE MEMBERS
401 
402 //const sheaf::size_type
403 //fields::barycentric_quad_refiner::
404 //REFINED_ZONE_CT;
double chart_point_coord_type
The type of local coordinate in the base space; the scalar type for the local coordinate vector space...
Definition: fiber_bundle.h:57
size_type ct() const
The number of items currently in use.
Namespace for fields component of sheaf system.
An abstract field refiner that subdivides a polygon by introducing new vertices into the centers of t...
STL namespace.
A field refiner that subdivides a quad into 4 quads by introducing a new vertex in the center of the ...
virtual size_type unrefined_vertex_ct() const
The number of vertices with refinement depth <= unrefined zone depth.
virtual const std::string & zone_type_name() const
The name of the type of zone this creates during refinement.
const field_refinement_policy & policy() const
The refinement policy for this refiner.
virtual bool invariant() const
Class invariant.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual size_type refined_zone_ct() const
The number of refined zones created by this.
virtual const block< size_type > & first_vertex_index() const
The index in _vertex_pos of the first vertex of each new zone; contains number of zones + 1 because f...
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
const chart_point_coord_type * local_coordinates_map(size_type xi) const
The map from the local coordinates of refined zone xi t0 the local coordinates of the parent zone...
An abstract policy that determines the conditions under which a zone should be refined.
virtual barycentric_quad_refiner & operator=(const local_field_refiner &xother)
Assignment operator.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual barycentric_quad_refiner * clone() const
Virtual constructor, creates a new instance of the same type as this.
virtual bool is_zone_centered_refiner() const
True if this adds a vertex at the center of the zone.
void reserve_vertex_buffers()
Reserves space in vertex buffers.
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.
barycentric_quad_refiner()
Default constructor; disabled.
virtual bool invariant() const
Class invariant.
An auto_block with a no-initialization initialization policy.
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
Whitespace-separated-value block; A block of objects of type T that can be conveniently initialized b...
Definition: tuple.h:62