xref: /petsc/include/petsccharacteristic.h (revision 1e25c2744a56dc779d05d2a7975a7f2272f1aa7b)
130a76a96SBarry Smith /*
230a76a96SBarry Smith    Defines the interface functions for the method of characteristics solvers
330a76a96SBarry Smith */
430a76a96SBarry Smith #ifndef __PETSCCHARACTERISTICS_H
530a76a96SBarry Smith #define __PETSCCHARACTERISTICS_H
630a76a96SBarry Smith 
72c8e378dSBarry Smith #include <petscvec.h>
8*1e25c274SJed Brown #include <petscdmdatypes.h>
930a76a96SBarry Smith 
10014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicInitializePackage(const char[]);
1130a76a96SBarry Smith 
1230a76a96SBarry Smith /*S
1330a76a96SBarry Smith      Characteristic - Abstract PETSc object that manages method of characteristics solves
1430a76a96SBarry Smith 
1530a76a96SBarry Smith    Level: beginner
1630a76a96SBarry Smith 
1730a76a96SBarry Smith   Concepts: Method of characteristics
1830a76a96SBarry Smith 
1930a76a96SBarry Smith .seealso:  CharacteristicCreate(), CharacteristicSetType(), CharacteristicType, SNES, TS, PC, KSP
2030a76a96SBarry Smith S*/
2130a76a96SBarry Smith typedef struct _p_Characteristic *Characteristic;
2230a76a96SBarry Smith 
2376bdecfbSBarry Smith /*J
2430a76a96SBarry Smith     CharacteristicType - String with the name of a characteristics method or the creation function
2530a76a96SBarry Smith        with an optional dynamic library name, for example
2630a76a96SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:mymoccreate()
2730a76a96SBarry Smith 
2830a76a96SBarry Smith    Level: beginner
2930a76a96SBarry Smith 
3030a76a96SBarry Smith .seealso: CharacteristicSetType(), Characteristic
3176bdecfbSBarry Smith J*/
3230a76a96SBarry Smith #define CHARACTERISTICDA "da"
3319fd82e9SBarry Smith typedef const char* CharacteristicType;
3430a76a96SBarry Smith 
35014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicCreate(MPI_Comm, Characteristic *);
3619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode CharacteristicSetType(Characteristic, CharacteristicType);
37014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicSetUp(Characteristic);
38014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicSetVelocityInterpolation(Characteristic, DM, Vec, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(Vec, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
39014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicSetVelocityInterpolationLocal(Characteristic, DM, Vec, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(void *, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
40014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicSetFieldInterpolation(Characteristic, DM, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(Vec, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
41014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicSetFieldInterpolationLocal(Characteristic, DM, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(void *, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
42014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicSolve(Characteristic, PetscReal, Vec);
43014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicDestroy(Characteristic*);
4430a76a96SBarry Smith 
45140e18c1SBarry Smith PETSC_EXTERN PetscBool         CharacteristicRegisterAllCalled;
46140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList CharacteristicList;
47014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicRegisterAll(const char[]);
48014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicRegisterDestroy(void);
4930a76a96SBarry Smith 
50014dd563SJed Brown PETSC_EXTERN PetscErrorCode CharacteristicRegister(const char[],const char[],const char[],PetscErrorCode (*)(Characteristic));
5130a76a96SBarry Smith 
5230a76a96SBarry Smith /*MC
5330a76a96SBarry Smith    CharacteristicRegisterDynamic - Adds a solver to the method of characteristics package.
5430a76a96SBarry Smith 
5530a76a96SBarry Smith    Synopsis:
56f2ba6396SBarry Smith    #include "petsccharacteristic.h"
5730a76a96SBarry Smith    PetscErrorCode CharacteristicRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(Characteristic))
5830a76a96SBarry Smith 
5930a76a96SBarry Smith    Not Collective
6030a76a96SBarry Smith 
6130a76a96SBarry Smith    Input Parameters:
6230a76a96SBarry Smith +  name_solver - name of a new user-defined solver
6330a76a96SBarry Smith .  path - path (either absolute or relative) the library containing this solver
6430a76a96SBarry Smith .  name_create - name of routine to create method context
6530a76a96SBarry Smith -  routine_create - routine to create method context
6630a76a96SBarry Smith 
6730a76a96SBarry Smith    Notes:
6830a76a96SBarry Smith    CharacteristicRegisterDynamic() may be called multiple times to add several user-defined solvers.
6930a76a96SBarry Smith 
7030a76a96SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
7130a76a96SBarry Smith    is ignored.
7230a76a96SBarry Smith 
7330a76a96SBarry Smith    Sample usage:
7430a76a96SBarry Smith .vb
7530a76a96SBarry Smith    CharacteristicRegisterDynamic("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a,
7630a76a96SBarry Smith                "MySolverCreate",MySolverCreate);
7730a76a96SBarry Smith .ve
7830a76a96SBarry Smith 
7930a76a96SBarry Smith    Then, your solver can be chosen with the procedural interface via
8030a76a96SBarry Smith $     CharacteristicSetType(ksp,"my_solver")
8130a76a96SBarry Smith    or at runtime via the option
8230a76a96SBarry Smith $     -characteristic_type my_solver
8330a76a96SBarry Smith 
8430a76a96SBarry Smith    Level: advanced
8530a76a96SBarry Smith 
8630a76a96SBarry Smith    Notes: Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
8730a76a96SBarry Smith           and others of the form ${any_environmental_variable} occuring in pathname will be
8830a76a96SBarry Smith           replaced with appropriate values.
8930a76a96SBarry Smith          If your function is not being put into a shared library then use CharacteristicRegister() instead
9030a76a96SBarry Smith 
9130a76a96SBarry Smith .keywords: Characteristic, register
9230a76a96SBarry Smith 
9330a76a96SBarry Smith .seealso: CharacteristicRegisterAll(), CharacteristicRegisterDestroy()
9430a76a96SBarry Smith 
9530a76a96SBarry Smith M*/
9630a76a96SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
9730a76a96SBarry Smith #define CharacteristicRegisterDynamic(a,b,c,d) CharacteristicRegister(a,b,c,0)
9830a76a96SBarry Smith #else
9930a76a96SBarry Smith #define CharacteristicRegisterDynamic(a,b,c,d) CharacteristicRegister(a,b,c,d)
10030a76a96SBarry Smith #endif
10130a76a96SBarry Smith 
10230a76a96SBarry Smith #endif /*__PETSCCHARACTERISTICS_H*/
103