HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
TransferFromPETSc.cpp File Reference

Copy from PETSc vector to HyPar array. More...

#include <stdlib.h>
#include <vector>
#include <basic.h>
#include <arrayfunctions.h>
#include <simulation_object.h>
#include <petscinterface_struct.h>

Go to the source code of this file.

Macros

#define __FUNCT__   "TransferVecFromPETSc"
 

Functions

int TransferVecFromPETSc (double *const u, const Vec Y, void *ctxt, const int sim_idx, const int offset)
 

Detailed Description

Copy from PETSc vector to HyPar array.

Author
Debojyoti Ghosh

Definition in file TransferFromPETSc.cpp.

Macro Definition Documentation

◆ __FUNCT__

#define __FUNCT__   "TransferVecFromPETSc"

Definition at line 16 of file TransferFromPETSc.cpp.

Function Documentation

◆ TransferVecFromPETSc()

int TransferVecFromPETSc ( double *const  u,
const Vec  Y,
void *  ctxt,
const int  sim_idx,
const int  offset 
)

Copy data from a PETSc vector (used by PETSc time integrators, and with no ghost points) to a HyPar::u array (with ghost points).

See also
TransferVecToPETSc()
Parameters
uHyPar::u type array (with ghost points)
YPETSc vector
ctxtObject of type PETScContext
sim_idxSimulation object index
offsetOffset

Definition at line 23 of file TransferFromPETSc.cpp.

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 }
int nvars
Definition: hypar.h:29
Structure defining a simulation.
INLINE int ArrayCopynD(int, const double *, double *, int *, int, int, int *, int)
Structure containing the variables for time-integration with PETSc.