|
| v0.14.0
|
Go to the documentation of this file.
10 using namespace MoFEM;
13 const static bool debug =
false;
15 #define INIT_DATA_CONSTRAINMATRIXCTX \
16 C(PETSC_NULL), CT(PETSC_NULL), CCT(PETSC_NULL), CTC(PETSC_NULL), \
17 K(PETSC_NULL), Cx(PETSC_NULL), CCTm1_Cx(PETSC_NULL), \
18 CT_CCTm1_Cx(PETSC_NULL), CTCx(PETSC_NULL), Qx(PETSC_NULL), \
19 KQx(PETSC_NULL), initQorP(true), initQTKQ(true), createKSP(create_ksp), \
20 createScatter(true), cancelKSPMonitor(true), \
21 ownConstrainMatrix(own_contrain_matrix)
24 string x_problem,
string y_problem,
26 bool own_contrain_matrix)
38 VecScatter scatter,
bool create_ksp,
39 bool own_contrain_matrix)
55 CHKERR MatTranspose(
C, MAT_INITIAL_MATRIX, &
CT);
57 CHKERR MatTransposeMatMult(
CT,
CT, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &
CCT);
63 CHKERR KSPSetInitialGuessKnoll(
kSP, PETSC_TRUE);
70 #if PETSC_VERSION_GE(3, 5, 3)
71 CHKERR MatCreateVecs(
C, &
X, PETSC_NULL);
75 CHKERR MatGetVecs(
C, &
X, PETSC_NULL);
93 CHKERR MatTranspose(
C, MAT_REUSE_MATRIX, &
CT);
94 CHKERR MatTransposeMatMult(
CT,
CT, MAT_REUSE_MATRIX, PETSC_DEFAULT, &
CCT);
124 CHKERR MatTransposeMatMult(
C,
C, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &
CTC);
128 MatGetSize(
CCT, &
m, &
n);
133 #if PETSC_VERSION_GE(3, 5, 3)
134 CHKERR MatCreateVecs(
K, &
Qx, PETSC_NULL);
151 CHKERR MatTransposeMatMult(
C,
C, MAT_REUSE_MATRIX, PETSC_DEFAULT, &
CTC);
170 CHKERR MatShellGetContext(Q, &void_ctx);
177 CHKERR VecScatterEnd(ctx->
sCatter, x, ctx->
X, INSERT_VALUES, SCATTER_FORWARD);
186 if (flg == PETSC_FALSE)
204 CHKERR MatShellGetContext(
P, &void_ctx);
210 CHKERR VecScatterEnd(ctx->
sCatter, x, ctx->
X, INSERT_VALUES, SCATTER_FORWARD);
215 CHKERR VecGhostUpdateBegin(
f, INSERT_VALUES, SCATTER_FORWARD);
216 CHKERR VecGhostUpdateEnd(
f, INSERT_VALUES, SCATTER_FORWARD);
228 CHKERR MatShellGetContext(
R, &void_ctx);
233 "you have to call first initQorP or use Q matrix");
237 CHKERR VecGhostUpdateBegin(
f, INSERT_VALUES, SCATTER_FORWARD);
238 CHKERR VecGhostUpdateEnd(
f, INSERT_VALUES, SCATTER_FORWARD);
250 CHKERR MatShellGetContext(RT, &void_ctx);
255 "you have to call first initQorP or use Q matrix");
258 CHKERR VecScatterEnd(ctx->
sCatter, x, ctx->
X, INSERT_VALUES, SCATTER_FORWARD);
268 CHKERR MatShellGetContext(CTC_QTKQ, &void_ctx);
276 CHKERR MatShellSetOperation(Q, MATOP_MULT,
284 CHKERR VecScatterEnd(ctx->
sCatter, x, ctx->
X, INSERT_VALUES, SCATTER_FORWARD);
297 CHKERR MatShellGetContext(Q, &void_ctx);
305 CHKERR MatShellGetContext(QTKQ, &void_ctx);
MoFEMErrorCode ConstrainMatrixMultOpCTC_QTKQ(Mat CTC_QTKQ, Vec x, Vec f)
Multiplication operator for RT = (CCT)^-TC.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
MoFEMErrorCode initializeQorP(Vec x)
initialize vectors and matrices for Q and P shell matrices, scattering is set based on x_problem and ...
#define INIT_DATA_CONSTRAINMATRIXCTX
MoFEMErrorCode destroyQorP()
destroy sub-matrices used for shell matrices P, Q, R, RT
virtual MPI_Comm & get_comm() const =0
PetscLogEvent MOFEM_EVENT_projCTC_QTKQ
MoFEMErrorCode recalculateCTandCCT()
re-calculate CT and CCT if C matrix has been changed since initialization
MoFEMErrorCode ConstrainMatrixDestroyOpPorQ(Mat Q)
Destroy shell matrix Q.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Deprecated interface functions.
ConstrainMatrixCtx(MoFEM::Interface &m_field, string x_problem, string y_problem, bool create_ksp=true, bool own_contrain_matrix=false)
MoFEMErrorCode destroyQTKQ()
destroy sub-matrices used for shell matrix QTKQ
MoFEMErrorCode ConstrainMatrixMultOpRT(Mat RT, Vec x, Vec f)
Multiplication operator for RT = (CCT)^-TC.
FTensor::Index< 'M', 3 > M
#define CHKERR
Inline error check.
PetscLogEvent MOFEM_EVENT_projR
implementation of Data Operators for Forces and Sources
PetscLogEvent MOFEM_EVENT_projInit
PetscLogEvent MOFEM_EVENT_projRT
Vector manager is used to create vectors \mofem_vectors.
PetscLogEvent MOFEM_EVENT_projP
MoFEMErrorCode recalculateCTC()
re-calculate CTC matrix has been changed since initialization
MoFEMErrorCode ProjectionMatrixMultOpQ(Mat Q, Vec x, Vec f)
Multiplication operator for Q = I-CTC(CCT)^-1C.
MoFEM::Interface & mField
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscLogEvent MOFEM_EVENT_projQ
FTensor::Index< 'm', 3 > m
structure for projection matrices
MoFEMErrorCode initializeQTKQ()
initialize vectors and matrices for CTC+QTKQ shell matrices, scattering is set based on x_problem and...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MoFEMErrorCode ConstrainMatrixDestroyOpQTKQ(Mat QTKQ)
Destroy shell matrix.
MoFEMErrorCode ConstrainMatrixMultOpR(Mat R, Vec x, Vec f)
Multiplication operator for R = CT(CCT)^-1.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
MoFEMErrorCode ConstrainMatrixMultOpP(Mat P, Vec x, Vec f)
Multiplication operator for P = CT(CCT)^-1C.