SheafSystem  0.0.0.0
constant_base_space_map_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/constant_base_space_map_push_action.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/block.impl.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 // =============================================================================
33 // CONSTANT_BASE_SPACE_MAP_PUSH_ACTION FACET
34 // =============================================================================
35 
36 // PUBLIC MEMBER FUNCTIONS
37 
40 {
41 
42  // Preconditions:
43 
44  // Body:
45 
46  // Nothing to do.
47 
48  // Postconditions:
49 
50  ensure(invariant());
51  ensure(out_dofs().ct() == 0);
52 
53  // Exit:
54 
55  return;
56 }
57 
60 {
61  // Preconditions:
62 
63 
64  // Body:
65 
66  // Nothing to do;
67 
68  // Postconditions:
69 
70  // Exit:
71 
72  return;
73 }
74 
78 {
79  return _out_dofs;
80 }
81 
82 
83 // =============================================================================
84 // BASE_SPACE_MAP_PUSH_ACTION FACET
85 // =============================================================================
86 
87 // PUBLIC MEMBER FUNCTIONS
88 
89 void
91 operator()(pullback_map::iterator& xitr,
92  block<sec_vd*>& xoutputs,
93  block< block<sec_vd_dof_type>* >& xout_dofs)
94 {
95  // Preconditions:
96 
97  require(xoutputs.ct() > 0);
98  require(xout_dofs.ct() >= xoutputs.ct());
99  require_for_all(i, 0, xoutputs.ct(), xoutputs[i]->state_is_read_accessible());
100  require_for_all(i, 0, xoutputs.ct(),
101  xout_dofs[i]->ub() >= xoutputs[i]->schema().df());
102 
103  // Body:
104 
105  for(int i=0; i<xout_dofs.ct(); ++i)
106  {
107  xout_dofs[i]->set_ct(xout_dofs[i]->ub());
108  if((i < _out_dofs.ct()) && (xout_dofs[i]->ct() == _out_dofs[i].ct()))
109  {
110  *xout_dofs[i] = _out_dofs[i];
111  }
112  else
113  {
114  xout_dofs[i]->assign(0.0);
115  }
116  }
117 
118 
119  // Postconditions:
120 
121  // Exit:
122 
123  return;
124 }
125 
126 
127 // =============================================================================
128 // ANY FACET
129 // =============================================================================
130 
131 // PUBLIC MEMBER FUNCTIONS
132 
133 bool
135 is_ancestor_of(const any* xother) const
136 {
137 
138  // Preconditions:
139 
140  require(xother != 0);
141 
142  // Body:
143 
144  // True if xother conforms to this
145 
146  bool result = dynamic_cast<const constant_base_space_map_push_action*>(xother) != 0;
147 
148  // Postconditions:
149 
150  return result;
151 }
152 
155 clone() const
156 {
158 
159  // Preconditions:
160 
161  // Body:
162 
163  result = new constant_base_space_map_push_action(*this);
164 
165  // Postconditions:
166 
167  ensure(result != 0);
168  ensure(is_same_type(result));
169 
170  // Exit:
171 
172  return result;
173 }
174 
179 {
180 
181  // Preconditions:
182 
183  require(is_ancestor_of(&xother));
184 
185  // Body:
186 
187  not_implemented();
188 
189  // Postconditions:
190 
191  ensure(invariant());
192 
193  // Exit:
194 
195  return *this;
196 }
197 
201 {
202 
203  // Preconditions:
204 
205 
206  // Body:
207 
208  _out_dofs = xother._out_dofs;
209 
210  // Postconditions:
211 
212  ensure(invariant());
213 
214  // Exit
215 
216  return *this;
217 }
218 
219 bool
221 invariant() const
222 {
223  bool result = true;
224 
225  if(invariant_check())
226  {
227  // Prevent recursive calls to invariant
228 
229  disable_invariant_check();
230 
231  // Must satisfy base class invariant
232 
233  invariance(base_space_map_push_action::invariant());
234 
235  // Invariances for this class:
236 
237  // Finished, turn invariant checking back on.
238 
239  enable_invariant_check();
240  }
241 
242  // Exit
243 
244  return result;
245 }
246 
247 
248 // =============================================================================
249 // NON-MEMBER FUNCTIONS
250 // =============================================================================
251 
size_type ct() const
The number of items currently in use.
Namespace for fields component of sheaf system.
Abstract functor to compute the dofs at a destination discretization point.
STL namespace.
constant_base_space_map_push_action()
Default constructor; creates an instance with out_dofs.ct() == 0.
virtual constant_base_space_map_push_action & operator=(const base_space_map_push_action &xother)
Assignment operator.
Abstract base class with useful features for all objects.
Definition: any.h:39
block< block< sec_vd_dof_type > > & out_dofs()
Constant values for output dofs.
virtual void operator()(pullback_map::iterator &xitr, block< sec_vd *> &xoutputs, block< block< sec_vd_dof_type > * > &xout_dofs)
Sets xout_dofs to constant out_dofs().
virtual constant_base_space_map_push_action * clone() const
Virtual constructor, makes a new instance of the same type as this.
virtual bool is_ancestor_of(const any *xother) const
Conformance test; true if other conforms to this.
Abstract functor to compute the dofs at a destination discretization point.
An auto_block with a no-initialization initialization policy.
block< block< sec_vd_dof_type > > _out_dofs
Constant value for destination dofs.