![]() |
Lethe Open-Source Library version 1.2.0
Developer Guide
|
#include <cahn_hilliard.h>
Public Member Functions | |
| CahnHilliard (MultiphysicsInterface< dim > *multiphysics_interface, const SimulationParameters< dim > &p_simulation_parameters, const std::shared_ptr< parallel::DistributedTriangulationBase< dim > > &p_triangulation, std::shared_ptr< SimulationControl > p_simulation_control) | |
| std::vector< OutputStruct< dim, GlobalVectorType > > | gather_output_hook () override |
| std::pair< double, double > | calculate_L2_error () |
| void | finish_simulation () override |
| void | percolate_time_vectors () override |
| void | modify_solution () override |
| void | postprocess (bool first_iteration) override |
| void | output_per_iteration_timer () override |
| void | pre_mesh_adaptation () override |
| void | post_mesh_adaptation () override |
| void | compute_error_estimate (const std::pair< const Variable, Parameters::MultipleAdaptationParameters > &ivar, dealii::Vector< float > &estimated_error_per_cell) override |
| void | compute_kelly (dealii::Vector< float > &estimated_error_per_cell, const ComponentMask &component_mask) |
| void | write_checkpoint () override |
| void | read_checkpoint () override |
| std::vector< OutputStructTableHandler > | gather_tables () override |
| const DoFHandler< dim > & | get_dof_handler () override |
| void | setup_dofs () override |
| void | set_initial_conditions () override |
| void | update_boundary_conditions () override |
| void | solve_linear_system () override |
| void | setup_ilu () |
| void | setup_amg () |
| GlobalVectorType & | get_evaluation_point () override |
| GlobalVectorType & | get_local_evaluation_point () override |
| GlobalVectorType & | get_newton_update () override |
| GlobalVectorType & | get_present_solution () override |
| GlobalVectorType & | get_system_rhs () override |
| AffineConstraints< double > & | get_nonzero_constraints () override |
| void | output_newton_update_norms () override |
| double | get_residual_rescale_metric () const override |
| Public Member Functions inherited from AuxiliaryPhysics< dim, GlobalVectorType > | |
| AuxiliaryPhysics (const Parameters::NonLinearSolver non_linear_solver_parameters) | |
| virtual | ~AuxiliaryPhysics ()=default |
| void | setup_preconditioner () override |
| virtual bool | should_solve_auxiliary_physics () |
| Public Member Functions inherited from PhysicsSolver< GlobalVectorType > | |
| PhysicsSolver (const Parameters::NonLinearSolver non_linear_solver_parameters) | |
| virtual | ~PhysicsSolver () |
| void | solve_governing_system () |
| virtual void | apply_constraints () |
| virtual double | get_current_residual () |
| virtual bool | allow_skip_linear_solve_when_residual_is_below_tolerance () const |
| unsigned int | get_current_newton_iteration () const |
Private Member Functions | |
| void | verify_consistency_of_boundary_conditions () |
| void | assemble_system_matrix () override |
| void | assemble_system_rhs () override |
| virtual void | assemble_local_system_matrix (const typename DoFHandler< dim >::active_cell_iterator &cell, CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) |
| virtual void | assemble_local_system_rhs (const typename DoFHandler< dim >::active_cell_iterator &cell, CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) |
| virtual void | setup_assemblers () |
| virtual void | copy_local_matrix_to_global_matrix (const StabilizedMethodsCopyData ©_data) |
| virtual void | copy_local_rhs_to_global_rhs (const StabilizedMethodsCopyData ©_data) |
| void | calculate_phase_statistics () |
| void | write_phase_statistics () |
| void | calculate_phase_energy () |
| void | write_phase_energy () |
| template<typename VectorType> | |
| std::pair< Tensor< 1, dim >, Tensor< 1, dim > > | calculate_barycenter (const GlobalVectorType &solution, const VectorType ¤t_solution_fd) |
| void | apply_phase_filter () |
Private Attributes | |
| MultiphysicsInterface< dim > * | multiphysics |
| TimerOutput | computing_timer |
| const SimulationParameters< dim > & | simulation_parameters |
| std::shared_ptr< parallel::DistributedTriangulationBase< dim > > | triangulation |
| std::shared_ptr< SimulationControl > | simulation_control |
| std::shared_ptr< DoFHandler< dim > > | dof_handler |
| std::shared_ptr< FESystem< dim > > | fe |
| std::shared_ptr< Mapping< dim > > | mapping |
| std::shared_ptr< Quadrature< dim > > | cell_quadrature |
| std::shared_ptr< Quadrature< dim - 1 > > | face_quadrature |
| ConvergenceTable | error_table |
| IndexSet | locally_owned_dofs |
| IndexSet | locally_relevant_dofs |
| GlobalVectorType | evaluation_point |
| GlobalVectorType | local_evaluation_point |
| GlobalVectorType | newton_update |
| std::shared_ptr< GlobalVectorType > | present_solution |
| GlobalVectorType | system_rhs |
| AffineConstraints< double > | nonzero_constraints |
| AffineConstraints< double > | zero_constraints |
| TrilinosWrappers::SparseMatrix | system_matrix |
| std::shared_ptr< TrilinosWrappers::PreconditionILU > | ilu_preconditioner |
| std::shared_ptr< TrilinosWrappers::PreconditionAMG > | amg_preconditioner |
| std::shared_ptr< GlobalVectorType > | filtered_solution |
| std::shared_ptr< std::vector< GlobalVectorType > > | previous_solutions |
| std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > | solution_transfer |
| std::vector< SolutionTransfer< dim, GlobalVectorType > > | previous_solutions_transfer |
| std::vector< std::shared_ptr< CahnHilliardAssemblerBase< dim > > > | assemblers |
| TableHandler | barycenter_table |
| TableHandler | statistics_table |
| TableHandler | phase_energy_table |
| std::shared_ptr< CahnHilliardFilterBase > | filter |
Additional Inherited Members | |
| Public Attributes inherited from PhysicsSolver< GlobalVectorType > | |
| ConditionalOStream | pcout |
| Parameters::SimulationControl::TimeSteppingMethod | time_stepping_method |
Definition at line 59 of file cahn_hilliard.h.
|
inline |
Definition at line 62 of file cahn_hilliard.h.
References AuxiliaryPhysics< dim, GlobalVectorType >::AuxiliaryPhysics(), cahn_hilliard, cell_quadrature, computing_timer, dof_handler, face_quadrature, fe, filtered_solution, mapping, maximum_number_of_previous_solutions(), multiphysics, PhysicsSolver< GlobalVectorType >::pcout, PhysicsSolver< GlobalVectorType >::physics_solving_strategy, present_solution, previous_solutions, previous_solutions_transfer, simulation_control, simulation_parameters, solution_transfer, and triangulation.
|
private |
Applies filter on phase fraction values.
Definition at line 1583 of file cahn_hilliard.cc.
References cell_quadrature, dof_handler, fe, filter, filtered_solution, locally_owned_dofs, mapping, CahnHilliardFilterBase::model_cast(), PhysicsSolver< GlobalVectorType >::pcout, present_solution, simulation_parameters, triangulation, and Parameters::verbose.
|
privatevirtual |
Assemble the local matrix for a given cell.
This function is used by the WorkStream class to assemble the system matrix. It is a thread safe function.
| cell | The cell for which the local matrix is assembled. |
| scratch_data | The scratch data which is used to store the calculated finite element information at the gauss point. See the documentation for CahnHilliardScratchData for more information |
| copy_data | The copy data which is used to store the results of the assembly over a cell |
Definition at line 127 of file cahn_hilliard.cc.
References assemblers, CahnHilliardScratchData< dim >::calculate_physical_properties(), StabilizedMethodsCopyData::cell_is_local, evaluation_point, fluid_dynamics, StabilizedMethodsCopyData::local_dof_indices, multiphysics, previous_solutions, CahnHilliardScratchData< dim >::reinit(), CahnHilliardScratchData< dim >::reinit_velocity(), StabilizedMethodsCopyData::reset(), simulation_control, simulation_parameters, and triangulation.
|
privatevirtual |
Assemble the local rhs for a given cell.
| cell | The cell for which the local matrix is assembled. |
| scratch_data | The scratch data which is used to store the calculated finite element information at the gauss point. See the documentation for CahnHilliardScratchData for more information |
| copy_data | The copy data which is used to store the results of the assembly over a cell |
Definition at line 224 of file cahn_hilliard.cc.
References assemblers, CahnHilliardScratchData< dim >::calculate_physical_properties(), StabilizedMethodsCopyData::cell_is_local, evaluation_point, fluid_dynamics, StabilizedMethodsCopyData::local_dof_indices, multiphysics, previous_solutions, CahnHilliardScratchData< dim >::reinit(), CahnHilliardScratchData< dim >::reinit_velocity(), StabilizedMethodsCopyData::reset(), simulation_control, simulation_parameters, and triangulation.
|
overrideprivatevirtual |
Assembles the matrix associated with the solver.
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 95 of file cahn_hilliard.cc.
References assemble_local_system_matrix(), computing_timer, copy_local_matrix_to_global_matrix(), dof_handler, fe, fluid_dynamics, multiphysics, setup_assemblers(), simulation_parameters, and system_matrix.
|
overrideprivatevirtual |
Assemble the rhs associated with the solver.
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 192 of file cahn_hilliard.cc.
References assemble_local_system_rhs(), computing_timer, copy_local_rhs_to_global_rhs(), dof_handler, fe, fluid_dynamics, multiphysics, setup_assemblers(), simulation_parameters, and system_rhs.
|
private |
Calculates the barycenter of fluid 1 and its velocity.
| solution | Cahn-Hilliard solution |
| current_solution_fd | Fluid dynamics solution |
Definition at line 1492 of file cahn_hilliard.cc.
References cell_quadrature, dof_handler, fe, filter, fluid_dynamics, mapping, CahnHilliardFilterBase::model_cast(), multiphysics, simulation_parameters, triangulation, and velocity.
| std::pair< double, double > CahnHilliard< dim >::calculate_L2_error | ( | ) |
Calculates the L2 error of the solution.
Definition at line 326 of file cahn_hilliard.cc.
References cell_quadrature, dof_handler, evaluation_point, fe, mapping, simulation_control, simulation_parameters, and triangulation.
|
private |
Calculate the phase energies : bulk energy, interface energy and total energy.
Definition at line 506 of file cahn_hilliard.cc.
References announce_string(), cell_quadrature, dof_handler, fe, Parameters::manual, mapping, PhysicsSolver< GlobalVectorType >::pcout, phase_energy_table, present_solution, simulation_control, simulation_parameters, triangulation, and Parameters::verbose.
|
private |
Calculate phase statistics for monitoring purposes.
Definition at line 400 of file cahn_hilliard.cc.
References announce_string(), cell_quadrature, dof_handler, fe, mapping, PhysicsSolver< GlobalVectorType >::pcout, present_solution, simulation_control, simulation_parameters, statistics_table, triangulation, and Parameters::verbose.
|
overridevirtual |
Compute the error estimator for mesh refinement.
| [in] | ivar | The current element of the map simulation_parameters.mesh_adaptation.variables |
| [in,out] | estimated_error_per_cell | The deal.II vector of estimated_error_per_cell |
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 920 of file cahn_hilliard.cc.
References chemical_potential_cahn_hilliard, compute_kelly(), fe, Parameters::MultipleAdaptationParameters::kelly, and phase_cahn_hilliard.
| void CahnHilliard< dim >::compute_kelly | ( | dealii::Vector< float > & | estimated_error_per_cell, |
| const ComponentMask & | component_mask ) |
Compute the Kelly error estimator on the phase variable for mesh refinement. See : https://www.dealii.org/current/doxygen/deal.II/classKellyErrorEstimator.html for more information on the Kelly error estimator.
| [in,out] | estimated_error_per_cell | The deal.II vector of estimated_error_per_cell |
| [in] | component_mask | The component mask corresponding to the phase variable |
Definition at line 955 of file cahn_hilliard.cc.
References dof_handler, face_quadrature, mapping, and present_solution.
|
privatevirtual |
Copy local cell information to global matrix.
Definition at line 178 of file cahn_hilliard.cc.
References StabilizedMethodsCopyData::cell_is_local, StabilizedMethodsCopyData::local_dof_indices, StabilizedMethodsCopyData::local_matrix, system_matrix, and zero_constraints.
|
privatevirtual |
Copy local cell rhs information to global rhs.
Definition at line 275 of file cahn_hilliard.cc.
References StabilizedMethodsCopyData::cell_is_local, StabilizedMethodsCopyData::local_dof_indices, StabilizedMethodsCopyData::local_rhs, system_rhs, and zero_constraints.
|
overridevirtual |
Carry out the operations required to finish a simulation correctly.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 604 of file cahn_hilliard.cc.
References announce_string(), computing_timer, Parameters::Timer::end, error_table, PhysicsSolver< GlobalVectorType >::pcout, simulation_control, simulation_parameters, Parameters::SimulationControl::steady, triangulation, and Parameters::verbose.
|
overridevirtual |
Gather and return vector of output structs that are particular to some applications.
Reimplemented from AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 289 of file cahn_hilliard.cc.
References dof_handler, filtered_solution, and present_solution.
|
overridevirtual |
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for the Cahn-Hilliard solver.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 971 of file cahn_hilliard.cc.
References barycenter_table, error_table, phase_energy_table, simulation_parameters, and statistics_table.
|
inlineoverridevirtual |
Returns the dof_handler of the Cahn-Hilliard physics.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 275 of file cahn_hilliard.h.
References dof_handler.
|
inlineoverridevirtual |
Getter methods to get the private attributes for the physic currently solved NB : dof_handler and present_solution are passed to the multiphysics interface at the end of the setup_dofs method.
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 326 of file cahn_hilliard.h.
References evaluation_point.
|
inlineoverridevirtual |
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 331 of file cahn_hilliard.h.
References local_evaluation_point.
|
inlineoverridevirtual |
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 336 of file cahn_hilliard.h.
References newton_update.
|
inlineoverridevirtual |
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 351 of file cahn_hilliard.h.
References nonzero_constraints.
|
inlineoverridevirtual |
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 341 of file cahn_hilliard.h.
References present_solution.
|
inlineoverridevirtual |
Return the metric for residual rescaling. By default, should return 1. If the rescale_residual_by_volume is set to true, the method returns the square root of the global volume of the triangulation.
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 370 of file cahn_hilliard.h.
References cahn_hilliard, mapping, simulation_parameters, and triangulation.
|
inlineoverridevirtual |
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 346 of file cahn_hilliard.h.
References system_rhs.
|
overridevirtual |
Carry out modifications on the auxiliary physic solution.
Reimplemented from AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 653 of file cahn_hilliard.cc.
References apply_phase_filter().
|
overridevirtual |
Output the L2 and Linfty norms of the correction vector.
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 1657 of file cahn_hilliard.cc.
References dof_handler, fe, newton_update, PhysicsSolver< GlobalVectorType >::pcout, and triangulation.
|
overridevirtual |
Output the per iteration wallclock times.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 867 of file cahn_hilliard.cc.
References announce_string(), computing_timer, and PhysicsSolver< GlobalVectorType >::pcout.
|
overridevirtual |
Rearrange vector solution correctly for transient simulations.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 642 of file cahn_hilliard.cc.
References present_solution, and previous_solutions.
|
overridevirtual |
post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 891 of file cahn_hilliard.cc.
References locally_owned_dofs, nonzero_constraints, present_solution, previous_solutions, previous_solutions_transfer, solution_transfer, and triangulation.
|
overridevirtual |
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all derived quantities using the solution vector of the physics. It does not concern the output of the solution using the DataOutObject, which is accomplished through the attach_solution_to_output function.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 661 of file cahn_hilliard.cc.
References announce_string(), barycenter_table, calculate_barycenter(), calculate_L2_error(), calculate_phase_energy(), calculate_phase_statistics(), error_table, fluid_dynamics, make_table_scalars_tensors(), multiphysics, PhysicsSolver< GlobalVectorType >::pcout, present_solution, simulation_control, simulation_parameters, triangulation, Parameters::verbose, write_phase_energy(), and write_phase_statistics().
|
overridevirtual |
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 878 of file cahn_hilliard.cc.
References present_solution, previous_solutions, previous_solutions_transfer, and solution_transfer.
|
overridevirtual |
Allows Cahn-Hilliard physics to set-up solution vector from checkpoint file;.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 1034 of file cahn_hilliard.cc.
References deserialize_tables_vector(), gather_tables(), locally_owned_dofs, PhysicsSolver< GlobalVectorType >::pcout, present_solution, previous_solutions, solution_transfer, and triangulation.
|
overridevirtual |
Sets-up the initial conditions associated with the physics. Generally, physics only support imposing nodal values, but some physics additionally support the use of L2 projection or steady-state solutions.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 1271 of file cahn_hilliard.cc.
References apply_phase_filter(), dof_handler, fe, mapping, newton_update, nonzero_constraints, percolate_time_vectors(), present_solution, and simulation_parameters.
| void CahnHilliard< dim >::setup_amg | ( | ) |
Set up the AMG preconditioner stored in amg_preconditioner.
Definition at line 1323 of file cahn_hilliard.cc.
References amg_preconditioner, cahn_hilliard, computing_timer, dof_handler, simulation_parameters, and system_matrix.
|
privatevirtual |
sets up the vector of assembler functions
Definition at line 34 of file cahn_hilliard.cc.
References assemblers, Parameters::manual, simulation_control, simulation_parameters, time_stepping_is_bdf(), time_stepping_is_sdirk(), and triangulation.
|
overridevirtual |
Sets-up the DofHandler and the degree of freedom associated with the physics.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 1071 of file cahn_hilliard.cc.
References cahn_hilliard, BoundaryConditions::dirichlet, dof_handler, fe, filtered_solution, local_evaluation_point, locally_owned_dofs, locally_relevant_dofs, mapping, multiphysics, newton_update, nonzero_constraints, PhysicsSolver< GlobalVectorType >::pcout, BoundaryConditions::periodic, present_solution, previous_solutions, simulation_parameters, system_matrix, system_rhs, triangulation, verify_consistency_of_boundary_conditions(), and zero_constraints.
| void CahnHilliard< dim >::setup_ilu | ( | ) |
Set up the ILU preconditioner stored in ilu_preconditioner.
Definition at line 1300 of file cahn_hilliard.cc.
References cahn_hilliard, computing_timer, ilu_preconditioner, simulation_parameters, and system_matrix.
|
overridevirtual |
Call for the solution of the linear system of equation using a strategy appropriate to the auxiliary physics.
Implements PhysicsSolver< GlobalVectorType >.
Definition at line 1404 of file cahn_hilliard.cc.
References Parameters::LinearSolver::amg, amg_preconditioner, cahn_hilliard, computing_timer, get_residual_rescale_metric(), Parameters::LinearSolver::ilu, ilu_preconditioner, locally_owned_dofs, newton_update, PhysicsSolver< GlobalVectorType >::pcout, Parameters::quiet, setup_amg(), setup_ilu(), simulation_parameters, system_matrix, system_rhs, triangulation, and zero_constraints.
|
overridevirtual |
Update non zero constraints if the boundary is time-dependent.
Reimplemented from AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 1214 of file cahn_hilliard.cc.
References BoundaryConditions::dirichlet, dof_handler, local_evaluation_point, nonzero_constraints, BoundaryConditions::periodic, present_solution, simulation_control, and simulation_parameters.
|
inlineprivate |
Verify consistency of the input parameters for boundary conditions to ensure that for every boundary condition within the triangulation, a boundary condition has been specified in the input file.
Definition at line 387 of file cahn_hilliard.h.
References simulation_parameters, and triangulation.
|
overridevirtual |
Prepares Cahn-Hilliard to write checkpoint.
Implements AuxiliaryPhysics< dim, GlobalVectorType >.
Definition at line 1010 of file cahn_hilliard.cc.
References gather_tables(), present_solution, previous_solutions, serialize_tables_vector(), solution_transfer, and triangulation.
|
private |
Definition at line 583 of file cahn_hilliard.cc.
References phase_energy_table, simulation_parameters, and triangulation.
|
private |
Writes the phase statistics to an output file.
Definition at line 489 of file cahn_hilliard.cc.
References simulation_parameters, statistics_table, and triangulation.
|
private |
AMG preconditioner used by the iterative linear solver.
Definition at line 567 of file cahn_hilliard.h.
|
private |
Definition at line 581 of file cahn_hilliard.h.
|
private |
Definition at line 584 of file cahn_hilliard.h.
|
private |
Definition at line 540 of file cahn_hilliard.h.
|
private |
Definition at line 526 of file cahn_hilliard.h.
|
private |
Definition at line 534 of file cahn_hilliard.h.
|
private |
Definition at line 544 of file cahn_hilliard.h.
|
private |
Definition at line 550 of file cahn_hilliard.h.
|
private |
Definition at line 541 of file cahn_hilliard.h.
|
private |
Definition at line 537 of file cahn_hilliard.h.
|
private |
Definition at line 593 of file cahn_hilliard.h.
|
private |
Definition at line 569 of file cahn_hilliard.h.
|
private |
ILU preconditioner used by the iterative linear solver.
Definition at line 562 of file cahn_hilliard.h.
|
private |
Definition at line 551 of file cahn_hilliard.h.
|
private |
Definition at line 547 of file cahn_hilliard.h.
|
private |
Definition at line 548 of file cahn_hilliard.h.
|
private |
Definition at line 539 of file cahn_hilliard.h.
|
private |
Definition at line 524 of file cahn_hilliard.h.
|
private |
Definition at line 552 of file cahn_hilliard.h.
|
private |
Definition at line 555 of file cahn_hilliard.h.
|
private |
Definition at line 590 of file cahn_hilliard.h.
|
private |
Definition at line 553 of file cahn_hilliard.h.
|
private |
Definition at line 573 of file cahn_hilliard.h.
|
private |
Definition at line 578 of file cahn_hilliard.h.
|
private |
Definition at line 533 of file cahn_hilliard.h.
|
private |
Definition at line 528 of file cahn_hilliard.h.
|
private |
Definition at line 576 of file cahn_hilliard.h.
|
private |
Definition at line 587 of file cahn_hilliard.h.
|
private |
Definition at line 557 of file cahn_hilliard.h.
|
private |
Definition at line 554 of file cahn_hilliard.h.
|
private |
Definition at line 532 of file cahn_hilliard.h.
|
private |
Definition at line 556 of file cahn_hilliard.h.