petscdmlibmesh.h File Reference

Go to the source code of this file.

Functions

PETSC_EXTERN PetscErrorCode DMlibMeshSetSystem (DM, libMesh::NonlinearImplicitSystem &)
 
PETSC_EXTERN PetscErrorCode DMlibMeshGetSystem (DM, libMesh::NonlinearImplicitSystem *&)
 
EXTERN_C_BEGIN PETSC_EXTERN PetscErrorCode DMCreate_libMesh (DM)
 

Function Documentation

◆ DMCreate_libMesh()

EXTERN_C_BEGIN PETSC_EXTERN PetscErrorCode DMCreate_libMesh ( DM  )

Definition at line 1164 of file petscdmlibmeshimpl.C.

References DM_libMesh::blockids, DM_libMesh::blocknames, CHKERRQ(), DM_libMesh::decomposition, DM_libMesh::decomposition_type, dlm, DMCreateDomainDecomposition_libMesh(), DMCreateDomainDecompositionDM_libMesh(), DMCreateFieldDecomposition_libMesh(), DMCreateFieldDecompositionDM_libMesh(), DMCreateGlobalVector_libMesh(), DMCreateMatrix_libMesh(), DMDestroy_libMesh(), DMlibMeshGetSystem_libMesh(), DMlibMeshSetSystem_libMesh(), DMSetUp_libMesh(), DMView_libMesh(), ierr, PetscFunctionReturn(), DM_libMesh::varids, and DM_libMesh::varnames.

Referenced by libMesh::LibMeshInit::LibMeshInit().

1165 {
1166  PetscErrorCode ierr;
1167  DM_libMesh * dlm;
1168 
1169  PetscFunctionBegin;
1170  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
1171 #if PETSC_RELEASE_LESS_THAN(3,5,0)
1172  ierr = PetscNewLog(dm,DM_libMesh,&dlm);CHKERRQ(ierr);
1173 #else
1174  ierr = PetscNewLog(dm,&dlm);CHKERRQ(ierr);
1175 #endif
1176  dm->data = dlm;
1177 
1178  /* DMlibMesh impl */
1179  dlm->varids = new(std::map<std::string, unsigned int>);
1180  dlm->blockids = new(std::map<std::string, unsigned int>);
1181  dlm->varnames = new(std::map<unsigned int, std::string>);
1182  dlm->blocknames = new(std::map<unsigned int, std::string>);
1183  dlm->decomposition = PETSC_NULL;
1184  dlm->decomposition_type = DMLIBMESH_NO_DECOMPOSITION;
1185 
1186  /* DM API */
1187  dm->ops->createglobalvector = DMCreateGlobalVector_libMesh;
1188  dm->ops->createlocalvector = 0; // DMCreateLocalVector_libMesh;
1189  dm->ops->getcoloring = 0; // DMGetColoring_libMesh;
1190  dm->ops->creatematrix = DMCreateMatrix_libMesh;
1191  dm->ops->createinterpolation= 0; // DMCreateInterpolation_libMesh;
1192 
1193  dm->ops->refine = 0; // DMRefine_libMesh;
1194  dm->ops->coarsen = 0; // DMCoarsen_libMesh;
1195  dm->ops->getinjection = 0; // DMGetInjection_libMesh;
1196  dm->ops->getaggregates = 0; // DMGetAggregates_libMesh;
1197 
1198 #if PETSC_RELEASE_LESS_THAN(3,3,1)
1199  dm->ops->createfielddecompositiondm = DMCreateFieldDecompositionDM_libMesh;
1200  dm->ops->createdomaindecompositiondm = DMCreateDomainDecompositionDM_libMesh;
1201 #endif
1202  dm->ops->createfielddecomposition = DMCreateFieldDecomposition_libMesh;
1203  dm->ops->createdomaindecomposition = DMCreateDomainDecomposition_libMesh;
1204 
1205  dm->ops->destroy = DMDestroy_libMesh;
1206  dm->ops->view = DMView_libMesh;
1207  dm->ops->setfromoptions = 0; // DMSetFromOptions_libMesh;
1208  dm->ops->setup = DMSetUp_libMesh;
1209 
1210  /* DMlibMesh API */
1211 #if PETSC_RELEASE_LESS_THAN(3,4,0)
1212  ierr = PetscObjectComposeFunction((PetscObject)dm,"DMlibMeshSetSystem_C",PETSC_NULL,(PetscVoidFunction)DMlibMeshSetSystem_libMesh);CHKERRQ(ierr);
1213  ierr = PetscObjectComposeFunction((PetscObject)dm,"DMlibMeshGetSystem_C",PETSC_NULL,(PetscVoidFunction)DMlibMeshGetSystem_libMesh);CHKERRQ(ierr);
1214 #else
1215  ierr = PetscObjectComposeFunction((PetscObject)dm,"DMlibMeshSetSystem_C",DMlibMeshSetSystem_libMesh);CHKERRQ(ierr);
1216  ierr = PetscObjectComposeFunction((PetscObject)dm,"DMlibMeshGetSystem_C",DMlibMeshGetSystem_libMesh);CHKERRQ(ierr);
1217 #endif
1218 
1220 }
static PetscErrorCode DMCreateDomainDecomposition_libMesh(DM dm, PetscInt *len, char ***namelist, IS **innerislist, IS **outerislist, DM **dmlist)
static PetscErrorCode DMCreateGlobalVector_libMesh(DM dm, Vec *x)
static PetscErrorCode DMCreateDomainDecompositionDM_libMesh(DM dm, const char *ddesc, DM *ddm)
std::map< std::string, unsigned int > * blockids
PetscErrorCode DMlibMeshSetSystem_libMesh(DM dm, NonlinearImplicitSystem &sys)
std::map< std::string, unsigned int > * varids
static PetscErrorCode DMCreateFieldDecomposition_libMesh(DM dm, PetscInt *len, char ***namelist, IS **islist, DM **dmlist)
std::vector< std::set< unsigned int > > * decomposition
static PetscErrorCode DMSetUp_libMesh(DM dm)
static PetscErrorCode DMCreateMatrix_libMesh(DM dm, const MatType, Mat *A) static PetscErrorCode DMCreateMatrix_libMesh(DM dm
PetscErrorCode DMlibMeshGetSystem_libMesh(DM dm, NonlinearImplicitSystem *&sys)
std::map< unsigned int, std::string > * varnames
std::map< unsigned int, std::string > * blocknames
static PetscErrorCode DMCreateFieldDecompositionDM_libMesh(DM dm, const char *ddesc, DM *ddm)
PetscErrorCode ierr
DM_libMesh * dlm
PetscFunctionReturn(0)
CHKERRQ(ierr)
static PetscErrorCode DMView_libMesh(DM dm, PetscViewer viewer)
unsigned int decomposition_type
static PetscErrorCode DMDestroy_libMesh(DM dm)

◆ DMlibMeshGetSystem()

PETSC_EXTERN PetscErrorCode DMlibMeshGetSystem ( DM  ,
libMesh::NonlinearImplicitSystem *&   
)

Definition at line 53 of file petscdmlibmesh.C.

References CHKERRQ(), ierr, and PetscFunctionReturn().

Referenced by DMlibMeshFunction(), DMlibMeshJacobian(), and DMVariableBounds_libMesh().

54 {
55  PetscErrorCode (*f)(DM,libMesh::NonlinearImplicitSystem *&) = nullptr;
56  PetscErrorCode ierr;
57 
58  PetscFunctionBegin;
59  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
60 #if PETSC_RELEASE_LESS_THAN(3,4,0)
61  ierr = PetscObjectQueryFunction((PetscObject)dm,"DMlibMeshGetSystem_C",(PetscVoidFunction*)&f);CHKERRQ(ierr);
62 #else
63  ierr = PetscObjectQueryFunction((PetscObject)dm,"DMlibMeshGetSystem_C",&f);CHKERRQ(ierr);
64 #endif
65  if (!f) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "DM has no implementation for DMlibMeshGetSystem");
66  ierr = (*f)(dm,sys);CHKERRQ(ierr);
68 }
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
PetscErrorCode ierr
PetscFunctionReturn(0)
CHKERRQ(ierr)

◆ DMlibMeshSetSystem()

PETSC_EXTERN PetscErrorCode DMlibMeshSetSystem ( DM  ,
libMesh::NonlinearImplicitSystem  
)

Any functional implementation of the DMlibMesh API must compose the following functions with the DM object. (See PETSc documentation on PetscObjectComposeFunction(), a polymorphism mechanism.) The following functions are called in PetscNonlinear Solver (others can be called by users): DMlibMeshSetSystem(), DMlibMeshGetSystem()

Any implementation needs to register its creation routine, DMCreate_libMesh, with PETSc using DMRegister().

Definition at line 34 of file petscdmlibmesh.C.

References CHKERRQ(), ierr, and PetscFunctionReturn().

Referenced by libMesh::PetscNonlinearSolver< Number >::init().

35 {
36  PetscErrorCode (*f)(DM,libMesh::NonlinearImplicitSystem &) = nullptr;
37  PetscErrorCode ierr;
38 
39  PetscFunctionBegin;
40  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
41 #if PETSC_RELEASE_LESS_THAN(3,4,0)
42  ierr = PetscObjectQueryFunction((PetscObject)dm,"DMlibMeshSetSystem_C",(PetscVoidFunction*)&f);CHKERRQ(ierr);
43 #else
44  ierr = PetscObjectQueryFunction((PetscObject)dm,"DMlibMeshSetSystem_C",&f);CHKERRQ(ierr);
45 #endif
46  if (!f) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "DM has no implementation for DMlibMeshSetSystem");
47  ierr = (*f)(dm,sys);CHKERRQ(ierr);
49 }
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
PetscErrorCode ierr
PetscFunctionReturn(0)
CHKERRQ(ierr)