SheafSystem  0.0.0.0
copy_push_action.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/copy_push_action.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/block.h"
25 #include "SheafSystem/error_message.h"
26 #include "SheafSystem/sec_vd.h"
27 
28 using namespace std;
29 using namespace fields; // Workaround for MS C++ bug.
30 
31 // =============================================================================
32 // COPY_PUSH_ACTION FACET
33 // =============================================================================
34 
35 // PUBLIC MEMBER FUNCTIONS
36 
37 fields::copy_push_action::
38 copy_push_action(int xdst_df)
40 {
41 
42  // Preconditions:
43 
44  require(xdst_df >= 0);
45 
46  // Body:
47 
48  // Nothing to do.
49 
50  // Postconditions:
51 
52  ensure(invariant());
53  ensure(dst_df() == xdst_df);
54 
55  // Exit:
56 
57  return;
58 }
59 
60 
61 
62 
65 {
66  // Preconditions:
67 
68 
69  // Body:
70 
71  // Nothing to do;
72 
73  // Postconditions:
74 
75  // Exit:
76 
77  return;
78 }
79 
80 
81 // =============================================================================
82 // SECTION_PUSHER_PUSH_ACTION FACET
83 // =============================================================================
84 
85 // PUBLIC MEMBER FUNCTIONS
86 
87 void
89 operator()(pullback_map::iterator& xitr,
90  sec_vd& xdst,
91  block<sec_vd_dof_type>& xdst_dofs)
92 {
93 #ifdef DIAGNOSTIC_OUTPUT
94  post_information_message("Entering copy_push_action::operator()");
95 #endif
96 
97  // Preconditions:
98 
99  require(xdst.state_is_read_accessible());
100  require(xdst.schema().df() == dst_df());
101  require(xdst_dofs.ub() >= dst_df());
102  require(unexecutable("dst_dofs initialized to source value"));
103 
104  // Body:
105 
106  // Do nothing; dst dofs already initalized to source value.
107 
108  // Postconditions:
109 
110  ensure(unexecutable("xdst_dofs unchanged"));
111 
112  // Exit:
113 
114 #ifdef DIAGNOSTIC_OUTPUT
115 
116  post_information_message("Leaving copy_push_action::operator()");
117 #endif
118 
119  return;
120 }
121 
122 
123 // =============================================================================
124 // ANY FACET
125 // =============================================================================
126 
127 // PUBLIC MEMBER FUNCTIONS
128 
129 bool
131 is_ancestor_of(const any* xother) const
132 {
133 
134  // Preconditions:
135 
136  require(xother != 0);
137 
138  // Body:
139 
140  // True if xother conforms to this
141 
142  bool result = dynamic_cast<const copy_push_action*>(xother) != 0;
143 
144  // Postconditions:
145 
146  return result;
147 }
148 
151 clone() const
152 {
153  copy_push_action* result;
154 
155  // Preconditions:
156 
157  // Body:
158 
159  result = new copy_push_action(*this);
160 
161  // Postconditions:
162 
163  ensure(result != 0);
164  ensure(is_same_type(result));
165 
166  // Exit:
167 
168  return result;
169 }
170 
175 {
176 
177  // Preconditions:
178 
179  require(is_ancestor_of(&xother));
180 
181  // Body:
182 
183  not_implemented();
184 
185  // Postconditions:
186 
187  ensure(invariant());
188 
189  // Exit:
190 
191  return *this;
192 }
193 
197 {
198 
199  // Preconditions:
200 
201 
202  // Body:
203 
204  _dst_df = xother._dst_df;
205 
206  // Postconditions:
207 
208  ensure(invariant());
209 
210  // Exit
211 
212  return *this;
213 }
214 
215 bool
217 invariant() const
218 {
219  bool result = true;
220 
221  if(invariant_check())
222  {
223  // Prevent recursive calls to invariant
224 
226 
227  // Must satisfy base class invariant
228 
230 
231  // Invariances for this class:
232 
233  // Finished, turn invariant checking back on.
234 
236  }
237 
238  // Exit
239 
240  return result;
241 }
242 
243 
244 // =============================================================================
245 // NON-MEMBER FUNCTIONS
246 // =============================================================================
247 
index_type ub() const
The upper bound on the storage array. The number of items current allocated in the storage array...
Functor to compute the dofs at a destination discretization point by copying the source value to the ...
Abstract functor to compute the dofs at a destination discretization point.
Namespace for fields component of sheaf system.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
STL namespace.
virtual bool invariant() const
Class invariant.
virtual ~copy_push_action()
Destructor.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
virtual copy_push_action * clone() const
Virtual constructor, makes a new instance of the same type as this.
int _dst_df
The fiber dimension of the destination.
virtual copy_push_action & operator=(const section_pusher_push_action &xother)
Assignment operator.
int dst_df()
The fiber dimension of the destination.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
A section of a fiber bundle with a d-dimensional vector space fiber.
Definition: sec_vd.h:54
virtual void operator()(pullback_map::iterator &xitr, sec_vd &xdst, block< sec_vd_dof_type > &xdst_dofs)
Computes xdst_dofs using xitr and the dofs already in xdst, as needed.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
virtual section_space_schema_member & schema()
The restricted schema for this (mutable version).
virtual bool invariant() const
Class invariant.
int df() const
The dimension of the fiber space component.
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