120cf1dd8SToby Isaac #include <petsc/private/petscfeimpl.h> /*I "petscfe.h" I*/ 220cf1dd8SToby Isaac #include <petscdmshell.h> 320cf1dd8SToby Isaac 420cf1dd8SToby Isaac PetscClassId PETSCSPACE_CLASSID = 0; 520cf1dd8SToby Isaac 620cf1dd8SToby Isaac PetscFunctionList PetscSpaceList = NULL; 720cf1dd8SToby Isaac PetscBool PetscSpaceRegisterAllCalled = PETSC_FALSE; 820cf1dd8SToby Isaac 920cf1dd8SToby Isaac /*@C 1020cf1dd8SToby Isaac PetscSpaceRegister - Adds a new PetscSpace implementation 1120cf1dd8SToby Isaac 1220cf1dd8SToby Isaac Not Collective 1320cf1dd8SToby Isaac 1420cf1dd8SToby Isaac Input Parameters: 1520cf1dd8SToby Isaac + name - The name of a new user-defined creation routine 1620cf1dd8SToby Isaac - create_func - The creation routine for the implementation type 1720cf1dd8SToby Isaac 1820cf1dd8SToby Isaac Notes: 1920cf1dd8SToby Isaac PetscSpaceRegister() may be called multiple times to add several user-defined types of PetscSpaces. The creation function is called 2020cf1dd8SToby Isaac when the type is set to 'name'. 2120cf1dd8SToby Isaac 2220cf1dd8SToby Isaac Sample usage: 2320cf1dd8SToby Isaac .vb 2420cf1dd8SToby Isaac PetscSpaceRegister("my_space", MyPetscSpaceCreate); 2520cf1dd8SToby Isaac .ve 2620cf1dd8SToby Isaac 2720cf1dd8SToby Isaac Then, your PetscSpace type can be chosen with the procedural interface via 2820cf1dd8SToby Isaac .vb 2920cf1dd8SToby Isaac PetscSpaceCreate(MPI_Comm, PetscSpace *); 3020cf1dd8SToby Isaac PetscSpaceSetType(PetscSpace, "my_space"); 3120cf1dd8SToby Isaac .ve 3220cf1dd8SToby Isaac or at runtime via the option 3320cf1dd8SToby Isaac .vb 3420cf1dd8SToby Isaac -petscspace_type my_space 3520cf1dd8SToby Isaac .ve 3620cf1dd8SToby Isaac 3720cf1dd8SToby Isaac Level: advanced 3820cf1dd8SToby Isaac 39db781477SPatrick Sanan .seealso: `PetscSpaceRegisterAll()`, `PetscSpaceRegisterDestroy()` 4020cf1dd8SToby Isaac 4120cf1dd8SToby Isaac @*/ 429371c9d4SSatish Balay PetscErrorCode PetscSpaceRegister(const char sname[], PetscErrorCode (*function)(PetscSpace)) { 4320cf1dd8SToby Isaac PetscFunctionBegin; 449566063dSJacob Faibussowitsch PetscCall(PetscFunctionListAdd(&PetscSpaceList, sname, function)); 4520cf1dd8SToby Isaac PetscFunctionReturn(0); 4620cf1dd8SToby Isaac } 4720cf1dd8SToby Isaac 4820cf1dd8SToby Isaac /*@C 4920cf1dd8SToby Isaac PetscSpaceSetType - Builds a particular PetscSpace 5020cf1dd8SToby Isaac 51d083f849SBarry Smith Collective on sp 5220cf1dd8SToby Isaac 5320cf1dd8SToby Isaac Input Parameters: 5420cf1dd8SToby Isaac + sp - The PetscSpace object 5520cf1dd8SToby Isaac - name - The kind of space 5620cf1dd8SToby Isaac 5720cf1dd8SToby Isaac Options Database Key: 5820cf1dd8SToby Isaac . -petscspace_type <type> - Sets the PetscSpace type; use -help for a list of available types 5920cf1dd8SToby Isaac 6020cf1dd8SToby Isaac Level: intermediate 6120cf1dd8SToby Isaac 62db781477SPatrick Sanan .seealso: `PetscSpaceGetType()`, `PetscSpaceCreate()` 6320cf1dd8SToby Isaac @*/ 649371c9d4SSatish Balay PetscErrorCode PetscSpaceSetType(PetscSpace sp, PetscSpaceType name) { 6520cf1dd8SToby Isaac PetscErrorCode (*r)(PetscSpace); 6620cf1dd8SToby Isaac PetscBool match; 6720cf1dd8SToby Isaac 6820cf1dd8SToby Isaac PetscFunctionBegin; 6920cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 709566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject)sp, name, &match)); 7120cf1dd8SToby Isaac if (match) PetscFunctionReturn(0); 7220cf1dd8SToby Isaac 739566063dSJacob Faibussowitsch PetscCall(PetscSpaceRegisterAll()); 749566063dSJacob Faibussowitsch PetscCall(PetscFunctionListFind(PetscSpaceList, name, &r)); 752c71b3e2SJacob Faibussowitsch PetscCheck(r, PetscObjectComm((PetscObject)sp), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscSpace type: %s", name); 7620cf1dd8SToby Isaac 77dbbe0bcdSBarry Smith PetscTryTypeMethod(sp, destroy); 7820cf1dd8SToby Isaac sp->ops->destroy = NULL; 79dbbe0bcdSBarry Smith 8043bfef1cSToby Isaac sp->dim = PETSC_DETERMINE; 819566063dSJacob Faibussowitsch PetscCall((*r)(sp)); 829566063dSJacob Faibussowitsch PetscCall(PetscObjectChangeTypeName((PetscObject)sp, name)); 8320cf1dd8SToby Isaac PetscFunctionReturn(0); 8420cf1dd8SToby Isaac } 8520cf1dd8SToby Isaac 8620cf1dd8SToby Isaac /*@C 8720cf1dd8SToby Isaac PetscSpaceGetType - Gets the PetscSpace type name (as a string) from the object. 8820cf1dd8SToby Isaac 8920cf1dd8SToby Isaac Not Collective 9020cf1dd8SToby Isaac 9120cf1dd8SToby Isaac Input Parameter: 9220cf1dd8SToby Isaac . sp - The PetscSpace 9320cf1dd8SToby Isaac 9420cf1dd8SToby Isaac Output Parameter: 9520cf1dd8SToby Isaac . name - The PetscSpace type name 9620cf1dd8SToby Isaac 9720cf1dd8SToby Isaac Level: intermediate 9820cf1dd8SToby Isaac 99db781477SPatrick Sanan .seealso: `PetscSpaceSetType()`, `PetscSpaceCreate()` 10020cf1dd8SToby Isaac @*/ 1019371c9d4SSatish Balay PetscErrorCode PetscSpaceGetType(PetscSpace sp, PetscSpaceType *name) { 10220cf1dd8SToby Isaac PetscFunctionBegin; 10320cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 10420cf1dd8SToby Isaac PetscValidPointer(name, 2); 105*48a46eb9SPierre Jolivet if (!PetscSpaceRegisterAllCalled) PetscCall(PetscSpaceRegisterAll()); 10620cf1dd8SToby Isaac *name = ((PetscObject)sp)->type_name; 10720cf1dd8SToby Isaac PetscFunctionReturn(0); 10820cf1dd8SToby Isaac } 10920cf1dd8SToby Isaac 11020cf1dd8SToby Isaac /*@C 111fe2efc57SMark PetscSpaceViewFromOptions - View from Options 112fe2efc57SMark 113fe2efc57SMark Collective on PetscSpace 114fe2efc57SMark 115fe2efc57SMark Input Parameters: 116fe2efc57SMark + A - the PetscSpace object 117736c3998SJose E. Roman . obj - Optional object 118736c3998SJose E. Roman - name - command line option 119fe2efc57SMark 120fe2efc57SMark Level: intermediate 121db781477SPatrick Sanan .seealso: `PetscSpace`, `PetscSpaceView`, `PetscObjectViewFromOptions()`, `PetscSpaceCreate()` 122fe2efc57SMark @*/ 1239371c9d4SSatish Balay PetscErrorCode PetscSpaceViewFromOptions(PetscSpace A, PetscObject obj, const char name[]) { 124fe2efc57SMark PetscFunctionBegin; 125fe2efc57SMark PetscValidHeaderSpecific(A, PETSCSPACE_CLASSID, 1); 1269566063dSJacob Faibussowitsch PetscCall(PetscObjectViewFromOptions((PetscObject)A, obj, name)); 127fe2efc57SMark PetscFunctionReturn(0); 128fe2efc57SMark } 129fe2efc57SMark 130fe2efc57SMark /*@C 13120cf1dd8SToby Isaac PetscSpaceView - Views a PetscSpace 13220cf1dd8SToby Isaac 133d083f849SBarry Smith Collective on sp 13420cf1dd8SToby Isaac 135d8d19677SJose E. Roman Input Parameters: 13620cf1dd8SToby Isaac + sp - the PetscSpace object to view 13720cf1dd8SToby Isaac - v - the viewer 13820cf1dd8SToby Isaac 13929b5c115SMatthew G. Knepley Level: beginner 14020cf1dd8SToby Isaac 141db781477SPatrick Sanan .seealso `PetscSpaceDestroy()` 14220cf1dd8SToby Isaac @*/ 1439371c9d4SSatish Balay PetscErrorCode PetscSpaceView(PetscSpace sp, PetscViewer v) { 1440aec8e07SMatthew G. Knepley PetscInt pdim; 14520cf1dd8SToby Isaac PetscBool iascii; 14620cf1dd8SToby Isaac 14720cf1dd8SToby Isaac PetscFunctionBegin; 14820cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 14920cf1dd8SToby Isaac if (v) PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2); 1509566063dSJacob Faibussowitsch if (!v) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)sp), &v)); 1519566063dSJacob Faibussowitsch PetscCall(PetscSpaceGetDimension(sp, &pdim)); 1529566063dSJacob Faibussowitsch PetscCall(PetscObjectPrintClassNamePrefixType((PetscObject)sp, v)); 1539566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject)v, PETSCVIEWERASCII, &iascii)); 1549566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(v)); 15563a3b9bcSJacob Faibussowitsch if (iascii) PetscCall(PetscViewerASCIIPrintf(v, "Space in %" PetscInt_FMT " variables with %" PetscInt_FMT " components, size %" PetscInt_FMT "\n", sp->Nv, sp->Nc, pdim)); 156dbbe0bcdSBarry Smith PetscTryTypeMethod(sp, view, v); 1579566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(v)); 15820cf1dd8SToby Isaac PetscFunctionReturn(0); 15920cf1dd8SToby Isaac } 16020cf1dd8SToby Isaac 16120cf1dd8SToby Isaac /*@ 16220cf1dd8SToby Isaac PetscSpaceSetFromOptions - sets parameters in a PetscSpace from the options database 16320cf1dd8SToby Isaac 164d083f849SBarry Smith Collective on sp 16520cf1dd8SToby Isaac 16620cf1dd8SToby Isaac Input Parameter: 16720cf1dd8SToby Isaac . sp - the PetscSpace object to set options for 16820cf1dd8SToby Isaac 16920cf1dd8SToby Isaac Options Database: 1708f2aacc6SMatthew G. Knepley + -petscspace_degree <deg> - the approximation order of the space 1718f2aacc6SMatthew G. Knepley . -petscspace_variables <n> - the number of different variables, e.g. x and y 1728f2aacc6SMatthew G. Knepley - -petscspace_components <c> - the number of components, say d for a vector field 17320cf1dd8SToby Isaac 17429b5c115SMatthew G. Knepley Level: intermediate 17520cf1dd8SToby Isaac 176db781477SPatrick Sanan .seealso `PetscSpaceView()` 17720cf1dd8SToby Isaac @*/ 1789371c9d4SSatish Balay PetscErrorCode PetscSpaceSetFromOptions(PetscSpace sp) { 17920cf1dd8SToby Isaac const char *defaultType; 18020cf1dd8SToby Isaac char name[256]; 1815a856986SBarry Smith PetscBool flg; 18220cf1dd8SToby Isaac 18320cf1dd8SToby Isaac PetscFunctionBegin; 18420cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 18520cf1dd8SToby Isaac if (!((PetscObject)sp)->type_name) { 18620cf1dd8SToby Isaac defaultType = PETSCSPACEPOLYNOMIAL; 18720cf1dd8SToby Isaac } else { 18820cf1dd8SToby Isaac defaultType = ((PetscObject)sp)->type_name; 18920cf1dd8SToby Isaac } 1909566063dSJacob Faibussowitsch if (!PetscSpaceRegisterAllCalled) PetscCall(PetscSpaceRegisterAll()); 19120cf1dd8SToby Isaac 192d0609cedSBarry Smith PetscObjectOptionsBegin((PetscObject)sp); 1939566063dSJacob Faibussowitsch PetscCall(PetscOptionsFList("-petscspace_type", "Linear space", "PetscSpaceSetType", PetscSpaceList, defaultType, name, 256, &flg)); 19420cf1dd8SToby Isaac if (flg) { 1959566063dSJacob Faibussowitsch PetscCall(PetscSpaceSetType(sp, name)); 19620cf1dd8SToby Isaac } else if (!((PetscObject)sp)->type_name) { 1979566063dSJacob Faibussowitsch PetscCall(PetscSpaceSetType(sp, defaultType)); 19820cf1dd8SToby Isaac } 1997be5e748SToby Isaac { 2009566063dSJacob Faibussowitsch PetscCall(PetscOptionsDeprecated("-petscspace_order", "-petscspace_degree", "3.11", NULL)); 2019566063dSJacob Faibussowitsch PetscCall(PetscOptionsBoundedInt("-petscspace_order", "DEPRECATED: The approximation order", "PetscSpaceSetDegree", sp->degree, &sp->degree, NULL, 0)); 2027be5e748SToby Isaac } 2039566063dSJacob Faibussowitsch PetscCall(PetscOptionsBoundedInt("-petscspace_degree", "The (maximally included) polynomial degree", "PetscSpaceSetDegree", sp->degree, &sp->degree, NULL, 0)); 2049566063dSJacob Faibussowitsch PetscCall(PetscOptionsBoundedInt("-petscspace_variables", "The number of different variables, e.g. x and y", "PetscSpaceSetNumVariables", sp->Nv, &sp->Nv, NULL, 0)); 2059566063dSJacob Faibussowitsch PetscCall(PetscOptionsBoundedInt("-petscspace_components", "The number of components", "PetscSpaceSetNumComponents", sp->Nc, &sp->Nc, NULL, 0)); 206dbbe0bcdSBarry Smith PetscTryTypeMethod(sp, setfromoptions, PetscOptionsObject); 20720cf1dd8SToby Isaac /* process any options handlers added with PetscObjectAddOptionsHandler() */ 208dbbe0bcdSBarry Smith PetscCall(PetscObjectProcessOptionsHandlers((PetscObject)sp, PetscOptionsObject)); 209d0609cedSBarry Smith PetscOptionsEnd(); 2109566063dSJacob Faibussowitsch PetscCall(PetscSpaceViewFromOptions(sp, NULL, "-petscspace_view")); 21120cf1dd8SToby Isaac PetscFunctionReturn(0); 21220cf1dd8SToby Isaac } 21320cf1dd8SToby Isaac 21420cf1dd8SToby Isaac /*@C 21520cf1dd8SToby Isaac PetscSpaceSetUp - Construct data structures for the PetscSpace 21620cf1dd8SToby Isaac 217d083f849SBarry Smith Collective on sp 21820cf1dd8SToby Isaac 21920cf1dd8SToby Isaac Input Parameter: 22020cf1dd8SToby Isaac . sp - the PetscSpace object to setup 22120cf1dd8SToby Isaac 22229b5c115SMatthew G. Knepley Level: intermediate 22320cf1dd8SToby Isaac 224db781477SPatrick Sanan .seealso `PetscSpaceView()`, `PetscSpaceDestroy()` 22520cf1dd8SToby Isaac @*/ 2269371c9d4SSatish Balay PetscErrorCode PetscSpaceSetUp(PetscSpace sp) { 22720cf1dd8SToby Isaac PetscFunctionBegin; 22820cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 229dbbe0bcdSBarry Smith PetscTryTypeMethod(sp, setup); 23020cf1dd8SToby Isaac PetscFunctionReturn(0); 23120cf1dd8SToby Isaac } 23220cf1dd8SToby Isaac 23320cf1dd8SToby Isaac /*@ 23420cf1dd8SToby Isaac PetscSpaceDestroy - Destroys a PetscSpace object 23520cf1dd8SToby Isaac 236d083f849SBarry Smith Collective on sp 23720cf1dd8SToby Isaac 23820cf1dd8SToby Isaac Input Parameter: 23920cf1dd8SToby Isaac . sp - the PetscSpace object to destroy 24020cf1dd8SToby Isaac 24129b5c115SMatthew G. Knepley Level: beginner 24220cf1dd8SToby Isaac 243db781477SPatrick Sanan .seealso `PetscSpaceView()` 24420cf1dd8SToby Isaac @*/ 2459371c9d4SSatish Balay PetscErrorCode PetscSpaceDestroy(PetscSpace *sp) { 24620cf1dd8SToby Isaac PetscFunctionBegin; 24720cf1dd8SToby Isaac if (!*sp) PetscFunctionReturn(0); 24820cf1dd8SToby Isaac PetscValidHeaderSpecific((*sp), PETSCSPACE_CLASSID, 1); 24920cf1dd8SToby Isaac 2509371c9d4SSatish Balay if (--((PetscObject)(*sp))->refct > 0) { 2519371c9d4SSatish Balay *sp = NULL; 2529371c9d4SSatish Balay PetscFunctionReturn(0); 2539371c9d4SSatish Balay } 25420cf1dd8SToby Isaac ((PetscObject)(*sp))->refct = 0; 2559566063dSJacob Faibussowitsch PetscCall(DMDestroy(&(*sp)->dm)); 25620cf1dd8SToby Isaac 2579566063dSJacob Faibussowitsch PetscCall((*(*sp)->ops->destroy)(*sp)); 2589566063dSJacob Faibussowitsch PetscCall(PetscHeaderDestroy(sp)); 25920cf1dd8SToby Isaac PetscFunctionReturn(0); 26020cf1dd8SToby Isaac } 26120cf1dd8SToby Isaac 26220cf1dd8SToby Isaac /*@ 26320cf1dd8SToby Isaac PetscSpaceCreate - Creates an empty PetscSpace object. The type can then be set with PetscSpaceSetType(). 26420cf1dd8SToby Isaac 265d083f849SBarry Smith Collective 26620cf1dd8SToby Isaac 26720cf1dd8SToby Isaac Input Parameter: 26820cf1dd8SToby Isaac . comm - The communicator for the PetscSpace object 26920cf1dd8SToby Isaac 27020cf1dd8SToby Isaac Output Parameter: 27120cf1dd8SToby Isaac . sp - The PetscSpace object 27220cf1dd8SToby Isaac 27320cf1dd8SToby Isaac Level: beginner 27420cf1dd8SToby Isaac 275db781477SPatrick Sanan .seealso: `PetscSpaceSetType()`, `PETSCSPACEPOLYNOMIAL` 27620cf1dd8SToby Isaac @*/ 2779371c9d4SSatish Balay PetscErrorCode PetscSpaceCreate(MPI_Comm comm, PetscSpace *sp) { 27820cf1dd8SToby Isaac PetscSpace s; 27920cf1dd8SToby Isaac 28020cf1dd8SToby Isaac PetscFunctionBegin; 28120cf1dd8SToby Isaac PetscValidPointer(sp, 2); 2829566063dSJacob Faibussowitsch PetscCall(PetscCitationsRegister(FECitation, &FEcite)); 28320cf1dd8SToby Isaac *sp = NULL; 2849566063dSJacob Faibussowitsch PetscCall(PetscFEInitializePackage()); 28520cf1dd8SToby Isaac 2869566063dSJacob Faibussowitsch PetscCall(PetscHeaderCreate(s, PETSCSPACE_CLASSID, "PetscSpace", "Linear Space", "PetscSpace", comm, PetscSpaceDestroy, PetscSpaceView)); 28720cf1dd8SToby Isaac 28820cf1dd8SToby Isaac s->degree = 0; 28943bfef1cSToby Isaac s->maxDegree = PETSC_DETERMINE; 29020cf1dd8SToby Isaac s->Nc = 1; 29120cf1dd8SToby Isaac s->Nv = 0; 29243bfef1cSToby Isaac s->dim = PETSC_DETERMINE; 2939566063dSJacob Faibussowitsch PetscCall(DMShellCreate(comm, &s->dm)); 2949566063dSJacob Faibussowitsch PetscCall(PetscSpaceSetType(s, PETSCSPACEPOLYNOMIAL)); 29520cf1dd8SToby Isaac 29620cf1dd8SToby Isaac *sp = s; 29720cf1dd8SToby Isaac PetscFunctionReturn(0); 29820cf1dd8SToby Isaac } 29920cf1dd8SToby Isaac 30020cf1dd8SToby Isaac /*@ 30120cf1dd8SToby Isaac PetscSpaceGetDimension - Return the dimension of this space, i.e. the number of basis vectors 30220cf1dd8SToby Isaac 30320cf1dd8SToby Isaac Input Parameter: 30420cf1dd8SToby Isaac . sp - The PetscSpace 30520cf1dd8SToby Isaac 30620cf1dd8SToby Isaac Output Parameter: 30720cf1dd8SToby Isaac . dim - The dimension 30820cf1dd8SToby Isaac 30920cf1dd8SToby Isaac Level: intermediate 31020cf1dd8SToby Isaac 311db781477SPatrick Sanan .seealso: `PetscSpaceGetDegree()`, `PetscSpaceCreate()`, `PetscSpace` 31220cf1dd8SToby Isaac @*/ 3139371c9d4SSatish Balay PetscErrorCode PetscSpaceGetDimension(PetscSpace sp, PetscInt *dim) { 31420cf1dd8SToby Isaac PetscFunctionBegin; 31520cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 316dadcf809SJacob Faibussowitsch PetscValidIntPointer(dim, 2); 3179371c9d4SSatish Balay if (sp->dim == PETSC_DETERMINE) { PetscTryTypeMethod(sp, getdimension, &sp->dim); } 31843bfef1cSToby Isaac *dim = sp->dim; 31920cf1dd8SToby Isaac PetscFunctionReturn(0); 32020cf1dd8SToby Isaac } 32120cf1dd8SToby Isaac 32220cf1dd8SToby Isaac /*@ 32320cf1dd8SToby Isaac PetscSpaceGetDegree - Return the polynomial degrees that characterize this space 32420cf1dd8SToby Isaac 32520cf1dd8SToby Isaac Input Parameter: 32620cf1dd8SToby Isaac . sp - The PetscSpace 32720cf1dd8SToby Isaac 328d8d19677SJose E. Roman Output Parameters: 32920cf1dd8SToby Isaac + minDegree - The degree of the largest polynomial space contained in the space 33020cf1dd8SToby Isaac - maxDegree - The degree of the smallest polynomial space containing the space 33120cf1dd8SToby Isaac 33220cf1dd8SToby Isaac Level: intermediate 33320cf1dd8SToby Isaac 334db781477SPatrick Sanan .seealso: `PetscSpaceSetDegree()`, `PetscSpaceGetDimension()`, `PetscSpaceCreate()`, `PetscSpace` 33520cf1dd8SToby Isaac @*/ 3369371c9d4SSatish Balay PetscErrorCode PetscSpaceGetDegree(PetscSpace sp, PetscInt *minDegree, PetscInt *maxDegree) { 33720cf1dd8SToby Isaac PetscFunctionBegin; 33820cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 339dadcf809SJacob Faibussowitsch if (minDegree) PetscValidIntPointer(minDegree, 2); 340dadcf809SJacob Faibussowitsch if (maxDegree) PetscValidIntPointer(maxDegree, 3); 34120cf1dd8SToby Isaac if (minDegree) *minDegree = sp->degree; 342f5a02b64SToby Isaac if (maxDegree) *maxDegree = sp->maxDegree; 34320cf1dd8SToby Isaac PetscFunctionReturn(0); 34420cf1dd8SToby Isaac } 34520cf1dd8SToby Isaac 34620cf1dd8SToby Isaac /*@ 34720cf1dd8SToby Isaac PetscSpaceSetDegree - Set the degree of approximation for this space. 34820cf1dd8SToby Isaac 34920cf1dd8SToby Isaac Input Parameters: 35020cf1dd8SToby Isaac + sp - The PetscSpace 351d39dd5f5SToby Isaac . degree - The degree of the largest polynomial space contained in the space 352d39dd5f5SToby Isaac - maxDegree - The degree of the largest polynomial space containing the space. One of degree and maxDegree can be PETSC_DETERMINE. 35320cf1dd8SToby Isaac 35420cf1dd8SToby Isaac Level: intermediate 35520cf1dd8SToby Isaac 356db781477SPatrick Sanan .seealso: `PetscSpaceGetDegree()`, `PetscSpaceCreate()`, `PetscSpace` 35720cf1dd8SToby Isaac @*/ 3589371c9d4SSatish Balay PetscErrorCode PetscSpaceSetDegree(PetscSpace sp, PetscInt degree, PetscInt maxDegree) { 35920cf1dd8SToby Isaac PetscFunctionBegin; 36020cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 361d39dd5f5SToby Isaac sp->degree = degree; 362d39dd5f5SToby Isaac sp->maxDegree = maxDegree; 36320cf1dd8SToby Isaac PetscFunctionReturn(0); 36420cf1dd8SToby Isaac } 36520cf1dd8SToby Isaac 36620cf1dd8SToby Isaac /*@ 36720cf1dd8SToby Isaac PetscSpaceGetNumComponents - Return the number of components for this space 36820cf1dd8SToby Isaac 36920cf1dd8SToby Isaac Input Parameter: 37020cf1dd8SToby Isaac . sp - The PetscSpace 37120cf1dd8SToby Isaac 37220cf1dd8SToby Isaac Output Parameter: 37320cf1dd8SToby Isaac . Nc - The number of components 37420cf1dd8SToby Isaac 37520cf1dd8SToby Isaac Note: A vector space, for example, will have d components, where d is the spatial dimension 37620cf1dd8SToby Isaac 37720cf1dd8SToby Isaac Level: intermediate 37820cf1dd8SToby Isaac 379db781477SPatrick Sanan .seealso: `PetscSpaceSetNumComponents()`, `PetscSpaceGetNumVariables()`, `PetscSpaceGetDimension()`, `PetscSpaceCreate()`, `PetscSpace` 38020cf1dd8SToby Isaac @*/ 3819371c9d4SSatish Balay PetscErrorCode PetscSpaceGetNumComponents(PetscSpace sp, PetscInt *Nc) { 38220cf1dd8SToby Isaac PetscFunctionBegin; 38320cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 384dadcf809SJacob Faibussowitsch PetscValidIntPointer(Nc, 2); 38520cf1dd8SToby Isaac *Nc = sp->Nc; 38620cf1dd8SToby Isaac PetscFunctionReturn(0); 38720cf1dd8SToby Isaac } 38820cf1dd8SToby Isaac 38920cf1dd8SToby Isaac /*@ 39020cf1dd8SToby Isaac PetscSpaceSetNumComponents - Set the number of components for this space 39120cf1dd8SToby Isaac 39220cf1dd8SToby Isaac Input Parameters: 39320cf1dd8SToby Isaac + sp - The PetscSpace 39420cf1dd8SToby Isaac - order - The number of components 39520cf1dd8SToby Isaac 39620cf1dd8SToby Isaac Level: intermediate 39720cf1dd8SToby Isaac 398db781477SPatrick Sanan .seealso: `PetscSpaceGetNumComponents()`, `PetscSpaceSetNumVariables()`, `PetscSpaceCreate()`, `PetscSpace` 39920cf1dd8SToby Isaac @*/ 4009371c9d4SSatish Balay PetscErrorCode PetscSpaceSetNumComponents(PetscSpace sp, PetscInt Nc) { 40120cf1dd8SToby Isaac PetscFunctionBegin; 40220cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 40320cf1dd8SToby Isaac sp->Nc = Nc; 40420cf1dd8SToby Isaac PetscFunctionReturn(0); 40520cf1dd8SToby Isaac } 40620cf1dd8SToby Isaac 40729b5c115SMatthew G. Knepley /*@ 40829b5c115SMatthew G. Knepley PetscSpaceSetNumVariables - Set the number of variables for this space 40929b5c115SMatthew G. Knepley 41029b5c115SMatthew G. Knepley Input Parameters: 41129b5c115SMatthew G. Knepley + sp - The PetscSpace 41229b5c115SMatthew G. Knepley - n - The number of variables, e.g. x, y, z... 41329b5c115SMatthew G. Knepley 41429b5c115SMatthew G. Knepley Level: intermediate 41529b5c115SMatthew G. Knepley 416db781477SPatrick Sanan .seealso: `PetscSpaceGetNumVariables()`, `PetscSpaceSetNumComponents()`, `PetscSpaceCreate()`, `PetscSpace` 41729b5c115SMatthew G. Knepley @*/ 4189371c9d4SSatish Balay PetscErrorCode PetscSpaceSetNumVariables(PetscSpace sp, PetscInt n) { 41920cf1dd8SToby Isaac PetscFunctionBegin; 42020cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 42120cf1dd8SToby Isaac sp->Nv = n; 42220cf1dd8SToby Isaac PetscFunctionReturn(0); 42320cf1dd8SToby Isaac } 42420cf1dd8SToby Isaac 42529b5c115SMatthew G. Knepley /*@ 42629b5c115SMatthew G. Knepley PetscSpaceGetNumVariables - Return the number of variables for this space 42729b5c115SMatthew G. Knepley 42829b5c115SMatthew G. Knepley Input Parameter: 42929b5c115SMatthew G. Knepley . sp - The PetscSpace 43029b5c115SMatthew G. Knepley 43129b5c115SMatthew G. Knepley Output Parameter: 43229b5c115SMatthew G. Knepley . Nc - The number of variables, e.g. x, y, z... 43329b5c115SMatthew G. Knepley 43429b5c115SMatthew G. Knepley Level: intermediate 43529b5c115SMatthew G. Knepley 436db781477SPatrick Sanan .seealso: `PetscSpaceSetNumVariables()`, `PetscSpaceGetNumComponents()`, `PetscSpaceGetDimension()`, `PetscSpaceCreate()`, `PetscSpace` 43729b5c115SMatthew G. Knepley @*/ 4389371c9d4SSatish Balay PetscErrorCode PetscSpaceGetNumVariables(PetscSpace sp, PetscInt *n) { 43920cf1dd8SToby Isaac PetscFunctionBegin; 44020cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 441dadcf809SJacob Faibussowitsch PetscValidIntPointer(n, 2); 44220cf1dd8SToby Isaac *n = sp->Nv; 44320cf1dd8SToby Isaac PetscFunctionReturn(0); 44420cf1dd8SToby Isaac } 44520cf1dd8SToby Isaac 44620cf1dd8SToby Isaac /*@C 44720cf1dd8SToby Isaac PetscSpaceEvaluate - Evaluate the basis functions and their derivatives (jet) at each point 44820cf1dd8SToby Isaac 44920cf1dd8SToby Isaac Input Parameters: 45020cf1dd8SToby Isaac + sp - The PetscSpace 45120cf1dd8SToby Isaac . npoints - The number of evaluation points, in reference coordinates 45220cf1dd8SToby Isaac - points - The point coordinates 45320cf1dd8SToby Isaac 45420cf1dd8SToby Isaac Output Parameters: 45520cf1dd8SToby Isaac + B - The function evaluations in a npoints x nfuncs array 45620cf1dd8SToby Isaac . D - The derivative evaluations in a npoints x nfuncs x dim array 45720cf1dd8SToby Isaac - H - The second derivative evaluations in a npoints x nfuncs x dim x dim array 45820cf1dd8SToby Isaac 45920cf1dd8SToby Isaac Note: Above nfuncs is the dimension of the space, and dim is the spatial dimension. The coordinates are given 46020cf1dd8SToby Isaac on the reference cell, not in real space. 46120cf1dd8SToby Isaac 46229b5c115SMatthew G. Knepley Level: beginner 46320cf1dd8SToby Isaac 464db781477SPatrick Sanan .seealso: `PetscFECreateTabulation()`, `PetscFEGetCellTabulation()`, `PetscSpaceCreate()` 46520cf1dd8SToby Isaac @*/ 4669371c9d4SSatish Balay PetscErrorCode PetscSpaceEvaluate(PetscSpace sp, PetscInt npoints, const PetscReal points[], PetscReal B[], PetscReal D[], PetscReal H[]) { 46720cf1dd8SToby Isaac PetscFunctionBegin; 46820cf1dd8SToby Isaac if (!npoints) PetscFunctionReturn(0); 46920cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 470dadcf809SJacob Faibussowitsch if (sp->Nv) PetscValidRealPointer(points, 3); 471dadcf809SJacob Faibussowitsch if (B) PetscValidRealPointer(B, 4); 472dadcf809SJacob Faibussowitsch if (D) PetscValidRealPointer(D, 5); 473dadcf809SJacob Faibussowitsch if (H) PetscValidRealPointer(H, 6); 474dbbe0bcdSBarry Smith PetscTryTypeMethod(sp, evaluate, npoints, points, B, D, H); 47520cf1dd8SToby Isaac PetscFunctionReturn(0); 47620cf1dd8SToby Isaac } 47720cf1dd8SToby Isaac 47820cf1dd8SToby Isaac /*@ 47920cf1dd8SToby Isaac PetscSpaceGetHeightSubspace - Get the subset of the primal space basis that is supported on a mesh point of a given height. 48020cf1dd8SToby Isaac 48120cf1dd8SToby Isaac If the space is not defined on mesh points of the given height (e.g. if the space is discontinuous and 48220cf1dd8SToby Isaac pointwise values are not defined on the element boundaries), or if the implementation of PetscSpace does not 48320cf1dd8SToby Isaac support extracting subspaces, then NULL is returned. 48420cf1dd8SToby Isaac 48520cf1dd8SToby Isaac This does not increment the reference count on the returned space, and the user should not destroy it. 48620cf1dd8SToby Isaac 48720cf1dd8SToby Isaac Not collective 48820cf1dd8SToby Isaac 48920cf1dd8SToby Isaac Input Parameters: 49020cf1dd8SToby Isaac + sp - the PetscSpace object 49120cf1dd8SToby Isaac - height - the height of the mesh point for which the subspace is desired 49220cf1dd8SToby Isaac 49320cf1dd8SToby Isaac Output Parameter: 49420cf1dd8SToby Isaac . subsp - the subspace 49520cf1dd8SToby Isaac 49620cf1dd8SToby Isaac Level: advanced 49720cf1dd8SToby Isaac 498db781477SPatrick Sanan .seealso: `PetscDualSpaceGetHeightSubspace()`, `PetscSpace` 49920cf1dd8SToby Isaac @*/ 5009371c9d4SSatish Balay PetscErrorCode PetscSpaceGetHeightSubspace(PetscSpace sp, PetscInt height, PetscSpace *subsp) { 50120cf1dd8SToby Isaac PetscFunctionBegin; 50220cf1dd8SToby Isaac PetscValidHeaderSpecific(sp, PETSCSPACE_CLASSID, 1); 50320cf1dd8SToby Isaac PetscValidPointer(subsp, 3); 50420cf1dd8SToby Isaac *subsp = NULL; 505dbbe0bcdSBarry Smith PetscTryTypeMethod(sp, getheightsubspace, height, subsp); 50620cf1dd8SToby Isaac PetscFunctionReturn(0); 50720cf1dd8SToby Isaac } 508