93 pIntDofs(pInterfDofs),
124 DEBUGCOUT(
"Entering SchurSolutionManager::SchurSolutionManager()"
131 SolvComm = MBDynComm.Dup();
132 SolvCommSize = SolvComm.Get_size();
133 MyRank = SolvComm.Get_rank();
135 if (SolvCommSize <= 1) {
136 silent_cerr(
"SchurSolutionManager: "
137 "invalid communicator size " << SolvCommSize
146 DEBUGCOUT(
"Solution Communicator Size: " << SolvCommSize << std::endl);
162 integer iIntWorkSpaceSize = iWorkSpaceSize*(iSchurIntDim*iSchurIntDim)/(iPrbmSize*iPrbmSize);
172 prVH = pLocalSM->pResHdl();
173 pSolrVH = pLocalSM->pSolHdl();
176 pSchMH = pInterSM->pMatHdl();
177 pSchVH = pInterSM->pResHdl();
178 pSolSchVH = pInterSM->pSolHdl();
182 if (prVH->pdGetVec() == pSolrVH->pdGetVec()) {
185 iIntVecDim, pBMH, pGlbToLoc));
190 iIntVecDim, pBMH, pGlbToLoc));
195 iIntVecDim, prVH, pGlbToLoc));
197 pdCM = pMH->GetCMat();
205 pgVH = pRVH->GetIVec();
209 iIntVecDim, pSolrVH, pgVH, pGlbToLoc));
214 SAFENEWARR(pBlockLenght,
int, pDispl[SolvCommSize]);
216 SAFENEWARR(pTypeDsp, MPI::Aint, pDispl[SolvCommSize]);
219 MPI::Aint DispTmp = MPI::Get_address(pdm1 + 1);
220 for (
int i = 0; i < pDispl[SolvCommSize]; i++) {
222 int blk = i/iBlkSize;
223 pTypeDsp[i] = MPI::Get_address(&pdm1[pSchGlbToLoc[pDofsRecvdList[j] + blk*iBlkSize]]) - DispTmp;
226 SAFENEWARR(ppNewTypes, MPI::Datatype*, SolvCommSize);
227 MPI::Aint* pCurrDispl = pTypeDsp;
229 for (
int i = 0; i < SolvCommSize; i++) {
230 ppNewTypes[i] = NULL;
232 MPI::Datatype(MPI::DOUBLE.Create_hindexed(pRecvDim[i],
233 pBlockLenght, pCurrDispl)));
234 ppNewTypes[i]->Commit();
235 pCurrDispl += pRecvDim[i];
239 silent_cout(
"Local dimension on process " << MyRank
240 <<
": " << iLocVecDim << std::endl);
243 silent_cout(
"Interface dimension: " << iSchurIntDim
249 silent_cout(
"Interface Dofs " << std::endl);
250 for (
int i = 0; i < iSchurIntDim; i++) {
251 silent_cout(pSchurDofs[i] <<
" ");
253 silent_cout(std::endl);
262 DEBUGCOUT(
"Entering SchurSolutionManager::~SchurSolutionManager()"
273 if (pDispl != NULL) {
297 if (pTypeDsp != NULL) {
305 if (ppNewTypes != NULL) {
307 ppNewTypes[i]->Free();
330 if (pGSReq != NULL) {
334 if (pGRReq != NULL) {
341 SchurSolutionManager::IsValid(
void)
const
381 DEBUGCOUT(
"Entering SchurSolutionManager::Solve()" << endl);
386 MPE_Log_event(31, 0,
"start");
400 MPE_Log_event(32, 0,
"end");
407 MPE_Log_event(13, 0,
"start");
414 MPE_Log_event(19, 0,
"start");
419 pGRReq[i] = SolvComm.Irecv(&
pBuffer[pDispl[i]],
431 MPI::DOUBLE, 0,
G_TAG);
451 MPI::Request::Waitall(SolvCommSize - 1, &pGRReq[1]);
455 if (MPI::Request::Testall(SolvCommSize - 1, &pGRReq[1]))
458 MPE_Log_event(20, 0,
"end");
473 std::cout <<
"# Solve 19:";
475 std::cout <<
" " <<
pBuffer[i];
477 std::cout << std::endl;
503 if (pGSReq[0].Test()) {
505 MPE_Log_event(14, 0,
"end");
526 MPE_Log_event(35, 0,
"start");
532 MPE_Log_event(36, 0,
"end");
537 MPE_Log_event(13, 0,
"start");
542 pGRReq[i] = SolvComm.Isend(pd, 1,
543 *ppNewTypes[i], i,
G_TAG);
553 MPI::Request::Waitall(SolvCommSize - 1, &pGRReq[1]);
558 if (MPI::Request::Testall(SolvCommSize - 1, &pGRReq[1]))
561 MPE_Log_event(14, 0,
"end");
572 MPE_Log_event(19, 0,
"start");
576 MPI::DOUBLE, 0,
G_TAG);
582 if (pGSReq[0].Test()) {
584 MPE_Log_event(20, 0,
"end");
585 MPE_Log_receive(0,
G_TAG, iIntVecDim);
598 std::cout <<
"# Solve 20a:";
600 std::cout <<
" " <<
pgVH->operator()(i);
602 std::cout << std::endl;
603 std::cout <<
"# Solve 20b:";
605 std::cout <<
" " <<
pSolrVH->operator()(i);
607 std::cout << std::endl;
615 MPE_Log_event(41, 0,
"start");
618 DEBUGCOUT(
"Entering SchurSolutionManager::AssSchur()" << endl);
629 MPE_Log_event(19, 0,
"start");
635 int iShift = pRecvDim[i]*pRecvDim[i];
637 pGRReq[i] = SolvComm.Irecv(&
pBuffer[iOffset],
638 iShift, MPI::DOUBLE, i,
S_TAG);
645 sizeof(
double)*pRecvDim[0]*pRecvDim[0]);
648 MPI::Request::Waitall(SolvCommSize - 1, &pGRReq[1]);
651 if (MPI::Request::Testall(SolvCommSize - 1, &pGRReq[1]))
654 MPE_Log_event(20, 0,
"end");
656 MPE_Log_receive(i,
S_TAG, pRecvDim[i]*pRecvDim[i]);
670 for (
int j = pDispl[i]; j < pDispl[i + 1]; j++) {
673 for (
int k = pDispl[i]; k < pDispl[i + 1]; k++) {
683 for (
int j = pDispl[i]; j < pDispl[i + 1]; j++) {
689 for (
int k = pDispl[i]; k < pDispl[i + 1]; k++) {
707 pbmd -= pDispl[i + 1] - pDispl[i];
714 MPE_Log_event(13, 0,
"start");
715 MPE_Log_send(0,
S_TAG, iIntVecDim*iIntVecDim);
718 pGSReq[0] = SolvComm.Isend(
pdCM, iIntVecDim*iIntVecDim,
719 MPI::DOUBLE, 0,
S_TAG);
726 if (pGSReq[0].Test()) {
728 MPE_Log_event(14, 0,
"end");
738 MPE_Log_event(42, 0,
"end");
745 DEBUGCOUT(
"Entering SchurSolutionManager::InitializeComm()" << endl);
756 SolvComm.Gather(&iIntVecDim, 1, MPI::INT, pRecvDim, 1, MPI::INT, 0);
759 pDispl[i + 1] = pDispl[i] + pRecvDim[i];
763 if (
MyRank == 0 && pDispl[SolvCommSize] == 0) {
764 silent_cerr(
"SchurSolutionManager::InitializeComm(): "
765 "empty problem" << std::endl);
774 SolvComm.Gatherv(
pIntDofs, iIntVecDim, MPI::INT,
775 pDofsRecvdList, pRecvDim, pDispl, MPI::INT, 0);
835 iTmpTot += pRecvDim[i]*pRecvDim[i];
839 pDispl[i + 1] = pDispl[i] + pRecvDim[i];
865 silent_cerr(
"SchurSolutionManager::pdSetResVec(): "
866 "you should not be here!! "
867 "Aborting..." << std::endl);
875 silent_cerr(
"SchurSolutionManager::pdSetSolVec(): "
876 "you should not be here!! "
877 "Aborting..." << std::endl);
908 DEBUGCOUT(
"Entering SchurSolutionManager::StartExchIntRes()" << endl);
913 MPE_Log_event(13, 0,
"start");
914 MPE_Log_send(0,
G_TAG, iIntVecDim);
919 MPE_Log_event(19, 0,
"start");
924 pGRReq[i] = SolvComm.Irecv(&
pBuffer[pDispl[i]],
925 pRecvDim[i], MPI::DOUBLE, i,
G_TAG);
930 sizeof(double)*pRecvDim[0]);
934 MPI::DOUBLE, 0,
G_TAG);
942 DEBUGCOUT(
"Entering SchurSolutionManager::ComplExchIntRes()" << endl);
948 const size_t DBLMSGSIZE = 1;
954 MPI::Request::Waitall(SolvCommSize - 1, &pGRReq[1]);
957 if (MPI::Request::Testall(SolvCommSize - 1, &pGRReq[1]))
960 MPE_Log_event(20, 0,
"end");
962 MPE_Log_receive(i,
G_TAG, pRecvDim[i]);
973 if (iPrbmBlocks == 1) {
989 for (
int iCntp1 = 1; iCntp1 <=
iSchurIntDim; iCntp1++) {
994 pGRReq[i] = SolvComm.Irecv(&
pBuffer[DBLMSGSIZE*i],
995 DBLMSGSIZE, MPI::DOUBLE,
1000 MPI::Request::Waitall(SolvCommSize - 1, &pGRReq[1]);
1003 if (MPI::Request::Testall(SolvCommSize - 1, &pGRReq[1]))
1016 SolvComm.Send(d, DBLMSGSIZE, MPI::DOUBLE, i,
G_TAG);
1021 SolvComm.Send(d, DBLMSGSIZE, MPI::DOUBLE, 0,
G_TAG + 100);
1028 if (pGSReq[0].Test()) {
1029 #ifdef MPI_PROFILING
1030 MPE_Log_event(14, 0,
"end");
1039 pGRReq[0] = SolvComm.Irecv(d, DBLMSGSIZE, MPI::DOUBLE,
1046 if (pGRReq[0].Test()) {
1060 DEBUGCOUT(
"Entering SchurSolutionManager::StartExchIntSol()" << endl);
1071 DEBUGCOUT(
"Entering SchurSolutionManager::ComplExchIntSol()" << endl);
1075 const size_t DBLMSGSIZE = 1;
1084 for (
int iCntp1 = 1; iCntp1 <=
iSchurIntDim; iCntp1++) {
1089 pGRReq[i] = SolvComm.Irecv(&
pBuffer[DBLMSGSIZE*i],
1090 DBLMSGSIZE, MPI::DOUBLE,
1095 MPI::Request::Waitall(SolvCommSize - 1, &pGRReq[1]);
1098 if (MPI::Request::Testall(SolvCommSize - 1, &pGRReq[1]))
1111 SolvComm.Send(d, DBLMSGSIZE, MPI::DOUBLE, i,
G_TAG);
1116 SolvComm.Send(d, DBLMSGSIZE, MPI::DOUBLE, 0,
G_TAG + 100);
1123 if (pGSReq[0].Test()) {
1124 #ifdef MPI_PROFILING
1125 MPE_Log_event(14, 0,
"end");
1134 pGRReq[0] = SolvComm.Irecv(d, DBLMSGSIZE, MPI::DOUBLE,
1141 if (pGRReq[0].Test()) {
SchurVectorHandler * pRVH
virtual void Reset(void)=0
void MatrInitialize(void)
virtual doublereal * GetECol(const integer iCol) const
void ComplExchIntRes(doublereal &d, const NonlinearSolverTest *t)
virtual void MatEFCReset(void)
virtual void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
#define MBDYN_EXCEPT_ARGS
virtual doublereal * pdGetVec(void) const =0
doublereal * pdSetSolVec(doublereal *pd)
SolutionManager *const GetSolutionManager(integer iNLD, integer iLWS=0) const
#define SAFEDELETEARR(pnt)
SchurSolutionManager(integer iSize, integer iBlocks, integer *pLocalDofs, int iDim1, integer *pInterfDofs, int iDim2, SolutionManager *pLSM, LinSol &ls)
virtual void IncCoef(integer iRow, const doublereal &dCoef)=0
virtual VectorHandler & CompNewf(VectorHandler &f, const VectorHandler &g) const
virtual void CompLocSchur(void)
virtual VectorHandler & CompNewg(VectorHandler &g, const VectorHandler &f) const
void StartExchIntSol(void)
SolutionManager * pLocalSM
virtual doublereal * GetEColSol(const integer iCol) const
virtual void TestMerge(doublereal &dResCurr, const doublereal &dResNew) const =0
virtual void Reset(void)=0
VectorHandler * pResHdl(void) const
virtual MatrixHandler * pMatHdl(void) const =0
doublereal * pdSetResVec(doublereal *pd)
virtual void MatrReset(void)=0
virtual void Solve(void)=0
VectorHandler * pSolSchVH
#define ASSERT(expression)
virtual void MatrInitialize(void)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
MatrixHandler * pMatHdl(void) const
void StartExchIntRes(void)
VectorHandler * pSolHdl(void) const
#define SAFENEWARRNOFILL(pnt, item, sz)
doublereal * pdSetResVec(doublereal *pRes)
integer iGetWorkSpaceSize(void) const
void ComplExchIntSol(doublereal &d, const NonlinearSolverTest *t)
void SetBMat(MatrixHandler *pBM)
#define SAFENEWARR(pnt, item, sz)
doublereal * pdSetSolVec(doublereal *pSol)
virtual void TestOne(doublereal &dRes, const VectorHandler &Vec, const integer &iIndex, doublereal dCoef) const =0
void InitializeList(T *list, integer dim, T value)
virtual ~SchurSolutionManager(void)
void InitializeComm(void)
SolutionManager * pInterSM