From 52995e2b8ac81d160b5bc75ad141cbdaded6e328 Mon Sep 17 00:00:00 2001 From: James McClure Date: Thu, 9 May 2019 01:01:15 +0200 Subject: [PATCH] added tolerance to MRT --- models/MRTModel.cpp | 16 +++++++++++++++- models/MRTModel.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/models/MRTModel.cpp b/models/MRTModel.cpp index 72b03925..d4413b1b 100644 --- a/models/MRTModel.cpp +++ b/models/MRTModel.cpp @@ -20,11 +20,20 @@ void ScaLBL_MRTModel::ReadParams(string filename){ db = std::make_shared( filename ); domain_db = db->getDatabase( "Domain" ); mrt_db = db->getDatabase( "MRT" ); + + tau = 1.0; + timestepMax = 100000; + tolerance = 0.01; + Fx = Fy = 0.0; + Fz = 1.0e-5; // Color Model parameters if (mrt_db->keyExists( "timestepMax" )){ timestepMax = mrt_db->getScalar( "timestepMax" ); } + if (mrt_db->keyExists( "tolerance" )){ + tolerance = mrt_db->getScalar( "timestepMax" ); + } if (mrt_db->keyExists( "tau" )){ tau = mrt_db->getScalar( "tau" ); } @@ -197,7 +206,9 @@ void ScaLBL_MRTModel::Run(){ if (rank==0) printf("Beginning AA timesteps...\n"); if (rank==0) printf("********************************************************\n"); timestep=0; - while (timestep < timestepMax) { + double error = 1.0; + double flow_rate_previous = 0.0; + while (timestep < timestepMax || error < tolerance) { //************************************************************************/ timestep++; ScaLBL_Comm->SendD3Q19AA(fq); //READ FROM NORMAL @@ -259,6 +270,9 @@ void ScaLBL_MRTModel::Run(){ } double flow_rate = (vax*dir_x + vay*dir_y + vaz*dir_z); + error = fabs(flow_rate - flow_rate_previous) / flow_rate; + flow_rate_previous = flow_rate; + //if (rank==0) printf("Computing Minkowski functionals \n"); Morphology.ComputeScalar(Distance,0.f); //Morphology.PrintAll(); diff --git a/models/MRTModel.h b/models/MRTModel.h index 29d4702b..aa4ee1f0 100644 --- a/models/MRTModel.h +++ b/models/MRTModel.h @@ -36,6 +36,7 @@ public: double tau,mu; double Fx,Fy,Fz,flux; double din,dout; + double tolerance; int Nx,Ny,Nz,N,Np; int rank,nprocx,nprocy,nprocz,nprocs;