include/meltpooldg/compressible_flow/multiphase_operation.hpp Source File

Developer Documentation: include/meltpooldg/compressible_flow/multiphase_operation.hpp Source File
Developer Documentation
multiphase_operation.hpp
Go to the documentation of this file.
1
23#pragma once
24
25#include <deal.II/base/function.h>
26
27#include <deal.II/fe/fe_system.h>
28
29#include <deal.II/non_matching/mesh_classifier.h>
30
46
47#include <memory>
48#include <variant>
49
51{
56 template <int dim, typename number>
58 {
59 public:
60 using VectorType = dealii::LinearAlgebra::distributed::Vector<number>;
63
65
67
69 std::variant<CompressibleMultiphaseOperator<dim, number, true, true>,
73
100 const ScratchData<dim, dim, number> &scratch_data_in,
101 const CompressibleFlow::OperationData<number> &comp_flow_data_in,
102 const CompressibleFlow::MaterialPhaseData<number> &material_data_gas_in,
103 const CompressibleFlow::MaterialPhaseData<number> &material_data_liquid_in,
104 const PhaseChangeData<number> &phase_change_data_in,
106 const CompressibleFlowPhaseCouplingData<number> &phase_coupling_data_in,
107 const Flow::DarcyDampingData<number> &darcy_damping_data_in,
108 const TimeIntegration::TimeIterator<number> &time_iterator_in,
109 const std::function<void()> &setup_dof_system_in,
110 const VectorType &level_set_in,
111 unsigned int comp_flow_dof_idx_in = dealii::numbers::invalid_unsigned_int,
112 unsigned int level_set_dof_idx_in = dealii::numbers::invalid_unsigned_int,
113 unsigned int comp_flow_quad_idx_in = dealii::numbers::invalid_unsigned_int);
114
120 void
121 reinit();
122
130 void
131 set_body_force(std::unique_ptr<dealii::Function<dim>> body_force_in);
132
138 void
140 std::shared_ptr<CompressibleFlow::ExternalFlowForce<dim, number>> external_force);
141
152 number
153 compute_time_step_size(bool do_print = false) const;
154
165 std::vector<std::complex<number>>
166 estimate_jacobian_eigenvalues(const number /*time_step*/) const
167 {
168 AssertThrow(false,
169 dealii::ExcMessage("Eigenvalue estimation is not implemented for "
170 "CompressibleMultiphaseOperation."));
171 return {};
172 }
173
182 void
183 distribute_dofs(dealii::DoFHandler<dim> &dof_handler) const;
184
191 void
192 solve(number current_time, number time_step);
193
199 void
200 set_initial_condition(const dealii::Function<dim> &function);
201
232 bool
233 repartition(VectorType &level_set_in, const std::function<void()> &distribute_level_set_dofs);
234
244 void
245 set_boundary_conditions(const std::shared_ptr<SimulationCaseBase<dim, number>> &simulation_case,
246 const std::string &operation_name);
247
256 void
258
262 const VectorType &
263 get_solution() const;
264
268 VectorType &
269 get_solution();
270
275 VectorType &
277
281 const dealii::DoFHandler<dim> &
282 get_dof_handler() const;
283
303 bool is_viscous_gas,
304 bool is_viscous_liquid,
306 const MappingInfoType &mapping_info_surface_in,
307 const MappingInfoVectorType &mapping_info_cells_in,
308 const MappingInfoVectorType &mapping_info_faces_in)
309 {
310 if (is_viscous_gas and is_viscous_liquid)
312 mapping_info_surface_in,
313 mapping_info_cells_in,
314 mapping_info_faces_in);
315 else if (is_viscous_gas and (not is_viscous_liquid))
317 mapping_info_surface_in,
318 mapping_info_cells_in,
319 mapping_info_faces_in);
320 else if ((not is_viscous_gas) and is_viscous_liquid)
322 mapping_info_surface_in,
323 mapping_info_cells_in,
324 mapping_info_faces_in);
325 else
327 mapping_info_surface_in,
328 mapping_info_cells_in,
329 mapping_info_faces_in);
330 }
331
332 private:
335
338
340 const unsigned int level_set_dof_idx;
341
344
347
350
353 std::shared_ptr<dealii::NonMatching::MeshClassifier<dim>> mesh_classifier;
354
357 std::shared_ptr<dealii::NonMatching::MeshClassifier<dim>> mesh_classifier_old;
358
362
364 std::function<void()> setup_dof_system;
365
367 std::function<void(VectorType &)> reinit_vector;
368
370 dealii::FESystem<dim> fe_point_temp;
371
373 const unsigned int n_dofs_per_cell;
374
377
380
383
386
389
392
395 unsigned int n_steps_performed = 0;
396
399 std::unique_ptr<CutUtil::PartitionWeights<dim>> partition_weights;
400
421 void
423
427 void
428 classify_cells() const;
429
435 number
437
445 number
446 compute_viscous_time_step_limit(const std::pair<number, number> &min_density) const;
447
453 std::pair<number, number>
455
460 void
462 };
463
464 // inlined functions
465 template <int dim, typename number>
466 const dealii::LinearAlgebra::distributed::Vector<number> &
468 {
469 return multiphase_scratch_data.solution_history.get_current_solution();
470 }
471
472 template <int dim, typename number>
473 dealii::LinearAlgebra::distributed::Vector<number> &
475 {
476 return multiphase_scratch_data.solution_history.get_current_solution();
477 }
478
479 template <int dim, typename number>
480 dealii::LinearAlgebra::distributed::Vector<number> &
482 {
483 update_primitive_variables_solution<dim, number, ConservedVariablesType>(
484 solution_primitive_variables,
485 get_solution(),
486 multiphase_scratch_data.scratch_data,
487 multiphase_scratch_data.dof_idx,
488 multiphase_scratch_data.quad_idx,
489 &multiphase_scratch_data.material_liquid,
490 &multiphase_scratch_data.material_gas);
491 return solution_primitive_variables;
492 }
493
494 template <int dim, typename number>
495 const dealii::DoFHandler<dim> &
497 {
498 return multiphase_scratch_data.scratch_data.get_dof_handler(multiphase_scratch_data.dof_idx);
499 }
500
501} // namespace MeltPoolDG::Multiphase
Operator for the solution transfer in moving boundary/interface simulations.
Definition solution_transfer.hpp:38
A generic utility for managing simulation output data in the MeltPoolDG context.
Definition generic_data_out.hpp:32
Operation that performs a full time step for the compressible two-phase Navier-Stokes equations in a ...
Definition multiphase_operation.hpp:58
number compute_viscous_time_step_limit(const std::pair< number, number > &min_density) const
Compute the viscous time step limit for the current mesh and flow field.
Definition multiphase_operation.cpp:886
std::function< void(VectorType &)> reinit_vector
Function for DoF vector reinitialization.
Definition multiphase_operation.hpp:367
std::shared_ptr< dealii::NonMatching::MeshClassifier< dim > > mesh_classifier_old
Definition multiphase_operation.hpp:357
void set_initial_condition(const dealii::Function< dim > &function)
Set the initial condition of the solution dof vector.
Definition multiphase_operation.cpp:390
const unsigned int level_set_dof_idx
DoF index associated to the level set field.
Definition multiphase_operation.hpp:340
std::unique_ptr< CutUtil::PartitionWeights< dim > > partition_weights
Definition multiphase_operation.hpp:399
CompressibleFlow::DofStateView< dim, number, const ConservedVariablesType > DofStateView
Definition multiphase_operation.hpp:66
MappingInfoVectorType mapping_info_faces
Mapping information for integration over cut faces.
Definition multiphase_operation.hpp:382
void set_body_force(std::unique_ptr< dealii::Function< dim > > body_force_in)
Set a body force, e.g. gravity, specified by the passed function.
Definition multiphase_operation.cpp:158
std::variant< CompressibleMultiphaseOperator< dim, number, true, true >, CompressibleMultiphaseOperator< dim, number, true, false >, CompressibleMultiphaseOperator< dim, number, false, true >, CompressibleMultiphaseOperator< dim, number, false, false > > CompMultiphaseOperatorVariant
Definition multiphase_operation.hpp:72
dealii::FESystem< dim > fe_point_temp
FESystem object, required by FEPointEvaluation.
Definition multiphase_operation.hpp:370
std::pair< number, number > compute_minimum_density() const
Compute the minimum density currently occurring in the flow field.
Definition multiphase_operation.cpp:555
CompMultiphaseOperatorVariant cmp_operator
Compressible multiphase operator object.
Definition multiphase_operation.hpp:385
VectorType & get_solution_in_primitive_variables() const
Getter function for the current solution vector in primitive variables (pressure, velocity,...
Definition multiphase_operation.hpp:481
bool repartition(VectorType &level_set_in, const std::function< void()> &distribute_level_set_dofs)
Repartition the triangulation among the MPI processes with cell weights according to the location of ...
Definition multiphase_operation.cpp:403
bool preconditioner_update_flag
Boolean indicator whether the preconditioner needs to be updated before the next solve.
Definition multiphase_operation.hpp:391
CompressibleFlow::ConservedVariablesType< dim, number > ConservedVariablesType
Definition multiphase_operation.hpp:64
number compute_convective_time_step_limit() const
Compute the convective time step limit for the current mesh and flow field.
Definition multiphase_operation.cpp:689
VectorType solution_primitive_variables
Solution vector in primitive variable formulation (pressure, velocity, temperature)
Definition multiphase_operation.hpp:349
void solve(number current_time, number time_step)
Solves the compressible two-phase Navier-Stokes equations for a single time step.
Definition multiphase_operation.cpp:332
MappingInfoVectorType mapping_info_cells
Mapping information for integration over cut cells.
Definition multiphase_operation.hpp:379
void reinit()
Set up the required internal data structures.
Definition multiphase_operation.cpp:279
MappingInfoType mapping_info_surface
Mapping information for integration over phase interfaces.
Definition multiphase_operation.hpp:376
number compute_time_step_size(bool do_print=false) const
Compute the maximum time step size.
Definition multiphase_operation.cpp:246
std::shared_ptr< dealii::NonMatching::MeshClassifier< dim > > mesh_classifier
Definition multiphase_operation.hpp:353
void attach_output_vectors(GenericDataOut< dim, number > &data_out) const
Attach the solution to the passed data out object.
Definition multiphase_operation.cpp:175
static CompMultiphaseOperatorVariant create_cut_flow_operator_variant(bool is_viscous_gas, bool is_viscous_liquid, CompressibleFlow::MultiphaseOperationScratchData< dim, number > &multiphase_scratch_data, const MappingInfoType &mapping_info_surface_in, const MappingInfoVectorType &mapping_info_cells_in, const MappingInfoVectorType &mapping_info_faces_in)
Create and return the appropriate compressible multiphase operator variant.
Definition multiphase_operation.hpp:302
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition multiphase_operation.hpp:60
const VectorType & get_solution() const
Constant getter function for the current solution vector.
Definition multiphase_operation.hpp:467
void classify_cells() const
Classify cells according to the current state of the level-set field.
Definition multiphase_operation.cpp:487
CutUtil::MappingInfoVectorType< dim, number > MappingInfoVectorType
Definition multiphase_operation.hpp:62
void add_external_force(std::shared_ptr< CompressibleFlow::ExternalFlowForce< dim, number > > external_force)
Add external fluid forces (e.g. gravity, ...).
Definition multiphase_operation.cpp:167
std::vector< std::complex< number > > estimate_jacobian_eigenvalues(const number) const
Definition multiphase_operation.hpp:166
CutUtil::MappingInfoType< dim, number > MappingInfoType
Definition multiphase_operation.hpp:61
CutUtil::SolutionTransferOperator< dim, number > cut_solution_transfer
Definition multiphase_operation.hpp:361
unsigned int n_steps_performed
Definition multiphase_operation.hpp:395
const unsigned int n_dofs_per_cell
Number of DoFs per cell.
Definition multiphase_operation.hpp:373
void distribute_dofs(dealii::DoFHandler< dim > &dof_handler) const
Distribute dofs needed for a finite element type given in CompressibleFlowData.
Definition multiphase_operation.cpp:308
CompressibleFlow::MultiphaseOperationScratchData< dim, number > multiphase_scratch_data
Scratch data for multiphase case.
Definition multiphase_operation.hpp:334
const TimeIntegration::TimeIterator< number > & time_iterator
Time iterator.
Definition multiphase_operation.hpp:337
Preconditioner< dim, VectorType, number > preconditioner
Preconditioner for the linear solver.
Definition multiphase_operation.hpp:388
std::function< void()> setup_dof_system
Function to set up the DoF system.
Definition multiphase_operation.hpp:364
const dealii::DoFHandler< dim > & get_dof_handler() const
Constant getter function for the DoFHandler.
Definition multiphase_operation.hpp:496
VectorType rhs
Right-hand side vector.
Definition multiphase_operation.hpp:346
const VectorType & level_set
Reference to the level-set field used to represent the interface between phases.
Definition multiphase_operation.hpp:343
void adapt_to_new_interface_position()
Adapt the dof layout, solution vector, and discretization to a new interface position,...
Definition multiphase_operation.cpp:494
void set_boundary_conditions(const std::shared_ptr< SimulationCaseBase< dim, number > > &simulation_case, const std::string &operation_name)
Set the boundary conditions.
Definition multiphase_operation.cpp:148
void compute_intersected_quadrature()
Compute the quadrature rules for intersected elements, intersected faces and phase surfaces.
Definition multiphase_operation.cpp:667
Operator for the matrix-free of a compressible multiphase flow cutDG formulation.
Definition multiphase_operator.hpp:31
Definition preconditioner.hpp:42
Container for shared scratch data between operations/operators.
Definition scratch_data.hpp:61
Base class for managing a simulation case in a parallel computing environment.
Definition simulation_case_base.hpp:44
Definition time_iterator.hpp:15
dealii::Tensor< 1, n_conserved_variables< dim, n_species >, VectorizedArrayType > ConservedVariablesType
Definition data_types.hpp:45
std::vector< std::shared_ptr< MappingInfoType< dim, number > > > MappingInfoVectorType
Definition util.hpp:56
dealii::NonMatching::MappingInfo< dim, dim, dealii::VectorizedArray< number > > MappingInfoType
Definition util.hpp:53
A collection of functions for the computation of the interface terms for compressible two-phase flows...
Definition multiphase_interface_kernels.hpp:32
This file provides a collection of view types for the compressible Navier–Stokes solver....
Collection of cut-related solver parameters required by the cut single-phase and multiphase compressi...
Definition operation_data.hpp:211
Definition state_views.hpp:186
An abstract interface for defining external forces acting on the fluid that must be evaluated and inc...
Definition utils.hpp:187
Collection of material parameters for a specific fluid phase.
Definition material.hpp:140
Scratch data structure for compressible multiphase flow solvers.
Definition operation_scratch_data.hpp:152
Collection of parameters required by the compressible Navier-Stokes operator.
Definition operation_data.hpp:35
Collection of parameters for Darcy damping.
Definition darcy_damping_data.hpp:16
Data structure, which contains parameters specifically for the phase coupling of compressible multiph...
Definition phase_coupling_data.hpp:23
Collection of parameters related to liquid-gas and solid-liquid phase transitions.
Definition phase_change_data.hpp:12