IBAMR
An adaptive and distributed-memory parallel implementation of the immersed boundary (IB) method
Public Member Functions | List of all members
IBTK::PETScSNESJacobianJOWrapper Class Reference

Class PETScSNESJacobianJOWrapper provides a JacobianOperator interface for a PETSc SNES Jacobian. More...

#include </home/runner/work/IBAMR/IBAMR/ibtk/include/ibtk/PETScSNESJacobianJOWrapper.h>

Inheritance diagram for IBTK::PETScSNESJacobianJOWrapper:
Inheritance graph
[legend]

Public Member Functions

 PETScSNESJacobianJOWrapper (std::string object_name, SNES petsc_snes, PetscErrorCode(*petsc_snes_form_jac)(SNES, Vec, Mat, Mat, void *), void *petsc_snes_jac_ctx)
 Constructor. More...
 
 ~PETScSNESJacobianJOWrapper ()
 Destructor.
 
General Jacobian functionality.
void formJacobian (SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &x) override
 Compute hierarchy dependent data required for evaluating F'[x]. More...
 
SAMRAI::tbox::Pointer< SAMRAI::solv::SAMRAIVectorReal< NDIM, double > > getBaseVector () const override
 Return the vector where the Jacobian is evaluated.
 
- Public Member Functions inherited from IBTK::JacobianOperator
 JacobianOperator (std::string object_name)
 Constructor.
 
 ~JacobianOperator ()=default
 Empty destructor.
 
- Public Member Functions inherited from IBTK::LinearOperator
 LinearOperator (std::string object_name, bool homogeneous_bc=false)
 Constructor.
 
 ~LinearOperator ()
 Empty destructor.
 
void modifyRhsForBcs (SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &y) override
 Modify y to account for boundary conditions. More...
 
- Public Member Functions inherited from IBTK::GeneralOperator
 GeneralOperator (std::string object_name, bool homogeneous_bc=false)
 Constructor.
 
virtual ~GeneralOperator ()
 Empty virtual destructor.
 
const std::stringgetName () const
 Return the object name.
 
virtual bool getIsInitialized () const
 Return whether the operator is initialized.
 
virtual void setHomogeneousBc (bool homogeneous_bc)
 Set whether the operator should use homogeneous boundary conditions.
 
virtual bool getHomogeneousBc () const
 Return whether the operator is using homogeneous boundary conditions.
 
virtual void setSolutionTime (double solution_time)
 Set the time at which the solution is to be evaluated.
 
virtual double getSolutionTime () const
 Get the time at which the solution is being evaluated.
 
virtual void setTimeInterval (double current_time, double new_time)
 Set the current time interval.
 
virtual std::pair< double, double > getTimeInterval () const
 Get the current time interval.
 
virtual double getDt () const
 Get the current time step size.
 
virtual void setHierarchyMathOps (SAMRAI::tbox::Pointer< HierarchyMathOps > hier_math_ops)
 Set the HierarchyMathOps object used by the operator.
 
virtual SAMRAI::tbox::Pointer< HierarchyMathOpsgetHierarchyMathOps () const
 Get the HierarchyMathOps object used by the operator.
 
virtual void imposeSolBcs (SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &u)
 Impose boudary conditions in the solution vector. More...
 
virtual void setLoggingEnabled (bool enable_logging=true)
 Enable or disable logging.
 
virtual bool getLoggingEnabled () const
 Determine whether logging is enabled or disabled.
 
virtual void printClassData (std::ostream &stream)
 Print class data to stream.
 

Functions to access the underlying PETSc function.

PetscErrorCode(*)(SNES, Vec, Mat, Mat, void *) getPETScSNESFormJacobian ()
 Get the function pointer to the PETSc SNES Jacobian "wrapped" by this object.
 
const SNES & getPETScSNES () const
 Get the PETSc SNES object "wrapped" by this object.
 
void * getPETScSNESJacobianContext () const
 Get the PETSc SNES Jacobian context object "wrapped" by this object.
 

Linear operator functionality.

void apply (SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &x, SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &y) override
 Compute y=Ax. More...
 
void applyAdd (SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &x, SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &y, SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &z) override
 Compute z=Ax+y. More...
 
void initializeOperatorState (const SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &in, const SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &out) override
 Compute hierarchy dependent data required for computing y=Ax and z=Ax+y. More...
 
void deallocateOperatorState () override
 Remove all hierarchy dependent data allocated by initializeOperatorState(). More...
 

Additional Inherited Members

- Protected Attributes inherited from IBTK::GeneralOperator
const std::string d_object_name
 
bool d_is_initialized = false
 
bool d_homogeneous_bc
 
double d_solution_time = std::numeric_limits<double>::quiet_NaN()
 
double d_current_time = std::numeric_limits<double>::quiet_NaN()
 
double d_new_time = std::numeric_limits<double>::quiet_NaN()
 
SAMRAI::tbox::Pointer< HierarchyMathOpsd_hier_math_ops
 
bool d_hier_math_ops_external = false
 
bool d_enable_logging = false
 

Detailed Description

Class PETScSNESJacobianJOWrapper provides a JacobianOperator interface for a PETSc SNES Jacobian.

Constructor & Destructor Documentation

◆ PETScSNESJacobianJOWrapper()

IBTK::PETScSNESJacobianJOWrapper::PETScSNESJacobianJOWrapper ( std::string  object_name,
SNES  petsc_snes,
PetscErrorCode(*)(SNES, Vec, Mat, Mat, void *)  petsc_snes_form_jac,
void *  petsc_snes_jac_ctx 
)

Constructor.

Construct a Jacobian operator wrapper corresponding to the provided PETSc SNES Jacobian object.

Member Function Documentation

◆ apply()

void IBTK::PETScSNESJacobianJOWrapper::apply ( SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  x,
SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  y 
)
overridevirtual

Compute y=Ax.

Before calling this function, the form of the vectors x and y should be set properly by the user on all patch interiors on the range of levels covered by the operator. All data in these vectors should be allocated. The user is responsible for managing the storage for the vectors.

Conditions on arguments:

  • vectors must have same hierarchy
  • vectors must have same variables (except that x must have enough ghost cells for computation of Ax).

In general, the vectors x and y cannot be the same.

Note
The operator NEED NOT be initialized prior to calling apply.
See also
initializeOperatorState
Parameters
xinput
youtput: y=Ax

Implements IBTK::GeneralOperator.

◆ applyAdd()

void IBTK::PETScSNESJacobianJOWrapper::applyAdd ( SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  x,
SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  y,
SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  z 
)
overridevirtual

Compute z=Ax+y.

Before calling this function, the form of the vectors x, y, and z should be set properly by the user on all patch interiors on the range of levels covered by the operator. All data in these vectors should be allocated. The user is responsible for managing the storage for the vectors.

Conditions on arguments:

  • vectors must have same hierarchy
  • vectors must have same variables (except that x must have enough ghost cells for computation of Ax).

In general, the vectors x and z cannot be the same.

Note
The operator NEED NOT be initialized prior to calling apply.
See also
initializeOperatorState
Parameters
xinput
yinput
zoutput: z=Ax+y

Reimplemented from IBTK::GeneralOperator.

◆ deallocateOperatorState()

void IBTK::PETScSNESJacobianJOWrapper::deallocateOperatorState ( )
overridevirtual

Remove all hierarchy dependent data allocated by initializeOperatorState().

Remove all hierarchy dependent data set by initializeOperatorState(). It is safe to call deallocateOperatorState() when the operator state is already deallocated.

See also
initializeOperatorState

Reimplemented from IBTK::GeneralOperator.

◆ formJacobian()

void IBTK::PETScSNESJacobianJOWrapper::formJacobian ( SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  x)
overridevirtual

Compute hierarchy dependent data required for evaluating F'[x].

Parameters
xvalue where the Jacobian is to be evaluated

Implements IBTK::JacobianOperator.

◆ initializeOperatorState()

void IBTK::PETScSNESJacobianJOWrapper::initializeOperatorState ( const SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  in,
const SAMRAI::solv::SAMRAIVectorReal< NDIM, double > &  out 
)
overridevirtual

Compute hierarchy dependent data required for computing y=Ax and z=Ax+y.

The vector arguments for apply(), applyAdd(), etc, need not match those for initializeOperatorState(). However, there must be a certain degree of similarity, including

  • hierarchy configuration (hierarchy pointer and level range)
  • number, type and alignment of vector component data
  • ghost cell widths of data in the input and output vectors
Note
It is generally necessary to reinitialize the operator state when the hierarchy configuration changes.

It is safe to call initializeOperatorState() when the state is already initialized. In this case, the operator state is first deallocated and then reinitialized.

Conditions on arguments:

  • input and output vectors must have same hierarchy
  • input and output vectors must have same structure, depth, etc.

Call deallocateOperatorState() to remove any data allocated by this method.

See also
deallocateOperatorState
Parameters
ininput vector
outoutput vector

Reimplemented from IBTK::GeneralOperator.


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