Skip to content

Commit 1bed06d

Browse files
authored
Restructuring PeriodicCubeFlow (#139)
* restructuring PeriodicCubeFlow and deriving new PeriodicTurbulence class; all affected tests passing * removing is_taylor_green_vortex from PeriodicCubeFlow * renaming domain_volume as domain_size * Addressing PR comment; moving integrated quantity functions to PeriodicTurbulence * addressing PR comments; cleaned up FlowSolver related template instantiations; correcting scope in Burgers related flow cases (.h files) to be consistent with base class
1 parent df23583 commit 1bed06d

13 files changed

+238
-149
lines changed

src/testing/flow_solver.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,6 @@ int FlowSolver<dim,nstate>::run_test() const
431431
return 0;
432432
}
433433

434-
template class FlowSolver <PHILIP_DIM,PHILIP_DIM>;
435-
template class FlowSolver <PHILIP_DIM,PHILIP_DIM+2>;
436-
437434
//=========================================================
438435
// FLOW SOLVER FACTORY
439436
//=========================================================
@@ -448,7 +445,7 @@ ::create_FlowSolver(const Parameters::AllParameters *const parameters_input,
448445
const FlowCaseEnum flow_type = parameters_input->flow_solver_param.flow_case_type;
449446
if (flow_type == FlowCaseEnum::taylor_green_vortex){
450447
if constexpr (dim==3 && nstate==dim+2){
451-
std::shared_ptr<FlowSolverCaseBase<dim, nstate>> flow_solver_case = std::make_shared<PeriodicCubeFlow<dim,nstate>>(parameters_input);
448+
std::shared_ptr<FlowSolverCaseBase<dim, nstate>> flow_solver_case = std::make_shared<PeriodicTurbulence<dim,nstate>>(parameters_input);
452449
return std::make_unique<FlowSolver<dim,nstate>>(parameters_input, flow_solver_case, parameter_handler_input);
453450
}
454451
} else if (flow_type == FlowCaseEnum::burgers_viscous_snapshot){
@@ -473,8 +470,15 @@ ::create_FlowSolver(const Parameters::AllParameters *const parameters_input,
473470
return nullptr;
474471
}
475472

473+
#if PHILIP_DIM==1
474+
template class FlowSolver <PHILIP_DIM,PHILIP_DIM>;
476475
template class FlowSolverFactory <PHILIP_DIM,PHILIP_DIM>;
476+
#endif
477+
478+
#if PHILIP_DIM!=1
479+
template class FlowSolver <PHILIP_DIM,PHILIP_DIM+2>;
477480
template class FlowSolverFactory <PHILIP_DIM,PHILIP_DIM+2>;
481+
#endif
478482

479483

480484
} // Tests namespace

src/testing/flow_solver_cases/1D_burgers_rewienski_snapshot.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ std::shared_ptr<Triangulation> BurgersRewienskiSnapshot<dim,nstate>::generate_gr
3737
const bool colorize = true;
3838
dealii::GridGenerator::hyper_cube(*grid, domain_left, domain_right, colorize);
3939
grid->refine_global(number_of_refinements);
40+
41+
return grid;
42+
}
43+
44+
template <int dim, int nstate>
45+
void BurgersRewienskiSnapshot<dim,nstate>::display_additional_flow_case_specific_parameters(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> /*initial_condition*/) const
46+
{
4047
// Display the information about the grid
4148
this->pcout << "\n- GRID INFORMATION:" << std::endl;
4249
this->pcout << "- - Domain dimensionality: " << dim << std::endl;
4350
this->pcout << "- - Domain left: " << domain_left << std::endl;
4451
this->pcout << "- - Domain right: " << domain_right << std::endl;
4552
this->pcout << "- - Number of refinements: " << number_of_refinements << std::endl;
46-
47-
return grid;
4853
}
4954

5055
template <int dim, int nstate>

src/testing/flow_solver_cases/1D_burgers_rewienski_snapshot.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class BurgersRewienskiSnapshot: public FlowSolverCaseBase<dim, nstate>
3030
/// Destructor
3131
~BurgersRewienskiSnapshot() {};
3232

33-
protected:
34-
const int number_of_refinements; ///< Number of cells per direction for the grid
35-
const double domain_left; ///< Domain left-boundary value for generating the grid
36-
const double domain_right; ///< Domain right-boundary value for generating the grid
37-
3833
/// Function to generate the grid
3934
std::shared_ptr<Triangulation> generate_grid() const override;
4035

@@ -48,6 +43,13 @@ class BurgersRewienskiSnapshot: public FlowSolverCaseBase<dim, nstate>
4843
/// Function for postprocessing when solving for steady state
4944
void steady_state_postprocessing(std::shared_ptr <DGBase<dim, double>> dg) const override;
5045

46+
protected:
47+
const int number_of_refinements; ///< Number of cells per direction for the grid
48+
const double domain_left; ///< Domain left-boundary value for generating the grid
49+
const double domain_right; ///< Domain right-boundary value for generating the grid
50+
51+
/// Display additional more specific flow case parameters
52+
void display_additional_flow_case_specific_parameters(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const override;
5153
};
5254

5355
} // Tests namespace

src/testing/flow_solver_cases/1d_burgers_viscous_snapshot.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ std::shared_ptr<Triangulation> BurgersViscousSnapshot<dim,nstate>::generate_grid
3636
const bool colorize = true;
3737
dealii::GridGenerator::hyper_cube(*grid, domain_left, domain_right, colorize);
3838
grid->refine_global(number_of_refinements);
39+
40+
return grid;
41+
}
42+
43+
template <int dim, int nstate>
44+
void BurgersViscousSnapshot<dim,nstate>::display_additional_flow_case_specific_parameters(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> /*initial_condition*/) const
45+
{
3946
// Display the information about the grid
4047
this->pcout << "\n- GRID INFORMATION:" << std::endl;
4148
this->pcout << "- - Domain dimensionality: " << dim << std::endl;
4249
this->pcout << "- - Domain left: " << domain_left << std::endl;
4350
this->pcout << "- - Domain right: " << domain_right << std::endl;
4451
this->pcout << "- - Number of refinements: " << number_of_refinements << std::endl;
45-
46-
return grid;
4752
}
4853

4954
template <int dim, int nstate>

src/testing/flow_solver_cases/1d_burgers_viscous_snapshot.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class BurgersViscousSnapshot: public FlowSolverCaseBase<dim, nstate>
3030
/// Destructor
3131
~BurgersViscousSnapshot() {};
3232

33-
protected:
34-
const int number_of_refinements; ///< Number of cells per direction for the grid
35-
const double domain_left; ///< Domain left-boundary value for generating the grid
36-
const double domain_right; ///< Domain right-boundary value for generating the grid
37-
3833
/// Virtual function to generate the grid
3934
std::shared_ptr<Triangulation> generate_grid() const override;
4035

@@ -45,6 +40,13 @@ class BurgersViscousSnapshot: public FlowSolverCaseBase<dim, nstate>
4540
const std::shared_ptr <DGBase<dim, double>> dg,
4641
const std::shared_ptr<dealii::TableHandler> unsteady_data_table) const override;
4742

43+
protected:
44+
const int number_of_refinements; ///< Number of cells per direction for the grid
45+
const double domain_left; ///< Domain left-boundary value for generating the grid
46+
const double domain_right; ///< Domain right-boundary value for generating the grid
47+
48+
/// Display additional more specific flow case parameters
49+
void display_additional_flow_case_specific_parameters(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const override;
4850
};
4951

5052
} // Tests namespace

src/testing/flow_solver_cases/flow_solver_case_base.cpp

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,59 @@ FlowSolverCaseBase<dim, nstate>::FlowSolverCaseBase(const PHiLiP::Parameters::Al
1212
, pcout(std::cout, mpi_rank==0)
1313
{}
1414

15-
16-
template <int dim, int nstate>
17-
void FlowSolverCaseBase<dim,nstate>::display_flow_solver_setup(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> /*initial_condition*/) const
15+
template<int dim, int nstate>
16+
std::string FlowSolverCaseBase<dim, nstate>::get_pde_string() const
1817
{
1918
using PDE_enum = Parameters::AllParameters::PartialDifferentialEquation;
20-
const PDE_enum pde_type = all_param.pde_type;
19+
20+
const PDE_enum pde_type = this->all_param.pde_type;
2121
std::string pde_string;
22+
if (pde_type == PDE_enum::advection) {pde_string = "advection";}
23+
if (pde_type == PDE_enum::advection_vector) {pde_string = "advection_vector";}
24+
if (pde_type == PDE_enum::diffusion) {pde_string = "diffusion";}
25+
if (pde_type == PDE_enum::convection_diffusion) {pde_string = "convection_diffusion";}
26+
if (pde_type == PDE_enum::burgers_inviscid) {pde_string = "burgers_inviscid";}
27+
if (pde_type == PDE_enum::burgers_viscous) {pde_string = "burgers_viscous";}
28+
if (pde_type == PDE_enum::burgers_rewienski) {pde_string = "burgers_rewienski";}
29+
if (pde_type == PDE_enum::mhd) {pde_string = "mhd";}
2230
if (pde_type == PDE_enum::euler) {pde_string = "euler";}
2331
if (pde_type == PDE_enum::navier_stokes) {pde_string = "navier_stokes";}
24-
if (pde_type == PDE_enum::burgers_rewienski) {pde_string = "burgers_rewienski";}
25-
if (pde_type == PDE_enum::burgers_viscous) {pde_string = "burgers_viscous";}
26-
pcout << "- PDE Type: " << pde_string << std::endl;
32+
33+
return pde_string;
34+
}
35+
36+
template<int dim, int nstate>
37+
std::string FlowSolverCaseBase<dim, nstate>::get_flow_case_string() const
38+
{
39+
// Get the flow case type
40+
using FlowCaseEnum = Parameters::FlowSolverParam::FlowCaseType;
41+
const FlowCaseEnum flow_case_type = this->all_param.flow_solver_param.flow_case_type;
42+
43+
std::string flow_case_string;
44+
if (flow_case_type == FlowCaseEnum::taylor_green_vortex) {flow_case_string = "taylor_green_vortex";}
45+
if (flow_case_type == FlowCaseEnum::burgers_viscous_snapshot) {flow_case_string = "burgers_viscous_snapshot";}
46+
if (flow_case_type == FlowCaseEnum::burgers_rewienski_snapshot) {flow_case_string = "burgers_rewienski_snapshot";}
47+
if (flow_case_type == FlowCaseEnum::naca0012) {flow_case_string = "naca0012";}
48+
49+
return flow_case_string;
50+
}
51+
52+
template <int dim, int nstate>
53+
void FlowSolverCaseBase<dim,nstate>::display_flow_solver_setup(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const
54+
{
55+
const std::string pde_string = this->get_pde_string();
56+
pcout << "- PDE Type: " << pde_string << " " << "(dim=" << dim << ", nstate=" << nstate << ")" << std::endl;
2757
pcout << "- Polynomial degree: " << this->all_param.grid_refinement_study_param.poly_degree << std::endl;
28-
pcout << "- Final time: " << this->all_param.flow_solver_param.final_time << std::endl;
58+
const std::string flow_case_string = this->get_flow_case_string();
59+
pcout << "- Flow case: " << flow_case_string << " " << std::flush;
60+
if(this->all_param.flow_solver_param.steady_state == true) {
61+
pcout << "(Steady state)" << std::endl;
62+
} else {
63+
pcout << "(Unsteady)" << std::endl;
64+
pcout << "- - Final time: " << this->all_param.flow_solver_param.final_time << std::endl;
65+
}
66+
67+
this->display_additional_flow_case_specific_parameters(initial_condition);
2968
}
3069

3170
template <int dim, int nstate>
@@ -59,15 +98,11 @@ void FlowSolverCaseBase<dim, nstate>::compute_unsteady_data_and_write_to_table(
5998

6099

61100
#if PHILIP_DIM==1
62-
template class FlowSolverCaseBase<PHILIP_DIM,PHILIP_DIM>;
63-
#endif
64-
65-
#if PHILIP_DIM==2
66-
template class FlowSolverCaseBase<PHILIP_DIM,PHILIP_DIM+2>;
101+
template class FlowSolverCaseBase<PHILIP_DIM,PHILIP_DIM>;
67102
#endif
68103

69-
#if PHILIP_DIM==3
70-
template class FlowSolverCaseBase<PHILIP_DIM,PHILIP_DIM+2>;
104+
#if PHILIP_DIM!=1
105+
template class FlowSolverCaseBase<PHILIP_DIM,PHILIP_DIM+2>;
71106
#endif
72107

73108
}

src/testing/flow_solver_cases/flow_solver_case_base.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class FlowSolverCaseBase
2626
FlowSolverCaseBase(const Parameters::AllParameters *const parameters_input);
2727

2828
/// Destructor
29-
virtual ~FlowSolverCaseBase() {};
29+
~FlowSolverCaseBase() {};
3030

3131
/// Displays the flow setup parameters
32-
virtual void display_flow_solver_setup(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const;
32+
void display_flow_solver_setup(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const;
3333

3434
/// Pure Virtual function to generate the grid
3535
virtual std::shared_ptr<Triangulation> generate_grid() const = 0;
@@ -60,6 +60,17 @@ class FlowSolverCaseBase
6060
/** Used as std::cout, but only prints if mpi_rank == 0
6161
*/
6262
dealii::ConditionalOStream pcout;
63+
64+
/// Display additional more specific flow case parameters
65+
virtual void display_additional_flow_case_specific_parameters(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const = 0;
66+
67+
private:
68+
/// Returns the pde type string from the all_param class member
69+
std::string get_pde_string() const;
70+
71+
/// Returns the flow case type string from the all_param class member
72+
std::string get_flow_case_string() const;
73+
6374
};
6475

6576
} // Tests namespace

src/testing/flow_solver_cases/naca0012.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,22 @@ NACA0012<dim, nstate>::NACA0012(const PHiLiP::Parameters::AllParameters *const p
2828
}
2929

3030
template <int dim, int nstate>
31-
void NACA0012<dim,nstate>::display_flow_solver_setup(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const
31+
void NACA0012<dim,nstate>::display_additional_flow_case_specific_parameters(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const
3232
{
3333
using PDE_enum = Parameters::AllParameters::PartialDifferentialEquation;
3434
const PDE_enum pde_type = this->all_param.pde_type;
35-
const double pi = atan(1.0) * 4.0;
36-
std::string pde_string;
37-
if (pde_type == PDE_enum::euler) {pde_string = "euler";}
38-
if (pde_type == PDE_enum::navier_stokes) {pde_string = "navier_stokes";}
39-
this->pcout << "- PDE Type: " << pde_string << std::endl;
40-
this->pcout << "- Polynomial degree: " << this->all_param.grid_refinement_study_param.poly_degree << std::endl;
4135
if (pde_type == PDE_enum::navier_stokes){
42-
this->pcout << "- Freestream Reynolds number: " << this->all_param.navier_stokes_param.reynolds_number_inf << std::endl;
36+
this->pcout << "- - Freestream Reynolds number: " << this->all_param.navier_stokes_param.reynolds_number_inf << std::endl;
4337
}
44-
this->pcout << "- Courant-Friedrich-Lewy number: " << this->all_param.flow_solver_param.courant_friedrich_lewy_number << std::endl;
45-
this->pcout << "- Freestream Mach number: " << this->all_param.euler_param.mach_inf << std::endl;
46-
this->pcout << "- Angle of attack: " << this->all_param.euler_param.angle_of_attack*180/pi << std::endl;
47-
this->pcout << "- Side-slip angle: " << this->all_param.euler_param.side_slip_angle*180/pi << std::endl;
48-
this->pcout << "- Farfield conditions: " << std::endl;
38+
this->pcout << "- - Courant-Friedrich-Lewy number: " << this->all_param.flow_solver_param.courant_friedrich_lewy_number << std::endl;
39+
this->pcout << "- - Freestream Mach number: " << this->all_param.euler_param.mach_inf << std::endl;
40+
const double pi = atan(1.0) * 4.0;
41+
this->pcout << "- - Angle of attack [deg]: " << this->all_param.euler_param.angle_of_attack*180/pi << std::endl;
42+
this->pcout << "- - Side-slip angle [deg]: " << this->all_param.euler_param.side_slip_angle*180/pi << std::endl;
43+
this->pcout << "- - Farfield conditions: " << std::endl;
4944
const dealii::Point<dim> dummy_point;
5045
for (int s=0;s<nstate;s++) {
51-
this->pcout << " - State " << s << "; Value: " << initial_condition->value(dummy_point, s) << std::endl;
46+
this->pcout << "- - - State " << s << "; Value: " << initial_condition->value(dummy_point, s) << std::endl;
5247
}
5348
}
5449

src/testing/flow_solver_cases/naca0012.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ class NACA0012 : public FlowSolverCaseBase<dim,nstate>
2929
/// Destructor
3030
~NACA0012() {};
3131

32-
protected:
33-
/// Displays the flow setup parameters
34-
void display_flow_solver_setup(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const override;
35-
3632
/// Function to generate the grid
3733
std::shared_ptr<Triangulation> generate_grid() const override;
3834

@@ -42,6 +38,9 @@ class NACA0012 : public FlowSolverCaseBase<dim,nstate>
4238
/// Will compute and print lift and drag coefficients
4339
void steady_state_postprocessing(std::shared_ptr <DGBase<dim, double>> dg) const override;
4440

41+
protected:
42+
/// Display additional more specific flow case parameters
43+
void display_additional_flow_case_specific_parameters(std::shared_ptr<InitialConditionFunction<dim,nstate,double>> initial_condition) const override;
4544
};
4645

4746
} // Tests namespace

0 commit comments

Comments
 (0)