Skip to content

Commit 39adcdf

Browse files
committed
merged upstream master
2 parents 0402bf2 + 2362a9d commit 39adcdf

File tree

9 files changed

+524
-44
lines changed

9 files changed

+524
-44
lines changed

models/particles/d3q27_PSM/Dynamics.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ AddQuantity(name="U",unit="m/s",vector=T)
7171
AddQuantity(name="Rho",unit="kg/m3")
7272

7373
AddSetting(name="omegaF", comment='one over F relaxation time and initial relaxation time for kl')
74-
AddSetting(name="nu", omegaF='1.0/(3*nu+0.5)', default=0.1, comment='kinetic viscosity in LBM unit')
74+
AddSetting(name="nu", omegaF='1.0/(3*nu+0.5)', default=0.1, comment='kinetic viscosity in LBM unit', unit='m2/s')
7575

7676
if (Options$TRT) {
7777
AddSetting( name="Lambda", comment="TRT Magic Number")
@@ -120,6 +120,8 @@ AddNodeType(name="BPressure", group="BOUNDARY")
120120

121121
AddNodeType(name="MovingWall_N", group="BOUNDARY")
122122
AddNodeType(name="MovingWall_S", group="BOUNDARY")
123+
AddNodeType(name="MovingWall_E", group="BOUNDARY")
124+
AddNodeType(name="MovingWall_W", group="BOUNDARY")
123125

124126

125127
if (Options$particles) {

models/particles/d3q27_PSM/Dynamics.c.Rt

+115-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Code updates:
2727

2828
*/
2929

30-
#define SQRT_3 1.732050807568877
3130
#define PI 3.141592653589793
3231

3332
<?R
@@ -178,6 +177,13 @@ CudaDeviceFunction void Run() {
178177
MovingSWall();
179178
break;
180179

180+
case NODE_MovingWall_E:
181+
MovingEWall();
182+
break;
183+
184+
case NODE_MovingWall_W:
185+
MovingWWall();
186+
break;
181187
}
182188

183189
switch (NodeType & NODE_COLLISION) {
@@ -393,7 +399,7 @@ CudaDeviceFunction void PressureExitB()
393399

394400
CudaDeviceFunction void MovingNWall()
395401
{
396-
f[1] = f[3];
402+
f[4] = f[3];
397403
f[16] = f[17];
398404
f[18] = f[15];
399405

@@ -420,6 +426,35 @@ CudaDeviceFunction void MovingSWall(){
420426
f[7] = f[10] + VelocityX/9.0;
421427
}
422428

429+
CudaDeviceFunction void MovingEWall()
430+
{
431+
f[2] = f[1];
432+
f[8] = f[9];
433+
f[10] = f[7];
434+
435+
f[20] = f[25] + VelocityZ/36.0;
436+
f[22] = f[23] + VelocityZ/36.0;
437+
f[12] = f[13] + VelocityZ/9.0;
438+
439+
f[24] = f[21] - VelocityZ/36.0;
440+
f[26]= f[19] - VelocityZ/36.0;
441+
f[14] = f[11] - VelocityZ/9.0;
442+
}
443+
444+
CudaDeviceFunction void MovingWWall()
445+
{
446+
f[1] = f[2];
447+
f[9] = f[8];
448+
f[7] = f[10];
449+
450+
f[25] = f[20] - VelocityZ/36.0;
451+
f[23] = f[22] - VelocityZ/36.0;
452+
f[13] = f[12] - VelocityZ/9.0;
453+
454+
f[21] = f[24] + VelocityZ/36.0;
455+
f[19]= f[26] + VelocityZ/36.0;
456+
f[11] = f[14] + VelocityZ/9.0;
457+
}
423458

424459
CudaDeviceFunction void CalcEquilibrium(real_t f_tab[27], real_t d, real_t u[3])
425460
{
@@ -450,11 +485,59 @@ CudaDeviceFunction void CalcF() {
450485
C( uP, 0)
451486
C( sol, 0)
452487
?>
488+
489+
<?R if (Options$MS) { ?>
490+
491+
for (auto p : SyncParticleIterator(X,Y,Z)) {
492+
493+
real_t dist = sqrt(p.diff.x*p.diff.x + p.diff.y*p.diff.y + p.diff.z*p.diff.z);
494+
495+
if ((dist - p.rad) < 0.5) {
496+
497+
real_t localCoverage = 0.0;
498+
499+
if ((dist - p.rad) < -1.0){
500+
localCoverage = 1.0;
501+
} else{
502+
localCoverage = (p.rad - 0.084/p.rad + 0.5 - dist);
503+
}
504+
505+
if (localCoverage > 1.0){ localCoverage = 1.0;}
506+
if (localCoverage < 0.0){ localCoverage = 0.0;}
507+
508+
<?R if (Options$KL) { ?>
509+
510+
real_t omegaF_tmp = 1.0/(3.0*nu_app+0.5); //From previous timestep
511+
localCoverage = localCoverage*(1.0/omegaF_tmp - 0.5) / ((1 - localCoverage) + 1.0/omegaF_tmp - 0.5);
512+
513+
<?R } else { ?>
514+
515+
localCoverage = localCoverage*(1.0/omegaF - 0.5) / ((1 - localCoverage) + 1.0/omegaF - 0.5);
516+
517+
<?R } ?>
518+
519+
<?R
520+
localCoverage = PV("localCoverage")
521+
C( sol, sol + localCoverage )
522+
?>
523+
}
524+
525+
}
526+
527+
real_t sol_factor = 1.0;
528+
529+
<?R sol_factor = PV("sol_factor") ?>
530+
if (sol > 1.0) {
531+
sol_factor = 1.0/sol;
532+
}
533+
534+
<?R } ?>
535+
453536
for (auto p : SyncParticleIterator(X,Y,Z)) {
454537

455538
real_t dist = sqrt(p.diff.x*p.diff.x + p.diff.y*p.diff.y + p.diff.z*p.diff.z);
456539

457-
if ((dist - p.rad)<SQRT_3) {
540+
if ((dist - p.rad) < 0.5) {
458541

459542
real_t localCoverage = 0.0;
460543

@@ -483,21 +566,42 @@ CudaDeviceFunction void CalcF() {
483566
uparticle = PV("p.cvel.",c("x","y","z"))
484567
force = PV("force.",c("x","y","z"))
485568
localCoverage = PV("localCoverage")
486-
C( force, d*localCoverage*(u - uparticle) )
487-
?>
488-
p.applyForce(force);
489-
<?R
490-
C( sol, sol + localCoverage )
569+
570+
if (Options$MS) {
571+
572+
C( force, d*sol_factor*localCoverage*(u - uparticle) )
573+
574+
} else {
575+
576+
C( force, d*localCoverage*(u - uparticle) )
577+
C( sol, sol + localCoverage )
578+
579+
}
580+
491581
C( uP, uP + localCoverage*uparticle )
492582
?>
583+
p.applyForce(force);
493584
}
494585

495586
}
496587

497-
if (sol > 1.0) { sol = 1.0; }
588+
<?R if (Options$MS) { ?>
589+
498590
if (sol > 1.0e-8) {
499-
<?R C( uP, uP*sol^{-1} ) ?>
500-
} else {
591+
<?R C( uP, uP*sol^{-1} ) ?>
592+
if (sol > 1.0) { sol = 1.0; }
593+
}
594+
595+
<?R } else { ?>
596+
597+
if (sol > 1.0) { sol = 1.0; }
598+
if (sol > 1.0e-8) {
599+
<?R C( uP, uP*sol^{-1} ) ?>
600+
}
601+
602+
<?R } ?>
603+
604+
else {
501605
<?R
502606
C(uP, 0)
503607
C(sol, 0)

models/particles/d3q27_PSM/conf.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ADJOINT=0
22
TEST=FALSE
3-
OPT="KL*TRT*(NEBB+SUP+(NEBB+SEP):singlekernel)"
3+
OPT="MS*KL*TRT*(NEBB+SUP+(NEBB+SEP):singlekernel)"

src/Consts.h.Rt

+2-12
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,11 @@
2424
#define PART_MAR_BOX <?%f max(0,PartMargin-0.5) ?>
2525

2626
<?R
27-
big_hex = function(x,bits=16) {
28-
ret = ""
29-
while (x > 0 | bits > 0) {
30-
a = x %% 16
31-
ret = sprintf("%01x%s",a,ret)
32-
x = (x-a) / 16
33-
bits = bits - 4
34-
}
35-
ret
36-
}
3727
for (n in rows(NodeTypes)) { ?>
38-
#define <?%-20s n$Index ?> 0x<?%s big_hex(n$value) ?> <?R
28+
#define <?%-20s n$Index ?> <?%s big_hex(n$value) ?> <?R
3929
}
4030
for (n in rows(NodeTypeGroups)) { ?>
41-
#define <?%-20s n$Index ?> 0x<?%s big_hex(n$mask) ?> <?R
31+
#define <?%-20s n$Index ?> <?%s big_hex(n$mask) ?> <?R
4232
}
4333
?>
4434
<?R

src/Geometry.cpp

+24-12
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ inline int Geometry::loadSweep(lbRegion reg, pugi::xml_node node)
688688
int order=1;
689689
attr = node.attribute("order");
690690
if (attr) order = attr.as_int();
691-
double dl=1e-3;
691+
double dl=1e-4;
692692
attr = node.attribute("step");
693693
if (attr) dl = attr.as_double();
694694
attr = node.attribute("steps");
@@ -719,19 +719,31 @@ inline int Geometry::loadSweep(lbRegion reg, pugi::xml_node node)
719719
order = n-1;
720720
}
721721
output("Making a Sweep over region (%ld) with %lf step\n",reg.size(), dl);
722-
for (int x = reg.dx; x < reg.dx + reg.nx; x++)
723-
for (int y = reg.dy; y < reg.dy + reg.ny; y++)
724-
for (int z = reg.dz; z < reg.dz + reg.nz; z++) {
725-
for (double l=0;l<1; l+= dl) {
726-
double x0 = bspline(l, nx, order);
727-
double y0 = bspline(l, ny, order);
728-
double z0 = bspline(l, nz, order);
729-
double r = bspline(l, nr, order);
730-
if ((x-x0)*(x-x0)+(y-y0)*(y-y0)+(z-z0)*(z-z0) < r*r) {
731-
Dot(x, y, z);
722+
723+
double x0_=-999.0, y0_=-999.0, z0_=-999.0, r0_=-999.0;
724+
for (double l=0;l<1; l+= dl) {
725+
double x0 = bspline(l, nx, order);
726+
double y0 = bspline(l, ny, order);
727+
double z0 = bspline(l, nz, order);
728+
double r = bspline(l, nr, order);
729+
730+
if (abs(x0-x0_) < 0.25 &&
731+
abs(y0-y0_) < 0.25 &&
732+
abs(z0-z0_) < 0.25 &&
733+
abs(r-r0_) < 0.25) {
734+
continue;
735+
}
736+
x0_ = x0; y0_ = y0; z0_ = z0; r0_ = r;
737+
738+
lbRegion tmpReg=reg.intersect(lbRegion(x0-r-1,y0-r-1,z0-r-1,2*r+2,2*r+2,2*r+2));
739+
for (int x = tmpReg.dx; x < tmpReg.dx + tmpReg.nx; x++)
740+
for (int y = tmpReg.dy; y < tmpReg.dy + tmpReg.ny; y++)
741+
for (int z = tmpReg.dz; z < tmpReg.dz + tmpReg.nz; z++) {
742+
if ((.5+x-x0)*(.5+x-x0)+(.5+y-y0)*(.5+y-y0)+(.5+z-z0)*(.5+z-z0) < r*r) {
743+
Dot(x, y, z);
732744
}
733745
}
734-
}
746+
}
735747

736748
return 0;
737749
}

0 commit comments

Comments
 (0)