43 using VectorType = dealii::LinearAlgebra::distributed::Vector<Number>;
45 using CellIntegratorScalar = CellIntegrator<dim, 1, Number>;
46 using CellIntegratorVector = CellIntegrator<dim, dim, Number>;
54 setup(dealii::MatrixFree<dim, Number>
const & matrix_free_in,
57 matrix_free = &matrix_free_in;
62 evaluate_integrate(VectorType & dst,
63 VectorType
const & velocity_cfd_in,
64 VectorType
const & pressure_cfd_in,
65 VectorType
const & pressure_cfd_time_derivative_in,
66 double const evaluation_time)
68 time = evaluation_time;
70 dst.zero_out_ghost_values();
72 if(data.consider_convection)
74 velocity_cfd.reset(velocity_cfd_in);
75 velocity_cfd->update_ghost_values();
77 pressure_cfd.reset(pressure_cfd_in);
78 pressure_cfd->update_ghost_values();
81 matrix_free->cell_loop(
82 &This::compute_source_term,
this, dst, pressure_cfd_time_derivative_in,
true);
87 compute_source_term(dealii::MatrixFree<dim, Number>
const & matrix_free_in,
89 VectorType
const & dp_cfd_dt,
90 std::pair<unsigned int, unsigned int>
const & cell_range)
const
92 CellIntegratorScalar dpdt(matrix_free_in, data.dof_index_pressure, data.quad_index);
93 CellIntegratorScalar p(matrix_free_in, data.dof_index_pressure, data.quad_index);
94 CellIntegratorVector u(matrix_free_in, data.dof_index_velocity, data.quad_index);
96 Number rho =
static_cast<Number
>(data.density);
102 AssertThrow(data.blend_in_function !=
nullptr,
103 dealii::ExcMessage(
"No blend-in function provided."));
105 bool const space_dependent_scaling =
106 data.blend_in_function !=
nullptr ? data.blend_in_function->varies_in_space(time) :
false;
107 Number
const pure_temporal_scaling_factor =
108 (not space_dependent_scaling) ? data.blend_in_function->compute_time_factor(time) : 1.0;
110 auto apply_scaling = [&](
auto & flux,
auto const & q) {
111 if(space_dependent_scaling)
114 flux *= pure_temporal_scaling_factor;
117 for(
unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
120 dpdt.gather_evaluate(dp_cfd_dt, dealii::EvaluationFlags::values);
122 if(data.consider_convection)
125 p.gather_evaluate(*pressure_cfd, dealii::EvaluationFlags::gradients);
127 u.gather_evaluate(*velocity_cfd, dealii::EvaluationFlags::values);
129 for(
unsigned int q = 0; q < dpdt.n_q_points; ++q)
131 auto flux = -rho * dpdt.get_value(q) + u.get_value(q) * p.get_gradient(q);
134 apply_scaling(flux, dpdt.quadrature_point(q));
136 dpdt.submit_value(flux, q);
141 for(
unsigned int q = 0; q < dpdt.n_q_points; ++q)
143 auto flux = -rho * dpdt.get_value(q);
146 apply_scaling(flux, dpdt.quadrature_point(q));
148 dpdt.submit_value(flux, q);
152 dpdt.integrate_scatter(dealii::EvaluationFlags::values, dst);
156 dealii::MatrixFree<dim, Number>
const * matrix_free;