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-2019 Manav Bhatia
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
26 #include "base/nonlinear_system.h"
27 #include "base/assembly_base.h"
28 #include "base/function_base.h"
29 
30 
33 _intersection (intersection),
34 _vol (0.),
35 _dvol_dp (0.) {
36 
37 }
38 
39 
40 
42 
43 
44 }
45 
46 
47 
48 void
50 
51  libmesh_assert(!_physics_elem);
52  libmesh_assert(_system);
53  libmesh_assert(_assembly);
54 
56 }
57 
58 
59 
60 
61 
62 void
64 
65  _vol = 0.;
66  _dvol_dp = 0.;
67 }
68 
69 
70 
71 void
73 
74  // sensitivity does not need the volume data, so we zero both.
75 
76  _vol = 0.;
77  _dvol_dp = 0.;
78 }
79 
80 
81 Real
83 
84  libmesh_assert(_physics_elem);
85 
87 
89  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
90 
91  return e.volume();
92  }
93  else
94  return 0.;
95 }
96 
97 
98 
99 Real
101 
102  Real val = _vol;
103 
104  // sum over all processors since part of the mesh can live on different
105  // processors
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  _system->system().comm().sum(val);
144 
145  return val;
146 }
147 
148 
149 void
151 
152  libmesh_assert(_physics_elem);
153 
155 
157  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
158 
159  _vol += e.volume();
160  }
161 }
162 
163 
164 void
166 
167  // nothing to be done here, since this is a topology quantity and
168  // the sensitivity is calculated for topology variables
169 }
170 
171 
172 
173 void
176 
177  // here we ignore the velocity, since the element is able to compute that
178  // and provide the sensitivity from level set sensitivity values.
179  (void)vel;
180 
181  libmesh_assert(_physics_elem);
182  libmesh_assert(f.is_topology_parameter());
183 
185  &elem = dynamic_cast<const MAST::LevelSetIntersectedElem&> (_physics_elem->elem());
186 
187  // sensitivity only exists at the boundary. So, we proceed with calculation
188  // only if this element has an intersection in the interior, or with a side.
189  if (this->if_evaluate_for_element(elem) &&
190  elem.if_elem_has_level_set_boundary() &&
191  elem.if_subelem_has_side_on_level_set_boundary()) {
192 
194  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
195 
197  (elem.get_subelem_side_on_level_set_boundary());
198  }
199 }
200 
LevelSetVolume(MAST::LevelSetIntersection &intersection)
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, const MAST::FieldFunction< RealVectorX > &vel)
This evaluates the contribution to the topology sensitivity on the boundary .
const MAST::GeomElem & elem() const
Definition: elem_base.h:117
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 void evaluate()
this is the abstract interface to be implemented by derived classes.
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
virtual void zero_for_analysis()
zeroes the output quantity values stored inside this object so that assembly process can begin...
virtual bool is_topology_parameter() const
Definition: function_base.h:97
MAST::SystemInitialization * _system