OGS
ProcessLib::AbstractJacobianAssembler Class Referenceabstract

Detailed Description

Base class for Jacobian assemblers.

Definition at line 18 of file AbstractJacobianAssembler.h.

#include <AbstractJacobianAssembler.h>

Inheritance diagram for ProcessLib::AbstractJacobianAssembler:
[legend]

Public Member Functions

 AbstractJacobianAssembler (std::vector< double > const &&absolute_epsilons)
 AbstractJacobianAssembler ()
virtual void assembleWithJacobian (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
void checkPerturbationSize (int const max_non_deformation_dofs_per_node) const
void setNonDeformationComponentIDs (std::vector< int > const &non_deformation_component_ids)
void setNonDeformationComponentIDsNoSizeCheck (std::vector< int > const &non_deformation_component_ids)
auto getVariableComponentEpsilonsView () const
auto isPerturbationEnabled () const

Protected Attributes

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

Constructor & Destructor Documentation

◆ AbstractJacobianAssembler() [1/2]

ProcessLib::AbstractJacobianAssembler::AbstractJacobianAssembler ( std::vector< double > const && 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 24 of file AbstractJacobianAssembler.h.

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

References absolute_epsilons_.

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

◆ AbstractJacobianAssembler() [2/2]

ProcessLib::AbstractJacobianAssembler::AbstractJacobianAssembler ( )
inlineexplicit

Definition at line 41 of file AbstractJacobianAssembler.h.

41: absolute_epsilons_({}) {}

References absolute_epsilons_.

◆ ~AbstractJacobianAssembler()

virtual ProcessLib::AbstractJacobianAssembler::~AbstractJacobianAssembler ( )
virtualdefault

Member Function Documentation

◆ assembleWithJacobian()

virtual void ProcessLib::AbstractJacobianAssembler::assembleWithJacobian ( 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 )
pure virtual

◆ assembleWithJacobianForStaggeredScheme()

virtual void ProcessLib::AbstractJacobianAssembler::assembleWithJacobianForStaggeredScheme ( LocalAssemblerInterface & ,
double const ,
double const ,
Eigen::VectorXd const & ,
Eigen::VectorXd const & ,
int const ,
std::vector< double > & ,
std::vector< double > &  )
inlinevirtual

Assembles the Jacobian, the matrices \(M\) and \(K\), and the vector \(b\) with coupling.

Reimplemented in ProcessLib::AnalyticalJacobianAssembler.

Definition at line 54 of file AbstractJacobianAssembler.h.

60 {
61 // TODO make pure virtual.
62 OGS_FATAL("not implemented.");
63 }

References OGS_FATAL.

Referenced by anonymous_namespace{ParallelVectorMatrixAssembler.cpp}::assembleWithJacobianForStaggeredSchemeOneElement().

◆ checkPerturbationSize()

void ProcessLib::AbstractJacobianAssembler::checkPerturbationSize ( int const max_non_deformation_dofs_per_node) const
inline

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

Definition at line 73 of file AbstractJacobianAssembler.h.

75 {
76 if (absolute_epsilons_.empty())
77 { // No epsilons specified — this assembler is used for the Picard
78 // nonlinear solver or for the Newton nonlinear solver with
79 // analytical Jacobian, so there is nothing to do.
80 return;
81 }
82
83 int const num_abs_eps = static_cast<int>(absolute_epsilons_.size());
84 if (num_abs_eps != max_non_deformation_dofs_per_node)
85 {
87 "Mismatch in numerical Jacobian perturbation configuration:\n"
88 " Provided epsilons: {:d}\n"
89 " Required epsilons: {:d} (one per non-deformation variable "
90 "component)\n\n"
91 "Each non-deformation variable needs exactly one epsilon value "
92 "for numerical differentiation.\n"
93 "Deformation variables use analytical Jacobian and do not "
94 "require epsilons.\n"
95 "Please adjust the <epsilons> array in your project file to "
96 "match the number of required components.",
97 num_abs_eps, max_non_deformation_dofs_per_node);
98 }
99 }

References absolute_epsilons_, and OGS_FATAL.

Referenced by setNonDeformationComponentIDs().

◆ copy()

◆ getVariableComponentEpsilonsView()

auto ProcessLib::AbstractJacobianAssembler::getVariableComponentEpsilonsView ( ) const
inline

Definition at line 129 of file AbstractJacobianAssembler.h.

130 {
131 assert(!non_deformation_component_ids_.empty());
132 namespace rv = ranges::views;
134 rv::transform(
135 [this](int comp_id) -> double const&
136 {
137 return absolute_epsilons_[static_cast<std::size_t>(
138 comp_id)];
139 });
140 }

References absolute_epsilons_, and non_deformation_component_ids_.

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

◆ isPerturbationEnabled()

auto ProcessLib::AbstractJacobianAssembler::isPerturbationEnabled ( ) const
inline

Definition at line 142 of file AbstractJacobianAssembler.h.

142{ return !absolute_epsilons_.empty(); }

References absolute_epsilons_.

◆ setNonDeformationComponentIDs()

void ProcessLib::AbstractJacobianAssembler::setNonDeformationComponentIDs ( std::vector< int > const & non_deformation_component_ids)
inline

Definition at line 101 of file AbstractJacobianAssembler.h.

103 {
104 // Repeated in checkPerturbationSize to cover staggered scheme in TH2M
105 // and THM, which may be supported in future.
106 if (absolute_epsilons_.empty())
107 { // No epsilons specified — this assembler is used for the Picard
108 // nonlinear solver or for the Newton nonlinear solver with
109 // analytical Jacobian, so there is nothing to do.
110 return;
111 }
112
113 // So far, the number of specified perturbations is checked inside this
114 // function, assuming the TH2M and THM processes do not use the
115 // staggered scheme. If the staggered scheme is supported in these
116 // processes, call `checkPerturbationSize(...)` and then
117 // `setNonDeformationComponentIDsNoSizeCheck(...)` instead.
118 checkPerturbationSize(non_deformation_component_ids.size());
119
120 non_deformation_component_ids_ = non_deformation_component_ids;
121 }
void checkPerturbationSize(int const max_non_deformation_dofs_per_node) const

References absolute_epsilons_, checkPerturbationSize(), and non_deformation_component_ids_.

◆ setNonDeformationComponentIDsNoSizeCheck()

void ProcessLib::AbstractJacobianAssembler::setNonDeformationComponentIDsNoSizeCheck ( std::vector< int > const & non_deformation_component_ids)
inline

Definition at line 123 of file AbstractJacobianAssembler.h.

125 {
126 non_deformation_component_ids_ = non_deformation_component_ids;
127 }

References non_deformation_component_ids_.

Member Data Documentation

◆ absolute_epsilons_

std::vector<double> const ProcessLib::AbstractJacobianAssembler::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 158 of file AbstractJacobianAssembler.h.

Referenced by AbstractJacobianAssembler(), AbstractJacobianAssembler(), checkPerturbationSize(), getVariableComponentEpsilonsView(), isPerturbationEnabled(), and setNonDeformationComponentIDs().

◆ non_deformation_component_ids_

std::vector<int> ProcessLib::AbstractJacobianAssembler::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 148 of file AbstractJacobianAssembler.h.

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


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