219 PetscBool flg_test = PETSC_FALSE;
220 CHKERR PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Poisson's problem options",
226 CHKERR PetscOptionsBool(
"-test",
"if true is ctest",
"", flg_test,
227 &flg_test, PETSC_NULL);
228 ierr = PetscOptionsEnd();
248 boost::shared_ptr<ForcesAndSourcesCore>
250 boost::shared_ptr<ForcesAndSourcesCore>
252 boost::shared_ptr<ForcesAndSourcesCore>
254 boost::shared_ptr<ForcesAndSourcesCore>
256 boost::shared_ptr<ForcesAndSourcesCore>
258 boost::shared_ptr<PoissonExample::PostProcFE>
260 boost::shared_ptr<ForcesAndSourcesCore>
null;
261 boost::shared_ptr<ForcesAndSourcesCore> boundary_penalty_lhs_fe;
268 boundary_lhs_fe, domain_rhs_fe, boundary_rhs_fe,
false);
273 global_error, domain_error);
278 const double beta = 1;
279 boundary_penalty_lhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
282 boundary_penalty_lhs_fe->getOpPtrVector().push_back(
new OpS(beta));
283 boundary_rhs_fe->getOpPtrVector().push_back(
358 CHKERR DMCreateGlobalVector(dm, &
F);
363 DM dm_sub_KK, dm_sub_LU;
364 ublas::matrix<Mat> nested_matrices(2, 2);
365 ublas::vector<IS> nested_is(2);
367 CHKERR DMCreate(PETSC_COMM_WORLD, &dm_sub_KK);
368 CHKERR DMSetType(dm_sub_KK,
"DMMOFEM");
370 CHKERR DMSetFromOptions(dm_sub_KK);
378 CHKERR DMSetUp(dm_sub_KK);
380 CHKERR DMCreateMatrix(dm_sub_KK, &nested_matrices(0, 0));
381 domain_lhs_fe->ksp_B = nested_matrices(0, 0);
384 boundary_penalty_lhs_fe->ksp_B = nested_matrices(0, 0);
387 boundary_penalty_lhs_fe);
388 CHKERR MatAssemblyBegin(nested_matrices(0, 0), MAT_FINAL_ASSEMBLY);
389 CHKERR MatAssemblyEnd(nested_matrices(0, 0), MAT_FINAL_ASSEMBLY);
390 CHKERR DMDestroy(&dm_sub_KK);
392 CHKERR DMCreate(PETSC_COMM_WORLD, &dm_sub_LU);
393 CHKERR DMSetType(dm_sub_LU,
"DMMOFEM");
395 CHKERR DMSetFromOptions(dm_sub_LU);
401 CHKERR DMSetUp(dm_sub_LU);
403 CHKERR DMCreateMatrix(dm_sub_LU, &nested_matrices(1, 0));
404 boundary_lhs_fe->ksp_B = nested_matrices(1, 0);
407 CHKERR MatAssemblyBegin(nested_matrices(1, 0), MAT_FINAL_ASSEMBLY);
408 CHKERR MatAssemblyEnd(nested_matrices(1, 0), MAT_FINAL_ASSEMBLY);
410 CHKERR MatTranspose(nested_matrices(1, 0), MAT_INITIAL_MATRIX,
411 &nested_matrices(0, 1));
412 CHKERR DMDestroy(&dm_sub_LU);
414 domain_rhs_fe->ksp_f =
F;
417 boundary_rhs_fe->ksp_f =
F;
424 nested_matrices(1, 1) = PETSC_NULL;
428 MatGetType(nested_matrices(0, 0), &
type);
429 cerr <<
"K " <<
type << endl;
430 MatGetType(nested_matrices(1, 0), &
type);
431 cerr <<
"C " <<
type << endl;
432 MatGetType(nested_matrices(0, 1), &
type);
433 cerr <<
"CT " <<
type << endl;
435 cerr <<
"UU" << endl;
436 MatView(nested_matrices(0, 0), PETSC_VIEWER_DRAW_WORLD);
438 cerr <<
"LU" << endl;
439 MatView(nested_matrices(1, 0), PETSC_VIEWER_DRAW_WORLD);
441 cerr <<
"UL" << endl;
442 MatView(nested_matrices(0, 1), PETSC_VIEWER_DRAW_WORLD);
446 CHKERR MatCreateNest(PETSC_COMM_WORLD, 2, &nested_is[0], 2, &nested_is[0],
447 &nested_matrices(0, 0), &
A);
451 CHKERR KSPCreate(PETSC_COMM_WORLD, &solver);
452 CHKERR KSPSetFromOptions(solver);
454 CHKERR KSPSetOperators(solver,
A,
A);
456 CHKERR KSPGetPC(solver, &pc);
457 PetscBool is_pcfs = PETSC_FALSE;
458 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
460 CHKERR PCFieldSplitSetIS(pc, NULL, nested_is[0]);
461 CHKERR PCFieldSplitSetIS(pc, NULL, nested_is[1]);
464 "Only works with pre-conditioner PCFIELDSPLIT");
478 CHKERR KSPDestroy(&solver);
479 for (
int i = 0;
i != 2;
i++) {
480 CHKERR ISDestroy(&nested_is[
i]);
481 for (
int j = 0;
j != 2;
j++) {
482 CHKERR MatDestroy(&nested_matrices(
i,
j));
499 if (flg_test == PETSC_TRUE) {
510 post_proc_volume->writeFile(
"out_vol.h5m");
517 CHKERR VecDestroy(&global_error);