preprocess.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "petscmat.h"
#include "syspro.h"
#include "sysprotransform.h"
#include "syspro_impl.h"

Go to the source code of this file.

Data Structures

struct  PreprocessorsGlobalInfo_

Defines

#define NPREPROCESS   25

Typedefs

typedef struct
PreprocessorsGlobalInfo_
PreprocessorsGlobalInfo

Functions

static PetscErrorCode CreateGlobalInfo ()
PetscErrorCode SysProInitialize ()
PetscErrorCode SysProFinalize ()
PetscErrorCode DeclarePreprocessor (char *name, PetscErrorCode(*this_preprocessor_setup)(), PetscErrorCode(*specific_setup)(NumericalProblem, SalsaTransform), PetscErrorCode(*specific_unset)(NumericalProblem), PetscErrorCode(*global_unset)(), PetscErrorCode(*ctxcreate)(NumericalProblem, void **), PetscErrorCode(*ctxdelete)(void *), PetscErrorCode(*start_function)(char *, int, PetscTruth, NumericalProblem, NumericalProblem *, void *, void **, PetscTruth *), PetscErrorCode(*end_function)(char *, PetscTruth, void *, void *, NumericalProblem, NumericalProblem, NumericalSolution, NumericalSolution))
PetscErrorCode SysProDeclareProblemMonitor (PetscErrorCode(*monitor)(NumericalProblem))
PetscErrorCode SysProDeclareErrorTracer (PetscErrorCode(*tracer)(NumericalProblem, NumericalSolution, char *))
PetscErrorCode SysProGetErrorTracer (PetscErrorCode(**tracer)(NumericalProblem, NumericalSolution, char *))
PetscErrorCode DeclarePreprocessorIntelligentChoice (char *name, PetscErrorCode(*picker)(NumericalProblem, char **, char **))
PetscErrorCode NumericalProblemGetComm (NumericalProblem prob, MPI_Comm *comm)
PetscErrorCode SysProDeclareFunctions (PetscErrorCode(*classstaticsetup)(char *), PetscErrorCode(*classdynamicsetup)(char *, NumericalProblem), PetscErrorCode(*classproblemcloner)(char *, char *, int, NumericalProblem, NumericalProblem), PetscErrorCode(*problemsolver)(NumericalProblem, void *, NumericalSolution *), PetscErrorCode(*problemdelete)(NumericalProblem), PetscErrorCode(*solutioncreator)(NumericalProblem, NumericalSolution *), PetscErrorCode(*solutioncopy)(NumericalSolution, NumericalSolution), PetscErrorCode(*solutiondelete)(NumericalSolution), PetscErrorCode(*ctxcloner)(char *, char *, void *, void **), PetscErrorCode(*ctxfree)(void *), PetscErrorCode(*solutioncontextdelete)(NumericalSolution))
static PetscErrorCode SysProGetContextFunctions (PetscErrorCode(**ctxcloner)(char *, char *, void *, void **), PetscErrorCode(**ctxfree)(void *))
static PetscErrorCode SysProProblemCloneContext (char *preprocessor, char *type, NumericalProblem in, NumericalProblem out)
static PetscErrorCode SysProProblemDeleteContext (NumericalProblem problem)
static PetscErrorCode RegisterPreprocessorSetting (char *preprocess, char *type, int option)
PetscErrorCode PreprocessorGetSetting (char *preprocess, char **type, int *option)
PetscErrorCode RetrievePreprocessorChoice (int idx, char **type, int *option)
PetscErrorCode PreprocessorGetIndex (char *name, int *prenumber)
PetscErrorCode SystemPreprocessorGetByName (char *name, SystemPreprocessor *pp)
PetscErrorCode TransformGetByName (char *name, SalsaTransform *tf)
PetscErrorCode RegisterPreprocessorContext (char *pre, void *ctx)
PetscErrorCode PreprocessorGetContext (char *pre, void **ctx)
static PetscErrorCode PreprocessorSpecificSetup (char *preprocess, NumericalProblem problem, PetscTruth user_choices)
static PetscErrorCode SysproPreprocessorStartFunction (SystemPreprocessor preprocessor, char *type, int option, PetscTruth overwrite, NumericalProblem inproblem, NumericalProblem *outproblem, void *preprocessor_context, void **transform_context, PetscTruth *success)
static PetscErrorCode SysProPreprocessorEndFunction (SystemPreprocessor preprocessor, char *pclassname, char *type, PetscTruth do_not_keep_original, void *gctx, void *ctx, NumericalProblem next_problem, NumericalProblem problem, NumericalSolution next_solution, NumericalSolution *rsolution)
static PetscErrorCode ChooseFirstTransform (NumericalProblem problem, char *preprocess, PetscTruth user_choices, PetscTruth exhaustive, SalsaTransform transform, SystemPreprocessor preprocessor, SalsaTransformObject *transformitem, PetscTruth *moretransform, char **type)
PetscErrorCode PreprocessedSolution (char *pclassname, NumericalProblem problem, void *prevctx, NumericalSolution *rsolution)
PetscErrorCode PreprocessedProblemSolving (NumericalProblem problem, NumericalSolution *solution)

Variables

SystemPreprocessorpreprocessors = NULL
char ** currentpreprocessors
char ** currentchoices = NULL
int * currentoptions = NULL
int npreprocess = 0
int preprocesslevel
static void ** preprocessorcontexts
static void * solutioncontext
static PetscErrorCode(** unsetpreprocessor )()
static PreprocessorsGlobalInfo GlobalInfo = NULL


Define Documentation

#define NPREPROCESS   25

Definition at line 149 of file preprocess.c.

Referenced by DeclarePreprocessor(), and SysProInitialize().


Typedef Documentation

Definition at line 189 of file preprocess.c.


Function Documentation

static PetscErrorCode ChooseFirstTransform ( NumericalProblem  problem,
char *  preprocess,
PetscTruth  user_choices,
PetscTruth  exhaustive,
SalsaTransform  transform,
SystemPreprocessor  preprocessor,
SalsaTransformObject transformitem,
PetscTruth *  moretransform,
char **  type 
) [static]

static PetscErrorCode CreateGlobalInfo (  )  [static]

Definition at line 194 of file preprocess.c.

References CHKERRQ(), and ierr.

Referenced by SysProInitialize().

PetscErrorCode DeclarePreprocessor ( char *  name,
PetscErrorCode(*)()  this_preprocessor_setup,
PetscErrorCode(*)(NumericalProblem, SalsaTransform specific_setup,
PetscErrorCode(*)(NumericalProblem specific_unset,
PetscErrorCode(*)()  global_unset,
PetscErrorCode(*)(NumericalProblem, void **)  ctxcreate,
PetscErrorCode(*)(void *)  ctxdelete,
PetscErrorCode(*)(char *, int, PetscTruth, NumericalProblem, NumericalProblem *, void *, void **, PetscTruth *)  start_function,
PetscErrorCode(*)(char *, PetscTruth, void *, void *, NumericalProblem, NumericalProblem, NumericalSolution, NumericalSolution end_function 
)

Declare a preprocessor class, by specifing its various members.

The name argument should not contain the colon character.

Here is an explanation of the various function arguments.

this_preprocessor_setup() : this routine is called only once, inside this function. This is a good place for defining all the preprocessors in this class

specific_setup(NumericalProblem,SalsaTransform) : this is called at the start of a preprocessing stage; one could use this for computing matrix metadata.

global_unset(void) : this is called in SysProFinalize().

ctx_create(NumericalProblem,void**) : create an object that can be used for the duration of the application of this preprocessor

ctxdelete(void*) : delete the context again

start_function : this is the function that performs the forward transform of the problem. Prototype:

  PetscErrorCode start_function
    (char             *classmember,
     int               optionvalue,
     PetscTruth        overwrite,
     NumericalProblem  problem,
     NumericalProblem *transformedproblem,
     void             *globalcontext,
     void            **localcontext,
     PetscTruth       *success)

end_function : this is the backtransform. Its main task is copying or backtransforming the preprocessed solution to the original solution.

  PetscErrorCode end_function
    (char             *classmember,
     PetscTruth        overwrite,
     void             *globalcontext,
     void             *localcontext,
     NumericalProblem  pproblem,
     NumericalProblem  oproblem,
     NumericalSolution psolution,
     NumericalSolution osolution)
where pproblem and psolution are the preprocessed quantities, the end function has to unprocess them and leave the result in oproblem, osolution. Actually, oproblem is only for reference.

Definition at line 319 of file preprocess.c.

References CHKERRQ(), PreprocessorsGlobalInfo_::classstaticsetup, SystemPreprocessor_::ctxcreate, SystemPreprocessor_::ctxdelete, SystemPreprocessor_::end_function, SystemPreprocessor_::exhaustive, ierr, SystemPreprocessor_::name, NewTransform(), NPREPROCESS, npreprocess, SystemPreprocessor_::setup, SystemPreprocessor_::start_function, SystemPreprocessor_::transform, SystemPreprocessor_::unset, and unsetpreprocessor.

Referenced by DeclareApproximationPreprocessor(), DeclareDistributionPreprocessor(), DeclareFlipsignPreprocessor(), DeclareKSPPreprocessor(), DeclarePCPreprocessor(), DeclareScalingPreprocessor(), DeclareSingletonPreprocessor(), and main().

PetscErrorCode DeclarePreprocessorIntelligentChoice ( char *  name,
PetscErrorCode(*)(NumericalProblem, char **, char **)  picker 
)

Install a function to pick the optimal choice for a preprocessor

Definition at line 399 of file preprocess.c.

References CHKERRQ(), ierr, SystemPreprocessor_::intelligence, and SystemPreprocessorGetByName().

Referenced by DeclareScalingPreprocessor().

PetscErrorCode NumericalProblemGetComm ( NumericalProblem  prob,
MPI_Comm *  comm 
)

Definition at line 411 of file preprocess.c.

References NumericalProblem_::comm.

Referenced by create_solver().

PetscErrorCode PreprocessedProblemSolving ( NumericalProblem  problem,
NumericalSolution solution 
)

Invoking this routine starts the preprocessing and ultimate solution of the numerical problem.

Definition at line 1063 of file preprocess.c.

References CHKERRQ(), PreprocessorsGlobalInfo_::errortracer, GetFirstPreprocessor(), ierr, PreprocessedSolution(), preprocesslevel, and PreprocessorsGlobalInfo_::problemsolver.

Referenced by main(), and PreprocessedLinearSystemSolution().

PetscErrorCode PreprocessedSolution ( char *  pclassname,
NumericalProblem  problem,
void *  prevctx,
NumericalSolution rsolution 
)

PetscErrorCode PreprocessorGetContext ( char *  pre,
void **  ctx 
)

Definition at line 668 of file preprocess.c.

References CHKERRQ(), ierr, preprocessorcontexts, PreprocessorGetIndex(), and solutioncontext.

Referenced by setup_ksp(), and setup_pc().

PetscErrorCode PreprocessorGetIndex ( char *  name,
int *  prenumber 
)

PetscErrorCode PreprocessorGetSetting ( char *  preprocess,
char **  type,
int *  option 
)

Definition at line 545 of file preprocess.c.

References currentchoices, currentoptions, currentpreprocessors, and preprocesslevel.

Referenced by disable_ksps().

static PetscErrorCode PreprocessorSpecificSetup ( char *  preprocess,
NumericalProblem  problem,
PetscTruth  user_choices 
) [static]

Setup actions that are particular to a specific class of preprocessors, such as scalings. This performs the following actions:

  • any user specified setup, for instance disqualifying preprocessors on purely logistical grounds.
  • subsequently, the suitability functions (Suitability functions) are evaluated for each preprocessor and the current problem. In the current implementation this is only used to disqualify preprocessors. We'll get more sophisticated later.

Definition at line 697 of file preprocess.c.

References CHKERRQ(), ierr, SalsaTransform_::n_objects, SalsaTransformObject_::name, PreprocessorApplyAprioriSelection(), PreprocessorsGlobalInfo_::problemmonitor, ReportEnabledPreprocessors(), SystemPreprocessor_::setup, SystemPreprocessorGetByName(), TransformGetByName(), TransformObjectGetSuitabilityFunction(), TransformObjectMark(), and SalsaTransform_::transformobjects.

Referenced by PreprocessedSolution().

PetscErrorCode RegisterPreprocessorContext ( char *  pre,
void *  ctx 
)

static PetscErrorCode RegisterPreprocessorSetting ( char *  preprocess,
char *  type,
int  option 
) [static]

Definition at line 533 of file preprocess.c.

References currentchoices, currentoptions, currentpreprocessors, and preprocesslevel.

Referenced by PreprocessedSolution().

PetscErrorCode RetrievePreprocessorChoice ( int  idx,
char **  type,
int *  option 
)

Definition at line 565 of file preprocess.c.

References currentchoices, and currentoptions.

Referenced by ContinueRetrievingCurrentPreprocessors().

PetscErrorCode SysProDeclareErrorTracer ( PetscErrorCode(*)(NumericalProblem, NumericalSolution, char *)  tracer  ) 

Definition at line 378 of file preprocess.c.

References PreprocessorsGlobalInfo_::errortracer.

PetscErrorCode SysProDeclareFunctions ( PetscErrorCode(*)(char *)  classstaticsetup,
PetscErrorCode(*)(char *, NumericalProblem classdynamicsetup,
PetscErrorCode(*)(char *, char *, int, NumericalProblem, NumericalProblem classproblemcloner,
PetscErrorCode(*)(NumericalProblem, void *, NumericalSolution *)  problemsolver,
PetscErrorCode(*)(NumericalProblem problemdelete,
PetscErrorCode(*)(NumericalProblem, NumericalSolution *)  solutioncreator,
PetscErrorCode(*)(NumericalSolution, NumericalSolution solutioncopy,
PetscErrorCode(*)(NumericalSolution solutiondelete,
PetscErrorCode(*)(char *, char *, void *, void **)  ctxcloner,
PetscErrorCode(*)(void *)  ctxfree,
PetscErrorCode(*)(NumericalSolution solutioncontextdelete 
)

Install various functions

  • classstaticsetup : this function is called on each processor as it is being created; see DeclarePreprocessor().
  • classdynamicsetup : this function is called as any invocation of a preprocessor starts; see PreprocessedSolution();
  • classproblemcloner : a function to clone the context : optional see Tracing the preprocessors for more details.
  • problemsolver : the ultimate problem solver : required
  • problemdelete : delete a problem object
  • solutioncreator : creates a solution object; optional, but required a preprocessor has an endfunction.
  • solutioncopy : guess what this does; optional
  • solutiondelete : optional, but needed if solutioncopy is used
  • contextcloner : problems can carry a context; this clones the context if a problem is copied; otherwise the pointer is simply duplicated
  • contextfree : used to delete cloned contexts
  • solutioncontextdelete : hm.

Definition at line 440 of file preprocess.c.

References PreprocessorsGlobalInfo_::classdynamicsetup, PreprocessorsGlobalInfo_::classproblemcloner, PreprocessorsGlobalInfo_::classstaticsetup, PreprocessorsGlobalInfo_::clonecontext, PreprocessorsGlobalInfo_::freecontext, PreprocessorsGlobalInfo_::problemdelete, PreprocessorsGlobalInfo_::problemsolver, PreprocessorsGlobalInfo_::solutioncontextdelete, PreprocessorsGlobalInfo_::solutioncopy, PreprocessorsGlobalInfo_::solutioncreator, and PreprocessorsGlobalInfo_::solutiondelete.

Referenced by main().

PetscErrorCode SysProDeclareProblemMonitor ( PetscErrorCode(*)(NumericalProblem monitor  ) 

Definition at line 368 of file preprocess.c.

References PreprocessorsGlobalInfo_::problemmonitor.

PetscErrorCode SysProFinalize (  ) 

static PetscErrorCode SysProGetContextFunctions ( PetscErrorCode(**)(char *, char *, void *, void **)  ctxcloner,
PetscErrorCode(**)(void *)  ctxfree 
) [static]

PetscErrorCode SysProGetErrorTracer ( PetscErrorCode(**)(NumericalProblem, NumericalSolution, char *)  tracer  ) 

Definition at line 388 of file preprocess.c.

References PreprocessorsGlobalInfo_::errortracer.

PetscErrorCode SysProInitialize (  ) 

Allocate SysPro globals. See also SysProFinalize().

Definition at line 211 of file preprocess.c.

References CHKERRQ(), CreateGlobalInfo(), currentchoices, currentoptions, currentpreprocessors, ierr, NPREPROCESS, preprocessorcontexts, and unsetpreprocessor.

Referenced by main().

static PetscErrorCode SysProPreprocessorEndFunction ( SystemPreprocessor  preprocessor,
char *  pclassname,
char *  type,
PetscTruth  do_not_keep_original,
void *  gctx,
void *  ctx,
NumericalProblem  next_problem,
NumericalProblem  problem,
NumericalSolution  next_solution,
NumericalSolution rsolution 
) [static]

static PetscErrorCode SysproPreprocessorStartFunction ( SystemPreprocessor  preprocessor,
char *  type,
int  option,
PetscTruth  overwrite,
NumericalProblem  inproblem,
NumericalProblem outproblem,
void *  preprocessor_context,
void **  transform_context,
PetscTruth *  success 
) [static]

static PetscErrorCode SysProProblemCloneContext ( char *  preprocessor,
char *  type,
NumericalProblem  in,
NumericalProblem  out 
) [static]

Definition at line 504 of file preprocess.c.

References CHKERRQ(), NumericalProblem_::ctx, ierr, and SysProGetContextFunctions().

Referenced by PreprocessedSolution().

static PetscErrorCode SysProProblemDeleteContext ( NumericalProblem  problem  )  [static]

Definition at line 516 of file preprocess.c.

References CHKERRQ(), ierr, and SysProGetContextFunctions().

Referenced by SysProPreprocessorEndFunction().

PetscErrorCode SystemPreprocessorGetByName ( char *  name,
SystemPreprocessor pp 
)

PetscErrorCode TransformGetByName ( char *  name,
SalsaTransform tf 
)


Variable Documentation

char ** currentchoices = NULL

int* currentoptions = NULL

Definition at line 190 of file preprocess.c.

int npreprocess = 0

void** preprocessorcontexts [static]

Definition at line 150 of file preprocess.c.

void * solutioncontext [static]

Definition at line 154 of file preprocess.c.

Referenced by PreprocessorGetContext(), and RegisterPreprocessorContext().

PetscErrorCode(** unsetpreprocessor)() [static]


Generated on Sun Oct 4 04:03:05 2009 for System Preprocessors by  doxygen 1.5.9