MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
level_set_perimeter_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
26 #include "base/nonlinear_system.h"
27 #include "base/assembly_base.h"
28 #include "base/function_base.h"
29 
30 #include "libmesh/parallel.h"
31 
34 _per (0.),
35 _dper_dp (0.),
36 _heaviside_smooth_delta (0.1) {
37 
38 }
39 
40 
41 
43 
44 
45 }
46 
47 
48 
49 void
51 
52  libmesh_assert(!_physics_elem);
53  libmesh_assert(_system);
54  libmesh_assert(_assembly);
55 
57 }
58 
59 
60 
61 
62 
63 void
65 
66  _per = 0.;
67  _dper_dp = 0.;
68 }
69 
70 
71 
72 void
74 
75  // sensitivity does not need the volume data, so we zero both.
76 
77  _per = 0.;
78  _dper_dp = 0.;
79 }
80 
81 
82 Real
84 
85  libmesh_assert(_physics_elem);
86 
88 
90  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
91 
93  }
94  else
95  return 0.;
96 }
97 
98 
99 
100 Real
102 
103  Real val = _per;
104 
105  // sum over all processors since part of the mesh can live on different
106  // processors
107  if (!_skip_comm_sum)
108  _system->system().comm().sum(val);
109 
110  return val;
111 }
112 
113 
114 
115 Real
117 
118  libmesh_assert(_physics_elem);
120  &elem = dynamic_cast<const MAST::LevelSetIntersectedElem&> (_physics_elem->elem());
121 
122  if (this->if_evaluate_for_element(elem) &&
125 
127  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
128 
130  }
131  else
132  return 0.;
133 
134 }
135 
136 
137 
138 Real
140 
141  Real val = _dper_dp;
142 
143  // sum over all processors since part of the mesh can live on different
144  // processors
145  if (!_skip_comm_sum)
146  _system->system().comm().sum(val);
147 
148  return val;
149 }
150 
151 
152 void
154 
155  libmesh_assert(_physics_elem);
156 
158 
160  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
161 
163  }
164 }
165 
166 
167 void
169 
170  // nothing to be done here, since this is a topology quantity and
171  // the sensitivity is calculated for topology variables
172 }
173 
174 
175 
176 void
178 
179  libmesh_assert(false);
180 }
181 
182 
183 void
186 
187  // here we ignore the velocity, since the element is able to compute that
188  // and provide the sensitivity from level set sensitivity values.
189  (void)vel;
190 
191  libmesh_assert(_physics_elem);
192  libmesh_assert(f.is_topology_parameter());
193 
195  &elem = dynamic_cast<const MAST::LevelSetIntersectedElem&> (_physics_elem->elem());
196 
197  // sensitivity only exists at the boundary. So, we proceed with calculation
198  // only if this element has an intersection in the interior, or with a side.
199  if (this->if_evaluate_for_element(elem)) {
200 
202  e = dynamic_cast<MAST::LevelSetElementBase&>(*_physics_elem);
203 
205  }
206 }
207 
MAST::NonlinearSystem & system()
virtual void init(const MAST::GeomElem &elem)
initializes the object for calculation of element quantities for the specified elem.
virtual void evaluate()
this is the abstract interface to be implemented by derived classes.
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 zero_for_analysis()
zeroes the output quantity values stored inside this object so that assembly process can begin...
libMesh::Real Real
virtual Real output_sensitivity_total(const MAST::FunctionBase &p)
virtual bool is_topology_parameter() const
Definition: function_base.h:97
virtual Real output_sensitivity_for_elem(const MAST::FunctionBase &p)
bool _skip_comm_sum
If an output has contrinutions only from local processor then the user can request that the global co...
This class inherits from MAST::GeomElem and provides an interface to initialize FE objects on sub-ele...
virtual void evaluate_sensitivity(const MAST::FunctionBase &f)
this evaluates all relevant sensitivity components on the element.
Real perimeter(Real delta=0.1)
Approximates the integral of the Dirac delta function to approximate the perimeter.
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_sensitivity()
zeroes the output quantity values stored inside this object so that assembly process can begin...
Real perimeter_sensitivity(Real delta=0.1)
computes the partial derivative of the integral of the Dirac delta function using the solution and se...
MAST::SystemInitialization * _system