From 8e4169cb83c8b61284f0121823688f4460967544 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Fri, 19 Apr 2019 10:49:55 -0400 Subject: [PATCH] updated color model with default parameters --- common/Domain.cpp | 1 + models/ColorModel.cpp | 94 +++++++++++++++++++++++++++++-------------- 2 files changed, 65 insertions(+), 30 deletions(-) diff --git a/common/Domain.cpp b/common/Domain.cpp index e8780c32..3d122f04 100644 --- a/common/Domain.cpp +++ b/common/Domain.cpp @@ -119,6 +119,7 @@ void Domain::initialize( std::shared_ptr db ) auto nproc = d_db->getVector("nproc"); auto n = d_db->getVector("n"); + voxel_length = 1.0; if (d_db->keyExists( "voxel_length" )){ auto voxel_length = d_db->getScalar("voxel_length"); } diff --git a/models/ColorModel.cpp b/models/ColorModel.cpp index e01783c5..01dd02f6 100644 --- a/models/ColorModel.cpp +++ b/models/ColorModel.cpp @@ -61,41 +61,65 @@ void ScaLBL_ColorModel::ReadParams(string filename){ color_db = db->getDatabase( "Color" ); analysis_db = db->getDatabase( "Analysis" ); + // set defaults + timestepMax = 100000; + tauA = tauB = 1.0; + rhoA = rhoB = 1.0; + Fx = Fy = Fz = 0.0; + alpha=1e-3; + beta=0.95; + Restart=false; + din=dout=1.0; + flux=0.0; + // Color Model parameters - timestepMax = color_db->getScalar( "timestepMax" ); - tauA = color_db->getScalar( "tauA" ); - tauB = color_db->getScalar( "tauB" ); - rhoA = color_db->getScalar( "rhoA" ); - rhoB = color_db->getScalar( "rhoB" ); - Fx = color_db->getVector( "F" )[0]; - Fy = color_db->getVector( "F" )[1]; - Fz = color_db->getVector( "F" )[2]; - alpha = color_db->getScalar( "alpha" ); - beta = color_db->getScalar( "beta" ); - Restart = color_db->getScalar( "Restart" ); - din = color_db->getScalar( "din" ); - dout = color_db->getScalar( "dout" ); - flux = color_db->getScalar( "flux" ); + if (color_db->keyExists( "timestepMax" )){ + timestepMax = color_db->getScalar( "timestepMax" ); + } + if (color_db->keyExists( "tauA" )){ + tauA = color_db->getScalar( "tauA" ); + } + if (color_db->keyExists( "tauB" )){ + tauB = color_db->getScalar( "tauB" ); + } + if (color_db->keyExists( "rhoA" )){ + rhoA = color_db->getScalar( "rhoA" ); + } + if (color_db->keyExists( "rhoB" )){ + rhoB = color_db->getScalar( "rhoB" ); + } + if (color_db->keyExists( "F" )){ + Fx = color_db->getVector( "F" )[0]; + Fy = color_db->getVector( "F" )[1]; + Fz = color_db->getVector( "F" )[2]; + } + if (color_db->keyExists( "alpha" )){ + alpha = color_db->getScalar( "alpha" ); + } + if (color_db->keyExists( "beta" )){ + beta = color_db->getScalar( "beta" ); + } + if (color_db->keyExists( "Restart" )){ + Restart = color_db->getScalar( "Restart" ); + } + if (color_db->keyExists( "din" )){ + din = color_db->getScalar( "din" ); + } + if (color_db->keyExists( "dout" )){ + dout = color_db->getScalar( "dout" ); + } + if (color_db->keyExists( "flux" )){ + flux = color_db->getScalar( "flux" ); + } inletA=1.f; inletB=0.f; outletA=0.f; outletB=1.f; - // Read domain parameters - auto L = domain_db->getVector( "L" ); - auto size = domain_db->getVector( "n" ); - auto nproc = domain_db->getVector( "nproc" ); - BoundaryCondition = domain_db->getScalar( "BC" ); - Nx = size[0]; - Ny = size[1]; - Nz = size[2]; - Lx = L[0]; - Ly = L[1]; - Lz = L[2]; - nprocx = nproc[0]; - nprocy = nproc[1]; - nprocz = nproc[2]; - + BoundaryCondition = 0; + if (domain_db->keyExists( "BC" )){ + BoundaryCondition = domain_db->getScalar( "BC" ); + } if (BoundaryCondition==4) flux *= rhoA; // mass flux must adjust for density (see formulation for details) } @@ -111,7 +135,17 @@ void ScaLBL_ColorModel::SetDomain(){ MPI_Barrier(comm); Dm->CommInit(); MPI_Barrier(comm); - rank = Dm->rank(); + // Read domain parameters + rank = Dm->rank(); + Nx = Dm->Nx; + Ny = Dm->Ny; + Nz = Dm->Nz; + Lx = Dm->Lx; + Ly = Dm->Ly; + Lz = Dm->Lz; + nprocx = Dm->nprocx(); + nprocy = Dm->nprocy(); + nprocz = Dm->nprocz(); } void ScaLBL_ColorModel::ReadInput(){