SheafSystem  0.0.0.0
sec_at0_space.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/sec_at0_space.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/binary_section_space_schema_member.impl.h"
26 #include "SheafSystem/binary_section_space_schema_poset.h"
27 #include "SheafSystem/fiber_bundles_namespace.h"
28 #include "SheafSystem/namespace_poset.impl.h"
29 #include "SheafSystem/namespace_poset_member.h"
30 #include "SheafSystem/poset_handle_factory.h"
31 #include "SheafSystem/sec_at0.h"
32 #include "SheafSystem/sec_at1.h"
33 #include "SheafSystem/sec_tuple_space.impl.h"
34 #include "SheafSystem/section_space_schema_member.impl.h"
35 #include "SheafSystem/section_space_schema_poset.h"
36 #include "SheafSystem/at0.h"
37 #include "SheafSystem/at0_space.h"
38 
39 
40 using namespace std;
41 using namespace fiber_bundle; // Workaround for MS C++ bug.
42 
43 //#define DIAGNOSTIC_OUTPUT
44 
45 //==============================================================================
46 // SEC_AT0_SPACE FACET
47 //==============================================================================
48 
49 // PUBLIC MEMBER FUNCTIONS
50 
54  const poset_path& xpath,
55  const poset_path& xschema_path,
56  bool xauto_access)
57 {
58  // cout << endl << "Entering sec_at0_space::new_table." << endl;
59 
60  // Preconditions:
61 
62 
63  require(!xpath.empty());
64  require(!xns.contains_path(xpath, xauto_access));
65 
66  require(xschema_path.full());
67  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
68  require(fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
69 
70  // Body:
71 
72  // Create the table; have to new it because namespace keeps a pointer.
73 
74  typedef sec_at0_space table_type;
75 
76  table_type& result = *(new table_type());
77 
78  // Create a handle of the right type for the schema member.
79 
80  schema_type lschema(xns, xschema_path, xauto_access);
81 
82  if(xauto_access)
83  {
84  lschema.get_read_access();
85  }
86 
87  // Create the table dof map.
88 
89  array_poset_dof_map& lmap = *(new array_poset_dof_map(&lschema, true));
90 
91  // The table dofs are mostly the same as the fiber schema,
92  // so just copy them from the fiber schema.
93  // Can't use copy constructor because schema objects are different.
94 
95  array_poset_dof_map& lfiber_map = lschema.fiber_space().table_dof_map();
96  lmap.copy_dof_tuple(lfiber_map);
97 
98  // Replace the fiber scalar space path with the section scalar space path.
99  // sec_at0 is its own scalar section space.
100 
101  lmap.put_dof("scalar_space_path", xpath);
102 
103  // Replace the fiber vector space path with the section vector space path.
104  // sec_at0 is its own vector section space.
105 
106  lmap.put_dof("vector_space_path", xpath);
107 
108  // Create the state.
109 
110  result.new_state(xns, xpath, lschema, lmap);
111 
112  if(xauto_access)
113  {
114  lschema.release_access();
115  }
116 
117  // Postconditions:
118 
119  ensure(xns.owns(result, xauto_access));
120  ensure(result.path(true) == xpath);
121  ensure(result.state_is_not_read_accessible());
122  ensure(result.schema(true).path(xauto_access) == xschema_path);
123 
124  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
125  ensure(result.factor_ct(true) == 1);
126  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
127  ensure(result.d(true) == 1);
128  ensure(result.scalar_space_path(true) == xpath);
129  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
130  ensure(result.p(true) == 0);
131  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
132  ensure(result.dd(true) == 1);
133  ensure(result.vector_space_path(true) == xpath);
134 
135  // Exit:
136 
137  // cout << "Leaving sec_at0_space::new_table." << endl;
138  return result;
139 }
140 
141 // PROTECTED MEMBER FUNCTIONS
142 
145  : sec_atp_space(new sec_at0, new sec_at0)
146 {
147  // Preconditions:
148 
149  // Body:
150 
151  // Nothing to do, handled by base class
152 
153  // Postconditions:
154 
155  ensure(postcondition_of(sec_atp_space::sec_atp_space()));
156 }
157 
160 {
161  // Preconditions:
162 
163  // Body:
164 
165  // Postconditions:
166 
167  // Exit
168 
169  return;
170 }
171 
173 sec_at0_space(sec_at0* xtop, sec_at0* xbottom)
174  : sec_atp_space(xtop, xbottom)
175 {
176  // Preconditions:
177 
178  require(xtop != 0);
179  require(xbottom != 0);
180 
181  // Body:
182 
183  // Nothing to do.
184 
185  // Postconditions:
186 
187  ensure(postcondition_of(poset_state_handle::poset_state_handle(xtop, xbottom)));
188 
189  // Exit:
190 
191  return;
192 }
193 
194 // PRIVATE MEMBER FUNCTIONS
195 
196 
197 // ===========================================================
198 // SEC_ATP_SPACE FACET
199 // ===========================================================
200 
201 // PUBLIC MEMBER FUNCTIONS
202 
203 // PROTECTED MEMBER FUNCTIONS
204 
205 // PRIVATE MEMBER FUNCTIONS
206 
207 
208 // ===========================================================
209 // SEC_TP_SPACE FACET
210 // ===========================================================
211 
212 // PUBLIC MEMBER FUNCTIONS
213 
214 // PROTECTED MEMBER FUNCTIONS
215 
216 // PRIVATE MEMBER FUNCTIONS
217 
218 
219 // ===========================================================
220 // SEC_VD_SPACE FACET
221 // ===========================================================
222 
223 // PUBLIC MEMBER FUNCTIONS
224 
225 bool
227 is_vector(pod_index_type xmbr_id, bool xauto_access) const
228 {
229 
235 
236  bool result = true;
237 
238  // Postconditions:
239 
240  ensure(result);
241 
242  // Exit:
243 
244  return result;
245 }
246 
247 void
249 put_is_vector(pod_index_type xmbr_id, bool xauto_access)
250 {
251  // Preconditions:
252 
253  // Body:
254 
255  // Do nothing.
256 
257  // Postconditions:
258 
259  ensure(is_vector(xmbr_id, xauto_access));
260 
261  // Exit:
262 
263  return;
264 }
265 
266 bool
268 is_covector(pod_index_type xmbr_id, bool xauto_access) const
269 {
270  // Preconditions:
271 
272  // Body:
273 
274  bool result = true;
275 
276  // Postconditions:
277 
278  ensure(result);
279 
280  // Exit:
281 
282  return result;
283 }
284 
285 void
287 put_is_covector(pod_index_type xmbr_id, bool xauto_access)
288 {
289  // Preconditions:
290 
291  // Body:
292 
293  // Do nothing.
294 
295  // Postconditions:
296 
297  ensure(is_covector(xmbr_id, xauto_access));
298 
299  // Exit:
300 
301  return;
302 }
303 
304 // PROTECTED MEMBER FUNCTIONS
305 
309 {
310  return 0;
311 }
312 
313 // PRIVATE MEMBER FUNCTIONS
314 
315 
316 // ===========================================================
317 // SEC_TUPLE_SPACE FACET
318 // ===========================================================
319 
320 // PUBLIC MEMBER FUNCTIONS
321 
322 // PROTECTED MEMBER FUNCTIONS
323 
324 // PRIVATE MEMBER FUNCTIONS
325 
326 
327 // ===========================================================
328 // SEC_REP_SPACE FACET
329 // ===========================================================
330 
331 // PUBLIC MEMBER FUNCTIONS
332 
333 // PROTECTED MEMBER FUNCTIONS
334 
335 // PRIVATE MEMBER FUNCTIONS
336 
337 bool
338 fiber_bundle::sec_at0_space::
339 make_prototype()
340 {
341  bool result = false;
342 
343  // Preconditions:
344 
345  // Body:
346 
347  sec_at0_space* lproto = new sec_at0_space;
348  poset_type ltype = lproto->type_id();
349 
350  factory().insert_prototype(lproto);
351  factory().insert_prototype(ltype, lproto);
352 
353  // Postconditions:
354 
355  // Exit:
356 
357  return result;
358 }
359 
360 
361 //==============================================================================
362 // POSET_STATE_HANDLE FACET
363 //==============================================================================
364 
365 // PUBLIC MEMBER FUNCTIONS
366 
369 type_id() const
370 {
371  return SEC_AT0_SPACE_ID;
372 }
373 
376 
377 const char*
379 class_name() const
380 {
381  // Preconditions:
382 
383  // Body:
384 
385  static const char* result = "sec_at0_space";
386 
387  // Postconditions:
388 
389  // Exit:
390 
391  return result;
392 }
393 
396 prereq_id(int xi) const
397 {
398  // Preconditions:
399 
400  require(state_is_read_accessible());
401  require(name_space()->state_is_read_accessible());
402 
403  // Body:
404 
405  pod_index_type result;
406 
407  switch(xi)
408  {
409  case 0:
410 
411  // The first prerequisite is always the schema.
412 
413  result = schema().host()->index().pod();
414  break;
415 
416  default:
417 
418  // No other prerequisites.
419 
420  result = invalid_pod_index();
421  break;
422  }
423 
424  // Postconditions:
425 
426  // Exit:
427 
428  return result;
429 }
430 
431 // PROTECTED MEMBER FUNCTIONS
432 
433 // PRIVATE MEMBER FUNCTIONS
434 
435 
436 //==============================================================================
437 // READ_WRITE_MONITOR_HANDLE FACET
438 //==============================================================================
439 
440 // PUBLIC MEMBER FUNCTIONS
441 
442 // PROTECTED MEMBER FUNCTIONS
443 
444 // PRIVATE MEMBER FUNCTIONS
445 
446 
447 //==============================================================================
448 // ANY FACET
449 //==============================================================================
450 
451 // PUBLIC MEMBER FUNCTIONS
452 
453 bool
455 is_ancestor_of(const any* xother) const
456 {
457  bool result;
458 
459  // Preconditions:
460 
461  // Body:
462 
463  result = dynamic_cast<const sec_at0_space*>(xother) != 0;
464 
465  // Postconditions:
466 
467  // Exit
468 
469  return result;
470 }
471 
474 clone() const
475 {
476  sec_at0_space* result;
477 
478  // Preconditions:
479 
480  // Body:
481 
482  result = new sec_at0_space;
483 
484  // Postconditions:
485 
486  ensure(result != 0);
487  ensure(is_same_type(result));
488  ensure(!result->is_attached());
489 
490  // Exit
491 
492  return result;
493 }
494 
495 bool
497 invariant() const
498 {
499  bool result = true;
500 
501 
502  if(invariant_check())
503  {
505 
506  invariance(sec_atp_space::invariant());
507 
508  invariance(state_is_read_accessible() ? dd() == d() : true);
509  invariance(state_is_read_accessible() ? vector_space_path().poset_name() == name() : true);
510  invariance(state_is_read_accessible() ? p() == 0 : true);
511  invariance(state_is_read_accessible() ? scalar_space_path().poset_name() == name() : true);
512  invariance(state_is_read_accessible() ? d() == 1 : true);
513  invariance(state_is_read_accessible() ? factor_ct() == d() : true);
514 
516  }
517 
518  return result;
519 }
520 
521 // PROTECTED MEMBER FUNCTIONS
522 
523 // PRIVATE MEMBER FUNCTIONS
524 
525 
526 
void insert_prototype(const poset_state_handle *xprototype)
Sets xprototype as the prototype for its client class.
section_space_schema_poset * host() const
The poset which this is a handle to a component of.
A client handle for a poset member which has been prepared for use as a schema for a section space...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
virtual poset_type type_id() const
Identifier for the type of this poset.
const scoped_index & index() const
The member index of this poset within the namespace host()
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
bool path_is_auto_read_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read accessible.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
virtual pod_index_type prereq_id(int xi) const
The id of the xi-th prerequisite poset for this.
poset_type
Identifiers for poset types.
Definition: poset_type.h:41
virtual void put_is_covector(pod_index_type xmbr_id, bool xauto_access)
Sets is_covector true for the member with id xmbr_id.
virtual bool is_covector(pod_index_type xmbr_id, bool xauto_access) const
True if and only if the member with id xmbr_id is a covector.
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
poset_path vector_space_path() const
The path of the underlying vector space.
STL namespace.
virtual bool is_ancestor_of(const any *xother) const
True if other conforms to this.
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
virtual void get_read_access() const
Get read access to the state associated with this.
sec_at0_space()
Default constructor; creates a new sec_at0_space handle not attached to any state.
void copy_dof_tuple(const poset_dof_map &xother)
Copies the dof tuple of xother into this.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
sec_atp_space()
Default constructor; creates a new sec_atp_space handle not attached to any state.
Abstract base class with useful features for all objects.
Definition: any.h:39
int p() const
The tensor degree of this space.
A space of scalars viewed as an antisymmetric tensor section space of degree 0.
Definition: sec_at0_space.h:48
virtual const char * class_name() const
The name of this class.
An abstract antisymmetric tensor section space of degree p.
Definition: sec_atp_space.h:47
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
A space of scalars viewed as an antisymmetric tensor space of degree 0.
Definition: at0_space.h:42
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual size_type covariant_subposet_ct() const
The number of covariant subposets.
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
virtual bool is_vector(pod_index_type xmbr_id, bool xauto_access) const
True if and only if the member with id xmbr_id is a vector (as opposed to a covector).
virtual bool invariant() const
Class invariant.
virtual ~sec_at0_space()
Destructor.
int dd() const
The dimension of the underlying ("domain") vector space.
static sec_at0_space & new_table(namespace_type &xhost, const poset_path &xpath, const poset_path &xschema_path, bool xauto_access)
Creates a new sec_at0_space in namespace xns with path xpath and schema specified by xschema_path...
virtual std::string name() const
The name of this poset.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
poset_state_handle()
Default constructor.
static poset_handle_factory & factory()
The poset handle factory.
namespace_poset * name_space() const
The namespace this poset resides in.
virtual bool is_attached() const
True if this is attached to a state.
int factor_ct() const
The number of factors in this product.
virtual void put_dof(pod_index_type xdof_id, const void *xdof, size_type xdof_size)
Sets the dof referred to by xdof_id to the value at xdof.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
virtual bool invariant() const
Class invariant.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
poset_path scalar_space_path() const
The path of the underlying space of scalars.
poset & fiber_space()
The fiber space for section spaces on this schema (mutable version).
int d() const
The dimension.
virtual sec_at0_space * clone() const
Virtual constructor; creates a new handle of the same actual type as this, attached to the same state...
virtual void put_is_vector(pod_index_type xmbr_id, bool xauto_access)
Sets is_vector true for the member with id xmbr_id.
An array representation of abstract class poset_dof_map.
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
Antisymetric tensor of degree 0. As the degree is 0 there is nothing to be symmetric or antisymmetric...
Definition: sec_at0.h:51
virtual array_poset_dof_map & table_dof_map(bool xrequire_write_access=false)
The map from table dof client_ids to table dof values for this poset (mutable version) ...