732 {
734
738
739 auto set_section_monitor = [&](auto solver) {
741 SNES snes;
742 CHKERR TSGetSNES(solver, &snes);
743 PetscViewerAndFormat *vf;
744 CHKERR PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,
745 PETSC_VIEWER_DEFAULT, &vf);
747 snes,
749 void *))SNESMonitorFields,
752 };
753
754 auto scatter_create = [&](
auto D,
auto coeff) {
756 CHKERR is_manager->isCreateProblemFieldAndRank(
simple->getProblemName(),
757 ROW,
"U", coeff, coeff, is);
758 int loc_size;
759 CHKERR ISGetLocalSize(is, &loc_size);
762 VecScatter scatter;
763 CHKERR VecScatterCreate(
D, is,
v, PETSC_NULLPTR, &scatter);
766 };
767
768 auto set_time_monitor = [&](auto dm, auto solver) {
771 boost::shared_ptr<ForcesAndSourcesCore> null;
775 };
776
777 auto set_essential_bc = [&]() {
779
781 auto pre_proc_ptr = boost::make_shared<FEMethod>();
782 auto post_proc_rhs_ptr = boost::make_shared<FEMethod>();
783 auto post_proc_lhs_ptr = boost::make_shared<FEMethod>();
784
785
786 auto time_scale = boost::make_shared<TimeScale>();
787
788 auto get_bc_hook_rhs = [&]() {
790 {time_scale}, false);
791 return hook;
792 };
793 pre_proc_ptr->preProcessHook = get_bc_hook_rhs();
794
795 auto get_post_proc_hook_rhs = [&]() {
797 mField, post_proc_rhs_ptr, 1.);
798 };
799 auto get_post_proc_hook_lhs = [&]() {
801 mField, post_proc_lhs_ptr, 1.);
802 };
803 post_proc_rhs_ptr->postProcessHook = get_post_proc_hook_rhs();
804
805 ts_ctx_ptr->getPreProcessIFunction().push_front(pre_proc_ptr);
806 ts_ctx_ptr->getPreProcessIJacobian().push_front(pre_proc_ptr);
807 ts_ctx_ptr->getPostProcessIFunction().push_back(post_proc_rhs_ptr);
808 post_proc_lhs_ptr->postProcessHook = get_post_proc_hook_lhs();
809 ts_ctx_ptr->getPostProcessIJacobian().push_back(post_proc_lhs_ptr);
811 };
812
813
814 auto set_schur_pc = [&](auto solver) {
815 boost::shared_ptr<SetUpSchur> schur_ptr;
816 if (
AT == AssemblyType::BLOCK_SCHUR) {
817
820 }
821 return schur_ptr;
822 };
823
824 auto dm =
simple->getDM();
826
828
833
834
835
836 CHKERR set_essential_bc();
837
839 auto solver = pip_mng->createTSIM();
840 CHKERR TSSetFromOptions(solver);
841
843 CHKERR TSSetIJacobian(solver,
B,
B, PETSC_NULLPTR, PETSC_NULLPTR);
844 auto schur_pc_ptr = set_schur_pc(solver);
845
847 CHKERR set_section_monitor(solver);
848 CHKERR set_time_monitor(dm, solver);
849 CHKERR TSSetSolution(solver,
D);
851 CHKERR TSSolve(solver, NULL);
852 } else {
853 auto solver = pip_mng->createTSIM2();
854 CHKERR TSSetFromOptions(solver);
855
857 CHKERR TSSetI2Jacobian(solver,
B,
B, PETSC_NULLPTR, PETSC_NULLPTR);
858 auto schur_pc_ptr = set_schur_pc(solver);
859
862 CHKERR set_section_monitor(solver);
863 CHKERR set_time_monitor(dm, solver);
864 CHKERR TS2SetSolution(solver,
D, DD);
866 CHKERR TSSolve(solver, NULL);
867 }
868
870}
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
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)