1 #include <boost/preprocessor/seq/for_each.hpp> 4 #include "dg_base_state.hpp" 5 #include "physics/model_factory.h" 6 #include "physics/physics_factory.h" 10 template <
int dim,
int nstate,
typename real,
typename MeshType>
12 const unsigned int degree,
const unsigned int max_degree_input,
13 const unsigned int grid_degree_input,
14 const std::shared_ptr<Triangulation> triangulation_input)
15 :
DGBase<dim, real, MeshType>::
DGBase(nstate, parameters_input, degree, max_degree_input, grid_degree_input,
40 template <
int dim,
int nstate,
typename real,
typename MeshType>
74 template <
int dim,
int nstate,
typename real,
typename MeshType>
90 template <
int dim,
int nstate,
typename real,
typename MeshType>
110 template <
int dim,
int nstate,
typename real,
typename MeshType>
117 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
118 const dealii::UpdateFlags update_flags = dealii::update_values | dealii::update_JxW_values;
119 dealii::hp::FEValues<dim, dim> fe_values_collection_volume(mapping_collection, this->
fe_collection,
123 for (
auto cell : this->
dof_handler.active_cell_iterators()) {
124 if (!(cell->is_locally_owned() || cell->is_ghost()))
continue;
127 const int i_fele = cell->active_fe_index();
128 const int i_quad = i_fele;
129 const int i_mapp = 0;
130 fe_values_collection_volume.reinit(cell, i_quad, i_mapp, i_fele);
131 const dealii::FEValues<dim, dim> &fe_values_volume = fe_values_collection_volume.get_present_fe_values();
134 const dealii::FESystem<dim, dim> &fe_high = this->
fe_collection[i_fele];
135 const unsigned int cell_poly_degree = fe_high.tensor_degree();
138 const dealii::Quadrature<dim> &quadrature = fe_values_volume.get_quadrature();
139 const unsigned int n_quad_pts = quadrature.size();
140 const std::vector<real> &JxW = fe_values_volume.get_JxW_values();
141 real cell_volume_estimate = 0.0;
142 for (
unsigned int iquad = 0; iquad < n_quad_pts; ++iquad) {
143 cell_volume_estimate = cell_volume_estimate + JxW[iquad];
148 const dealii::types::global_dof_index cell_index = cell->active_cell_index();
157 pde_model_fad->cellwise_poly_degree[cell_index] = cell_poly_degree;
160 pde_model_rad->cellwise_poly_degree[cell_index] = cell_poly_degree;
181 template <
int dim,
int nstate,
typename real,
typename MeshType>
186 template <
int dim,
int nstate,
typename real,
typename MeshType>
188 const real artificial_dissipation,
const real cell_diameter,
189 const unsigned int cell_degree) {
190 const unsigned int n_pts = soln_at_q.size();
191 std::vector<real> convective_eigenvalues(n_pts);
192 std::vector<real> viscosities(n_pts);
193 for (
unsigned int isol = 0; isol < n_pts; ++isol) {
194 convective_eigenvalues[isol] =
pde_physics_double->max_convective_eigenvalue(soln_at_q[isol]);
197 const real max_eig = *(std::max_element(convective_eigenvalues.begin(), convective_eigenvalues.end()));
198 const real max_diffusive = *(std::max_element(viscosities.begin(), viscosities.end()));
204 const unsigned int p = std::max((
unsigned int)1, cell_degree);
205 const real cfl_convective = (cell_diameter / max_eig) / (2 * p + 1);
206 const real cfl_diffusive = artificial_dissipation != 0.0
207 ? (0.5 * cell_diameter * cell_diameter / artificial_dissipation) / (p * p * p * p)
209 Parameters::ODESolverParam::ODESolverEnum::implicit_solver)
211 (0.5 * cell_diameter * cell_diameter / max_diffusive) / (2 * p + 1)
213 real min_cfl = std::min(cfl_convective, cfl_diffusive);
215 if (min_cfl >= 1e190) min_cfl = cell_diameter / 1;
221 #define POSSIBLE_NSTATE (1)(2)(3)(4)(5)(6) 224 #define INSTANTIATE_DISTRIBUTED(r, data, index) \ 225 template class DGBaseState <PHILIP_DIM, index, double, dealii::parallel::distributed::Triangulation<PHILIP_DIM>>; 228 BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_DISTRIBUTED, _, POSSIBLE_NSTATE)
231 #define INSTANTIATE_SHARED(r, data, index) \ 232 template class DGBaseState <PHILIP_DIM, index, double, dealii::parallel::shared::Triangulation<PHILIP_DIM>>; 233 BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_SHARED, _, POSSIBLE_NSTATE)
235 #define INSTANTIATE_TRIA(r, data, index) \ 236 template class DGBaseState <PHILIP_DIM, index, double, dealii::Triangulation<PHILIP_DIM>>; 237 BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_TRIA, _, POSSIBLE_NSTATE)
PartialDifferentialEquation pde_type
Store the PDE type to be solved.
DGBaseState(const Parameters::AllParameters *const parameters_input, const unsigned int degree, const unsigned int max_degree_input, const unsigned int grid_degree_input, const std::shared_ptr< Triangulation > triangulation_input)
< Input parameters.
bool use_auxiliary_eq
Flag for using the auxiliary equation.
std::unique_ptr< NumericalFlux::NumericalFluxDissipative< dim, nstate, real > > diss_num_flux_double
Dissipative numerical flux with real type.
void set_use_auxiliary_eq()
Set use_auxiliary_eq flag.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
Base class from which Advection, Diffusion, ConvectionDiffusion, and Euler is derived.
static std::unique_ptr< NumericalFluxConvective< dim, nstate, real > > create_convective_numerical_flux(const AllParam::ConvectiveNumericalFlux conv_num_flux_type, const AllParam::PartialDifferentialEquation pde_type, const AllParam::ModelType model_type, std::shared_ptr< Physics::PhysicsBase< dim, nstate, real >> physics_input)
Creates convective numerical flux (baseline flux + upwind term) based on input.
void update_model_variables()
Update the necessary variables declared in src/physics/model.h.
std::unique_ptr< NumericalFlux::NumericalFluxConvective< dim, nstate, FadFadType > > conv_num_flux_fad_fad
Convective numerical flux with FadFadType.
std::unique_ptr< NumericalFlux::NumericalFluxConvective< dim, nstate, real > > conv_num_flux_double
Convective numerical flux with real type.
std::shared_ptr< Triangulation > triangulation
Mesh.
std::unique_ptr< NumericalFlux::NumericalFluxConvective< dim, nstate, FadType > > conv_num_flux_fad
Convective numerical flux with FadType.
Files for the baseline physics.
static std::unique_ptr< NumericalFluxDissipative< dim, nstate, real > > create_dissipative_numerical_flux(const AllParam::DissipativeNumericalFlux diss_num_flux_type, std::shared_ptr< Physics::PhysicsBase< dim, nstate, real >> physics_input, std::shared_ptr< ArtificialDissipationBase< dim, nstate >> artificial_dissipation_input)
Creates dissipative numerical flux based on input.
std::shared_ptr< Physics::ModelBase< dim, nstate, FadFadType > > pde_model_fad_fad
Contains the model terms of the PDEType == PhysicsModel with FadFadType.
std::shared_ptr< Physics::ModelBase< dim, nstate, real > > pde_model_double
Contains the model terms of the PDEType == PhysicsModel with real type.
std::unique_ptr< NumericalFlux::NumericalFluxConvective< dim, nstate, RadFadType > > conv_num_flux_rad_fad
Convective numerical flux with RadFadDtype.
MPI_Comm mpi_communicator
MPI communicator.
Main parameter class that contains the various other sub-parameter classes.
void reset_numerical_fluxes()
Reinitializes the numerical fluxes based on the current physics.
std::unique_ptr< NumericalFlux::NumericalFluxDissipative< dim, nstate, RadFadType > > diss_num_flux_rad_fad
Dissipative numerical flux with RadFadDtype.
static std::shared_ptr< ArtificialDissipationBase< dim, nstate > > create_artificial_dissipation(const Parameters::AllParameters *const parameters_input)
Creates artificial dissipation type depending on input parameters.
std::shared_ptr< Physics::PhysicsBase< dim, nstate, FadFadType > > pde_physics_fad_fad
Contains the physics of the PDE with FadFadType.
ODESolverParam ode_solver_param
Contains parameters for ODE solver.
std::shared_ptr< Physics::ModelBase< dim, nstate, RadFadType > > pde_model_rad_fad
Contains the model terms of the PDEType == PhysicsModel with RadFadType.
std::shared_ptr< Physics::PhysicsBase< dim, nstate, real > > pde_physics_double
Contains the physics of the PDE with real type.
void allocate_model_variables()
Allocate the necessary variables declared in src/physics/model.h.
std::shared_ptr< Physics::PhysicsBase< dim, nstate, RadType > > pde_physics_rad
Contains the physics of the PDE with RadType.
static std::shared_ptr< ModelBase< dim, nstate, real > > create_Model(const Parameters::AllParameters *const parameters_input)
Factory to return the correct model given input parameters.
std::shared_ptr< ArtificialDissipationBase< dim, nstate > > artificial_dissip
Link to Artificial dissipation class (with three dissipation types, depending on the input)...
std::shared_ptr< HighOrderGrid< dim, real, MeshType > > high_order_grid
High order grid that will provide the MappingFEField.
real evaluate_CFL(std::vector< std::array< real, nstate > > soln_at_q, const real artificial_dissipation, const real cell_diameter, const unsigned int cell_degree)
Evaluate the time it takes for the maximum wavespeed to cross the cell domain.
std::shared_ptr< Physics::PhysicsBase< dim, nstate, RadFadType > > pde_physics_rad_fad
Contains the physics of the PDE with RadFadDtype.
std::unique_ptr< NumericalFlux::NumericalFluxDissipative< dim, nstate, FadType > > diss_num_flux_fad
Dissipative numerical flux with FadType.
std::shared_ptr< Physics::ModelBase< dim, nstate, FadType > > pde_model_fad
Contains the model terms of the PDEType == PhysicsModel with FadType.
std::unique_ptr< NumericalFlux::NumericalFluxDissipative< dim, nstate, RadType > > diss_num_flux_rad
Dissipative numerical flux with RadType.
static std::shared_ptr< PhysicsBase< dim, nstate, real > > create_Physics(const Parameters::AllParameters *const parameters_input, std::shared_ptr< ModelBase< dim, nstate, real > > model_input=nullptr)
Factory to return the correct physics given input file.
std::shared_ptr< Physics::ModelBase< dim, nstate, RadType > > pde_model_rad
Contains the model terms of the PDEType == PhysicsModel with RadType.
std::unique_ptr< NumericalFlux::NumericalFluxDissipative< dim, nstate, FadFadType > > diss_num_flux_fad_fad
Dissipative numerical flux with FadFadType.
std::shared_ptr< Physics::PhysicsBase< dim, nstate, FadType > > pde_physics_fad
Contains the physics of the PDE with FadType.
ConvectiveNumericalFlux conv_num_flux_type
Store convective flux type.
ODESolverEnum ode_solver_type
ODE solver type.
dealii::DoFHandler< dim > dof_handler
Finite Element Collection to represent the high-order grid.
std::unique_ptr< NumericalFlux::NumericalFluxConvective< dim, nstate, RadType > > conv_num_flux_rad
Convective numerical flux with RadType.
DissipativeNumericalFlux diss_num_flux_type
Store diffusive flux type.
dealii::Vector< double > cell_volume
Time it takes for the maximum wavespeed to cross the cell domain.
ModelType model_type
Store the model type.
DGBase is independent of the number of state variables.
dealii::hp::QCollection< dim > volume_quadrature_collection
Finite Element Collection to represent the high-order grid.
void set_physics(std::shared_ptr< Physics::PhysicsBase< dim, nstate, real > > pde_physics_double_input, std::shared_ptr< Physics::PhysicsBase< dim, nstate, FadType > > pde_physics_fad_input, std::shared_ptr< Physics::PhysicsBase< dim, nstate, RadType > > pde_physics_rad_input, std::shared_ptr< Physics::PhysicsBase< dim, nstate, FadFadType > > pde_physics_fad_fad_input, std::shared_ptr< Physics::PhysicsBase< dim, nstate, RadFadType > > pde_physics_rad_fad_input)
const dealii::hp::FECollection< dim > fe_collection
Finite Element Collection for p-finite-element to represent the solution.