Skip to content

Commit

Permalink
using nekRS ywd
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadish Saini committed Dec 18, 2023
1 parent 9077b73 commit 8789991
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 38 deletions.
8 changes: 6 additions & 2 deletions examples/phillDES/phill.udf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ci.inc"

static dfloat rho, mueLam;
static occa::memory o_ywd;

#ifdef __okl__

Expand Down Expand Up @@ -64,9 +65,12 @@ void UDF_Setup(nrs_t *nrs)
platform->options.getArgs("VISCOSITY", mueLam);
platform->options.getArgs("DENSITY", rho);

double *ywd = (double *) nek::scPtr(1);
std::vector<int> bidWall = {1,2};
occa::memory o_bidWall = platform->device.malloc<int>(bidWall.size(), bidWall.data());
o_ywd = mesh->minDistance(bidWall.size(), o_bidWall, "cheap");

std::string model = "sst+des";
RANSktau::setup(nrs, mueLam, rho, scalarFieldStart, model, ywd);
RANSktau::setup(nrs, mueLam, rho, scalarFieldStart, model, o_ywd);

if(ciMode){
auto o_u = nrs->o_U.slice(0 * nrs->fieldOffset, nrs->fieldOffset);
Expand Down
21 changes: 0 additions & 21 deletions examples/phillDES/phill.usr
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,6 @@ c-----------------------------------------------------------------------
include 'SIZE'
include 'TOTAL'

common /walldist/ ywd(lx1,ly1,lz1,lelt)
real ywd

real w1,w2,w3,w4,w5
common /SCRNS/
& w1(lx1*ly1*lz1*lelv)
& ,w2(lx1*ly1*lz1*lelv)
& ,w3(lx1*ly1*lz1*lelv)
& ,w4(lx1*ly1*lz1*lelv)
& ,w5(lx1*ly1*lz1*lelv)

common /NRSSCPTR/ nrs_scptr(1)
integer*8 nrs_scptr

nxyz = lx1*ly1*lz1
ntot = nxyz*nelt

call cheap_dist(ywd,1,'W ')
!call distf(ywd,1,'W ',w1,w2,w3,w4,w5)
nrs_scptr(1) = loc(ywd(1,1,1,1))

return
end
c-----------------------------------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void rmin(dfloat *s_min, const dlong t, const dlong bs) {
s_min[t] = (s_min[t] < s_min[t + bs]) ? s_min[t] : s_min[t + bs];
}

@kernel void desFilter(const dlong Nelements,
@kernel void desLenScale(const dlong Nelements,
const dlong offset,
@ restrict const dfloat *x,
@ restrict const dfloat *y,
Expand Down
34 changes: 21 additions & 13 deletions src/plugins/RANSktau.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ static occa::kernel computeGradKernel;
static occa::kernel mueKernel;
static occa::kernel mueSSTKernel;
static occa::kernel limitKernel;
static occa::kernel desFilterKernel;
static occa::kernel desLenScaleKernel;

static occa::kernel OiOjSkKernel;

static bool buildKernelCalled = false;
static bool setupCalled = false;
static bool desScaleCalled = false;

static dfloat coeff[] = {
0.6, // sigma_k
Expand Down Expand Up @@ -185,9 +186,9 @@ void RANSktau::buildKernel(occa::properties _kernelInfo)
fileName = path + kernelName + extension;
OiOjSkKernel = platform->device.buildKernel(fileName, kernelInfo, true);

kernelName = "desFilter";
kernelName = "desLenScale";
fileName = path + kernelName + extension;
desFilterKernel = platform->device.buildKernel(fileName, kernelInfo, true);
desLenScaleKernel = platform->device.buildKernel(fileName, kernelInfo, true);

kernelName = "RANSktauComputeHex3D";
fileName = path + kernelName + extension;
Expand Down Expand Up @@ -243,6 +244,9 @@ void RANSktau::updateProperties()
platform->linAlg->magSqrVector(mesh->Nelements * mesh->Np, nrs->fieldOffset, o_Oij, o_OijMag2);
}

//not sure whether i want this here
o_SijOij.free();

computeGradKernel(mesh->Nelements,
nrs->cds->fieldOffset[kFieldIndex],
mesh->o_vgeo,
Expand Down Expand Up @@ -291,7 +295,18 @@ void RANSktau::updateSourceTerms()
}
else {
bool ifDES = false;
if(mid == "SST+DES") ifDES = true;
if(mid == "SST+DES") {
ifDES = true;
if(platform->options.compareArgs("MOVING MESH", "TRUE") || !desScaleCalled) {
desLenScaleKernel(mesh->Nelements,
nrs->fieldOffset,
mesh->o_x,
mesh->o_y,
mesh->o_z,
o_dgrd);
desScaleCalled = true;
}
}
computeSSTKernel(mesh->Nelements * mesh->Np,
nrs->cds->fieldOffset[kFieldIndex],
static_cast<int>(ifDES),
Expand Down Expand Up @@ -353,21 +368,14 @@ void RANSktau::setup(nrs_t *nrsIn, dfloat mueIn, dfloat rhoIn, int ifld, std::st

if(mid == "SST+DES"){
o_dgrd = platform->device.malloc<dfloat>(mesh->Nelements);
desFilterKernel(mesh->Nelements,
nrs->fieldOffset,
mesh->o_x,
mesh->o_y,
mesh->o_z,
o_dgrd);
o_OijMag2 = platform->device.malloc<dfloat>(nrs->fieldOffset);
}
setupCalled = true;
}

void RANSktau::setup(nrs_t *nrsIn, dfloat mueIn, dfloat rhoIn, int ifld, std::string & model, double *ywd)
void RANSktau::setup(nrs_t *nrsIn, dfloat mueIn, dfloat rhoIn, int ifld, std::string & model, occa::memory o_ywdIn)
{
o_ywd = platform->device.malloc<dfloat>(nrsIn->fieldOffset);
o_ywd.copyFrom(ywd, nrsIn->fieldOffset);
o_ywd = o_ywdIn;

RANSktau::setup(nrsIn, mueIn, rhoIn, ifld, model);
}
2 changes: 1 addition & 1 deletion src/plugins/RANSktau.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace RANSktau
void buildKernel(occa::properties kernelInfo);
void updateSourceTerms();
void setup(nrs_t* nrsIn, dfloat mue, dfloat rho, int startIndex, std::string & model);
void setup(nrs_t* nrsIn, dfloat mue, dfloat rho, int startIndex, std::string & model, double *ywd);
void setup(nrs_t* nrsIn, dfloat mue, dfloat rho, int startIndex, std::string & model, occa::memory o_ywdIn);
void updateProperties();
occa::memory o_mue_t();
}
Expand Down

0 comments on commit 8789991

Please sign in to comment.