18 #if PETSC_VERSION_GE(3, 6, 0) 19 #include <petsc/private/dmimpl.h> 22 #include <petsc-private/dmimpl.h> 23 #include <petsc-private/vecimpl.h> 31 : mField_ptr(PETSC_NULL), isProblemBuild(PETSC_FALSE),
32 isPartitioned(PETSC_FALSE), isSquareMatrix(PETSC_TRUE),
33 isSubDM(PETSC_FALSE), isCompDM(PETSC_FALSE), destroyProblem(PETSC_FALSE),
34 verbosity(
VERBOSE), referenceNumber(0) {}
46 *iface = const_cast<DMCtx *>(
this);
60 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
76 CHKERR DMSetMatType(dm, MATMPIAIJ);
82 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
84 dm->data =
new DMCtx();
90 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
91 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
93 if (((
DMCtx *)dm->data)->referenceNumber == 0) {
100 delete ((
DMCtx *)dm->data);
104 (((
DMCtx *)dm->data)->referenceNumber)--;
110 const char problem_name[],
115 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
118 "data structure for MoFEM not yet created");
122 "DM function not implemented into MoFEM");
140 boost::shared_ptr<KspCtx>(
new KspCtx(*m_field_ptr, problem_name));
142 boost::shared_ptr<SnesCtx>(
new SnesCtx(*m_field_ptr, problem_name));
144 boost::shared_ptr<TsCtx>(
new TsCtx(*m_field_ptr, problem_name));
147 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
149 MPI_Comm_compare(comm, m_field_ptr->
get_comm(), &result);
152 if (result > MPI_CONGRUENT) {
154 "MoFEM and DM using different communicators");
156 MPI_Comm_size(comm, &dm_field->
sIze);
157 MPI_Comm_rank(comm, &dm_field->
rAnk);
169 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
172 "data structure for MoFEM not yet created");
178 subdm_field->
isSubDM = PETSC_TRUE;
179 subdm_field->problemMainOfSubPtr = dm_field->
problemPtr;
181 subdm_field->isSquareMatrix = PETSC_FALSE;
188 EntityType lo_type, EntityType hi_type) {
189 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
191 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
194 "data structure for MoFEM not yet created");
199 dm_field->
rowFields.push_back(field_name);
200 if (lo_type != MBVERTEX || hi_type != MBMAXTYPE) {
203 std::map<std::string, std::pair<EntityType, EntityType>>>();
205 std::pair<EntityType, EntityType>(lo_type, hi_type);
211 EntityType lo_type, EntityType hi_type) {
212 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
214 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
217 "data structure for MoFEM not yet created");
222 dm_field->
colFields.push_back(field_name);
223 if (lo_type != MBVERTEX || hi_type != MBMAXTYPE) {
226 std::map<std::string, std::pair<EntityType, EntityType>>>();
228 std::pair<EntityType, EntityType>(lo_type, hi_type);
235 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
237 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
238 *is_sub_dm = dm_field->
isSubDM;
244 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
246 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
247 if (dm_field->
isSubDM != PETSC_TRUE) {
249 "This DM is not created as a SubDM");
254 boost::shared_ptr<Problem::SubProblemData> sub_data =
256 CHKERR sub_data->getRowIs(is);
262 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
264 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
265 if (dm_field->
isSubDM != PETSC_TRUE) {
267 "This DM is not created as a SubDM");
272 boost::shared_ptr<Problem::SubProblemData> sub_data =
274 CHKERR sub_data->getColIs(is);
279 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
281 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
284 "data structure for MoFEM not yet created");
297 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
299 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
302 "data structure for MoFEM not yet created");
309 "No need to add problem on column when problem block structurally " 318 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
320 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
326 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
328 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
331 "data structure for MoFEM not yet created");
338 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
340 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
343 "data structure for MoFEM not yet created");
351 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
353 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
360 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
362 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
369 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
371 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
378 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
380 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
382 ->resolveSharedFiniteElements(dm_field->
problemPtr, fe_name);
391 PetscLayout *layout) {
393 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
395 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
398 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
407 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
409 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
415 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
417 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
425 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
427 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
435 ScatterMode scatter_mode) {
437 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
439 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
447 ScatterMode scatter_mode) {
448 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
450 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
458 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
460 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
468 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
470 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
479 int low_rank,
int up_rank) {
481 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
483 dm_field->
problemPtr, fe_name, *method, low_rank, up_rank);
490 boost::shared_ptr<MoFEM::FEMethod> method,
491 int low_rank,
int up_rank) {
498 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
500 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
509 boost::shared_ptr<MoFEM::FEMethod> method) {
515 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
517 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
520 *method, dm_field->
rAnk, dm_field->
rAnk);
525 template <
class S,
class T0,
class T1,
class T2>
527 T1 pre_only, T2 post_only) {
528 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
530 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
532 dm_field->
kspCtx->get_preProcess_to_do_Rhs().push_back(pre_only);
535 dm_field->
kspCtx->get_loops_to_do_Rhs().push_back(
539 dm_field->
kspCtx->get_postProcess_to_do_Rhs().push_back(post_only);
551 dm, fe_name, method, pre_only, post_only);
556 boost::shared_ptr<MoFEM::FEMethod> method,
557 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
558 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
560 boost::shared_ptr<MoFEM::FEMethod>,
561 boost::shared_ptr<MoFEM::BasicMethod>,
562 boost::shared_ptr<MoFEM::BasicMethod>>(
563 dm, fe_name, method, pre_only, post_only);
566 template <
class S,
class T0,
class T1,
class T2>
568 T1 pre_only, T2 post_only) {
569 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
571 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
573 dm_field->
kspCtx->get_preProcess_to_do_Mat().push_back(pre_only);
576 dm_field->
kspCtx->get_loops_to_do_Mat().push_back(
580 dm_field->
kspCtx->get_postProcess_to_do_Mat().push_back(post_only);
593 dm, fe_name, method, pre_only, post_only);
598 boost::shared_ptr<MoFEM::FEMethod> method,
599 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
600 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
602 boost::shared_ptr<MoFEM::FEMethod>>(
603 dm, fe_name, method, pre_only, post_only);
606 template <
class S,
class T0,
class T1,
class T2>
608 T1 pre_only, T2 post_only) {
609 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
611 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
613 dm_field->
snesCtx->get_preProcess_to_do_Rhs().push_back(pre_only);
616 dm_field->
snesCtx->get_loops_to_do_Rhs().push_back(
620 dm_field->
snesCtx->get_postProcess_to_do_Rhs().push_back(post_only);
632 dm, fe_name, method, pre_only, post_only);
637 boost::shared_ptr<MoFEM::FEMethod> method,
638 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
639 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
641 boost::shared_ptr<MoFEM::FEMethod>,
642 boost::shared_ptr<MoFEM::BasicMethod>,
643 boost::shared_ptr<MoFEM::BasicMethod>>(
644 dm, fe_name, method, pre_only, post_only);
647 template <
class S,
class T0,
class T1,
class T2>
649 T1 pre_only, T2 post_only) {
650 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
652 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
654 dm_field->
snesCtx->get_preProcess_to_do_Mat().push_back(pre_only);
657 dm_field->
snesCtx->get_loops_to_do_Mat().push_back(
661 dm_field->
snesCtx->get_postProcess_to_do_Mat().push_back(post_only);
673 dm, fe_name, method, pre_only, post_only);
678 boost::shared_ptr<MoFEM::FEMethod> method,
679 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
680 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
682 boost::shared_ptr<MoFEM::FEMethod>,
683 boost::shared_ptr<MoFEM::BasicMethod>,
684 boost::shared_ptr<MoFEM::BasicMethod>>(
685 dm, fe_name, method, pre_only, post_only);
688 template <
class S,
class T0,
class T1,
class T2>
690 T1 pre_only, T2 post_only) {
691 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
693 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
695 dm_field->
tsCtx->get_preProcess_to_do_IFunction().push_back(pre_only);
698 dm_field->
tsCtx->get_loops_to_do_IFunction().push_back(
702 dm_field->
tsCtx->get_postProcess_to_do_IFunction().push_back(post_only);
714 dm, fe_name, method, pre_only, post_only);
720 boost::shared_ptr<MoFEM::FEMethod> method,
721 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
722 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
724 boost::shared_ptr<MoFEM::FEMethod>,
725 boost::shared_ptr<MoFEM::BasicMethod>,
726 boost::shared_ptr<MoFEM::BasicMethod>>(
727 dm, fe_name, method, pre_only, post_only);
731 template <
class S,
class T0,
class T1,
class T2>
733 T1 pre_only, T2 post_only) {
734 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
736 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
738 dm_field->
tsCtx->get_preProcess_to_do_IJacobian().push_back(pre_only);
741 dm_field->
tsCtx->get_loops_to_do_IJacobian().push_back(
745 dm_field->
tsCtx->get_postProcess_to_do_IJacobian().push_back(post_only);
757 pre_only, post_only);
762 boost::shared_ptr<MoFEM::FEMethod> method,
763 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
764 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
766 boost::shared_ptr<MoFEM::FEMethod>,
767 boost::shared_ptr<MoFEM::BasicMethod>,
768 boost::shared_ptr<MoFEM::BasicMethod>>(
769 dm, fe_name, method, pre_only, post_only);
772 template <
class S,
class T0,
class T1,
class T2>
774 T1 pre_only, T2 post_only) {
775 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
777 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
779 dm_field->
tsCtx->get_preProcess_to_do_RHSFunction().push_back(pre_only);
781 dm_field->
tsCtx->get_loops_to_do_RHSFunction().push_back(
784 dm_field->
tsCtx->get_postProcess_to_do_RHSFunction().push_back(post_only);
791 boost::shared_ptr<MoFEM::FEMethod> method,
792 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
793 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
795 boost::shared_ptr<MoFEM::FEMethod>,
796 boost::shared_ptr<MoFEM::BasicMethod>,
797 boost::shared_ptr<MoFEM::BasicMethod>>(
798 dm, fe_name, method, pre_only, post_only);
802 template <
class S,
class T0,
class T1,
class T2>
804 T1 pre_only, T2 post_only) {
805 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
807 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
809 dm_field->
tsCtx->get_preProcess_to_do_RHSFunction().push_back(pre_only);
811 dm_field->
tsCtx->get_loops_to_do_RHSFunction().push_back(
814 dm_field->
tsCtx->get_postProcess_to_do_RHSFunction().push_back(post_only);
821 boost::shared_ptr<MoFEM::FEMethod> method,
822 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
823 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
825 boost::shared_ptr<MoFEM::FEMethod>,
826 boost::shared_ptr<MoFEM::BasicMethod>,
827 boost::shared_ptr<MoFEM::BasicMethod>>(
828 dm, fe_name, method, pre_only, post_only);
834 boost::shared_ptr<MoFEM::FEMethod> method,
835 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
836 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
837 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
839 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
841 dm_field->
tsCtx->get_preProcess_to_do_IFunction().push_back(pre_only);
844 dm_field->
tsCtx->get_loops_to_do_IFunction().push_back(
848 dm_field->
tsCtx->get_postProcess_to_do_IFunction().push_back(post_only);
856 boost::shared_ptr<MoFEM::FEMethod> method,
857 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
858 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
859 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
861 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
863 dm_field->
tsCtx->get_preProcess_to_do_IJacobian().push_back(pre_only);
866 dm_field->
tsCtx->get_loops_to_do_IJacobian().push_back(
870 dm_field->
tsCtx->get_postProcess_to_do_IJacobian().push_back(post_only);
876 template <
class S,
class T0,
class T1,
class T2>
878 T1 pre_only, T2 post_only) {
879 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
881 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
883 dm_field->
tsCtx->get_preProcess_to_do_Monitor().push_back(pre_only);
885 dm_field->
tsCtx->get_loops_to_do_Monitor().push_back(
888 dm_field->
tsCtx->get_postProcess_to_do_Monitor().push_back(post_only);
899 dm, ts, fe_name, method, pre_only, post_only);
905 boost::shared_ptr<MoFEM::FEMethod> method,
906 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
907 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
909 boost::shared_ptr<MoFEM::FEMethod>,
910 boost::shared_ptr<MoFEM::BasicMethod>,
911 boost::shared_ptr<MoFEM::BasicMethod>>(
912 dm, ts, fe_name, method, pre_only, post_only);
917 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
919 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
920 *ksp_ctx = dm_field->
kspCtx.get();
926 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
928 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
929 const_cast<boost::shared_ptr<MoFEM::KspCtx> &
>(ksp_ctx) = dm_field->
kspCtx;
934 boost::shared_ptr<MoFEM::KspCtx> &ksp_ctx) {
935 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
937 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
938 dm_field->
kspCtx = ksp_ctx;
943 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
946 *snes_ctx = dm_field->
snesCtx.get();
952 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
954 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
955 const_cast<boost::shared_ptr<MoFEM::SnesCtx> &
>(snes_ctx) = dm_field->
snesCtx;
960 boost::shared_ptr<MoFEM::SnesCtx> &snes_ctx) {
961 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
963 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
972 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
974 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
983 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
985 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
991 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
993 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
994 *ts_ctx = dm_field->
tsCtx.get();
999 const boost::shared_ptr<MoFEM::TsCtx> &ts_ctx) {
1000 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1002 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1003 const_cast<boost::shared_ptr<MoFEM::TsCtx> &
>(ts_ctx) = dm_field->
tsCtx;
1008 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1010 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1011 dm_field->
tsCtx = ts_ctx;
1016 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1018 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1025 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1027 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1034 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1036 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1043 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1045 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1046 if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1048 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->
problemName,
1050 }
else if (strcmp(dm->mattype, MATAIJ) == 0) {
1052 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->
problemName,
1056 "Matrix type not implemented");
1062 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1064 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1065 if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1067 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->
problemName,
1069 }
else if (strcmp(dm->mattype, MATAIJ) == 0) {
1071 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->
problemName,
1075 "Matrix type not implemented");
1080 #if PETSC_VERSION_GE(3, 7, 0) 1083 #elif PETSC_VERSION_GE(3, 5, 3) 1089 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1091 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1092 #if PETSC_VERSION_GE(3, 5, 3) 1093 ierr = PetscOptionsHead(PetscOptionsObject,
"DMMoFEM Options");
1096 ierr = PetscOptionsHead(
"DMMoFEM Options");
1099 ierr = PetscOptionsBool(
"-dm_is_partitioned",
1100 "set if mesh is partitioned (works which native MOAB " 1101 "file format, i.e. h5m",
1109 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1112 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1156 PetscValidHeaderSpecific(subdm, DM_CLASSID, 1);
1160 DMCtx *subdm_field = static_cast<DMCtx *>(subdm->data);
1165 map<std::string, std::pair<EntityType, EntityType>> *entity_map_row =
nullptr;
1166 map<std::string, std::pair<EntityType, EntityType>> *entity_map_col =
nullptr;
1169 entity_map_row = subdm_field->
mapTypeRow.get();
1171 entity_map_row = subdm_field->
mapTypeCol.get();
1176 subdm_field->
isSquareMatrix == PETSC_TRUE, entity_map_row, entity_map_col,
1183 0, subdm_field->
sIze,
1204 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1206 CHKERR VecGhostUpdateBegin(g, INSERT_VALUES, SCATTER_FORWARD);
1212 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1215 CHKERR VecGhostUpdateEnd(g, INSERT_VALUES, SCATTER_FORWARD);
1217 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1221 double *array_loc, *array_glob;
1222 CHKERR VecGetArray(l, &array_loc);
1223 CHKERR VecGetArray(g, &array_glob);
1226 cblas_dcopy(nb_dofs + nb_ghost, array_glob, 1, array_loc, 1);
1229 cblas_daxpy(nb_dofs + nb_ghost, 1, array_glob, 1, array_loc, 1);
1234 CHKERR VecRestoreArray(l, &array_loc);
1235 CHKERR VecRestoreArray(g, &array_glob);
1242 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1245 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1249 double *array_loc, *array_glob;
1250 CHKERR VecGetArray(l, &array_loc);
1251 CHKERR VecGetArray(g, &array_glob);
1254 cblas_dcopy(nb_dofs + nb_ghost, array_loc, 1, array_glob, 1);
1257 cblas_daxpy(nb_dofs + nb_ghost, 1, array_loc, 1, array_glob, 1);
1262 CHKERR VecRestoreArray(l, &array_loc);
1263 CHKERR VecRestoreArray(g, &array_glob);
1275 char ***fieldNames, IS **fields) {
1276 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1289 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1292 Field_multiIndex::iterator fit, hi_fit;
1293 fit = fields_ptr->begin();
1294 hi_fit = fields_ptr->end();
1295 *numFields = std::distance(fit, hi_fit);
1298 CHKERR PetscMalloc1(*numFields, fieldNames);
1301 CHKERR PetscMalloc1(*numFields, fields);
1304 for (
int f = 0; fit != hi_fit; fit++, f++) {
1306 CHKERR PetscStrallocpy(fit->get()->getName().c_str(),
1307 (
char **)&(*fieldNames)[f]);
1311 ->isCreateProblemFieldAndRank(
1313 fit->get()->getNbOfCoeffs(), &(*fields)[f]);
1322 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1324 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1327 field_name, 0, 1000, is);
1332 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1334 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
PetscErrorCode TsSetI2Jacobian(TS ts, PetscReal t, Vec u, Vec u_t, Vec u_tt, PetscReal v, PetscReal a, Mat A, Mat B, void *ctx)
Calculation Jaconian for second order PDE in time.
std::string problemName
Problem name.
PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is)
get sub problem is
structure for User Loop Methods on finite elementsIt can be used to calculate stiffness matrices,...
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
MoFEM interface unique ID.
Problem manager is used to build and partition problems.
PetscBool isSquareMatrix
true if rows equals to cols
virtual bool check_problem(const std::string name)=0
check if problem exist
PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb)
Set verbosity level.
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set compute operator for KSP solver via sub-matrix and IS.
DEPRECATED PetscErrorCode DMMoFEMResolveSharedEntities(DM dm, const char fe_name[])
virtual MoFEMErrorCode delete_problem(const std::string name)=0
Delete problem.
PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec)
boost::shared_ptr< SubProblemData > & getSubData() const
Get main problem of sub-problem is.
boost::shared_ptr< std::map< std::string, std::pair< EntityType, EntityType > > > mapTypeRow
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
void cblas_daxpy(const int N, const double alpha, const double *X, const int incX, double *Y, const int incY)
PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is)
get sub problem is
Section manager is used to create indexes and sectionsFIXME: ISManager is not properly testsed by ato...
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, const char fe_name[])
Resolve shared entities.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problemIt if true is assumed that matrix has the same indexing on rows and columns....
Interface for Time Stepping (TS) solver.
PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm)
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[], EntityType lo_type=MBVERTEX, EntityType hi_type=MBMAXTYPE)
MoFEMErrorCode buildCompsedProblem(const std::string out_name, const std::vector< std::string > add_row_problems, const std::vector< std::string > add_col_problems, const bool square_matrix=true, int verb=1)
build composite problem
PetscErrorCode DMMoFEMAddElement(DM dm, const char fe_name[])
add element to dm
void cblas_dcopy(const int N, const double *X, const int incX, double *Y, const int incY)
PetscErrorCode SnesMat(SNES snes, Vec x, Mat A, Mat B, void *ctx)
This is MoFEM implementation for the left hand side (tangent matrix) evaluation in SNES solver.
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string &name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
Interface * mField_ptr
MoFEM interface.
base class for all interface classes
PetscBool isPartitioned
true if read mesh is on parts
PetscErrorCode TsSetRHSFunction(TS ts, PetscReal t, Vec u, Vec F, void *ctx)
TS solver function.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
PetscErrorCode DMSetUp_MoFEM(DM dm)
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on colThis create block on col with DOFs from problem of given name.
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Field_multiIndex for Field.
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
DofIdx getNbLocalDofsRow() const
PetscErrorCode TsMonitorSet(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Set monitor for TS solver.
const Problem * problemPtr
pinter to problem data structure
std::vector< std::string > colCompPrb
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Data structure to exchange data between mofem and User Loop Methods on entities.It allows to exchange...
keeps basic data about problemThis is low level structure with information about problem,...
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set KSP operators and push mofem finite element methods.
DofIdx getNbGhostDofsRow() const
PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, 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 TS Jacobian evaluation function
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method)
Executes FEMethod for finite elements in DM.
implementation of Data Operators for Forces and Sources
Discrete manager interface for MoFEM.
PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm)
Get if this DM is composite DM.
PetscBool destroyProblem
If true destroy problem with DM.
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVectorsets the routine to create a global vector associated with the shell DM.
PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, const char fe_name[], PetscLayout *layout)
Get finite elements layout in the problem.
PetscErrorCode DMMoFEMTSSetI2Function(DM dm, 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 TS implicit function evaluation function
boost::shared_ptr< TsCtx > tsCtx
data structure for TS solver
PetscErrorCode DMMoFEMTSSetRHSFunction(DM dm, 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 TS the right hand side function
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on rowThis create block on row with DOFs from problem of given name.
PetscErrorCode KspRhs(KSP ksp, Vec f, void *ctx)
Run over elements in the lists.
std::vector< std::string > rowFields
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[], EntityType lo_type=MBVERTEX, EntityType hi_type=MBMAXTYPE)
PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr< MoFEM::TsCtx > &ts_ctx)
Set MoFEM::TsCtx data structureIt take over pointer, do not delete it, DM will destroy pointer when i...
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
PetscErrorCode DMMoFEMTSSetI2Jacobian(DM dm, 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 TS Jacobian evaluation function
PetscErrorCode TsSetIFunction(TS ts, PetscReal t, Vec u, Vec u_t, Vec F, void *ctx)
Set IFunction for TS solver.
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
MoFEMErrorCode partitionGhostDofsOnDistributedMesh(const std::string name, int verb=VERBOSE)
determine ghost nodes on distributed meshes
virtual MoFEMErrorCode get_problem(const std::string &problem_name, const Problem **problem_ptr) const =0
Get problem database (data structure)
PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem)
get squared problemIt if true is assumed that matrix has the same indexing on rows and columns....
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
boost::shared_ptr< KspCtx > kspCtx
data structure KSP
PetscBool isProblemBuild
True if problem is build.
Interface for nonlinear (SNES) solver.
const Problem * problemMainOfSubPtr
pinter to main problem to sub-problem
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMMoFEMTSSetRHSJacobian(DM dm, 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 TS the right hand side jacobian
PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem)
boost::shared_ptr< SnesCtx > snesCtx
data structure SNES
PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx)
get MoFEM::KspCtx data structure
virtual MoFEMErrorCode modify_problem_unset_finite_element(const std::string &name_problem, const std::string &fe_name)=0
unset finite element from problem, this remove entities assigned to finite element to a particular pr...
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
PetscErrorCode DMMoFEMUnSetElement(DM dm, const char fe_name[])
unset element from dm
PetscErrorCode KspMat(KSP ksp, Mat A, Mat B, void *ctx)
Run over elenents in the list.
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Vector manager is used to create vectors \mofem_vectors.
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMCreate_MoFEM(DM dm)
Create dm data structure with MoFEM data structure.
virtual MoFEMErrorCode problem_basic_method_preProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
PetscErrorCode DMSetOperators_MoFEM(DM dm)
Set operators for MoFEM dm.
#define CHKERR
Inline error check.
PetscErrorCode TsSetI2Function(TS ts, PetscReal t, Vec u, Vec u_t, Vec u_tt, Vec F, void *ctx)
Calculation the right hand side for second order PDE in time.
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
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.
MoFEMErrorCode buildSubProblem(const std::string out_name, const std::vector< std::string > &fields_row, const std::vector< std::string > &fields_col, const std::string main_problem, const bool square_matrix=true, const map< std::string, std::pair< EntityType, EntityType >> *entityMapRow=nullptr, const map< std::string, std::pair< EntityType, EntityType >> *entityMapCol=nullptr, int verb=VERBOSE)
build sub problem
std::vector< std::string > colFields
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode buildProblemOnDistributedMesh(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures, assuming that mesh is distributed (collective)Mesh is distributed,...
BitRefLevel getBitRefLevel() const
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
std::vector< std::string > rowCompPrb
Interface for linear (KSP) solver.
PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
PetscErrorCode TsSetRHSJacobian(TS ts, PetscReal t, Vec u, Mat A, Mat B, void *ctx)
TS solver function.
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elementsFunction which partition finite elements based on dofs partitioning....
PETSc Discrete Manager data structure.
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set TS implicit function evaluation function
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned)
static const MOFEMuuid IDD_DMCTX
virtual MPI_Comm & get_comm() const =0
std::string getName() const
virtual MoFEMErrorCode get_fields(const Field_multiIndex **fields_ptr) const =0
Get fields multi-index from database.
PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[], MoFEM::DofMethod *method)
execute method for dofs on field in problem
MoFEMErrorCode getNumberOfElementsByNameAndPart(MPI_Comm comm, const std::string name, PetscLayout *layout) const
Get number of finite elements by name on processors.
PetscErrorCode DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank, int up_rank)
Executes FEMethod for finite elements in DM.
boost::shared_ptr< std::map< std::string, std::pair< EntityType, EntityType > > > mapTypeCol
PetscErrorCode SnesRhs(SNES snes, Vec x, Vec f, void *ctx)
This is MoFEM implementation for the right hand side (residual vector) evaluation in SNES solver.
virtual MoFEMErrorCode problem_basic_method_postProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethodThis function set data about problem, adjacencies and other multi-indices in ...
PetscErrorCode DMMoFEMSetKspCtx(DM dm, boost::shared_ptr< MoFEM::KspCtx > &ksp_ctx)
set MoFEM::KspCtx data structure
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Data structure to exchange data between mofem and User Loop Methods.It allows to exchange data betwee...
Matrix manager is used to build and partition problems.
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
virtual MoFEMErrorCode modify_problem_mask_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set dof mask ref level for problem
PetscErrorCode TsSetIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx)
Set function evaluating jacobina in TS solver.
DEPRECATED MoFEMErrorCode loop_finite_elements(const Problem *problem_ptr, const std::string &fe_name, FEMethod &method, int lower_rank, int upper_rank, MoFEMTypes bh, int verb=DEFAULT_VERBOSITY)
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVectorsets the routine to create a local vector associated with the shell DM.
PetscErrorCode DMMoFEMSetSnesCtx(DM dm, boost::shared_ptr< MoFEM::SnesCtx > &snes_ctx)
Set MoFEM::SnesCtx data structure.