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