HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
TransferFromPETSc.cpp
Go to the documentation of this file.
1 
6 #ifdef with_petsc
7 
8 #include <stdlib.h>
9 #include <vector>
10 #include <basic.h>
11 #include <arrayfunctions.h>
12 #include <simulation_object.h>
13 #include <petscinterface_struct.h>
14 
15 #undef __FUNCT__
16 #define __FUNCT__ "TransferVecFromPETSc"
17 
23 int TransferVecFromPETSc( double* const u,
24  const Vec Y,
25  void* ctxt,
26  const int sim_idx,
27  const int offset )
28 {
29  PETScContext* context = (PETScContext*) ctxt;
30  SimulationObject* sim = (SimulationObject*) context->simobj;
31  const double* Yarr;
32 
33  PetscFunctionBegin;
34  VecGetArrayRead(Y,&Yarr);
35  std::vector<int> index(sim[sim_idx].solver.ndims,0);
36  ArrayCopynD( sim[sim_idx].solver.ndims,
37  (Yarr+offset),
38  u,
39  sim[sim_idx].solver.dim_local,
40  0,
41  sim[sim_idx].solver.ghosts,
42  index.data(),
43  sim[sim_idx].solver.nvars );
44  VecRestoreArrayRead(Y,&Yarr);
45 
46  PetscFunctionReturn(0);
47 }
48 
49 #endif
int nvars
Definition: hypar.h:29
Structure defining a simulation.
Some basic definitions and macros.
Simulation object.
INLINE int ArrayCopynD(int, const double *, double *, int *, int, int, int *, int)
Structure containing the variables for time-integration with PETSc.
int * dim_local
Definition: hypar.h:37
int ghosts
Definition: hypar.h:52
int TransferVecFromPETSc(double *const u, const Vec Y, void *ctxt, const int sim_idx, const int offset)
Contains macros and function definitions for common array operations.
Contains structure that defines the interface for time integration with PETSc (https://petsc.org/release/)