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