ExaDG
Loading...
Searching...
No Matches
fluid.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2023 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef EXADG_AERO_ACOUSTIC_SINGLE_FIELD_SOLVERS_FLUID_H_
23#define EXADG_AERO_ACOUSTIC_SINGLE_FIELD_SOLVERS_FLUID_H_
24
25// ExaDG
26#include <exadg/aero_acoustic/user_interface/application_base.h>
27#include <exadg/incompressible_navier_stokes/postprocessor/postprocessor.h>
28#include <exadg/incompressible_navier_stokes/spatial_discretization/create_operator.h>
29#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_coupled.h>
30#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_dual_splitting.h>
31#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_pressure_correction.h>
32#include <exadg/incompressible_navier_stokes/time_integration/create_time_integrator.h>
33#include <exadg/incompressible_navier_stokes/time_integration/time_int_bdf_coupled_solver.h>
34#include <exadg/incompressible_navier_stokes/time_integration/time_int_bdf_dual_splitting.h>
35#include <exadg/incompressible_navier_stokes/time_integration/time_int_bdf_pressure_correction.h>
36#include <exadg/utilities/timer_tree.h>
37
38namespace ExaDG
39{
40namespace AeroAcoustic
41{
42template<int dim, typename Number>
43class SolverFluid
44{
45public:
46 using VectorType = dealii::LinearAlgebra::distributed::Vector<Number>;
47
48 SolverFluid()
49 : timer_tree(std::make_shared<TimerTree>()),
50 adaptive_time_stepping_limiting_factor(std::numeric_limits<double>::min())
51 {
52 }
53
54 void
55 setup(std::shared_ptr<FluidAeroAcoustic::ApplicationBase<dim, Number>> application,
56 MPI_Comm const mpi_comm,
57 bool const is_test)
58 {
59 // setup application
60 application->setup(grid, mapping, multigrid_mappings);
61
62 // initialize pde_operator
63 pde_operator = IncNS::create_operator<dim, Number>(grid,
64 mapping,
65 multigrid_mappings,
66 application->get_boundary_descriptor(),
67 application->get_field_functions(),
68 application->get_parameters(),
69 "fluid",
70 mpi_comm);
71
72 // setup Navier-Stokes operator
73 pde_operator->setup();
74
75 // setup postprocessor
76 postprocessor = application->create_postprocessor();
77 postprocessor->setup(*pde_operator);
78
79 // setup time integrator before calling setup_solvers (this is necessary since the setup
80 // of the solvers depends on quantities such as the time_step_size or gamma0!)
81 AssertThrow(application->get_parameters().solver_type == IncNS::SolverType::Unsteady,
82 dealii::ExcMessage("Invalid parameter in context of fluid-structure interaction."));
83
84 // initialize time_integrator
85 time_integrator = IncNS::create_time_integrator<dim, Number>(pde_operator,
86 nullptr /*no ALE*/,
87 postprocessor,
88 application->get_parameters(),
89 mpi_comm,
90 is_test);
91
92 time_integrator->setup(application->get_parameters().restarted_simulation);
93
94 // initialize vector that stores the pressure time derivative
95 pde_operator->initialize_vector_pressure(pressure_time_derivative);
96
97 // store the adaptive time-stepping limiting factor
98 adaptive_time_stepping_limiting_factor =
99 application->get_parameters().adaptive_time_stepping_limiting_factor;
100 }
101
102 double
103 max_next_time_step_size() const
104 {
105 const auto dt = time_integrator->get_time_step_size();
106 return dt * adaptive_time_stepping_limiting_factor;
107 }
108
109 void
110 advance_one_timestep_and_compute_pressure_time_derivative(bool const update_dpdt)
111 {
112 time_integrator->advance_one_timestep_pre_solve(true);
113 time_integrator->advance_one_timestep_solve();
114
115 // The pressure time derivative has to be computed before the push back
116 // of pressure vectors that is triggered in advance_one_timestep_post_solve()
117 if(update_dpdt)
118 {
119 std::vector<VectorType const *> pressures;
120 std::vector<double> times;
121 time_integrator->get_pressures_and_times_np(pressures, times);
122
123 compute_bdf_time_derivative(pressure_time_derivative, pressures, times);
124 }
125
126 time_integrator->advance_one_timestep_post_solve();
127 }
128
129 VectorType const &
130 get_pressure_time_derivative() const
131 {
132 return pressure_time_derivative;
133 }
134
135 // grid and mapping
136 std::shared_ptr<Grid<dim>> grid;
137 std::shared_ptr<dealii::Mapping<dim>> mapping;
138
139 std::shared_ptr<MultigridMappings<dim, Number>> multigrid_mappings;
140
141 // spatial discretization
142 std::shared_ptr<IncNS::SpatialOperatorBase<dim, Number>> pde_operator;
143
144 // temporal discretization
145 std::shared_ptr<IncNS::TimeIntBDF<dim, Number>> time_integrator;
146
147 // Postprocessor
148 std::shared_ptr<IncNS::PostProcessorBase<dim, Number>> postprocessor;
149
150 // Computation time (wall clock time).
151 std::shared_ptr<TimerTree> timer_tree;
152
153private:
154 // The aeroacoustic source term needs the pressure time derivative.
155 // The update of the vector is performed using
156 // advance_one_timestep_and_compute_pressure_time_derivative(true).
157 VectorType pressure_time_derivative;
158
159 // To be able to estimate if dp/dt has to be evaluated we have to
160 // estimate the maximum time-step size that can be performed after
161 // the current time step. For that we need the limiting factor.
162 double adaptive_time_stepping_limiting_factor;
163};
164
165} // namespace AeroAcoustic
166} // namespace ExaDG
167
168#endif /* EXADG_AERO_ACOUSTIC_SINGLE_FIELD_SOLVERS_FLUID_H_ */
Definition application_base.h:180
Definition driver.cpp:33