ImplicitExplicitIntegrator< dim, number > Class Template Reference

Developer Documentation: MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number > Class Template Reference
Developer Documentation
MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number > Class Template Referencefinal

#include <implicit_explicit_integrator.hpp>

Inheritance diagram for MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >:
[legend]
Collaboration diagram for MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >:
[legend]

Public Member Functions

 ImplicitExplicitIntegrator (const TimeIntegratorData< number > &time_integrator_data)
 
unsigned required_solution_history_size () const override
 
void reinit (const VectorType &vector_template) override
 
void reinit (const SolutionHistory< VectorType > &solution_history) override
 
void configure_explicit_step (ExplicitRhsFunctionType explicit_rhs)
 Configure the function used to compute the explicit right-hand side.
 
void configure_implicit_step_wo_internal_nonlinear_solver (CustomSolverType custom_solver_in)
 
void configure_implicit_step (JacobianType jacobian, ResidualType residual, DistributeConstraintsType constraints=[](VectorType &) {})
 Configure the functions used by the internal nonlinear solver to solve the implicit step. For details on the functions see the corresponding class member descriptions.
 
void set_preconditioner (Preconditioner< dim, VectorType, number > &&preconditioner_in)
 
void perform_time_step (const number current_time, const number time_step, SolutionHistory< VectorType > &solution_history, const std::function< void(number, number, VectorType &, const VectorType &)> &stage_pre_processing, const std::function< void(number, number, VectorType &, const VectorType &)> &stage_post_processing) override
 
- Public Member Functions inherited from MeltPoolDG::TimeIntegration::TimeIntegratorBase< number >
 TimeIntegratorBase (const TimeIntegratorData< number > &time_integrator_data_in)
 
virtual ~TimeIntegratorBase ()=default
 
TimeIntegratorSchemes get_integrator_type () const
 
void set_monitoring_vector (VectorType &monitoring_vector_in)
 
void reset_monitoring_vector ()
 

Private Types

using VectorType = dealii::LinearAlgebra::distributed::Vector< number >
 
using ExplicitRhsFunctionType = std::function< void(number, number, VectorType &, const VectorType &, const bool, const std::function< void(unsigned, unsigned)> &)>
 
using JacobianType = std::function< void(number time, number time_step, VectorType &dst, const VectorType &src)>
 
using ResidualType = std::function< void(number time, number time_step, const VectorType &src, VectorType &dst, const VectorType &explicit_solution)>
 
using DistributeConstraintsType = std::function< void(VectorType &dst)>
 
using CustomSolverType = std::function< void(number time, number time_step, const VectorType &explicit_step_solution, const VectorType &solution)>
 

Private Member Functions

void apply_explicit_step (number time, number time_step, const VectorType &src, VectorType &dst) const
 
void apply_implicit_step (number time, number time_step, VectorType &explicit_solution, VectorType &solution)
 

Private Attributes

ResidualType compute_residual
 Compute the negative residual for the implicit step of the time integrator.
 
JacobianType compute_jacobian
 Apply the Jacobian of the residual operator to a given vector.
 
DistributeConstraintsType distribute_constraints
 
CustomSolverType custom_solver
 
ExplicitRhsFunctionType explicit_compute_rhs
 
VectorType intermediate_explicit_solution
 Vector to store the solution of the explicit step.
 
std::optional< NewtonRaphsonSolver< number, VectorType > > solver
 Nonlinear solver used when no custom solver is provided.
 
Preconditioner< dim, VectorType, number > preconditioner
 Preconditioner for the linear solver used within each nonlinear solver iteration.
 
bool preconditioner_update_flag = false
 Boolean to indicate whether the preconditioner needs to be updated before the next solve.
 
unsigned n_steps_performed = 0
 Number of time steps already performed by the integrator.
 

Additional Inherited Members

- Protected Attributes inherited from MeltPoolDG::TimeIntegration::TimeIntegratorBase< number >
const TimeIntegratorData< number > time_integrator_data
 
VectorTypemonitoring_vector = nullptr
 

Member Typedef Documentation

◆ CustomSolverType

template<unsigned int dim, typename number >
using MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::CustomSolverType = std::function<void(number time, number time_step, const VectorType &explicit_step_solution, const VectorType &solution)>
private

◆ DistributeConstraintsType

template<unsigned int dim, typename number >
using MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::DistributeConstraintsType = std::function<void(VectorType &dst)>
private

◆ ExplicitRhsFunctionType

template<unsigned int dim, typename number >
using MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::ExplicitRhsFunctionType = std::function<void(number, number, VectorType &, const VectorType &, const bool, const std::function<void(unsigned, unsigned)> &)>
private

◆ JacobianType

template<unsigned int dim, typename number >
using MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::JacobianType = std::function<void(number time, number time_step, VectorType &dst, const VectorType &src)>
private

◆ ResidualType

template<unsigned int dim, typename number >
using MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::ResidualType = std::function<void(number time, number time_step, const VectorType &src, VectorType &dst, const VectorType &explicit_solution)>
private

◆ VectorType

template<unsigned int dim, typename number >
using MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::VectorType = dealii::LinearAlgebra::distributed::Vector<number>
private

Constructor & Destructor Documentation

◆ ImplicitExplicitIntegrator()

template<unsigned int dim, typename number >
MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::ImplicitExplicitIntegrator ( const TimeIntegratorData< number > &  time_integrator_data)
explicit

Constructor. After construction it is still required to configure the explicit and implicit steps using configure_explicit_step() and configure_implicit_step() and make a call to reinit() before the integrator can be used.

Parameters
time_integrator_dataTime integrator data struct setting the scheme of the integrator.

Member Function Documentation

◆ apply_explicit_step()

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::apply_explicit_step ( number  time,
number  time_step,
const VectorType src,
VectorType dst 
) const
private

Apply the explicit and store the result in dst. The solution at \( t^n \) is given by the vector src.

◆ apply_implicit_step()

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::apply_implicit_step ( number  time,
number  time_step,
VectorType explicit_solution,
VectorType solution 
)
private

Solve the implicit step of the implicit-explicit scheme. If the function custom_solver has been set this function is used, otherwise the default nonlinear solver of the class is used. The result, i.e., the solution at the new time step, is stored in solution. The solution after the explicit step is given by explicit_solution.

◆ configure_explicit_step()

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::configure_explicit_step ( ExplicitRhsFunctionType  explicit_rhs)

Configure the function used to compute the explicit right-hand side.

Sets the class member explicit_compute_rhs to the provided function. For details on the expected function signature and behavior, see the documentation of the corresponding class member.

Parameters
explicit_rhsFunction to compute the right-hand side in the explicit step.

◆ configure_implicit_step()

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::configure_implicit_step ( JacobianType  jacobian,
ResidualType  residual,
DistributeConstraintsType  constraints = [](VectorType &) {} 
)

Configure the functions used by the internal nonlinear solver to solve the implicit step. For details on the functions see the corresponding class member descriptions.

Sets the class member compute_jacobian, compute_residual and distribute_constraints to the provided functions. For details on the expected function signatures and behavior, see the documentation of the corresponding class member.

Parameters
jacobianFunction used to apply the Jacobian to a vector.
residualFunction used to compute the residual.
constraintsFunction used to apply constraints to a vector.
Note
If a custom solver has already been set by calling configure_implicit_step(CustomSolverType) this function has no effect.

◆ configure_implicit_step_wo_internal_nonlinear_solver()

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::configure_implicit_step_wo_internal_nonlinear_solver ( CustomSolverType  custom_solver_in)

Configure a custom solver function used to solve the implicit step.

If this function is called the integrator will not use its internal nonlinear solver. For details on the functions see the corresponding class member descriptions.

Sets the class member custom_solver to the provided function. For details on the expected function signature and behavior, see the documentation of the corresponding class member.

Parameters
custom_solver_inCustom solver function to be used in the implicit step.

◆ perform_time_step()

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::perform_time_step ( const number  current_time,
const number  time_step,
SolutionHistory< VectorType > &  solution_history,
const std::function< void(number, number, VectorType &, const VectorType &)> &  stage_pre_processing,
const std::function< void(number, number, VectorType &, const VectorType &)> &  stage_post_processing 
)
overridevirtual

Perform a single time step by first computing an intermediate explicit solution using an explicit Euler step for the part of the pde which is treated explicitly. The explicit step is followed by an implicit Euler step for the implicit part of the PDE resulting in the solution at the new time step.

Parameters
current_timeCurrent time.
time_stepCurrent time step size.
solution_historySolution history object providing the current and all required previous solutions.
stage_pre_processingFunction which is executed before the explicit step.
stage_post_processingFunction which is executed after the solution at the new time step has been computed.

Implements MeltPoolDG::TimeIntegration::TimeIntegratorBase< number >.

◆ reinit() [1/2]

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::reinit ( const SolutionHistory< VectorType > &  solution_history)
overridevirtual

Sets up the necessary internal data structures by internally calling reinit(solution_history.get_current_solution()).

Reimplemented from MeltPoolDG::TimeIntegration::TimeIntegratorBase< number >.

◆ reinit() [2/2]

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::reinit ( const VectorType vector_template)
overridevirtual

Allocate memory for the required vectors used during the integration. This function needs to be called once before the function perform_time_step() can be called.

Parameters
vector_templateReference vector used to define the partitioning for all internal vectors.

Implements MeltPoolDG::TimeIntegration::TimeIntegratorBase< number >.

◆ required_solution_history_size()

template<unsigned int dim, typename number >
unsigned MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::required_solution_history_size ( ) const
overridevirtual

Returns the number of previous solutions, that is solutions at time step n - x, where x >= 0, required by the time integrator.

Implements MeltPoolDG::TimeIntegration::TimeIntegratorBase< number >.

◆ set_preconditioner()

template<unsigned int dim, typename number >
void MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::set_preconditioner ( Preconditioner< dim, VectorType, number > &&  preconditioner_in)

Set the preconditioner used in the linear solver of the implicit step. If this function is never called an identity preconditioner is used.

Parameters
preconditioner_inPreconditioner to be used in the linear solver of the implicit step.
Note
The precondiitioner is only used for the default internal solver of the class. If a custom solver function is set it is not used at all.

Member Data Documentation

◆ compute_jacobian

template<unsigned int dim, typename number >
JacobianType MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::compute_jacobian
private

Apply the Jacobian of the residual operator to a given vector.

This function computes the action of the Jacobian, associated with the residual

\[ R = \frac{y^{n+1} - \tilde{y}}{\Delta t} - G(y^{n+1}), \]

on the input vector src and stores the result in dst.

Function Signature:

void f(number time,
number time_step,
VectorType &dst,
const VectorType &src);
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition implicit_explicit_integrator.hpp:24

Parameters:

  • time : Current simulation time \(t^n\).
  • time_step : Current time step size \(\Delta t\).
  • dst : Destination vector to store the Jacobian–vector product.
  • src : Input vector to which the Jacobian is applied.
Note
This function is only used if the internal nonlinear solver of the class is used.

◆ compute_residual

template<unsigned int dim, typename number >
ResidualType MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::compute_residual
private

Compute the negative residual for the implicit step of the time integrator.

Assuming that the explicit part of the update

\[ \tilde{y} = y^{n} + \Delta t F(y^{n}) \]

has already been computed and is provided as explicit_step_solution, this function evaluates the residual of the implicit equation

\[ R = \frac{y^{n+1} - \tilde{y}}{\Delta t} - G(y^{n+1}), \]

and returns its negative, i.e., \( -R \). The negative residual is required directly by the internal nonlinear solver.

Function Signature:

void f(number time,
number time_step,
VectorType &dst,
const VectorType &src,
const VectorType &explicit_step_solution);

Parameters:

  • time : Current simulation time \(t^n\).
  • time_step : Current time step size \(\Delta t\).
  • dst : Destination vector to store the negative residual.
  • src : Current solution vector, i.e., \( y^{n+1} \).
  • explicit_step_solution : Result \(\tilde{y}\) from the explicit step. This vector may be modified safely, as it will be overwritten during the next integration step.
Note
This function is only used if the internal nonlinear solver of the class is used.

◆ custom_solver

template<unsigned int dim, typename number >
CustomSolverType MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::custom_solver
private

Solve the implicit step of the implicit–explicit scheme.

For an ODE of the form

\[ \dot{y} = F(y) + G(y), \]

where \(F\) is treated explicitly and \(G\) implicitly, this function advances the solution by one time step.

Having already computed the explicit part

\[ \tilde{y} = y^{n} + \Delta t F(y^{n}), \]

the function solves the implicit equation

\[ y^{n+1} = \tilde{y} + \Delta t G(y^{n+1}), \]

to obtain the new solution \(y^{n+1}\).

Function Signature:

void f(number time,
number time_step,
VectorType &explicit_step_solution,
VectorType &solution);

Parameters:

  • time : Current simulation time at \(t^{n+1}\).
  • time_step : Current step size \(\Delta t\).
  • explicit_step_solution : Result \(\tilde{y}\) from the explicit step. May be safely modified since it will be overwritten in the next step.
  • solution : Solution vector \(y^{n+1}\) at the new time step. On input, contains the previous solution \(y^n\); on output, the updated solution \(y^{n+1}\).

◆ distribute_constraints

template<unsigned int dim, typename number >
DistributeConstraintsType MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::distribute_constraints
private

Apply constraints to a given vector.

This function enforces problem-specific constraints (e.g., boundary conditions or degrees of freedom restrictions) directly on the input vector dst.

Function Signature:

void f(VectorType &dst);

Parameters:

  • dst : Vector to which the constraints are applied (modified in place).
Note
This function is only used if the internal nonlinear solver of the class is used.

◆ explicit_compute_rhs

template<unsigned int dim, typename number >
ExplicitRhsFunctionType MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::explicit_compute_rhs
private

Explicit right-hand side function for the ODE system

\[ y' = F(y) + G(y), \]

where \(F\) is treated explicitly and \(G\) implicitly. This function computes the explicit part \(F(y)\).

Function Signature:

void f(number time,
number time_step,
VectorType &dst,
const VectorType &src,
const bool zero_dst_vec,
std::function<void(unsigned, unsigned)> post);

Parameters:

  • time : Current simulation time at \(t^n\).
  • time_step : Current step size \(\Delta t\).
  • dst : Destination vector for the explicit RHS contribution.
  • src : Source solution vector \(y^n\).
  • zero_dst_vec : If true, zero out dst before adding contributions. This allows efficient accumulation while computing values.
  • post : Post-processing function applied after computing the RHS. Receives a range of global indices [begin, end) to process, ensuring all indices are handled. Designed for efficient integration with deal.II’s matrix-free framework.

◆ intermediate_explicit_solution

template<unsigned int dim, typename number >
VectorType MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::intermediate_explicit_solution
private

Vector to store the solution of the explicit step.

◆ n_steps_performed

template<unsigned int dim, typename number >
unsigned MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::n_steps_performed = 0
private

Number of time steps already performed by the integrator.

◆ preconditioner

template<unsigned int dim, typename number >
Preconditioner<dim, VectorType, number> MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::preconditioner
private

Preconditioner for the linear solver used within each nonlinear solver iteration.

◆ preconditioner_update_flag

template<unsigned int dim, typename number >
bool MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::preconditioner_update_flag = false
private

Boolean to indicate whether the preconditioner needs to be updated before the next solve.

◆ solver

template<unsigned int dim, typename number >
std::optional<NewtonRaphsonSolver<number, VectorType> > MeltPoolDG::TimeIntegration::ImplicitExplicitIntegrator< dim, number >::solver
private

Nonlinear solver used when no custom solver is provided.


The documentation for this class was generated from the following files: