6 #if PETSC_VERSION_GE(3, 6, 0)
7 #include <petsc/private/dmimpl.h>
10 #include <petsc-private/dmimpl.h>
11 #include <petsc-private/vecimpl.h>
19 : mField_ptr(PETSC_NULL), isProblemBuild(PETSC_FALSE),
20 isPartitioned(PETSC_FALSE), isSquareMatrix(PETSC_TRUE),
21 isSubDM(PETSC_FALSE), isCompDM(PETSC_FALSE), destroyProblem(PETSC_FALSE),
22 verbosity(
VERBOSE), referenceNumber(0) {
25 auto core_log = logging::core::get();
43 *iface =
const_cast<DMCtx *
>(
this);
54 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
70 CHKERR DMSetMatType(dm, MATMPIAIJ);
76 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
78 dm->data =
new DMCtx();
84 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
85 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
89 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
92 MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
93 if (result == MPI_IDENT)
95 <<
"MoFEM DM destroy for problem " << dm_field->
problemName
99 <<
"MoFEM DM destroy for problem " << dm_field->
problemName
110 delete static_cast<DMCtx *
>(dm->data);
119 const char problem_name[],
124 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
127 "data structure for MoFEM not yet created");
131 "DM function not implemented into MoFEM");
149 boost::shared_ptr<KspCtx>(
new KspCtx(*m_field_ptr, problem_name));
151 boost::shared_ptr<SnesCtx>(
new SnesCtx(*m_field_ptr, problem_name));
153 boost::shared_ptr<TsCtx>(
new TsCtx(*m_field_ptr, problem_name));
156 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
158 MPI_Comm_compare(comm, m_field_ptr->
get_comm(), &result);
159 if (result > MPI_CONGRUENT) {
161 "MoFEM and DM using different communicators");
163 MPI_Comm_size(comm, &dm_field->
sIze);
164 MPI_Comm_rank(comm, &dm_field->
rAnk);
170 MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
171 if (result == MPI_IDENT) {
173 <<
"MoFEM DM created for problem " << dm_field->
problemName;
177 <<
"MoFEM DM created for problem " << dm_field->
problemName;
189 "data structure for MoFEM not yet created");
192 delete static_cast<DMCtx *
>(dm_duplicate->data);
194 dm_duplicate->data = dm->data;
195 ++(
static_cast<DMCtx *
>(dm_duplicate->data)->referenceNumber);
204 "data structure for MoFEM not yet created on dm");
207 "data structure for MoFEM not yet created on swap dm");
209 auto *dm_field =
static_cast<DMCtx *
>(dm->data);
210 auto *dm_field_swap =
static_cast<DMCtx *
>(dm_swap->data);
212 auto tmp_field = dm_field;
213 dm_field = dm_field_swap;
214 dm_field_swap = tmp_field;
224 "data structure for MoFEM not yet created");
226 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
233 subdm_field->
isSubDM = PETSC_TRUE;
243 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
245 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
248 "data structure for MoFEM not yet created");
263 boost::shared_ptr<Range> r_ptr) {
264 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
266 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
269 "data structure for MoFEM not yet created");
280 boost::shared_ptr<Range> r_ptr) {
285 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
287 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
290 "data structure for MoFEM not yet created");
305 boost::shared_ptr<Range> r_ptr) {
306 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
308 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
311 "data structure for MoFEM not yet created");
322 boost::shared_ptr<Range> r_ptr) {
328 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
330 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
331 *is_sub_dm = dm_field->
isSubDM;
337 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
339 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
340 if (dm_field->
isSubDM != PETSC_TRUE) {
342 "This DM is not created as a SubDM");
347 boost::shared_ptr<Problem::SubProblemData> sub_data =
349 CHKERR sub_data->getRowIs(is);
355 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
357 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
358 if (dm_field->
isSubDM != PETSC_TRUE) {
360 "This DM is not created as a SubDM");
365 boost::shared_ptr<Problem::SubProblemData> sub_data =
367 CHKERR sub_data->getColIs(is);
372 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
374 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
377 "data structure for MoFEM not yet created");
390 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
392 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
395 "data structure for MoFEM not yet created");
402 "No need to add problem on column when problem block structurally "
411 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
413 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
419 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
421 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
424 "data structure for MoFEM not yet created");
431 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
433 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
436 "data structure for MoFEM not yet created");
444 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
446 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
453 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
455 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
461 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
463 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
469 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
471 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
473 ->resolveSharedFiniteElements(dm_field->
problemPtr, fe_name);
478 PetscLayout *layout) {
480 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
482 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
485 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
494 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
496 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
502 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
504 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
512 for (
auto fe : fe_name) {
519 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
521 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
528 ScatterMode scatter_mode) {
530 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
532 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
540 ScatterMode scatter_mode) {
541 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
543 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
551 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
553 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
561 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
563 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
575 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
577 dm_field->
problemPtr, fe_name, *method, low_rank, up_rank,
nullptr,
584 DM dm,
const std::string fe_name, boost::shared_ptr<MoFEM::FEMethod> method,
587 low_rank, up_rank, cache_ptr);
593 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
595 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
597 dm, fe_name, method, dm_field->
rAnk, dm_field->
rAnk, cache_ptr);
604 boost::shared_ptr<MoFEM::FEMethod> method,
611 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
613 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
616 *method, dm_field->
rAnk, dm_field->
rAnk);
621 template <
class S,
class T0,
class T1,
class T2>
623 T1 pre_only, T2 post_only) {
624 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
626 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
628 dm_field->
kspCtx->getPreProcComputeRhs().push_back(pre_only);
631 dm_field->
kspCtx->getComputeRhs().push_back(
635 dm_field->
kspCtx->getPostProcComputeRhs().push_back(post_only);
647 dm, fe_name, method, pre_only, post_only);
652 boost::shared_ptr<MoFEM::FEMethod> method,
653 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
654 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
656 boost::shared_ptr<MoFEM::FEMethod>,
657 boost::shared_ptr<MoFEM::BasicMethod>,
658 boost::shared_ptr<MoFEM::BasicMethod>>(
659 dm, fe_name, method, pre_only, post_only);
662 template <
class S,
class T0,
class T1,
class T2>
664 T1 pre_only, T2 post_only) {
665 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
667 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
669 dm_field->
kspCtx->getPreProcSetOperators().push_back(pre_only);
672 dm_field->
kspCtx->getSetOperators().push_back(
676 dm_field->
kspCtx->getPostProcSetOperators().push_back(post_only);
689 dm, fe_name, method, pre_only, post_only);
694 boost::shared_ptr<MoFEM::FEMethod> method,
695 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
696 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
698 boost::shared_ptr<MoFEM::FEMethod>>(
699 dm, fe_name, method, pre_only, post_only);
702 template <
class S,
class T0,
class T1,
class T2>
704 T1 pre_only, T2 post_only) {
705 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
707 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
709 dm_field->
snesCtx->getPreProcComputeRhs().push_back(pre_only);
712 dm_field->
snesCtx->getComputeRhs().push_back(
716 dm_field->
snesCtx->getPostProcComputeRhs().push_back(post_only);
728 dm, fe_name, method, pre_only, post_only);
733 boost::shared_ptr<MoFEM::FEMethod> method,
734 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
735 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
737 boost::shared_ptr<MoFEM::FEMethod>,
738 boost::shared_ptr<MoFEM::BasicMethod>,
739 boost::shared_ptr<MoFEM::BasicMethod>>(
740 dm, fe_name, method, pre_only, post_only);
743 template <
class S,
class T0,
class T1,
class T2>
745 T1 pre_only, T2 post_only) {
746 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
748 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
750 dm_field->
snesCtx->getPreProcSetOperators().push_back(pre_only);
753 dm_field->
snesCtx->getSetOperators().push_back(
757 dm_field->
snesCtx->getPostProcSetOperators().push_back(post_only);
769 dm, fe_name, method, pre_only, post_only);
774 boost::shared_ptr<MoFEM::FEMethod> method,
775 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
776 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
778 boost::shared_ptr<MoFEM::FEMethod>,
779 boost::shared_ptr<MoFEM::BasicMethod>,
780 boost::shared_ptr<MoFEM::BasicMethod>>(
781 dm, fe_name, method, pre_only, post_only);
784 template <
class S,
class T0,
class T1,
class T2>
786 T1 pre_only, T2 post_only) {
787 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
789 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
791 dm_field->
tsCtx->getPreProcessIFunction().push_back(pre_only);
794 dm_field->
tsCtx->getLoopsIFunction().push_back(
798 dm_field->
tsCtx->getPostProcessIFunction().push_back(post_only);
810 dm, fe_name, method, pre_only, post_only);
816 boost::shared_ptr<MoFEM::FEMethod> method,
817 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
818 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
820 boost::shared_ptr<MoFEM::FEMethod>,
821 boost::shared_ptr<MoFEM::BasicMethod>,
822 boost::shared_ptr<MoFEM::BasicMethod>>(
823 dm, fe_name, method, pre_only, post_only);
827 template <
class S,
class T0,
class T1,
class T2>
829 T1 pre_only, T2 post_only) {
830 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
832 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
834 dm_field->
tsCtx->getPreProcessIJacobian().push_back(pre_only);
837 dm_field->
tsCtx->getLoopsIJacobian().push_back(
841 dm_field->
tsCtx->getPostProcessIJacobian().push_back(post_only);
853 pre_only, post_only);
858 boost::shared_ptr<MoFEM::FEMethod> method,
859 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
860 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
862 boost::shared_ptr<MoFEM::FEMethod>,
863 boost::shared_ptr<MoFEM::BasicMethod>,
864 boost::shared_ptr<MoFEM::BasicMethod>>(
865 dm, fe_name, method, pre_only, post_only);
868 template <
class S,
class T0,
class T1,
class T2>
870 T1 pre_only, T2 post_only) {
871 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
873 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
875 dm_field->
tsCtx->getPreProcessRHSFunction().push_back(pre_only);
877 dm_field->
tsCtx->getLoopsRHSFunction().push_back(
880 dm_field->
tsCtx->getPostProcessRHSFunction().push_back(post_only);
887 boost::shared_ptr<MoFEM::FEMethod> method,
888 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
889 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
891 boost::shared_ptr<MoFEM::FEMethod>,
892 boost::shared_ptr<MoFEM::BasicMethod>,
893 boost::shared_ptr<MoFEM::BasicMethod>>(
894 dm, fe_name, method, pre_only, post_only);
904 dm, fe_name, method, pre_only, post_only);
908 template <
class S,
class T0,
class T1,
class T2>
910 T1 pre_only, T2 post_only) {
911 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
913 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
915 dm_field->
tsCtx->getPreProcessRHSFunction().push_back(pre_only);
917 dm_field->
tsCtx->getLoopsRHSFunction().push_back(
920 dm_field->
tsCtx->getPostProcessRHSFunction().push_back(post_only);
927 boost::shared_ptr<MoFEM::FEMethod> method,
928 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
929 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
931 boost::shared_ptr<MoFEM::FEMethod>,
932 boost::shared_ptr<MoFEM::BasicMethod>,
933 boost::shared_ptr<MoFEM::BasicMethod>>(
934 dm, fe_name, method, pre_only, post_only);
944 dm, fe_name, method, pre_only, post_only);
948 template <
class S,
class T0,
class T1,
class T2>
950 T1 pre_only, T2 post_only) {
951 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
953 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
955 dm_field->
tsCtx->getPreProcessIFunction().push_back(pre_only);
958 dm_field->
tsCtx->getLoopsIFunction().push_back(
962 dm_field->
tsCtx->getPostProcessIFunction().push_back(post_only);
974 dm, fe_name, method, pre_only, post_only);
980 boost::shared_ptr<MoFEM::FEMethod> method,
981 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
982 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
984 boost::shared_ptr<MoFEM::FEMethod>,
985 boost::shared_ptr<MoFEM::BasicMethod>,
986 boost::shared_ptr<MoFEM::BasicMethod>>(
987 dm, fe_name, method, pre_only, post_only);
991 template <
class S,
class T0,
class T1,
class T2>
993 T1 pre_only, T2 post_only) {
994 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
996 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
998 dm_field->
tsCtx->getPreProcessIJacobian().push_back(pre_only);
1001 dm_field->
tsCtx->getLoopsIJacobian().push_back(
1005 dm_field->
tsCtx->getPostProcessIJacobian().push_back(post_only);
1017 pre_only, post_only);
1022 boost::shared_ptr<MoFEM::FEMethod> method,
1023 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
1024 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
1026 boost::shared_ptr<MoFEM::FEMethod>,
1027 boost::shared_ptr<MoFEM::BasicMethod>,
1028 boost::shared_ptr<MoFEM::BasicMethod>>(
1029 dm, fe_name, method, pre_only, post_only);
1032 template <
class S,
class T0,
class T1,
class T2>
1034 T1 pre_only, T2 post_only) {
1035 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1037 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1039 dm_field->
tsCtx->getPreProcessMonitor().push_back(pre_only);
1041 dm_field->
tsCtx->getLoopsMonitor().push_back(
1044 dm_field->
tsCtx->getPostProcessMonitor().push_back(post_only);
1055 dm, ts, fe_name, method, pre_only, post_only);
1061 boost::shared_ptr<MoFEM::FEMethod> method,
1062 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
1063 boost::shared_ptr<MoFEM::BasicMethod> post_only) {
1065 boost::shared_ptr<MoFEM::FEMethod>,
1066 boost::shared_ptr<MoFEM::BasicMethod>,
1067 boost::shared_ptr<MoFEM::BasicMethod>>(
1068 dm, ts, fe_name, method, pre_only, post_only);
1073 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1075 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1076 *ksp_ctx = dm_field->
kspCtx.get();
1082 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1084 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1085 const_cast<boost::shared_ptr<MoFEM::KspCtx> &
>(ksp_ctx) = dm_field->
kspCtx;
1090 boost::shared_ptr<MoFEM::KspCtx> ksp_ctx) {
1091 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1093 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1094 dm_field->
kspCtx = ksp_ctx;
1099 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1102 *snes_ctx = dm_field->
snesCtx.get();
1108 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1110 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1111 const_cast<boost::shared_ptr<MoFEM::SnesCtx> &
>(snes_ctx) = dm_field->
snesCtx;
1116 boost::shared_ptr<MoFEM::SnesCtx> snes_ctx) {
1117 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1119 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1128 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1130 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1139 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1141 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1147 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1149 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1155 const boost::shared_ptr<MoFEM::TsCtx> &
ts_ctx) {
1156 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1158 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1159 const_cast<boost::shared_ptr<MoFEM::TsCtx> &
>(
ts_ctx) = dm_field->
tsCtx;
1164 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1166 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1172 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1174 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1182 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1184 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1187 CHKERR VecSetDM(g_ptr, dm);
1192 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1194 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1202 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1204 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1205 if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1207 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->
problemName,
1209 }
else if (strcmp(dm->mattype, MATAIJ) == 0) {
1211 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->
problemName,
1213 }
else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1215 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1217 }
else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1219 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1223 "Matrix type not implemented");
1230 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1232 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1233 if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1235 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->
problemName,
1237 }
else if (strcmp(dm->mattype, MATAIJ) == 0) {
1239 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->
problemName,
1241 }
else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1243 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1245 }
else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1247 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1251 "Matrix type not implemented");
1257 #if PETSC_VERSION_GE(3, 7, 0)
1260 #elif PETSC_VERSION_GE(3, 5, 3)
1266 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1268 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1269 #if PETSC_VERSION_GE(3, 5, 3)
1270 ierr = PetscOptionsHead(PetscOptionsObject,
"DMMoFEM Options");
1273 ierr = PetscOptionsHead(
"DMMoFEM Options");
1276 ierr = PetscOptionsBool(
"-dm_is_partitioned",
1277 "set if mesh is partitioned (works which native MOAB "
1278 "file format, i.e. h5m",
1286 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1289 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1333 PetscValidHeaderSpecific(subdm, DM_CLASSID, 1);
1337 DMCtx *subdm_field =
static_cast<DMCtx *
>(subdm->data);
1342 map<std::string, boost::shared_ptr<Range>> *entity_map_row =
nullptr;
1343 map<std::string, boost::shared_ptr<Range>> *entity_map_col =
nullptr;
1353 subdm_field->
isSquareMatrix == PETSC_TRUE, entity_map_row, entity_map_col,
1360 0, subdm_field->
sIze,
1381 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1383 CHKERR VecGhostUpdateBegin(
g, INSERT_VALUES, SCATTER_FORWARD);
1389 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1392 CHKERR VecGhostUpdateEnd(
g, INSERT_VALUES, SCATTER_FORWARD);
1394 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1398 double *array_loc, *array_glob;
1399 CHKERR VecGetArray(
l, &array_loc);
1400 CHKERR VecGetArray(
g, &array_glob);
1403 cblas_dcopy(nb_dofs + nb_ghost, array_glob, 1, array_loc, 1);
1406 cblas_daxpy(nb_dofs + nb_ghost, 1, array_glob, 1, array_loc, 1);
1411 CHKERR VecRestoreArray(
l, &array_loc);
1412 CHKERR VecRestoreArray(
g, &array_glob);
1419 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1422 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1426 double *array_loc, *array_glob;
1427 CHKERR VecGetArray(
l, &array_loc);
1428 CHKERR VecGetArray(
g, &array_glob);
1431 cblas_dcopy(nb_dofs + nb_ghost, array_loc, 1, array_glob, 1);
1434 cblas_daxpy(nb_dofs + nb_ghost, 1, array_loc, 1, array_glob, 1);
1439 CHKERR VecRestoreArray(
l, &array_loc);
1440 CHKERR VecRestoreArray(
g, &array_glob);
1452 char ***fieldNames, IS **fields) {
1453 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1466 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1468 Field_multiIndex::iterator fit, hi_fit;
1469 fit = fields_ptr->begin();
1470 hi_fit = fields_ptr->end();
1471 *numFields = std::distance(fit, hi_fit);
1474 CHKERR PetscMalloc1(*numFields, fieldNames);
1477 CHKERR PetscMalloc1(*numFields, fields);
1480 for (
int f = 0; fit != hi_fit; fit++,
f++) {
1482 CHKERR PetscStrallocpy(fit->get()->getName().c_str(),
1483 (
char **)&(*fieldNames)[
f]);
1487 ->isCreateProblemFieldAndRank(
1489 fit->get()->getNbOfCoeffs(), &(*fields)[
f]);
1498 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1500 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);
1508 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1510 DMCtx *dm_field =
static_cast<DMCtx *
>(dm->data);