From 11252ecb3808bc169e9a52ae62f2510f5c75fc01 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 4 Sep 2018 21:34:00 -0400 Subject: [PATCH 1/6] 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; From 50f26adccaab7f4beba9afd73d1031bb4fafb814 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 4 Sep 2018 21:40:44 -0400 Subject: [PATCH 2/6] fix phase field init --- cpu/Color.cpp | 2 +- gpu/Color.cu | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/Color.cpp b/cpu/Color.cpp index b2080ec7..dd2f863a 100644 --- a/cpu/Color.cpp +++ b/cpu/Color.cpp @@ -2785,7 +2785,7 @@ extern "C" void ScaLBL_PhaseField_Init(int *Map, double *Phi, double *Den, doubl } else{ nA=0.5*(phi-1.f); - nB=0.5*(phi+1.f); + nB=0.5*(1.f-phi); } Den[idx] = nA; Den[Np+idx] = nB; diff --git a/gpu/Color.cu b/gpu/Color.cu index f5931d51..3fdc272a 100644 --- a/gpu/Color.cu +++ b/gpu/Color.cu @@ -3910,7 +3910,7 @@ __global__ void dvc_ScaLBL_PhaseField_Init(int *Map, double *Phi, double *Den, d } else{ nA=0.5*(phi-1.f); - nB=0.5*(phi+1.f); + nB=0.5*(1.f-phi); } Den[idx] = nA; Den[Np+idx] = nB; From b04120e8f0c17f1fcb6e262c7c96d0b68ed2be92 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 4 Sep 2018 21:51:35 -0400 Subject: [PATCH 3/6] fix phase field init --- gpu/Color.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpu/Color.cu b/gpu/Color.cu index 3fdc272a..e8de8f02 100644 --- a/gpu/Color.cu +++ b/gpu/Color.cu @@ -3909,7 +3909,7 @@ __global__ void dvc_ScaLBL_PhaseField_Init(int *Map, double *Phi, double *Den, d nB = 1.0; nA = 0.f; } else{ - nA=0.5*(phi-1.f); + nA=0.5*(phi+1.f); nB=0.5*(1.f-phi); } Den[idx] = nA; From b4936bfa280d1274e1e163388474411b2c6addbb Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 4 Sep 2018 22:00:33 -0400 Subject: [PATCH 4/6] fix phase field init --- cpu/Color.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/Color.cpp b/cpu/Color.cpp index dd2f863a..40a70552 100644 --- a/cpu/Color.cpp +++ b/cpu/Color.cpp @@ -2784,7 +2784,7 @@ extern "C" void ScaLBL_PhaseField_Init(int *Map, double *Phi, double *Den, doubl nB = 1.0; nA = 0.f; } else{ - nA=0.5*(phi-1.f); + nA=0.5*(phi+1.f); nB=0.5*(1.f-phi); } Den[idx] = nA; From e2ca178e3db24a9bed7bcba42ca553e13aa4229e Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 4 Sep 2018 22:10:29 -0400 Subject: [PATCH 5/6] fixed color model restart bug --- analysis/runAnalysis.cpp | 41 ++++++++++++++++++++-------------------- models/ColorModel.cpp | 4 +++- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/analysis/runAnalysis.cpp b/analysis/runAnalysis.cpp index 8a953176..34eeb8a0 100644 --- a/analysis/runAnalysis.cpp +++ b/analysis/runAnalysis.cpp @@ -39,25 +39,27 @@ void DeleteArray( const TYPE *p ) class WriteRestartWorkItem: public ThreadPool::WorkItemRet { public: - WriteRestartWorkItem( const char* filename_, std::shared_ptr cphi_, std::shared_ptr cfq_, int N_ ): - filename(filename_), cphi(cphi_), cfq(cfq_), N(N_) {} - virtual void run() { - PROFILE_START("Save Checkpoint",1); - double value; - ofstream File(filename,ios::binary); - for (int n=0; n cphi_, std::shared_ptr cfq_, int N_ ): + filename(filename_), cphi(cphi_), cfq(cfq_), N(N_) {} + virtual void run() { + PROFILE_START("Save Checkpoint",1); + double value; + ofstream File(filename,ios::binary); + for (int n=0; n db, d_meshData[0].mesh = std::make_shared( Dm->rank_info,Dm->Nx-2,Dm->Ny-2,Dm->Nz-2,Dm->Lx,Dm->Ly,Dm->Lz ); auto PhaseVar = std::make_shared(); auto PressVar = std::make_shared(); - auto VxVar = std::make_shared(); auto VyVar = std::make_shared(); auto VzVar = std::make_shared(); - auto SignDistVar = std::make_shared(); auto BlobIDVar = std::make_shared(); + PhaseVar->name = "phase"; PhaseVar->type = IO::VariableType::VolumeVariable; PhaseVar->dim = 1; diff --git a/models/ColorModel.cpp b/models/ColorModel.cpp index 38163bf7..2ce1ec4e 100644 --- a/models/ColorModel.cpp +++ b/models/ColorModel.cpp @@ -297,9 +297,11 @@ void ScaLBL_ColorModel::Initialize(){ double *cDist = new double[19*Np]; ifstream File(LocalRestartFile,ios::binary); double value; - for (int n=0; n Date: Tue, 4 Sep 2018 22:36:22 -0400 Subject: [PATCH 6/6] fix restart bug, blob id bug --- analysis/runAnalysis.cpp | 27 +++++++++++++++++---------- models/ColorModel.cpp | 8 +++++--- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/analysis/runAnalysis.cpp b/analysis/runAnalysis.cpp index 34eeb8a0..30431027 100644 --- a/analysis/runAnalysis.cpp +++ b/analysis/runAnalysis.cpp @@ -39,21 +39,24 @@ void DeleteArray( const TYPE *p ) class WriteRestartWorkItem: public ThreadPool::WorkItemRet { public: - WriteRestartWorkItem( const char* filename_, std::shared_ptr cphi_, std::shared_ptr cfq_, int N_ ): - filename(filename_), cphi(cphi_), cfq(cfq_), N(N_) {} + WriteRestartWorkItem( const char* filename_, std::shared_ptr cDen_, std::shared_ptr cfq_, int N_ ): + filename(filename_), cDen(cDen_), cfq(cfq_), N(N_) {} virtual void run() { PROFILE_START("Save Checkpoint",1); double value; ofstream File(filename,ios::binary); for (int n=0; n cfq,cphi; + std::shared_ptr cfq,cDen; // const DoubleArray& phase; //const DoubleArray& dist; const int N; @@ -601,14 +604,14 @@ void runAnalysis::run( int timestep, TwoPhase& Averages, const double *Phi, d_ScaLBL_Comm->RegularLayout(d_Map,&Velocity[2*d_Np],Averages.Vel_z); PROFILE_STOP("Copy-State",1); } - std::shared_ptr cfq,cPhi; + std::shared_ptr cfq,cDen; //if ( matches(type,AnalysisType::CreateRestart) ) { if (timestep%d_restart_interval==0){ // Copy restart data to the CPU - cPhi = std::shared_ptr(new double[d_Np],DeleteArray); + cDen = std::shared_ptr(new double[2*d_Np],DeleteArray); cfq = std::shared_ptr(new double[19*d_Np],DeleteArray); ScaLBL_CopyToHost(cfq.get(),fq,19*d_Np*sizeof(double)); - ScaLBL_CopyToHost(cPhi.get(),Phi,d_Np*sizeof(double)); + ScaLBL_CopyToHost(cDen.get(),Den,2*d_Np*sizeof(double)); } PROFILE_STOP("Copy data to host",1); @@ -616,6 +619,10 @@ void runAnalysis::run( int timestep, TwoPhase& Averages, const double *Phi, if ( matches(type,AnalysisType::IdentifyBlobs) ) { phase = std::shared_ptr(new DoubleArray(d_N[0],d_N[1],d_N[2])); d_ScaLBL_Comm->RegularLayout(d_Map,Phi,*phase); + if (d_regular) + d_ScaLBL_Comm->RegularLayout(d_Map,Phi,*phase); + else + ScaLBL_CopyToHost(phase.get(),Phi,N*sizeof(double)); BlobIDstruct new_index(new std::pair(0,IntArray())); BlobIDstruct new_ids(new std::pair(0,IntArray())); @@ -653,7 +660,7 @@ void runAnalysis::run( int timestep, TwoPhase& Averages, const double *Phi, fclose(Rst); } // Write the restart file (using a seperate thread) - auto work = new WriteRestartWorkItem(d_restartFile.c_str(),cPhi,cfq,d_Np); + auto work = new WriteRestartWorkItem(d_restartFile.c_str(),cDen,cfq,d_Np); work->add_dependency(d_wait_restart); d_wait_restart = d_tpool.add_work(work); } diff --git a/models/ColorModel.cpp b/models/ColorModel.cpp index 2ce1ec4e..5e77a29d 100644 --- a/models/ColorModel.cpp +++ b/models/ColorModel.cpp @@ -296,9 +296,11 @@ void ScaLBL_ColorModel::Initialize(){ double *cPhi = new double[Np]; double *cDist = new double[19*Np]; ifstream File(LocalRestartFile,ios::binary); - double value; - for (int n=0; n