MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
build_structural_elem_1D.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 
21 
22 // MAST includes
23 #include "tests/structural/build_structural_elem_1D.h"
25 #include "elasticity/structural_discipline.h"
28 #include "base/parameter.h"
32 #include "base/nonlinear_system.h"
33 
34 extern libMesh::LibMeshInit* __init;
35 
36 
38 _initialized(false),
39 _mesh(nullptr),
40 _eq_sys(nullptr),
41 _sys(nullptr),
42 _structural_sys(nullptr),
43 _discipline(nullptr),
44 _thy(nullptr),
45 _thz(nullptr),
46 _E(nullptr),
47 _nu(nullptr),
48 _hy_off(nullptr),
49 _hz_off(nullptr),
50 _zero(nullptr),
51 _temp(nullptr),
52 _alpha(nullptr),
53 _thy_f(nullptr),
54 _thz_f(nullptr),
55 _E_f(nullptr),
56 _nu_f(nullptr),
57 _hyoff_f(nullptr),
58 _hzoff_f(nullptr),
59 _temp_f(nullptr),
60 _ref_temp_f(nullptr),
61 _alpha_f(nullptr),
62 _m_card(nullptr),
63 _p_card(nullptr),
64 _p_theory(nullptr),
65 _thermal_load(nullptr) {
66 
67  }
68 
69 
70 void
71 MAST::BuildStructural1DElem::init(bool if_link_offset_to_th,
72  bool if_nonlinear) {
73 
74  // make sure that this has not already been initialized
75  libmesh_assert(!_initialized);
76 
77  // create the mesh
78  _mesh = new libMesh::SerialMesh(__init->comm());
79 
80  // initialize the mesh with one element
81  libMesh::MeshTools::Generation::build_line(*_mesh, 1, 0, 2);
82 
83  // create the equation system
84  _eq_sys = new libMesh::EquationSystems(*_mesh);
85 
86  // create the libmesh system
87  _sys = &(_eq_sys->add_system<MAST::NonlinearSystem>("structural"));
88 
89  // FEType to initialize the system
90  libMesh::FEType fetype (libMesh::FIRST, libMesh::LAGRANGE);
91 
92  // initialize the system to the right set of variables
94  _sys->name(),
95  fetype);
96  _discipline = new MAST::StructuralDiscipline(*_eq_sys);
97 
98  // initialize the equation system
99  _eq_sys->init();
100 
101  // create the property functions and add them to the
102 
103  _thy = new MAST::Parameter("thy", 0.06);
104  _thz = new MAST::Parameter("thz", 0.02);
105  _E = new MAST::Parameter("E", 72.e9);
106  _nu = new MAST::Parameter("nu", 0.33);
107  _hy_off = new MAST::Parameter("hyoff", 0.);
108  _hz_off = new MAST::Parameter("hzoff", 0.);
109  _zero = new MAST::Parameter("zero", 0.);
110  _temp = new MAST::Parameter("temp", 60.);
111  _alpha = new MAST::Parameter("alpha", 2.5e-5);
112  _velocity = new MAST::Parameter("V" , 200.);
113  _mach = new MAST::Parameter("mach", 4.);
114  _rho_air = new MAST::Parameter("rho" , 1.1);
115  _gamma_air = new MAST::Parameter("gamma", 1.4);
116  _dwdx = new MAST::Parameter("dwdx", 2.5);
117  _dwdt = new MAST::Parameter("dwdx", 4.5);
118 
119 
120 
121  // prepare the vector of parameters with respect to which the sensitivity
122  // needs to be benchmarked
123  _params_for_sensitivity.push_back(_E);
124  _params_for_sensitivity.push_back(_nu);
125  _params_for_sensitivity.push_back(_thy);
126  _params_for_sensitivity.push_back(_thz);
127  _params_for_sensitivity.push_back(_hy_off);
128  _params_for_sensitivity.push_back(_hz_off);
129 
130 
131 
134  _E_f = new MAST::ConstantFieldFunction("E", *_E);
135  _nu_f = new MAST::ConstantFieldFunction("nu", *_nu);
136  _temp_f = new MAST::ConstantFieldFunction("temperature", *_temp);
137  _ref_temp_f = new MAST::ConstantFieldFunction("ref_temperature", *_zero);
138  _alpha_f = new MAST::ConstantFieldFunction("alpha_expansion", *_alpha);
139  if (!if_link_offset_to_th) {
140  _hyoff_f = new MAST::ConstantFieldFunction("hy_off", *_hy_off);
141  _hzoff_f = new MAST::ConstantFieldFunction("hz_off", *_hz_off);
142  }
143  else {
144  _hyoff_f = new MAST::ConstantFieldFunction("hy_off", *_thy);
145  _hzoff_f = new MAST::ConstantFieldFunction("hz_off", *_thz);
146  }
148  _mach_f = new MAST::ConstantFieldFunction("mach", *_mach);
151  _dwdx_f = new MAST::ConstantFieldFunction("dwdx", *_dwdx);
152  _dwdt_f = new MAST::ConstantFieldFunction("dwdt", *_dwdt);
153 
154 
155  // create the material property card
157 
158  // add the material properties to the card
159  _m_card->add(*_E_f);
160  _m_card->add(*_nu_f);
161  _m_card->add(*_alpha_f);
162 
163  // create the element property card
165 
166  // tell the card about the orientation
167  libMesh::Point orientation;
168  orientation(1) = 1.;
169  _p_card->y_vector() = orientation;
170 
171  // add the section properties to the card
172  _p_card->add(*_thy_f);
173  _p_card->add(*_thz_f);
174  _p_card->add(*_hyoff_f);
175  _p_card->add(*_hzoff_f);
176 
177  // tell the section property about the material property
179  if (if_nonlinear) _p_card->set_strain(MAST::VON_KARMAN_STRAIN);
180 
181  _p_card->init();
182 
184  vel = RealVectorX::Zero(3);
185 
186  // set velocity along x axis
187  vel(0) = 1.;
188 
189  // create the boundary condition
191  vel);
193  _p_theory->add(*_mach_f);
196 
200 }
201 
202 
203 
204 
205 
206 
207 
209 
210  delete _m_card;
211  delete _p_card;
212 
213  delete _p_theory;
214  delete _thermal_load;
215 
216  delete _thy_f;
217  delete _thz_f;
218  delete _E_f;
219  delete _nu_f;
220  delete _hyoff_f;
221  delete _hzoff_f;
222  delete _temp_f;
223  delete _ref_temp_f;
224  delete _alpha_f;
225  delete _velocity_f;
226  delete _mach_f;
227  delete _rho_air_f;
228  delete _gamma_air_f;
229  delete _dwdx_f;
230  delete _dwdt_f;
231 
232  delete _thy;
233  delete _thz;
234  delete _hy_off;
235  delete _hz_off;
236  delete _E;
237  delete _nu;
238  delete _zero;
239  delete _temp;
240  delete _alpha;
241  delete _velocity;
242  delete _mach;
243  delete _rho_air;
244  delete _gamma_air;
245  delete _dwdx;
246  delete _dwdt;
247 
248 
249  delete _eq_sys;
250  delete _mesh;
251 
252  delete _discipline;
253  delete _structural_sys;
254 
255 
256 }
257 
258 
MAST::ConstantFieldFunction * _hzoff_f
MAST::ConstantFieldFunction * _gamma_air_f
This class implements a system for solution of nonlinear systems.
libMesh::LibMeshInit * __init
virtual void set_material(MAST::MaterialPropertyCardBase &mat)
sets the material card
MAST::ConstantFieldFunction * _nu_f
MAST::ConstantFieldFunction * _thy_f
RealVectorX & y_vector()
returns value of the property val.
MAST::ConstantFieldFunction * _alpha_f
MAST::ConstantFieldFunction * _ref_temp_f
This is a scalar function whose value can be changed and one that can be used as a design variable in...
Definition: parameter.h:35
MAST::ConstantFieldFunction * _E_f
MAST::ConstantFieldFunction * _rho_air_f
void set_strain(MAST::StrainType strain)
sets the type of strain to be used, which is LINEAR_STRAIN by default
MAST::StructuralSystemInitialization * _structural_sys
std::vector< MAST::Parameter * > _params_for_sensitivity
void add(MAST::FunctionBase &f)
adds the function to this card and returns a reference to it.
MAST::Solid1DSectionElementPropertyCard * _p_card
MAST::ConstantFieldFunction * _dwdt_f
libMesh::EquationSystems * _eq_sys
MAST::ConstantFieldFunction * _mach_f
MAST::BoundaryConditionBase * _thermal_load
MAST::PistonTheoryBoundaryCondition * _p_theory
MAST::ConstantFieldFunction * _thz_f
Matrix< Real, Dynamic, 1 > RealVectorX
void init(bool if_link_offset_to_th, bool if_nonlinear)
MAST::ConstantFieldFunction * _temp_f
MAST::StructuralDiscipline * _discipline
MAST::IsotropicMaterialPropertyCard * _m_card
MAST::ConstantFieldFunction * _hyoff_f
MAST::ConstantFieldFunction * _dwdx_f
MAST::ConstantFieldFunction * _velocity_f