[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
dual_weighted_residual_mesh_adaptation.cpp
1 #include <stdlib.h> /* srand, rand */
2 #include <iostream>
3 #include "dual_weighted_residual_mesh_adaptation.h"
4 #include "flow_solver/flow_solver_factory.h"
5 
6 namespace PHiLiP {
7 namespace Tests {
8 
9 template <int dim, int nstate>
11  const Parameters::AllParameters *const parameters_input,
12  const dealii::ParameterHandler &parameter_handler_input)
13  : TestsBase::TestsBase(parameters_input)
14  , parameter_handler(parameter_handler_input)
15 {}
16 
17 template <int dim, int nstate>
19 {
21  bool use_mesh_adaptation = param.mesh_adaptation_param.total_mesh_adaptation_cycles > 0;
23  ManParam manu_grid_conv_param = param.manufactured_convergence_study_param;
24 
25  bool check_for_p_refined_cell = false;
26 
27  using MeshAdaptationTypeEnum = Parameters::MeshAdaptationParam::MeshAdaptationType;
28  MeshAdaptationTypeEnum mesh_adaptation_type = param.mesh_adaptation_param.mesh_adaptation_type;
29  if(mesh_adaptation_type == MeshAdaptationTypeEnum::p_adaptation)
30  {
31  check_for_p_refined_cell = true;
32  }
33 
34  if(!use_mesh_adaptation)
35  {
36  pcout<<"This test case checks mesh adaptation. However, total mesh adaptation cycles have been set to 0 in the parameters file. Aborting..."<<std::endl;
37  std::abort();
38  }
39 
40  std::unique_ptr<FlowSolver::FlowSolver<dim,nstate>> flow_solver = FlowSolver::FlowSolverFactory<dim,nstate>::select_flow_case(&param, parameter_handler);
41  flow_solver->run();
42 
43  // Check location of the most refined cell
44  dealii::Point<dim> refined_cell_coord = flow_solver->dg->coordinates_of_highest_refined_cell(check_for_p_refined_cell);
45  pcout<<" Coordinates of the most refined cell (x,y) = ("<<refined_cell_coord[0]<<", "<<refined_cell_coord[1]<<")"<<std::endl;
46  // Check if the mesh is refined near the shock i.e x,y in [0.3,0.6].
47  if ((refined_cell_coord[0] > 0.3) && (refined_cell_coord[0] < 0.6) && (refined_cell_coord[1] > 0.3) && (refined_cell_coord[1] < 0.6))
48  {
49  pcout<<"Mesh is refined near the shock. Test passed!"<<std::endl;
50  return 0; // Mesh adaptation test passed.
51  }
52  else
53  {
54  pcout<<"Mesh Adaptation has failed."<<std::endl;
55  return 1; // Mesh adaptation failed.
56  }
57 }
58 
59 #if PHILIP_DIM==2
61 #endif
62 
63 } // namespace Tests
64 } // namespace PHiLiP
65 
Parameters related to the manufactured convergence study.
DualWeightedResidualMeshAdaptation(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler &parameter_handler_input)
Constructor of DualWeightedResidualConvergence.
int total_mesh_adaptation_cycles
Total/maximum number of mesh adaptation cycles while solving a problem.
Files for the baseline physics.
Definition: ADTypes.hpp:10
const dealii::ParameterHandler & parameter_handler
Parameter handler.
Main parameter class that contains the various other sub-parameter classes.
MeshAdaptationParam mesh_adaptation_param
Constains parameters for mesh adaptation.
MeshAdaptationType mesh_adaptation_type
Selection of mesh adaptation type.
ManufacturedConvergenceStudyParam manufactured_convergence_study_param
Contains parameters for manufactured convergence study.
MeshAdaptationType
Choices for mesh adaptation to be used.
static std::unique_ptr< FlowSolver< dim, nstate > > select_flow_case(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler &parameter_handler_input)
Factory to return the correct flow solver given input file.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
Definition: tests.h:20
int run_test() const
Runs the test to check the location of refined cell after performing goal-oriented mesh adaptation...
Test to check the goal-oriented mesh adaptation locations for various manufactured solutions...
dealii::ConditionalOStream pcout
ConditionalOStream.
Definition: tests.h:45
Base class of all the tests.
Definition: tests.h:17