MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
assembly_elem_operation.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 // MAST includes
22 #include "base/elem_base.h"
23 #include "base/assembly_base.h"
27 #include "mesh/geom_elem.h"
28 #include "mesh/fe_base.h"
29 
30 
31 
32 
33 
34 
36 _system (nullptr),
37 _discipline (nullptr),
38 _assembly (nullptr),
39 _physics_elem (nullptr),
40 _skip_comm_sum (false) {
41 
42 }
43 
44 
46 
47  this->clear_elem();
48 }
49 
50 
51 void
55 
56  libmesh_assert_msg(!_discipline && !_system,
57  "Error: Assembly should be cleared before attaching System.");
58 
59  _discipline = &discipline;
60  _system = &system;
61 }
62 
63 
64 
65 void
68 
69  _discipline = nullptr;
70  _system = nullptr;
71 }
72 
73 
74 void
76 
77  libmesh_assert(!_assembly);
78  _assembly = &assembly;
79 }
80 
81 
82 void
84 
85  _assembly = nullptr;
86 }
87 
88 
91 
92  return *_system;
93 }
94 
95 
98 
99  return *_discipline;
100 }
101 
102 
105 
106  libmesh_assert(_assembly);
107  return *_assembly;
108 }
109 
110 
111 
112 void
114 
115  libmesh_assert(_physics_elem);
116 
118 }
119 
120 
121 void
123 
124  libmesh_assert(_physics_elem);
125 
126  _physics_elem->set_solution(sol, true);
127 }
128 
129 
130 
131 void
133 
134  libmesh_assert(_physics_elem);
135 
137 }
138 
139 
140 void
142 
143  libmesh_assert(_physics_elem);
144 
145  _physics_elem->set_velocity(vel, true);
146 }
147 
148 
149 
150 void
152 
153  libmesh_assert(_physics_elem);
154 
156 }
157 
158 
159 void
161 
162  libmesh_assert(_physics_elem);
163 
164  _physics_elem->set_acceleration(accel, true);
165 }
166 
167 
168 void
170 
171  libmesh_assert(_physics_elem);
172 
174 }
175 
176 
177 void
179 
180  libmesh_assert(_physics_elem);
181 
183 }
184 
185 
186 void
188 
189  libmesh_assert(_physics_elem);
190 
192 }
193 
194 
195 void
197 
198  if (_physics_elem)
199  delete _physics_elem;
200 
201  _physics_elem = nullptr;
202 }
203 
204 
205 std::pair<const MAST::FieldFunction<RealVectorX>*, unsigned int>
208 
209  libmesh_assert(_physics_elem);
210 
211  std::pair<const MAST::FieldFunction<RealVectorX>*, unsigned int>
212  val = std::make_pair(nullptr, 0);
213 
214  std::map<unsigned int, std::vector<MAST::BoundaryConditionBase*>> loads;
216  loads);
217 
218  std::map<unsigned int, std::vector<MAST::BoundaryConditionBase*>>::const_iterator
219  it = loads.begin(),
220  end = loads.end();
221 
222  for ( ; it != end; it++) {
223 
224  std::vector<MAST::BoundaryConditionBase*>::const_iterator
225  bc_it = it->second.begin(),
226  bc_end = it->second.end();
227 
228  for ( ; bc_it != bc_end; bc_it++) {
229 
230  // apply all the types of loading
231  switch ((*bc_it)->type()) {
232 
234 
235  val.first = &((*bc_it)->get<MAST::FieldFunction<RealVectorX>>("phi_vel"));
236  val.second = it->first;
237  }
238  break;
239 
240 
241  default:
242  // nothing to be done here
243  break;
244  }
245  }
246  }
247 
248  return val;
249 }
250 
virtual void set_elem_perturbed_solution(const RealVectorX &sol)
sets the element perturbed solution
virtual void external_side_loads_for_quadrature_elem(std::multimap< libMesh::boundary_id_type, MAST::BoundaryConditionBase *> &bc, std::map< unsigned int, std::vector< MAST::BoundaryConditionBase *>> &loads) const
From the given list of boundary loads, this identifies the sides of the quadrature element and the lo...
Definition: geom_elem.cpp:183
virtual void set_elem_acceleration_sensitivity(const RealVectorX &accel)
sets the element acceleration
virtual void set_velocity(const RealVectorX &vec, bool if_sens=false)
stores vec as velocity for element level calculations, or its sensitivity if if_sens is true...
Definition: elem_base.cpp:98
virtual void set_elem_solution_sensitivity(const RealVectorX &sol)
sets the element solution sensitivity
virtual void set_assembly(MAST::AssemblyBase &assembly)
sets the assembly object
virtual void set_elem_solution(const RealVectorX &sol)
sets the element solution
virtual void clear_discipline_and_system()
clears association with a system to this discipline
MAST::PhysicsDisciplineBase * _discipline
virtual std::pair< const MAST::FieldFunction< RealVectorX > *, unsigned int > get_elem_boundary_velocity_data()
searches through the side load data and populates the data with the boundary id and velocity function...
MAST::SystemInitialization & get_system_initialization()
MAST::PhysicsDisciplineBase & get_discipline()
const MAST::SideBCMapType & side_loads() const
virtual void clear_assembly()
clears the assembly object
virtual MAST::AssemblyBase & get_assembly()
virtual void set_discipline_and_system(MAST::PhysicsDisciplineBase &discipline, MAST::SystemInitialization &system)
attaches a system to this discipline
Matrix< Real, Dynamic, 1 > RealVectorX
virtual void set_elem_perturbed_acceleration(const RealVectorX &accel)
sets the element perturbed acceleration
virtual void set_perturbed_solution(const RealVectorX &vec, bool if_sens=false)
This provides the perturbed solution (or its sensitivity if if_sens is true.) for linearized analysis...
Definition: elem_base.cpp:72
virtual void set_elem_velocity(const RealVectorX &vel)
sets the element velocity
const MAST::GeomElem & elem() const
Definition: elem_base.h:109
virtual void set_elem_velocity_sensitivity(const RealVectorX &vel)
sets the element velocity sensitivity
virtual void set_solution(const RealVectorX &vec, bool if_sens=false)
stores vec as solution for element level calculations, or its sensitivity if if_sens is true...
Definition: elem_base.cpp:60
virtual void clear_elem()
clears the element initialization
virtual void set_elem_perturbed_velocity(const RealVectorX &vel)
sets the element perturbed velocity
virtual void set_elem_acceleration(const RealVectorX &accel)
sets the element acceleration
virtual void set_perturbed_velocity(const RealVectorX &vec, bool if_sens=false)
stores vec as perturbed velocity for element level calculations, or its sensitivity if if_sens is tru...
Definition: elem_base.cpp:110
virtual void set_perturbed_acceleration(const RealVectorX &vec, bool if_sens=false)
stores vec as perturbed acceleration for element level calculations, or its sensitivity if if_sens is...
Definition: elem_base.cpp:134
virtual void set_acceleration(const RealVectorX &vec, bool if_sens=false)
stores vec as acceleration for element level calculations, or its sensitivity if if_sens is true...
Definition: elem_base.cpp:122
MAST::SystemInitialization * _system