-
Hi all, I'm extending the lowMach example to add sources to additional scalars. To do so, I changed the relevant section in the udf to: void userq(nrs_t *nrs, dfloat time, occa::memory o_S, occa::memory o_FS)
{
cds_t *cds = nrs->cds;
mesh_t *mesh = cds->mesh[0];
fillQ(mesh->Nelements, nrs->cds->fieldOffset[0], o_FS, o_S);
} The corresponding oudf file becomes: @kernel void fillQ(const dlong Nelements, const dlong sOffset, @ restrict dfloat *QVOL, @ restrict const dfloat *TEMP)
{
for (dlong e = 0; e < Nelements; ++e; @outer(0)) {
for (int n = 0; n < p_Np; ++n; @inner(0)) {
const int id = e * p_Np + n;
const dfloat temp1 = TEMP[id];
const dfloat zz = TEMP[id + 1 * sOffset];
QVOL[id + 0 * sOffset] = temp1*zz;
QVOL[id + 1 * sOffset] = 1 / temp1;
}
}
} To check results, I output the sources in o_FS for temperature and scalar01 by adding the following lines to UDF_ExecuteStep: void UDF_ExecuteStep(nrs_t *nrs, dfloat time, int tstep)
{
cds_t *cds = nrs->cds;
if (nrs->isOutputStep) {
nek::ocopyToNek(time, tstep);
nek::userchk();
const auto fieldOffsetBytes = nrs->fieldOffset * sizeof(dfloat);
auto o_field1 = nrs->cds->o_FS.slice(0 * fieldOffsetBytes, fieldOffsetBytes);
auto o_field2 = nrs->cds->o_FS.slice(1 * fieldOffsetBytes, fieldOffsetBytes);
bool coords = true;
bool FP64 = true;
int Nscalar = nrs->Nscalar;
occa::memory o_null;
writeFld("fs1", time, tstep, coords, FP64, &o_null, &o_field1, &o_null, Nscalar);
writeFld("fs2", time, tstep, coords, FP64, &o_null, &o_field2, &o_null, Nscalar);
}
} I have the corresponding nek5000 simulation as a check, and can confirm that this method does not add the correct source terms to the scalars. Does anyone notice anything wrong with the approach? I just switched over to nekrs so perhaps I have missed something. Thanks for the help, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
What you see as |
Beta Was this translation helpful? Give feedback.
What you see as
cds->o_FS
inUDF_ExecuteStep
will not contain just the source term. Additional things like the convection term will be added tocds->o_FS
. Moreover it's weighted byJw
.