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