void SPivotd::SetOrientation(XYZd& newdView,XYZd& newdNorm) { dview=newdView; dnorm=newdNorm; v3dComputeOrthoBase(this); ComputeMatrix(); }
void SPivotf::SetPos(float x,float y,float z) { pos.x=x; pos.y=y; pos.z=z; ComputeMatrix(); }
void SPivotd::SetPos(double x,double y,double z) { pos.x=x; pos.y=y; pos.z=z; ComputeMatrix(); }
SPivotd::SPivotd() : dview(0.0,0.0,1.0), dnorm(0.0,1.0,0.0) { v3dComputeOrthoBase(this); ComputeMatrix(); }
void SPivotd::Set(XYZd p,XYZd dv,XYZd dn) { pos=p; dview=dv; dnorm=dn; v3dComputeOrthoBase(this); ComputeMatrix(); }
SPivotd::SPivotd(XYZd p,XYZd dv,XYZd dn) : pos(p), dview(dv), dnorm(dn) { v3dComputeOrthoBase(this); ComputeMatrix(); }
void SPivotf::Set(XYZf p,XYZf dv,XYZf dn) { pos=p; dview=dv; dnorm=dn; v3fComputeOrthoBase(this); ComputeMatrix(); }
SPivotf::SPivotf(XYZf p,XYZf dv,XYZf dn) : pos(p), dview(dv), dnorm(dn) { v3fComputeOrthoBase(this); ComputeMatrix(); }
void SPivotd::SetOrientation(double dViewX,double dViewY,double dViewZ,double dNormX,double dNormY,double dNormZ) { dview.x=dViewX; dview.y=dViewY; dview.z=dViewZ; dnorm.x=dNormX; dnorm.y=dNormY; dnorm.z=dNormZ; v3dComputeOrthoBase(this); ComputeMatrix(); }
void SPivotf::SetOrientation(float dViewX,float dViewY,float dViewZ,float dNormX,float dNormY,float dNormZ) { dview.x=dViewX; dview.y=dViewY; dview.z=dViewZ; dnorm.x=dNormX; dnorm.y=dNormY; dnorm.z=dNormZ; v3fComputeOrthoBase(this); ComputeMatrix(); }
int main(int argc,char **argv) { PetscErrorCode ierr; KSP ksp; PC pc; Vec x,b; DM da; Mat A,Atrans; PetscInt dof=1,M=8; PetscBool flg,trans=PETSC_FALSE; ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr; ierr = PetscOptionsGetInt(NULL,NULL,"-dof",&dof,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetBool(NULL,NULL,"-trans",&trans,NULL);CHKERRQ(ierr); ierr = DMDACreate(PETSC_COMM_WORLD,&da);CHKERRQ(ierr); ierr = DMSetDimension(da,3);CHKERRQ(ierr); ierr = DMDASetBoundaryType(da,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE);CHKERRQ(ierr); ierr = DMDASetStencilType(da,DMDA_STENCIL_STAR);CHKERRQ(ierr); ierr = DMDASetSizes(da,M,M,M);CHKERRQ(ierr); ierr = DMDASetNumProcs(da,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE);CHKERRQ(ierr); ierr = DMDASetDof(da,dof);CHKERRQ(ierr); ierr = DMDASetStencilWidth(da,1);CHKERRQ(ierr); ierr = DMDASetOwnershipRanges(da,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DMSetFromOptions(da);CHKERRQ(ierr); ierr = DMSetUp(da);CHKERRQ(ierr); ierr = DMCreateGlobalVector(da,&x);CHKERRQ(ierr); ierr = DMCreateGlobalVector(da,&b);CHKERRQ(ierr); ierr = ComputeRHS(da,b);CHKERRQ(ierr); ierr = DMSetMatType(da,MATBAIJ);CHKERRQ(ierr); ierr = DMSetFromOptions(da);CHKERRQ(ierr); ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr); ierr = ComputeMatrix(da,A);CHKERRQ(ierr); /* A is non-symmetric. Make A = 0.5*(A + Atrans) symmetric for testing icc and cholesky */ ierr = MatTranspose(A,MAT_INITIAL_MATRIX,&Atrans);CHKERRQ(ierr); ierr = MatAXPY(A,1.0,Atrans,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatScale(A,0.5);CHKERRQ(ierr); ierr = MatDestroy(&Atrans);CHKERRQ(ierr); /* Test sbaij matrix */ flg = PETSC_FALSE; ierr = PetscOptionsGetBool(NULL,NULL, "-test_sbaij1", &flg,NULL);CHKERRQ(ierr); if (flg) { Mat sA; PetscBool issymm; ierr = MatIsTranspose(A,A,0.0,&issymm);CHKERRQ(ierr); if (issymm) { ierr = MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);CHKERRQ(ierr); } else {ierr = PetscPrintf(PETSC_COMM_WORLD,"Warning: A is non-symmetric\n");CHKERRQ(ierr);} ierr = MatConvert(A,MATSBAIJ,MAT_INITIAL_MATRIX,&sA);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); A = sA; } ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr); ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr); ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetDM(pc,(DM)da);CHKERRQ(ierr); if (trans) { ierr = KSPSolveTranspose(ksp,b,x);CHKERRQ(ierr); } else { ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); } /* check final residual */ flg = PETSC_FALSE; ierr = PetscOptionsGetBool(NULL,NULL, "-check_final_residual", &flg,NULL);CHKERRQ(ierr); if (flg) { Vec b1; PetscReal norm; ierr = KSPGetSolution(ksp,&x);CHKERRQ(ierr); ierr = VecDuplicate(b,&b1);CHKERRQ(ierr); ierr = MatMult(A,x,b1);CHKERRQ(ierr); ierr = VecAXPY(b1,-1.0,b);CHKERRQ(ierr); ierr = VecNorm(b1,NORM_2,&norm);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Final residual %g\n",norm);CHKERRQ(ierr); ierr = VecDestroy(&b1);CHKERRQ(ierr); } ierr = KSPDestroy(&ksp);CHKERRQ(ierr); ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&b);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = DMDestroy(&da);CHKERRQ(ierr); ierr = PetscFinalize(); return ierr; }
int main(int argc,char **argv) { PetscErrorCode ierr; KSP ksp; PC pc; Vec x,b; DA da; Mat A,Atrans; PetscInt dof=1,M=-8; PetscTruth flg,trans=PETSC_FALSE; PetscInitialize(&argc,&argv,(char *)0,help); ierr = PetscOptionsGetInt(PETSC_NULL,"-dof",&dof,PETSC_NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(PETSC_NULL,"-M",&M,PETSC_NULL);CHKERRQ(ierr); ierr = PetscOptionsGetTruth(PETSC_NULL,"-trans",&trans,PETSC_NULL);CHKERRQ(ierr); ierr = DACreate(PETSC_COMM_WORLD,&da);CHKERRQ(ierr); ierr = DASetDim(da,3);CHKERRQ(ierr); ierr = DASetPeriodicity(da,DA_NONPERIODIC);CHKERRQ(ierr); ierr = DASetStencilType(da,DA_STENCIL_STAR);CHKERRQ(ierr); ierr = DASetSizes(da,M,M,M);CHKERRQ(ierr); ierr = DASetNumProcs(da,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE);CHKERRQ(ierr); ierr = DASetDof(da,dof);CHKERRQ(ierr); ierr = DASetStencilWidth(da,1);CHKERRQ(ierr); ierr = DASetVertexDivision(da,PETSC_NULL,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr); ierr = DASetFromOptions(da);CHKERRQ(ierr); ierr = DACreateGlobalVector(da,&x);CHKERRQ(ierr); ierr = DACreateGlobalVector(da,&b);CHKERRQ(ierr); ierr = ComputeRHS(da,b);CHKERRQ(ierr); ierr = DAGetMatrix(da,MATBAIJ,&A);CHKERRQ(ierr); ierr = ComputeMatrix(da,A);CHKERRQ(ierr); /* A is non-symmetric. Make A = 0.5*(A + Atrans) symmetric for testing icc and cholesky */ ierr = MatTranspose(A,MAT_INITIAL_MATRIX,&Atrans);CHKERRQ(ierr); ierr = MatAXPY(A,1.0,Atrans,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatScale(A,0.5);CHKERRQ(ierr); ierr = MatDestroy(Atrans);CHKERRQ(ierr); /* Test sbaij matrix */ flg = PETSC_FALSE; ierr = PetscOptionsGetTruth(PETSC_NULL, "-test_sbaij1", &flg,PETSC_NULL);CHKERRQ(ierr); if (flg){ Mat sA; ierr = MatConvert(A,MATSBAIJ,MAT_INITIAL_MATRIX,&sA);CHKERRQ(ierr); ierr = MatDestroy(A);CHKERRQ(ierr); A = sA; } ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr); ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr); ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetDA(pc,da);CHKERRQ(ierr); if (trans) { ierr = KSPSolveTranspose(ksp,b,x);CHKERRQ(ierr); } else { ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); } /* check final residual */ flg = PETSC_FALSE; ierr = PetscOptionsGetTruth(PETSC_NULL, "-check_final_residual", &flg,PETSC_NULL);CHKERRQ(ierr); if (flg){ Vec b1; PetscReal norm; ierr = KSPGetSolution(ksp,&x);CHKERRQ(ierr); ierr = VecDuplicate(b,&b1);CHKERRQ(ierr); ierr = MatMult(A,x,b1);CHKERRQ(ierr); ierr = VecAXPY(b1,-1.0,b);CHKERRQ(ierr); ierr = VecNorm(b1,NORM_2,&norm);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Final residual %g\n",norm);CHKERRQ(ierr); ierr = VecDestroy(b1);CHKERRQ(ierr); } ierr = KSPDestroy(ksp);CHKERRQ(ierr); ierr = VecDestroy(x);CHKERRQ(ierr); ierr = VecDestroy(b);CHKERRQ(ierr); ierr = MatDestroy(A);CHKERRQ(ierr); ierr = DADestroy(da);CHKERRQ(ierr); ierr = PetscFinalize();CHKERRQ(ierr); return 0; }
int main(int argc, char** argv) { DM da; PetscErrorCode ierr; Vec x, rhs; Mat A, jac; ierr = PetscInitialize(&argc, &argv, NULL, NULL); CHKERRQ(ierr); ierr = PetscOptionsBegin(PETSC_COMM_WORLD, NULL, "Laplacian in 2D", ""); CHKERRQ(ierr); ierr = PetscOptionsEnd(); CHKERRQ(ierr); ierr = HpddmRegisterKSP(); CHKERRQ(ierr); MPI_Barrier(PETSC_COMM_WORLD); double time = MPI_Wtime(); ierr = DMDACreate2d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DMDA_STENCIL_STAR, 10, 10, PETSC_DECIDE, PETSC_DECIDE, 1, 1, 0, 0, &da); CHKERRQ(ierr); ierr = DMSetFromOptions(da); CHKERRQ(ierr); ierr = DMSetUp(da); CHKERRQ(ierr); ierr = DMCreateGlobalVector(da, &rhs); CHKERRQ(ierr); ierr = DMCreateGlobalVector(da, &x); CHKERRQ(ierr); ierr = DMCreateMatrix(da, &A); CHKERRQ(ierr); ierr = DMCreateMatrix(da, &jac); CHKERRQ(ierr); ierr = ComputeMatrix(da, jac, A); CHKERRQ(ierr); MPI_Barrier(PETSC_COMM_WORLD); time = MPI_Wtime() - time; ierr = PetscPrintf(PETSC_COMM_WORLD, "--- Mat assembly = %f\n", time); CHKERRQ(ierr); MPI_Barrier(PETSC_COMM_WORLD); time = MPI_Wtime(); KSP ksp; ierr = KSPCreate(PETSC_COMM_WORLD, &ksp); CHKERRQ(ierr); ierr = KSPSetDM(ksp, da); CHKERRQ(ierr); ierr = KSPSetFromOptions(ksp); CHKERRQ(ierr); ierr = KSPSetOperators(ksp, A, A); CHKERRQ(ierr); ierr = KSPSetDMActive(ksp, PETSC_FALSE); CHKERRQ(ierr); ierr = KSPSetInitialGuessNonzero(ksp, PETSC_TRUE); CHKERRQ(ierr); ierr = KSPSetUp(ksp); CHKERRQ(ierr); MPI_Barrier(PETSC_COMM_WORLD); time = MPI_Wtime() - time; ierr = PetscPrintf(PETSC_COMM_WORLD, "--- PC setup = %f\n", time); CHKERRQ(ierr); PetscScalar nus[SIZE_ARRAY_NU] = {0.1, 10.0, 0.001, 100.0}; float t_time[SIZE_ARRAY_NU]; int t_its[SIZE_ARRAY_NU]; int i, j; for (j = 0; j < 2; ++j) { { if (j == 1) { ierr = KSPSetType(ksp, "hpddm"); CHKERRQ(ierr); ierr = KSPSetFromOptions(ksp); CHKERRQ(ierr); ierr = VecZeroEntries(x); CHKERRQ(ierr); } ierr = KSPSolve(ksp, rhs, x); CHKERRQ(ierr); if (j == 1) { const HpddmOption* const opt = HpddmOptionGet(); int previous = HpddmOptionVal(opt, "krylov_method"); if (previous == HPDDM_KRYLOV_METHOD_GCRODR || previous == HPDDM_KRYLOV_METHOD_BGCRODR) HpddmDestroyRecycling(); } } for (i = 0; i < SIZE_ARRAY_NU; ++i) { ierr = VecZeroEntries(x); CHKERRQ(ierr); ierr = ComputeRHS(da, rhs, nus[i]); CHKERRQ(ierr); MPI_Barrier(PETSC_COMM_WORLD); time = MPI_Wtime(); ierr = KSPSolve(ksp, rhs, x); CHKERRQ(ierr); MPI_Barrier(PETSC_COMM_WORLD); t_time[i] = MPI_Wtime() - time; PetscInt its; ierr = KSPGetIterationNumber(ksp, &its); CHKERRQ(ierr); t_its[i] = its; ierr = ComputeError(A, rhs, x); CHKERRQ(ierr); } for (i = 0; i < SIZE_ARRAY_NU; ++i) { ierr = PetscPrintf(PETSC_COMM_WORLD, "%d\t%d\t%f\n", i + 1, t_its[i], t_time[i]); CHKERRQ(ierr); if (i > 0) { t_its[0] += t_its[i]; t_time[0] += t_time[i]; } } if (SIZE_ARRAY_NU > 1) { ierr = PetscPrintf(PETSC_COMM_WORLD, "------------------------\n\t%d\t%f\n", t_its[0], t_time[0]); CHKERRQ(ierr); } } ierr = KSPDestroy(&ksp); CHKERRQ(ierr); ierr = VecDestroy(&x); CHKERRQ(ierr); ierr = VecDestroy(&rhs); CHKERRQ(ierr); ierr = MatDestroy(&A); CHKERRQ(ierr); ierr = MatDestroy(&jac); CHKERRQ(ierr); ierr = DMDestroy(&da); CHKERRQ(ierr); ierr = PetscFinalize(); return ierr; }
void SPivotd::SetPos(XYZd& newPos) { pos=newPos; ComputeMatrix(); }
void KG3DCameraPreset::GetPresetCamera(KG3DModel *pModel, enuCameraPresetType Type, float fAspect, bool bUsedForMeshMdlThumbnail/* = false */ ) { D3DXVECTOR3 vec3Position, vec3LookAt; float fWidth, fHeight, fDepth, fZFar; fZFar = 0.0f; D3DXMATRIX matTranlation; float offset_position = 0.0f; KG_PROCESS_ERROR(pModel); fWidth = abs(pModel->m_BBox.A.x - pModel->m_BBox.B.x); fHeight = abs(pModel->m_BBox.A.y - pModel->m_BBox.B.y); fDepth = abs(pModel->m_BBox.A.z - pModel->m_BBox.B.z); vec3LookAt.z = (pModel->m_BBox.A.z + pModel->m_BBox.B.z) / 2.0f; vec3LookAt.x = pModel->m_BBox.A.x + fWidth / 2.0f; vec3LookAt.y = (pModel->m_BBox.A.y + pModel->m_BBox.B.y) / 2; if (bUsedForMeshMdlThumbnail) { TCHAR strFile[MAX_PATH]; TCHAR strDrive[MAX_PATH]; TCHAR strPath[MAX_PATH]; TCHAR strExt[MAX_PATH]; _splitpath_s(pModel->m_scName.c_str(), strDrive, MAX_PATH, strPath, MAX_PATH, strFile, MAX_PATH, strExt, MAX_PATH); offset_position = max(max(fWidth, fHeight), fDepth) / 2.0f / tan(D3DX_PI / 6.0f); if (strcmpi(strExt, ".mesh") == 0) { vec3Position.z = vec3LookAt.z - offset_position; vec3Position.x = vec3LookAt.x + offset_position; vec3Position.y = vec3LookAt.y + offset_position; } else { vec3LookAt.y = (pModel->m_BBox.A.y + pModel->m_BBox.B.y) / 2.0f + fHeight / 5.0f; vec3Position.z = vec3LookAt.z - offset_position * 0.65f; vec3Position.x = vec3LookAt.x + offset_position * 0.65f; vec3Position.y = vec3LookAt.y + offset_position * 0.65f; } } else { vec3Position.z = pModel->m_BBox.A.z - max(fWidth, fHeight) / 2.0f / tan(D3DX_PI / 8); vec3Position.x = vec3LookAt.x; vec3Position.y = vec3LookAt.y; } fZFar = vec3Position.z - pModel->m_BBox.B.z; /*SetUpDirection(D3DXVECTOR3(0.0f, 1.0f, 0.0f)); SetPosition(vec3Position); SetLookAtPosition(vec3LookAt);*/ SetPositionLookAtUp(&vec3Position, &vec3LookAt, &D3DXVECTOR3(0,1,0)); SetPerspective(D3DX_PI / 4, fAspect, 10.0f, fZFar); ComputeMatrix(Type); D3DXMatrixTranslation(&matTranlation, 0.0f, 0.0f, -(pModel->m_BBox.A.y + pModel->m_BBox.B.y) / 2.0f); m_CameraInfo[Type].matView = /*matTranlation * */m_matTransform[Type] * m_CameraInfo[Type].matView; Exit0: ; }
int main(int argc,char **args) { PetscErrorCode ierr; DomainData dd; PetscReal norm,maxeig,mineig; PetscScalar scalar_value; PetscInt ndofs,its; Mat A =0,F=0; KSP KSPwithBDDC =0,KSPwithFETIDP=0; Vec fetidp_solution_all=0,bddc_solution=0,bddc_rhs=0; Vec exact_solution =0,fetidp_solution=0,fetidp_rhs=0; /* Init PETSc */ ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr; /* Initialize DomainData */ ierr = InitializeDomainData(&dd);CHKERRQ(ierr); /* Decompose domain */ ierr = DomainDecomposition(&dd);CHKERRQ(ierr); #if DEBUG printf("Subdomain data\n"); printf("IPS : %d %d %d\n",dd.ipx,dd.ipy,dd.ipz); printf("NEG : %d %d %d\n",dd.nex,dd.ney,dd.nez); printf("NEL : %d %d %d\n",dd.nex_l,dd.ney_l,dd.nez_l); printf("LDO : %d %d %d\n",dd.xm_l,dd.ym_l,dd.zm_l); printf("SIZES : %d %d %d\n",dd.xm,dd.ym,dd.zm); printf("STARTS: %d %d %d\n",dd.startx,dd.starty,dd.startz); #endif /* assemble global matrix */ ierr = ComputeMatrix(dd,&A);CHKERRQ(ierr); /* get work vectors */ ierr = MatCreateVecs(A,&bddc_solution,NULL);CHKERRQ(ierr); ierr = VecDuplicate(bddc_solution,&bddc_rhs);CHKERRQ(ierr); ierr = VecDuplicate(bddc_solution,&fetidp_solution_all);CHKERRQ(ierr); ierr = VecDuplicate(bddc_solution,&exact_solution);CHKERRQ(ierr); /* create and customize KSP/PC for BDDC */ ierr = ComputeKSPBDDC(dd,A,&KSPwithBDDC);CHKERRQ(ierr); /* create KSP/PC for FETIDP */ ierr = ComputeKSPFETIDP(dd,KSPwithBDDC,&KSPwithFETIDP);CHKERRQ(ierr); /* create random exact solution */ ierr = VecSetRandom(exact_solution,NULL);CHKERRQ(ierr); ierr = VecShift(exact_solution,-0.5);CHKERRQ(ierr); ierr = VecScale(exact_solution,100.0);CHKERRQ(ierr); ierr = VecGetSize(exact_solution,&ndofs);CHKERRQ(ierr); if (dd.pure_neumann) { ierr = VecSum(exact_solution,&scalar_value);CHKERRQ(ierr); scalar_value = -scalar_value/(PetscScalar)ndofs; ierr = VecShift(exact_solution,scalar_value);CHKERRQ(ierr); } /* assemble BDDC rhs */ ierr = MatMult(A,exact_solution,bddc_rhs);CHKERRQ(ierr); /* test ksp with BDDC */ ierr = KSPSolve(KSPwithBDDC,bddc_rhs,bddc_solution);CHKERRQ(ierr); ierr = KSPGetIterationNumber(KSPwithBDDC,&its);CHKERRQ(ierr); ierr = KSPComputeExtremeSingularValues(KSPwithBDDC,&maxeig,&mineig);CHKERRQ(ierr); if (dd.pure_neumann) { ierr = VecSum(bddc_solution,&scalar_value);CHKERRQ(ierr); scalar_value = -scalar_value/(PetscScalar)ndofs; ierr = VecShift(bddc_solution,scalar_value);CHKERRQ(ierr); } /* check exact_solution and BDDC solultion */ ierr = VecAXPY(bddc_solution,-1.0,exact_solution);CHKERRQ(ierr); ierr = VecNorm(bddc_solution,NORM_INFINITY,&norm);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"---------------------BDDC stats-------------------------------\n");CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Number of degrees of freedom : %8D \n",ndofs);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Number of iterations : %8D \n",its);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Eigenvalues preconditioned operator : %1.2e %1.2e\n",(double)mineig,(double)maxeig);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Error betweeen exact and computed solution : %1.2e\n",(double)norm);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"--------------------------------------------------------------\n");CHKERRQ(ierr); /* assemble fetidp rhs on the space of Lagrange multipliers */ ierr = KSPGetOperators(KSPwithFETIDP,&F,NULL);CHKERRQ(ierr); ierr = MatCreateVecs(F,&fetidp_solution,&fetidp_rhs);CHKERRQ(ierr); ierr = PCBDDCMatFETIDPGetRHS(F,bddc_rhs,fetidp_rhs);CHKERRQ(ierr); ierr = VecSet(fetidp_solution,0.0);CHKERRQ(ierr); /* test ksp with FETIDP */ ierr = KSPSolve(KSPwithFETIDP,fetidp_rhs,fetidp_solution);CHKERRQ(ierr); ierr = KSPGetIterationNumber(KSPwithFETIDP,&its);CHKERRQ(ierr); ierr = KSPComputeExtremeSingularValues(KSPwithFETIDP,&maxeig,&mineig);CHKERRQ(ierr); /* assemble fetidp solution on physical domain */ ierr = PCBDDCMatFETIDPGetSolution(F,fetidp_solution,fetidp_solution_all);CHKERRQ(ierr); /* check FETIDP sol */ if (dd.pure_neumann) { ierr = VecSum(fetidp_solution_all,&scalar_value);CHKERRQ(ierr); scalar_value = -scalar_value/(PetscScalar)ndofs; ierr = VecShift(fetidp_solution_all,scalar_value);CHKERRQ(ierr); } ierr = VecAXPY(fetidp_solution_all,-1.0,exact_solution);CHKERRQ(ierr); ierr = VecNorm(fetidp_solution_all,NORM_INFINITY,&norm);CHKERRQ(ierr); ierr = VecGetSize(fetidp_solution,&ndofs);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"------------------FETI-DP stats-------------------------------\n");CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Number of degrees of freedom : %8D \n",ndofs);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Number of iterations : %8D \n",its);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Eigenvalues preconditioned operator : %1.2e %1.2e\n",(double)mineig,(double)maxeig);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"Error betweeen exact and computed solution : %1.2e\n",(double)norm);CHKERRQ(ierr); ierr = PetscPrintf(dd.gcomm,"--------------------------------------------------------------\n");CHKERRQ(ierr); /* Free workspace */ ierr = VecDestroy(&exact_solution);CHKERRQ(ierr); ierr = VecDestroy(&bddc_solution);CHKERRQ(ierr); ierr = VecDestroy(&fetidp_solution);CHKERRQ(ierr); ierr = VecDestroy(&fetidp_solution_all);CHKERRQ(ierr); ierr = VecDestroy(&bddc_rhs);CHKERRQ(ierr); ierr = VecDestroy(&fetidp_rhs);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = KSPDestroy(&KSPwithBDDC);CHKERRQ(ierr); ierr = KSPDestroy(&KSPwithFETIDP);CHKERRQ(ierr); /* Quit PETSc */ ierr = PetscFinalize(); return ierr; }