Calculates the local residual and its Jacobian for a single element of the grid. More...

#include <fvbaseadlocallinearizer.hh>

Public Member Functions

 FvBaseAdLocalLinearizer ()
 
 FvBaseAdLocalLinearizer (const FvBaseAdLocalLinearizer &)=delete
 
 ~FvBaseAdLocalLinearizer ()
 
void init (Simulator &simulator)
 Initialize the local Jacobian object. More...
 
void linearize (const Element &element)
 Compute an element's local Jacobian matrix and evaluate its residual. More...
 
void linearize (ElementContext &elemCtx, const Element &elem)
 Compute an element's local Jacobian matrix and evaluate its residual. More...
 
LocalResidual & localResidual ()
 Return reference to the local residual. More...
 
const LocalResidual & localResidual () const
 Return reference to the local residual. More...
 
const ScalarMatrixBlock & jacobian (unsigned domainScvIdx, unsigned rangeScvIdx) const
 Returns the local Jacobian matrix of the residual of a sub-control volume. More...
 
const ScalarVectorBlock & residual (unsigned dofIdx) const
 Returns the local residual of a sub-control volume. More...
 

Static Public Member Functions

static void registerParameters ()
 Register all run-time parameters for the local jacobian. More...
 

Protected Member Functions

Implementation & asImp_ ()
 
const Implementation & asImp_ () const
 
const Simulator & simulator_ () const
 
const Problem & problem_ () const
 
const Model & model_ () const
 
void resize_ (const ElementContext &elemCtx)
 Resize all internal attributes to the size of the element. More...
 
void reset_ (const ElementContext &)
 Reset the all relevant internal attributes to 0. More...
 
void updateLocalLinearization_ (const ElementContext &elemCtx, unsigned focusDofIdx)
 Updates the current local Jacobian matrix with the partial derivatives of all equations for the degree of freedom associated with 'focusDofIdx'. More...
 

Protected Attributes

Simulator * simulatorPtr_
 
Model * modelPtr_
 
ElementContext * internalElemContext_
 
LocalResidual localResidual_
 
ScalarLocalBlockVector residual_
 
ScalarLocalBlockMatrix jacobian_
 

Detailed Description

template<class TypeTag>
class Opm::FvBaseAdLocalLinearizer< TypeTag >

Calculates the local residual and its Jacobian for a single element of the grid.

This class uses automatic differentiation to calculate the partial derivatives (the alternative is finite differences).

Constructor & Destructor Documentation

◆ FvBaseAdLocalLinearizer() [1/2]

template<class TypeTag >
Opm::FvBaseAdLocalLinearizer< TypeTag >::FvBaseAdLocalLinearizer ( )
inline

◆ FvBaseAdLocalLinearizer() [2/2]

template<class TypeTag >
Opm::FvBaseAdLocalLinearizer< TypeTag >::FvBaseAdLocalLinearizer ( const FvBaseAdLocalLinearizer< TypeTag > &  )
delete

◆ ~FvBaseAdLocalLinearizer()

Member Function Documentation

◆ asImp_() [1/2]

template<class TypeTag >
Implementation & Opm::FvBaseAdLocalLinearizer< TypeTag >::asImp_ ( )
inlineprotected

◆ asImp_() [2/2]

template<class TypeTag >
const Implementation & Opm::FvBaseAdLocalLinearizer< TypeTag >::asImp_ ( ) const
inlineprotected

◆ init()

template<class TypeTag >
void Opm::FvBaseAdLocalLinearizer< TypeTag >::init ( Simulator &  simulator)
inline

Initialize the local Jacobian object.

At this point we can assume that everything has been allocated, although some objects may not yet be completely initialized.

Parameters
simulatorThe simulator object of the simulation.

References Opm::FvBaseAdLocalLinearizer< TypeTag >::internalElemContext_, and Opm::FvBaseAdLocalLinearizer< TypeTag >::simulatorPtr_.

◆ jacobian()

template<class TypeTag >
const ScalarMatrixBlock & Opm::FvBaseAdLocalLinearizer< TypeTag >::jacobian ( unsigned  domainScvIdx,
unsigned  rangeScvIdx 
) const
inline

Returns the local Jacobian matrix of the residual of a sub-control volume.

Parameters
domainScvIdxThe local index of the sub control volume to which the primary variables are associated with
rangeScvIdxThe local index of the sub control volume which contains the local residual

References Opm::FvBaseAdLocalLinearizer< TypeTag >::jacobian_.

◆ linearize() [1/2]

template<class TypeTag >
void Opm::FvBaseAdLocalLinearizer< TypeTag >::linearize ( const Element &  element)
inline

Compute an element's local Jacobian matrix and evaluate its residual.

The local Jacobian for a given context is defined as the derivatives of the residuals of all degrees of freedom featured by the stencil with regard to the primary variables of the stencil's "primary" degrees of freedom. Adding the local Jacobians for all elements in the grid will give the global Jacobian 'grad f(x)'.

Parameters
elementThe grid element for which the local residual and its local Jacobian should be calculated.

References Opm::FvBaseAdLocalLinearizer< TypeTag >::internalElemContext_, and Opm::FvBaseAdLocalLinearizer< TypeTag >::linearize().

Referenced by Opm::FvBaseAdLocalLinearizer< TypeTag >::linearize().

◆ linearize() [2/2]

template<class TypeTag >
void Opm::FvBaseAdLocalLinearizer< TypeTag >::linearize ( ElementContext &  elemCtx,
const Element &  elem 
)
inline

Compute an element's local Jacobian matrix and evaluate its residual.

The local Jacobian for a given context is defined as the derivatives of the residuals of all degrees of freedom featured by the stencil with regard to the primary variables of the stencil's "primary" degrees of freedom. Adding the local Jacobians for all elements in the grid will give the global Jacobian 'grad f(x)'.

After calling this method the ElementContext is in an undefined state, so do not use it anymore!

Parameters
elemCtxThe element execution context for which the local residual and its local Jacobian should be calculated.

References Opm::FvBaseAdLocalLinearizer< TypeTag >::localResidual_, Opm::FvBaseAdLocalLinearizer< TypeTag >::model_(), Opm::FvBaseAdLocalLinearizer< TypeTag >::resize_(), and Opm::FvBaseAdLocalLinearizer< TypeTag >::updateLocalLinearization_().

◆ localResidual() [1/2]

template<class TypeTag >
LocalResidual & Opm::FvBaseAdLocalLinearizer< TypeTag >::localResidual ( )
inline

Return reference to the local residual.

References Opm::FvBaseAdLocalLinearizer< TypeTag >::localResidual_.

◆ localResidual() [2/2]

template<class TypeTag >
const LocalResidual & Opm::FvBaseAdLocalLinearizer< TypeTag >::localResidual ( ) const
inline

Return reference to the local residual.

References Opm::FvBaseAdLocalLinearizer< TypeTag >::localResidual_.

◆ model_()

template<class TypeTag >
const Model & Opm::FvBaseAdLocalLinearizer< TypeTag >::model_ ( ) const
inlineprotected

◆ problem_()

template<class TypeTag >
const Problem & Opm::FvBaseAdLocalLinearizer< TypeTag >::problem_ ( ) const
inlineprotected

◆ registerParameters()

template<class TypeTag >
static void Opm::FvBaseAdLocalLinearizer< TypeTag >::registerParameters ( )
inlinestatic

Register all run-time parameters for the local jacobian.

◆ reset_()

template<class TypeTag >
void Opm::FvBaseAdLocalLinearizer< TypeTag >::reset_ ( const ElementContext &  )
inlineprotected

Reset the all relevant internal attributes to 0.

References Opm::FvBaseAdLocalLinearizer< TypeTag >::jacobian_, and Opm::FvBaseAdLocalLinearizer< TypeTag >::residual_.

◆ residual()

template<class TypeTag >
const ScalarVectorBlock & Opm::FvBaseAdLocalLinearizer< TypeTag >::residual ( unsigned  dofIdx) const
inline

Returns the local residual of a sub-control volume.

Parameters
dofIdxThe local index of the sub control volume

References Opm::FvBaseAdLocalLinearizer< TypeTag >::residual_.

◆ resize_()

template<class TypeTag >
void Opm::FvBaseAdLocalLinearizer< TypeTag >::resize_ ( const ElementContext &  elemCtx)
inlineprotected

◆ simulator_()

template<class TypeTag >
const Simulator & Opm::FvBaseAdLocalLinearizer< TypeTag >::simulator_ ( ) const
inlineprotected

◆ updateLocalLinearization_()

template<class TypeTag >
void Opm::FvBaseAdLocalLinearizer< TypeTag >::updateLocalLinearization_ ( const ElementContext &  elemCtx,
unsigned  focusDofIdx 
)
inlineprotected

Updates the current local Jacobian matrix with the partial derivatives of all equations for the degree of freedom associated with 'focusDofIdx'.

References Opm::FvBaseAdLocalLinearizer< TypeTag >::jacobian_, Opm::FvBaseAdLocalLinearizer< TypeTag >::localResidual_, and Opm::FvBaseAdLocalLinearizer< TypeTag >::residual_.

Referenced by Opm::FvBaseAdLocalLinearizer< TypeTag >::linearize().

Member Data Documentation

◆ internalElemContext_

◆ jacobian_

◆ localResidual_

◆ modelPtr_

template<class TypeTag >
Model* Opm::FvBaseAdLocalLinearizer< TypeTag >::modelPtr_
protected

◆ residual_

◆ simulatorPtr_


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