xref: /petsc/src/vec/pf/impls/string/tests/ex1.c (revision 732aec7a18f2199fb53bb9a2f3aef439a834ce31)
1f236b2adSBarry Smith static char help[] = "Tests ().\n\n";
2f236b2adSBarry Smith 
3f236b2adSBarry Smith #include <petscpf.h>
4f236b2adSBarry Smith #include <petscvec.h>
5f236b2adSBarry Smith 
main(int argc,char ** argv)6f236b2adSBarry Smith int main(int argc, char **argv)
7f236b2adSBarry Smith {
8f236b2adSBarry Smith   PetscScalar x = 2, f;
9f236b2adSBarry Smith   PF          pf;
10f236b2adSBarry Smith 
11f236b2adSBarry Smith   PetscFunctionBeginUser;
12*c8025a54SPierre Jolivet   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
13f236b2adSBarry Smith 
14f236b2adSBarry Smith   PetscCall(PFCreate(PETSC_COMM_WORLD, 1, 1, &pf));
15f236b2adSBarry Smith   PetscCall(PFSetType(pf, PFSTRING, (void *)"f = 2*x;"));
16f236b2adSBarry Smith   PetscCall(PFSetFromOptions(pf));
17f236b2adSBarry Smith   PetscCall(PFApply(pf, 1, &x, &f));
18f236b2adSBarry Smith   PetscCheck(f == 4, PETSC_COMM_WORLD, PETSC_ERR_PLIB, "Error in calling string function");
19f236b2adSBarry Smith   PetscCall(PFDestroy(&pf));
20f236b2adSBarry Smith 
21f236b2adSBarry Smith   PetscCall(PetscFinalize());
22f236b2adSBarry Smith   return 0;
23f236b2adSBarry Smith }
24f236b2adSBarry Smith 
25f236b2adSBarry Smith /*TEST
26f236b2adSBarry Smith 
27f236b2adSBarry Smith      test:
28f236b2adSBarry Smith        requires: defined(PETSC_HAVE_POPEN) defined(PETSC_USE_SHARED_LIBRARIES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
29f236b2adSBarry Smith        args: -pf_view
30f236b2adSBarry Smith 
31f236b2adSBarry Smith TEST*/
32