MAST
surface_integrated_pressure_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 
21 // MAST includes
23 
24 
25 
28  const RealVectorX& n_vec):
30 _mode(o),
31 _n_vec(n_vec) {
32 
33  // scale the vector if needed
34  if (o == MAST::SurfaceIntegratedPressureOutput::OutputMode::UNIT_VEC &&
35  n_vec.norm() >= 0.)
36  _n_vec /= _n_vec.norm();
37 }
38 
39 
42 
43 }
44 
45 
46 void
48 
49  _load.setZero();
50  _load_sensitivity.clear();
51  _dload_dX.setZero();
52 }
53 
54 
55 
56 void
59  const RealVectorX* n_vec) {
60 
61  _mode = o;
62 
63  // scale the vector if needed
64  if (o == MAST::SurfaceIntegratedPressureOutput::OutputMode::UNIT_VEC) {
65 
66  libmesh_assert(n_vec);
67  _n_vec = *n_vec;
68  _n_vec /= _n_vec.norm();
69  }
70 }
71 
72 
73 
74 Real
76 value() const {
77 
78  switch (_mode) {
80 
81  return _load.norm();
82  }
83  break;
84 
86 
87  return _load.dot(_n_vec);
88  }
89  break;
90 
91  default:
92  libmesh_assert(false); // should not get here
93  break;
94  }
95 }
96 
97 
98 
99 Real
102 
103  // get the sensitivity of the load wrt the specified parameter
104  std::map<const MAST::FunctionBase*, RealVectorX>::const_iterator
105  it = _load_sensitivity.find(&f);
106 
107  libmesh_assert(it != _load_sensitivity.end());
108 
109  switch (_mode) {
111 
112  return (_load.dot(it->second)) / _load.norm();
113  }
114  break;
115 
117 
118  return it->second.dot(_n_vec);
119  }
120  break;
121 
122  default:
123  libmesh_assert(false); // should not get here
124  break;
125  }
126 }
127 
128 
129 
132 
133  switch (_mode) {
135 
136  return (_load.transpose()*_dload_dX) / _load.norm();
137  }
138  break;
139 
141 
142  return _n_vec.transpose() * _dload_dX;
143  }
144  break;
145 
146  default:
147  libmesh_assert(false); // should not get here
148  break;
149  }
150 }
151 
RealMatrixX _dload_dX
derivative of load wrt state vector.
This provides the base class for definitin of element level contribution of output quantity in an ana...
Real sensitivity(const MAST::FunctionBase &f) const
libMesh::Real Real
MAST::SurfaceIntegratedPressureOutput::OutputMode _mode
output calculation mode
void set_output_mode(MAST::SurfaceIntegratedPressureOutput::OutputMode o, const RealVectorX *n_vec=nullptr)
sets the mode that will be used for calculation of the output functional from the load vector...
SurfaceIntegratedPressureOutput(MAST::SurfaceIntegratedPressureOutput::OutputMode o, const RealVectorX &n_vec=RealVectorX::Zero(3, 1))
default constructor
RealVectorX _load
This is the 3x1 vector of the integrated load.
RealVectorX _n_vec
unit vector used for output, if _mode = UNIT_VEC
Matrix< Real, Dynamic, 1 > RealVectorX
std::map< const MAST::FunctionBase *, RealVectorX > _load_sensitivity
map of sensitivity of the stress with respect to a parameter