4#ifndef lethe_void_fraction_h
5#define lethe_void_fraction_h
16#include <deal.II/base/index_set.h>
17#include <deal.II/base/utilities.h>
19#include <deal.II/distributed/tria_base.h>
21#include <deal.II/dofs/dof_handler.h>
23#include <deal.II/fe/fe_q.h>
24#include <deal.II/fe/fe_simplex_p.h>
25#include <deal.II/fe/fe_system.h>
26#include <deal.II/fe/mapping_fe.h>
28#include <deal.II/lac/affine_constraints.h>
29#include <deal.II/lac/trilinos_precondition.h>
30#include <deal.II/lac/trilinos_sparse_matrix.h>
32#include <deal.II/numerics/data_out.h>
33#include <deal.II/numerics/vector_tools.h>
35#include <deal.II/particles/particle_handler.h>
42 NotSupportedMeshAdaptationMethod,
43 "Mesh adaptation is only supported with the steady time-stepping method "
44 "in the VANS and CFD-DEM solvers at the moment because the void fraction "
45 "field is not yet updated during mesh adaptation.");
57 const double r_circle,
58 const double neighbor_distance)
60 return pow(r_particle, 2) * Utilities::fixed_power<-1,
double>(
61 cos((pow(neighbor_distance, 2) +
62 pow(r_particle, 2) - pow(r_circle, 2)) /
63 (2 * neighbor_distance * r_particle))) +
64 Utilities::fixed_power<2, double>(r_circle) *
65 Utilities::fixed_power<-1,
double>(
66 cos((pow(neighbor_distance, 2) - pow(r_particle, 2) +
68 (2 * neighbor_distance * r_circle))) -
69 0.5 * sqrt((-neighbor_distance + r_particle + r_circle) *
70 (neighbor_distance + r_particle - r_circle) *
71 (neighbor_distance - r_particle + r_circle) *
72 (neighbor_distance + r_particle + r_circle));
85 const double r_sphere,
86 const double neighbor_distance)
89 Utilities::fixed_power<2, double>(r_sphere + r_particle -
91 (Utilities::fixed_power<2, double>(neighbor_distance) +
92 (2 * neighbor_distance * r_particle) -
93 (3 * Utilities::fixed_power<2, double>(r_particle)) +
94 (2 * neighbor_distance * r_sphere) + (6 * r_sphere * r_particle) -
95 (3 * Utilities::fixed_power<2, double>(r_sphere))) /
96 (12 * neighbor_distance);
124 const double distance)
126 const double v_particle =
128 (4.0 / 3.0) * M_PI * Utilities::fixed_power<3, double>(r_particle) :
129 M_PI * Utilities::fixed_power<2, double>(r_particle);
130 const double inv_norm = 1.0 / std::pow(2.0 * M_PI * sigma * sigma, 0.5 * dim);
131 return v_particle * inv_norm *
132 std::exp(-0.5 * distance * distance / (sigma * sigma));
152template <
int dim,
int n_components,
int property_start_index = -1>
175 const unsigned int fe_degree,
179 :
dof_handler(std::make_shared<DoFHandler<dim>>(*triangulation))
186 const FE_SimplexP<dim> fe_temp(fe_degree);
187 fe = std::make_shared<FESystem<dim>>(fe_temp, n_components);
191 const FE_Q<dim> temp_fe(fe_degree);
192 fe = std::make_shared<FESystem<dim>>(temp_fe, n_components);
204 std::shared_ptr<FESystem<dim>>
fe;
278template <
int dim,
typename PropertiesIndex>
298 const unsigned int fe_degree,
300 const ConditionalOStream &
pcout)
324 fe = std::make_shared<FE_SimplexP<dim>>(fe_degree);
325 mapping = std::make_shared<MappingFE<dim>>(*fe);
326 quadrature = std::make_shared<QGaussSimplex<dim>>(
fe->degree + 1);
331 fe = std::make_shared<FE_Q<dim>>(fe_degree);
332 mapping = std::make_shared<MappingQ<dim>>(
fe->degree);
337 quadrature = std::make_shared<QGauss<dim>>(
fe->degree + 1);
346 quadrature = std::make_shared<QGaussLobatto<dim>>(
fe->degree + 2);
348 quadrature = std::make_shared<QGaussLobatto<dim>>(
351 throw(std::runtime_error(
352 "For void fraction using Gauss-Lobatto ('gauss_lobatto') quadrature rule, the minimum number of quadrature points is 3"));
359 "An invalid quadrature rule was provided to the ParticleProject class."));
372 std::make_shared<GlobalVectorType>();
378 "The projection of the particle velocity field requires that the l2 smoothing length be > 0. Otherwise, the Poisson equation used in the Neumann boundary is invalid."));
385 "The projection of the particle velocity currently requires that the QCM method be used for the calculation of the void fraction."));
391 "The particle temperature is always projected in thermal CFD-DEM simulations (solver type = dem_mp), which requires that the l2 smoothing length be > 0. Otherwise, the Poisson equation used in the Neumann boundary is invalid."));
433 &boundary_conditions);
459 template <
typename VectorType>
463 DoFHandler<dim> &fluid_dof_handler,
464 const VectorType &present_velocity_pressure_solution,
465 const std::vector<VectorType> &previous_velocity_pressure_solution,
466 const Tensor<1, 3> &gravity,
525 template <
int property_start_index,
int n_components>
541 .update_ghost_values();
560 const std::string &prefix,
561 const unsigned int group_files);
589 std::vector<LinearAlgebra::distributed::Vector<double>>
593 std::shared_ptr<FiniteElement<dim>>
fe;
619 return 0.5 * pow(2.0 *
static_cast<double>(dim) * volume / M_PI,
620 1.0 /
static_cast<double>(dim));
648 return std::cbrt(cell_measure);
668 double distance_between_spheres)
671 if (distance_between_spheres <= (r_sphere - r_particle))
673 if constexpr (dim == 2)
674 return M_PI * Utilities::fixed_power<2>(r_particle);
675 if constexpr (dim == 3)
676 return 4. / 3. * M_PI * Utilities::fixed_power<3>(r_particle);
680 if ((distance_between_spheres > (r_sphere - r_particle)) &&
681 (distance_between_spheres < (r_sphere + r_particle)))
683 if constexpr (dim == 2)
686 distance_between_spheres);
688 else if constexpr (dim == 3)
691 distance_between_spheres);
714 template <Parameters::QCMFilterType filter_type>
717 const double filter_length,
718 const double distance)
732 "Unhandled QCMFilterType in ParticleProjector::evaluate_filter."));
776 template <Parameters::QCMFilterType filter_type>
788 int property_start_index>
811 inline Tensor<1, dim>
814 Tensor<1, dim> offset;
817 for (
const auto &cell : (*this->
triangulation).active_cell_iterators())
819 if (cell->is_locally_owned() || cell->is_ghost())
821 if (cell->at_boundary())
824 for (
unsigned int face_id = 0; face_id < cell->n_faces();
827 unsigned int face_boundary_id =
828 cell->face(face_id)->boundary_id();
834 if (face_boundary_id == boundary_id)
836 Point<dim> face_center = cell->face(face_id)->center();
837 auto periodic_cell = cell->periodic_neighbor(face_id);
838 unsigned int periodic_face_id =
839 cell->periodic_neighbor_face_no(face_id);
840 Point<dim> periodic_face_center =
841 periodic_cell->face(periodic_face_id)->center();
843 offset = periodic_face_center - face_center;
865 std::shared_ptr<Parameters::VoidFractionParameters<dim>>
889 std::map<
unsigned int,
890 std::set<typename DoFHandler<dim>::active_cell_iterator>>
904 std::map<
unsigned int,
905 std::set<typename DoFHandler<dim>::active_cell_iterator>>
This class manages the boundary conditions forhe fluid dynamics solver It introduces the boundary fun...
Class that stores the information required by the assembly procedure for a Navier-Stokes equation....
Parameters controlling the void fraction computation in CFD-DEM simulations.
ParticleFieldQCM calculator. This class stores the required information for the calculation of a fiel...
const bool neumann_boundaries
IndexSet locally_owned_dofs
Index set for the locally owned degree of freedoms.
bool multigrid_level_dofs_required
std::shared_ptr< FESystem< dim > > fe
Finite element for the particle field.
IndexSet locally_relevant_dofs
Index set for the locally relevant degree of freedoms.
const bool conservative_projection
TrilinosWrappers::SparseMatrix system_matrix
void setup_dofs()
Setup the degrees of freedom. This function allocates the necessary memory.
std::shared_ptr< DoFHandler< dim > > dof_handler
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
LinearAlgebra::distributed::Vector< double > system_rhs
ParticleFieldQCM(parallel::DistributedTriangulationBase< dim > *triangulation, const unsigned int fe_degree, const bool simplex, const bool neumann_boundaries, const bool conservative_projection)
Constructor.
LinearAlgebra::distributed::Vector< double > particle_field_solution
deal.II vector for the particle field solution.
AffineConstraints< double > particle_field_constraints
Constraints used for the boundary conditions of the particle field.
bool matrix_requires_assembly
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > vertices_to_cell
IndexSet locally_owned_dofs
Index set for the locally owned degree of freedoms.
const Parameters::LinearSolver linear_solver_parameters
Linear solvers for the calculation of the void fraction.
double calculate_filter_length_from_cell_measure(const double cell_measure)
Calculate the characteristic length of the QCM filter from a cell measure.
GlobalVectorType void_fraction_locally_owned
Locally owned solution of the void fraction.
std::shared_ptr< GlobalVectorType > void_fraction_locally_relevant
void calculate_field_projection(ParticleFieldQCM< dim, property_start_index, n_components > &field_qcm)
Calculates the projection of a particle field onto the mesh.
std::shared_ptr< FiniteElement< dim > > fe
Finite element for the void fraction.
std::map< types::boundary_id, unsigned int > cfd_periodic_directions
Map of directions associated with periodic boundary conditions.
std::shared_ptr< DoFHandler< dim > > dof_handler
void calculate_void_fraction(const double time)
Calculate the void fraction.
void calculate_field_projection_impl(ParticleFieldQCM< dim, n_components, property_start_index > &field_qcm)
Templated implementation of calculate_field_projection.
static double evaluate_filter(const double r_particle, const double filter_length, const double distance)
Evaluate the QCM filter kernel selected at compile time.
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > vertices_to_periodic_cell
std::shared_ptr< Quadrature< dim > > quadrature
Quadrature for the void fraction.
void calculate_void_fraction_quadrature_centered_method()
Calculate the void fraction using the Quadrature-Centered Method (QCM).
bool particle_have_been_projected
void setup_constraints(const BoundaryConditions::FluidDynamicsBoundaryConditions< dim > &boundary_conditions)
Establish the constraints of the void fraction systems.
void calculate_void_fraction_particle_centered_method()
Calculate the void fraction using the particle centered method.
std::shared_ptr< Parameters::VoidFractionParameters< dim > > void_fraction_parameters
TrilinosWrappers::SparseMatrix system_matrix_void_fraction
std::vector< LinearAlgebra::distributed::Vector< double > > void_fraction_previous_solution
deal.II vector the previous void fraction
void write_qcm_quadrature_points(const std::string &folder, const std::string &prefix, const unsigned int group_files)
Write the location of the QCM quadrature points and the radius of the filter centered at each of them...
static double radius_sphere_equivalent_volume(const double volume)
Calculate the characteristic radius of a sphere with a given volume (area in 2D): R = (2*dim*V/pi)^(1...
virtual void solve_linear_system_and_update_solution() override
Solve the linear system resulting from the assemblies.
Tensor< 1, dim > get_periodic_offset_distance(unsigned int boundary_id) const
Calculate and return the periodic offset distance vector of the domain which is needed for the period...
std::map< types::boundary_id, Tensor< 1, dim > > cfd_periodic_offsets
Map of offsets for periodic boundary conditions.
GlobalVectorType system_rhs_void_fraction
bool multigrid_level_dofs_required
ParticleFieldQCM< dim, 3, PropertiesIndex::fem_force_two_way_coupling_x > fluid_force_on_particles_two_way_coupling
void calculate_void_fraction_function(const double time)
Calculate the void fraction using a function. This is a straightforward usage of VectorTools.
void zero_out_and_ghost_auxiliary_fields()
Zeros out and update the ghost values of the auxiliary fields. This is necessary when the void fracti...
const double l2_smoothing_factor
Smoothing length factor for the void fraction calculation.
parallel::DistributedTriangulationBase< dim > * triangulation
Triangulation.
std::shared_ptr< Mapping< dim > > mapping
Mapping for the void fraction.
void initialize_void_fraction(const double time)
Initialize the void fraction at the beginning of a simulation.
ParticleFieldQCM< dim, 1, PropertiesIndex::momentum_transfer_coefficient > momentum_transfer_coefficient
std::shared_ptr< std::vector< GlobalVectorType > > previous_void_fraction
IndexSet locally_relevant_dofs
Index set for the locally relevant degree of freedoms.
static double calculate_intersection_measure(double r_particle, double r_sphere, double distance_between_spheres)
Calculate the intersection measure (volume in 3D and area in 2D) between a particle and an hyperspher...
LinearAlgebra::distributed::Vector< double > void_fraction_solution
deal.II vector for the void fraction
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
void calculate_void_fraction_satellite_point_method()
Calculate the void fraction using the satellite point method.
AffineConstraints< double > void_fraction_constraints
bool has_periodic_boundaries
Boolean to indicate if the mesh has periodic boundaries.
void calculate_void_fraction_qcm_impl()
Templated implementation of the Quadrature-Centered Method (QCM).
Particles::ParticleHandler< dim > * particle_handler
Particle handler used when the void fraction depends on particles.
void enable_multigrid_level_dofs(const bool enabled=true)
Request that all DoFHandlers managed by this projector also distribute multigrid level DoFs the next ...
void calculate_particle_temperature_projection()
Project the particle temperature onto the fluid mesh with the QCM, then copy it into particle_tempera...
void percolate_void_fraction()
Percolate the time vector for the void fraction. This operation is called at the end of a time step....
ParticleFieldQCM< dim, 1, DEM::temperature_property_index< PropertiesIndex > > particle_temperature
ParticleProjector(parallel::DistributedTriangulationBase< dim > *triangulation, std::shared_ptr< Parameters::VoidFractionParameters< dim > > input_parameters, const Parameters::LinearSolver &linear_solver_parameters, Particles::ParticleHandler< dim > *particle_handler, const unsigned int fe_degree, const bool simplex, const ConditionalOStream &pcout)
Constructor for the void fraction calculator.
void calculate_particle_fluid_forces_projection(const Parameters::CFDDEM &cfd_dem_parameters, DoFHandler< dim > &fluid_dof_handler, const VectorType &present_velocity_pressure_solution, const std::vector< VectorType > &previous_velocity_pressure_solution, const Tensor< 1, 3 > &gravity, NavierStokesScratchData< dim > scratch_data)
Calculate all the necessary information for the particle-fluid coupling. This means calculating the p...
ParticleFieldQCM< dim, 3, PropertiesIndex::v_x > particle_velocity
void setup_dofs() override
Setup the degrees of freedom.
void solve() override
Assemble and solve the system.
std::shared_ptr< GlobalVectorType > particle_temperature_locally_relevant
ParticleFieldQCM< dim, 3, PropertiesIndex::fem_drag_x > fluid_drag_on_particles
const ConditionalOStream pcout
PhysicsLinearSubequationsSolver(const ConditionalOStream &pcout)
Constructor for physics subequations that require the use of a linear solver within the span of the p...
DEM particle property definitions and output name management.
constexpr bool has_thermal_properties
Whether a properties index set carries thermal properties.
@ gauss
Gauss quadrature rule (default).
@ gauss_lobatto
Gauss-Lobatto quadrature rule.
@ qcm
Quadrature centered method.
QCMFilterType
Filter kernel used by the Quadrature-Centered Method (QCM) to weigh particle contributions onto the m...
@ gaussian
Gaussian filter parametrised by a standard deviation sigma.
@ spherical
Spherical indicator (heaviside) filter (default, original QCM).
Parameter structures for CFD-DEM coupled simulations.
double particle_circle_intersection_2d(const double r_particle, const double r_circle, const double neighbor_distance)
Calculate the area of intersection between a circular (2D) particle and a circle. \ .
DeclExceptionMsg(NotSupportedMeshAdaptationMethod, "Mesh adaptation is only supported with the steady time-stepping method " "in the VANS and CFD-DEM solvers at the moment because the void fraction " "field is not yet updated during mesh adaptation.")
double particle_sphere_intersection_3d(const double r_particle, const double r_sphere, const double neighbor_distance)
Calculate the volume of intersection between a spherical (3D) particle and a sphere.
double gaussian_filter_kernel(const double r_particle, const double sigma, const double distance)
Evaluate a Gaussian filter kernel between a particle and a point.
Parameters for the CFD-DEM coupled solver.
LinearSolver - Parameters that control the solution of the linear system of equations that arise from...
GlobalVectorType VectorType
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType