4#ifndef lethe_cls_pde_based_interface_reinitialization_h
5#define lethe_cls_pde_based_interface_reinitialization_h
13#include <deal.II/base/work_stream.h>
15#include <deal.II/distributed/tria_base.h>
17#include <deal.II/fe/fe_q.h>
18#include <deal.II/fe/fe_simplex_p.h>
19#include <deal.II/fe/mapping_fe.h>
20#include <deal.II/fe/mapping_q.h>
22#include <deal.II/grid/grid_tools.h>
24#include <deal.II/lac/trilinos_sparse_matrix.h>
25#include <deal.II/lac/trilinos_vector.h>
56 const ConditionalOStream &p_pcout,
57 std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
59 const std::shared_ptr<SimulationControl> &p_simulation_control,
62 p_simulation_parameters.cls_subequations_non_linear_solvers.at(
72 .reinitialization_method.verbosity)
80 this->
fe = std::make_shared<FE_SimplexP<dim>>(
82 this->
mapping = std::make_shared<MappingFE<dim>>(*this->
fe);
84 std::make_shared<QGaussSimplex<dim>>(this->
fe->degree + 1);
89 this->
fe = std::make_shared<FE_Q<dim>>(
91 this->
mapping = std::make_shared<MappingQ<dim>>(this->
fe->degree);
93 std::make_shared<QGauss<dim>>(this->
fe->degree + 1);
188 AffineConstraints<double> &
201 this->
pcout <<
"\t ||dphi_reinit||_L2 = " << std::setw(6)
203 <<
"\t ||dphi_reinit||_Linfty = "
218 .rescale_residual_by_volume ?
247 const double multiplier =
249 .reinitialization_method.pde_based_interface_reinitialization
250 .diffusivity_multiplier;
253 .reinitialization_method.pde_based_interface_reinitialization
255 return multiplier * std::pow(min_cell_size, power);
268 const double dtau_factor =
270 .reinitialization_method.pde_based_interface_reinitialization
284 const double dtau = h_min * h_min * diffusivity_inv * dtau_factor;
340 if (step_number == 1)
342 return (step_number <
344 .reinitialization_method
345 .pde_based_interface_reinitialization.max_steps_number +
351 double steady_state_criterion =
353 .reinitialization_method.pde_based_interface_reinitialization
354 .steady_state_criterion;
361 double stop_criterion =
362 solution_diff.l2_norm() /
368 <<
"PDE-based reinitialization solution norm difference = "
369 << solution_diff.l2_norm() << std::endl;
371 <<
"PDE-based reinitialization steady-state criterion value = "
372 << stop_criterion << std::endl;
374 <<
"PDE-based reinitialization fixed steady-state criterion = "
375 << steady_state_criterion << std::endl;
378 return ((stop_criterion > steady_state_criterion) &&
381 .reinitialization_method
382 .pde_based_interface_reinitialization.max_steps_number +
413 std::shared_ptr<FiniteElement<dim>>
fe;
GlobalVectorType & get_local_evaluation_point() override
Getter method to access the private attribute local_evaluation_point for the subequation currently so...
std::shared_ptr< FiniteElement< dim > > fe
double get_residual_rescale_metric() const override
Return the metric for residual rescaling. By default, should return 1. If the rescale_residual_by_vol...
~CLSPDEBasedInterfaceReinitialization()=default
Default destructor.
AffineConstraints< double > & get_nonzero_constraints() override
Getter method to access the private attribute nonzero_constraints for the subequation currently solve...
void assemble_system_matrix() override
Assemble the matrix.
AffineConstraints< double > nonzero_constraints
CLSSubequationsInterface< dim > & subequations_interface
GlobalVectorType newton_update
void define_zero_constraints()
Define the zero constraints used to solve the problem.
std::shared_ptr< Mapping< dim > > mapping
void setup_dofs() override
Set up the DofHandler and the degree of freedom associated with the subequation.
IndexSet locally_relevant_dofs
GlobalVectorType & get_present_solution() override
Getter method to access the private attribute present_solution for the subequation currently solved.
void set_initial_conditions()
Sets-up the initial conditions associated with the subequation.
const CLSSubequationsID subequation_id
void output_newton_update_norms() override
Output the and norms of the correction vector.
GlobalVectorType previous_local_evaluation_point
void assemble_system_rhs() override
Assemble the right-hand side (rhs).
IndexSet locally_owned_dofs
void define_non_zero_constraints()
Define the non zero constraints used to solve the problem.
double compute_time_step()
Computes PDE-based reinitialization time step value with user-imposed CFL and minimum cell size.
TrilinosWrappers::SparseMatrix system_matrix
std::shared_ptr< GlobalVectorType > present_solution
GlobalVectorType previous_solution
std::shared_ptr< DoFHandler< dim > > dof_handler
bool continue_iterating(const unsigned int step_number)
Indicate if the PDE-based reinitialization should continue by checking if at least one of the two sto...
const SimulationParameters< dim > & simulation_parameters
void check_dependencies_validity()
Check if the phase gradient and curvature L2 projections have been solved.
GlobalVectorType evaluation_point
double compute_diffusivity(const double min_cell_size) const
Computes mesh-dependant diffusivity coefficient value.
AffineConstraints< double > zero_constraints
std::shared_ptr< Quadrature< dim > > cell_quadrature
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
void solve() override
Solve interface PDE-based reinitialization process until one of the stop criteria is met.
std::shared_ptr< SimulationControl > simulation_control
GlobalVectorType & get_evaluation_point() override
Getter method to access the private attribute evaluation_point for the subequation currently solved.
GlobalVectorType local_evaluation_point
GlobalVectorType & get_system_rhs() override
Getter method to access the private attribute system_rhs for the subequation currently solved.
void write_output_results(const unsigned int step)
Write parallel VTU files of quantities of interest for the PDE-based interface reinitialization proce...
CLSPDEBasedInterfaceReinitialization(const SimulationParameters< dim > &p_simulation_parameters, const ConditionalOStream &p_pcout, std::shared_ptr< parallel::DistributedTriangulationBase< dim > > p_triangulation, const std::shared_ptr< SimulationControl > &p_simulation_control, CLSSubequationsInterface< dim > &p_subequations_interface)
Constructor of the CLS PDE-based interface reinitialization.
GlobalVectorType system_rhs
GlobalVectorType & get_newton_update() override
Getter method to access the private attribute newton_update for the subequation currently solved.
const Parameters::Verbosity subequation_verbosity
void solve_linear_system() override
Solve the linear system.
std::vector< double > time_step_vector
Interface for secondary equations (subequations) solved within the CLS auxiliary physics.
The PVDHandler class manages the storage of the information required to write pvd file....
const ConditionalOStream pcout
PhysicsNonlinearSubequationsSolver(const Parameters::NonLinearSolver non_linear_solver_parameters, const ConditionalOStream &pcout)
CLSSubequationsID
IDs associated to the different subequations solved in Lethe.
@ pde_based_interface_reinitialization
CLS PDE-based interface reinitialization.
double identify_minimum_cell_size(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const Quadrature< dim > &cell_quadrature, const MPI_Comm &mpi_communicator)
Identify minimum cell size. The cell size corresponds to the diameter of a disk (2D) or sphere (3D) o...
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType