MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
level_set_volume_output.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
25 #include "base/nonlinear_system.h"
26 #include "base/assembly_base.h"
27 #include "base/function_base.h"
28 
29 #include "libmesh/parallel.h"
30 
33 _vol (0.),
34 _dvol_dp (0.) {
35 
36 }
37 
38 
39 
41 
42 
43 }
44 
45 
46 
47 void
49 
50  libmesh_assert(!_physics_elem);
51  libmesh_assert(_system);
52  libmesh_assert(_assembly);
53 
55 }
56 
57 
58 
59 
60 
61 void
63 
64  _vol = 0.;
65  _dvol_dp = 0.;
66 }
67 
68 
69 
70 void
72 
73  // sensitivity does not need the volume data, so we zero both.
74 
75  _vol = 0.;
76  _dvol_dp = 0.;
77 }
78 
79 
80 Real
82 
83  libmesh_assert(_physics_elem);
84 
86 
88  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
89 
90  return e.volume();
91  }
92  else
93  return 0.;
94 }
95 
96 
97 
98 Real
100 
101  Real val = _vol;
102 
103  // sum over all processors since part of the mesh can live on different
104  // processors
105  if (!_skip_comm_sum)
106  _system->system().comm().sum(val);
107 
108  return val;
109 }
110 
111 
112 
113 Real
115 
116  libmesh_assert(_physics_elem);
118  &elem = dynamic_cast<const MAST::LevelSetIntersectedElem&> (_physics_elem->elem());
119 
120  if (this->if_evaluate_for_element(elem) &&
123 
125  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
126 
128  }
129  else
130  return 0.;
131 
132 }
133 
134 
135 
136 Real
138 
139  Real val = _dvol_dp;
140 
141  // sum over all processors since part of the mesh can live on different
142  // processors
143  if (!_skip_comm_sum)
144  _system->system().comm().sum(val);
145 
146  return val;
147 }
148 
149 
150 void
152 
153  libmesh_assert(_physics_elem);
154 
156 
158  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
159 
160  _vol += e.volume();
161  }
162 }
163 
164 
165 void
167 
168  // nothing to be done here, since this is a topology quantity and
169  // the sensitivity is calculated for topology variables
170 }
171 
172 
173 
174 void
176 
177  libmesh_assert(false);
178 }
179 
180 
181 
182 void
185 
186  // here we ignore the velocity, since the element is able to compute that
187  // and provide the sensitivity from level set sensitivity values.
188  (void)vel;
189 
190  libmesh_assert(_physics_elem);
191  libmesh_assert(f.is_topology_parameter());
192 
194  &elem = dynamic_cast<const MAST::LevelSetIntersectedElem&> (_physics_elem->elem());
195 
196  // sensitivity only exists at the boundary. So, we proceed with calculation
197  // only if this element has an intersection in the interior, or with a side.
198  if (this->if_evaluate_for_element(elem) &&
199  elem.if_elem_has_level_set_boundary() &&
200  elem.if_subelem_has_side_on_level_set_boundary()) {
201 
203  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
204 
206  (elem.get_subelem_side_on_level_set_boundary());
207  }
208 }
209 
MAST::NonlinearSystem & system()
virtual Real output_sensitivity_total(const MAST::FunctionBase &p)
virtual bool if_evaluate_for_element(const MAST::GeomElem &elem) const
checks to see if the object has been told about the subset of elements and if the specified element i...
virtual void evaluate_topology_sensitivity(const MAST::FunctionBase &f)
this evaluates all relevant topological sensitivity components on the element.
This provides the base class for definitin of element level contribution of output quantity in an ana...
virtual void init(const MAST::GeomElem &elem)
initializes the object for calculation of element quantities for the specified elem.
virtual Real output_sensitivity_for_elem(const MAST::FunctionBase &p)
libMesh::Real Real
Real volume_boundary_velocity_on_side(unsigned int s)
virtual bool is_topology_parameter() const
Definition: function_base.h:97
virtual void evaluate()
this is the abstract interface to be implemented by derived classes.
bool _skip_comm_sum
If an output has contrinutions only from local processor then the user can request that the global co...
virtual void evaluate_sensitivity(const MAST::FunctionBase &f)
this evaluates all relevant sensitivity components on the element.
virtual void zero_for_sensitivity()
zeroes the output quantity values stored inside this object so that assembly process can begin...
This class inherits from MAST::GeomElem and provides an interface to initialize FE objects on sub-ele...
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
Definition: geom_elem.h:59
const MAST::GeomElem & elem() const
Definition: elem_base.h:109
virtual void zero_for_analysis()
zeroes the output quantity values stored inside this object so that assembly process can begin...
MAST::SystemInitialization * _system