SALSA Analysis Modules
anamod.h
Go to the documentation of this file.
00001 /*! \file anamod.h \ingroup functions
00002   \brief Prototypes for general module functions
00003 
00004   This file defines the functions for defining and querying 
00005   analysis modules.
00006 */
00007 #ifndef MODULE_FUNCTIONS_H
00008 #define MODULE_FUNCTIONS_H
00009 
00010 #define ANAMOD_FORMAT_VERSION "1.0"
00011 #define MXC 30
00012 #define INC 7
00013 
00014 #include "petscmat.h"
00015 #include <petsc-private/petscimpl.h>
00016 #include "anamodtypes.h"
00017 
00018 #define TRUTH(x) ( (x) ? PETSC_TRUE : PETSC_FALSE )
00019 #define HASTOEXIST(h) \
00020   if (!h) {                                      \
00021     printf("ERROR asking for unknown module\n"); \
00022     PetscFunctionReturn(1);                      \
00023   }
00024 #define ANAMODCHECKVALID(i,c,s) {if (!(i)) SETERRQ(MPI_COMM_WORLD,1,"Null pointer"); if ((i)->cookie!=c) SETERRQ1(MPI_COMM_WORLD,1,"Not a valid <%s>",s);}
00025 
00026 typedef struct categoryobject_* categoryobject;
00027 typedef struct componentobject_* componentobject;
00028 
00029 /*
00030  * Init/Final
00031  */
00032 extern PetscErrorCode AnaModInitialize();
00033 extern PetscErrorCode AnaModFinalize();
00034 extern PetscErrorCode AnaModGetTypeName(int id,const char **name);
00035 extern PetscErrorCode AnaModGetTypeMySQLName(int id,const char **name);
00036 
00037 /*
00038  * Categories and modules
00039  */
00040 extern PetscErrorCode AllocCategoryObjects();
00041 extern PetscErrorCode FreeCategoryObjects();
00042 extern PetscErrorCode CreateCategoryObject(const char*,categoryobject*);
00043 extern PetscErrorCode DestroyCategoryObject(categoryobject);
00044 extern PetscErrorCode GetCategory(const char*,categoryobject*,PetscBool*);
00045 extern PetscErrorCode GetOrCreateCategory(const char*,categoryobject*);
00046 extern PetscErrorCode CategoryGetComponentIndex
00047 (categoryobject,const char*,int*,PetscBool*);
00048 extern PetscErrorCode CategoryComponentSetModule
00049 (const char*,const char*,AnalysisDataType,int,
00050  PetscErrorCode(*)(AnaModNumericalProblem,AnalysisItem*,int*,PetscBool*));
00051 
00052 extern PetscErrorCode AnaModRegisterStandardModules();
00053 extern PetscErrorCode RegisterModule
00054 (const char*,const char*,AnalysisDataType,
00055  PetscErrorCode(*f)(AnaModNumericalProblem,AnalysisItem*,int*,PetscBool*));
00056 extern PetscErrorCode DeRegisterCategory(const char *cat);
00057 extern PetscErrorCode DeregisterModules(void);
00058 extern PetscErrorCode GetCategories(int*,const char***);
00059 extern PetscErrorCode CategoryGetModules
00060 (const char*,const char***,AnalysisDataType**,int**,int*);
00061 extern PetscErrorCode HasComputeCategory(const char*,PetscBool*);
00062 extern PetscErrorCode HasComputeModule(const char*,const char*,PetscBool*);
00063 typedef enum { 
00064   CATCMP_ENABLE, CATCMP_SKIP_FROM_LOOPS,CATCMP_DISABLE} CatCmpEnableMode;
00065 extern PetscErrorCode CategoryEnableByName(const char*,int);
00066 extern PetscErrorCode GetFirstCategory(const char**,PetscBool*);
00067 extern PetscErrorCode GetNextCategory(const char**,PetscBool*);
00068 
00069 /*
00070  * Components
00071  */
00072 extern PetscErrorCode CreateComponentObject(const char*,componentobject*);
00073 extern PetscErrorCode DestroyComponentObject(componentobject);
00074 extern PetscErrorCode CategoryGetOrCreateComponent
00075 (categoryobject,const char*,componentobject*);
00076 extern PetscErrorCode CategoryGetComponent
00077 (categoryobject,const char*,componentobject*,PetscBool*);
00078 extern PetscErrorCode ComponentSetModule
00079 (componentobject,AnalysisDataType,int,
00080  PetscErrorCode(*)(AnaModNumericalProblem,AnalysisItem*,int*,PetscBool*));
00081 extern PetscErrorCode ComponentGetType(componentobject,AnalysisDataType*);
00082 extern PetscErrorCode ComponentCompute
00083 (componentobject,AnaModNumericalProblem,AnalysisItem*,int*,PetscBool*);
00084 extern PetscErrorCode ComponentRetrieve
00085 (componentobject,AnaModNumericalProblem,AnalysisItem*,int*,PetscBool*);
00086 extern PetscErrorCode ComponentGetType(componentobject,AnalysisDataType*);
00087 extern PetscErrorCode ComponentGetName(componentobject,const char**);
00088 extern PetscErrorCode ComponentGetId(componentobject,int*);
00089 
00090 /*
00091  * Quantities
00092  */
00093 extern PetscErrorCode GetDataID(const char*,const char*,int*,PetscBool*);
00094 extern PetscErrorCode GetDataType(const char*,const char*,AnalysisDataType*,PetscBool*);
00095 extern PetscErrorCode ComputeQuantity
00096 (AnaModNumericalProblem,const char*,const char*,AnalysisItem*,int*,PetscBool*);
00097 extern PetscErrorCode ComputeQuantityByID
00098 (AnaModNumericalProblem,int,int,AnalysisItem*,int*,PetscBool*);
00099 extern PetscErrorCode HasQuantity
00100 (AnaModNumericalProblem,const char*,const char*,PetscBool*);
00101 extern PetscErrorCode HasQuantityByID
00102 (AnaModNumericalProblem,int,AnalysisDataType,PetscBool*);
00103 extern PetscErrorCode RetrieveQuantity
00104 (AnaModNumericalProblem,const char*,const char*,AnalysisItem*,int*,PetscBool*);
00105 extern PetscErrorCode RetrieveQuantityByID
00106 (AnaModNumericalProblem,int,AnalysisDataType,AnalysisItem*,PetscBool*);
00107 extern PetscErrorCode QuantityAsString(AnalysisItem*,AnalysisDataType,char**);
00108 
00109 /*
00110  * Execution control
00111  */
00112 extern PetscErrorCode AnaModOptionsHandling(void);
00113 extern PetscErrorCode AnaModShowOptions(MPI_Comm);
00114 extern PetscErrorCode DeclareCategoryOptionFunction
00115 (const char *cat,PetscErrorCode(*f)(char*));
00116 extern PetscErrorCode CategoryGetOptionFunction
00117 (const char *cat,PetscErrorCode(**f)(char*));
00118 extern PetscErrorCode AnaModHasForcedSequentialComputation(PetscBool*);
00119 extern PetscErrorCode AnaModHasForcedExpensiveComputation(PetscBool*);
00120 extern PetscErrorCode AnaModGetSequentialMatrix
00121 (Mat A,Mat *Awork,PetscBool *mem,PetscBool *local,PetscBool *global);
00122 
00123 /*
00124  * Tracing and output
00125  */
00126 extern PetscErrorCode AnaModDeclareTraceFunction
00127 (PetscErrorCode(*)(void*,const char*,va_list));
00128 extern PetscErrorCode AnaModDeclareTraceContext(void*);
00129 extern PetscErrorCode AnaModTraceMessage(const char *fmt,...);
00130 extern PetscErrorCode AnaModHasTrace(PetscBool *flg);
00131 extern PetscErrorCode AnaModSetTraceArrays(PetscBool f);
00132 extern PetscErrorCode AnaModTraceArrays(PetscBool *f);
00133 #if defined(HAVE_NMD)
00134 extern PetscErrorCode TabReportModules(char**,int);
00135 extern PetscErrorCode TabReportValues(NMD_metadata,char**,char**,int);
00136 #else
00137 extern PetscErrorCode TabReportModules(Mat,char**,char**,int);
00138 #endif
00139 extern PetscErrorCode PurgeAttachedArrays(Mat A);
00140 
00141 /*
00142  * Feature sets
00143  */
00144 typedef struct FeatureSet_* FeatureSet;
00145 typedef struct FeatureValues_* FeatureValues;
00146 extern PetscErrorCode NewFeatureSet(FeatureSet*);
00147 extern PetscErrorCode DeleteFeatureSet(FeatureSet);
00148 extern PetscErrorCode AddToFeatureSet(FeatureSet,const char*,const char*,int*);
00149 extern PetscErrorCode NewFeatureValues(FeatureValues*);
00150 extern PetscErrorCode DeleteFeatureValues(FeatureValues);
00151 extern PetscErrorCode InstantiateFeatureSet
00152 (AnaModNumericalProblem,FeatureSet,FeatureValues);
00153 extern PetscErrorCode GetFeatureValue
00154 (FeatureValues,int,AnalysisItem*,PetscBool*);
00155 extern PetscErrorCode AnaModSetRetrievalFunction
00156 (PetscErrorCode(*)(void*,char*,char*,AnalysisItem*,AnalysisDataType*,PetscBool*));
00157 extern PetscErrorCode AnaModGetRetrievalFunction
00158 (PetscErrorCode(**)(void*,char*,char*,AnalysisItem*,AnalysisDataType*,PetscBool*),PetscBool*);
00159 extern PetscErrorCode AnaModCheckValidFeatureSet(void*);
00160 
00161 /*
00162  * Utils
00163  */
00164 extern PetscErrorCode CreateIntArray(const char*,int,IntArray*);
00165 extern PetscErrorCode DeleteIntArray(IntArray);
00166 extern PetscErrorCode IntArrayAdd(IntArray,int,int*);
00167 extern PetscErrorCode IntArraySetAt(IntArray,int,int);
00168 extern PetscErrorCode IntArrayTryGetAt(IntArray,int,int*,PetscBool*);
00169 extern PetscErrorCode IntArrayGetAt(IntArray,int,int*);
00170 extern PetscErrorCode IntArrayGetFill(IntArray,int*);
00171 
00172 extern PetscErrorCode CreateStringArray(const char*,int,StringArray*);
00173 extern PetscErrorCode DeleteStringArray(StringArray);
00174 extern PetscErrorCode StringArrayAdd(StringArray,const char*,int*);
00175 extern PetscErrorCode StringArraySetAt(StringArray,int,const char*);
00176 extern PetscErrorCode StringArrayTryGetAt(StringArray,int,char**,PetscBool*);
00177 extern PetscErrorCode StringArrayGetAt(StringArray,int,char**);
00178 extern PetscErrorCode StringArrayGetFill(StringArray,int*);
00179 
00180 extern PetscErrorCode CreateAnalysisItemArray(const char*,int,AnalysisItemArray*);
00181 extern PetscErrorCode DeleteAnalysisItemArray(AnalysisItemArray);
00182 extern PetscErrorCode AnalysisItemArrayAdd(AnalysisItemArray,AnalysisItem,int*);
00183 extern PetscErrorCode AnalysisItemArraySetAt(AnalysisItemArray,int,AnalysisItem);
00184 extern PetscErrorCode AnalysisItemArrayTryGetAt(AnalysisItemArray,int,AnalysisItem*,PetscBool*);
00185 extern PetscErrorCode AnalysisItemArrayGetAt(AnalysisItemArray,int,AnalysisItem*);
00186 
00187 extern PetscErrorCode CreateAnalysisDataTypeArray(const char*,int,AnalysisDataTypeArray*);
00188 extern PetscErrorCode DeleteAnalysisDataTypeArray(AnalysisDataTypeArray);
00189 extern PetscErrorCode AnalysisDataTypeArrayAdd(AnalysisDataTypeArray,AnalysisDataType,int*);
00190 extern PetscErrorCode AnalysisDataTypeArraySetAt(AnalysisDataTypeArray,int,AnalysisDataType);
00191 extern PetscErrorCode AnalysisDataTypeArrayTryGetAt(AnalysisDataTypeArray,int,AnalysisDataType*,PetscBool*);
00192 extern PetscErrorCode AnalysisDataTypeArrayGetAt(AnalysisDataTypeArray,int,AnalysisDataType*);
00193 
00194 /*
00195  * Logging
00196  */
00197 extern PetscErrorCode CategoryLogEventRegister(char *cat,int icat);
00198 
00199 #endif