718 {
720
724
725 auto set_section_monitor = [&](auto solver) {
727 SNES snes;
728 CHKERR TSGetSNES(solver, &snes);
729 PetscViewerAndFormat *vf;
730 CHKERR PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,
731 PETSC_VIEWER_DEFAULT, &vf);
733 snes,
735 void *))SNESMonitorFields,
738 };
739
740 auto scatter_create = [&](
auto D,
auto coeff) {
742 CHKERR is_manager->isCreateProblemFieldAndRank(
simple->getProblemName(),
743 ROW,
"U", coeff, coeff, is);
744 int loc_size;
745 CHKERR ISGetLocalSize(is, &loc_size);
748 VecScatter scatter;
749 CHKERR VecScatterCreate(
D, is,
v, PETSC_NULLPTR, &scatter);
752 };
753
754 auto set_time_monitor = [&](auto dm, auto solver) {
757 boost::shared_ptr<ForcesAndSourcesCore> null;
761 };
762
763 auto set_essential_bc = [&]() {
765
767 auto pre_proc_ptr = boost::make_shared<FEMethod>();
768 auto post_proc_rhs_ptr = boost::make_shared<FEMethod>();
769 auto post_proc_lhs_ptr = boost::make_shared<FEMethod>();
770
771
772 auto time_scale = boost::make_shared<TimeScale>();
773
774 auto get_bc_hook_rhs = [&]() {
776 {time_scale}, false);
777 return hook;
778 };
779 pre_proc_ptr->preProcessHook = get_bc_hook_rhs();
780
781 auto get_post_proc_hook_rhs = [&]() {
783 mField, post_proc_rhs_ptr, 1.);
784 };
785 auto get_post_proc_hook_lhs = [&]() {
787 mField, post_proc_lhs_ptr, 1.);
788 };
789 post_proc_rhs_ptr->postProcessHook = get_post_proc_hook_rhs();
790
791 ts_ctx_ptr->getPreProcessIFunction().push_front(pre_proc_ptr);
792 ts_ctx_ptr->getPreProcessIJacobian().push_front(pre_proc_ptr);
793 ts_ctx_ptr->getPostProcessIFunction().push_back(post_proc_rhs_ptr);
794 post_proc_lhs_ptr->postProcessHook = get_post_proc_hook_lhs();
795 ts_ctx_ptr->getPostProcessIJacobian().push_back(post_proc_lhs_ptr);
797 };
798
799
800 auto set_schur_pc = [&](auto solver) {
801 boost::shared_ptr<SetUpSchur> schur_ptr;
802 if (
AT == AssemblyType::BLOCK_SCHUR) {
803
806 }
807 return schur_ptr;
808 };
809
810 auto dm =
simple->getDM();
812
814
819
820
821
822 CHKERR set_essential_bc();
823
825 auto solver = pip_mng->createTSIM();
826 CHKERR TSSetFromOptions(solver);
827
829 CHKERR TSSetIJacobian(solver,
B,
B, PETSC_NULLPTR, PETSC_NULLPTR);
830 auto schur_pc_ptr = set_schur_pc(solver);
831
833 CHKERR set_section_monitor(solver);
834 CHKERR set_time_monitor(dm, solver);
835 CHKERR TSSetSolution(solver,
D);
837 CHKERR TSSolve(solver, NULL);
838 } else {
839 auto solver = pip_mng->createTSIM2();
840 CHKERR TSSetFromOptions(solver);
841
843 CHKERR TSSetI2Jacobian(solver,
B,
B, PETSC_NULLPTR, PETSC_NULLPTR);
844 auto schur_pc_ptr = set_schur_pc(solver);
845
848 CHKERR set_section_monitor(solver);
849 CHKERR set_time_monitor(dm, solver);
850 CHKERR TS2SetSolution(solver,
D, DD);
852 CHKERR TSSolve(solver, NULL);
853 }
854
856}
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
auto createDMVector(DM dm)
Get smart vector from DM.
auto createDMMatrix(DM dm)
Get smart matrix from DM.
const double v
phase velocity of light in medium (cm/ns)
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
Set Monitor To TS solver.
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
Class (Function) to enforce essential constrains on the left hand side diagonal.
Class (Function) to enforce essential constrains on the right hand side diagonal.
Class (Function) to enforce essential constrains.
Section manager is used to create indexes and sections.
intrusive_ptr for managing petsc objects
static boost::shared_ptr< SetUpSchur > createSetUpSchur(MoFEM::Interface &m_field)