20class ConstrainedOperator;
21class RectangularConstrainedOperator;
94 {
mfem_error(
"Operator::MultTranspose() is not overridden!"); }
124 mfem_error(
"Operator::GetGradient() is not overridden!");
125 return const_cast<Operator &
>(*this);
133 MFEM_CONTRACT_VAR(diag);
134 MFEM_ABORT(
"Not relevant or not implemented for this Operator.");
198 int copy_interior = 0);
452 int jok,
int *jcur,
real_t gamma);
595 int jokB,
int *jcurB,
real_t gammaB)
597 mfem_error(
"TimeDependentAdjointOperator::SUNImplicitSetupB() is not "
615 mfem_error(
"TimeDependentAdjointOperator::SUNImplicitSolveB() is not "
692 explicit Solver(
int s = 0,
bool iter_mode =
false)
696 Solver(
int h,
int w,
bool iter_mode =
false)
739 { A_.
Mult(x, y); y *= a_; }
784 bool ownA,
bool ownB);
865 bool ownA, ownB, ownC;
871 const Operator *C,
bool ownA,
bool ownB,
bool ownC);
1044 int numSteps = 10,
real_t tolerance = 1e-8,
Square Operator for imposing essential boundary conditions using only the action, Mult(),...
MemoryClass GetMemoryClass() const override
Returns the type of memory in which the solution and temporaries are stored.
Array< int > constraint_list
List of constrained indices/dofs.
void Mult(const Vector &x, Vector &y) const override
Constrained operator action.
Operator * A
The unconstrained Operator.
void EliminateRHS(const Vector &x, Vector &b) const
Eliminate "essential boundary condition" values specified in x from the given right-hand side b.
ConstrainedOperator(Operator *A, const Array< int > &list, bool own_A=false, DiagonalPolicy diag_policy=DIAG_ONE)
Constructor from a general Operator and a list of essential indices/dofs.
void AddMult(const Vector &x, Vector &y, const real_t a=1.0) const override
Operator application: y+=A(x) (default) or y+=a*A(x).
void AssembleDiagonal(Vector &diag) const override
Diagonal of A, modified according to the used DiagonalPolicy.
DiagonalPolicy diag_policy
Diagonal policy for constrained dofs.
void ConstrainedMult(const Vector &x, Vector &y, const bool transpose) const
Implementation of Mult or MultTranspose. TODO - Generalize to allow constraining rows and columns dif...
Vector w
Auxiliary vectors.
bool own_A
Ownership flag for A.
~ConstrainedOperator() override
Destructor: destroys the unconstrained Operator, if owned.
void SetDiagonalPolicy(const DiagonalPolicy diag_policy_)
Set the diagonal policy for the constrained operator.
void MultTranspose(const Vector &x, Vector &y) const override
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Identity Operator I: x -> x.
virtual void MultTranspose(const Vector &x, Vector &y) const
Application of the transpose.
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
IdentityOperator(int n)
Create an identity operator of size n.
void FormRectangularLinearSystem(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, Vector &x, Vector &b, Operator *&A, Vector &X, Vector &B)
Form a column-constrained linear system using a matrix-free approach.
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
void FormConstrainedSystemOperator(const Array< int > &ess_tdof_list, ConstrainedOperator *&Aout)
see FormSystemOperator()
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, Operator *&A, Vector &X, Vector &B, int copy_interior=0)
Form a constrained linear system using a matrix-free approach.
int width
Dimension of the input / number of columns in the matrix.
void FormSystemOperator(const Array< int > &ess_tdof_list, Operator *&A)
Return in A a parallel (on truedofs) version of this square operator.
void FormDiscreteOperator(Operator *&A)
Return in A a parallel (on truedofs) version of this rectangular operator.
virtual void ArrayMultTranspose(const Array< const Vector * > &X, Array< Vector * > &Y) const
Action of the transpose operator on a matrix: Y=A^t(X).
Operator(int s=0)
Construct a square Operator with given size s (default 0).
virtual const Operator * GetOutputRestrictionTranspose() const
Transpose of GetOutputRestriction, directly available in this form to facilitate matrix-free RAP-type...
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int height
Dimension of the output / number of rows in the matrix.
virtual void ArrayAddMult(const Array< const Vector * > &X, Array< Vector * > &Y, const real_t a=1.0) const
Operator application on a matrix: Y+=A(X) (default) or Y+=a*A(X).
virtual const Operator * GetRestriction() const
Restriction operator from input vectors for the operator to linear algebra (linear system) vectors....
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
int NumCols() const
Get the number of columns (size of input) of the Operator. Synonym with Width().
DiagonalPolicy
Defines operator diagonal policy upon elimination of rows and/or columns.
@ DIAG_ONE
Set the diagonal value to one.
@ DIAG_KEEP
Keep the diagonal value.
@ DIAG_ZERO
Set the diagonal value to zero.
virtual const Operator * GetOutputRestriction() const
Restriction operator from output vectors for the operator to linear algebra (linear system) vectors....
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual const Operator * GetOutputProlongation() const
Prolongation operator from linear algebra (linear system) vectors, to output vectors for the operator...
virtual void ArrayAddMultTranspose(const Array< const Vector * > &X, Array< Vector * > &Y, const real_t a=1.0) const
Operator transpose application on a matrix: Y+=A^t(X) (default) or Y+=a*A^t(X).
virtual void ArrayMult(const Array< const Vector * > &X, Array< Vector * > &Y) const
Operator application on a matrix: Y=A(X).
virtual const Operator * GetProlongation() const
Prolongation operator from linear algebra (linear system) vectors, to input vectors for the operator....
virtual ~Operator()
Virtual destructor.
Type
Enumeration defining IDs for some classes derived from Operator.
@ ANY_TYPE
ID for the base class Operator, i.e. any type.
@ MFEM_SPARSEMAT
ID for class SparseMatrix.
@ PETSC_MATIS
ID for class PetscParMatrix, MATIS format.
@ MFEM_ComplexSparseMat
ID for class ComplexSparseMatrix.
@ Hypre_ParCSR
ID for class HypreParMatrix.
@ PETSC_MATHYPRE
ID for class PetscParMatrix, MATHYPRE format.
@ Complex_Operator
ID for class ComplexOperator.
@ PETSC_MATGENERIC
ID for class PetscParMatrix, unspecified format.
@ MFEM_Block_Matrix
ID for class BlockMatrix.
@ MFEM_Block_Operator
ID for the base class BlockOperator.
@ Complex_Hypre_ParCSR
ID for class ComplexHypreParMatrix.
@ PETSC_MATAIJ
ID for class PetscParMatrix, MATAIJ format.
@ PETSC_MATNEST
ID for class PetscParMatrix, MATNEST format.
@ Complex_DenseMat
ID for class ComplexDenseMatrix.
@ PETSC_MATSHELL
ID for class PetscParMatrix, MATSHELL format.
void FormRectangularSystemOperator(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, Operator *&A)
Return in A a parallel (on truedofs) version of this rectangular operator (including constraints).
Operator * SetupRAP(const Operator *Pi, const Operator *Po)
Returns RAP Operator of this, using input/output Prolongation matrices Pi corresponds to "P",...
virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x)
Reconstruct a solution vector x (e.g. a GridFunction) from the solution X of a constrained linear sys...
Type GetType() const
Return the type ID of the Operator class.
virtual void AssembleDiagonal(Vector &diag) const
Computes the diagonal entries into diag. Typically, this operation only makes sense for linear Operat...
void InitTVectors(const Operator *Po, const Operator *Ri, const Operator *Pi, Vector &x, Vector &b, Vector &X, Vector &B) const
Initializes memory for true vectors of linear system.
int NumRows() const
Get the number of rows (size of output) of the Operator. Synonym with Height().
virtual void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const
Operator transpose application: y+=A^t(x) (default) or y+=a*A^t(x).
void FormRectangularConstrainedSystemOperator(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, RectangularConstrainedOperator *&Aout)
see FormRectangularSystemOperator()
Operator(int h, int w)
Construct an Operator with the given height (output size) and width (input size).
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
virtual Operator & GetGradient(const Vector &x) const
Evaluate the gradient operator at the point x. The default behavior in class Operator is to generate ...
void PrintMatlab(std::ostream &out, int n, int m=0) const
Prints operator with input size n and output size m in Matlab format.
virtual void AddMult(const Vector &x, Vector &y, const real_t a=1.0) const
Operator application: y+=A(x) (default) or y+=a*A(x).
PowerMethod helper class to estimate the largest eigenvalue of an operator using the iterative power ...
real_t EstimateLargestEigenvalue(Operator &opr, Vector &v0, int numSteps=10, real_t tolerance=1e-8, int seed=12345)
Returns an estimate of the largest eigenvalue of the operator opr using the iterative power method.
PowerMethod(MPI_Comm comm_)
General product operator: x -> (A*B)(x) = A(B(x)).
ProductOperator(const Operator *A, const Operator *B, bool ownA, bool ownB)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
virtual ~ProductOperator()
The operator x -> R*A*P*x constructed through the actions of R^T, A and P.
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
virtual void MultTranspose(const Vector &x, Vector &y) const
Application of the transpose.
RAPOperator(const Operator &Rt_, const Operator &A_, const Operator &P_)
Construct the RAP operator given R^T, A and P.
virtual void AssembleDiagonal(Vector &diag) const
Approximate diagonal of the RAP Operator.
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
Rectangular Operator for imposing essential boundary conditions on the input space using only the act...
RectangularConstrainedOperator(Operator *A, const Array< int > &trial_list, const Array< int > &test_list, bool own_A=false)
Constructor from a general Operator and a list of essential indices/dofs.
Array< int > test_constraints
Array< int > trial_constraints
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
virtual void Mult(const Vector &x, Vector &y) const
Rectangular-constrained operator action.
virtual MemoryClass GetMemoryClass() const
Returns the type of memory in which the solution and temporaries are stored.
virtual ~RectangularConstrainedOperator()
void EliminateRHS(const Vector &x, Vector &b) const
Eliminate columns corresponding to "essential boundary condition" values specified in x from the give...
Scaled Operator B: x -> a A(x).
ScaledOperator(const Operator *A, real_t a)
Create an operator which is a scalar multiple of A.
virtual void MultTranspose(const Vector &x, Vector &y) const
Application of the transpose.
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
Base abstract class for second order time dependent operators.
virtual void Mult(const Vector &x, const Vector &dxdt, Vector &y) const
Perform the action of the operator: y = k = f(x,@ dxdt, t), where k solves the algebraic equation F(x...
virtual void ImplicitSolve(const real_t fac0, const real_t fac1, const Vector &x, const Vector &dxdt, Vector &k)
Solve the equation: k = f(x + fac0 k, dxdt + fac1 k, t), for the unknown k at the current time t.
SecondOrderTimeDependentOperator(int h, int w, real_t t_=0.0, Type type_=EXPLICIT)
Construct a SecondOrderTimeDependentOperator y = f(x,dxdt,t), where x, dxdt and y have the same dimen...
SecondOrderTimeDependentOperator(int n=0, real_t t_=0.0, Type type_=EXPLICIT)
Construct a "square" SecondOrderTimeDependentOperator y = f(x,dxdt,t), where x, dxdt and y have the s...
virtual ~SecondOrderTimeDependentOperator()
Solver(int h, int w, bool iter_mode=false)
Initialize a Solver with height h and width w.
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
virtual void SetOperator(const Operator &op)=0
Set/update the solver for the given operator.
Solver(int s=0, bool iter_mode=false)
Initialize a square Solver with size s.
General linear combination operator: x -> a A(x) + b B(x).
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
SumOperator(const Operator *A, const real_t alpha, const Operator *B, const real_t beta, bool ownA, bool ownB)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
virtual int SUNImplicitSolveB(Vector &x, const Vector &b, real_t tol)
Solve the ODE linear system as setup by the method SUNImplicitSetup().
virtual int SUNImplicitSetupB(const real_t t, const Vector &x, const Vector &xB, const Vector &fxB, int jokB, int *jcurB, real_t gammaB)
Setup the ODE linear system or , where .
virtual void AdjointRateMult(const Vector &y, Vector &yB, Vector &yBdot) const =0
Perform the action of the operator: yBdot = k = f(y,@2 yB, t), where.
virtual void QuadratureSensitivityMult(const Vector &y, const Vector &yB, Vector &qBdot) const
Provides the sensitivity of the quadrature w.r.t to primal and adjoint solutions.
virtual void QuadratureIntegration(const Vector &y, Vector &qdot) const
Provide the operator integration of a quadrature equation.
virtual ~TimeDependentAdjointOperator()
Destructor.
TimeDependentAdjointOperator(int dim, int adjdim, real_t t=0., Type type=EXPLICIT)
The TimedependentAdjointOperator extends the TimeDependentOperator class to use features in SUNDIALS ...
int GetAdjointHeight()
Returns the size of the adjoint problem state space.
Base abstract class for first order time dependent operators.
bool isHomogeneous() const
True if type is HOMOGENEOUS.
EvalMode
Evaluation mode. See SetEvalMode() for details.
bool isExplicit() const
True if type is EXPLICIT.
EvalMode eval_mode
Current evaluation mode.
virtual ~TimeDependentOperator()
TimeDependentOperator(int h, int w, real_t t_=0.0, Type type_=EXPLICIT)
Construct a TimeDependentOperator y = f(x,t), where x and y have dimensions w and h,...
virtual Operator & GetExplicitGradient(const Vector &x) const
Return an Operator representing dG/dx at the given point x and the currently set time.
virtual int SUNImplicitSolve(const Vector &b, Vector &x, real_t tol)
Solve the ODE linear system as setup by the method SUNImplicitSetup().
virtual void ImplicitMult(const Vector &x, const Vector &k, Vector &y) const
Perform the action of the implicit part of the operator, F: y = F(x, k, t) where t is the current tim...
virtual int SUNMassMult(const Vector &x, Vector &v)
Compute the mass matrix-vector product .
@ HOMOGENEOUS
This type assumes that G(x,t) = 0.
@ EXPLICIT
This type assumes F(x,k,t) = k, i.e. k = f(x,t) = G(x,t).
@ IMPLICIT
This is the most general type, no assumptions on F and G.
bool isImplicit() const
True if type is IMPLICIT or HOMOGENEOUS.
virtual int SUNMassSetup()
Setup the mass matrix in the ODE system .
TimeDependentOperator(int n=0, real_t t_=0.0, Type type_=EXPLICIT)
Construct a "square" TimeDependentOperator y = f(x,t), where x and y have the same dimension n.
virtual void Mult(const Vector &x, Vector &y) const
Perform the action of the operator: y = k = f(x, t), where k solves the algebraic equation F(x,...
virtual void ExplicitMult(const Vector &x, Vector &y) const
Perform the action of the explicit part of the operator, G: y = G(x, t) where t is the current time.
virtual int SUNMassSolve(const Vector &b, Vector &x, real_t tol)
Solve the mass matrix linear system as setup by the method SUNMassSetup().
virtual void SetEvalMode(const EvalMode new_eval_mode)
Set the evaluation mode of the time-dependent operator.
virtual void SetTime(const real_t t_)
Set the current time.
EvalMode GetEvalMode() const
Return the current evaluation mode. See SetEvalMode() for details.
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
Solve the equation: k = f(x + dt k, t), for the unknown k at the current time t.
Type type
Describes the form of the TimeDependentOperator.
virtual int SUNImplicitSetup(const Vector &x, const Vector &fx, int jok, int *jcur, real_t gamma)
Setup the ODE linear system or , where .
virtual real_t GetTime() const
Read the currently set time.
virtual Operator & GetImplicitGradient(const Vector &x, const Vector &k, real_t shift) const
Return an Operator representing (dF/dk shift + dF/dx) at the given x, k, and the currently set time.
The transpose of a given operator. Switches the roles of the methods Mult() and MultTranspose().
virtual void MultTranspose(const Vector &x, Vector &y) const
Application of the transpose. Apply the original Operator.
TransposeOperator(const Operator *a)
Construct the transpose of a given operator *a.
virtual void Mult(const Vector &x, Vector &y) const
Operator application. Apply the transpose of the original Operator.
TransposeOperator(const Operator &a)
Construct the transpose of a given operator a.
General triple product operator x -> A*B*C*x, with ownership of the factors.
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
TripleProductOperator(const Operator *A, const Operator *B, const Operator *C, bool ownA, bool ownB, bool ownC)
virtual ~TripleProductOperator()
void SetSize(int s)
Resize the vector to size s.
void mfem_error(const char *msg)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
void add(const Vector &v1, const Vector &v2, Vector &v)
MemoryClass
Memory classes identify sets of memory types.
bool IsIdentityProlongation(const Operator *P)