MAST
integrated_force_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
24 #include "base/assembly_base.h"
25 #include "base/elem_base.h"
27 #include "base/nonlinear_system.h"
28 #include "mesh/geom_elem.h"
29 
30 
31 // libMesh includes
32 #include "libmesh/boundary_info.h"
33 
34 
37 _n_vec (nvec),
38 _force (0.),
39 _force_sens (0.) {
40 
41  _n_vec /= _n_vec.norm();
42 }
43 
44 
45 
47 
48 }
49 
50 
51 
52 void
54 
55  libmesh_assert(!_physics_elem);
56  libmesh_assert(_system);
57  libmesh_assert(_assembly);
58 
59  const MAST::FlightCondition& p =
61  (_assembly->discipline()).flight_condition();
62 
65 }
66 
67 
68 
69 void
71 
72  _force = 0.;
73  _force_sens = 0.;
74 }
75 
76 
77 void
79 
80  // nothing to be done here
81  _force_sens = 0.;
82 }
83 
84 
85 Real
87 
88  Real val = _force;
89  _system->system().comm().sum(val);
90  return val;
91 }
92 
93 
94 
95 Real
97 
98  Real val = _force_sens;
99  _system->system().comm().sum(val);
100  return val;
101 }
102 
103 
104 
105 void
107 
108  libmesh_assert(_physics_elem);
109 
111  dynamic_cast<MAST::ConservativeFluidElementBase&>(*_physics_elem);
112 
113  const MAST::GeomElem&
114  elem = _physics_elem->elem();
115 
117  f = RealVectorX::Zero(3);
118 
119  for (unsigned short int n=0; n<elem.n_sides_quadrature_elem(); n++)
120  if (this->if_evaluate_for_boundary(elem, n)) {
121 
122  e.side_integrated_force(n, f);
123  _force += f.dot(_n_vec);
124  }
125 }
126 
127 
128 
129 void
131 
132  libmesh_assert(_physics_elem);
133 
135  dynamic_cast<MAST::ConservativeFluidElementBase&>(*_physics_elem);
136 
137  const MAST::GeomElem&
138  elem = _physics_elem->elem();
139 
141  df = RealVectorX::Zero(3);
142 
143  for (unsigned short int n=0; n<elem.n_sides_quadrature_elem(); n++)
144  if (this->if_evaluate_for_boundary(elem, n)) {
145 
147  _force_sens += df.dot(_n_vec);
148  }
149 }
150 
151 
152 
153 void
155 
156  libmesh_assert(_physics_elem);
157 
159  dynamic_cast<MAST::ConservativeFluidElementBase&>(*_physics_elem);
160 
161  const MAST::GeomElem&
162  elem = _physics_elem->elem();
163 
165  f = RealVectorX::Zero(3);
166 
168  dfdX = RealMatrixX::Zero(3, dq_dX.size());
169 
170  for (unsigned short int n=0; n<elem.n_sides_quadrature_elem(); n++)
171  if (this->if_evaluate_for_boundary(elem, n)) {
172 
173  e.side_integrated_force(n, f, &dfdX);
174  dq_dX += _n_vec.transpose() * dfdX;
175  }
176 }
177 
178 
179 
MAST::NonlinearSystem & system()
This class provides the necessary functionality for spatial discretization of the conservative fluid ...
virtual Real output_sensitivity_total(const MAST::FunctionBase &p)
Real _force
integrated value of the force
virtual void side_integrated_force_sensitivity(const MAST::FunctionBase &p, const unsigned int s, RealVectorX &f)
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...
libMesh::Real Real
virtual void side_integrated_force(const unsigned int s, RealVectorX &f, RealMatrixX *dfdX=nullptr)
surface integrated force
virtual void zero_for_sensitivity()
zeroes the output quantity values stored inside this object so that assembly process can begin...
virtual void output_derivative_for_elem(RealVectorX &dq_dX)
returns the output quantity derivative with respect to state vector in dq_dX.
unsigned int n_sides_quadrature_elem() const
number of sides on quadrature element.
Definition: geom_elem.cpp:101
Matrix< Real, Dynamic, Dynamic > RealMatrixX
virtual bool if_evaluate_for_boundary(const MAST::GeomElem &elem, const unsigned int s) const
checks to see if the specified side of the element needs evaluation of the output contribution...
Matrix< Real, Dynamic, 1 > RealVectorX
virtual void evaluate_sensitivity(const MAST::FunctionBase &p)
this evaluates all relevant sensitivity components on the element.
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 init(const MAST::GeomElem &elem)
initialize for the element.
Real _force_sens
integrated value of the sensitivity of force
IntegratedForceOutput(const RealVectorX &nvec)
RealVectorX _n_vec
vector along which the force is measured
virtual void zero_for_analysis()
zeroes the output quantity values stored inside this object so that assembly process can begin...
virtual void evaluate()
this is the abstract interface to be implemented by derived classes.
MAST::SystemInitialization * _system
const MAST::PhysicsDisciplineBase & discipline() const