Skip to content

Commit

Permalink
Digitization (PSNS) and Application of Digitized Pressure (PUMP) (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
Novocain1 authored and jacob1 committed Mar 4, 2018
1 parent c3ff761 commit 68efe49
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/simulation/elements/PSNS.cpp
Expand Up @@ -48,6 +48,8 @@ Element_PSNS::Element_PSNS()
int Element_PSNS::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
float photonWl = 0.0f;
bool setFilt = false;
if (sim->pv[y/CELL][x/CELL] > parts[i].temp-273.15f)
{
parts[i].life = 0;
Expand All @@ -70,6 +72,35 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS)
}
}
}
if (parts[i].tmp == 1)
{
parts[i].life = 0;
setFilt = true;
photonWl = sim->pv[y / CELL][x / CELL];
if (setFilt)
{
int nx, ny;
for (rx = -1; rx < 2; rx++)
for (ry = -1; ry < 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y + ry][x + rx];
if (!r)
continue;
nx = x + rx;
ny = y + ry;
while (TYP(r) == PT_FILT)
{
parts[ID(r)].ctype = 0x10000000 + roundl(photonWl) + 256;
nx += rx;
ny += ry;
if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES)
break;
r = pmap[ny][nx];
}
}
}
}
return 0;
}

Expand Down
13 changes: 12 additions & 1 deletion src/simulation/elements/PUMP.cpp
Expand Up @@ -63,7 +63,7 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS)

for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (!(rx && ry))
if (parts[i].tmp != 1 && (!(rx && ry)))
{
sim->pv[(y/CELL)+ry][(x/CELL)+rx] += 0.1f*((parts[i].temp-273.15)-sim->pv[(y/CELL)+ry][(x/CELL)+rx]);
}
Expand All @@ -81,6 +81,17 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS)
else if (parts[ID(r)].life==0)
parts[ID(r)].life = 10;
}
if (parts[i].tmp == 1 && (TYP(r) == PT_FILT || TYP(r) == PT_PHOT || TYP(r) == PT_BRAY))
{
if (parts[ID(r)].ctype >= 0x10000000 && parts[ID(r)].ctype <= 0x10000000 + 512)
{
sim->pv[(y / CELL) + ry][(x / CELL) + rx] = (parts[ID(r)].ctype - 0x10000000) - 256;
}
else
{
sim->pv[(y / CELL) + ry][(x / CELL) + rx] = 0.0f;
}
}
}
}
return 0;
Expand Down

0 comments on commit 68efe49

Please sign in to comment.