xref: /petsc/include/petsccharacteristic.h (revision 5c8f6a953e7ed1c81f507d64aebddb11080b60e9)
1 /*
2    Defines the interface functions for the method of characteristics solvers
3 */
4 #ifndef __PETSCCHARACTERISTICS_H
5 #define __PETSCCHARACTERISTICS_H
6 
7 #include <petscvec.h>
8 #include <petscdmda.h>
9 
10 PETSC_EXTERN PetscErrorCode CharacteristicInitializePackage(const char[]);
11 
12 /*S
13      Characteristic - Abstract PETSc object that manages method of characteristics solves
14 
15    Level: beginner
16 
17   Concepts: Method of characteristics
18 
19 .seealso:  CharacteristicCreate(), CharacteristicSetType(), CharacteristicType, SNES, TS, PC, KSP
20 S*/
21 typedef struct _p_Characteristic *Characteristic;
22 
23 /*J
24     CharacteristicType - String with the name of a characteristics method or the creation function
25        with an optional dynamic library name, for example
26        http://www.mcs.anl.gov/petsc/lib.a:mymoccreate()
27 
28    Level: beginner
29 
30 .seealso: CharacteristicSetType(), Characteristic
31 J*/
32 #define CHARACTERISTICDA "da"
33 typedef const char* CharacteristicType;
34 
35 PETSC_EXTERN PetscErrorCode CharacteristicCreate(MPI_Comm, Characteristic *);
36 PETSC_EXTERN PetscErrorCode CharacteristicSetType(Characteristic, CharacteristicType);
37 PETSC_EXTERN PetscErrorCode CharacteristicSetUp(Characteristic);
38 PETSC_EXTERN PetscErrorCode CharacteristicSetVelocityInterpolation(Characteristic, DM, Vec, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(Vec, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
39 PETSC_EXTERN PetscErrorCode CharacteristicSetVelocityInterpolationLocal(Characteristic, DM, Vec, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(void *, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
40 PETSC_EXTERN PetscErrorCode CharacteristicSetFieldInterpolation(Characteristic, DM, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(Vec, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
41 PETSC_EXTERN PetscErrorCode CharacteristicSetFieldInterpolationLocal(Characteristic, DM, Vec, PetscInt, PetscInt[], PetscErrorCode (*)(void *, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *), void *);
42 PETSC_EXTERN PetscErrorCode CharacteristicSolve(Characteristic, PetscReal, Vec);
43 PETSC_EXTERN PetscErrorCode CharacteristicDestroy(Characteristic*);
44 
45 PETSC_EXTERN PetscBool         CharacteristicRegisterAllCalled;
46 PETSC_EXTERN PetscFunctionList CharacteristicList;
47 PETSC_EXTERN PetscErrorCode CharacteristicRegisterAll(const char[]);
48 PETSC_EXTERN PetscErrorCode CharacteristicRegisterDestroy(void);
49 
50 PETSC_EXTERN PetscErrorCode CharacteristicRegister(const char[],const char[],const char[],PetscErrorCode (*)(Characteristic));
51 
52 /*MC
53    CharacteristicRegisterDynamic - Adds a solver to the method of characteristics package.
54 
55    Synopsis:
56    #include "petsccharacteristic.h"
57    PetscErrorCode CharacteristicRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(Characteristic))
58 
59    Not Collective
60 
61    Input Parameters:
62 +  name_solver - name of a new user-defined solver
63 .  path - path (either absolute or relative) the library containing this solver
64 .  name_create - name of routine to create method context
65 -  routine_create - routine to create method context
66 
67    Notes:
68    CharacteristicRegisterDynamic() may be called multiple times to add several user-defined solvers.
69 
70    If dynamic libraries are used, then the fourth input argument (routine_create)
71    is ignored.
72 
73    Sample usage:
74 .vb
75    CharacteristicRegisterDynamic("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a,
76                "MySolverCreate",MySolverCreate);
77 .ve
78 
79    Then, your solver can be chosen with the procedural interface via
80 $     CharacteristicSetType(ksp,"my_solver")
81    or at runtime via the option
82 $     -characteristic_type my_solver
83 
84    Level: advanced
85 
86    Notes: Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
87           and others of the form ${any_environmental_variable} occuring in pathname will be
88           replaced with appropriate values.
89          If your function is not being put into a shared library then use CharacteristicRegister() instead
90 
91 .keywords: Characteristic, register
92 
93 .seealso: CharacteristicRegisterAll(), CharacteristicRegisterDestroy()
94 
95 M*/
96 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
97 #define CharacteristicRegisterDynamic(a,b,c,d) CharacteristicRegister(a,b,c,0)
98 #else
99 #define CharacteristicRegisterDynamic(a,b,c,d) CharacteristicRegister(a,b,c,d)
100 #endif
101 
102 #endif /*__PETSCCHARACTERISTICS_H*/
103