22 #ifndef _aspect_simulator_h 23 #define _aspect_simulator_h 25 #include <deal.II/base/timer.h> 26 #include <deal.II/base/parameter_handler.h> 27 #include <deal.II/base/conditional_ostream.h> 28 #include <deal.II/base/symmetric_tensor.h> 30 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
32 #include <deal.II/lac/affine_constraints.h> 34 #include <deal.II/distributed/tria.h> 36 #include <deal.II/dofs/dof_handler.h> 37 #include <deal.II/dofs/dof_tools.h> 39 #include <deal.II/fe/fe_system.h> 40 #include <deal.II/fe/mapping.h> 41 #include <deal.II/base/tensor_function.h> 43 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
69 #include <boost/iostreams/tee.hpp> 70 #include <boost/iostreams/stream.hpp> 89 template <
int dim,
int velocity_degree>
92 namespace MeshDeformation
147 scalar_moment_of_inertia(numbers::signaling_nan<double>()),
148 scalar_angular_momentum(numbers::signaling_nan<double>()),
149 scalar_rotation(numbers::signaling_nan<double>()),
150 tensor_moment_of_inertia(numbers::signaling_nan<SymmetricTensor<2,dim>>()),
151 tensor_angular_momentum(numbers::signaling_nan<Tensor<1,dim>>()),
152 tensor_rotation(numbers::signaling_nan<Tensor<1,dim>>())
175 "Nonlinear solver failed to converge in the prescribed number of steps. " 176 "Consider changing `Max nonlinear iterations` or `Nonlinear solver failure " 203 Simulator (
const MPI_Comm mpi_communicator,
204 ParameterHandler &prm);
300 const unsigned int compositional_variable = numbers::invalid_unsigned_int);
320 AdvectionField composition (
const unsigned int compositional_variable);
326 is_temperature ()
const;
361 unsigned int sparsity_pattern_block_index(
const Introspection<dim> &introspection)
const;
369 unsigned int field_index()
const;
384 FEValuesExtractors::Scalar scalar_extractor(
const Introspection<dim> &introspection)
const;
467 void setup_introspection ();
480 void set_initial_temperature_and_compositional_fields ();
497 void compute_initial_pressure_field ();
504 void compute_initial_velocity_boundary_constraints (AffineConstraints<double> &constraints);
511 void compute_current_velocity_boundary_constraints (AffineConstraints<double> &constraints);
525 void compute_current_constraints ();
540 double compute_pressure_scaling_factor ()
const;
553 void start_timestep ();
562 void solve_timestep ();
575 void solve_single_advection_single_stokes ();
589 void solve_no_advection_iterated_stokes ();
601 void solve_no_advection_single_stokes ();
614 void solve_first_timestep_only_single_stokes ();
628 void solve_iterated_advection_and_stokes ();
642 void solve_single_advection_iterated_stokes ();
656 void solve_no_advection_iterated_defect_correction_stokes ();
670 void solve_single_advection_iterated_defect_correction_stokes ();
685 void solve_iterated_advection_and_defect_correction_stokes ();
705 void solve_iterated_advection_and_newton_stokes (
bool use_newton_iterations);
726 void solve_single_advection_and_iterated_newton_stokes (
bool use_newton_iterations);
739 void solve_single_advection_no_stokes ();
752 void solve_no_advection_no_stokes ();
762 void build_stokes_preconditioner ();
771 void build_advection_preconditioner (
const AdvectionField &advection_field,
773 const double diagonal_strengthening);
781 void assemble_stokes_system ();
797 double assemble_and_solve_temperature (
const double &initial_residual = 0,
798 double *residual =
nullptr);
815 std::vector<double> assemble_and_solve_composition (
const std::vector<double> &initial_residual = {},
816 std::vector<double> *residual =
nullptr);
832 double assemble_and_solve_stokes (
const double &initial_nonlinear_residual = 0,
833 double *nonlinear_residual =
nullptr);
848 const bool use_picard);
857 void assemble_advection_system (
const AdvectionField &advection_field);
875 void interpolate_particle_properties (
const std::vector<AdvectionField> &advection_fields);
953 std::pair<double,double>
985 void refine_mesh (
const unsigned int max_grid_level);
1007 void create_snapshot();
1022 void resume_from_snapshot();
1030 template <
class Archive>
1031 void serialize (Archive &ar,
const unsigned int version);
1048 Table<2,DoFTools::Coupling>
1049 setup_system_matrix_coupling ()
const;
1058 void setup_system_matrix (
const std::vector<IndexSet> &system_partitioning);
1071 void setup_system_preconditioner (
const std::vector<IndexSet> &system_partitioning);
1104 void set_assemblers ();
1116 void set_advection_assemblers ();
1127 void set_stokes_assemblers ();
1135 void assemble_stokes_preconditioner ();
1145 local_assemble_stokes_preconditioner (
const typename DoFHandler<dim>::active_cell_iterator &cell,
1167 local_assemble_stokes_system (
const typename DoFHandler<dim>::active_cell_iterator &cell,
1189 local_assemble_advection_face_terms(
const AdvectionField &advection_field,
1190 const typename DoFHandler<dim>::active_cell_iterator &cell,
1201 local_assemble_advection_system (
const AdvectionField &advection_field,
1202 const Vector<double> &viscosity_per_cell,
1203 const typename DoFHandler<dim>::active_cell_iterator &cell,
1215 copy_local_to_global_advection_system (
const AdvectionField &advection_field,
1253 template <
typename T>
1254 void get_artificial_viscosity (Vector<T> &viscosity_per_cell,
1256 const bool skip_interior_cells =
false)
const;
1269 void compute_Vs_anomaly(Vector<float> &values)
const;
1285 void compute_Vp_anomaly(Vector<float> &values)
const;
1360 void denormalize_pressure(
const double pressure_adjustment,
1371 void apply_limiter_to_dg_solutions (
const AdvectionField &advection_field);
1396 void compute_reactions ();
1407 void update_solution_vectors_with_reaction_results (
const unsigned int block_index,
1421 void initialize_current_linearization_point ();
1442 void interpolate_material_output_into_advection_field (
const AdvectionField &adv_field);
1452 void interpolate_onto_velocity_system(
const TensorFunction<1,dim> &func,
1470 void setup_nullspace_constraints(AffineConstraints<double> &constraints);
1502 compute_net_angular_momentum(
const bool use_constant_density,
1504 const bool limit_to_top_faces =
false)
const;
1522 void remove_net_angular_momentum(
const bool use_constant_density,
1525 const bool limit_to_top_faces =
false)
const;
1534 void replace_outflow_boundary_ids(
const unsigned int boundary_id_offset);
1543 void restore_outflow_boundary_ids(
const unsigned int boundary_id_offset);
1558 void remove_net_linear_momentum(
const bool use_constant_density,
1583 double get_entropy_variation (
const double average_field,
1594 std::pair<double,double>
1595 get_extrapolated_advection_field_range (
const AdvectionField &advection_field)
const;
1605 void exchange_refinement_flags();
1616 void maybe_write_timing_output ()
const;
1625 bool maybe_write_checkpoint (
const time_t last_checkpoint_time,
1626 const bool force_writing_checkpoint);
1644 bool maybe_do_initial_refinement (
const unsigned int max_refinement_level);
1654 void maybe_refine_mesh (
const double new_time_step,
1655 unsigned int &max_refinement_level);
1664 void advance_time (
const double step_size);
1675 const double global_u_infty,
1676 const double global_field_variation,
1677 const double average_field,
1678 const double global_entropy_variation,
1679 const double cell_diameter,
1692 const double average_field,
1694 double &max_residual,
1695 double &max_velocity,
1696 double &max_density,
1697 double &max_specific_heat,
1698 double &conductivity)
const;
1715 stokes_matrix_depends_on_solution ()
const;
1727 stokes_A_block_is_symmetric ()
const;
1742 check_consistency_of_formulation ();
1750 select_default_solver_and_averaging ();
1763 check_consistency_of_boundary_conditions ()
const;
1769 compute_initial_newton_residual ();
1780 compute_Eisenstat_Walker_linear_tolerance(
const bool EisenstatWalkerChoiceOne,
1781 const double maximum_linear_stokes_solver_tolerance,
1782 const double linear_stokes_solver_tolerance,
1783 const double stokes_residual,
1784 const double newton_residual,
1785 const double newton_residual_old);
1796 void output_statistics();
1810 compute_initial_stokes_residual();
1861 using TeeDevice = boost::iostreams::tee_device<std::ostream, std::ofstream>;
1955 #ifdef ASPECT_WITH_WORLD_BUILDER 1967 std::shared_ptr<WorldBuilder::World> world_builder;
2158 friend class boost::serialization::access;
2163 template <
int dimension,
int velocity_degree>
The NullspaceRemoval struct.
unsigned int nonlinear_iteration
BoundaryVelocity::Manager< dim > boundary_velocity_manager
const std::unique_ptr< AdiabaticConditions::Interface< dim > > adiabatic_conditions
std::shared_ptr< InitialComposition::Manager< dim > > initial_composition_manager
void write_plugin_graph(std::ostream &output_stream)
parallel::distributed::Triangulation< dim > triangulation
TimerOutput computing_timer
BoundaryTemperature::Manager< dim > boundary_temperature_manager
boost::iostreams::tee_device< std::ostream, std::ofstream > TeeDevice
::TrilinosWrappers::MPI::BlockVector BlockVector
double scalar_moment_of_inertia
Tensor< 1, dim > tensor_rotation
Tensor< 1, dim > tensor_angular_momentum
AffineConstraints< double > constraints
bool assemble_newton_stokes_system
double scalar_angular_momentum
LinearAlgebra::BlockVector old_solution
const IntermediaryConstructorAction post_geometry_model_creation_action
std::unique_ptr< VolumeOfFluidHandler< dim > > volume_of_fluid_handler
bool rebuild_stokes_matrix
Parameters< dim > parameters
SymmetricTensor< 2, dim > tensor_moment_of_inertia
AffineConstraints< double > current_constraints
std::unique_ptr< MeshDeformation::MeshDeformationHandler< dim > > mesh_deformation
LinearAlgebra::BlockVector system_rhs
std::pair< double, double > stokes_residuals
std::vector< Particle::Manager< dim > > particle_managers
std::thread output_statistics_thread
LateralAveraging< dim > lateral_averaging
DeclExceptionMsg(ExcNonlinearSolverNoConvergence, "Nonlinear solver failed to converge in the prescribed number of steps. " "Consider changing `Max nonlinear iterations` or `Nonlinear solver failure " "strategy`.")
TeeStream iostream_tee_stream
::TrilinosWrappers::MPI::Vector Vector
MeshRefinement::Manager< dim > mesh_refinement_manager
std::size_t statistics_last_write_size
const std::unique_ptr< MaterialModel::Interface< dim > > material_model
unsigned int nonlinear_solver_failures
double last_pressure_normalization_adjustment
::TrilinosWrappers::BlockSparseMatrix BlockSparseMatrix
double total_walltime_until_last_snapshot
void declare_parameters(ParameterHandler &prm)
const std::unique_ptr< GeometryModel::Interface< dim > > geometry_model
LinearAlgebra::BlockVector operator_split_reaction_vector
DoFHandler< dim > dof_handler
std::unique_ptr< StokesMatrixFreeHandler< dim > > stokes_matrix_free
std::unique_ptr< Assemblers::Manager< dim > > assemblers
bool rebuild_sparsity_and_matrices
const IntermediaryConstructorAction post_signal_creation
double global_Omega_diameter
unsigned int timestep_number
bool assemble_newton_stokes_matrix
unsigned int pre_refinement_step
TimeStepping::Manager< dim > time_stepping_manager
std::size_t statistics_last_hash
Introspection< dim > introspection
MPI_Comm mpi_communicator
typename Parameters< dim >::NullspaceRemoval NullspaceRemoval
LinearAlgebra::BlockSparseMatrix system_preconditioner_matrix
bool do_pressure_rhs_compatibility_modification
LinearAlgebra::BlockVector current_linearization_point
LinearAlgebra::BlockVector old_old_solution
BoundaryTraction::Manager< dim > boundary_traction_manager
LinearAlgebra::BlockVector pressure_shape_function_integrals
std::ofstream log_file_stream
std::unique_ptr< LinearAlgebra::PreconditionAMG > Amg_preconditioner
const FieldType field_type
std::shared_ptr< InitialTemperature::Manager< dim > > initial_temperature_manager
TeeDevice iostream_tee_device
boost::iostreams::stream< TeeDevice > TeeStream
LinearAlgebra::BlockSparseMatrix system_matrix
std::unique_ptr< MeltHandler< dim > > melt_handler
LinearAlgebra::BlockVector inverse_lumped_mass_matrix
bool rebuild_stokes_preconditioner
const unsigned int compositional_variable
std::unique_ptr< Mapping< dim > > mapping
const std::unique_ptr< PrescribedStokesSolution::Interface< dim > > prescribed_stokes_solution
double switch_initial_residual
HeatingModel::Manager< dim > heating_model_manager
SimulatorSignals< dim > signals
const std::unique_ptr< BoundaryHeatFlux::Interface< dim > > boundary_heat_flux
const FESystem< dim > finite_element
bool simulator_is_past_initialization
const std::unique_ptr< InitialTopographyModel::Interface< dim > > initial_topography_model
LinearAlgebra::BlockVector solution
std::unique_ptr< NewtonHandler< dim > > newton_handler
typename Parameters< dim >::NonlinearSolver NonlinearSolver
Postprocess::Manager< dim > postprocess_manager
const std::unique_ptr< GravityModel::Interface< dim > > gravity_model
double newton_residual_for_derivative_scaling_factor
BoundaryComposition::Manager< dim > boundary_composition_manager
std::unique_ptr< LinearAlgebra::PreconditionBase > Mp_preconditioner
::TrilinosWrappers::PreconditionILU PreconditionILU