299 const char param_file[] =
"param_file.petsc";
311 DMType dm_name =
"DMMOFEM";
332 boost::shared_ptr<CommonData> data(
new CommonData());
334 auto val_ptr = boost::shared_ptr<VectorDouble>(data, &data->val);
335 auto dot_val_ptr = boost::shared_ptr<VectorDouble>(data, &data->dot_val);
336 auto grad_ptr = boost::shared_ptr<MatrixDouble>(data, &data->grad);
340 boost::shared_ptr<Ele> vol_ele_slow_rhs(
new Ele(m_field));
341 boost::shared_ptr<Ele> vol_ele_stiff_rhs(
new Ele(m_field));
342 boost::shared_ptr<Ele> vol_ele_stiff_lhs(
new Ele(m_field));
345 vol_ele_slow_rhs->getOpPtrVector().push_back(
352 auto solve_for_g = [&]() {
354 if (*(vol_ele_slow_rhs->vecAssembleSwitch)) {
355 CHKERR VecGhostUpdateBegin(vol_ele_slow_rhs->ts_F, ADD_VALUES,
357 CHKERR VecGhostUpdateEnd(vol_ele_slow_rhs->ts_F, ADD_VALUES,
359 CHKERR VecAssemblyBegin(vol_ele_slow_rhs->ts_F);
360 CHKERR VecAssemblyEnd(vol_ele_slow_rhs->ts_F);
361 *vol_ele_slow_rhs->vecAssembleSwitch =
false;
363 CHKERR KSPSolve(data->ksp, vol_ele_slow_rhs->ts_F,
364 vol_ele_slow_rhs->ts_F);
368 vol_ele_slow_rhs->postProcessHook = solve_for_g;
370 auto det_ptr = boost::make_shared<VectorDouble>();
371 auto jac_ptr = boost::make_shared<MatrixDouble>();
372 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
374 vol_ele_stiff_rhs->getOpPtrVector().push_back(
376 vol_ele_stiff_rhs->getOpPtrVector().push_back(
378 vol_ele_stiff_rhs->getOpPtrVector().push_back(
380 vol_ele_stiff_rhs->getOpPtrVector().push_back(
382 vol_ele_stiff_rhs->getOpPtrVector().push_back(
384 vol_ele_stiff_rhs->getOpPtrVector().push_back(
388 vol_ele_stiff_lhs->getOpPtrVector().push_back(
390 vol_ele_stiff_lhs->getOpPtrVector().push_back(
392 vol_ele_stiff_lhs->getOpPtrVector().push_back(
394 vol_ele_stiff_lhs->getOpPtrVector().push_back(
398 auto vol_rule = [](
int,
int,
int p) ->
int {
return 2 * p; };
399 vol_ele_slow_rhs->getRuleHook = vol_rule;
400 vol_ele_stiff_rhs->getRuleHook = vol_rule;
401 vol_ele_stiff_lhs->getRuleHook = vol_rule;
405 auto post_proc = boost::make_shared<PostProcEle>(m_field);
406 boost::shared_ptr<ForcesAndSourcesCore>
null;
410 auto u_ptr = boost::make_shared<VectorDouble>();
411 post_proc->getOpPtrVector().push_back(
413 post_proc->getOpPtrVector().push_back(
417 post_proc->getPostProcMesh(), post_proc->getMapGaussPts(),
432 auto dm = simple_interface->
getDM();
440 1,
BLOCKSET, 2, inner_surface,
true);
441 if (!inner_surface.empty()) {
442 Range inner_surface_verts;
443 CHKERR moab.get_connectivity(inner_surface, inner_surface_verts,
false);
445 u0, MBVERTEX, inner_surface_verts,
"u");
457 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
458 CHKERR pcomm->filter_pstatus(edges, PSTATUS_SHARED | PSTATUS_MULTISHARED,
459 PSTATUS_NOT, -1, &edges_part);
461 CHKERR moab.get_connectivity(edges_part, edges_verts,
false);
466 unite(edges_verts, edges_part));
470 CHKERR MatZeroEntries(data->M);
471 boost::shared_ptr<Ele> vol_mass_ele(
new Ele(m_field));
472 vol_mass_ele->getOpPtrVector().push_back(
new OpAssembleMass(data));
475 CHKERR MatAssemblyBegin(data->M, MAT_FINAL_ASSEMBLY);
476 CHKERR MatAssemblyEnd(data->M, MAT_FINAL_ASSEMBLY);
481 CHKERR KSPSetOperators(data->ksp, data->M, data->M);
482 CHKERR KSPSetFromOptions(data->ksp);
483 CHKERR KSPSetUp(data->ksp);
488 CHKERR TSSetType(ts, TSARKIMEX);
489 CHKERR TSARKIMEXSetType(ts, TSARKIMEXA2);
493 vol_ele_stiff_lhs,
null,
null);
496 vol_ele_stiff_rhs,
null,
null);
499 vol_ele_slow_rhs,
null,
null);
502 boost::shared_ptr<Monitor> monitor_ptr(
new Monitor(dm, post_proc));
504 monitor_ptr,
null,
null);
514 CHKERR TSSetDuration(ts, PETSC_DEFAULT, ftime);
515 CHKERR TSSetSolution(ts, X);
516 CHKERR TSSetFromOptions(ts);