SheafSystem  0.0.0.0
field_met_e3.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 
24 
25 #include "SheafSystem/field_met_e3.h"
26 
27 #include "SheafSystem/assert_contract.h"
28 #include "SheafSystem/base_space_member.h"
29 #include "SheafSystem/sec_ed_invertible.h"
30 #include "SheafSystem/sec_met_e3.h"
31 
32 using namespace std;
33 using namespace fields; // Workaround for MS C++ bug.
34 
35 //=============================================================================
36 // FIELD_VD FACET OF CLASS FIELD_MET_E3
37 //=============================================================================
38 
43 {
44  // Preconditions:
45 
46  // Body:
47 
48  // Postconditions:
49 
50  ensure(invariant());
51  ensure(!is_attached());
52 
53  // Exit:
54 
55  return;
56 }
57 
60 field_met_e3(const field_met_e3& xother, bool xauto_access)
62 {
63  // Preconditions:
64 
65  require(xauto_access || !xother.is_attached() || \
66  xother.state_is_read_accessible());
67 
68  // Body:
69 
70  _coordinates->attach_to_state(xother._coordinates, xauto_access);
71  _property->attach_to_state(xother._property, xauto_access);
72  _base_space->attach_to_state(xother._base_space, xauto_access);
73 
74  // Postconditions:
75 
76  ensure(invariant());
77  ensure(coordinates().is_same_state(&xother.coordinates()));
78  ensure(property().is_same_state(&xother.property()));
79  ensure(base_space().is_same_state(&xother.base_space()));
80 
81  // Exit:
82 
83  return;
84 }
85 
88 field_met_e3(const sec_ed& xcoordinates, const sec_met_e3& xproperty, bool xauto_access)
90 {
91  // Preconditions:
92 
93  require(xcoordinates.is_attached());
94  require(xproperty.is_attached());
95  require(xauto_access || xcoordinates.state_is_read_accessible());
96  require(xauto_access || xproperty.state_is_read_accessible());
97 
98  // Body:
99 
100  if(xauto_access)
101  {
102  xcoordinates.get_read_access();
103  xproperty.get_read_access();
104  }
105 
106  _coordinates->attach_to_state(&xcoordinates);
107  _property->attach_to_state(&xproperty);
108  _base_space->attach_to_state(&(xproperty.schema().base_space()));
109 
110  if(xauto_access)
111  {
112  xcoordinates.release_access();
113  xproperty.release_access();
114  }
115 
116  // Postconditions:
117 
118  ensure(invariant());
119  ensure(coordinates().is_same_state(&xcoordinates));
120  ensure(property().is_same_state(&xproperty));
121 
122  // Exit:
123 
124  return;
125 }
126 
130  const poset_path& xcoordinates_path,
131  const poset_path& xproperty_path,
132  bool xauto_access)
134 {
135  // Preconditions:
136 
137  require(xauto_access || xns.state_is_read_accessible());
138  require(xns.contains_poset_member(xcoordinates_path));
139  require(xauto_access ||
140  xns.member_poset(xcoordinates_path).state_is_read_accessible());
141  require(xns.contains_poset_member(xproperty_path));
142  require(xauto_access ||
143  xns.member_poset(xproperty_path).state_is_read_accessible());
144 
145  // Body:
146 
147  if(xauto_access)
148  {
149  xns.get_read_access();
150  }
151 
152  _coordinates->attach_to_state(&xns, xcoordinates_path, xauto_access);
153  _property->attach_to_state(&xns, xproperty_path, xauto_access);
154 
155  if(xauto_access)
156  {
159  }
160 
162 
163  if(xauto_access)
164  {
165  xns.release_access();
168  }
169 
170  // Postconditions:
171 
172  ensure(invariant());
173  ensure(coordinates().path(true) == xcoordinates_path);
174  ensure(property().path(true) == xproperty_path);
175 
176  // Exit:
177 
178  return;
179 }
180 
184  sec_ed_invertible* xcoordinates,
185  base_space_member* xbase_space)
186  : field_met_ed(xproperty, xcoordinates, xbase_space)
187 {
188  // Preconditions:
189 
190  // Body:
191 
192  // Postconditions:
193 
194  // Exit:
195 
196 }
197 
201 operator=(const field_vd& xother)
202 {
203  // Preconditions:
204 
205  require(precondition_of(field_vd::operator=(xother)));
206 
207  // Body:
208 
209  field_vd::operator=(xother);
210 
211  // Postconditions:
212 
213  ensure(postcondition_of(field_vd::operator=(xother)));
214 
215  // Exit:
216 
217  return *this;
218 }
219 
223 operator=(const field_met_e3& xother)
224 {
225  // Preconditions:
226 
227  require(precondition_of(field_vd::operator=(xother)));
228 
229  // Body:
230 
231  field_vd::operator=(xother);
232 
233  // Postconditions:
234 
235  ensure(postcondition_of(field_vd::operator=(xother)));
236 
237  // Exit:
238 
239  return *this;
240 }
241 
245 operator=(const sec_met_e3& xsection)
246 {
247  // Preconditions:
248 
249  require(precondition_of(field_vd::operator=(xsection)));
250 
251  // Body:
252 
253  field_vd::operator=(xsection);
254 
255  // Postconditions:
256 
257  ensure(postcondition_of(field_vd::operator=(xsection)));
258 
259  // Exit
260 
261  return *this;
262 
263 }
264 
268 operator=(const met_e3& xfiber)
269 {
270  // Preconditions:
271 
272  require(precondition_of(field_vd::operator=(xfiber)));
273 
274  // Body:
275 
276  field_vd::operator=(xfiber);
277 
278  // Postconditions:
279 
280  ensure(postcondition_of(field_vd::operator=(xfiber)));
281 
282  // Exit
283 
284  return *this;
285 
286 }
287 
291 operator=(const met_e3_lite& xfiber)
292 {
293  // Preconditions:
294 
295  require(precondition_of(field_vd::operator=(xfiber)));
296 
297  // Body:
298 
299  field_vd::operator=(xfiber);
300 
301  // Postconditions:
302 
303  ensure(postcondition_of(field_vd::operator=(xfiber)));
304 
305  // Exit
306 
307  return *this;
308 
309 }
310 
314 {
315  // Preconditions:
316 
317  // Body:
318 
319  // Postconditions:
320 
321  // Exit:
322 
323  return;
324 }
325 
329 property() const
330 {
331  // Preconditions:
332 
333  // Body:
334 
335  sec_met_e3& result = dynamic_cast<sec_met_e3&>(*_property);
336 
337  // Postconditions:
338 
339  // Exit:
340 
341  return result;
342 }
343 
344 
346 bool
348 same_property_fiber_schema(const field_met_e3& xother, bool xauto_access) const
349 {
350  bool result;
351 
352  // Preconditions:
353 
354  require(xauto_access || state_is_read_accessible());
355 
356  // Body:
357 
358  if(xauto_access)
359  {
360  get_read_access();
361  xother.get_read_access();
362  }
363 
364  result = property().schema().fiber_schema().
365  is_same_state(&xother.property().schema().fiber_schema());
366 
367  if(xauto_access)
368  {
369  release_access();
370  xother.release_access();
371  }
372 
373  // Postconditions:
374 
375  // Exit:
376 
377  return result;
378 }
379 
380 //=============================================================================
381 // ANY FACET OF CLASS FIELD_MET_E3
382 //=============================================================================
383 
385 const std::string&
387 class_name() const
388 {
389  // Preconditions:
390 
391  // Body:
392 
393  const string& result = static_class_name();
394 
395  // Postconditions:
396 
397  ensure(!result.empty());
398 
399  // Exit:
400 
401  return result;
402 }
403 
405 const std::string&
408 {
409  // Preconditions:
410 
411  // Body:
412 
413  static const string result("field_met_e3");
414 
415  // Postconditions:
416 
417  ensure(!result.empty());
418 
419  // Exit:
420 
421  return result;
422 }
423 
425 bool
427 is_ancestor_of(const any* xother) const
428 {
429 
430  // Preconditions:
431 
432  require(xother != 0);
433 
434  // Body:
435 
436  // True if xother conforms to this.
437 
438  bool result = dynamic_cast<const field_met_e3*>(xother) != 0;
439 
440  // Postconditions:
441 
442  return result;
443 }
444 
448 clone() const
449 {
450  field_met_e3* result;
451 
452  // Preconditions:
453 
454  // Body:
455 
456  result = new field_met_e3();
457 
458  // Postconditions:
459 
460  ensure(result != 0);
461  ensure(is_same_type(result));
462 
463  // Exit:
464 
465  return result;
466 }
467 
469 bool
471 invariant() const
472 {
473  bool result = true;
474 
475  if(invariant_check())
476  {
477  // Prevent recursive calls to invariant.
478 
480 
481  // Must satisfy base class invariant.
482 
483  invariance(field_met_ed::invariant());
484 
485  // Invariances for this class:
486 
487  invariance(state_is_read_accessible() ?
488  base_space().is_same_state(&property().schema().base_space()) :
489  true);
490 
491  invariance(state_is_read_accessible() ?
492  property().schema().base_space().le(&coordinates().
493  schema().base_space()) :
494  true);
495 
496  // Finished, turn invariant checking back on.
497 
499  }
500 
501  // Exit
502 
503  return result;
504 }
505 
506 //=============================================================================
507 // NON-MEMBER FUNCTIONS OF CLASS FIELD_MET_E3
508 //=============================================================================
509 
512 fields::
514 {
515  // Preconditions:
516 
517  require(xsrc.is_attached());
518  require(xdst.is_attached());
519  require(xsrc.same_property_fiber_schema(xdst, true));
520 
521  // Body:
522 
523  not_implemented();
524 
525  // Postconditions:
526 
527  //Exit:
528 
529  return xdst;
530 }
531 
533 std::ostream&
534 fields::
535 operator<<(std::ostream& xos, const field_met_e3& xfield)
536 {
537  // Preconditions:
538 
539  require(xfield.state_is_read_accessible());
540 
541  // Body:
542 
543  xfield.print_property_dofs(xos, 0, "", false, false);
544 
545  // Postconditions:
546 
547  // Exit:
548 
549  return xos;
550 }
551 
552 //==============================================================================
553 
555 
556 //...
557 
virtual const std::string & class_name() const
The name of this class.
virtual field_vd & operator=(const field_vd &xother)
Assignment operator.
Definition: field_vd.cc:1763
void print_property_dofs(std::ostream &xos, property_dof_function_type xproperty_dofs_fcn, const std::string &xtitle_text, bool xzero_specified, bool xauto_access) const
Prints the property dofs and coordinates at the property discretization points. If xproperty_dof_fcn ...
Definition: field_vd.cc:723
A metric tensor over a 1 dimensional Euclidean vector space (volatile version).
Definition: met_e3.h:145
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
A property of type sec_met_e3 as a function of global coordinates.
Definition: field_met_e3.h:50
Namespace for fields component of sheaf system.
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
base_space_member * _base_space
The base space of this field.
Definition: field_vd.h:299
virtual void get_read_access() const
Get read access to the state associated with this.
Definition: field_vd.cc:1516
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
virtual bool invariant() const
Class invariant.
static const std::string & static_class_name()
The name of this class.
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
STL namespace.
virtual void get_read_access() const
Get read access to the state associated with this.
virtual field_met_e3 * clone() const
Virtual constructor, makes a new instance of the same type as this.
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
SHEAF_DLL_SPEC field_at0 & operator>>(const field_at0 &xsrc, field_at0 &xdst)
Pushes xsrc.property() to xdst.property().
Definition: field_at0.cc:513
A client handle for a member of a base space poset.
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...
A section of a fiber bundle with a d-dimensional Euclidean vector space fiber.
Definition: sec_ed.h:47
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual bool invariant() const
Class invariant.
An abstract invertible section of a fiber bundle with a d-dimensional base space and a d-dimensional ...
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if xother conforms to this.
A property of type sec_met_ed as a function of global coordinates.
Definition: field_met_ed.h:50
virtual bool is_attached() const
True if this handle is attached to a non-void state.
virtual void get_read_access() const
Get read access to the state associated with this.
A vd-valued property as a function of global coordinates.
Definition: field_vd.h:69
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...
Definition: field_vd.cc:1594
A section of a bundle with fiber type met_e3.
Definition: sec_met_e3.h:48
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &xos, const field_at0 &xfield)
Inserts field_at0 xfield into ostream xos.
Definition: field_at0.cc:535
base_space_member & base_space() const
The base space of this field.
Definition: field_vd.cc:373
A metric tensor over a 3 dimensional Euclidean vector space (persistent version). ...
Definition: met_e3.h:461
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
virtual bool is_attached() const
True if this handle has a state associated with it.
Definition: field_vd.cc:1311
total_poset_member & base_space()
The base space component of this (mutable version).
field_met_e3()
Default constructor.
Definition: field_met_e3.cc:41
virtual section_space_schema_member & schema()
The restricted schema for this (mutable version).
sec_ed_invertible * _coordinates
The independent variable of this field.
Definition: field_vd.h:294
sec_met_e3 & property() const
The dependent variable of this field.
sec_ed_invertible & coordinates() const
The independent variable of this field.
Definition: field_vd.cc:339
bool state_is_read_accessible() const
True if this is attached and if the coordinates and property are accessible for read or access contro...
Definition: field_vd.cc:1380
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
virtual field_met_e3 & operator=(const field_vd &xother)
Assignment operator.
sec_vd * _property
The dependent variable of this field.
Definition: field_vd.h:289
virtual ~field_met_e3()
Destructor.
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
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...
bool same_property_fiber_schema(const field_met_e3 &xother, bool xauto_access) const
True if this has the same property fiber as xother.