ExaDG
Loading...
Searching...
No Matches
volume_coupling.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 INCLUDE_EXADG_AERO_ACOUSTIC_VOLUME_COUPLING_H_
23#define INCLUDE_EXADG_AERO_ACOUSTIC_VOLUME_COUPLING_H_
24
25#include <exadg/aero_acoustic/calculators/source_term_calculator.h>
26#include <exadg/aero_acoustic/single_field_solvers/acoustics.h>
27#include <exadg/aero_acoustic/single_field_solvers/fluid.h>
28#include <exadg/aero_acoustic/user_interface/parameters.h>
29
30namespace ExaDG
31{
32namespace AeroAcoustic
33{
37template<int dim, typename Number>
39{
40 using VectorType = dealii::LinearAlgebra::distributed::Vector<Number>;
41
42public:
43 void
44 setup(Parameters const & parameters_in,
45 std::shared_ptr<SolverAcoustic<dim, Number>> acoustic_solver_in,
46 std::shared_ptr<SolverFluid<dim, Number>> fluid_solver_in,
47 std::shared_ptr<FieldFunctions<dim>> field_functions_in)
48 {
49 parameters = parameters_in;
50 acoustic_solver = acoustic_solver_in;
51 fluid_solver = fluid_solver_in;
52
53 acoustic_solver_in->pde_operator->initialize_dof_vector_pressure(source_term_acoustic);
54 fluid_solver_in->pde_operator->initialize_vector_pressure(source_term_fluid);
55
56 // setup the transfer operator
57 if(parameters.fluid_to_acoustic_coupling_strategy ==
58 FluidToAcousticCouplingStrategy::ConservativeInterpolation)
59 {
60 non_nested_grid_transfer.reinit(fluid_solver_in->pde_operator->get_dof_handler_p(),
61 acoustic_solver_in->pde_operator->get_dof_handler_p(),
62 *fluid_solver_in->pde_operator->get_mapping(),
63 *acoustic_solver_in->pde_operator->get_mapping());
64 }
65 else
66 {
67 AssertThrow(false, dealii::ExcMessage("FluidToAcousticCouplingStrategy not implemented."));
68 }
69
70 // setup aeroacoustic source term calculator
72 data.dof_index_pressure = fluid_solver_in->pde_operator->get_dof_index_pressure();
73 data.dof_index_velocity = fluid_solver_in->pde_operator->get_dof_index_velocity();
74 data.quad_index = fluid_solver_in->pde_operator->get_quad_index_pressure();
75 data.density = parameters_in.density;
76 data.consider_convection = parameters_in.source_term_with_convection;
77 data.blend_in = parameters.blend_in_source_term;
78 data.blend_in_function = field_functions_in->source_term_blend_in;
79
80 source_term_calculator.setup(fluid_solver_in->pde_operator->get_matrix_free(), data);
81 }
82
83 void
84 fluid_to_acoustic()
85 {
86 if(parameters.fluid_to_acoustic_coupling_strategy ==
87 FluidToAcousticCouplingStrategy::ConservativeInterpolation)
88 {
89 source_term_calculator.evaluate_integrate(source_term_fluid,
90 fluid_solver->time_integrator->get_velocity(),
91 fluid_solver->time_integrator->get_pressure(),
92 fluid_solver->get_pressure_time_derivative(),
93 fluid_solver->time_integrator->get_time());
94
95 non_nested_grid_transfer.restrict_and_add(source_term_acoustic, source_term_fluid);
96 }
97 else
98 {
99 AssertThrow(false, dealii::ExcMessage("FluidToAcousticCouplingStrategy not implemented."));
100 }
101
102 acoustic_solver->pde_operator->set_aero_acoustic_source_term(source_term_acoustic);
103 }
104
105private:
106 Parameters parameters;
107
108 // Single field solvers
109 std::shared_ptr<SolverAcoustic<dim, Number>> acoustic_solver;
110 std::shared_ptr<SolverFluid<dim, Number>> fluid_solver;
111
112 // Field functions
113 std::shared_ptr<FieldFunctions<dim>> field_functions;
114
115 // Transfer operator
116 dealii::MGTwoLevelTransferNonNested<dim, VectorType> non_nested_grid_transfer;
117
118 // Class that knows how to compute the source term
119 SourceTermCalculator<dim, Number> source_term_calculator;
120
121 // Aeroacoustic source term defined on the acoustic mesh
122 VectorType source_term_acoustic;
123
124 // Aeroacoustic source term defined on the fluid mesh
125 VectorType source_term_fluid;
126};
127} // namespace AeroAcoustic
128} // namespace ExaDG
129
130#endif /*INCLUDE_EXADG_AERO_ACOUSTIC_VOLUME_COUPLING_H_*/
Definition parameters.h:40
Definition acoustics.h:38
Definition source_term_calculator.h:41
Definition volume_coupling.h:39
Definition driver.cpp:33
Definition field_functions.h:33
Definition source_term_calculator.h:13