v0.14.0
DMMoFEM.cpp
Go to the documentation of this file.
1 
2 
3 // #undef PETSC_VERSION_RELEASE
4 // #define PETSC_VERSION_RELEASE 1
5 
6 #if PETSC_VERSION_GE(3, 6, 0)
7 #include <petsc/private/dmimpl.h> /*I "petscdm.h" I*/
8 // #include <petsc/private/vecimpl.h> /*I "petscdm.h" I*/
9 #else
10 #include <petsc-private/dmimpl.h> /*I "petscdm.h" I*/
11 #include <petsc-private/vecimpl.h> /*I "petscdm.h" I*/
12 #endif
13 
14 #include <DMMoFEM.hpp>
15 #include <DMCtxImpl.hpp>
16 
17 namespace MoFEM {
18 
19 MoFEMErrorCode DMCtx::query_interface(boost::typeindex::type_index type_index,
20  UnknownInterface **iface) const {
21  *iface = const_cast<DMCtx *>(this);
22  return 0;
23 }
24 
26  if (!LogManager::checkIfChannelExist("DMWORLD")) {
27  auto core_log = logging::core::get();
28  core_log->add_sink(
30  core_log->add_sink(
32  core_log->add_sink(
34  LogManager::setLog("DMWORLD");
35  LogManager::setLog("DMSYNC");
36  LogManager::setLog("DMSELF");
37  MOFEM_LOG_TAG("DMWORLD", "DM");
38  MOFEM_LOG_TAG("DMSYNC", "DM");
39  MOFEM_LOG_TAG("DMSELF", "DM");
40  }
41 }
42 
43 PetscErrorCode DMRegister_MoFEM(const char sname[]) {
45  CHKERR DMRegister(sname, DMCreate_MoFEM);
47 }
48 
49 PetscErrorCode DMSetOperators_MoFEM(DM dm) {
50  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
52 
53  dm->ops->createglobalvector = DMCreateGlobalVector_MoFEM;
54  dm->ops->createlocalvector = DMCreateLocalVector_MoFEM;
55  dm->ops->creatematrix = DMCreateMatrix_MoFEM;
56  dm->ops->setup = DMSetUp_MoFEM;
57  dm->ops->destroy = DMDestroy_MoFEM;
58  dm->ops->setfromoptions = DMSetFromOptions_MoFEM;
59  dm->ops->globaltolocalbegin = DMGlobalToLocalBegin_MoFEM;
60  dm->ops->globaltolocalend = DMGlobalToLocalEnd_MoFEM;
61  dm->ops->localtoglobalbegin = DMLocalToGlobalBegin_MoFEM;
62  dm->ops->localtoglobalend = DMLocalToGlobalEnd_MoFEM;
63  dm->ops->createfieldis = DMCreateFieldIS_MoFEM;
64 
65  // Default matrix type
66  CHKERR DMSetMatType(dm, MATMPIAIJ);
67 
69 }
70 
71 PetscErrorCode DMCreate_MoFEM(DM dm) {
72  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
74  dm->data = new DMCtxImpl();
77 }
78 
79 PetscErrorCode DMDestroy_MoFEM(DM dm) {
80  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
81  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
83 
84  MPI_Comm comm;
85  CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
86 
87  int result;
88  MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
89  if (result == MPI_IDENT)
90  MOFEM_LOG("DMSELF", Sev::noisy)
91  << "MoFEM DM destroy for problem " << dm_field->problemName
92  << " referenceNumber " << dm_field->referenceNumber;
93  else
94  MOFEM_LOG("DMWORLD", Sev::noisy)
95  << "MoFEM DM destroy for problem " << dm_field->problemName
96  << " referenceNumber " << dm_field->referenceNumber;
97 
98  if (dm_field->referenceNumber == 0) {
99  if (dm_field->destroyProblem) {
100 
101  if (dm_field->mField_ptr->check_problem(dm_field->problemName)) {
102  dm_field->mField_ptr->delete_problem(dm_field->problemName);
103  } // else problem has to be deleted by the user
104  }
105 
106  delete static_cast<DMCtxImpl *>(dm->data);
107 
108  } else
109  --dm_field->referenceNumber;
110 
112 }
113 
114 PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr,
115  const char problem_name[],
116  const MoFEM::BitRefLevel bit_level,
117  const MoFEM::BitRefLevel bit_mask) {
119 
120  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
121  if (!dm->data) {
122  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
123  "data structure for MoFEM not yet created");
124  }
125  if (!m_field_ptr) {
126  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
127  "DM function not implemented into MoFEM");
128  }
129  dm_field->mField_ptr = m_field_ptr;
130  dm_field->problemName = problem_name;
131  if (!m_field_ptr->check_problem(dm_field->problemName)) {
132  // problem is not defined, declare problem internally set bool to
133  // destroyProblem problem with DM
134  dm_field->destroyProblem = PETSC_TRUE;
135  CHKERR dm_field->mField_ptr->add_problem(dm_field->problemName, MF_EXCL,
136  dm_field->verbosity);
137  } else {
138  dm_field->destroyProblem = PETSC_FALSE;
139  }
141  dm_field->problemName, bit_level);
143  dm_field->problemName, bit_mask);
144  dm_field->kspCtx =
145  boost::shared_ptr<KspCtx>(new KspCtx(*m_field_ptr, problem_name));
146  dm_field->snesCtx =
147  boost::shared_ptr<SnesCtx>(new SnesCtx(*m_field_ptr, problem_name));
148  dm_field->tsCtx =
149  boost::shared_ptr<TsCtx>(new TsCtx(*m_field_ptr, problem_name));
150 
151  MPI_Comm comm;
152  CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
153  int result = 0;
154  MPI_Comm_compare(comm, m_field_ptr->get_comm(), &result);
155  if (result > MPI_CONGRUENT) {
156  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
157  "MoFEM and DM using different communicators");
158  }
159  MPI_Comm_size(comm, &dm_field->sIze);
160  MPI_Comm_rank(comm, &dm_field->rAnk);
161 
162  // problem structure
163  CHKERR dm_field->mField_ptr->get_problem(dm_field->problemName,
164  &dm_field->problemPtr);
165 
166  MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
167  if (result == MPI_IDENT) {
168  MOFEM_LOG("DMSELF", Sev::noisy)
169  << "MoFEM DM created for problem " << dm_field->problemName;
170  MOFEM_LOG("DMSELF", Sev::noisy) << *dm_field->problemPtr;
171  } else {
172  MOFEM_LOG("DMWORLD", Sev::noisy)
173  << "MoFEM DM created for problem " << dm_field->problemName;
174  MOFEM_LOG("DMWORLD", Sev::noisy) << *dm_field->problemPtr;
175  }
176 
178 }
179 
180 PetscErrorCode DMMoFEMDuplicateDMCtx(DM dm, DM dm_duplicate) {
182 
183  if (!dm->data)
184  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
185  "data structure for MoFEM not yet created");
186 
187  if (static_cast<DMCtxImpl *>(dm_duplicate->data)->referenceNumber == 0)
188  delete static_cast<DMCtxImpl *>(dm_duplicate->data);
189 
190  dm_duplicate->data = dm->data;
191  ++(static_cast<DMCtxImpl *>(dm_duplicate->data)->referenceNumber);
192 
194 }
195 
196 PetscErrorCode DMMoFEMSwapDMCtx(DM dm, DM dm_swap) {
198  if (!dm->data)
199  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
200  "data structure for MoFEM not yet created on dm");
201  if (!dm_swap->data)
202  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
203  "data structure for MoFEM not yet created on swap dm");
204 
205  auto *dm_field = static_cast<DMCtxImpl *>(dm->data);
206  auto *dm_field_swap = static_cast<DMCtxImpl *>(dm_swap->data);
207 
208  auto tmp_field = dm_field;
209  dm_field = dm_field_swap;
210  dm_field_swap = tmp_field;
211 
213 }
214 
215 PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[]) {
217 
218  if (!dm->data) {
219  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
220  "data structure for MoFEM not yet created");
221  }
222  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
223 
224  CHKERR DMMoFEMCreateMoFEM(subdm, dm_field->mField_ptr, problem_name,
225  dm_field->problemPtr->getBitRefLevel(),
226  dm_field->problemPtr->getBitRefLevelMask());
227 
228  DMCtxImpl *subdm_field = (DMCtxImpl *)subdm->data;
229  subdm_field->isSubDM = PETSC_TRUE;
230  subdm_field->problemMainOfSubPtr = dm_field->problemPtr;
231  subdm_field->isPartitioned = dm_field->isPartitioned;
232  subdm_field->isSquareMatrix = PETSC_FALSE;
233  subdm->ops->setup = DMSubDMSetUp_MoFEM;
234 
236 }
237 
238 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[]) {
239  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
241  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
242  if (!dm->data) {
243  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
244  "data structure for MoFEM not yet created");
245  }
246  if (!dm_field->isSubDM) {
247  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
248  }
249  dm_field->rowSubFields.push_back(field_name);
250  dm_field->mapTypeRow.erase(field_name);
252 }
253 
254 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name) {
255  return DMMoFEMAddSubFieldRow(dm, field_name.c_str());
256 }
257 
258 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[],
259  boost::shared_ptr<Range> r_ptr) {
260  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
262  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
263  if (!dm->data) {
264  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
265  "data structure for MoFEM not yet created");
266  }
267  if (!dm_field->isSubDM) {
268  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
269  }
270  dm_field->rowSubFields.push_back(field_name);
271  dm_field->mapTypeRow[field_name] = r_ptr;
273 }
274 
275 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name,
276  boost::shared_ptr<Range> r_ptr) {
277  return DMMoFEMAddSubFieldRow(dm, field_name.c_str(), r_ptr);
278 }
279 
280 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[]) {
281  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
283  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
284  if (!dm->data) {
285  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
286  "data structure for MoFEM not yet created");
287  }
288  if (!dm_field->isSubDM) {
289  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
290  }
291  dm_field->colSubFields.push_back(field_name);
292  dm_field->mapTypeCol.erase(field_name);
294 }
295 
296 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name) {
297  return DMMoFEMAddSubFieldCol(dm, field_name.c_str());
298 }
299 
300 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[],
301  boost::shared_ptr<Range> r_ptr) {
302  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
304  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
305  if (!dm->data) {
306  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
307  "data structure for MoFEM not yet created");
308  }
309  if (!dm_field->isSubDM) {
310  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
311  }
312  dm_field->colSubFields.push_back(field_name);
313  dm_field->mapTypeCol[field_name] = r_ptr;
315 }
316 
317 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name,
318  boost::shared_ptr<Range> r_ptr) {
319  return DMMoFEMAddSubFieldCol(dm, field_name.c_str(), r_ptr);
320 }
321 
322 PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm) {
324  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
326  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
327  *is_sub_dm = dm_field->isSubDM;
329 }
330 
331 PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is) {
333  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
335  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
336  if (dm_field->isSubDM != PETSC_TRUE) {
337  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
338  "This DM is not created as a SubDM");
339  }
340  if (dm_field->isProblemBuild != PETSC_TRUE) {
341  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Problem is not build");
342  }
343  boost::shared_ptr<Problem::SubProblemData> sub_data =
344  dm_field->problemPtr->getSubData();
345  CHKERR sub_data->getRowIs(is);
347 }
348 
349 PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is) {
351  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
353  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
354  if (dm_field->isSubDM != PETSC_TRUE) {
355  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
356  "This DM is not created as a SubDM");
357  }
358  if (dm_field->isProblemBuild != PETSC_TRUE) {
359  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Problem is not build");
360  }
361  boost::shared_ptr<Problem::SubProblemData> sub_data =
362  dm_field->problemPtr->getSubData();
363  CHKERR sub_data->getColIs(is);
365 }
366 
367 PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[]) {
368  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
370  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
371  if (!dm->data) {
372  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
373  "data structure for MoFEM not yet created");
374  }
375  if (!dm_field->isCompDM) {
376  dm_field->isCompDM = PETSC_TRUE;
377  }
378  dm_field->rowCompPrb.push_back(prb_name);
379  if (dm_field->isSquareMatrix) {
380  dm_field->colCompPrb.push_back(prb_name);
381  }
383 }
384 
385 PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[]) {
386  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
388  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
389  if (!dm->data) {
390  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
391  "data structure for MoFEM not yet created");
392  }
393  if (!dm_field->isCompDM) {
394  dm_field->isCompDM = PETSC_TRUE;
395  }
396  if (dm_field->isSquareMatrix) {
397  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
398  "No need to add problem on column when problem block structurally "
399  "symmetric");
400  }
401  dm_field->colCompPrb.push_back(prb_name);
403 }
404 
405 PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm) {
407  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
409  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
410  *is_comp_dm = dm_field->isCompDM;
412 }
413 
414 PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr) {
415  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
417  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
418  if (!dm->data) {
419  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
420  "data structure for MoFEM not yet created");
421  }
422  *m_field_ptr = dm_field->mField_ptr;
424 }
425 
426 PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr) {
427  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
429  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
430  if (!dm->data) {
431  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
432  "data structure for MoFEM not yet created");
433  }
434  *problem_ptr = dm_field->problemPtr;
436 }
437 
438 PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem) {
440  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
442  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
443  dm_field->destroyProblem = destroy_problem;
445 }
446 
447 PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem) {
449  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
451  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
452  *destroy_problem = dm_field->destroyProblem;
454 }
455 
456 PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem) {
457  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
459  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
460  dm_field->isSquareMatrix = square_problem;
462 }
463 
464 PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name) {
465  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
467  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
469  ->resolveSharedFiniteElements(dm_field->problemPtr, fe_name);
471 }
472 
473 PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name,
474  PetscLayout *layout) {
476  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
478  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
479 
480  MPI_Comm comm;
481  CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
482  CHKERR dm_field->problemPtr->getNumberOfElementsByNameAndPart(comm, fe_name,
483  layout);
485 }
486 
487 PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem) {
490  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
492  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
493  *square_problem = dm_field->isSquareMatrix;
495 }
496 
497 PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name) {
498  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
500  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
502  dm_field->problemName, fe_name);
504 }
505 
506 PetscErrorCode DMMoFEMAddElement(DM dm, std::vector<std::string> fe_name) {
508  for (auto fe : fe_name) {
509  CHKERR DMMoFEMAddElement(dm, fe);
510  }
512 }
513 
514 PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name) {
515  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
517  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
519  dm_field->problemName, fe_name);
521 }
522 
523 PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode,
524  ScatterMode scatter_mode) {
526  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
528  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
529  ierr = dm_field->mField_ptr->getInterface<VecManager>()->setLocalGhostVector(
530  dm_field->problemPtr, COL, l, mode, scatter_mode);
531  CHKERRG(ierr);
533 }
534 
535 PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode,
536  ScatterMode scatter_mode) {
537  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
539  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
540  ierr = dm_field->mField_ptr->getInterface<VecManager>()->setGlobalGhostVector(
541  dm_field->problemPtr, COL, g, mode, scatter_mode);
542  CHKERRG(ierr);
544 }
545 
546 PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method) {
547  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
549  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
551  dm_field->problemPtr, *method);
552  CHKERRG(ierr);
554 }
555 
556 PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method) {
557  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
559  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
561  dm_field->problemPtr, *method);
562  CHKERRG(ierr);
564 }
565 
566 PetscErrorCode
567 DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[],
568  MoFEM::FEMethod *method, int low_rank,
569  int up_rank, CacheTupleWeakPtr cache_ptr) {
571  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
572  ierr = dm_field->mField_ptr->loop_finite_elements(
573  dm_field->problemPtr, fe_name, *method, low_rank, up_rank, nullptr,
574  MF_EXIST, cache_ptr);
575  CHKERRG(ierr);
577 }
578 
580  DM dm, const std::string fe_name, boost::shared_ptr<MoFEM::FEMethod> method,
581  int low_rank, int up_rank, CacheTupleWeakPtr cache_ptr) {
582  return DMoFEMLoopFiniteElementsUpAndLowRank(dm, fe_name.c_str(), method.get(),
583  low_rank, up_rank, cache_ptr);
584 }
585 
586 PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[],
587  MoFEM::FEMethod *method,
588  CacheTupleWeakPtr cache_ptr) {
589  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
591  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
593  dm, fe_name, method, dm_field->rAnk, dm_field->rAnk, cache_ptr);
594  CHKERRG(ierr);
596 }
597 
598 PetscErrorCode
599 DMoFEMLoopFiniteElements(DM dm, const std::string fe_name,
600  boost::shared_ptr<MoFEM::FEMethod> method,
601  CacheTupleWeakPtr cache_ptr) {
602  return DMoFEMLoopFiniteElements(dm, fe_name.c_str(), method.get(), cache_ptr);
603 }
604 
605 PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[],
606  MoFEM::DofMethod *method) {
607  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
609  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
610  ierr =
611  dm_field->mField_ptr->loop_dofs(dm_field->problemPtr, field_name, COL,
612  *method, dm_field->rAnk, dm_field->rAnk);
613  CHKERRG(ierr);
615 }
616 
617 template <class S, class T0, class T1, class T2>
618 static PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, S fe_name, T0 method,
619  T1 pre_only, T2 post_only) {
620  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
622  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
623  if (pre_only) {
624  dm_field->kspCtx->getPreProcComputeRhs().push_back(pre_only);
625  }
626  if (method) {
627  dm_field->kspCtx->getComputeRhs().push_back(
628  PairNameFEMethodPtr(fe_name, method));
629  }
630  if (post_only) {
631  dm_field->kspCtx->getPostProcComputeRhs().push_back(post_only);
632  }
633  CHKERR DMKSPSetComputeRHS(dm, KspRhs, dm_field->kspCtx.get());
635 }
636 
637 PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[],
638  MoFEM::FEMethod *method,
639  MoFEM::BasicMethod *pre_only,
640  MoFEM::BasicMethod *post_only) {
641  return DMMoFEMKSPSetComputeRHS<const char *, MoFEM::FEMethod *,
643  dm, fe_name, method, pre_only, post_only);
644 }
645 
646 PetscErrorCode
647 DMMoFEMKSPSetComputeRHS(DM dm, const std::string fe_name,
648  boost::shared_ptr<MoFEM::FEMethod> method,
649  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
650  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
651  return DMMoFEMKSPSetComputeRHS<const std::string,
652  boost::shared_ptr<MoFEM::FEMethod>,
653  boost::shared_ptr<MoFEM::BasicMethod>,
654  boost::shared_ptr<MoFEM::BasicMethod>>(
655  dm, fe_name, method, pre_only, post_only);
656 }
657 
658 template <class S, class T0, class T1, class T2>
659 static PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, S fe_name, T0 method,
660  T1 pre_only, T2 post_only) {
661  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
663  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
664  if (pre_only) {
665  dm_field->kspCtx->getPreProcSetOperators().push_back(pre_only);
666  }
667  if (method) {
668  dm_field->kspCtx->getSetOperators().push_back(
669  PairNameFEMethodPtr(fe_name, method));
670  }
671  if (post_only) {
672  dm_field->kspCtx->getPostProcSetOperators().push_back(post_only);
673  }
674  CHKERR DMKSPSetComputeOperators(dm, KspMat, dm_field->kspCtx.get());
676 }
677 
678 PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[],
679  MoFEM::FEMethod *method,
680  MoFEM::BasicMethod *pre_only,
681  MoFEM::BasicMethod *post_only) {
682  return DMMoFEMKSPSetComputeOperators<const char *, MoFEM::FEMethod *,
685  dm, fe_name, method, pre_only, post_only);
686 }
687 
688 PetscErrorCode
689 DMMoFEMKSPSetComputeOperators(DM dm, const std::string fe_name,
690  boost::shared_ptr<MoFEM::FEMethod> method,
691  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
692  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
693  return DMMoFEMKSPSetComputeOperators<const std::string,
694  boost::shared_ptr<MoFEM::FEMethod>>(
695  dm, fe_name, method, pre_only, post_only);
696 }
697 
698 template <class S, class T0, class T1, class T2>
699 static PetscErrorCode DMMoFEMSNESSetFunction(DM dm, S fe_name, T0 method,
700  T1 pre_only, T2 post_only) {
701  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
703  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
704  if (pre_only) {
705  dm_field->snesCtx->getPreProcComputeRhs().push_back(pre_only);
706  }
707  if (method) {
708  dm_field->snesCtx->getComputeRhs().push_back(
709  PairNameFEMethodPtr(fe_name, method));
710  }
711  if (post_only) {
712  dm_field->snesCtx->getPostProcComputeRhs().push_back(post_only);
713  }
714  CHKERR DMSNESSetFunction(dm, SnesRhs, dm_field->snesCtx.get());
716 }
717 
718 PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[],
719  MoFEM::FEMethod *method,
720  MoFEM::BasicMethod *pre_only,
721  MoFEM::BasicMethod *post_only) {
722  return DMMoFEMSNESSetFunction<const char *, MoFEM::FEMethod *,
724  dm, fe_name, method, pre_only, post_only);
725 }
726 
727 PetscErrorCode
728 DMMoFEMSNESSetFunction(DM dm, const std::string fe_name,
729  boost::shared_ptr<MoFEM::FEMethod> method,
730  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
731  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
732  return DMMoFEMSNESSetFunction<const std::string,
733  boost::shared_ptr<MoFEM::FEMethod>,
734  boost::shared_ptr<MoFEM::BasicMethod>,
735  boost::shared_ptr<MoFEM::BasicMethod>>(
736  dm, fe_name, method, pre_only, post_only);
737 }
738 
739 template <class S, class T0, class T1, class T2>
740 static PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, S fe_name, T0 method,
741  T1 pre_only, T2 post_only) {
742  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
744  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
745  if (pre_only) {
746  dm_field->snesCtx->getPreProcSetOperators().push_back(pre_only);
747  }
748  if (method) {
749  dm_field->snesCtx->getSetOperators().push_back(
750  PairNameFEMethodPtr(fe_name, method));
751  }
752  if (post_only) {
753  dm_field->snesCtx->getPostProcSetOperators().push_back(post_only);
754  }
755  CHKERR DMSNESSetJacobian(dm, SnesMat, dm_field->snesCtx.get());
757 }
758 
759 PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[],
760  MoFEM::FEMethod *method,
761  MoFEM::BasicMethod *pre_only,
762  MoFEM::BasicMethod *post_only) {
763  return DMMoFEMSNESSetJacobian<const char *, MoFEM::FEMethod *,
765  dm, fe_name, method, pre_only, post_only);
766 }
767 
768 PetscErrorCode
769 DMMoFEMSNESSetJacobian(DM dm, const std::string fe_name,
770  boost::shared_ptr<MoFEM::FEMethod> method,
771  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
772  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
773  return DMMoFEMSNESSetJacobian<const std::string,
774  boost::shared_ptr<MoFEM::FEMethod>,
775  boost::shared_ptr<MoFEM::BasicMethod>,
776  boost::shared_ptr<MoFEM::BasicMethod>>(
777  dm, fe_name, method, pre_only, post_only);
778 }
779 
780 template <class S, class T0, class T1, class T2>
781 static PetscErrorCode DMMoFEMTSSetIFunction(DM dm, S fe_name, T0 method,
782  T1 pre_only, T2 post_only) {
783  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
785  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
786  if (pre_only) {
787  dm_field->tsCtx->getPreProcessIFunction().push_back(pre_only);
788  }
789  if (method) {
790  dm_field->tsCtx->getLoopsIFunction().push_back(
791  PairNameFEMethodPtr(fe_name, method));
792  }
793  if (post_only) {
794  dm_field->tsCtx->getPostProcessIFunction().push_back(post_only);
795  }
796  CHKERR DMTSSetIFunction(dm, TsSetIFunction, dm_field->tsCtx.get());
798 }
799 
800 PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[],
801  MoFEM::FEMethod *method,
802  MoFEM::BasicMethod *pre_only,
803  MoFEM::BasicMethod *post_only) {
804  return DMMoFEMTSSetIFunction<const char *, MoFEM::FEMethod *,
806  dm, fe_name, method, pre_only, post_only);
808 }
809 
810 PetscErrorCode
811 DMMoFEMTSSetIFunction(DM dm, const std::string fe_name,
812  boost::shared_ptr<MoFEM::FEMethod> method,
813  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
814  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
815  return DMMoFEMTSSetIFunction<const std::string,
816  boost::shared_ptr<MoFEM::FEMethod>,
817  boost::shared_ptr<MoFEM::BasicMethod>,
818  boost::shared_ptr<MoFEM::BasicMethod>>(
819  dm, fe_name, method, pre_only, post_only);
821 }
822 
823 template <class S, class T0, class T1, class T2>
824 static PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, S fe_name, T0 method,
825  T1 pre_only, T2 post_only) {
826  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
828  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
829  if (pre_only) {
830  dm_field->tsCtx->getPreProcessIJacobian().push_back(pre_only);
831  }
832  if (method) {
833  dm_field->tsCtx->getLoopsIJacobian().push_back(
834  PairNameFEMethodPtr(fe_name, method));
835  }
836  if (post_only) {
837  dm_field->tsCtx->getPostProcessIJacobian().push_back(post_only);
838  }
839  CHKERR DMTSSetIJacobian(dm, TsSetIJacobian, dm_field->tsCtx.get());
841 }
842 
843 PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, const char fe_name[],
844  MoFEM::FEMethod *method,
845  MoFEM::BasicMethod *pre_only,
846  MoFEM::BasicMethod *post_only) {
847  return DMMoFEMTSSetIJacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
848  MoFEM::BasicMethod *>(dm, fe_name, method,
849  pre_only, post_only);
850 }
851 
852 PetscErrorCode
853 DMMoFEMTSSetIJacobian(DM dm, const std::string fe_name,
854  boost::shared_ptr<MoFEM::FEMethod> method,
855  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
856  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
857  return DMMoFEMTSSetIJacobian<const std::string,
858  boost::shared_ptr<MoFEM::FEMethod>,
859  boost::shared_ptr<MoFEM::BasicMethod>,
860  boost::shared_ptr<MoFEM::BasicMethod>>(
861  dm, fe_name, method, pre_only, post_only);
862 }
863 
864 template <class S, class T0, class T1, class T2>
865 static PetscErrorCode DMMoFEMTSSetRHSFunction(DM dm, S fe_name, T0 method,
866  T1 pre_only, T2 post_only) {
867  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
869  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
870  if (pre_only)
871  dm_field->tsCtx->getPreProcessRHSFunction().push_back(pre_only);
872  if (method)
873  dm_field->tsCtx->getLoopsRHSFunction().push_back(
874  PairNameFEMethodPtr(fe_name, method));
875  if (post_only)
876  dm_field->tsCtx->getPostProcessRHSFunction().push_back(post_only);
877  CHKERR DMTSSetRHSFunction(dm, TsSetRHSFunction, dm_field->tsCtx.get());
879 }
880 
881 PetscErrorCode
882 DMMoFEMTSSetRHSFunction(DM dm, const std::string fe_name,
883  boost::shared_ptr<MoFEM::FEMethod> method,
884  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
885  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
886  return DMMoFEMTSSetRHSFunction<const std::string,
887  boost::shared_ptr<MoFEM::FEMethod>,
888  boost::shared_ptr<MoFEM::BasicMethod>,
889  boost::shared_ptr<MoFEM::BasicMethod>>(
890  dm, fe_name, method, pre_only, post_only);
892 }
893 
894 PetscErrorCode DMMoFEMTSSetRHSFunction(DM dm, const char fe_name[],
895  MoFEM::FEMethod *method,
896  MoFEM::BasicMethod *pre_only,
897  MoFEM::BasicMethod *post_only) {
898  return DMMoFEMTSSetRHSFunction<const char *, MoFEM::FEMethod *,
900  dm, fe_name, method, pre_only, post_only);
902 }
903 
904 template <class S, class T0, class T1, class T2>
905 static PetscErrorCode DMMoFEMTSSetRHSJacobian(DM dm, S fe_name, T0 method,
906  T1 pre_only, T2 post_only) {
907  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
909  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
910  if (pre_only)
911  dm_field->tsCtx->getPreProcessRHSFunction().push_back(pre_only);
912  if (method)
913  dm_field->tsCtx->getLoopsRHSFunction().push_back(
914  PairNameFEMethodPtr(fe_name, method));
915  if (post_only)
916  dm_field->tsCtx->getPostProcessRHSFunction().push_back(post_only);
917  CHKERR DMTSSetRHSJacobian(dm, TsSetRHSJacobian, dm_field->tsCtx.get());
919 }
920 
921 PetscErrorCode
922 DMMoFEMTSSetRHSJacobian(DM dm, const std::string fe_name,
923  boost::shared_ptr<MoFEM::FEMethod> method,
924  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
925  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
926  return DMMoFEMTSSetRHSJacobian<const std::string,
927  boost::shared_ptr<MoFEM::FEMethod>,
928  boost::shared_ptr<MoFEM::BasicMethod>,
929  boost::shared_ptr<MoFEM::BasicMethod>>(
930  dm, fe_name, method, pre_only, post_only);
932 }
933 
934 PetscErrorCode DMMoFEMTSSetRHSJacobian(DM dm, const char fe_name[],
935  MoFEM::FEMethod *method,
936  MoFEM::BasicMethod *pre_only,
937  MoFEM::BasicMethod *post_only) {
938  return DMMoFEMTSSetRHSJacobian<const char *, MoFEM::FEMethod *,
940  dm, fe_name, method, pre_only, post_only);
942 }
943 
944 template <class S, class T0, class T1, class T2>
945 static PetscErrorCode DMMoFEMTSSetI2Function(DM dm, S fe_name, T0 method,
946  T1 pre_only, T2 post_only) {
947  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
949  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
950  if (pre_only) {
951  dm_field->tsCtx->getPreProcessIFunction().push_back(pre_only);
952  }
953  if (method) {
954  dm_field->tsCtx->getLoopsIFunction().push_back(
955  PairNameFEMethodPtr(fe_name, method));
956  }
957  if (post_only) {
958  dm_field->tsCtx->getPostProcessIFunction().push_back(post_only);
959  }
960  CHKERR DMTSSetI2Function(dm, TsSetI2Function, dm_field->tsCtx.get());
962 }
963 
964 PetscErrorCode DMMoFEMTSSetI2Function(DM dm, const char fe_name[],
965  MoFEM::FEMethod *method,
966  MoFEM::BasicMethod *pre_only,
967  MoFEM::BasicMethod *post_only) {
968  return DMMoFEMTSSetI2Function<const char *, MoFEM::FEMethod *,
970  dm, fe_name, method, pre_only, post_only);
972 }
973 
974 PetscErrorCode
975 DMMoFEMTSSetI2Function(DM dm, const std::string fe_name,
976  boost::shared_ptr<MoFEM::FEMethod> method,
977  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
978  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
979  return DMMoFEMTSSetI2Function<const std::string,
980  boost::shared_ptr<MoFEM::FEMethod>,
981  boost::shared_ptr<MoFEM::BasicMethod>,
982  boost::shared_ptr<MoFEM::BasicMethod>>(
983  dm, fe_name, method, pre_only, post_only);
985 }
986 
987 template <class S, class T0, class T1, class T2>
988 static PetscErrorCode DMMoFEMTSSetI2Jacobian(DM dm, S fe_name, T0 method,
989  T1 pre_only, T2 post_only) {
990  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
992  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
993  if (pre_only) {
994  dm_field->tsCtx->getPreProcessIJacobian().push_back(pre_only);
995  }
996  if (method) {
997  dm_field->tsCtx->getLoopsIJacobian().push_back(
998  PairNameFEMethodPtr(fe_name, method));
999  }
1000  if (post_only) {
1001  dm_field->tsCtx->getPostProcessIJacobian().push_back(post_only);
1002  }
1003  CHKERR DMTSSetI2Jacobian(dm, TsSetI2Jacobian, dm_field->tsCtx.get());
1005 }
1006 
1007 PetscErrorCode DMMoFEMTSSetI2Jacobian(DM dm, const char fe_name[],
1008  MoFEM::FEMethod *method,
1009  MoFEM::BasicMethod *pre_only,
1010  MoFEM::BasicMethod *post_only) {
1011  return DMMoFEMTSSetI2Jacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
1012  MoFEM::BasicMethod *>(dm, fe_name, method,
1013  pre_only, post_only);
1014 }
1015 
1016 PetscErrorCode
1017 DMMoFEMTSSetI2Jacobian(DM dm, const std::string fe_name,
1018  boost::shared_ptr<MoFEM::FEMethod> method,
1019  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
1020  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
1021  return DMMoFEMTSSetI2Jacobian<const std::string,
1022  boost::shared_ptr<MoFEM::FEMethod>,
1023  boost::shared_ptr<MoFEM::BasicMethod>,
1024  boost::shared_ptr<MoFEM::BasicMethod>>(
1025  dm, fe_name, method, pre_only, post_only);
1026 }
1027 
1028 template <class S, class T0, class T1, class T2>
1029 static PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, S fe_name, T0 method,
1030  T1 pre_only, T2 post_only) {
1031  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1033  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1034  if (pre_only)
1035  dm_field->tsCtx->getPreProcessMonitor().push_back(pre_only);
1036  if (method)
1037  dm_field->tsCtx->getLoopsMonitor().push_back(
1038  PairNameFEMethodPtr(fe_name, method));
1039  if (post_only)
1040  dm_field->tsCtx->getPostProcessMonitor().push_back(post_only);
1041  CHKERR TSMonitorSet(ts, TsMonitorSet, dm_field->tsCtx.get(), PETSC_NULL);
1043 }
1044 
1045 PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const char fe_name[],
1046  MoFEM::FEMethod *method,
1047  MoFEM::BasicMethod *pre_only,
1048  MoFEM::BasicMethod *post_only) {
1049  return DMMoFEMTSSetMonitor<const char *, MoFEM::FEMethod *,
1051  dm, ts, fe_name, method, pre_only, post_only);
1053 }
1054 
1055 PetscErrorCode
1056 DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name,
1057  boost::shared_ptr<MoFEM::FEMethod> method,
1058  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
1059  boost::shared_ptr<MoFEM::BasicMethod> post_only) {
1060  return DMMoFEMTSSetMonitor<const std::string,
1061  boost::shared_ptr<MoFEM::FEMethod>,
1062  boost::shared_ptr<MoFEM::BasicMethod>,
1063  boost::shared_ptr<MoFEM::BasicMethod>>(
1064  dm, ts, fe_name, method, pre_only, post_only);
1066 }
1067 
1068 PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx) {
1069  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1071  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1072  *ksp_ctx = dm_field->kspCtx.get();
1074 }
1075 
1076 PetscErrorCode
1077 DMMoFEMGetKspCtx(DM dm, const boost::shared_ptr<MoFEM::KspCtx> &ksp_ctx) {
1078  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1080  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1081  const_cast<boost::shared_ptr<MoFEM::KspCtx> &>(ksp_ctx) = dm_field->kspCtx;
1083 }
1084 
1085 PetscErrorCode DMMoFEMSetKspCtx(DM dm,
1086  boost::shared_ptr<MoFEM::KspCtx> ksp_ctx) {
1087  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1089  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1090  dm_field->kspCtx = ksp_ctx;
1092 }
1093 
1094 PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx) {
1095  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1097  DMCtxImpl *dm_field = (DMCtxImpl *)dm->data;
1098  *snes_ctx = dm_field->snesCtx.get();
1100 }
1101 
1102 PetscErrorCode
1103 DMMoFEMGetSnesCtx(DM dm, const boost::shared_ptr<MoFEM::SnesCtx> &snes_ctx) {
1104  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1106  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1107  const_cast<boost::shared_ptr<MoFEM::SnesCtx> &>(snes_ctx) = dm_field->snesCtx;
1109 }
1110 
1111 PetscErrorCode DMMoFEMSetSnesCtx(DM dm,
1112  boost::shared_ptr<MoFEM::SnesCtx> snes_ctx) {
1113  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1115  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1116  dm_field->snesCtx = snes_ctx;
1118 }
1119 
1120 /** get if read mesh is partitioned
1121  * \ingroup dm
1122  */
1123 PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned) {
1124  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1126  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1127  dm_field->isPartitioned = is_partitioned;
1129 }
1130 
1131 /** get if read mesh is partitioned
1132  * \ingroup dm
1133  */
1134 PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned) {
1135  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1137  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1138  *is_partitioned = dm_field->isPartitioned;
1140 }
1141 
1142 PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx) {
1143  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1145  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1146  *ts_ctx = dm_field->tsCtx.get();
1148 }
1149 
1150 PetscErrorCode DMMoFEMGetTsCtx(DM dm,
1151  const boost::shared_ptr<MoFEM::TsCtx> &ts_ctx) {
1152  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1154  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1155  const_cast<boost::shared_ptr<MoFEM::TsCtx> &>(ts_ctx) = dm_field->tsCtx;
1157 }
1158 
1159 PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr<MoFEM::TsCtx> ts_ctx) {
1160  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1162  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1163  dm_field->tsCtx = ts_ctx;
1165 }
1166 
1167 PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g) {
1168  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1170  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1171  CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1172  dm_field->problemName, COL, g);
1173  CHKERR VecSetDM(*g, dm);
1175 }
1176 
1177 PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, SmartPetscObj<Vec> &g_ptr) {
1178  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1180  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1181  CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1182  dm_field->problemName, COL, g_ptr);
1183  CHKERR VecSetDM(g_ptr, dm);
1185 }
1186 
1187 PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l) {
1188  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1190  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1191  CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateSeq(
1192  dm_field->problemName, COL, l);
1193  CHKERR VecSetDM(*l, dm);
1195 }
1196 
1197 PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M) {
1198  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1200  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1201 
1202  if (strcmp(dm->mattype, MATSHELL) == 0) {
1203 
1204  if (dm_field->blocMatDataPtr) {
1207  } else {
1208  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1209  "Matrix shell data not set, or matrix type not implemented");
1210  }
1211 
1212  } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1214  ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1215  M);
1216  } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1218  ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1219  M);
1220  } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1222  ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1223  dm_field->problemName, M);
1224  } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1226  ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1227  dm_field->problemName, M);
1228  } else {
1229  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1230  "Matrix type not implemented");
1231  }
1232  CHKERR MatSetDM(*M, dm);
1234 }
1235 
1236 PetscErrorCode DMCreateMatrix_MoFEM(DM dm, SmartPetscObj<Mat> &M) {
1237  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1239  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1240 
1241  if (strcmp(dm->mattype, MATSHELL) == 0) {
1242  if (dm_field->blocMatDataPtr) {
1243  Mat mat_raw;
1244  CHKERR DMMoFEMCreateBlockMat(dm, &mat_raw);
1245  M = SmartPetscObj<Mat>(mat_raw);
1247  } else {
1248  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1249  "Matrix shell data not set, or matrix type not implemented");
1250  }
1251  } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1253  ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1254  M);
1255  } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1257  ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1258  M);
1259  } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1261  ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1262  dm_field->problemName, M);
1263  } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1265  ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1266  dm_field->problemName, M);
1267  } else {
1268  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1269  "Matrix type not implemented");
1270  }
1271  CHKERR MatSetDM(M, dm);
1273 }
1274 
1275 #if PETSC_VERSION_GE(3, 7, 0)
1276 PetscErrorCode DMSetFromOptions_MoFEM(PetscOptionItems *PetscOptionsObject,
1277  DM dm) {
1278 #elif PETSC_VERSION_GE(3, 5, 3)
1279 PetscErrorCode DMSetFromOptions_MoFEM(PetscOptions *PetscOptionsObject, DM dm) {
1280 #else
1281 PetscErrorCode DMSetFromOptions_MoFEM(DM dm) {
1282 #endif
1283 
1284  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1286  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1287 #if PETSC_VERSION_GE(3, 5, 3)
1288  ierr = PetscOptionsHead(PetscOptionsObject, "DMMoFEM Options");
1289  CHKERRG(ierr);
1290 #else
1291  ierr = PetscOptionsHead("DMMoFEM Options");
1292  CHKERRG(ierr);
1293 #endif
1294  ierr = PetscOptionsBool("-dm_is_partitioned",
1295  "set if mesh is partitioned (works which native MOAB "
1296  "file format, i.e. h5m",
1297  "DMSetUp", dm_field->isPartitioned,
1298  &dm_field->isPartitioned, NULL);
1299  CHKERRG(ierr);
1301 }
1302 
1303 PetscErrorCode DMSetUp_MoFEM(DM dm) {
1304  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1305  ProblemsManager *prb_mng_ptr;
1307  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1308  CHKERR dm_field->mField_ptr->getInterface(prb_mng_ptr);
1309 
1310  if (dm_field->isCompDM) {
1311  // It is composite probelm
1312  CHKERR prb_mng_ptr->buildComposedProblem(
1313  dm_field->problemName, dm_field->rowCompPrb, dm_field->colCompPrb,
1314  dm_field->isSquareMatrix == PETSC_TRUE, dm_field->verbosity);
1315  } else {
1316  if (dm_field->isPartitioned) {
1318  dm_field->problemName, dm_field->isSquareMatrix == PETSC_TRUE,
1319  dm_field->verbosity);
1320  } else {
1321  CHKERR prb_mng_ptr->buildProblem(dm_field->problemName,
1322  dm_field->isSquareMatrix == PETSC_TRUE,
1323  dm_field->verbosity);
1324  CHKERR prb_mng_ptr->partitionProblem(dm_field->problemName,
1325  dm_field->verbosity);
1326  }
1327  }
1328 
1329  // Partition finite elements
1330  if (dm_field->isPartitioned) {
1331  CHKERR prb_mng_ptr->partitionFiniteElements(
1332  dm_field->problemName, true, 0, dm_field->sIze, dm_field->verbosity);
1334  dm_field->problemName, dm_field->verbosity);
1335  } else {
1336  // partition finite elemnets
1337  CHKERR prb_mng_ptr->partitionFiniteElements(dm_field->problemName, false,
1338  -1, -1, dm_field->verbosity);
1339  // Get ghost DOFs
1340  CHKERR prb_mng_ptr->partitionGhostDofs(dm_field->problemName,
1341  dm_field->verbosity);
1342  }
1343 
1344  // Set flag that problem is build and partitioned
1345  dm_field->isProblemBuild = PETSC_TRUE;
1346 
1348 }
1349 
1350 PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm) {
1351  PetscValidHeaderSpecific(subdm, DM_CLASSID, 1);
1352  ProblemsManager *prb_mng_ptr;
1354 
1355  DMCtxImpl *subdm_field = static_cast<DMCtxImpl *>(subdm->data);
1356 
1357  // build sub dm problem
1358  CHKERR subdm_field->mField_ptr->getInterface(prb_mng_ptr);
1359 
1360  map<std::string, boost::shared_ptr<Range>> *entity_map_row = nullptr;
1361  map<std::string, boost::shared_ptr<Range>> *entity_map_col = nullptr;
1362 
1363  if (subdm_field->mapTypeRow.size())
1364  entity_map_row = &subdm_field->mapTypeRow;
1365  if (subdm_field->mapTypeCol.size())
1366  entity_map_col = &subdm_field->mapTypeCol;
1367 
1368  CHKERR prb_mng_ptr->buildSubProblem(
1369  subdm_field->problemName, subdm_field->rowSubFields,
1370  subdm_field->colSubFields, subdm_field->problemMainOfSubPtr->getName(),
1371  subdm_field->isSquareMatrix == PETSC_TRUE, entity_map_row, entity_map_col,
1372  subdm_field->verbosity);
1373 
1374  // partition problem
1375  subdm_field->isPartitioned = subdm_field->isPartitioned;
1376  if (subdm_field->isPartitioned) {
1377  CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, true,
1378  0, subdm_field->sIze,
1379  subdm_field->verbosity);
1380  // set ghost nodes
1382  subdm_field->problemName, subdm_field->verbosity);
1383  } else {
1384  // partition finite elements
1385  CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, false,
1386  -1, -1, subdm_field->verbosity);
1387  // set ghost nodes
1388  CHKERR prb_mng_ptr->partitionGhostDofs(subdm_field->problemName,
1389  subdm_field->verbosity);
1390  }
1391 
1392  subdm_field->isProblemBuild = PETSC_TRUE;
1393 
1395 }
1396 
1397 PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec g, InsertMode mode,
1398  Vec l) {
1399  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1401  CHKERR VecGhostUpdateBegin(g, INSERT_VALUES, SCATTER_FORWARD);
1403 }
1404 
1405 PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec g, InsertMode mode, Vec l) {
1407  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1409 
1410  CHKERR VecGhostUpdateEnd(g, INSERT_VALUES, SCATTER_FORWARD);
1411 
1412  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1413  int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1414  int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1415 
1416  double *array_loc, *array_glob;
1417  CHKERR VecGetArray(l, &array_loc);
1418  CHKERR VecGetArray(g, &array_glob);
1419  switch (mode) {
1420  case INSERT_VALUES:
1421  cblas_dcopy(nb_dofs + nb_ghost, array_glob, 1, array_loc, 1);
1422  break;
1423  case ADD_VALUES:
1424  cblas_daxpy(nb_dofs + nb_ghost, 1, array_glob, 1, array_loc, 1);
1425  break;
1426  default:
1427  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1428  }
1429  CHKERR VecRestoreArray(l, &array_loc);
1430  CHKERR VecRestoreArray(g, &array_glob);
1432 }
1433 
1434 PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM dm, Vec l, InsertMode mode,
1435  Vec g) {
1436 
1437  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1439 
1440  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1441  int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1442  int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1443 
1444  double *array_loc, *array_glob;
1445  CHKERR VecGetArray(l, &array_loc);
1446  CHKERR VecGetArray(g, &array_glob);
1447  switch (mode) {
1448  case INSERT_VALUES:
1449  cblas_dcopy(nb_dofs + nb_ghost, array_loc, 1, array_glob, 1);
1450  break;
1451  case ADD_VALUES:
1452  cblas_daxpy(nb_dofs + nb_ghost, 1, array_loc, 1, array_glob, 1);
1453  break;
1454  default:
1455  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1456  }
1457  CHKERR VecRestoreArray(l, &array_loc);
1458  CHKERR VecRestoreArray(g, &array_glob);
1459 
1461 }
1462 
1463 PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec l, InsertMode mode, Vec g) {
1464  //
1467 }
1468 
1469 PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields,
1470  char ***fieldNames, IS **fields) {
1471  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1473 
1474  if (numFields) {
1475  *numFields = 0;
1476  }
1477  if (fieldNames) {
1478  *fieldNames = NULL;
1479  }
1480  if (fields) {
1481  *fields = NULL;
1482  }
1483 
1484  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1485  auto fields_ptr = dm_field->mField_ptr->get_fields();
1486  Field_multiIndex::iterator fit, hi_fit;
1487  fit = fields_ptr->begin();
1488  hi_fit = fields_ptr->end();
1489  *numFields = std::distance(fit, hi_fit);
1490 
1491  if (fieldNames) {
1492  CHKERR PetscMalloc1(*numFields, fieldNames);
1493  }
1494  if (fields) {
1495  CHKERR PetscMalloc1(*numFields, fields);
1496  }
1497 
1498  for (int f = 0; fit != hi_fit; fit++, f++) {
1499  if (fieldNames) {
1500  CHKERR PetscStrallocpy(fit->get()->getName().c_str(),
1501  (char **)&(*fieldNames)[f]);
1502  }
1503  if (fields) {
1504  CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1505  ->isCreateProblemFieldAndRank(
1506  dm_field->problemPtr->getName(), ROW, fit->get()->getName(), 0,
1507  fit->get()->getNbOfCoeffs(), &(*fields)[f]);
1508  }
1509  }
1510 
1512 }
1513 
1514 PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[],
1515  IS *is) {
1516  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1518  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1519  CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1520  ->isCreateProblemFieldAndRank(dm_field->problemPtr->getName(), ROW,
1521  field_name, 0, 1000, is);
1523 }
1524 
1525 PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb) {
1526  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1528  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1529  dm_field->verbosity = verb;
1531 }
1532 
1534  boost::shared_ptr<BlockStructure> data) {
1535  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1537  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1538  dm_field->blocMatDataPtr = data;
1540 }
1541 
1543  boost::shared_ptr<BlockStructure> &data) {
1544  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1546  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1547  data = dm_field->blocMatDataPtr;
1549 }
1550 
1552  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1554  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1555  auto mat_data = createBlockMat(dm, dm_field->blocMatDataPtr);
1556  *mat = mat_data.first;
1557  CHKERR PetscObjectReference((PetscObject)(*mat));
1559 }
1560 
1561 template <>
1563  boost::shared_ptr<NestSchurData> data) {
1564  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1566  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1567  dm_field->nestedSchurDataPtr = data;
1568  dm_field->blocMatDataPtr = get<2>(*(data));
1570 }
1571 
1573  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1575  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1576  auto mat_data = createSchurNestedMatrix(dm_field->nestedSchurDataPtr);
1577  *mat = mat_data.first;
1578  CHKERR PetscObjectReference((PetscObject)(*mat));
1580 }
1581 
1583  PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1585  DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1586  auto matrix_mng = dm_field->mField_ptr->getInterface<MatrixManager>();
1587  CHKERR matrix_mng->createHybridL2MPIAIJ<PetscGlobalIdx_mi_tag>(
1588  dm_field->problemName, mat);
1590 }
1591 
1592 } // namespace MoFEM
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::DMMoFEMGetBlocMatData
MoFEMErrorCode DMMoFEMGetBlocMatData(DM dm, boost::shared_ptr< BlockStructure > &)
Get data for block mat.
Definition: DMMoFEM.cpp:1542
MoFEM::DMCtxImpl::colSubFields
std::vector< std::string > colSubFields
Definition: DMCtxImpl.hpp:26
MoFEM::KspRhs
PetscErrorCode KspRhs(KSP ksp, Vec f, void *ctx)
Run over elements in the lists.
Definition: KspCtx.cpp:21
MoFEM::DMSetFromOptions_MoFEM
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1281
g
constexpr double g
Definition: shallow_wave.cpp:63
MoFEM::DMMoFEMSetSnesCtx
PetscErrorCode DMMoFEMSetSnesCtx(DM dm, boost::shared_ptr< MoFEM::SnesCtx > snes_ctx)
Set MoFEM::SnesCtx data structure.
Definition: DMMoFEM.cpp:1111
MoFEM::LogManager::checkIfChannelExist
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
Definition: LogManager.cpp:404
MoFEM::CoreInterface::problem_basic_method_postProcess
virtual MoFEMErrorCode problem_basic_method_postProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
MoFEM::CoreInterface::loop_finite_elements
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
MoFEM::CoreInterface::loop_dofs
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.
MoFEM::ProblemsManager::buildProblem
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
Definition: ProblemsManager.cpp:87
MoFEM::DMMoFEMSetKspCtx
PetscErrorCode DMMoFEMSetKspCtx(DM dm, boost::shared_ptr< MoFEM::KspCtx > ksp_ctx)
set MoFEM::KspCtx data structure
Definition: DMMoFEM.cpp:1085
MoFEM::DMMoFEMKSPSetComputeRHS
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set KSP right hand side evaluation function
Definition: DMMoFEM.cpp:637
MoFEM::DMMoFEMAddSubFieldCol
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition: DMMoFEM.cpp:280
MoFEM::DMCtxImpl::colCompPrb
std::vector< std::string > colCompPrb
Definition: DMCtxImpl.hpp:31
MoFEM::DMMoFEMGetDestroyProblem
PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem)
Definition: DMMoFEM.cpp:447
MoFEM::DMCtxImpl::rAnk
int rAnk
Definition: DMCtxImpl.hpp:17
MoFEM::Problem::getNumberOfElementsByNameAndPart
MoFEMErrorCode getNumberOfElementsByNameAndPart(MPI_Comm comm, const std::string name, PetscLayout *layout) const
Get number of finite elements by name on processors.
Definition: ProblemsMultiIndices.cpp:98
MoFEM::ProblemsManager
Problem manager is used to build and partition problems.
Definition: ProblemsManager.hpp:21
MoFEM::FEMethod
structure for User Loop Methods on finite elements
Definition: LoopMethods.hpp:369
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
MoFEM::TsSetIFunction
PetscErrorCode TsSetIFunction(TS ts, PetscReal t, Vec u, Vec u_t, Vec F, void *ctx)
Set IFunction for TS solver.
Definition: TsCtx.cpp:56
MoFEM::DMMoFEMSetSquareProblem
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition: DMMoFEM.cpp:456
MoFEM::DMCtxImpl::isCompDM
PetscBool isCompDM
Definition: DMCtxImpl.hpp:29
MoFEM::DMCtxImpl::mapTypeRow
std::map< std::string, boost::shared_ptr< Range > > mapTypeRow
Definition: DMCtxImpl.hpp:32
MoFEM::DMCtxImpl::isPartitioned
PetscBool isPartitioned
true if read mesh is on parts
Definition: DMCtxImpl.hpp:36
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::DMGlobalToLocalBegin_MoFEM
PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1397
MoFEM::DMMoFEMGetSubColIS
PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is)
get sub problem is
Definition: DMMoFEM.cpp:349
MoFEM::DMMoFEMAddColCompositeProblem
PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on col.
Definition: DMMoFEM.cpp:385
MoFEM::CoreInterface::get_problem
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
DMMoFEM.hpp
Discrete manager interface for MoFEM.
MoFEM::DMSetUp_MoFEM
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1303
MoFEM::DMoFEMMeshToLocalVector
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMoFEM.cpp:523
MoFEM::TsSetI2Jacobian
PetscErrorCode TsSetI2Jacobian(TS ts, PetscReal t, Vec u, Vec u_t, Vec u_tt, PetscReal a, PetscReal aa, Mat A, Mat B, void *ctx)
Calculation Jacobian for second order PDE in time.
Definition: TsCtx.cpp:511
MoFEM::Problem::getNbGhostDofsRow
DofIdx getNbGhostDofsRow() const
Definition: ProblemsMultiIndices.hpp:380
DMCtxImpl.hpp
Implementation of DM context. You should not use it directly.
MoFEM::DMMoFEMTSSetRHSJacobian
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
Definition: DMMoFEM.cpp:922
MoFEM::DMMoFEMGetIsSubDM
PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm)
Definition: DMMoFEM.cpp:322
MoFEM::DofMethod
Data structure to exchange data between mofem and User Loop Methods on entities.
Definition: LoopMethods.hpp:493
MoFEM::DMMoFEMKSPSetComputeOperators
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.
Definition: DMMoFEM.cpp:678
MoFEM::LogManager::createSink
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:298
ts_ctx
MoFEM::TsCtx * ts_ctx
Definition: level_set.cpp:1932
MoFEM::DMLocalToGlobalBegin_MoFEM
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1434
MoFEM::DMCtxImpl::nestedSchurDataPtr
boost::shared_ptr< NestSchurData > nestedSchurDataPtr
Definition: DMCtxImpl.hpp:49
MoFEM::DMCtxImpl::problemName
std::string problemName
Problem name.
Definition: DMCtxImpl.hpp:45
MoFEM::DMCtxImpl::sIze
int sIze
Definition: DMCtxImpl.hpp:18
MoFEM::DMMoFEMSwapDMCtx
PetscErrorCode DMMoFEMSwapDMCtx(DM dm, DM dm_swap)
Swap internal data struture.
Definition: DMMoFEM.cpp:196
MoFEM::DMMoFEMAddElement
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition: DMMoFEM.cpp:497
MoFEM::CoreInterface::check_problem
virtual bool check_problem(const std::string name)=0
check if problem exist
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
ROW
@ ROW
Definition: definitions.h:136
MoFEM::DMMoFEMGetIsCompDM
PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm)
Get if this DM is composite DM.
Definition: DMMoFEM.cpp:405
MoFEM::TsMonitorSet
PetscErrorCode TsMonitorSet(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Set monitor for TS solver.
Definition: TsCtx.cpp:259
MoFEM::DMCreateGlobalVector_MoFEM
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition: DMMoFEM.cpp:1167
MoFEM::DMMoFEMSetDestroyProblem
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
Definition: DMMoFEM.cpp:438
PlasticOps::M
FTensor::Index< 'M', 3 > M
Definition: PlasticOps.hpp:117
MoFEM::CoreInterface::problem_basic_method_preProcess
virtual MoFEMErrorCode problem_basic_method_preProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
MoFEM::DMCtxImpl
Definition: DMCtxImpl.hpp:10
MoFEM::DMCreateMatrix_MoFEM
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition: DMMoFEM.cpp:1197
MoFEM::DMMoFEMAddRowCompositeProblem
PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on row.
Definition: DMMoFEM.cpp:367
MoFEM::DMCtxImpl::isSquareMatrix
PetscBool isSquareMatrix
true if rows equals to cols
Definition: DMCtxImpl.hpp:37
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::createBlockMat
SchurShellMatData createBlockMat(DM dm, boost::shared_ptr< BlockStructure > data)
Create a Schur Mat object.
Definition: Schur.cpp:1379
MoFEM::DMMoFEMTSSetIJacobian
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
Definition: DMMoFEM.cpp:853
MoFEM::DMoFEMLoopFiniteElementsUpAndLowRank
PetscErrorCode DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank, int up_rank, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:567
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::DMMoFEMCreateHybridL2Mat
MoFEMErrorCode DMMoFEMCreateHybridL2Mat(DM dm, SmartPetscObj< Mat > &mat)
Create matrix for hybridised system.
Definition: DMMoFEM.cpp:1582
MoFEM::ISManager
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
MoFEM::DMCtxImpl::blocMatDataPtr
boost::shared_ptr< BlockStructure > blocMatDataPtr
Definition: DMCtxImpl.hpp:48
MoFEM::DMMoFEMTSSetI2Jacobian
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
Definition: DMMoFEM.cpp:1017
MoFEM::DMDestroy_MoFEM
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
Definition: DMMoFEM.cpp:79
MoFEM::ProblemsManager::partitionGhostDofsOnDistributedMesh
MoFEMErrorCode partitionGhostDofsOnDistributedMesh(const std::string name, int verb=VERBOSE)
determine ghost nodes on distributed meshes
Definition: ProblemsManager.cpp:2473
MoFEM::DMSubDMSetUp_MoFEM
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition: DMMoFEM.cpp:1350
MoFEM::DMCtxImpl::rowSubFields
std::vector< std::string > rowSubFields
Definition: DMCtxImpl.hpp:25
MoFEM::DMMoFEMTSSetI2Function
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
Definition: DMMoFEM.cpp:975
MoFEM::DMCtxImpl::mField_ptr
Interface * mField_ptr
MoFEM interface.
Definition: DMCtxImpl.hpp:41
MoFEM::DMMoFEMCreateSubDM
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
Definition: DMMoFEM.cpp:215
MoFEM::DMCtxImpl::destroyProblem
PetscBool destroyProblem
If true destroy problem with DM.
Definition: DMCtxImpl.hpp:38
RowColData
RowColData
RowColData.
Definition: definitions.h:136
MoFEM::DMMoFEMGetSubRowIS
PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is)
get sub problem is
Definition: DMMoFEM.cpp:331
MoFEM::PairNameFEMethodPtr
Definition: AuxPETSc.hpp:12
MoFEM::Problem::getSubData
boost::shared_ptr< SubProblemData > & getSubData() const
Get main problem of sub-problem is.
Definition: ProblemsMultiIndices.hpp:119
MoFEM::LogManager::getStrmSync
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
Definition: LogManager.cpp:348
MoFEM::DMCtx::kspCtx
boost::shared_ptr< KspCtx > kspCtx
data structure KSP
Definition: DMMoFEM.hpp:1019
MoFEM::DMoFEMMeshToGlobalVector
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
Definition: DMMoFEM.cpp:535
COL
@ COL
Definition: definitions.h:136
MoFEM::LogManager::getStrmWorld
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:344
MoFEM::CoreInterface::modify_problem_unset_finite_element
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...
MoFEM::DMMoFEMGetSnesCtx
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
Definition: DMMoFEM.cpp:1094
MoFEM::TsCtx
Interface for Time Stepping (TS) solver.
Definition: TsCtx.hpp:17
MoFEM::DMRegister_MoFEM
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMoFEM.cpp:43
MoFEM::DMCtx::tsCtx
boost::shared_ptr< TsCtx > tsCtx
data structure for TS solver
Definition: DMMoFEM.hpp:1021
MoFEM::DMCtxImpl::referenceNumber
int referenceNumber
Definition: DMCtxImpl.hpp:21
MoFEM::DMMoFEMSNESSetJacobian
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
Definition: DMMoFEM.cpp:759
MoFEM::TsSetIJacobian
PetscErrorCode TsSetIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx)
Set function evaluating jacobian in TS solver.
Definition: TsCtx.cpp:165
MoFEM::LogManager::getStrmSelf
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Definition: LogManager.cpp:340
MoFEM::DMoFEMPreProcessFiniteElements
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition: DMMoFEM.cpp:546
MoFEM::DMCtx
PETSc Discrete Manager data structure.
Definition: DMMoFEM.hpp:1012
MoFEM::DMMoFEMGetSquareProblem
PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem)
get squared problem
Definition: DMMoFEM.cpp:487
MoFEM::PetscGlobalIdx_mi_tag
Definition: TagMultiIndices.hpp:38
MoFEM::createSchurNestedMatrix
std::pair< SmartPetscObj< Mat >, boost::shared_ptr< NestSchurData > > createSchurNestedMatrix(boost::shared_ptr< NestSchurData > schur_net_data_ptr)
Create a Mat Diag Blocks object.
Definition: Schur.cpp:2153
MoFEM::DMGlobalToLocalEnd_MoFEM
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1405
MoFEM::BasicMethod
Data structure to exchange data between mofem and User Loop Methods.
Definition: LoopMethods.hpp:183
MoFEM::DMoFEMPostProcessFiniteElements
PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition: DMMoFEM.cpp:556
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
MoFEM::Problem::getNbLocalDofsRow
DofIdx getNbLocalDofsRow() const
Definition: ProblemsMultiIndices.hpp:378
MoFEM::DMMoFEMCreateMoFEM
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.
Definition: DMMoFEM.cpp:114
MoFEM::ProblemsManager::partitionFiniteElements
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
Definition: ProblemsManager.cpp:2167
MoFEM::DMMoFEMSetBlocMatData
MoFEMErrorCode DMMoFEMSetBlocMatData(DM dm, boost::shared_ptr< BlockStructure >)
Set data for block mat.
Definition: DMMoFEM.cpp:1533
MoFEM::DMSetOperators_MoFEM
PetscErrorCode DMSetOperators_MoFEM(DM dm)
Set operators for MoFEM dm.
Definition: DMMoFEM.cpp:49
MoFEM::CoreInterface::modify_problem_ref_level_add_bit
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
MoFEM::VecManager
Vector manager is used to create vectors \mofem_vectors.
Definition: VecManager.hpp:23
MoFEM::DMCreateFieldIS_MoFEM
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition: DMMoFEM.cpp:1469
MoFEM::ProblemsManager::buildComposedProblem
MoFEMErrorCode buildComposedProblem(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
Definition: ProblemsManager.cpp:1250
MoFEM::DMCtxImpl::isSubDM
PetscBool isSubDM
Definition: DMCtxImpl.hpp:24
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::DMCtxImpl::rowCompPrb
std::vector< std::string > rowCompPrb
Definition: DMCtxImpl.hpp:30
MoFEM::MatrixManager
Matrix manager is used to build and partition problems.
Definition: MatrixManager.hpp:21
MoFEM::DMCtx::snesCtx
boost::shared_ptr< SnesCtx > snesCtx
data structure SNES
Definition: DMMoFEM.hpp:1020
MoFEM::DMMoFEMResolveSharedFiniteElements
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name)
Resolve shared entities.
Definition: DMMoFEM.cpp:464
MoFEM::DMMoFEMGetKspCtx
PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx)
get MoFEM::KspCtx data structure
Definition: DMMoFEM.cpp:1068
MoFEM::CoreInterface::get_fields
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
MoFEM::DMMoFEMSetTsCtx
PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr< MoFEM::TsCtx > ts_ctx)
Set MoFEM::TsCtx data structure.
Definition: DMMoFEM.cpp:1159
MoFEM::SnesRhs
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.
Definition: SnesCtx.cpp:27
MoFEM::DMMoFEMTSSetRHSFunction
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
Definition: DMMoFEM.cpp:882
MoFEM::DMCreate_MoFEM
PetscErrorCode DMCreate_MoFEM(DM dm)
Create dm data structure with MoFEM data structure.
Definition: DMMoFEM.cpp:71
MoFEM::DMCtx::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: DMMoFEM.cpp:19
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::DMCtxImpl::problemMainOfSubPtr
const Problem * problemMainOfSubPtr
pointer to main problem to sub-problem
Definition: DMCtxImpl.hpp:27
MoFEM::CommInterface
Managing BitRefLevels.
Definition: CommInterface.hpp:21
MoFEM::DMMoFEMGetFieldIS
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
Definition: DMMoFEM.cpp:1514
MoFEM::DMoFEMGetInterfacePtr
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
Definition: DMMoFEM.cpp:414
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
MoFEM::KspMat
PetscErrorCode KspMat(KSP ksp, Mat A, Mat B, void *ctx)
Run over elements in the list.
Definition: KspCtx.cpp:86
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEM::DMMoFEMTSSetMonitor
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.
Definition: DMMoFEM.cpp:1056
MoFEM::DMMoFEMTSSetIFunction
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
Definition: DMMoFEM.cpp:800
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::ProblemsManager::buildProblemOnDistributedMesh
MoFEMErrorCode buildProblemOnDistributedMesh(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures, assuming that mesh is distributed (collective)
Definition: ProblemsManager.cpp:290
MoFEM::DMMoFEMGetIsPartitioned
PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned)
Definition: DMMoFEM.cpp:1134
MoFEM::DMMoFEMGetProblemPtr
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition: DMMoFEM.cpp:426
MoFEM::DMMoFEMCreateBlockMat
MoFEMErrorCode DMMoFEMCreateBlockMat(DM dm, Mat *mat)
Create block matrix.
Definition: DMMoFEM.cpp:1551
MoFEM::DMMoFEMUnSetElement
PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name)
unset element from dm
Definition: DMMoFEM.cpp:514
MoFEM::CacheTupleWeakPtr
boost::weak_ptr< CacheTuple > CacheTupleWeakPtr
Definition: FEMultiIndices.hpp:494
MoFEM::Problem::getBitRefLevelMask
BitRefLevel getBitRefLevelMask() const
Definition: ProblemsMultiIndices.hpp:384
MoFEM::DMMoFEMGetTsCtx
PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
Definition: DMMoFEM.cpp:1142
MoFEM::Problem::getBitRefLevel
BitRefLevel getBitRefLevel() const
Definition: ProblemsMultiIndices.hpp:383
MoFEM::KspCtx
Interface for linear (KSP) solver.
Definition: KspCtx.hpp:13
MoFEM::TsSetRHSJacobian
PetscErrorCode TsSetRHSJacobian(TS ts, PetscReal t, Vec u, Mat A, Mat B, void *ctx)
TS solver function.
Definition: TsCtx.cpp:422
MoFEM::DMCtxImpl::DMCtxImpl
DMCtxImpl()
Definition: DMMoFEM.cpp:25
MoFEM::CoreInterface::modify_problem_add_finite_element
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
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEM::CoreInterface::modify_problem_mask_ref_level_add_bit
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
MoFEM::DMCtxImpl::isProblemBuild
PetscBool isProblemBuild
True if problem is build.
Definition: DMCtxImpl.hpp:39
MoFEM::DMMoFEMSetNestSchurData
MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr< NestSchurData >)
Definition: DMMoFEM.cpp:1562
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
MoFEM::SnesCtx
Interface for nonlinear (SNES) solver.
Definition: SnesCtx.hpp:13
MoFEM::Problem
keeps basic data about problem
Definition: ProblemsMultiIndices.hpp:54
MoFEM::TsSetRHSFunction
PetscErrorCode TsSetRHSFunction(TS ts, PetscReal t, Vec u, Vec F, void *ctx)
TS solver function.
Definition: TsCtx.cpp:323
MoFEM::DMMoFEMAddSubFieldRow
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition: DMMoFEM.cpp:238
MoFEM::LogManager::setLog
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:389
MoFEM::SmartPetscObj< Vec >
MoFEM::TsSetI2Function
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.
Definition: TsCtx.cpp:612
MoFEM::DMMoFEMCreateNestSchurMat
MoFEMErrorCode DMMoFEMCreateNestSchurMat(DM dm, Mat *mat)
Create nest schur matrix.
Definition: DMMoFEM.cpp:1572
MoFEM::SnesMat
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.
Definition: SnesCtx.cpp:139
MoFEM::ProblemsManager::partitionGhostDofs
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
Definition: ProblemsManager.cpp:2339
MoFEM::DMMoFEMGetProblemFiniteElementLayout
PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name, PetscLayout *layout)
Get finite elements layout in the problem.
Definition: DMMoFEM.cpp:473
MoFEM::DMCtxImpl::problemPtr
const Problem * problemPtr
pointer to problem data structure
Definition: DMCtxImpl.hpp:44
MoFEM::DMMoFEMDuplicateDMCtx
PetscErrorCode DMMoFEMDuplicateDMCtx(DM dm, DM dm_duplicate)
Duplicate internal data struture.
Definition: DMMoFEM.cpp:180
MF_EXCL
@ MF_EXCL
Definition: definitions.h:112
MoFEM::Problem::getName
auto getName() const
Definition: ProblemsMultiIndices.hpp:372
MoFEM::DMLocalToGlobalEnd_MoFEM
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1463
MoFEM::CoreInterface::add_problem
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
MoFEM::DMoFEMLoopFiniteElements
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:586
MF_EXIST
@ MF_EXIST
Definition: definitions.h:113
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEM::DMoFEMLoopDofs
PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[], MoFEM::DofMethod *method)
execute method for dofs on field in problem
Definition: DMMoFEM.cpp:605
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
MoFEM::DMCtxImpl::mapTypeCol
std::map< std::string, boost::shared_ptr< Range > > mapTypeCol
Definition: DMCtxImpl.hpp:33
MoFEM::CoreInterface::delete_problem
virtual MoFEMErrorCode delete_problem(const std::string name)=0
Delete problem.
MoFEM::DMCreateLocalVector_MoFEM
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition: DMMoFEM.cpp:1187
MoFEM::DMCtxImpl::verbosity
int verbosity
verbosity
Definition: DMCtxImpl.hpp:20
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
MOFEM_INVALID_DATA
@ MOFEM_INVALID_DATA
Definition: definitions.h:36
MoFEM::ProblemsManager::partitionProblem
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
Definition: ProblemsManager.cpp:1683
MoFEM::DMMoFEMSetVerbosity
PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb)
Set verbosity level.
Definition: DMMoFEM.cpp:1525
MoFEM::ProblemsManager::buildSubProblem
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, boost::shared_ptr< Range >> *entityMapRow=nullptr, const map< std::string, boost::shared_ptr< Range >> *entityMapCol=nullptr, int verb=VERBOSE)
build sub problem
Definition: ProblemsManager.cpp:981
MoFEM::DMMoFEMSetIsPartitioned
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition: DMMoFEM.cpp:1123
MoFEM::DMMoFEMSNESSetFunction
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
Definition: DMMoFEM.cpp:718