From 11252ecb3808bc169e9a52ae62f2510f5c75fc01 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 4 Sep 2018 21:34:00 -0400 Subject: [PATCH] better phase field init --- cpu/Color.cpp | 10 +++++++--- gpu/Color.cu | 16 ++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/cpu/Color.cpp b/cpu/Color.cpp index dfed4e40..b2080ec7 100644 --- a/cpu/Color.cpp +++ b/cpu/Color.cpp @@ -2777,11 +2777,15 @@ extern "C" void ScaLBL_PhaseField_Init(int *Map, double *Phi, double *Den, doubl n = Map[idx]; phi = Phi[n]; - if (phi > 0.f){ - nA = 1.0; nB = 0.f; + if (phi > 1.f){ + nA = 1.0; nB = 0.f; + } + else if (phi < -1.f){ + nB = 1.0; nA = 0.f; } else{ - nB = 1.0; nA = 0.f; + nA=0.5*(phi-1.f); + nB=0.5*(phi+1.f); } Den[idx] = nA; Den[Np+idx] = nB; diff --git a/gpu/Color.cu b/gpu/Color.cu index a5861617..f5931d51 100644 --- a/gpu/Color.cu +++ b/gpu/Color.cu @@ -3902,12 +3902,16 @@ __global__ void dvc_ScaLBL_PhaseField_Init(int *Map, double *Phi, double *Den, d n = Map[idx]; phi = Phi[n]; - if (phi > 0.f){ - nA = 1.0; nB = 0.f; - } - else{ - nB = 1.0; nA = 0.f; - } + if (phi > 1.f){ + nA = 1.0; nB = 0.f; + } + else if (phi < -1.f){ + nB = 1.0; nA = 0.f; + } + else{ + nA=0.5*(phi-1.f); + nB=0.5*(phi+1.f); + } Den[idx] = nA; Den[Np+idx] = nB;