SALSA Analysis Modules
|
Go to the source code of this file.
Data Structures | |
struct | categoryobject_ |
Defines | |
#define | CATEGORYCOOKIE 983429 |
#define | CHECKVALIDCATEGORY(x) ANAMODCHECKVALID(x,CATEGORYCOOKIE,"category") |
Functions | |
PetscErrorCode | AllocCategoryObjects () |
PetscErrorCode | FreeCategoryObjects () |
PetscErrorCode | CreateCategoryObject (const char *cat, categoryobject *obj) |
PetscErrorCode | DestroyCategoryObject (categoryobject obj) |
static PetscErrorCode | GetCategoryIndex (const char *cat, int *icat, PetscTruth *flag) |
PetscErrorCode | GetOrCreateCategory (const char *cat, categoryobject *catg) |
PetscErrorCode | GetCategory (const char *cat, categoryobject *catg, PetscTruth *f) |
PetscErrorCode | GetCategories (int *ncat, const char ***cats) |
PetscErrorCode | CategoryGetComponentIndex (categoryobject catg, const char *cmp, int *icmp, PetscTruth *flag) |
PetscErrorCode | CategoryGetOrCreateComponent (categoryobject catg, const char *cmp, componentobject *cmpt) |
PetscErrorCode | CategoryGetComponent (categoryobject catg, const char *cmp, componentobject *cmpt, PetscTruth *success) |
PetscErrorCode | CategoryComponentSetModule (const char *cat, const char *cmp, AnalysisDataType type, int id, PetscErrorCode(*f)(AnaModNumericalProblem, AnalysisItem *, int *, PetscTruth *)) |
PetscErrorCode | CategoryGetModules (const char *cat, const char ***ms, AnalysisDataType **t, int **id, int *n) |
PetscErrorCode | GetFirstCategory (const char **rname, PetscTruth *rfound) |
PetscErrorCode | GetNextCategory (const char **rname, PetscTruth *rfound) |
PetscErrorCode | CategoryEnableByName (const char *cat, int mode) |
PetscErrorCode | DeclareCategoryOptionFunction (const char *cat, PetscErrorCode(*f)(char *)) |
PetscErrorCode | CategoryGetOptionFunction (const char *cat, PetscErrorCode(**f)(char *)) |
Variables | |
int | ncategories |
int | maxcategories |
categoryobject * | categoryobjects |
const char ** | categorynames |
static int | categoryreadout = -1 |
#define CATEGORYCOOKIE 983429 |
Definition at line 6 of file category.c.
Referenced by CreateCategoryObject().
#define CHECKVALIDCATEGORY | ( | x | ) | ANAMODCHECKVALID(x,CATEGORYCOOKIE,"category") |
Definition at line 7 of file category.c.
Referenced by CategoryGetComponent(), CategoryGetComponentIndex(), CategoryGetOrCreateComponent(), and DestroyCategoryObject().
PetscErrorCode AllocCategoryObjects | ( | ) |
Definition at line 26 of file category.c.
References categorynames, maxcategories, MXC, and ncategories.
Referenced by AnaModInitialize().
{ PetscErrorCode ierr; PetscFunctionBegin; maxcategories = MXC; ncategories = 0; ierr = PetscMalloc (maxcategories*sizeof(categoryobject),&categoryobjects); CHKERRQ(ierr); ierr = PetscMalloc (maxcategories*sizeof(char*),&categorynames); CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode CategoryComponentSetModule | ( | const char * | cat, |
const char * | cmp, | ||
AnalysisDataType | type, | ||
int | id, | ||
PetscErrorCode(*)(AnaModNumericalProblem, AnalysisItem *, int *, PetscTruth *) | f | ||
) |
Definition at line 226 of file category.c.
References CategoryGetComponentIndex(), CategoryGetOrCreateComponent(), ComponentSetModule(), GetOrCreateCategory(), and categoryobject_::types.
Referenced by RegisterModule().
{ categoryobject catg; componentobject cmpt; int icmp; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetOrCreateCategory(cat,&catg); CHKERRQ(ierr); ierr = CategoryGetOrCreateComponent(catg,cmp,&cmpt); CHKERRQ(ierr); ierr = ComponentSetModule(cmpt,type,id,f); CHKERRQ(ierr); ierr = CategoryGetComponentIndex(catg,cmp,&icmp,PETSC_NULL); CHKERRQ(ierr); catg->types[icmp] = type; PetscFunctionReturn(0); }
PetscErrorCode CategoryEnableByName | ( | const char * | cat, |
int | mode | ||
) |
Mark a category as enabled/disabled. Values (CatCmpEnableMode):
Definition at line 317 of file category.c.
References categoryobject_::enabled, name, and ncategories.
Referenced by AnaModOptionsHandling().
{ int icat; PetscFunctionBegin; for (icat=0; icat<ncategories; icat++) { if (!strcmp(cat,categoryobjects[icat]->name)) { categoryobjects[icat]->enabled = mode; } } PetscFunctionReturn(0); }
PetscErrorCode CategoryGetComponent | ( | categoryobject | catg, |
const char * | cmp, | ||
componentobject * | cmpt, | ||
PetscTruth * | success | ||
) |
Retrieve a component.
See also CategoryGetOrCreateComponent(), CategoryGetComponentIndex().
Definition at line 209 of file category.c.
References CategoryGetComponentIndex(), CHECKVALIDCATEGORY, and categoryobject_::components.
Referenced by ComputeOrRetrieveQuantity(), GetDataID(), GetDataType(), HasComputeModule(), and HasQuantity().
{ int icmp; PetscTruth flg; PetscErrorCode ierr; PetscFunctionBegin; CHECKVALIDCATEGORY(catg); ierr = CategoryGetComponentIndex(catg,cmp,&icmp,&flg); CHKERRQ(ierr); if (success) *success = flg; if (flg) { if (cmpt) *cmpt = catg->components[icmp]; } else if (!success) SETERRQ(1,"Component not found but no flag given to report this"); PetscFunctionReturn(0); }
PetscErrorCode CategoryGetComponentIndex | ( | categoryobject | catg, |
const char * | cmp, | ||
int * | icmp, | ||
PetscTruth * | flag | ||
) |
Test for presence of a component in a category, and return its index if present. The index parameter can be null.
Definition at line 164 of file category.c.
References CHECKVALIDCATEGORY, categoryobject_::componentnames, and categoryobject_::ncomponents.
Referenced by CategoryComponentSetModule(), CategoryGetComponent(), and CategoryGetOrCreateComponent().
{ int i; PetscTruth flg; PetscErrorCode ierr; PetscFunctionBegin; CHECKVALIDCATEGORY(catg); flg = PETSC_FALSE; for (i=0; i<catg->ncomponents; i++) { ierr = PetscStrcmp(cmp,catg->componentnames[i],&flg); CHKERRQ(ierr); if (flg) {if (icmp) *icmp = i; goto found;} } found: if (flag) *flag = flg; if (!flg && !flag) SETERRQ(1,"Component not found but no flag to return this info"); PetscFunctionReturn(0); }
PetscErrorCode CategoryGetModules | ( | const char * | cat, |
const char *** | ms, | ||
AnalysisDataType ** | t, | ||
int ** | id, | ||
int * | n | ||
) |
Query the modules in a specified category.
The category name has to exist. The routine will call the Petsc error handler if the name is invalid.
Parameters:
cat
: the category that is being queriedms
(optional) : the names of the modules in the categoryt
(optional) : the corresponding list of datatypesid
(optional) : the list of module IDs (see RetrieveQuantityByID())n
(optional) : the number of modules in the categorySee also GetCategories() and HasComputeCategory().
Definition at line 256 of file category.c.
References categoryobject_::componentnames, GetCategory(), categoryobject_::ncomponents, and categoryobject_::types.
Referenced by analyze_matrix(), main(), and ReportAnamodContent().
{ categoryobject catg; PetscTruth flg; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetCategory(cat,&catg,&flg); CHKERRQ(ierr); if (!flg) SETERRQ1(1,"Unknown category <%s>",cat); if (ms) *ms = catg->componentnames; if (t) *t = catg->types; if (n) *n = catg->ncomponents; // if (id) *id = ids[i]; PetscFunctionReturn(0); }
PetscErrorCode CategoryGetOptionFunction | ( | const char * | cat, |
PetscErrorCode(**)(char *) | f | ||
) |
This function is called in AnaModOptionsHandling(). There is probably no reason for the user ever to call it.
See DeclareCategoryOptionFunction(),GetCategoryOptionFunction(), AnaModOptionsHandling() and section optionsfile.
Definition at line 358 of file category.c.
References GetCategory(), and categoryobject_::optionfunction.
Referenced by AnaModOptionsHandling().
{ PetscTruth flg; categoryobject catg; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetCategory(cat,&catg,&flg); CHKERRQ(ierr); if (flg) { *f = catg->optionfunction; } else *f = NULL; PetscFunctionReturn(0); }
PetscErrorCode CategoryGetOrCreateComponent | ( | categoryobject | catg, |
const char * | cmp, | ||
componentobject * | cmpt | ||
) |
Definition at line 184 of file category.c.
References CategoryGetComponentIndex(), CHECKVALIDCATEGORY, ComponentGetName(), categoryobject_::componentnames, categoryobject_::components, CreateComponentObject(), categoryobject_::maxcomponents, and categoryobject_::ncomponents.
Referenced by CategoryComponentSetModule().
{ int icmp; PetscTruth flg; PetscErrorCode ierr; PetscFunctionBegin; CHECKVALIDCATEGORY(catg); ierr = CategoryGetComponentIndex(catg,cmp,&icmp,&flg); CHKERRQ(ierr); if (!flg) { icmp = catg->ncomponents++; if (icmp>=catg->maxcomponents) SETERRQ(1,"Component reallocation not implemented"); ierr = CreateComponentObject(cmp,&(catg->components[icmp])); CHKERRQ(ierr); ierr = ComponentGetName (catg->components[icmp],&(catg->componentnames[icmp])); CHKERRQ(ierr); } *cmpt = catg->components[icmp]; PetscFunctionReturn(0); }
PetscErrorCode CreateCategoryObject | ( | const char * | cat, |
categoryobject * | obj | ||
) |
Create a category object with a given name. See also DestroyCategoryObject().
Definition at line 57 of file category.c.
References CATCMP_ENABLE, CATEGORYCOOKIE, categoryobject_::componentnames, categoryobject_::components, categoryobject_::cookie, categoryobject_::enabled, categoryobject_::maxcomponents, MXC, categoryobject_::name, categoryobject_::ncomponents, and categoryobject_::types.
Referenced by GetOrCreateCategory().
{ categoryobject nnew; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscMalloc(sizeof(struct categoryobject_),&nnew); CHKERRQ(ierr); ierr = PetscStrallocpy(cat,(char**)&(nnew->name)); CHKERRQ(ierr); nnew->cookie = CATEGORYCOOKIE; nnew->enabled = CATCMP_ENABLE; nnew->maxcomponents = MXC; nnew->ncomponents = 0; ierr = PetscMalloc (nnew->maxcomponents*sizeof(componentobject),&(nnew->components)); CHKERRQ(ierr); ierr = PetscMalloc (nnew->maxcomponents*sizeof(char*),&(nnew->componentnames)); CHKERRQ(ierr); ierr = PetscMalloc (nnew->maxcomponents*sizeof(AnalysisDataType),&(nnew->types)); CHKERRQ(ierr); *obj = nnew; PetscFunctionReturn(0); }
PetscErrorCode DeclareCategoryOptionFunction | ( | const char * | cat, |
PetscErrorCode(*)(char *) | f | ||
) |
This function allows the module developer to give the user commandline options for control of a module.
See DeclareCategoryOptionFunction(),GetCategoryOptionFunction(), AnaModOptionsHandling() and section optionsfile.
Definition at line 338 of file category.c.
References GetCategory(), and categoryobject_::optionfunction.
Referenced by RegisterSpectrumModules().
{ PetscTruth flg; categoryobject catg; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetCategory(cat,&catg,&flg); CHKERRQ(ierr); if (flg) { catg->optionfunction = f; } PetscFunctionReturn(0); }
PetscErrorCode DestroyCategoryObject | ( | categoryobject | obj | ) |
Deallocate a category object. See also CreateCategoryObject().
Definition at line 79 of file category.c.
References CHECKVALIDCATEGORY, categoryobject_::componentnames, categoryobject_::components, DestroyComponentObject(), categoryobject_::name, categoryobject_::ncomponents, and categoryobject_::types.
Referenced by FreeCategoryObjects().
{ int icmp; PetscErrorCode ierr; PetscFunctionBegin; CHECKVALIDCATEGORY(obj); for (icmp=0; icmp<obj->ncomponents; icmp++) { ierr = DestroyComponentObject(obj->components[icmp]); CHKERRQ(ierr); } ierr = PetscFree(obj->components); CHKERRQ(ierr); ierr = PetscFree(obj->componentnames); CHKERRQ(ierr); ierr = PetscFree(obj->types); CHKERRQ(ierr); ierr = PetscFree(obj->name); CHKERRQ(ierr); ierr = PetscFree(obj); CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode FreeCategoryObjects | ( | ) |
Definition at line 40 of file category.c.
References categorynames, DestroyCategoryObject(), and ncategories.
Referenced by AnaModFinalize().
{ int icat; PetscErrorCode ierr; PetscFunctionBegin; for (icat=0; icat<ncategories; icat++) { ierr = DestroyCategoryObject(categoryobjects[icat]); CHKERRQ(ierr); } ierr = PetscFree(categoryobjects); CHKERRQ(ierr); ierr = PetscFree(categorynames); CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode GetCategories | ( | int * | ncat, |
const char *** | cats | ||
) |
Definition at line 150 of file category.c.
References categorynames, and ncategories.
Referenced by AnaModOptionsHandling(), AnaModShowOptions(), main(), and ReportAnamodContent().
{ PetscFunctionBegin; if (ncat) *ncat = ncategories; if (cats) *cats = categorynames; PetscFunctionReturn(0); }
PetscErrorCode GetCategory | ( | const char * | cat, |
categoryobject * | catg, | ||
PetscTruth * | f | ||
) |
Return a named category
Definition at line 138 of file category.c.
References GetCategoryIndex().
Referenced by CategoryGetModules(), CategoryGetOptionFunction(), ComputeOrRetrieveQuantity(), DeclareCategoryOptionFunction(), GetDataID(), GetDataType(), HasComputeCategory(), HasComputeModule(), and HasQuantity().
{ int icat; PetscTruth flg; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetCategoryIndex(cat,&icat,&flg); CHKERRQ(ierr); if (f) *f = flg; if (flg && catg) *catg = categoryobjects[icat]; PetscFunctionReturn(0); }
static PetscErrorCode GetCategoryIndex | ( | const char * | cat, |
int * | icat, | ||
PetscTruth * | flag | ||
) | [static] |
Test for existence of a category, and return its index if present. Both output parameters can be null.
Definition at line 100 of file category.c.
References name, and ncategories.
Referenced by GetCategory(), and GetOrCreateCategory().
{ int i; PetscTruth flg; PetscErrorCode ierr; PetscFunctionBegin; flg = PETSC_FALSE; for (i=0; i<ncategories; i++) { ierr = PetscStrcmp(cat,categoryobjects[i]->name,&flg); CHKERRQ(ierr); if (flg) {if (icat) *icat = i; goto found;} } found: if (flag) *flag = flg; if (!flag && !flg) SETERRQ(1,"Category not found but no flag provided to report this"); PetscFunctionReturn(0); }
PetscErrorCode GetFirstCategory | ( | const char ** | rname, |
PetscTruth * | rfound | ||
) |
Definition at line 276 of file category.c.
References CATCMP_ENABLE, categoryreadout, categoryobject_::name, and ncategories.
Referenced by analyze_matrix().
{ PetscTruth found = PETSC_FALSE; PetscFunctionBegin; categoryreadout = 0; while (categoryreadout<ncategories && categoryobjects[categoryreadout]->enabled!=CATCMP_ENABLE) categoryreadout++; if (categoryreadout<ncategories) { found = PETSC_TRUE; if (rname) *rname = categoryobjects[categoryreadout]->name; } *rfound = found; PetscFunctionReturn(0); }
PetscErrorCode GetNextCategory | ( | const char ** | rname, |
PetscTruth * | rfound | ||
) |
Definition at line 294 of file category.c.
References CATCMP_ENABLE, categoryreadout, categoryobject_::name, and ncategories.
Referenced by analyze_matrix().
{ PetscTruth found = PETSC_FALSE; PetscFunctionBegin; categoryreadout++; while (categoryreadout<ncategories && categoryobjects[categoryreadout]->enabled!=CATCMP_ENABLE) categoryreadout++; if (categoryreadout<ncategories) { found = PETSC_TRUE; if (rname) *rname = categoryobjects[categoryreadout]->name; } *rfound = found; PetscFunctionReturn(0); }
PetscErrorCode GetOrCreateCategory | ( | const char * | cat, |
categoryobject * | catg | ||
) |
Return a named category, creating it if necessary
Definition at line 119 of file category.c.
References categorynames, CreateCategoryObject(), GetCategoryIndex(), maxcategories, categoryobject_::name, and ncategories.
Referenced by CategoryComponentSetModule().
{ int icat; PetscTruth flg; PetscErrorCode ierr; PetscFunctionBegin; ierr = GetCategoryIndex(cat,&icat,&flg); CHKERRQ(ierr); if (!flg) { icat = ncategories++; if (icat>=maxcategories) SETERRQ(1,"Category reallocation not implemented"); ierr = CreateCategoryObject(cat,&categoryobjects[icat]); CHKERRQ(ierr); categorynames[icat] = categoryobjects[icat]->name; } *catg = categoryobjects[icat]; PetscFunctionReturn(0); }
const char** categorynames |
Definition at line 22 of file category.c.
Referenced by AllocCategoryObjects(), FreeCategoryObjects(), GetCategories(), and GetOrCreateCategory().
Definition at line 279 of file module_functions.c.
int categoryreadout = -1 [static] |
Definition at line 272 of file category.c.
Referenced by GetFirstCategory(), and GetNextCategory().
int maxcategories |
Definition at line 20 of file category.c.
Referenced by AllocCategoryObjects(), and GetOrCreateCategory().
int ncategories |
Definition at line 278 of file module_functions.c.
Referenced by AllocCategoryObjects(), CategoryEnableByName(), FreeCategoryObjects(), GetCategories(), GetCategoryIndex(), GetFirstCategory(), GetNextCategory(), and GetOrCreateCategory().