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