MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
build_conservative_fluid_elem.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 // C++ includes
21 #include <iostream>
22 
23 
24 
25 // MAST includes
26 #include "tests/fluid/build_conservative_fluid_elem.h"
27 #include "examples/base/rigid_surface_motion.h"
32 #include "fluid/flight_condition.h"
33 #include "base/parameter.h"
38 #include "base/nonlinear_system.h"
39 
40 // libMesh includes
41 #include "libmesh/mesh_generation.h"
42 
43 
44 // MAST includes
45 
46 
47 extern libMesh::LibMeshInit* __init;
48 
49 
50 
52 
53 
54  // initialize the libMesh object
55  _mesh = new libMesh::ParallelMesh(__init->comm());
56  _eq_sys = new libMesh::EquationSystems(*_mesh);
57 
58  // add the system to be used for analysis
59  _sys = &(_eq_sys->add_system<MAST::NonlinearSystem>("fluid"));
60 
61  // initialize the mesh
62  unsigned int
63  dim = 2;
64 
65  libMesh::MeshTools::Generation::build_square(*_mesh, 1, 1);
66 
67  // variable type
68  libMesh::FEType fe_type(libMesh::FIRST,
69  libMesh::LAGRANGE);
70 
73  _sys->name(),
74  fe_type,
75  dim);
76 
77 
78  // initialize the equation system for analysis
79  _eq_sys->init();
80 
81  // create the oundary conditions for slip-wall and far-field
84 
85  // tell the physics about these conditions
87 
88 
89 
91  _flight_cond->body_roll_axis(0) = 1.;
92  _flight_cond->body_pitch_axis(2) = 1.;
93  _flight_cond->body_yaw_axis(1) = 1.;
94  _flight_cond->body_euler_angles = RealVectorX::Zero(3);
95  _flight_cond->body_angular_rates = RealVectorX::Zero(3);
96 
97  _flight_cond->ref_chord = 1.;
98  _flight_cond->altitude = 0.;
99  _flight_cond->mach = .5;
100  _flight_cond->gas_property.cp = 1003.;
101  _flight_cond->gas_property.cv = 716.;
102  _flight_cond->gas_property.T = 300.;
104 
105  _flight_cond->init();
106 
107  // tell the discipline about the fluid values
109 
110  // define parameters
111  _omega = new MAST::Parameter("omega", 0.);
113  _b_ref = new MAST::Parameter("b_ref", 1.);
114 
115 
116  // now define the constant field functions based on this
120 
121  // initialize the frequency function
123  *_omega_f,
124  *_velocity_f,
125  *_b_ref_f);
126 
127  // initialize the motion object
128  _motion = new MAST::RigidSurfaceMotion;
129  _motion->init(*_freq_function, // frequency function
130  _flight_cond->body_yaw_axis, // plunge vector
131  _flight_cond->body_pitch_axis, // pitch axis
132  RealVectorX::Zero(3), // hinge location
133  0., // plunge amplitude
134  1., // pitch amplitude
135  0.); // pitch phase lead
136  _displacement = new MAST::RigidSurfaceDisplacement(*_motion);
137  _normal_rot = new MAST::RigidSurfaceNormalRotation(*_motion);
138 
142 
143 
144  // initialize the solution
145  _base_sol = RealVectorX::Zero(4),
146 
147  _base_sol(0) = _flight_cond->rho();
148  _base_sol(1) = _flight_cond->rho_u1();
149  _base_sol(2) = _flight_cond->rho_u2();
150  _base_sol(3) = _flight_cond->rho_e();
151 
152 }
153 
154 
155 
156 
157 
158 
160 
161  delete _eq_sys;
162  delete _mesh;
163 
164  delete _discipline;
165  delete _fluid_sys;
166 
167  delete _far_field;
168  delete _slip_wall;
169 
170  delete _flight_cond;
171 
172  delete _omega;
173  delete _velocity;
174  delete _b_ref;
175 
176  delete _omega_f;
177  delete _velocity_f;
178  delete _b_ref_f;
179 
180  delete _freq_function;
181 
182  delete _motion;
183  delete _displacement;
184  delete _normal_rot;
185 }
186 
187 
188 
189 
190 
MAST::ConservativeFluidDiscipline * _discipline
MAST::BoundaryConditionBase * _far_field
This class implements a system for solution of nonlinear systems.
Real mach
Flight Mach number.
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::RigidSurfaceMotion * _motion
surface rigid motion
MAST::ConservativeFluidSystemInitialization * _fluid_sys
void add_side_load(libMesh::boundary_id_type bid, MAST::BoundaryConditionBase &load)
adds the specified side loads for the boudnary with tag b_id
Real ref_chord
reference chord
MAST::RigidSurfaceDisplacement * _displacement
void add(MAST::FunctionBase &f)
adds the function to this card and returns a reference to it.
MAST::FrequencyFunction * _freq_function
frequency object
Real velocity_magnitude() const
Velocity magnitude, whose direction is evaluated from the Euler angles.
void init()
initializes the data structures
MAST::RigidSurfaceNormalRotation * _normal_rot
void set_flight_condition(MAST::FlightCondition &flt)
Attaches the flight condition that specifies the far-field flow properties.
GasProperty gas_property
Ambient air properties.
Real rho
Property values for ideal gas.
Definition: gas_property.h:71
libMesh::LibMeshInit * __init
MAST::BoundaryConditionBase * _slip_wall