本文整理汇总了C++中NV_DATA_P函数的典型用法代码示例。如果您正苦于以下问题:C++ NV_DATA_P函数的具体用法?C++ NV_DATA_P怎么用?C++ NV_DATA_P使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NV_DATA_P函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: N_VScale_Parallel
void N_VScale_Parallel(realtype c, N_Vector x, N_Vector z)
{
long int i, N;
realtype *xd, *zd;
xd = zd = NULL;
if (z == x) { /* BLAS usage: scale x <- cx */
VScaleBy_Parallel(c, x);
return;
}
if (c == ONE) {
VCopy_Parallel(x, z);
} else if (c == -ONE) {
VNeg_Parallel(x, z);
} else {
N = NV_LOCLENGTH_P(x);
xd = NV_DATA_P(x);
zd = NV_DATA_P(z);
for (i = 0; i < N; i++)
zd[i] = c*xd[i];
}
return;
}
示例2: N_VConstrMask_Parallel
booleantype N_VConstrMask_Parallel(N_Vector c, N_Vector x, N_Vector m)
{
long int i, N;
realtype temp;
realtype *cd, *xd, *md;
MPI_Comm comm;
cd = xd = md = NULL;
N = NV_LOCLENGTH_P(x);
xd = NV_DATA_P(x);
cd = NV_DATA_P(c);
md = NV_DATA_P(m);
comm = NV_COMM_P(x);
temp = ONE;
for (i = 0; i < N; i++) {
md[i] = ZERO;
if (cd[i] == ZERO) continue;
if (cd[i] > ONEPT5 || cd[i] < -ONEPT5) {
if (xd[i]*cd[i] <= ZERO) { temp = ZERO; md[i] = ONE; }
continue;
}
if (cd[i] > HALF || cd[i] < -HALF) {
if (xd[i]*cd[i] < ZERO ) { temp = ZERO; md[i] = ONE; }
}
}
temp = VAllReduce_Parallel(temp, 3, comm);
if (temp == ONE) return(TRUE);
else return(FALSE);
}
示例3: N_VInvTest_Parallel
booleantype N_VInvTest_Parallel(N_Vector x, N_Vector z)
{
long int i, N;
realtype *xd, *zd, val, gval;
MPI_Comm comm;
xd = zd = NULL;
N = NV_LOCLENGTH_P(x);
xd = NV_DATA_P(x);
zd = NV_DATA_P(z);
comm = NV_COMM_P(x);
val = ONE;
for (i = 0; i < N; i++) {
if (xd[i] == ZERO)
val = ZERO;
else
zd[i] = ONE/xd[i];
}
gval = VAllReduce_Parallel(val, 3, comm);
if (gval == ZERO)
return(FALSE);
else
return(TRUE);
}
示例4: N_VWrmsNormMask_Parallel
realtype N_VWrmsNormMask_Parallel(N_Vector x, N_Vector w, N_Vector id)
{
long int i, N, N_global;
realtype sum, prodi, *xd, *wd, *idd, gsum;
MPI_Comm comm;
sum = ZERO;
xd = wd = idd = NULL;
N = NV_LOCLENGTH_P(x);
N_global = NV_GLOBLENGTH_P(x);
xd = NV_DATA_P(x);
wd = NV_DATA_P(w);
idd = NV_DATA_P(id);
comm = NV_COMM_P(x);
for (i = 0; i < N; i++) {
if (idd[i] > ZERO) {
prodi = xd[i]*wd[i];
sum += SUNSQR(prodi);
}
}
gsum = VAllReduce_Parallel(sum, 1, comm);
return(SUNRsqrt(gsum/N_global));
}
示例5: N_VMinQuotient_Parallel
realtype N_VMinQuotient_Parallel(N_Vector num, N_Vector denom)
{
booleantype notEvenOnce;
long int i, N;
realtype *nd, *dd, min;
MPI_Comm comm;
nd = dd = NULL;
N = NV_LOCLENGTH_P(num);
nd = NV_DATA_P(num);
dd = NV_DATA_P(denom);
comm = NV_COMM_P(num);
notEvenOnce = TRUE;
min = BIG_REAL;
for (i = 0; i < N; i++) {
if (dd[i] == ZERO) continue;
else {
if (!notEvenOnce) min = SUNMIN(min, nd[i]/dd[i]);
else {
min = nd[i]/dd[i];
notEvenOnce = FALSE;
}
}
}
return(VAllReduce_Parallel(min, 3, comm));
}
示例6: Vaxpy_Parallel
static void Vaxpy_Parallel(realtype a, N_Vector x, N_Vector y)
{
long int i, N;
realtype *xd, *yd;
xd = yd = NULL;
N = NV_LOCLENGTH_P(x);
xd = NV_DATA_P(x);
yd = NV_DATA_P(y);
if (a == ONE) {
for (i = 0; i < N; i++)
yd[i] += xd[i];
return;
}
if (a == -ONE) {
for (i = 0; i < N; i++)
yd[i] -= xd[i];
return;
}
for (i = 0; i < N; i++)
yd[i] += a*xd[i];
return;
}
示例7: SetInitialProfile
static int SetInitialProfile(N_Vector uu, N_Vector up, N_Vector id,
N_Vector res, UserData data)
{
int i, iloc, j, jloc, offset, loc, ixsub, jysub;
int ixbegin, ixend, jybegin, jyend;
realtype xfact, yfact, *udata, *iddata, dx, dy;
/* Initialize uu. */
udata = NV_DATA_P(uu);
iddata = NV_DATA_P(id);
/* Set mesh spacings and subgrid indices for this PE. */
dx = data->dx;
dy = data->dy;
ixsub = data->ixsub;
jysub = data->jysub;
/* Set beginning and ending locations in the global array corresponding
to the portion of that array assigned to this processor. */
ixbegin = MXSUB*ixsub;
ixend = MXSUB*(ixsub+1) - 1;
jybegin = MYSUB*jysub;
jyend = MYSUB*(jysub+1) - 1;
/* Loop over the local array, computing the initial profile value.
The global indices are (i,j) and the local indices are (iloc,jloc).
Also set the id vector to zero for boundary points, one otherwise. */
N_VConst(ONE,id);
for (j = jybegin, jloc = 0; j <= jyend; j++, jloc++) {
yfact = data->dy*j;
offset= jloc*MXSUB;
for (i = ixbegin, iloc = 0; i <= ixend; i++, iloc++) {
xfact = data->dx * i;
loc = offset + iloc;
udata[loc] = RCONST(16.0) * xfact * (ONE - xfact) * yfact * (ONE - yfact);
if (i == 0 || i == MX-1 || j == 0 || j == MY-1) iddata[loc] = ZERO;
}
}
/* Initialize up. */
N_VConst(ZERO, up); /* Initially set up = 0. */
/* heatres sets res to negative of ODE RHS values at interior points. */
heatres(ZERO, uu, up, res, data);
/* Copy -res into up to get correct initial up values. */
N_VScale(-ONE, res, up);
return(0);
}
示例8: N_VDestroy_Parallel
void N_VDestroy_Parallel(N_Vector v)
{
if ((NV_OWN_DATA_P(v) == TRUE) && (NV_DATA_P(v) != NULL)) {
free(NV_DATA_P(v));
NV_DATA_P(v) = NULL;
}
free(v->content); v->content = NULL;
free(v->ops); v->ops = NULL;
free(v); v = NULL;
return;
}
示例9: cvode_rhs
static int cvode_rhs(real t,
N_Vector u, N_Vector du,
void *user_data)
{
real *udata = NV_DATA_P(u);
real *dudata = NV_DATA_P(du);
Solver *s = (Solver*) user_data;
// Calculate residuals
s->rhs(t, udata, dudata);
return 0;
}
示例10: cvode_jac
/// Jacobian-vector multiplication function
static int cvode_jac(N_Vector v, N_Vector Jv,
realtype t, N_Vector y, N_Vector fy,
void *user_data, N_Vector tmp)
{
real *ydata = NV_DATA_P(y); ///< System state
real *vdata = NV_DATA_P(v); ///< Input vector
real *Jvdata = NV_DATA_P(Jv); ///< Jacobian*vector output
Solver *s = (Solver*) user_data;
s->jac(t, ydata, vdata, Jvdata);
return 0;
}
示例11: N_VAddConst_Parallel
void N_VAddConst_Parallel(N_Vector x, realtype b, N_Vector z)
{
long int i, N;
realtype *xd, *zd;
xd = zd = NULL;
N = NV_LOCLENGTH_P(x);
xd = NV_DATA_P(x);
zd = NV_DATA_P(z);
for (i = 0; i < N; i++) zd[i] = xd[i]+b;
return;
}
示例12: ucomm
static void ucomm(realtype t, N_Vector u, UserData data)
{
realtype *udata, *uext, buffer[2*NVARS*MYSUB];
MPI_Comm comm;
int my_pe, isubx, isuby;
long int nvmxsub, nvmysub;
MPI_Request request[4];
udata = NV_DATA_P(u);
/* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
comm = data->comm; my_pe = data->my_pe;
isubx = data->isubx; isuby = data->isuby;
nvmxsub = data->nvmxsub;
nvmysub = NVARS*MYSUB;
uext = data->uext;
/* Start receiving boundary data from neighboring PEs */
BRecvPost(comm, request, my_pe, isubx, isuby, nvmxsub, nvmysub, uext, buffer);
/* Send data from boundary of local grid to neighboring PEs */
BSend(comm, my_pe, isubx, isuby, nvmxsub, nvmysub, udata);
/* Finish receiving boundary data from neighboring PEs */
BRecvWait(request, isubx, isuby, nvmxsub, uext, buffer);
}
示例13: N_VClone_Parallel
N_Vector N_VClone_Parallel(N_Vector w)
{
N_Vector v;
realtype *data;
long int local_length;
v = NULL;
v = N_VCloneEmpty_Parallel(w);
if (v == NULL) return(NULL);
local_length = NV_LOCLENGTH_P(w);
/* Create data */
if(local_length > 0) {
/* Allocate memory */
data = NULL;
data = (realtype *) malloc(local_length * sizeof(realtype));
if(data == NULL) { N_VDestroy_Parallel(v); return(NULL); }
/* Attach data */
NV_OWN_DATA_P(v) = TRUE;
NV_DATA_P(v) = data;
}
return(v);
}
示例14: N_VNew_Parallel
N_Vector N_VNew_Parallel(MPI_Comm comm,
long int local_length,
long int global_length)
{
N_Vector v;
realtype *data;
v = NULL;
v = N_VNewEmpty_Parallel(comm, local_length, global_length);
if (v == NULL) return(NULL);
/* Create data */
if(local_length > 0) {
/* Allocate memory */
data = NULL;
data = (realtype *) malloc(local_length * sizeof(realtype));
if(data == NULL) { N_VDestroy_Parallel(v); return(NULL); }
/* Attach data */
NV_OWN_DATA_P(v) = TRUE;
NV_DATA_P(v) = data;
}
return(v);
}
示例15: cvode_pre
/// Preconditioner function
static int cvode_pre(real t, N_Vector yy, N_Vector yp,
N_Vector rvec, N_Vector zvec,
real gamma, real delta, int lr,
void *user_data, N_Vector tmp)
{
real *udata = NV_DATA_P(yy);
real *rdata = NV_DATA_P(rvec);
real *zdata = NV_DATA_P(zvec);
Solver *s = (Solver*) user_data;
// Calculate residuals
s->pre(t, gamma, delta, udata, rdata, zdata);
return 0;
}