1e5c89e4eSSatish Balay #define PETSC_DLL 2e5c89e4eSSatish Balay /* 3e5c89e4eSSatish Balay Provides utility routines for manulating any type of PETSc object. 4e5c89e4eSSatish Balay */ 5e5c89e4eSSatish Balay #include "petsc.h" /*I "petsc.h" I*/ 6e5c89e4eSSatish Balay 7e5c89e4eSSatish Balay #undef __FUNCT__ 8e5c89e4eSSatish Balay #define __FUNCT__ "PetscObjectGetComm" 9e5c89e4eSSatish Balay /*@C 10e5c89e4eSSatish Balay PetscObjectGetComm - Gets the MPI communicator for any PetscObject, 11e5c89e4eSSatish Balay regardless of the type. 12e5c89e4eSSatish Balay 13e5c89e4eSSatish Balay Not Collective 14e5c89e4eSSatish Balay 15e5c89e4eSSatish Balay Input Parameter: 16e5c89e4eSSatish Balay . obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be 17e5c89e4eSSatish Balay cast with a (PetscObject), for example, 18e5c89e4eSSatish Balay PetscObjectGetComm((PetscObject)mat,&comm); 19e5c89e4eSSatish Balay 20e5c89e4eSSatish Balay Output Parameter: 21e5c89e4eSSatish Balay . comm - the MPI communicator 22e5c89e4eSSatish Balay 23e5c89e4eSSatish Balay Level: advanced 24e5c89e4eSSatish Balay 25e5c89e4eSSatish Balay Concepts: communicator^getting from object 26e5c89e4eSSatish Balay Concepts: MPI communicator^getting from object 27e5c89e4eSSatish Balay 28e5c89e4eSSatish Balay @*/ 29e5c89e4eSSatish Balay PetscErrorCode PETSC_DLLEXPORT PetscObjectGetComm(PetscObject obj,MPI_Comm *comm) 30e5c89e4eSSatish Balay { 31e5c89e4eSSatish Balay PetscErrorCode ierr; 32e5c89e4eSSatish Balay 33e5c89e4eSSatish Balay PetscFunctionBegin; 343cfa8680SLisandro Dalcin PetscValidHeader(obj,1); 353cfa8680SLisandro Dalcin PetscValidPointer(comm,2); 36e5c89e4eSSatish Balay if (obj->bops->getcomm) { 37e5c89e4eSSatish Balay ierr = obj->bops->getcomm(obj,comm);CHKERRQ(ierr); 38e5c89e4eSSatish Balay } else { 39e5c89e4eSSatish Balay *comm = obj->comm; 40e5c89e4eSSatish Balay } 41e5c89e4eSSatish Balay PetscFunctionReturn(0); 42e5c89e4eSSatish Balay } 43e5c89e4eSSatish Balay 44*1cee3971SBarry Smith #undef __FUNCT__ 45*1cee3971SBarry Smith #define __FUNCT__ "PetscObjectGetTabLevel" 46*1cee3971SBarry Smith /*@C 47*1cee3971SBarry Smith PetscObjectGetTabLevel - Gets the number of tabs that ASCII output for that object use 48e5c89e4eSSatish Balay 49*1cee3971SBarry Smith Not Collective 50*1cee3971SBarry Smith 51*1cee3971SBarry Smith Input Parameter: 52*1cee3971SBarry Smith . obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be 53*1cee3971SBarry Smith cast with a (PetscObject), for example, 54*1cee3971SBarry Smith PetscObjectGetComm((PetscObject)mat,&comm); 55*1cee3971SBarry Smith 56*1cee3971SBarry Smith Output Parameter: 57*1cee3971SBarry Smith . tab - the number of tabs 58*1cee3971SBarry Smith 59*1cee3971SBarry Smith Level: developer 60*1cee3971SBarry Smith 61*1cee3971SBarry Smith Notes: this is used to manage the output from options that are imbedded in other objects. For example 62*1cee3971SBarry Smith the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects 63*1cee3971SBarry Smith is very clear. 64*1cee3971SBarry Smith 65*1cee3971SBarry Smith .seealso: PetscObjectIncrementTabLevel() 66*1cee3971SBarry Smith 67*1cee3971SBarry Smith @*/ 68*1cee3971SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscObjectGetTabLevel(PetscObject obj,PetscInt *tab) 69*1cee3971SBarry Smith { 70*1cee3971SBarry Smith PetscFunctionBegin; 71*1cee3971SBarry Smith PetscValidHeader(obj,1); 72*1cee3971SBarry Smith *tab = obj->tablevel; 73*1cee3971SBarry Smith PetscFunctionReturn(0); 74*1cee3971SBarry Smith } 75*1cee3971SBarry Smith 76*1cee3971SBarry Smith /*@C 77*1cee3971SBarry Smith PetscObjectIncrementTabLevel - Sets the number of tabs that ASCII output for that object use based on 78*1cee3971SBarry Smith the tablevel of another object. This should be called immediately after the object is created. 79*1cee3971SBarry Smith 80*1cee3971SBarry Smith Not Collective 81*1cee3971SBarry Smith 82*1cee3971SBarry Smith Input Parameter: 83*1cee3971SBarry Smith + obj - any PETSc object where we are changing the tab 84*1cee3971SBarry Smith . oldobj - the object providing the tab 85*1cee3971SBarry Smith - tab - the increment that is added to the old objects tab 86*1cee3971SBarry Smith 87*1cee3971SBarry Smith 88*1cee3971SBarry Smith Level: developer 89*1cee3971SBarry Smith 90*1cee3971SBarry Smith Notes: this is used to manage the output from options that are imbedded in other objects. For example 91*1cee3971SBarry Smith the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects 92*1cee3971SBarry Smith is very clear. 93*1cee3971SBarry Smith 94*1cee3971SBarry Smith .seealso: PetscObjectSetLabLevel(), PetscObjectGetTabLevel() 95*1cee3971SBarry Smith 96*1cee3971SBarry Smith @*/ 97*1cee3971SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscObjectIncrementTabLevel(PetscObject obj,PetscObject oldobj,PetscInt tab) 98*1cee3971SBarry Smith { 99*1cee3971SBarry Smith PetscErrorCode ierr; 100*1cee3971SBarry Smith 101*1cee3971SBarry Smith PetscFunctionBegin; 102*1cee3971SBarry Smith PetscValidHeader(obj,1); 103*1cee3971SBarry Smith if (oldobj) { 104*1cee3971SBarry Smith obj->tablevel = oldobj->tablevel + tab; 105*1cee3971SBarry Smith } else { 106*1cee3971SBarry Smith obj->tablevel = tab; 107*1cee3971SBarry Smith } 108*1cee3971SBarry Smith PetscFunctionReturn(0); 109*1cee3971SBarry Smith } 110