14 #include "../general/forall.hpp"
159 trial_tdof_list, test_tdof_list,
191 if (n == 0) { n =
width; }
192 if (m == 0) { m =
height; }
197 out << setiosflags(ios::scientific | ios::showpos);
198 for (
int i = 0; i < n; i++)
202 for (
int j = 0; j < m; j++)
206 out << j+1 <<
" " << i+1 <<
" " << y(j) <<
'\n';
216 mfem_error(
"TimeDependentOperator::ExplicitMult() is not overridden!");
222 mfem_error(
"TimeDependentOperator::ImplicitMult() is not overridden!");
227 mfem_error(
"TimeDependentOperator::Mult() is not overridden!");
233 mfem_error(
"TimeDependentOperator::ImplicitSolve() is not overridden!");
239 mfem_error(
"TimeDependentOperator::GetImplicitGradient() is "
246 mfem_error(
"TimeDependentOperator::GetExplicitGradient() is "
255 mfem_error(
"TimeDependentOperator::SUNImplicitSetup() is not overridden!");
261 mfem_error(
"TimeDependentOperator::SUNImplicitSolve() is not overridden!");
267 mfem_error(
"TimeDependentOperator::SUNMassSetup() is not overridden!");
273 mfem_error(
"TimeDependentOperator::SUNMassSolve() is not overridden!");
279 mfem_error(
"TimeDependentOperator::SUNMassMult() is not overridden!");
288 mfem_error(
"SecondOrderTimeDependentOperator::Mult() is not overridden!");
297 mfem_error(
"SecondOrderTimeDependentOperator::ImplicitSolve() is not overridden!");
302 bool ownA,
bool ownB)
304 A(A), B(B), ownA(ownA), ownB(ownB), z(A->
Width())
307 "incompatible Operators: A->Width() = " << A->
Width()
308 <<
", B->Height() = " << B->
Height());
315 "Operator B of a ProductOperator should not be in iterative mode");
322 if (ownA) {
delete A; }
323 if (ownB) {
delete B; }
329 :
Operator(Rt_.Width(), P_.Width()), Rt(Rt_), A(A_), P(P_)
332 "incompatible Operators: Rt.Height() = " << Rt.
Height()
333 <<
", A.Height() = " << A.
Height());
335 "incompatible Operators: A.Width() = " << A.
Width()
336 <<
", P.Height() = " << P.
Height());
339 const Solver* SolverA =
dynamic_cast<const Solver*
>(&A);
343 "Operator A of an RAPOperator should not be in iterative mode");
346 const Solver* SolverP =
dynamic_cast<const Solver*
>(&P);
350 "Operator P of an RAPOperator should not be in iterative mode");
363 bool ownA,
bool ownB,
bool ownC)
366 , ownA(ownA), ownB(ownB), ownC(ownC)
369 "incompatible Operators: A->Width() = " << A->
Width()
370 <<
", B->Height() = " << B->
Height());
372 "incompatible Operators: B->Width() = " << B->
Width()
373 <<
", C->Height() = " << C->
Height());
380 "Operator B of a TripleProductOperator should not be in iterative mode");
387 "Operator C of a TripleProductOperator should not be in iterative mode");
399 if (ownA) {
delete A; }
400 if (ownB) {
delete B; }
401 if (ownC) {
delete C; }
408 :
Operator(A->Height(), A->Width()), A(A), own_A(own_A_),
409 diag_policy(diag_policy_)
435 const int id = idx[i];
442 const int id = idx[i];
447 MFEM_ABORT(
"unknown diagonal policy");
462 const int id = idx[i];
474 const int id = idx[i];
493 MFEM_FORALL(i, csz, d_z[idx[i]] = 0.0;);
505 const int id = idx[i];
512 const int id = idx[i];
531 :
Operator(A->Height(), A->Width()), A(A), own_A(own_A_)
554 MFEM_FORALL(i, trial_csz,
556 const int id = trial_idx[i];
567 MFEM_FORALL(i, test_csz, d_b[test_idx[i]] = 0.0;);
585 MFEM_FORALL(i, trial_csz, d_w[idx[i]] = 0.0;);
594 MFEM_FORALL(i, test_csz, d_y[idx[i]] = 0.0;);
614 MFEM_FORALL(i, test_csz, d_z[idx[i]] = 0.0;);
623 MFEM_FORALL(i, trial_csz, d_y[idx[i]] = 0.0;);
628 int numSteps,
double tolerance,
int seed)
636 double eigenvalue = 1.0;
638 for (
int iter = 0; iter < numSteps; ++iter)
643 if (comm != MPI_COMM_NULL)
658 double eigenvalueNew;
660 if (comm != MPI_COMM_NULL)
671 double diff = std::abs((eigenvalueNew - eigenvalue) / eigenvalue);
673 eigenvalue = eigenvalueNew;
676 if (diff < tolerance)
static MemoryClass GetMemoryClass()
(DEPRECATED) Equivalent to GetDeviceMemoryClass().
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...
int Size() const
Return the logical size of the array.
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)...
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.
virtual ~ProductOperator()
virtual void AssembleDiagonal(Vector &diag) const
Diagonal of A, modified according to the used DiagonalPolicy.
Array< int > constraint_list
List of constrained indices/dofs.
virtual void ImplicitSolve(const double fac0, const double 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...
void SetSize(int s)
Resize the vector to size s.
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k)
Solve the equation: k = f(x + dt k, t), for the unknown k at the current time t.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual void Mult(const Vector &x, Vector &y) const
Constrained operator action.
virtual Operator & GetExplicitGradient(const Vector &x) const
Return an Operator representing dG/dx at the given point x and the currently set time.
int Size() const
Returns the size of the vector.
virtual const Operator * GetOutputProlongation() const
Prolongation operator from linear algebra (linear system) vectors, to output vectors for the operator...
void EliminateRHS(const Vector &x, Vector &b) const
Eliminate columns corresponding to "essential boundary condition" values specified in x from the give...
void FormDiscreteOperator(Operator *&A)
Return in A a parallel (on truedofs) version of this rectangular operator.
ProductOperator(const Operator *A, const Operator *B, bool ownA, bool ownB)
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
void Randomize(int seed=0)
Set random values in the vector.
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
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 ...
void FormRectangularConstrainedSystemOperator(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, RectangularConstrainedOperator *&Aout)
see FormRectangularSystemOperator()
Array< int > test_constraints
virtual int SUNImplicitSolve(const Vector &b, Vector &x, double tol)
Solve the ODE linear system as setup by the method SUNImplicitSetup().
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...
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 const Operator * GetProlongation() const
Prolongation operator from linear algebra (linear system) vectors, to input vectors for the operator...
General product operator: x -> (A*B)(x) = A(B(x)).
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
static MemoryClass GetDeviceMemoryClass()
Get the current Device MemoryClass. This is the MemoryClass used by most MFEM device kernels to acces...
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
void FormConstrainedSystemOperator(const Array< int > &ess_tdof_list, ConstrainedOperator *&Aout)
see FormSystemOperator()
virtual int SUNMassSetup()
Setup the mass matrix in the ODE system .
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
The operator x -> R*A*P*x constructed through the actions of R^T, A and P.
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.
Set the diagonal value to one.
RAPOperator(const Operator &Rt_, const Operator &A_, const Operator &P_)
Construct the RAP operator given R^T, A and P.
virtual const Operator * GetRestriction() const
Restriction operator from input vectors for the operator to linear algebra (linear system) vectors...
void SyncMemory(const Vector &v) const
Update the memory location of the vector to match v.
void SetSubVectorComplement(const Array< int > &dofs, const double val)
Set all vector entries NOT in the dofs Array to the given val.
bool IsIdentityProlongation(const Operator *P)
Array< int > trial_constraints
virtual int SUNMassSolve(const Vector &b, Vector &x, double tol)
Solve the mass matrix linear system as setup by the method SUNMassSetup().
Vector w
Auxiliary vectors.
MemoryType
Memory types supported by MFEM.
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.
virtual Operator & GetImplicitGradient(const Vector &x, const Vector &k, double shift) const
Return an Operator representing (dF/dk shift + dF/dx) at the given x, k, and the currently set time...
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.
The transpose of a given operator. Switches the roles of the methods Mult() and MultTranspose().
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...
int height
Dimension of the output / number of rows in the matrix.
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...
double InnerProduct(HypreParVector *x, HypreParVector *y)
virtual double * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
Rectangular Operator for imposing essential boundary conditions on the input space using only the act...
virtual void AssembleDiagonal(Vector &diag) const
Computes the diagonal entries into diag. Typically, this operation only makes sense for linear Operat...
virtual ~TripleProductOperator()
void EliminateRHS(const Vector &x, Vector &b) const
Eliminate "essential boundary condition" values specified in x from the given right-hand side b...
void PrintMatlab(std::ostream &out, int n=0, int m=0) const
Prints operator with input size n and output size m in Matlab format.
void FormSystemOperator(const Array< int > &ess_tdof_list, Operator *&A)
Return in A a parallel (on truedofs) version of this square operator.
DiagonalPolicy
Defines operator diagonal policy upon elimination of rows and/or columns.
General triple product operator x -> A*B*C*x, with ownership of the factors.
MemoryType GetMemoryType(MemoryClass mc)
Return a suitable MemoryType for a given MemoryClass.
virtual int SUNImplicitSetup(const Vector &x, const Vector &fx, int jok, int *jcur, double gamma)
Setup the ODE linear system or , where .
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...
TripleProductOperator(const Operator *A, const Operator *B, const Operator *C, bool ownA, bool ownB, bool ownC)
virtual int SUNMassMult(const Vector &x, Vector &v)
Compute the mass matrix-vector product .
Operator * SetupRAP(const Operator *Pi, const Operator *Po)
Returns RAP Operator of this, using input/output Prolongation matrices Pi corresponds to "P"...
void MakeRef(T *, int)
Make this Array a reference to a pointer.
void MakeRef(Vector &base, int offset, int size)
Reset the Vector to be a reference to a sub-vector of base.
DiagonalPolicy diag_policy
Diagonal policy for constrained dofs.
Operator * A
The unconstrained Operator.
Square Operator for imposing essential boundary conditions using only the action, Mult()...
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
double EstimateLargestEigenvalue(Operator &opr, Vector &v0, int numSteps=10, double tolerance=1e-8, int seed=12345)
Returns an estimate of the largest eigenvalue of the operator opr using the iterative power method...
virtual const double * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
Set the diagonal value to zero.
int width
Dimension of the input / number of columns in the matrix.
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.
virtual const Operator * GetOutputRestriction() const
Restriction operator from output vectors for the operator to linear algebra (linear system) vectors...