72 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
74 typedef CellIntegrator<dim, dim, Number> CellIntegratorVelocity;
75 typedef FaceIntegrator<dim, dim, Number> FaceIntegratorVelocity;
77 typedef dealii::VectorizedArray<Number> scalar;
78 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
80 typedef CellIntegrator<dim, 1, Number> IntegratorCell;
81 typedef FaceIntegrator<dim, 1, Number> IntegratorFace;
85 reinit(dealii::MatrixFree<dim, Number>
const & matrix_free,
87 unsigned int const quad_index,
88 bool const use_own_velocity_storage)
92 if(data.velocity_type == TypeVelocityField::DoFVector)
95 std::make_shared<CellIntegratorVelocity>(matrix_free, data.dof_index_velocity, quad_index);
97 integrator_velocity_m = std::make_shared<FaceIntegratorVelocity>(matrix_free,
99 data.dof_index_velocity,
102 integrator_velocity_p = std::make_shared<FaceIntegratorVelocity>(matrix_free,
104 data.dof_index_velocity,
107 if(use_own_velocity_storage)
110 matrix_free.initialize_dof_vector(velocity.own(), data.dof_index_velocity);
116 get_integrator_flags()
const
120 if(data.formulation == FormulationConvectiveTerm::DivergenceFormulation)
122 flags.cell_evaluate = dealii::EvaluationFlags::values;
123 flags.cell_integrate = dealii::EvaluationFlags::gradients;
125 else if(data.formulation == FormulationConvectiveTerm::ConvectiveFormulation)
127 flags.cell_evaluate = dealii::EvaluationFlags::gradients;
128 flags.cell_integrate = dealii::EvaluationFlags::values;
132 AssertThrow(
false, dealii::ExcMessage(
"Not implemented."));
135 flags.face_evaluate = dealii::EvaluationFlags::values;
136 flags.face_integrate = dealii::EvaluationFlags::values;
146 flags.cells = dealii::update_gradients | dealii::update_JxW_values |
147 dealii::update_quadrature_points;
148 flags.inner_faces = dealii::update_JxW_values | dealii::update_quadrature_points |
149 dealii::update_normal_vectors;
150 flags.boundary_faces =
151 dealii::update_JxW_values | dealii::update_quadrature_points | dealii::update_normal_vectors;
156 dealii::LinearAlgebra::distributed::Vector<Number>
const &
163 set_velocity_copy(VectorType
const & velocity_in)
const
165 AssertThrow(data.velocity_type == TypeVelocityField::DoFVector,
166 dealii::ExcMessage(
"Invalid parameter velocity_type."));
168 velocity.own() = velocity_in;
170 velocity->update_ghost_values();
174 set_velocity_ptr(VectorType
const & velocity_in)
const
176 AssertThrow(data.velocity_type == TypeVelocityField::DoFVector,
177 dealii::ExcMessage(
"Invalid parameter velocity_type."));
179 velocity.reset(velocity_in);
181 velocity->update_ghost_values();
185 reinit_cell(
unsigned int const cell)
const
187 if(data.velocity_type == TypeVelocityField::DoFVector)
189 integrator_velocity->reinit(cell);
190 integrator_velocity->gather_evaluate(*velocity, dealii::EvaluationFlags::values);
195 reinit_face(
unsigned int const face)
const
197 if(data.velocity_type == TypeVelocityField::DoFVector)
199 integrator_velocity_m->reinit(face);
200 integrator_velocity_m->gather_evaluate(*velocity, dealii::EvaluationFlags::values);
202 integrator_velocity_p->reinit(face);
203 integrator_velocity_p->gather_evaluate(*velocity, dealii::EvaluationFlags::values);
208 reinit_boundary_face(
unsigned int const face)
const
210 if(data.velocity_type == TypeVelocityField::DoFVector)
212 integrator_velocity_m->reinit(face);
213 integrator_velocity_m->gather_evaluate(*velocity, dealii::EvaluationFlags::values);
218 reinit_face_cell_based(
unsigned int const cell,
219 unsigned int const face,
220 dealii::types::boundary_id
const boundary_id)
const
222 if(data.velocity_type == TypeVelocityField::DoFVector)
224 integrator_velocity_m->reinit(cell, face);
225 integrator_velocity_m->gather_evaluate(*velocity, dealii::EvaluationFlags::values);
227 if(boundary_id == dealii::numbers::internal_face_boundary_id)
240 inline DEAL_II_ALWAYS_INLINE
242 calculate_central_flux(scalar
const & value_m,
243 scalar
const & value_p,
244 scalar
const & normal_velocity)
const
246 scalar average_value = 0.5 * (value_m + value_p);
248 return normal_velocity * average_value;
254 inline DEAL_II_ALWAYS_INLINE
256 calculate_central_flux(scalar
const & value_m,
257 scalar
const & value_p,
258 scalar
const & normal_velocity_m,
259 scalar
const & normal_velocity_p)
const
261 return 0.5 * (normal_velocity_m * value_m + normal_velocity_p * value_p);
267 inline DEAL_II_ALWAYS_INLINE
269 calculate_lax_friedrichs_flux(scalar
const & value_m,
270 scalar
const & value_p,
271 scalar
const & normal_velocity)
const
273 scalar average_value = 0.5 * (value_m + value_p);
274 scalar jump_value = value_m - value_p;
275 scalar lambda = std::abs(normal_velocity);
277 return normal_velocity * average_value + 0.5 * lambda * jump_value;
283 inline DEAL_II_ALWAYS_INLINE
285 calculate_lax_friedrichs_flux(scalar
const & value_m,
286 scalar
const & value_p,
287 scalar
const & normal_velocity_m,
288 scalar
const & normal_velocity_p)
const
290 scalar jump_value = value_m - value_p;
291 scalar lambda = std::max(std::abs(normal_velocity_m), std::abs(normal_velocity_p));
293 return 0.5 * (normal_velocity_m * value_m + normal_velocity_p * value_p) +
294 0.5 * lambda * jump_value;
301 inline DEAL_II_ALWAYS_INLINE
303 calculate_flux(
unsigned int const q,
304 IntegratorFace & integrator,
305 scalar
const & value_m,
306 scalar
const & value_p,
307 vector
const & normal_m,
309 bool const exterior_velocity_available)
const
311 scalar flux = dealii::make_vectorized_array<Number>(0.0);
313 if(data.velocity_type == TypeVelocityField::Function)
315 dealii::Point<dim, scalar> q_points = integrator.quadrature_point(q);
317 vector velocity = FunctionEvaluator<1, dim, Number>::value(*(data.velocity), q_points, time);
319 scalar normal_velocity = velocity * normal_m;
323 if(data.numerical_flux_formulation == NumericalFluxConvectiveOperator::CentralFlux)
325 flux = calculate_central_flux(value_m, value_p, normal_velocity);
327 else if(data.numerical_flux_formulation == NumericalFluxConvectiveOperator::LaxFriedrichsFlux)
329 flux = calculate_lax_friedrichs_flux(value_m, value_p, normal_velocity);
332 else if(data.velocity_type == TypeVelocityField::DoFVector)
334 vector velocity_m = integrator_velocity_m->get_value(q);
336 exterior_velocity_available ? integrator_velocity_p->get_value(q) : velocity_m;
338 scalar normal_velocity_m = velocity_m * normal_m;
339 scalar normal_velocity_p = velocity_p * normal_m;
341 if(data.formulation == FormulationConvectiveTerm::DivergenceFormulation)
343 if(data.numerical_flux_formulation == NumericalFluxConvectiveOperator::CentralFlux)
345 flux = calculate_central_flux(value_m, value_p, normal_velocity_m, normal_velocity_p);
347 else if(data.numerical_flux_formulation ==
348 NumericalFluxConvectiveOperator::LaxFriedrichsFlux)
351 calculate_lax_friedrichs_flux(value_m, value_p, normal_velocity_m, normal_velocity_p);
354 else if(data.formulation == FormulationConvectiveTerm::ConvectiveFormulation)
356 scalar normal_velocity = 0.5 * (normal_velocity_m + normal_velocity_p);
358 if(data.numerical_flux_formulation == NumericalFluxConvectiveOperator::CentralFlux)
360 flux = calculate_central_flux(value_m, value_p, normal_velocity);
362 else if(data.numerical_flux_formulation ==
363 NumericalFluxConvectiveOperator::LaxFriedrichsFlux)
365 flux = calculate_lax_friedrichs_flux(value_m, value_p, normal_velocity);
370 AssertThrow(
false, dealii::ExcMessage(
"Not implemented."));
375 AssertThrow(
false, dealii::ExcMessage(
"Not implemented."));
381 inline DEAL_II_ALWAYS_INLINE
383 calculate_average_velocity(
unsigned int const q,
384 IntegratorFace & integrator,
386 bool const exterior_velocity_available)
const
390 if(data.velocity_type == TypeVelocityField::Function)
392 dealii::Point<dim, scalar> q_points = integrator.quadrature_point(q);
394 velocity = FunctionEvaluator<1, dim, Number>::value(*(data.velocity), q_points, time);
396 else if(data.velocity_type == TypeVelocityField::DoFVector)
398 vector velocity_m = integrator_velocity_m->get_value(q);
400 exterior_velocity_available ? integrator_velocity_p->get_value(q) : velocity_m;
402 velocity = 0.5 * (velocity_m + velocity_p);
406 AssertThrow(
false, dealii::ExcMessage(
"Not implemented."));
412 inline DEAL_II_ALWAYS_INLINE
413 std::tuple<scalar, scalar>
414 calculate_flux_interior_and_neighbor(
unsigned int const q,
415 IntegratorFace & integrator,
416 scalar
const & value_m,
417 scalar
const & value_p,
418 vector
const & normal_m,
420 bool const exterior_velocity_available)
const
423 calculate_flux(q, integrator, value_m, value_p, normal_m, time, exterior_velocity_available);
424 scalar fluxP = -fluxM;
426 if(data.formulation == FormulationConvectiveTerm::ConvectiveFormulation)
429 calculate_average_velocity(q, integrator, time, exterior_velocity_available);
430 scalar normal_velocity = velocity * normal_m;
434 fluxM = fluxM - normal_velocity * value_m;
436 fluxP = fluxP + normal_velocity * value_p;
439 return std::make_tuple(fluxM, fluxP);
442 inline DEAL_II_ALWAYS_INLINE
444 calculate_flux_interior(
unsigned int const q,
445 IntegratorFace & integrator,
446 scalar
const & value_m,
447 scalar
const & value_p,
448 vector
const & normal_m,
450 bool const exterior_velocity_available)
const
453 calculate_flux(q, integrator, value_m, value_p, normal_m, time, exterior_velocity_available);
455 if(data.formulation == FormulationConvectiveTerm::ConvectiveFormulation)
458 calculate_average_velocity(q, integrator, time, exterior_velocity_available);
459 scalar normal_velocity = velocity * normal_m;
463 flux = flux - normal_velocity * value_m;
473 inline DEAL_II_ALWAYS_INLINE
475 get_volume_flux_divergence_form(scalar
const & value,
476 IntegratorCell & integrator,
477 unsigned int const q,
478 Number
const & time)
const
482 if(data.velocity_type == TypeVelocityField::Function)
484 velocity = FunctionEvaluator<1, dim, Number>::value(*(data.velocity),
485 integrator.quadrature_point(q),
488 else if(data.velocity_type == TypeVelocityField::DoFVector)
490 velocity = integrator_velocity->get_value(q);
494 AssertThrow(
false, dealii::ExcMessage(
"Not implemented."));
497 return (-value * velocity);
500 inline DEAL_II_ALWAYS_INLINE
502 get_volume_flux_convective_form(vector
const & gradient,
503 IntegratorCell & integrator,
504 unsigned int const q,
505 Number
const & time)
const
509 if(data.velocity_type == TypeVelocityField::Function)
511 velocity = FunctionEvaluator<1, dim, Number>::value(*(data.velocity),
512 integrator.quadrature_point(q),
515 else if(data.velocity_type == TypeVelocityField::DoFVector)
517 velocity = integrator_velocity->get_value(q);
521 AssertThrow(
false, dealii::ExcMessage(
"Not implemented."));
524 return (velocity * gradient);
532 std::shared_ptr<CellIntegratorVelocity> integrator_velocity;
533 std::shared_ptr<FaceIntegratorVelocity> integrator_velocity_m;
534 std::shared_ptr<FaceIntegratorVelocity> integrator_velocity_p;
556 typedef OperatorBase<dim, Number, 1> Base;
558 typedef typename Base::IntegratorCell IntegratorCell;
559 typedef typename Base::IntegratorFace IntegratorFace;
561 typedef typename Base::VectorType VectorType;
563 typedef dealii::VectorizedArray<Number> scalar;
564 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
568 initialize(dealii::MatrixFree<dim, Number>
const & matrix_free,
569 dealii::AffineConstraints<Number>
const & affine_constraints,
573 dealii::LinearAlgebra::distributed::Vector<Number>
const &
574 get_velocity()
const;
577 set_velocity_copy(VectorType
const & velocity)
const;
580 set_velocity_ptr(VectorType
const & velocity)
const;
584 reinit_cell_derived(IntegratorCell & integrator,
unsigned int const cell)
const final;
587 reinit_face_derived(IntegratorFace & integrator_m,
588 IntegratorFace & integrator_p,
589 unsigned int const face)
const final;
592 reinit_boundary_face_derived(IntegratorFace & integrator_m,
unsigned int const face)
const final;
595 reinit_face_cell_based_derived(IntegratorFace & integrator_m,
596 IntegratorFace & integrator_p,
597 unsigned int const cell,
598 unsigned int const face,
599 dealii::types::boundary_id
const boundary_id)
const final;
602 do_cell_integral(IntegratorCell & integrator)
const final;
605 do_face_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const final;
608 do_face_int_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const final;
611 do_face_ext_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const final;
614 do_boundary_integral(IntegratorFace & integrator_m,
615 OperatorType
const & operator_type,
616 dealii::types::boundary_id
const & boundary_id)
const final;
621 do_face_int_integral_cell_based(IntegratorFace & integrator_m,
622 IntegratorFace & integrator_p)
const final;
626 std::shared_ptr<Operators::ConvectiveKernel<dim, Number>> kernel;