SheafSystem  0.0.0.0
homogeneous_block_crg_interval.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/homogeneous_block_crg_interval.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/arg_list.h"
25 #include "SheafSystem/base_space_poset.h"
26 #include "SheafSystem/error_message.h"
27 #include "SheafSystem/offset_index_space_state.h"
28 #include "SheafSystem/index_space_iterator.h"
29 #include "SheafSystem/std_iomanip.h"
30 #include "SheafSystem/std_string.h"
31 #include "SheafSystem/std_sstream.h"
32 #include "SheafSystem/homogeneous_block.h"
33 
34 using namespace std;
35 using namespace fiber_bundle; // Workaround for MS C++ bug.
36 
37 
38 // ===========================================================
39 // HOMOGENEOUS_BLOCK_CRG_INTERVAL FACET
40 // ===========================================================
41 
42 // PUBLIC MEMBER FUNCTIONS
43 
46  : _zones_initialized(false),
47  _zones_space_id(invalid_pod_index()),
48  _vertices_initialized(false),
49  _vertices_space_id(invalid_pod_index()),
50  _connectivity_begin(invalid_pod_index()),
51  _adjacency_begin(invalid_pod_index())
52 {
53  // Body:
54 
55  // Initialize dof tuple ids.
56 
57  _dof_tuple_ids.reserve(MEMBER_CLASS_END);
58  _dof_tuple_ids.set_ct(MEMBER_CLASS_END);
60 
61  // Postconditions:
62 
63  ensure(invariant());
64  ensure(!is_initialized());
65 
66  return;
67 }
68 
71 {
72  // Preconditions:
73 
74  // Body:
75 
78  {
80  }
81 
84  {
86  }
87 
88  // Postconditions:
89 
90  // Exit:
91 
92  return;
93 }
94 
95 // PROTECTED MEMBER FUNCTIONS
96 
99 member_class(pod_index_type xmbr_index) const
100 {
101 
102  // Preconditions:
103 
104  require(contains_member(xmbr_index));
105 
106  // Body:
107 
108  member_class_type result;
109 
110  if(_id_spaces->contains_hub(_vertices_space_id, xmbr_index))
111  {
112  result = VERTEX;
113  }
114  else if(_id_spaces->contains_hub(_zones_space_id, xmbr_index))
115  {
116  result = ZONE;
117  }
118  else
119  {
120  result = BLOCK;
121  }
122 
123  // Postconditions:
124 
125  // Exit:
126 
127  return result;
128 }
129 
130 // PRIVATE MEMBER FUNCTIONS
131 
132 
133 // ===========================================================
134 // ZONES FACET
135 // ===========================================================
136 
137 // PUBLIC MEMBER FUNCTIONS
138 
139 bool
142 {
143  // Preconditions:
144 
145  // Body:
146 
147  bool result = _zones_initialized;
148 
149  // Postconditions:
150 
151  ensure(is_basic_query);
152 
153  // Exit:
154 
155  return result;
156 }
157 
161 {
162  // Preconditions:
163 
164  require(zones_initialized());
165 
166  // Body:
167 
169 
170  // Postconditions:
171 
172  ensure(is_basic_query);
173 
174  // Exit:
175 
176  return result;
177 }
178 
179 // PROTECTED MEMBER FUNCTIONS
180 
181 // PRIVATE MEMBER FUNCTIONS
182 
183 
184 // ===========================================================
185 // VERTICES FACET
186 // ===========================================================
187 
188 // PUBLIC MEMBER FUNCTIONS
189 
190 bool
193 {
194  // Preconditions:
195 
196  // Body:
197 
198  bool result = _vertices_initialized;
199 
200  // Postconditions:
201 
202  ensure(is_basic_query);
203 
204  // Exit:
205 
206  return result;
207 }
208 
212 {
213  // Preconditions:
214 
215  require(vertices_initialized());
216 
217  // Body:
218 
220 
221  // Postconditions:
222 
223  ensure(is_basic_query);
224 
225  // Exit:
226 
227  return result;
228 }
229 
230 // PROTECTED MEMBER FUNCTIONS
231 
232 // PRIVATE MEMBER FUNCTIONS
233 
234 
235 // ===========================================================
236 // CONNECTIVITY FACET
237 // ===========================================================
238 
239 // PUBLIC MEMBER FUNCTIONS
240 
244 {
245  // Preconditions:
246 
247  require(id_spaces().contains_hub(zones_space_id(), xzone_id));
248 
249  // Body:
250 
251  pod_index_type result =
253 
254  // Postconditions:
255 
256  ensure(is_basic_query);
257 
258  // Exit:
259 
260  return result;
261 }
262 
263 // PROTECTED MEMBER FUNCTIONS
264 
265 // PRIVATE MEMBER FUNCTIONS
266 
267 
268 // ===========================================================
269 // ADJACENCY FACET
270 // ===========================================================
271 
272 // PUBLIC MEMBER FUNCTIONS
273 
277 {
278  // Preconditions:
279 
280  require(id_spaces().contains_hub(vertices_space_id(), xvertex_id));
281 
282  // Body:
283 
284  pod_index_type result =
286 
287  // Postconditions:
288 
289  ensure(is_basic_query);
290 
291  // Exit:
292 
293  return result;
294 }
295 
296 // PROTECTED MEMBER FUNCTIONS
297 
298 // PRIVATE MEMBER FUNCTIONS
299 
300 
301 // ===========================================================
302 // BLOCK VERTICES FACET
303 // ===========================================================
304 
305 // PUBLIC MEMBER FUNCTIONS
306 
307 // PROTECTED MEMBER FUNCTIONS
308 
309 // PRIVATE MEMBER FUNCTIONS
310 
311 
312 // ===========================================================
313 // BASE_SPACE_CRG_INTERVAL FACET
314 // ===========================================================
315 
316 // PUBLIC MEMBER FUNCTIONS
317 
320 cells_begin() const
321 {
322  return implicit_begin();
323 }
324 
327 cells_end() const
328 {
329  return end();
330 }
331 
332 // PROTECTED MEMBER FUNCTIONS
333 
334 // PRIVATE MEMBER FUNCTIONS
335 
336 
337 // ===========================================================
338 // IMPLICIT_CRG_INTERVAL FACET
339 // ===========================================================
340 
341 // PUBLIC MEMBER FUNCTIONS
342 
343 // PROTECTED MEMBER FUNCTIONS
344 
345 // PRIVATE MEMBER FUNCTIONS
346 
347 
348 // ===========================================================
349 // CRG_INTERVAL FACET
350 // ===========================================================
351 
352 // PUBLIC MEMBER FUNCTIONS
353 
354 // PROTECTED MEMBER FUNCTIONS
355 
356 // PRIVATE MEMBER FUNCTIONS
357 
358 
359 // ===========================================================
360 // COVER SET FACET
361 // ===========================================================
362 
363 // PUBLIC MEMBER FUNCTIONS
364 
365 // PROTECTED MEMBER FUNCTIONS
366 
367 // PRIVATE MEMBER FUNCTIONS
368 
369 
370 // ===========================================================
371 // DOF TUPLE FACET
372 // ===========================================================
373 
374 // PUBLIC MEMBER FUNCTIONS
375 
376 bool
378 is_jim(pod_index_type xmbr_index) const
379 {
380  // Every member except the block itself is a jim.
381 
382  return !is_interval_member(xmbr_index);
383 }
384 
387 dof_tuple_id(pod_index_type xmbr_index) const
388 {
389  // Preconditions:
390 
391  require(contains_member(xmbr_index));
392 
393  // Body:
394 
395  // Map xmbr_index to the id space of this.
396 
397  pod_index_type result =
398  _dof_tuple_ids[member_class(xmbr_index)];
399 
400  // Postconditions:
401 
402  ensure(is_valid(result));
403 
404  // Exit:
405 
406  return result;
407 }
408 
412 {
413  return _dof_tuple_ids[BLOCK];
414 }
415 
419 {
420  return _dof_tuple_ids[ZONE];
421 }
422 
426 {
427  return _dof_tuple_ids[VERTEX];
428 }
429 
430 // PROTECTED MEMBER FUNCTIONS
431 
432 // PRIVATE MEMBER FUNCTIONS
433 
434 
435 // ===========================================================
436 // FACTORY FACET
437 // ===========================================================
438 
439 // PUBLIC MEMBER FUNCTIONS
440 
441 void
443 initialize(const namespace_poset& xnamespace)
444 {
445  // Preconditions:
446 
447  // Body:
448 
450 
451  _zones_initialized = true;
452  _vertices_initialized = true;
453 
454  // Postconditions:
455 
456  ensure(is_initialized());
457 
458  // Exit:
459 
460  return;
461 }
462 
463 bool
466 {
467  bool result =
471 
472  return result;
473 }
474 
475 const std::string&
477 class_name() const
478 {
479  static const string result("homogeneous_block_crg_interval");
480  return result;
481 }
482 
483 // PROTECTED MEMBER FUNCTIONS
484 
485 // PRIVATE MEMBER FUNCTIONS
486 
487 
488 // ===========================================================
489 // ANY FACET
490 // ===========================================================
491 
492 // PUBLIC MEMBER FUNCTIONS
493 
494 bool
496 is_ancestor_of(const any* other) const
497 {
498 
499  // Preconditions:
500 
501  require(other != 0);
502 
503  // Body:
504 
505  // True if other conforms to this
506 
507  bool result = dynamic_cast<const homogeneous_block_crg_interval*>(other) != 0;
508 
509  // Postconditions:
510 
511  return result;
512 }
513 
516 clone() const
517 {
518  // Preconditions:
519 
520  // Body:
521 
522  homogeneous_block_crg_interval* result = 0;
523 
524  is_abstract();
525 
526  // Postconditions:
527 
528  ensure(result != 0);
529  ensure(is_same_type(result));
530 
531  // Exit:
532 
533  return result;
534 }
535 
536 bool
538 invariant() const
539 {
540  bool result = true;
541 
542  if(invariant_check())
543  {
544  // Prevent recursive calls to invariant
545 
547 
548  // Must satisfy base class invariant
549 
551 
552  // Invariances for this class:
553 
554  // Finished, turn invariant checking back on.
555 
557  }
558 
559  // Exit
560 
561  return result;
562 }
563 
564 // PROTECTED MEMBER FUNCTIONS
565 
566 // PRIVATE MEMBER FUNCTIONS
567 
568 
569 // ===========================================================
570 // NON-MEMBER FUNCTIONS
571 // ===========================================================
572 
pod_index_type vertices_space_id() const
The index of the vertex id space.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
pod_type pod(const std::string &xname, pod_type xid) const
The pod index in the space with name xname equivalent to xid in the hub id space. ...
void initialize(const namespace_poset &xnamespace)
Sets is_initialized() == true; dummy routine provided to satisfy factory template.
index_space_family * _id_spaces
The id space family of this interval.
Definition: crg_interval.h:186
virtual bool invariant() const
Class invariant.
block< pod_index_type > _dof_tuple_ids
The ids of the dof tuples associated with this interval.
virtual pod_index_type cells_end() const
The end of the local cells interval.
The default name space; a poset which contains other posets as members.
pod_index_type zone_dof_tuple_id() const
Dof tuple id for zones.
pod_index_type block_dof_tuple_id() const
Dof tuple id for the block itself.
bool is_interval_member(pod_index_type xindex) const
True if xindex is the interval member.
STL namespace.
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
pod_index_type adjacency_space_id(pod_index_type xvertex_id) const
The index of the adjacency id space for vertex with id xvertex_id.
virtual homogeneous_block_crg_interval * clone() const
Virtual constructor, makes a new instance of the same type as this.
pod_index_type _vertices_space_id
The index of the vertex id space.
pod_index_type implicit_begin() const
The beginning of the implicit member interval (begin(), end()), excludes interval member; synonym for...
virtual bool is_initialized() const
True if fully initialized.
pod_index_type _connectivity_begin
The beginning offset of the connectivity id spaces in the id space family.
virtual bool is_initialized() const
True if fully initialized.
Abstract base class with useful features for all objects.
Definition: any.h:39
member_class_type member_class(pod_index_type xmbr_index) const
The member class of the member with index xmbr_index.
virtual pod_index_type dof_tuple_id(pod_index_type xmbr_index) const
The dof tuple id of the member with index xmbr_index.
Emulator for a interval of implicit base space members representing a homogeneous collection of cells...
pod_index_type end() const
The end of the member interval.
virtual bool is_jim(pod_index_type xmbr_index) const
True if and only if the member with index xmbr_index is join-irreducible.
void assign(const_reference_type xitem)
Sets the values of all items to xitem.
virtual pod_index_type cells_begin() const
The beginning of the local cells interval.
void set_ct(size_type xct)
Sets ct() == xct.
virtual const std::string & class_name() const
The name of this class; provided to satisfy factory template.
pod_index_type zones_space_id() const
The index of the zone id space.
pod_index_type connectivity_space_id(pod_index_type xzone_id) const
The index of the connectivity id space for zone with id xzone_id.
bool contains_member(pod_index_type xindex) const
True if and only if the index xindex is contained in this interval.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
const index_space_family & id_spaces() const
The id space family for this interval.
void delete_space(pod_type xid)
Delete the id space with index xid.
pod_index_type _adjacency_begin
The beginning offset of the adjacency id spaces in the id space family.
pod_index_type vertex_dof_tuple_id() const
Dof tuple id for vertices.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
pod_index_type _zones_space_id
The index of the zone id space.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
bool _vertices_initialized
True if the vertex id space has been initialized.
bool _zones_initialized
True if the zone id space has been initialized.
bool vertices_initialized() const
True if the vertex id space has been initialized.
void initialize(const namespace_poset &xnamespace)
Sets is_initialized() == true; dummy routine provided to satisfy factory template.
bool zones_initialized() const
True if the zone id space has been initialized.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
Namespace for the fiber_bundles component of the sheaf system.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Definition: pod_types.cc:31
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
bool contains_hub(const std::string &xname, pod_type xid) const
True if the space with name xname contains an id equivalent to xid in the unglued hub id space...