1*7d0a6c19SBarry Smith 2e5c89e4eSSatish Balay /* 3e5c89e4eSSatish Balay Provides utility routines for manulating any type of PETSc object. 4e5c89e4eSSatish Balay */ 5d382aafbSBarry Smith #include "petscsys.h" /*I "petscsys.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 @*/ 297087cfbeSBarry Smith PetscErrorCode 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 441cee3971SBarry Smith #undef __FUNCT__ 451cee3971SBarry Smith #define __FUNCT__ "PetscObjectGetTabLevel" 46cbf1b8bfSBarry Smith /*@ 471cee3971SBarry Smith PetscObjectGetTabLevel - Gets the number of tabs that ASCII output for that object use 48e5c89e4eSSatish Balay 491cee3971SBarry Smith Not Collective 501cee3971SBarry Smith 511cee3971SBarry Smith Input Parameter: 521cee3971SBarry Smith . obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be 531cee3971SBarry Smith cast with a (PetscObject), for example, 541cee3971SBarry Smith PetscObjectGetComm((PetscObject)mat,&comm); 551cee3971SBarry Smith 561cee3971SBarry Smith Output Parameter: 571cee3971SBarry Smith . tab - the number of tabs 581cee3971SBarry Smith 591cee3971SBarry Smith Level: developer 601cee3971SBarry Smith 611cee3971SBarry Smith Notes: this is used to manage the output from options that are imbedded in other objects. For example 621cee3971SBarry Smith the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects 631cee3971SBarry Smith is very clear. 641cee3971SBarry Smith 651cee3971SBarry Smith .seealso: PetscObjectIncrementTabLevel() 661cee3971SBarry Smith 671cee3971SBarry Smith @*/ 687087cfbeSBarry Smith PetscErrorCode PetscObjectGetTabLevel(PetscObject obj,PetscInt *tab) 691cee3971SBarry Smith { 701cee3971SBarry Smith PetscFunctionBegin; 711cee3971SBarry Smith PetscValidHeader(obj,1); 721cee3971SBarry Smith *tab = obj->tablevel; 731cee3971SBarry Smith PetscFunctionReturn(0); 741cee3971SBarry Smith } 751cee3971SBarry Smith 7653c77d0aSJed Brown #undef __FUNCT__ 7753c77d0aSJed Brown #define __FUNCT__ "PetscObjectIncrementTabLevel" 78cbf1b8bfSBarry Smith /*@ 791cee3971SBarry Smith PetscObjectIncrementTabLevel - Sets the number of tabs that ASCII output for that object use based on 801cee3971SBarry Smith the tablevel of another object. This should be called immediately after the object is created. 811cee3971SBarry Smith 821cee3971SBarry Smith Not Collective 831cee3971SBarry Smith 841cee3971SBarry Smith Input Parameter: 851cee3971SBarry Smith + obj - any PETSc object where we are changing the tab 861cee3971SBarry Smith . oldobj - the object providing the tab 871cee3971SBarry Smith - tab - the increment that is added to the old objects tab 881cee3971SBarry Smith 891cee3971SBarry Smith 901cee3971SBarry Smith Level: developer 911cee3971SBarry Smith 921cee3971SBarry Smith Notes: this is used to manage the output from options that are imbedded in other objects. For example 931cee3971SBarry Smith the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects 941cee3971SBarry Smith is very clear. 951cee3971SBarry Smith 961cee3971SBarry Smith .seealso: PetscObjectSetLabLevel(), PetscObjectGetTabLevel() 971cee3971SBarry Smith 981cee3971SBarry Smith @*/ 997087cfbeSBarry Smith PetscErrorCode PetscObjectIncrementTabLevel(PetscObject obj,PetscObject oldobj,PetscInt tab) 1001cee3971SBarry Smith { 1011cee3971SBarry Smith 1021cee3971SBarry Smith PetscFunctionBegin; 1031cee3971SBarry Smith PetscValidHeader(obj,1); 1041cee3971SBarry Smith if (oldobj) { 1051cee3971SBarry Smith obj->tablevel = oldobj->tablevel + tab; 1061cee3971SBarry Smith } else { 1071cee3971SBarry Smith obj->tablevel = tab; 1081cee3971SBarry Smith } 1091cee3971SBarry Smith PetscFunctionReturn(0); 1101cee3971SBarry Smith } 111