SheafSystem  0.0.0.0
property_disc_iterator_1_1.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/property_disc_iterator_1_1.h"
23 
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/base_space_member.h"
26 #include "SheafSystem/binary_section_space_schema_member.h"
27 #include "SheafSystem/eval_family.h"
28 #include "SheafSystem/sec_rep_descriptor.h"
29 #include "SheafSystem/section_evaluator.h"
30 #include "SheafSystem/section_space_schema_member.h"
31 #include "SheafSystem/sec_ed_invertible.h"
32 #include "SheafSystem/sec_vd.h"
33 #include "SheafSystem/std_limits.h"
34 #include "SheafSystem/structured_block_1d.h"
35 #include "SheafSystem/structured_block_2d.h"
36 #include "SheafSystem/structured_block_3d.h"
37 #include "SheafSystem/subposet_member_iterator.h"
38 #include "SheafSystem/uniform_eval_family.h"
39 #include "SheafSystem/field_vd.h"
40 
41 using namespace std;
42 using namespace fields; // Workaround for MS C++ bug.
43 
44 //#define DIAGNOSTIC_OUTPUT 1
45 
46 // ===========================================================
47 // PROPERTY_DISC_ITERATOR_1_1 FACET
48 // ===========================================================
49 
50 // PUBLIC MEMBER FUNCTIONS
51 
52 fields::property_disc_iterator_1_1::
53 property_disc_iterator_1_1(const field_vd& xfield)
55 {
56 
57  // Preconditions:
58 
59  require(xfield.state_is_read_accessible());
61  require(xfield.property().schema().base_space().le(&xfield.coordinates().schema().base_space()));
62  require(xfield.property().schema().rep().is_same_state(&xfield.coordinates().schema().rep()));
63 
64  // Body:
65 
66  initialize_iteration(xfield, POSTORDER);
67 
68  // Postconditions:
69 
70  ensure(invariant());
71  ensure(is_initialized());
72  ensure(coordinates_schema().is_same_state(&xfield.coordinates().schema()));
73  ensure(coordinates_schema().is_same_type(&xfield.coordinates().schema()));
74  ensure(coordinates_schema().version() == xfield.coordinates().schema().version());
75  ensure(property_schema().is_same_state(&xfield.property().schema()));
76  ensure(property_schema().is_same_type(&xfield.property().schema()));
77  ensure(property_schema().version() == xfield.property().schema().version());
78  ensure(descending());
79  ensure(!strict());
80  ensure(unexecutable(!is_done() implies this is first member));
81 
82  return;
83 }
84 
85 
86 fields::property_disc_iterator_1_1::
87 property_disc_iterator_1_1(
88  const section_space_schema_member& xcoordinates_schema,
89  const section_space_schema_member& xproperty_schema)
91 {
92 
93  // Preconditions:
94 
95  require(xcoordinates_schema.state_is_read_accessible());
96  require(xcoordinates_schema.base_space().schema().conforms_to(base_space_member::standard_schema_path()));
97  require(xproperty_schema.state_is_read_accessible());
98  require(xproperty_schema.base_space().le(&xcoordinates_schema.base_space()));
99  require(xproperty_schema.rep().is_same_state(&xcoordinates_schema.rep()));
100 
101  // Body:
102 
103  initialize_iteration(xcoordinates_schema, xproperty_schema, POSTORDER);
104 
105  // Postconditions:
106 
107  ensure(invariant());
108  ensure(is_initialized());
109  ensure(coordinates_schema().is_same_state(&xcoordinates_schema));
110  ensure(coordinates_schema().is_same_type(&xcoordinates_schema));
111  ensure(coordinates_schema().version() == xcoordinates_schema.version());
112  ensure(property_schema().is_same_state(&xproperty_schema));
113  ensure(property_schema().is_same_type(&xproperty_schema));
114  ensure(property_schema().version() == xproperty_schema.version());
115  ensure(descending());
116  ensure(!strict());
117  ensure(unexecutable(!is_done() implies this is first member));
118 
119  return;
120 }
121 
124 {
125  // Preconditions:
126 
127  // Body:
128 
129  // Postconditions:
130 
131 }
132 
133 void
136 {
137  // Preconditions:
138 
139  require(xsec.state_is_read_accessible());
140  require(xsec.schema().is_same_state(&coordinates_schema()));
141 
143 
144  require(xsec.schema().df() <= 3);
145 
146  // Body:
147 
149 
150  // Don't need to evaluate, just get the coord disc.
151 
152  xsec.get_fiber(ldisc_mbr.disc_id, ldisc_mbr.values,
153  3*sizeof(sec_vd::dof_type), false);
154 
155  // Postconditions:
156 
157 
158  // Exit:
159 
160  return;
161 }
162 
163 
164 // ===========================================================
165 // DEPTH_FIRST_ITERATOR FACET
166 // ===========================================================
167 
168 // PUBLIC MEMBER FUNCTIONS
169 
170 void
172 next(bool xtruncate)
173 {
174  // Preconditions:
175 
176  require(!is_done());
177 
178  // Body:
179 
180  bool ltruncate = xtruncate;
181 
182  // Never want to see a prop disc member more than once,
183  // so always clear the buffer before we start.
184 
186 
187  // Traverse the graph gathering coord and prop disc members until
188  // we have enough context to evaluate the coordinates at the
189  // the property disc points or until the trversal is done.
190 
191  property_disc_iterator::next(ltruncate);
192 
193  while(!is_done())
194  {
196  {
198  break;
199  }
200 
202  } // end while(!is_done())
203 
204  // Postconditions:
205 
206  ensure(invariant());
207  ensure(!is_done() ? action() == POSTVISIT_ACTION : true);
208 
209  // Exit
210 
211  return;
212 }
213 
214 
215 // ===========================================================
216 // ANY FACET
217 // ===========================================================
218 
219 // PUBLIC MEMBER FUNCTIONS
220 
221 bool
223 is_ancestor_of(const any* xother) const
224 {
225  // Preconditions:
226 
227  // Body:
228 
229  bool result = dynamic_cast<const property_disc_iterator_1_1*>(xother) != 0;
230 
231  // Postconditions:
232 
233  // Exit
234 
235  return result;
236 }
237 
240 clone() const
241 {
242  // Preconditions:
243 
244  // Body:
245 
248 
249  // Postconditions:
250 
251  // ensure(invariant());
252  ensure(result != 0);
253 
254  // Exit
255 
256  return result;
257 }
258 
259 bool
261 invariant() const
262 {
263  bool result = true;
264 
265  // Preconditions:
266 
267  // Body:
268 
269 
270  if(invariant_check())
271  {
272  invariance(property_disc_iterator::invariant());
273 
275 
276  invariance(order() == POSTORDER);
277  invariance(property_schema().rep().is_same_state(&coordinates_schema().rep()));
278 
279  // Finished, turn invariant checking back on.
280 
282  }
283 
284  // Postconditions:
285 
286  // Exit
287 
288  return result;
289 }
290 
291 
section_iteration_state _prop_state
Descriptor for property section iteration.
virtual bool is_ancestor_of(const any *xother) const
True if other conforms to this.
A context for discretization members. Intended for implementing various iterators, especially concurrent iterations over multiple sections.
virtual property_disc_iterator_1_1 * clone() const
Make a new instance of the same type as this.
int version(bool xunalias=true) const
The (possibly aliased) version of this component. The version of the host used when evaluating proper...
virtual bool is_initialized() const
True if this has been initialized for iteration with respect to a specific anchor.
action_type action() const
The type of action the client should take when the iterator returns control to the client...
Namespace for fields component of sheaf system.
bool conforms_to(const schema_poset_member &xother) const
True if the dofs defined by this agree in type and in order with the dofs defined by xother...
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
void get_fiber(pod_index_type xdisc_id, vd_lite &xfiber) const
Sets xfiber to the fiber referred to by discretization id xdisc_id.
Definition: sec_vd.cc:1087
const section_space_schema_member & property_schema() const
The property field schema member which is being iterated over.
virtual bool contains_member(pod_index_type xmbr_hub_id) const
True if this poset contains poset member with hub id xmbr_hub_id.
Definition: subposet.cc:955
STL namespace.
bool is_same_state(const poset_state_handle *xhost, pod_index_type xhub_id) const
True is this is attached to state with hub id xhub_id in host xhost.
void initialize_iteration(const field_vd &xfield, order_type xorder)
Initializes this for iteration of type xorder over the schema of xfield.
Abstract base class with useful features for all objects.
Definition: any.h:39
order_type order() const
The order of the iteration. Determines which actions are exported to the client.
block< discretization_context > discretization_members
The discretization members in the downset of the current evaluation member.
bool descending() const
True if iterating over down set of anchor.
A vd-valued property as a function of global coordinates.
Definition: field_vd.h:69
sec_vd & property() const
The dependent variable of this field.
Definition: field_vd.cc:357
bool le(pod_index_type xother_index) const
True if this is less than or equal to the member with index xother_index.
bool invariant() const
The class invariant.
void next()
Makes this the next member of the subset.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
base_space_member & base_space() const
The base space of this field.
Definition: field_vd.cc:373
const scoped_index & greater_index() const
The index of the greater member of the current link.
A section of a fiber bundle with a d-dimensional vector space fiber.
Definition: sec_vd.h:54
void gather_discretization_member(const scoped_index &xindex, const scoped_index &xgreater_index)
Puts xindex into the discretization gather buffer and, if enabled, corrects discretization order...
bool is_done() const
True if iteration finished.
static const poset_path & standard_schema_path()
The path of the schema required by this class.
void first()
Moves this to the first member of the iteration.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
total_poset_member & base_space()
The base space component of this (mutable version).
virtual section_space_schema_member & schema()
The restricted schema for this (mutable version).
sec_vd_dof_type dof_type
The type of degree of freedom.
Definition: sec_vd.h:91
A client handle for a poset member which has been prepared for use as a schema for a section space...
virtual void get_prop_disc_values(const sec_vd &xsec)
The gets the values of xsec at the property discretization points.
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
const section_space_schema_member & coordinates_schema() const
The coordinates field schema member which is being iterated over.
int df() const
The dimension of the fiber space component.
A property discretization iterator for a property section with the same discretization as the coordin...
bool invariant() const
The class invariant.
sec_rep_descriptor & rep()
The representation for section spaces on this schema (mutable version).
virtual schema_poset_member & schema()
The schema for this member (mutable version).
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
subposet disc_sp
The discretization subposet associated with schema.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
bool strict() const
True if iterating over xstrict up/down set of anchor.
Abstract iterator over the discretization of the property section of a field_vd. Concurrently travers...
scoped_index _index
The index of the lesser end of the current link; the current item in the iteration.