v0.15.0
Loading...
Searching...
No Matches
MoFEM::ConstrainMatrixCtx Struct Reference

structure for projection matrices More...

#include "src/finite_elements/ConstrainMatrixCtx.hpp"

Collaboration diagram for MoFEM::ConstrainMatrixCtx:
[legend]

Public Member Functions

 ConstrainMatrixCtx (MoFEM::Interface &m_field, string x_problem, string y_problem, bool create_ksp=true, bool own_contrain_matrix=false)
 
 ConstrainMatrixCtx (MoFEM::Interface &m_field, VecScatter scatter, bool create_ksp=true, bool own_contrain_matrix=false)
 
virtual ~ConstrainMatrixCtx ()
 
MoFEMErrorCode initializeQorP (Vec x)
 initialize vectors and matrices for Q and P shell matrices, scattering is set based on x_problem and y_problem
 
MoFEMErrorCode initializeQTKQ ()
 initialize vectors and matrices for CTC+QTKQ shell matrices, scattering is set based on x_problem and y_problem
 
MoFEMErrorCode recalculateCTandCCT ()
 re-calculate CT and CCT if C matrix has been changed since initialization
 
MoFEMErrorCode recalculateCTC ()
 re-calculate CTC matrix has been changed since initialization
 
MoFEMErrorCode destroyQorP ()
 destroy sub-matrices used for shell matrices P, Q, R, RT
 
MoFEMErrorCode destroyQTKQ ()
 destroy sub-matrices used for shell matrix QTKQ
 

Public Attributes

MoFEM::InterfacemField
 
KSP kSP
 
Mat C
 
Mat CT
 
Mat CCT
 
Mat CTC
 
Mat K
 
Vec Cx
 
Vec CCTm1_Cx
 
Vec CT_CCTm1_Cx
 
Vec CTCx
 
Vec X
 
Vec Qx
 
Vec KQx
 
bool initQorP
 
bool initQTKQ
 
bool createKSP
 
bool createScatter
 
bool cancelKSPMonitor
 
bool ownConstrainMatrix
 
VecScatter sCatter
 
string xProblem
 
string yProblem
 
PetscLogEvent MOFEM_EVENT_projInit
 
PetscLogEvent MOFEM_EVENT_projQ
 
PetscLogEvent MOFEM_EVENT_projP
 
PetscLogEvent MOFEM_EVENT_projR
 
PetscLogEvent MOFEM_EVENT_projRT
 
PetscLogEvent MOFEM_EVENT_projCTC_QTKQ
 
PetscReal rTol
 
PetscReal absTol
 
PetscReal dTol
 
PetscInt maxIts
 

Friends

MoFEMErrorCode ProjectionMatrixMultOpQ (Mat Q, Vec x, Vec f)
 Multiplication operator for Q = I-CTC(CCT)^-1C.
 
MoFEMErrorCode ConstrainMatrixMultOpP (Mat P, Vec x, Vec f)
 Multiplication operator for P = CT(CCT)^-1C.
 
MoFEMErrorCode ConstrainMatrixMultOpR (Mat R, Vec x, Vec f)
 Multiplication operator for R = CT(CCT)^-1.
 
MoFEMErrorCode ConstrainMatrixMultOpRT (Mat RT, Vec x, Vec f)
 Multiplication operator for RT = (CCT)^-TC.
 
MoFEMErrorCode ConstrainMatrixMultOpCTC_QTKQ (Mat CTC_QTKQ, Vec x, Vec f)
 Multiplication operator for RT = (CCT)^-TC.
 
MoFEMErrorCode ConstrainMatrixDestroyOpPorQ ()
 
MoFEMErrorCode ConstrainMatrixDestroyOpQTKQ ()
 

Detailed Description

structure for projection matrices

Definition at line 18 of file ConstrainMatrixCtx.hpp.

Constructor & Destructor Documentation

◆ ConstrainMatrixCtx() [1/2]

MoFEM::ConstrainMatrixCtx::ConstrainMatrixCtx ( MoFEM::Interface & m_field,
string x_problem,
string y_problem,
bool create_ksp = true,
bool own_contrain_matrix = false )

Construct data structure to build operators for projection matrices

User need to set matrix C to make it work

Parameters
x_problemproblem on which vector is projected
y_problemproblem used to construct projection matrices
create_kspcreate ksp solver otherwise user need to set it up

Definition at line 19 of file ConstrainMatrixCtx.cpp.

23 : mField(m_field), INIT_DATA_CONSTRAINMATRIXCTX, xProblem(x_problem),
24 yProblem(y_problem) {
25 PetscLogEventRegister("ProjectionInit", 0, &MOFEM_EVENT_projInit);
26 PetscLogEventRegister("ProjectionQ", 0, &MOFEM_EVENT_projQ);
27 PetscLogEventRegister("ProjectionP", 0, &MOFEM_EVENT_projP);
28 PetscLogEventRegister("ProjectionR", 0, &MOFEM_EVENT_projR);
29 PetscLogEventRegister("ProjectionRT", 0, &MOFEM_EVENT_projRT);
30 PetscLogEventRegister("ProjectionCTC_QTKQ", 0, &MOFEM_EVENT_projCTC_QTKQ);
31}
#define INIT_DATA_CONSTRAINMATRIXCTX

◆ ConstrainMatrixCtx() [2/2]

MoFEM::ConstrainMatrixCtx::ConstrainMatrixCtx ( MoFEM::Interface & m_field,
VecScatter scatter,
bool create_ksp = true,
bool own_contrain_matrix = false )

Definition at line 33 of file ConstrainMatrixCtx.cpp.

36 : mField(m_field), INIT_DATA_CONSTRAINMATRIXCTX, sCatter(scatter) {
37 PetscLogEventRegister("ProjectionInit", 0, &MOFEM_EVENT_projInit);
38 PetscLogEventRegister("ProjectionQ", 0, &MOFEM_EVENT_projQ);
39 PetscLogEventRegister("ProjectionP", 0, &MOFEM_EVENT_projP);
40 PetscLogEventRegister("ProjectionR", 0, &MOFEM_EVENT_projR);
41 PetscLogEventRegister("ProjectionRT", 0, &MOFEM_EVENT_projRT);
42 PetscLogEventRegister("ProjectionCTC_QTKQ", 0, &MOFEM_EVENT_projCTC_QTKQ);
43}

◆ ~ConstrainMatrixCtx()

virtual MoFEM::ConstrainMatrixCtx::~ConstrainMatrixCtx ( )
inlinevirtual

Definition at line 61 of file ConstrainMatrixCtx.hpp.

61 {
62 ierr = destroyQorP();
63 CHKERRABORT(mField.get_comm(), ierr);
64 ierr = destroyQTKQ();
65 CHKERRABORT(mField.get_comm(), ierr);
67 ierr = MatDestroy(&C);
68 CHKERRABORT(mField.get_comm(), ierr);
69 }
70 };
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
MoFEMErrorCode destroyQTKQ()
destroy sub-matrices used for shell matrix QTKQ
MoFEMErrorCode destroyQorP()
destroy sub-matrices used for shell matrices P, Q, R, RT
virtual MPI_Comm & get_comm() const =0

Member Function Documentation

◆ destroyQorP()

MoFEMErrorCode MoFEM::ConstrainMatrixCtx::destroyQorP ( )

destroy sub-matrices used for shell matrices P, Q, R, RT

Definition at line 94 of file ConstrainMatrixCtx.cpp.

94 {
96 if (initQorP)
98 CHKERR MatDestroy(&CT);
99 CHKERR MatDestroy(&CCT);
100 if (createKSP) {
101 CHKERR KSPDestroy(&kSP);
102 }
103 CHKERR VecDestroy(&X);
104 CHKERR VecDestroy(&Cx);
105 CHKERR VecDestroy(&CCTm1_Cx);
106 CHKERR VecDestroy(&CT_CCTm1_Cx);
107 if (createScatter) {
108 CHKERR VecScatterDestroy(&sCatter);
109 }
110 initQorP = true;
112}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.

◆ destroyQTKQ()

MoFEMErrorCode MoFEM::ConstrainMatrixCtx::destroyQTKQ ( )

destroy sub-matrices used for shell matrix QTKQ

Definition at line 151 of file ConstrainMatrixCtx.cpp.

◆ initializeQorP()

MoFEMErrorCode MoFEM::ConstrainMatrixCtx::initializeQorP ( Vec x)

initialize vectors and matrices for Q and P shell matrices, scattering is set based on x_problem and y_problem

Parameters
xis a vector from problem x

Definition at line 45 of file ConstrainMatrixCtx.cpp.

45 {
47 if (initQorP) {
48 initQorP = false;
49
50 PetscLogEventBegin(MOFEM_EVENT_projInit, 0, 0, 0, 0);
51 CHKERR MatTranspose(C, MAT_INITIAL_MATRIX, &CT);
52 // need to be calculated when C is changed
53 CHKERR MatTransposeMatMult(CT, CT, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &CCT);
54 if (createKSP) {
55 CHKERR KSPCreate(mField.get_comm(), &kSP);
56 // need to be recalculated when C is changed
57 CHKERR KSPSetOperators(kSP, CCT, CCT);
58 CHKERR KSPSetFromOptions(kSP);
59 CHKERR KSPSetInitialGuessKnoll(kSP, PETSC_TRUE);
60 CHKERR KSPGetTolerances(kSP, &rTol, &absTol, &dTol, &maxIts);
61 CHKERR KSPSetUp(kSP);
62 if (cancelKSPMonitor) {
63 CHKERR KSPMonitorCancel(kSP);
64 }
65 }
66#if PETSC_VERSION_GE(3, 5, 3)
67 CHKERR MatCreateVecs(C, &X, PETSC_NULLPTR);
68 CHKERR MatCreateVecs(C, PETSC_NULLPTR, &Cx);
69 CHKERR MatCreateVecs(CCT, PETSC_NULLPTR, &CCTm1_Cx);
70#else
71 CHKERR MatGetVecs(C, &X, PETSC_NULLPTR);
72 CHKERR MatGetVecs(C, PETSC_NULLPTR, &Cx);
73 CHKERR MatGetVecs(CCT, PETSC_NULLPTR, &CCTm1_Cx);
74#endif
75 CHKERR VecDuplicate(X, &CT_CCTm1_Cx);
76 if (createScatter) {
77 CHKERR mField.getInterface<VecManager>()->vecScatterCreate(
78 x, xProblem, ROW, X, yProblem, COL, &sCatter);
79 }
80 PetscLogEventEnd(MOFEM_EVENT_projInit, 0, 0, 0, 0);
81 }
83}
@ COL
@ ROW
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ initializeQTKQ()

MoFEMErrorCode MoFEM::ConstrainMatrixCtx::initializeQTKQ ( )

initialize vectors and matrices for CTC+QTKQ shell matrices, scattering is set based on x_problem and y_problem

Definition at line 114 of file ConstrainMatrixCtx.cpp.

114 {
116 if (initQTKQ) {
117 initQTKQ = false;
118 PetscLogEventBegin(MOFEM_EVENT_projInit, 0, 0, 0, 0);
119 // need to be recalculated when C is changed
120 CHKERR MatTransposeMatMult(C, C, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &CTC);
121 if (debug) {
122 // MatView(CCT,PETSC_VIEWER_DRAW_WORLD);
123 int m, n;
124 MatGetSize(CCT, &m, &n);
125 PetscPrintf(mField.get_comm(), "CCT size (%d,%d)\n", m, n);
126 // std::string wait;
127 // std::cin >> wait;
128 }
129#if PETSC_VERSION_GE(3, 5, 3)
130 CHKERR MatCreateVecs(K, &Qx, PETSC_NULLPTR);
131 CHKERR MatCreateVecs(K, PETSC_NULLPTR, &KQx);
132 CHKERR MatCreateVecs(CTC, PETSC_NULLPTR, &CTCx);
133#else
134 CHKERR MatGetVecs(K, &Qx, PETSC_NULLPTR);
135 CHKERR MatGetVecs(K, PETSC_NULLPTR, &KQx);
136 CHKERR MatGetVecs(CTC, PETSC_NULLPTR, &CTCx);
137#endif
138 PetscLogEventEnd(MOFEM_EVENT_projInit, 0, 0, 0, 0);
139 }
141}
const double n
refractive index of diffusive medium
static const bool debug
FTensor::Index< 'm', 3 > m

◆ recalculateCTandCCT()

MoFEMErrorCode MoFEM::ConstrainMatrixCtx::recalculateCTandCCT ( )

re-calculate CT and CCT if C matrix has been changed since initialization

Definition at line 85 of file ConstrainMatrixCtx.cpp.

85 {
87 if (initQorP)
89 CHKERR MatTranspose(C, MAT_REUSE_MATRIX, &CT);
90 CHKERR MatTransposeMatMult(CT, CT, MAT_REUSE_MATRIX, PETSC_DEFAULT, &CCT);
92}

◆ recalculateCTC()

MoFEMErrorCode MoFEM::ConstrainMatrixCtx::recalculateCTC ( )

re-calculate CTC matrix has been changed since initialization

Definition at line 143 of file ConstrainMatrixCtx.cpp.

143 {
145 if (initQTKQ)
147 CHKERR MatTransposeMatMult(C, C, MAT_REUSE_MATRIX, PETSC_DEFAULT, &CTC);
149}

Friends And Related Symbol Documentation

◆ ConstrainMatrixDestroyOpPorQ

MoFEMErrorCode ConstrainMatrixDestroyOpPorQ ( )
friend

◆ ConstrainMatrixDestroyOpQTKQ

MoFEMErrorCode ConstrainMatrixDestroyOpQTKQ ( )
friend

◆ ConstrainMatrixMultOpCTC_QTKQ

MoFEMErrorCode ConstrainMatrixMultOpCTC_QTKQ ( Mat CTC_QTKQ,
Vec x,
Vec f )
friend

Multiplication operator for RT = (CCT)^-TC.

Mat CTC_QTKQ; //for problem
projection_matrix_ctx(m_field,problem_name,contrains_problem_name);
MatCreateShell(PETSC_COMM_WORLD,m,m,M,M,&projection_matrix_ctx,&CTC_QTKQ);
MatShellSetOperation(CTC_QTKQ,MATOP_MULT,(void(*)(void))ConstrainMatrixMultOpCTC_QTKQ);
MatShellSetOperation(CTC_QTKQ,MATOP_DESTROY,(void(*)(void))ConstrainMatrixDestroyOpQTKQ);
structure for projection matrices
friend MoFEMErrorCode ConstrainMatrixDestroyOpQTKQ()
friend MoFEMErrorCode ConstrainMatrixMultOpCTC_QTKQ(Mat CTC_QTKQ, Vec x, Vec f)
Multiplication operator for RT = (CCT)^-TC.

Definition at line 261 of file ConstrainMatrixCtx.cpp.

261 {
263 void *void_ctx;
264 CHKERR MatShellGetContext(CTC_QTKQ, &void_ctx);
265 ConstrainMatrixCtx *ctx = (ConstrainMatrixCtx *)void_ctx;
266 PetscLogEventBegin(ctx->MOFEM_EVENT_projCTC_QTKQ, 0, 0, 0, 0);
267 Mat Q;
268 int M, N, m, n;
269 CHKERR MatGetSize(ctx->K, &M, &N);
270 CHKERR MatGetLocalSize(ctx->K, &m, &n);
271 CHKERR MatCreateShell(ctx->mField.get_comm(), m, n, M, N, ctx, &Q);
272 CHKERR MatShellSetOperation(Q, MATOP_MULT,
273 (void (*)(void))ProjectionMatrixMultOpQ);
274 CHKERR ctx->initializeQTKQ();
275 CHKERR MatMult(Q, x, ctx->Qx);
276 CHKERR MatMult(ctx->K, ctx->Qx, ctx->KQx);
277 CHKERR MatMult(Q, ctx->KQx, f);
278 CHKERR VecScatterBegin(ctx->sCatter, x, ctx->X, INSERT_VALUES,
279 SCATTER_FORWARD);
280 CHKERR VecScatterEnd(ctx->sCatter, x, ctx->X, INSERT_VALUES, SCATTER_FORWARD);
281 CHKERR MatMult(ctx->CTC, ctx->X, ctx->CTCx);
282 CHKERR VecScatterBegin(ctx->sCatter, ctx->CTCx, f, ADD_VALUES,
283 SCATTER_REVERSE);
284 CHKERR VecScatterEnd(ctx->sCatter, ctx->CTCx, f, ADD_VALUES, SCATTER_REVERSE);
285 CHKERR MatDestroy(&Q);
286 PetscLogEventEnd(ctx->MOFEM_EVENT_projCTC_QTKQ, 0, 0, 0, 0);
288}
FTensor::Index< 'M', 3 > M
const int N
Definition speed_test.cpp:3
ConstrainMatrixCtx(MoFEM::Interface &m_field, string x_problem, string y_problem, bool create_ksp=true, bool own_contrain_matrix=false)
friend MoFEMErrorCode ProjectionMatrixMultOpQ(Mat Q, Vec x, Vec f)
Multiplication operator for Q = I-CTC(CCT)^-1C.

◆ ConstrainMatrixMultOpP

MoFEMErrorCode ConstrainMatrixMultOpP ( Mat P,
Vec x,
Vec f )
friend

Multiplication operator for P = CT(CCT)^-1C.

Mat P; //for problem
projection_matrix_ctx(m_field,problem_name,contrains_problem_name);
CHKERR MatCreateShell(PETSC_COMM_WORLD,m,m,M,M,&projection_matrix_ctx,&P);
MatShellSetOperation(P,MATOP_MULT,(void(*)(void))ConstrainMatrixMultOpP);
friend MoFEMErrorCode ConstrainMatrixMultOpP(Mat P, Vec x, Vec f)
Multiplication operator for P = CT(CCT)^-1C.

Definition at line 197 of file ConstrainMatrixCtx.cpp.

197 {
199 void *void_ctx;
200 CHKERR MatShellGetContext(P, &void_ctx);
201 ConstrainMatrixCtx *ctx = (ConstrainMatrixCtx *)void_ctx;
202 PetscLogEventBegin(ctx->MOFEM_EVENT_projP, 0, 0, 0, 0);
203 CHKERR ctx->initializeQorP(x);
204 CHKERR VecScatterBegin(ctx->sCatter, x, ctx->X, INSERT_VALUES,
205 SCATTER_FORWARD);
206 CHKERR VecScatterEnd(ctx->sCatter, x, ctx->X, INSERT_VALUES, SCATTER_FORWARD);
207 CHKERR MatMult(ctx->C, ctx->X, ctx->Cx);
208 CHKERR KSPSolve(ctx->kSP, ctx->Cx, ctx->CCTm1_Cx);
209 CHKERR MatMult(ctx->CT, ctx->CCTm1_Cx, ctx->CT_CCTm1_Cx);
210 CHKERR VecZeroEntries(f);
211 CHKERR VecGhostUpdateBegin(f, INSERT_VALUES, SCATTER_FORWARD);
212 CHKERR VecGhostUpdateEnd(f, INSERT_VALUES, SCATTER_FORWARD);
213 CHKERR VecScatterBegin(ctx->sCatter, ctx->CT_CCTm1_Cx, f, INSERT_VALUES,
214 SCATTER_REVERSE);
215 CHKERR VecScatterEnd(ctx->sCatter, ctx->CT_CCTm1_Cx, f, INSERT_VALUES,
216 SCATTER_REVERSE);
217 PetscLogEventEnd(ctx->MOFEM_EVENT_projP, 0, 0, 0, 0);
219}

◆ ConstrainMatrixMultOpR

MoFEMErrorCode ConstrainMatrixMultOpR ( Mat R,
Vec x,
Vec f )
friend

Multiplication operator for R = CT(CCT)^-1.

Mat R; //for problem
projection_matrix_ctx(m_field,problem_name,contrains_problem_name);
CHKERR MatCreateShell(PETSC_COMM_WORLD,m,m,M,M,&projection_matrix_ctx,&R);
MatShellSetOperation(R,MATOP_MULT,(void(*)(void))ConstrainMatrixMultOpR);
@ R
friend MoFEMErrorCode ConstrainMatrixMultOpR(Mat R, Vec x, Vec f)
Multiplication operator for R = CT(CCT)^-1.

Definition at line 221 of file ConstrainMatrixCtx.cpp.

221 {
223 void *void_ctx;
224 CHKERR MatShellGetContext(R, &void_ctx);
225 ConstrainMatrixCtx *ctx = (ConstrainMatrixCtx *)void_ctx;
226 PetscLogEventBegin(ctx->MOFEM_EVENT_projR, 0, 0, 0, 0);
227 if (ctx->initQorP)
228 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE,
229 "you have to call first initQorP or use Q matrix");
230 CHKERR KSPSolve(ctx->kSP, x, ctx->CCTm1_Cx);
231 CHKERR MatMult(ctx->CT, ctx->CCTm1_Cx, ctx->CT_CCTm1_Cx);
232 CHKERR VecZeroEntries(f);
233 CHKERR VecGhostUpdateBegin(f, INSERT_VALUES, SCATTER_FORWARD);
234 CHKERR VecGhostUpdateEnd(f, INSERT_VALUES, SCATTER_FORWARD);
235 CHKERR VecScatterBegin(ctx->sCatter, ctx->CT_CCTm1_Cx, f, INSERT_VALUES,
236 SCATTER_REVERSE);
237 CHKERR VecScatterEnd(ctx->sCatter, ctx->CT_CCTm1_Cx, f, INSERT_VALUES,
238 SCATTER_REVERSE);
239 PetscLogEventEnd(ctx->MOFEM_EVENT_projR, 0, 0, 0, 0);
241}
@ MOFEM_IMPOSSIBLE_CASE
Definition definitions.h:35

◆ ConstrainMatrixMultOpRT

MoFEMErrorCode ConstrainMatrixMultOpRT ( Mat RT,
Vec x,
Vec f )
friend

Multiplication operator for RT = (CCT)^-TC.

Mat RT; //for problem
projection_matrix_ctx(m_field,problem_name,contrains_problem_name);
CHKERR MatCreateShell(PETSC_COMM_WORLD,m,m,M,M,&projection_matrix_ctx,&RT);
MatShellSetOperation(RT,MATOP_MULT,(void(*)(void))ConstrainMatrixMultOpRT);
friend MoFEMErrorCode ConstrainMatrixMultOpRT(Mat RT, Vec x, Vec f)
Multiplication operator for RT = (CCT)^-TC.

Definition at line 243 of file ConstrainMatrixCtx.cpp.

243 {
245 void *void_ctx;
246 CHKERR MatShellGetContext(RT, &void_ctx);
247 ConstrainMatrixCtx *ctx = (ConstrainMatrixCtx *)void_ctx;
248 PetscLogEventBegin(ctx->MOFEM_EVENT_projRT, 0, 0, 0, 0);
249 if (ctx->initQorP)
250 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE,
251 "you have to call first initQorP or use Q matrix");
252 CHKERR VecScatterBegin(ctx->sCatter, x, ctx->X, INSERT_VALUES,
253 SCATTER_FORWARD);
254 CHKERR VecScatterEnd(ctx->sCatter, x, ctx->X, INSERT_VALUES, SCATTER_FORWARD);
255 CHKERR MatMult(ctx->C, ctx->X, ctx->Cx);
256 CHKERR KSPSolve(ctx->kSP, ctx->Cx, f);
257 PetscLogEventEnd(ctx->MOFEM_EVENT_projRT, 0, 0, 0, 0);
259}

◆ ProjectionMatrixMultOpQ

MoFEMErrorCode ProjectionMatrixMultOpQ ( Mat Q,
Vec x,
Vec f )
friend

Multiplication operator for Q = I-CTC(CCT)^-1C.

Mat Q; //for problem
projection_matrix_ctx(m_field,problem_name,contrains_problem_name);
CHKERR MatCreateShell(PETSC_COMM_WORLD,m,m,M,M,&projection_matrix_ctx,&Q);
MatShellSetOperation(Q,MATOP_MULT,(void(*)(void))ProjectionMatrixMultOpQ);
MatShellSetOperation(Q,MATOP_DESTROY,(void(*)(void))ConstrainMatrixDestroyOpPorQ);
friend MoFEMErrorCode ConstrainMatrixDestroyOpPorQ()

Definition at line 163 of file ConstrainMatrixCtx.cpp.

163 {
165 void *void_ctx;
166 CHKERR MatShellGetContext(Q, &void_ctx);
167 ConstrainMatrixCtx *ctx = (ConstrainMatrixCtx *)void_ctx;
168 PetscLogEventBegin(ctx->MOFEM_EVENT_projQ, 0, 0, 0, 0);
169 CHKERR ctx->initializeQorP(x);
170 CHKERR VecCopy(x, f);
171 CHKERR VecScatterBegin(ctx->sCatter, x, ctx->X, INSERT_VALUES,
172 SCATTER_FORWARD);
173 CHKERR VecScatterEnd(ctx->sCatter, x, ctx->X, INSERT_VALUES, SCATTER_FORWARD);
174 if (debug) {
175 // CHKERR VecView(ctx->X,PETSC_VIEWER_STDOUT_WORLD);
176 CHKERR VecScatterBegin(ctx->sCatter, ctx->X, f, INSERT_VALUES,
177 SCATTER_REVERSE);
178 CHKERR VecScatterEnd(ctx->sCatter, ctx->X, f, INSERT_VALUES,
179 SCATTER_REVERSE);
180 PetscBool flg;
181 CHKERR VecEqual(x, f, &flg);
182 if (flg == PETSC_FALSE)
183 SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE, "scatter is not working");
184 }
185 CHKERR MatMult(ctx->C, ctx->X, ctx->Cx);
186 CHKERR KSPSolve(ctx->kSP, ctx->Cx, ctx->CCTm1_Cx);
187 CHKERR MatMult(ctx->CT, ctx->CCTm1_Cx, ctx->CT_CCTm1_Cx);
188 CHKERR VecScale(ctx->CT_CCTm1_Cx, -1);
189 CHKERR VecScatterBegin(ctx->sCatter, ctx->CT_CCTm1_Cx, f, ADD_VALUES,
190 SCATTER_REVERSE);
191 CHKERR VecScatterEnd(ctx->sCatter, ctx->CT_CCTm1_Cx, f, ADD_VALUES,
192 SCATTER_REVERSE);
193 PetscLogEventEnd(ctx->MOFEM_EVENT_projQ, 0, 0, 0, 0);
195}

Member Data Documentation

◆ absTol

PetscReal MoFEM::ConstrainMatrixCtx::absTol

Definition at line 72 of file ConstrainMatrixCtx.hpp.

◆ C

Mat MoFEM::ConstrainMatrixCtx::C

Definition at line 23 of file ConstrainMatrixCtx.hpp.

◆ cancelKSPMonitor

bool MoFEM::ConstrainMatrixCtx::cancelKSPMonitor

Definition at line 29 of file ConstrainMatrixCtx.hpp.

◆ CCT

Mat MoFEM::ConstrainMatrixCtx::CCT

Definition at line 23 of file ConstrainMatrixCtx.hpp.

◆ CCTm1_Cx

Vec MoFEM::ConstrainMatrixCtx::CCTm1_Cx

Definition at line 24 of file ConstrainMatrixCtx.hpp.

◆ createKSP

bool MoFEM::ConstrainMatrixCtx::createKSP

Definition at line 27 of file ConstrainMatrixCtx.hpp.

◆ createScatter

bool MoFEM::ConstrainMatrixCtx::createScatter

Definition at line 28 of file ConstrainMatrixCtx.hpp.

◆ CT

Mat MoFEM::ConstrainMatrixCtx::CT

Definition at line 23 of file ConstrainMatrixCtx.hpp.

◆ CT_CCTm1_Cx

Vec MoFEM::ConstrainMatrixCtx::CT_CCTm1_Cx

Definition at line 24 of file ConstrainMatrixCtx.hpp.

◆ CTC

Mat MoFEM::ConstrainMatrixCtx::CTC

Definition at line 23 of file ConstrainMatrixCtx.hpp.

◆ CTCx

Vec MoFEM::ConstrainMatrixCtx::CTCx

Definition at line 24 of file ConstrainMatrixCtx.hpp.

◆ Cx

Vec MoFEM::ConstrainMatrixCtx::Cx

Definition at line 24 of file ConstrainMatrixCtx.hpp.

◆ dTol

PetscReal MoFEM::ConstrainMatrixCtx::dTol

Definition at line 72 of file ConstrainMatrixCtx.hpp.

◆ initQorP

bool MoFEM::ConstrainMatrixCtx::initQorP

Definition at line 26 of file ConstrainMatrixCtx.hpp.

◆ initQTKQ

bool MoFEM::ConstrainMatrixCtx::initQTKQ

Definition at line 26 of file ConstrainMatrixCtx.hpp.

◆ K

Mat MoFEM::ConstrainMatrixCtx::K

Definition at line 23 of file ConstrainMatrixCtx.hpp.

◆ KQx

Vec MoFEM::ConstrainMatrixCtx::KQx

Definition at line 25 of file ConstrainMatrixCtx.hpp.

◆ kSP

KSP MoFEM::ConstrainMatrixCtx::kSP

Definition at line 22 of file ConstrainMatrixCtx.hpp.

◆ maxIts

PetscInt MoFEM::ConstrainMatrixCtx::maxIts

Definition at line 73 of file ConstrainMatrixCtx.hpp.

◆ mField

MoFEM::Interface& MoFEM::ConstrainMatrixCtx::mField

Definition at line 20 of file ConstrainMatrixCtx.hpp.

◆ MOFEM_EVENT_projCTC_QTKQ

PetscLogEvent MoFEM::ConstrainMatrixCtx::MOFEM_EVENT_projCTC_QTKQ

Definition at line 43 of file ConstrainMatrixCtx.hpp.

◆ MOFEM_EVENT_projInit

PetscLogEvent MoFEM::ConstrainMatrixCtx::MOFEM_EVENT_projInit

Definition at line 38 of file ConstrainMatrixCtx.hpp.

◆ MOFEM_EVENT_projP

PetscLogEvent MoFEM::ConstrainMatrixCtx::MOFEM_EVENT_projP

Definition at line 40 of file ConstrainMatrixCtx.hpp.

◆ MOFEM_EVENT_projQ

PetscLogEvent MoFEM::ConstrainMatrixCtx::MOFEM_EVENT_projQ

Definition at line 39 of file ConstrainMatrixCtx.hpp.

◆ MOFEM_EVENT_projR

PetscLogEvent MoFEM::ConstrainMatrixCtx::MOFEM_EVENT_projR

Definition at line 41 of file ConstrainMatrixCtx.hpp.

◆ MOFEM_EVENT_projRT

PetscLogEvent MoFEM::ConstrainMatrixCtx::MOFEM_EVENT_projRT

Definition at line 42 of file ConstrainMatrixCtx.hpp.

◆ ownConstrainMatrix

bool MoFEM::ConstrainMatrixCtx::ownConstrainMatrix

Definition at line 30 of file ConstrainMatrixCtx.hpp.

◆ Qx

Vec MoFEM::ConstrainMatrixCtx::Qx

Definition at line 25 of file ConstrainMatrixCtx.hpp.

◆ rTol

PetscReal MoFEM::ConstrainMatrixCtx::rTol

Definition at line 72 of file ConstrainMatrixCtx.hpp.

◆ sCatter

VecScatter MoFEM::ConstrainMatrixCtx::sCatter

Definition at line 35 of file ConstrainMatrixCtx.hpp.

◆ X

Vec MoFEM::ConstrainMatrixCtx::X

Definition at line 25 of file ConstrainMatrixCtx.hpp.

◆ xProblem

string MoFEM::ConstrainMatrixCtx::xProblem

Definition at line 36 of file ConstrainMatrixCtx.hpp.

◆ yProblem

string MoFEM::ConstrainMatrixCtx::yProblem

Definition at line 36 of file ConstrainMatrixCtx.hpp.


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