OGS
ProcessLib::NumericalJacobianAssembler Class Reference

Detailed Description

Base class for numerical Jacobian assemblers.

Definition at line 11 of file NumericalJacobianAssembler.h.

#include <NumericalJacobianAssembler.h>

Inheritance diagram for ProcessLib::NumericalJacobianAssembler:
[legend]
Collaboration diagram for ProcessLib::NumericalJacobianAssembler:
[legend]

Public Member Functions

 NumericalJacobianAssembler (std::vector< double > &&absolute_epsilons)
bool needsPicardAssembly () const override
void checkPerturbationSize (int const max_non_deformation_dofs_per_node) const override
void setNonDeformationComponentIDs (std::vector< int > const &non_deformation_component_ids) override
void setNonDeformationComponentIDsNoSizeCheck (std::vector< int > const &non_deformation_component_ids) override
Public Member Functions inherited from ProcessLib::AbstractJacobianAssembler
virtual void assembleWithJacobian (std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, double const t, double const dt, std::vector< double > const &local_x, std::vector< double > const &local_x_prev, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data)=0
virtual void assembleWithJacobianForStaggeredScheme (LocalAssemblerInterface &, double const, double const, Eigen::VectorXd const &, Eigen::VectorXd const &, int const, std::vector< double > &, std::vector< double > &)
virtual std::unique_ptr< AbstractJacobianAssemblercopy () const =0
virtual ~AbstractJacobianAssembler ()=default
virtual void preIteration (const unsigned)

Protected Member Functions

auto getVariableComponentEpsilonsView () const

Protected Attributes

std::vector< double > const absolute_epsilons_
std::vector< int > non_deformation_component_ids_

Constructor & Destructor Documentation

◆ NumericalJacobianAssembler()

ProcessLib::NumericalJacobianAssembler::NumericalJacobianAssembler ( std::vector< double > && absolute_epsilons)
inlineexplicit

Constructs a new instance for the numerical Jacobian.

Parameters
absolute_epsilonsperturbations of the components of the local solution vector used for evaluating the finite differences.

Definition at line 17 of file NumericalJacobianAssembler.h.

18 : absolute_epsilons_(std::move(absolute_epsilons))
19 {
20 if (absolute_epsilons_.empty())
21 {
23 "Numerical Jacobian assembler requires perturbation values "
24 "(epsilons) for finite difference approximation, but none were "
25 "provided.\n"
26 "Please specify <epsilons> in the <jacobian_assembler> section "
27 "of your project file.\n"
28 "Example: <epsilons>1e-8 1e-8</epsilons> for a process with 2 "
29 "non-deformation variables.");
30 }
31 }
#define OGS_FATAL(...)
Definition Error.h:10

References absolute_epsilons_.

Referenced by ProcessLib::CentralDifferencesJacobianAssembler::CentralDifferencesJacobianAssembler(), and ProcessLib::ForwardDifferencesJacobianAssembler::ForwardDifferencesJacobianAssembler().

Member Function Documentation

◆ checkPerturbationSize()

void ProcessLib::NumericalJacobianAssembler::checkPerturbationSize ( int const max_non_deformation_dofs_per_node) const
inlineoverridevirtual

Checks that the number of specified perturbations is not smaller than the maximum number of non-deformation degrees of freedom per node.

Implements ProcessLib::AbstractJacobianAssembler.

Definition at line 35 of file NumericalJacobianAssembler.h.

37 {
38 int const num_abs_eps = static_cast<int>(absolute_epsilons_.size());
39 if (num_abs_eps != max_non_deformation_dofs_per_node)
40 {
42 "Mismatch in numerical Jacobian perturbation configuration:\n"
43 " Provided epsilons: {:d}\n"
44 " Required epsilons: {:d} (one per non-deformation variable "
45 "component)\n\n"
46 "Each non-deformation variable needs exactly one epsilon value "
47 "for numerical differentiation.\n"
48 "Deformation variables use analytical Jacobian and do not "
49 "require epsilons.\n"
50 "Please adjust the <epsilons> array in your project file to "
51 "match the number of required components.",
52 num_abs_eps, max_non_deformation_dofs_per_node);
53 }
54 }

References absolute_epsilons_, and OGS_FATAL.

Referenced by setNonDeformationComponentIDs().

◆ getVariableComponentEpsilonsView()

auto ProcessLib::NumericalJacobianAssembler::getVariableComponentEpsilonsView ( ) const
inlineprotected

Definition at line 76 of file NumericalJacobianAssembler.h.

77 {
78 assert(!non_deformation_component_ids_.empty());
79 namespace rv = ranges::views;
81 rv::transform(
82 [this](int comp_id) -> double const&
83 {
84 return absolute_epsilons_[static_cast<std::size_t>(
85 comp_id)];
86 });
87 }

References absolute_epsilons_, and non_deformation_component_ids_.

Referenced by ProcessLib::CentralDifferencesJacobianAssembler::assembleWithJacobian(), and ProcessLib::ForwardDifferencesJacobianAssembler::assembleWithJacobian().

◆ needsPicardAssembly()

bool ProcessLib::NumericalJacobianAssembler::needsPicardAssembly ( ) const
inlineoverridevirtual

Implements ProcessLib::AbstractJacobianAssembler.

Definition at line 33 of file NumericalJacobianAssembler.h.

33{ return true; }

◆ setNonDeformationComponentIDs()

void ProcessLib::NumericalJacobianAssembler::setNonDeformationComponentIDs ( std::vector< int > const & non_deformation_component_ids)
inlineoverridevirtual

Implements ProcessLib::AbstractJacobianAssembler.

Definition at line 56 of file NumericalJacobianAssembler.h.

58 {
59 // So far, the number of specified perturbations is checked inside this
60 // function, assuming the TH2M and THM processes do not use the
61 // staggered scheme. If the staggered scheme is supported in these
62 // processes, call `checkPerturbationSize(...)` and then
63 // `setNonDeformationComponentIDsNoSizeCheck(...)` instead.
64 checkPerturbationSize(non_deformation_component_ids.size());
65
66 non_deformation_component_ids_ = non_deformation_component_ids;
67 }
void checkPerturbationSize(int const max_non_deformation_dofs_per_node) const override

References checkPerturbationSize(), and non_deformation_component_ids_.

◆ setNonDeformationComponentIDsNoSizeCheck()

void ProcessLib::NumericalJacobianAssembler::setNonDeformationComponentIDsNoSizeCheck ( std::vector< int > const & non_deformation_component_ids)
inlineoverridevirtual

Implements ProcessLib::AbstractJacobianAssembler.

Definition at line 69 of file NumericalJacobianAssembler.h.

71 {
72 non_deformation_component_ids_ = non_deformation_component_ids;
73 }

References non_deformation_component_ids_.

Member Data Documentation

◆ absolute_epsilons_

std::vector<double> const ProcessLib::NumericalJacobianAssembler::absolute_epsilons_
protected

Perturbations of the variable components used for evaluating finite differences (excluding deformation).

Note
The perturbations must be specified component-wise for each non-deformation variable. If the number of perturbations is not equal to the number of non-deformation variable components, a fatal error is issued. The deformation block of the local Jacobian matrix is calculated analytically; therefore, perturbations for deformation components are not required.

Definition at line 97 of file NumericalJacobianAssembler.h.

Referenced by NumericalJacobianAssembler(), checkPerturbationSize(), and getVariableComponentEpsilonsView().

◆ non_deformation_component_ids_

std::vector<int> ProcessLib::NumericalJacobianAssembler::non_deformation_component_ids_
protected

IDs of the components that are not deformation variables. Used by the numerical Jacobian assembler. It is manipulated by processes that use the numerical Jacobian assembler. Therefore, it is thread-safe.

Definition at line 102 of file NumericalJacobianAssembler.h.

Referenced by ProcessLib::CentralDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::ForwardDifferencesJacobianAssembler::assembleWithJacobian(), getVariableComponentEpsilonsView(), setNonDeformationComponentIDs(), and setNonDeformationComponentIDsNoSizeCheck().


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