4#ifndef lethe_subequations_interface_h
5#define lethe_subequations_interface_h
18 "The subequation validity map is not reset. Call "
19 "'set_cls_solution_and_dof_handler' before 'set_cls_solution'.");
22 InvalidSubequationSolution,
24 "The current solution of the "
27 "A new CLS solution has been set but the subequation was not solved "
33 "The " << arg1 <<
" has to be solved before " << arg2 <<
".");
38 "The " << arg1 <<
" has to be solved before " << arg2 <<
".");
64 const ConditionalOStream &p_pcout,
65 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
67 const std::shared_ptr<SimulationControl> &p_simulation_control)
72 p_simulation_control);
93 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
95 const std::shared_ptr<SimulationControl> &p_simulation_control);
106 subequation.second->setup_dofs();
124 this->
subequations.find(subequation_id)->second->setup_dofs();
135 subequation.second->solve();
152 this->
subequations.find(subequation_id)->second->solve();
160 std::vector<CLSSubequationsID>
174 const DoFHandler<dim> &
190 const DoFHandler<dim> &
208 InvalidSubequationSolution(
265 std::string subequation_string;
268 subequation_string =
"CLS phase indicator gradient L2 projection";
270 subequation_string =
"CLS curvature L2 projection";
271 else if (subequation_id ==
273 subequation_string =
"CLS PDE-based interface reinitialization";
275 throw(std::invalid_argument(
"Invalid CLSSubequationID. Options are: \n"
276 " <phase_gradient_projection>\n"
277 " <curvature_projection>\n"
278 " <pde_based_interface_reinitialization>"));
280 return subequation_string;
295 std::shared_ptr<DoFHandler<dim>> dof_handler)
315 std::shared_ptr<GlobalVectorType> solution_vector)
373 if (pair.second ==
true)
401 std::optional<std::reference_wrapper<const GlobalVectorType>>
409 std::map<CLSSubequationsID, std::shared_ptr<PhysicsSubequationsSolverBase>>
413 std::map<CLSSubequationsID, std::shared_ptr<DoFHandler<dim>>>
417 std::map<CLSSubequationsID, std::shared_ptr<GlobalVectorType>>
const ConditionalOStream pcout
Parallel consol output object.
std::optional< std::reference_wrapper< const GlobalVectorType > > cls_solution_vector
std::map< CLSSubequationsID, std::shared_ptr< DoFHandler< dim > > > subequations_dof_handler
Map of DoFHandler of subequations.
void solve_specific_subequation(const CLSSubequationsID &subequation_id)
Call solving method for a specific subequation.
const DoFHandler< dim > & get_cls_dof_handler()
Get a reference to the DoFHandler of the CLS auxiliary physics.
void set_cls_solution_and_dof_handler(const GlobalVectorType &cls_solution_vector, const DoFHandler< dim > &dof_handler_cls)
Set a new CLS solution vector and DoFHandler for the subequations to be solved and reset their validi...
std::map< CLSSubequationsID, bool > subequations_solutions_validity
void solve()
Call solving method of active subequations.
void setup_dofs()
Setup the DofHandler and the degree of freedom associated with the subequations.
const GlobalVectorType & get_solution(const CLSSubequationsID &subequation_id)
Get a reference to the solution vector of a specific subequation.
std::vector< CLSSubequationsID > get_active_subequations()
Get vector of active subequations.
~CLSSubequationsInterface()=default
Default destructor.
void setup_specific_subequation_dofs(const CLSSubequationsID &subequation_id)
Setup the DofHandler and the degree of freedom associated with the physics.
void set_solution_valid(const CLSSubequationsID &subequation_id)
Set the solution as valid after solving it.
void reset_subequations_solutions_validity()
Reset all boolean in the validity associated with active subequations to false.
std::vector< CLSSubequationsID > active_subequations
Data structure that stores all enabled subequations.
void set_dof_handler(const CLSSubequationsID &subequation_id, std::shared_ptr< DoFHandler< dim > > dof_handler)
Set the DoFHandler associated with a specific subequation in the interface.
CLSSubequationsInterface(const SimulationParameters< dim > &p_simulation_parameters, const ConditionalOStream &p_pcout, const std::shared_ptr< parallel::DistributedTriangulationBase< dim > > &p_triangulation, const std::shared_ptr< SimulationControl > &p_simulation_control)
Constructor of an interface for subequations that require the use of a solver within the span of the ...
void set_solution(const CLSSubequationsID &subequation_id, std::shared_ptr< GlobalVectorType > solution_vector)
Set the solution associated with a specific subequation in the interface.
std::map< CLSSubequationsID, std::shared_ptr< PhysicsSubequationsSolverBase > > subequations
bool validity_map_has_been_reset()
Check if all booleans in subequations_solutions_validity have been reset to false.
bool get_solution_validity(const CLSSubequationsID &subequation_id)
Check and return a boolean indicating if the solution of the subequation has been solved for the corr...
std::string get_subequation_string(const CLSSubequationsID &subequation_id)
Get the string associated with a specific subequation.
void initialize_subequations(const SimulationParameters< dim > &p_simulation_parameters, const std::shared_ptr< parallel::DistributedTriangulationBase< dim > > &p_triangulation, const std::shared_ptr< SimulationControl > &p_simulation_control)
Initialize subequations necessary for the simulation and reset subeqaution validation map.
std::map< CLSSubequationsID, std::shared_ptr< GlobalVectorType > > subequations_solutions
Present solutions map.
std::optional< std::reference_wrapper< const DoFHandler< dim > > > dof_handler_cls
CLS DoFHandler associated with solved equations.
const GlobalVectorType & get_cls_solution()
Get a reference to the phase indicator solution vector.
const DoFHandler< dim > & get_dof_handler(const CLSSubequationsID &subequation_id)
Get a reference to the DoFHandler of a specific subequation.
CLSSubequationsID
IDs associated to the different subequations solved in Lethe.
@ curvature_projection
CLS curvature L2 projection.
@ pde_based_interface_reinitialization
CLS PDE-based interface reinitialization.
@ phase_gradient_projection
CLS phase indicator gradient L2 projection.
DeclException1(InvalidSubequationSolution, std::string, "The current solution of the "<< arg1<< " is invalid. \n" "A new CLS solution has been set but the subequation was not solved " "afterwards.")
DeclExceptionMsg(ValidityMapNotReset, "The subequation validity map is not reset. Call " "'set_cls_solution_and_dof_handler' before 'set_cls_solution'.")
DeclException2(PhaseGradientProjectionIsInvalid, std::string, std::string, "The "<< arg1<< " has to be solved before "<< arg2<< ".")
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType