System Preprocessors
compute.c
Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <string.h>
00004 #include "petscmat.h"
00005 #include "syspro.h"
00006 #include "syspro_impl.h"
00007 
00008 /*! \file compute.c \anchor computec
00009   \brief System/Anamod and NMD interface
00010  */
00011 
00012 /*! \page anamodinterface Computational modules interface
00013 
00014   SysPro has a facility for computing or retrieving metadata about the
00015   numerical problems it deals with. The interface comprises
00016   - specification of preserved categories under preprocessor application
00017   with PreprocessorSetPreservedCategories().
00018   
00019 
00020   THE FOLLOWING FACILITY IS DISABLED
00021 
00022   Standard it comes with a dummy library
00023   \c libsysprocompute.a 
00024   of routines that simply say "failed to compute/retrieve data". If the user
00025   has an actual computation package (such as AnaMod), then that can be
00026   interfaced by providing implementations of the routines
00027   SysProComputeQuantity() and SyspProRetrieveQuantity().
00028 */
00029 
00030 #undef __FUNCT__
00031 #define __FUNCT__ "PreprocessorSetPreservedCategories"
00032 PetscErrorCode PreprocessorSetPreservedCategories
00033 (const char *preprocess,const char *cats)
00034 {
00035   SystemPreprocessor pp; PetscErrorCode ierr;
00036   PetscFunctionBegin;
00037   ierr = SystemPreprocessorGetByName(preprocess,&pp); CHKERRQ(ierr);
00038   if (!pp->preserved) {
00039     ierr = PetscStrallocpy(cats,(char**)&pp->preserved); CHKERRQ(ierr);
00040   } else {
00041     size_t l1,l2; char *cnew;
00042     ierr = PetscStrlen(pp->preserved,&l1); CHKERRQ(ierr);
00043     ierr = PetscStrlen(cats,&l2); CHKERRQ(ierr);
00044     ierr = PetscMalloc((l1+l2+2)*sizeof(char),&cnew); CHKERRQ(ierr);
00045     ierr = sprintf(cnew,"%s,%s",pp->preserved,cats);
00046     ierr = PetscFree(pp->preserved); CHKERRQ(ierr);
00047     pp->preserved = cnew;
00048   }
00049   PetscFunctionReturn(0);
00050 }
00051 
00052 #undef __FUNCT__
00053 #define __FUNCT__ "PreprocessorGetPreservedCategories"
00054 PetscErrorCode PreprocessorGetPreservedCategories
00055 (const char *preprocess,const char **cats)
00056 {
00057   SystemPreprocessor pp; PetscErrorCode ierr;
00058   PetscFunctionBegin;
00059   ierr = SystemPreprocessorGetByName(preprocess,&pp); CHKERRQ(ierr);
00060   *cats = pp->preserved;
00061   PetscFunctionReturn(0);
00062 }
00063 
00064 #undef __FUNCT__
00065 #define __FUNCT__ "DeclarePreprocessorRequiredCategories"
00066 /*!
00067   Indicate which metadata categories need to be computed for a 
00068   successful application of this preprocessor.
00069 
00070   Arguments:
00071   - \c name : name of the current preprocessor
00072   - \c required : comma-separated list of metadata categories
00073 */
00074 PetscErrorCode DeclarePreprocessorRequiredCategories
00075 (char *name,char *required)
00076 {
00077   SystemPreprocessor pp;
00078   PetscErrorCode ierr;
00079   PetscFunctionBegin;
00080   ierr = SystemPreprocessorGetByName(name,&pp); CHKERRQ(ierr);
00081   ierr = PetscStrallocpy(required,(char**)&(pp->required)); CHKERRQ(ierr);
00082   PetscFunctionReturn(0);
00083 }
00084 
00085 #if 0
00086 #undef __FUNCT__
00087 #define __FUNCT__ "SysProComputeQuantity"
00088 PetscErrorCode SysProComputeQuantity
00089 (NumericalProblem problem,char *cat,char *mod,void *res,PetscBool *flg)
00090 {
00091   PetscFunctionBegin;
00092   *flg = PETSC_FALSE;
00093   PetscFunctionReturn(0);
00094 }
00095 
00096 #undef __FUNCT__
00097 #define __FUNCT__ "SysProRetrieveQuantity"
00098 PetscErrorCode SysProRetrieveQuantity
00099 (NumericalProblem problem,char *cat,char *mod,void *res,PetscBool *flg)
00100 {
00101   PetscFunctionBegin;
00102   *flg = PETSC_FALSE;
00103   PetscFunctionReturn(0);
00104 }
00105 #endif