20 #ifndef __mast_fluid_elem_initialization_h__ 21 #define __mast_fluid_elem_initialization_h__ 39 #include "libmesh/libmesh.h" 40 #include "libmesh/string_to_enum.h" 41 #include "libmesh/enum_order.h" 42 #include "libmesh/enum_fe_family.h" 43 #include "libmesh/enum_elem_type.h" 44 #include "libmesh/fe_type.h" 45 #include "libmesh/replicated_mesh.h" 46 #include "libmesh/equation_systems.h" 47 #include "libmesh/dof_map.h" 48 #include "libmesh/numeric_vector.h" 49 #include "libmesh/exodusII_io.h" 50 #include "libmesh/nonlinear_solver.h" 51 #include "libmesh/mesh_generation.h" 59 libMesh::UnstructuredMesh*
_mesh;
88 _discipline (nullptr),
89 _flight_cond (nullptr),
92 _transient_solver(nullptr),
93 _fluid_elem (nullptr),
94 _far_field_bc (nullptr),
95 _slip_wall_bc (nullptr),
96 _noslip_wall_bc (nullptr),
107 _mesh =
new libMesh::ReplicatedMesh(_init.comm());
110 libMesh::MeshTools::Generation::build_square(*_mesh, 1, 1);
113 _eq_sys =
new libMesh::EquationSystems(*_mesh);
122 libMesh::Order fe_order = libMesh::FIRST;
123 libMesh::FEFamily fe_family = libMesh::LAGRANGE;
127 libMesh::FEType(fe_order, fe_family),
139 _flight_cond->
mach = 0.5;
145 _flight_cond->
init();
156 _transient_solver =
new MAST::FirstOrderNewmarkTransientSolver;
160 _transient_solver->set_discipline_and_system(*_discipline, *_sys_init);
161 _transient_solver->set_elem_operation_object(*_elem_ops);
198 libmesh_assert(_initialized);
201 n_shape = _sys->n_dofs()/(_dim+2);
206 rand = RealVectorX::Random(n_shape);
208 s = RealVectorX::Zero(_sys->n_dofs());
210 for (
unsigned int i=0; i<n_shape; i++) {
212 s(i) = _flight_cond->
rho() * (1. + _delta * rand(i));
213 s(n_shape+i) = _flight_cond->
rho_u1() * (1. + _delta * rand(i));
214 s(2*n_shape+i) = _flight_cond->
rho_u2() * (1. + _delta * rand(i));
216 s(3*n_shape+i) = _flight_cond->
rho_u3() * (1. + _delta * rand(i));
217 s((_dim+1)*n_shape+i) = _flight_cond->
rho_e() * (1. + _delta * rand(i));
225 libmesh_assert(_initialized);
228 c_sol = RealVectorX::Zero(_dim+2);
230 c_sol(0) = _flight_cond->
rho();
231 c_sol(1) = _flight_cond->
rho_u1();
232 c_sol(2) = _flight_cond->
rho_u2();
234 c_sol(3) = _flight_cond->
rho_u3();
235 c_sol(_dim+1) = _flight_cond->
rho_e();
244 template <
typename ValType>
247 libmesh_assert(_initialized);
256 jac0 = RealMatrixX::Zero(n, n),
257 jac_fd = RealMatrixX::Zero(n, n);
260 v_low = RealVectorX::Zero(n),
261 v_hi = RealVectorX::Zero(n),
262 v0 = RealVectorX::Zero(n),
263 x_low = RealVectorX::Zero(n),
264 x_hi = RealVectorX::Zero(n),
265 x0 = RealVectorX::Zero(n),
266 f0 = RealVectorX::Zero(n),
267 f_low = RealVectorX::Zero(n),
268 f_hi = RealVectorX::Zero(n);
279 val.compute(
true, f0, jac0);
281 for (
unsigned int i=0; i<n; i++) {
289 if (fabs(x0(i)) > 0.)
290 delta = x0(i)*val.frac;
298 if (fabs(v0(i)) > 0.)
299 delta = v0(i)*val.frac;
312 val.compute(
false, f_low, jac0);
319 val.compute(
false, f_hi, jac0);
322 jac_fd.col(i) = (f_hi-f_low)/2./delta;
330 #endif // __mast_fluid_elem_initialization_h__ This class provides the necessary functionality for spatial discretization of the conservative fluid ...
MAST::GeomElem * _geom_elem
This class implements a system for solution of nonlinear systems.
MAST::ConservativeFluidTransientAssemblyElemOperations * _elem_ops
MAST::FlightCondition * _flight_cond
virtual void set_velocity(const RealVectorX &vec, bool if_sens=false)
stores vec as velocity for element level calculations, or its sensitivity if if_sens is true...
Real mach
Flight Mach number.
Class defines the conversion and some basic operations on primitive fluid variables used in calculati...
libMesh::EquationSystems * _eq_sys
MAST::ConservativeFluidDiscipline * _discipline
MAST::BoundaryConditionBase * _far_field_bc
bool check_jacobian(ValType &val)
bool compare_matrix(const RealMatrixX &m0, const RealMatrixX &m, const Real tol)
RealVectorX flow_unit_vector
direction along which flow is defined
void init(bool if_viscous)
libMesh::LibMeshInit * _libmesh_init
void init()
initializes the data structures
libMesh::LibMeshInit & _init
std::set< MAST::BoundaryConditionBase * > _boundary_conditions
MAST::NonlinearSystem * _sys
Matrix< Real, Dynamic, Dynamic > RealMatrixX
MAST::ConservativeFluidElementBase * _fluid_elem
MAST::FirstOrderNewmarkTransientSolver * _transient_solver
virtual void set_discipline_and_system(MAST::PhysicsDisciplineBase &discipline, MAST::SystemInitialization &system)
attaches a system to this discipline
Matrix< Real, Dynamic, 1 > RealVectorX
void init_solution_for_elem(RealVectorX &s)
MAST::TransientAssembly * _assembly
void set_flight_condition(MAST::FlightCondition &flt)
Attaches the flight condition that specifies the far-field flow properties.
void init(const unsigned int dim, const RealVectorX &conservative_sol, const Real cp_val, const Real cv_val, bool if_viscous)
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
MAST::BoundaryConditionBase * _noslip_wall_bc
GasProperty gas_property
Ambient air properties.
void init_primitive_sol(MAST::PrimitiveSolution &s)
Real rho
Property values for ideal gas.
virtual void set_solution(const RealVectorX &vec, bool if_sens=false)
stores vec as solution for element level calculations, or its sensitivity if if_sens is true...
virtual void set_discipline_and_system(MAST::PhysicsDisciplineBase &discipline, MAST::SystemInitialization &system)
attaches a system to this discipline
virtual void init(const libMesh::Elem &elem, const MAST::SystemInitialization &sys_init)
initialize the object for the specified reference elem.
MAST::ConservativeFluidSystemInitialization * _sys_init
libMesh::UnstructuredMesh * _mesh
MAST::BoundaryConditionBase * _slip_wall_bc