File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,6 @@ Implementation of color lattice boltzmann model
|
||||
#include "ProfilerApp.h"
|
||||
#include "threadpool/thread_pool.h"
|
||||
|
||||
|
||||
#ifndef ScaLBL_ColorModel_INC
|
||||
#define ScaLBL_ColorModel_INC
|
||||
|
||||
@@ -46,7 +45,7 @@ Implementation of color lattice boltzmann model
|
||||
* Mass transport equations are described by D3Q7 scheme
|
||||
*/
|
||||
|
||||
class ScaLBL_ColorModel{
|
||||
class ScaLBL_ColorModel {
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor
|
||||
@@ -54,81 +53,81 @@ public:
|
||||
* @param NP number of processors
|
||||
* @param COMM MPI communicator
|
||||
*/
|
||||
ScaLBL_ColorModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_ColorModel();
|
||||
|
||||
ScaLBL_ColorModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_ColorModel();
|
||||
|
||||
/**
|
||||
* \brief Read simulation parameters
|
||||
* @param filename input database file that includes "Color" section
|
||||
*/
|
||||
void ReadParams(string filename);
|
||||
|
||||
*/
|
||||
void ReadParams(string filename);
|
||||
|
||||
/**
|
||||
* \brief Read simulation parameters
|
||||
* @param db0 input database that includes "Color" section
|
||||
*/
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
|
||||
/**
|
||||
* \brief Create domain data structures
|
||||
*/
|
||||
void SetDomain();
|
||||
|
||||
void SetDomain();
|
||||
|
||||
/**
|
||||
* \brief Read image data
|
||||
*/
|
||||
void ReadInput();
|
||||
|
||||
void ReadInput();
|
||||
|
||||
/**
|
||||
* \brief Create color model data structures
|
||||
*/
|
||||
void Create();
|
||||
|
||||
void Create();
|
||||
|
||||
/**
|
||||
* \brief Initialize the simulation
|
||||
*/
|
||||
void Initialize();
|
||||
|
||||
void Initialize();
|
||||
|
||||
/**
|
||||
* \brief Run the simulation
|
||||
*/
|
||||
void Run();
|
||||
|
||||
void Run();
|
||||
|
||||
/**
|
||||
* \brief Run the simulation
|
||||
* @param returntime - timestep at which the routine will return
|
||||
*/
|
||||
double Run(int returntime);
|
||||
|
||||
double Run(int returntime);
|
||||
|
||||
/**
|
||||
* \brief Debugging function to dump simulation state to disk
|
||||
*/
|
||||
void WriteDebug();
|
||||
|
||||
void WriteDebug();
|
||||
|
||||
/**
|
||||
* \brief Copy the phase field for use by external methods
|
||||
* @param f - DoubleArray to hold the phase field
|
||||
*/
|
||||
void getPhaseField(DoubleArray &f);
|
||||
|
||||
bool Restart,pBC;
|
||||
bool REVERSE_FLOW_DIRECTION;
|
||||
int timestep,timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA,tauB,rhoA,rhoB,alpha,beta;
|
||||
double Fx,Fy,Fz,flux;
|
||||
double din,dout,inletA,inletB,outletA,outletB;
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
void getPhaseField(DoubleArray &f);
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
bool Restart, pBC;
|
||||
bool REVERSE_FLOW_DIRECTION;
|
||||
int timestep, timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA, tauB, rhoA, rhoB, alpha, beta;
|
||||
double Fx, Fy, Fz, flux;
|
||||
double din, dout, inletA, inletB, outletA, outletB;
|
||||
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
std::shared_ptr<SubPhase> Averages;
|
||||
|
||||
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -137,33 +136,32 @@ public:
|
||||
std::shared_ptr<Database> vis_db;
|
||||
|
||||
IntArray Map;
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
int *dvcMap;
|
||||
double *fq, *Aq, *Bq;
|
||||
double *Den, *Phi;
|
||||
double *ColorGrad;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
int *dvcMap;
|
||||
double *fq, *Aq, *Bq;
|
||||
double *Den, *Phi;
|
||||
double *ColorGrad;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
|
||||
/**
|
||||
* \brief Assign wetting affinity values
|
||||
*/
|
||||
void AssignComponentLabels(double *phase);
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
void AssignComponentLabels(double *phase);
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1051
models/DFHModel.cpp
1051
models/DFHModel.cpp
File diff suppressed because it is too large
Load Diff
@@ -16,38 +16,38 @@ Implementation of color lattice boltzmann model
|
||||
#include "ProfilerApp.h"
|
||||
#include "threadpool/thread_pool.h"
|
||||
|
||||
class ScaLBL_DFHModel{
|
||||
class ScaLBL_DFHModel {
|
||||
public:
|
||||
ScaLBL_DFHModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_DFHModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void AssignSolidPotential();
|
||||
void Run();
|
||||
void WriteDebug();
|
||||
|
||||
bool Restart,pBC;
|
||||
int timestep,timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA,tauB,rhoA,rhoB,alpha,beta;
|
||||
double Fx,Fy,Fz,flux;
|
||||
double din,dout,inletA,inletB,outletA,outletB;
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
ScaLBL_DFHModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_DFHModel();
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void AssignSolidPotential();
|
||||
void Run();
|
||||
void WriteDebug();
|
||||
|
||||
bool Restart, pBC;
|
||||
int timestep, timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA, tauB, rhoA, rhoB, alpha, beta;
|
||||
double Fx, Fy, Fz, flux;
|
||||
double din, dout, inletA, inletB, outletA, outletB;
|
||||
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<TwoPhase> Averages;
|
||||
|
||||
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -64,20 +64,18 @@ public:
|
||||
double *Velocity;
|
||||
double *Gradient;
|
||||
double *Pressure;
|
||||
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void AssignComponentLabels(double *phase);
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,50 +19,50 @@ Implementation of Lee et al JCP 2016 lattice boltzmann model
|
||||
#ifndef ScaLBL_FreeLeeModel_INC
|
||||
#define ScaLBL_FreeLeeModel_INC
|
||||
|
||||
class ScaLBL_FreeLeeModel{
|
||||
class ScaLBL_FreeLeeModel {
|
||||
public:
|
||||
ScaLBL_FreeLeeModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_FreeLeeModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create_TwoFluid();
|
||||
void Initialize_TwoFluid();
|
||||
double Run_TwoFluid(int returntime);
|
||||
ScaLBL_FreeLeeModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_FreeLeeModel();
|
||||
|
||||
void WriteDebug_TwoFluid();
|
||||
void Create_SingleFluid();
|
||||
void Initialize_SingleFluid();
|
||||
void Run_SingleFluid();
|
||||
|
||||
void WriteDebug_SingleFluid();
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create_TwoFluid();
|
||||
void Initialize_TwoFluid();
|
||||
double Run_TwoFluid(int returntime);
|
||||
|
||||
void WriteDebug_TwoFluid();
|
||||
void Create_SingleFluid();
|
||||
void Initialize_SingleFluid();
|
||||
void Run_SingleFluid();
|
||||
|
||||
void WriteDebug_SingleFluid();
|
||||
// test utilities
|
||||
void Create_DummyPhase_MGTest();
|
||||
void MGTest();
|
||||
|
||||
bool Restart,pBC;
|
||||
int timestep,timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA,tauB,rhoA,rhoB;
|
||||
double tau, rho0;//only for single-fluid Lee model
|
||||
double tauM;//relaxation time for phase field (or mass)
|
||||
double W,gamma,kappa,beta;
|
||||
double Fx,Fy,Fz,flux;
|
||||
double din,dout,inletA,inletB,outletA,outletB;
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int Nxh,Nyh,Nzh,Nh; // extra halo width
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
std::shared_ptr<ScaLBLWideHalo_Communicator> ScaLBL_Comm_WideHalo;
|
||||
bool Restart, pBC;
|
||||
int timestep, timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA, tauB, rhoA, rhoB;
|
||||
double tau, rho0; //only for single-fluid Lee model
|
||||
double tauM; //relaxation time for phase field (or mass)
|
||||
double W, gamma, kappa, beta;
|
||||
double Fx, Fy, Fz, flux;
|
||||
double din, dout, inletA, inletB, outletA, outletB;
|
||||
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int Nxh, Nyh, Nzh, Nh; // extra halo width
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
std::shared_ptr<ScaLBLWideHalo_Communicator> ScaLBL_Comm_WideHalo;
|
||||
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
@@ -72,35 +72,34 @@ public:
|
||||
std::shared_ptr<Database> vis_db;
|
||||
|
||||
IntArray Map;
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
int *dvcMap;
|
||||
double *gqbar, *hq;
|
||||
double *mu_phi, *Den, *Phi;
|
||||
double *ColorGrad;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
|
||||
void getPhase(DoubleArray &PhaseValues);
|
||||
void getPotential(DoubleArray &PressureValues, DoubleArray &MuValues);
|
||||
void getVelocity(DoubleArray &Vx, DoubleArray &Vy, DoubleArray &Vz);
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
int *dvcMap;
|
||||
double *gqbar, *hq;
|
||||
double *mu_phi, *Den, *Phi;
|
||||
double *ColorGrad;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
|
||||
void getPhase(DoubleArray &PhaseValues);
|
||||
void getPotential(DoubleArray &PressureValues, DoubleArray &MuValues);
|
||||
void getVelocity(DoubleArray &Vx, DoubleArray &Vy, DoubleArray &Vz);
|
||||
void getData_RegularLayout(const double *data, DoubleArray ®data);
|
||||
|
||||
DoubleArray SignDist;
|
||||
|
||||
|
||||
DoubleArray SignDist;
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void AssignComponentLabels_ChemPotential_ColorGrad();
|
||||
|
||||
void AssignComponentLabels_ChemPotential_ColorGrad();
|
||||
};
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,7 @@ Implementation of two-fluid greyscale color lattice boltzmann model
|
||||
* Mass transport equations are described by D3Q7 scheme
|
||||
*/
|
||||
|
||||
|
||||
class ScaLBL_GreyscaleColorModel{
|
||||
class ScaLBL_GreyscaleColorModel {
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor
|
||||
@@ -34,75 +33,76 @@ public:
|
||||
* @param NP number of processors
|
||||
* @param COMM MPI communicator
|
||||
*/
|
||||
ScaLBL_GreyscaleColorModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_GreyscaleColorModel();
|
||||
|
||||
// functions in they should be run
|
||||
ScaLBL_GreyscaleColorModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_GreyscaleColorModel();
|
||||
|
||||
// functions in they should be run
|
||||
/**
|
||||
* \brief Read simulation parameters
|
||||
* @param filename input database file that includes "Color" section
|
||||
*/
|
||||
void ReadParams(string filename);
|
||||
|
||||
*/
|
||||
void ReadParams(string filename);
|
||||
|
||||
/**
|
||||
* \brief Read simulation parameters
|
||||
* @param db0 input database that includes "Color" section
|
||||
*/
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
|
||||
/**
|
||||
* \brief Create domain data structures
|
||||
*/
|
||||
void SetDomain();
|
||||
|
||||
void SetDomain();
|
||||
|
||||
/**
|
||||
* \brief Read image data
|
||||
*/
|
||||
void ReadInput();
|
||||
|
||||
void ReadInput();
|
||||
|
||||
/**
|
||||
* \brief Create color model data structures
|
||||
*/
|
||||
void Create();
|
||||
|
||||
void Create();
|
||||
|
||||
/**
|
||||
* \brief Initialize the simulation
|
||||
*/
|
||||
void Initialize();
|
||||
|
||||
void Initialize();
|
||||
|
||||
/**
|
||||
* \brief Run the simulation
|
||||
*/
|
||||
void Run();
|
||||
|
||||
void Run();
|
||||
|
||||
/**
|
||||
* \brief Debugging function to dump simulation state to disk
|
||||
*/
|
||||
void WriteDebug();
|
||||
void WriteDebug();
|
||||
void WriteVisFiles();
|
||||
|
||||
bool Restart,pBC;
|
||||
bool REVERSE_FLOW_DIRECTION;
|
||||
int timestep,timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA,tauB,rhoA,rhoB,alpha,beta;
|
||||
double tauA_eff,tauB_eff;
|
||||
double Fx,Fy,Fz,flux;
|
||||
double din,dout,inletA,inletB,outletA,outletB;
|
||||
double GreyPorosity;
|
||||
bool RecoloringOff;//recoloring can be turn off for grey nodes if this is true
|
||||
//double W;//wetting strength paramter for capillary pressure penalty for grey nodes
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
bool Restart, pBC;
|
||||
bool REVERSE_FLOW_DIRECTION;
|
||||
int timestep, timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tauA, tauB, rhoA, rhoB, alpha, beta;
|
||||
double tauA_eff, tauB_eff;
|
||||
double Fx, Fy, Fz, flux;
|
||||
double din, dout, inletA, inletB, outletA, outletB;
|
||||
double GreyPorosity;
|
||||
bool
|
||||
RecoloringOff; //recoloring can be turn off for grey nodes if this is true
|
||||
//double W;//wetting strength paramter for capillary pressure penalty for grey nodes
|
||||
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
std::shared_ptr<GreyPhaseAnalysis> Averages;
|
||||
|
||||
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -111,11 +111,11 @@ public:
|
||||
std::shared_ptr<Database> vis_db;
|
||||
|
||||
IntArray Map;
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
int *dvcMap;
|
||||
double *fq, *Aq, *Bq;
|
||||
double *Den, *Phi;
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
int *dvcMap;
|
||||
double *fq, *Aq, *Bq;
|
||||
double *Den, *Phi;
|
||||
//double *GreySolidPhi; //Model 2 & 3
|
||||
//double *GreySolidGrad;//Model 1 & 4
|
||||
double *GreySolidW;
|
||||
@@ -123,31 +123,31 @@ public:
|
||||
double *GreySw;
|
||||
double *GreyKn;
|
||||
double *GreyKw;
|
||||
double *MobilityRatio;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
double *MobilityRatio;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
double *Porosity_dvc;
|
||||
double *Permeability_dvc;
|
||||
//double *Psi;
|
||||
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Assign wetting affinity values
|
||||
*/
|
||||
void AssignComponentLabels();
|
||||
|
||||
|
||||
/**
|
||||
* \brief Assign wetting affinity values in greyscale regions
|
||||
*/
|
||||
@@ -161,4 +161,3 @@ private:
|
||||
*/
|
||||
double SeedPhaseField(const double seed_water_in_oil);
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,43 +31,43 @@
|
||||
#include "ProfilerApp.h"
|
||||
#include "threadpool/thread_pool.h"
|
||||
|
||||
class ScaLBL_GreyscaleModel{
|
||||
class ScaLBL_GreyscaleModel {
|
||||
public:
|
||||
ScaLBL_GreyscaleModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_GreyscaleModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run();
|
||||
void WriteDebug();
|
||||
void VelocityField();
|
||||
|
||||
bool Restart,pBC;
|
||||
int timestep,timestepMax;
|
||||
int BoundaryCondition;
|
||||
int CollisionType;
|
||||
double tau;
|
||||
double tau_eff;
|
||||
double Den;//constant density
|
||||
double tolerance;
|
||||
double Fx,Fy,Fz,flux;
|
||||
double din,dout;
|
||||
double dp;//solid particle diameter, unit in voxel
|
||||
double GreyPorosity;
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
ScaLBL_GreyscaleModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_GreyscaleModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run();
|
||||
void WriteDebug();
|
||||
void VelocityField();
|
||||
|
||||
bool Restart, pBC;
|
||||
int timestep, timestepMax;
|
||||
int BoundaryCondition;
|
||||
int CollisionType;
|
||||
double tau;
|
||||
double tau_eff;
|
||||
double Den; //constant density
|
||||
double tolerance;
|
||||
double Fx, Fy, Fz, flux;
|
||||
double din, dout;
|
||||
double dp; //solid particle diameter, unit in voxel
|
||||
double GreyPorosity;
|
||||
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -75,13 +75,13 @@ public:
|
||||
std::shared_ptr<Database> analysis_db;
|
||||
std::shared_ptr<Database> vis_db;
|
||||
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
double *fq;
|
||||
double *Permeability;//grey voxel permeability
|
||||
double *Porosity;
|
||||
double *Velocity;
|
||||
double *Pressure_dvc;
|
||||
signed char *id;
|
||||
int *NeighborList;
|
||||
double *fq;
|
||||
double *Permeability; //grey voxel permeability
|
||||
double *Porosity;
|
||||
double *Velocity;
|
||||
double *Pressure_dvc;
|
||||
IntArray Map;
|
||||
DoubleArray SignDist;
|
||||
DoubleArray Velocity_x;
|
||||
@@ -89,18 +89,19 @@ public:
|
||||
DoubleArray Velocity_z;
|
||||
DoubleArray PorosityMap;
|
||||
DoubleArray Pressure;
|
||||
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
Utilities::MPI comm;
|
||||
|
||||
int dist_mem_size;
|
||||
int neighborSize;
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
|
||||
void AssignComponentLabels(double *Porosity, double *Permeablity);
|
||||
void AssignComponentLabels(double *Porosity,double *Permeability,const vector<std::string> &File_poro,const vector<std::string> &File_perm);
|
||||
};
|
||||
|
||||
void AssignComponentLabels(double *Porosity, double *Permeablity);
|
||||
void AssignComponentLabels(double *Porosity, double *Permeability,
|
||||
const vector<std::string> &File_poro,
|
||||
const vector<std::string> &File_perm);
|
||||
};
|
||||
|
||||
2096
models/IonModel.cpp
2096
models/IonModel.cpp
File diff suppressed because it is too large
Load Diff
@@ -20,25 +20,28 @@
|
||||
#include "analysis/Minkowski.h"
|
||||
#include "ProfilerApp.h"
|
||||
|
||||
class ScaLBL_IonModel{
|
||||
class ScaLBL_IonModel {
|
||||
public:
|
||||
ScaLBL_IonModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_IonModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename,vector<int> &num_iter);
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run(double *Velocity, double *ElectricField);
|
||||
ScaLBL_IonModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_IonModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename, vector<int> &num_iter);
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run(double *Velocity, double *ElectricField);
|
||||
void getIonConcentration(DoubleArray &IonConcentration, const size_t ic);
|
||||
void getIonConcentration_debug(int timestep);
|
||||
void getIonFluxDiffusive(DoubleArray &IonFlux_x,DoubleArray &IonFlux_y,DoubleArray &IonFlux_z,const size_t ic);
|
||||
void getIonFluxAdvective(DoubleArray &IonFlux_x,DoubleArray &IonFlux_y,DoubleArray &IonFlux_z,const size_t ic);
|
||||
void getIonFluxElectrical(DoubleArray &IonFlux_x,DoubleArray &IonFlux_y,DoubleArray &IonFlux_z,const size_t ic);
|
||||
void getIonFluxDiffusive(DoubleArray &IonFlux_x, DoubleArray &IonFlux_y,
|
||||
DoubleArray &IonFlux_z, const size_t ic);
|
||||
void getIonFluxAdvective(DoubleArray &IonFlux_x, DoubleArray &IonFlux_y,
|
||||
DoubleArray &IonFlux_z, const size_t ic);
|
||||
void getIonFluxElectrical(DoubleArray &IonFlux_x, DoubleArray &IonFlux_y,
|
||||
DoubleArray &IonFlux_z, const size_t ic);
|
||||
void getIonFluxDiffusive_debug(int timestep);
|
||||
void getIonFluxAdvective_debug(int timestep);
|
||||
void getIonFluxElectrical_debug(int timestep);
|
||||
@@ -46,35 +49,37 @@ public:
|
||||
void DummyElectricField();
|
||||
double CalIonDenConvergence(vector<double> &ci_avg_previous);
|
||||
|
||||
//bool Restart,pBC;
|
||||
int timestep;
|
||||
//bool Restart,pBC;
|
||||
int timestep;
|
||||
vector<int> timestepMax;
|
||||
int BoundaryConditionSolid;
|
||||
double h;//domain resolution, unit [um/lu]
|
||||
double kb,electron_charge,T,Vt;
|
||||
int BoundaryConditionSolid;
|
||||
double h; //domain resolution, unit [um/lu]
|
||||
double kb, electron_charge, T, Vt;
|
||||
double k2_inv;
|
||||
double tolerance;
|
||||
double fluidVelx_dummy,fluidVely_dummy,fluidVelz_dummy;
|
||||
double Ex_dummy,Ey_dummy,Ez_dummy;
|
||||
|
||||
size_t number_ion_species;
|
||||
vector<int> BoundaryConditionInlet;
|
||||
vector<int> BoundaryConditionOutlet;
|
||||
vector<double> IonDiffusivity;//User input unit [m^2/sec]
|
||||
vector<int> IonValence;
|
||||
vector<double> IonConcentration;//unit [mol/m^3]
|
||||
vector<double> Cin;//inlet boundary value, can be either concentration [mol/m^3] or flux [mol/m^2/sec]
|
||||
vector<double> Cout;//outlet boundary value, can be either concentration [mol/m^3] or flux [mol/m^2/sec]
|
||||
vector<double> tau;
|
||||
vector<double> time_conv;
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
double fluidVelx_dummy, fluidVely_dummy, fluidVelz_dummy;
|
||||
double Ex_dummy, Ey_dummy, Ez_dummy;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
size_t number_ion_species;
|
||||
vector<int> BoundaryConditionInlet;
|
||||
vector<int> BoundaryConditionOutlet;
|
||||
vector<double> IonDiffusivity; //User input unit [m^2/sec]
|
||||
vector<int> IonValence;
|
||||
vector<double> IonConcentration; //unit [mol/m^3]
|
||||
vector<double>
|
||||
Cin; //inlet boundary value, can be either concentration [mol/m^3] or flux [mol/m^2/sec]
|
||||
vector<double>
|
||||
Cout; //outlet boundary value, can be either concentration [mol/m^3] or flux [mol/m^2/sec]
|
||||
vector<double> tau;
|
||||
vector<double> time_conv;
|
||||
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -84,8 +89,8 @@ public:
|
||||
DoubleArray Distance;
|
||||
int *NeighborList;
|
||||
double *fq;
|
||||
double *Ci;
|
||||
double *ChargeDensity;
|
||||
double *Ci;
|
||||
double *ChargeDensity;
|
||||
double *IonSolid;
|
||||
double *FluidVelocityDummy;
|
||||
double *ElectricFieldDummy;
|
||||
@@ -94,18 +99,20 @@ public:
|
||||
double *FluxElectrical;
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
char OutputFilename[200];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void AssignSolidBoundary(double *ion_solid);
|
||||
void AssignIonConcentration_FromFile(double *Ci,const vector<std::string> &File_ion,int ic);
|
||||
void AssignIonConcentration_FromFile(double *Ci,
|
||||
const vector<std::string> &File_ion,
|
||||
int ic);
|
||||
void IonConcentration_LB_to_Phys(DoubleArray &Den_reg);
|
||||
void IonFlux_LB_to_Phys(DoubleArray &Den_reg, const size_t ic);
|
||||
};
|
||||
|
||||
@@ -20,375 +20,408 @@
|
||||
#include "models/MRTModel.h"
|
||||
#include "analysis/distance.h"
|
||||
#include "common/ReadMicroCT.h"
|
||||
ScaLBL_MRTModel::ScaLBL_MRTModel(int RANK, int NP, const Utilities::MPI& COMM):
|
||||
rank(RANK), nprocs(NP), Restart(0),timestep(0),timestepMax(0),tau(0),
|
||||
Fx(0),Fy(0),Fz(0),flux(0),din(0),dout(0),mu(0),
|
||||
Nx(0),Ny(0),Nz(0),N(0),Np(0),nprocx(0),nprocy(0),nprocz(0),BoundaryCondition(0),Lx(0),Ly(0),Lz(0),comm(COMM)
|
||||
{
|
||||
ScaLBL_MRTModel::ScaLBL_MRTModel(int RANK, int NP, const Utilities::MPI &COMM)
|
||||
: rank(RANK), nprocs(NP), Restart(0), timestep(0), timestepMax(0), tau(0),
|
||||
Fx(0), Fy(0), Fz(0), flux(0), din(0), dout(0), mu(0), Nx(0), Ny(0), Nz(0),
|
||||
N(0), Np(0), nprocx(0), nprocy(0), nprocz(0), BoundaryCondition(0), Lx(0),
|
||||
Ly(0), Lz(0), comm(COMM) {}
|
||||
ScaLBL_MRTModel::~ScaLBL_MRTModel() {}
|
||||
|
||||
}
|
||||
ScaLBL_MRTModel::~ScaLBL_MRTModel(){
|
||||
void ScaLBL_MRTModel::ReadParams(string filename) {
|
||||
// read the input database
|
||||
db = std::make_shared<Database>(filename);
|
||||
domain_db = db->getDatabase("Domain");
|
||||
mrt_db = db->getDatabase("MRT");
|
||||
vis_db = db->getDatabase("Visualization");
|
||||
|
||||
}
|
||||
tau = 1.0;
|
||||
timestepMax = 100000;
|
||||
tolerance = 1.0e-8;
|
||||
Fx = Fy = 0.0;
|
||||
Fz = 1.0e-5;
|
||||
dout = 1.0;
|
||||
din = 1.0;
|
||||
|
||||
void ScaLBL_MRTModel::ReadParams(string filename){
|
||||
// read the input database
|
||||
db = std::make_shared<Database>( filename );
|
||||
domain_db = db->getDatabase( "Domain" );
|
||||
mrt_db = db->getDatabase( "MRT" );
|
||||
vis_db = db->getDatabase( "Visualization" );
|
||||
|
||||
tau = 1.0;
|
||||
timestepMax = 100000;
|
||||
tolerance = 1.0e-8;
|
||||
Fx = Fy = 0.0;
|
||||
Fz = 1.0e-5;
|
||||
dout = 1.0;
|
||||
din = 1.0;
|
||||
|
||||
// Color Model parameters
|
||||
if (mrt_db->keyExists( "timestepMax" )){
|
||||
timestepMax = mrt_db->getScalar<int>( "timestepMax" );
|
||||
}
|
||||
if (mrt_db->keyExists( "tolerance" )){
|
||||
tolerance = mrt_db->getScalar<double>( "tolerance" );
|
||||
}
|
||||
if (mrt_db->keyExists( "tau" )){
|
||||
tau = mrt_db->getScalar<double>( "tau" );
|
||||
}
|
||||
if (mrt_db->keyExists( "F" )){
|
||||
Fx = mrt_db->getVector<double>( "F" )[0];
|
||||
Fy = mrt_db->getVector<double>( "F" )[1];
|
||||
Fz = mrt_db->getVector<double>( "F" )[2];
|
||||
}
|
||||
if (mrt_db->keyExists( "Restart" )){
|
||||
Restart = mrt_db->getScalar<bool>( "Restart" );
|
||||
}
|
||||
if (mrt_db->keyExists( "din" )){
|
||||
din = mrt_db->getScalar<double>( "din" );
|
||||
}
|
||||
if (mrt_db->keyExists( "dout" )){
|
||||
dout = mrt_db->getScalar<double>( "dout" );
|
||||
}
|
||||
if (mrt_db->keyExists( "flux" )){
|
||||
flux = mrt_db->getScalar<double>( "flux" );
|
||||
}
|
||||
|
||||
// Read domain parameters
|
||||
if (mrt_db->keyExists( "BoundaryCondition" )){
|
||||
BoundaryCondition = mrt_db->getScalar<int>( "BC" );
|
||||
}
|
||||
else if (domain_db->keyExists( "BC" )){
|
||||
BoundaryCondition = domain_db->getScalar<int>( "BC" );
|
||||
}
|
||||
|
||||
mu=(tau-0.5)/3.0;
|
||||
}
|
||||
void ScaLBL_MRTModel::SetDomain(){
|
||||
Dm = std::shared_ptr<Domain>(new Domain(domain_db,comm)); // full domain for analysis
|
||||
Mask = std::shared_ptr<Domain>(new Domain(domain_db,comm)); // mask domain removes immobile phases
|
||||
|
||||
// domain parameters
|
||||
Nx = Dm->Nx;
|
||||
Ny = Dm->Ny;
|
||||
Nz = Dm->Nz;
|
||||
Lx = Dm->Lx;
|
||||
Ly = Dm->Ly;
|
||||
Lz = Dm->Lz;
|
||||
|
||||
N = Nx*Ny*Nz;
|
||||
Distance.resize(Nx,Ny,Nz);
|
||||
Velocity_x.resize(Nx,Ny,Nz);
|
||||
Velocity_y.resize(Nx,Ny,Nz);
|
||||
Velocity_z.resize(Nx,Ny,Nz);
|
||||
|
||||
for (int i=0; i<Nx*Ny*Nz; i++) Dm->id[i] = 1; // initialize this way
|
||||
//Averages = std::shared_ptr<TwoPhase> ( new TwoPhase(Dm) ); // TwoPhase analysis object
|
||||
comm.barrier();
|
||||
Dm->CommInit();
|
||||
comm.barrier();
|
||||
|
||||
rank = Dm->rank();
|
||||
nprocx = Dm->nprocx();
|
||||
nprocy = Dm->nprocy();
|
||||
nprocz = Dm->nprocz();
|
||||
}
|
||||
|
||||
void ScaLBL_MRTModel::ReadInput(){
|
||||
|
||||
sprintf(LocalRankString,"%05d",Dm->rank());
|
||||
sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
|
||||
sprintf(LocalRestartFile,"%s%s","Restart.",LocalRankString);
|
||||
|
||||
|
||||
if (domain_db->keyExists( "Filename" )){
|
||||
auto Filename = domain_db->getScalar<std::string>( "Filename" );
|
||||
Mask->Decomp(Filename);
|
||||
// Color Model parameters
|
||||
if (mrt_db->keyExists("timestepMax")) {
|
||||
timestepMax = mrt_db->getScalar<int>("timestepMax");
|
||||
}
|
||||
else if (domain_db->keyExists( "GridFile" )){
|
||||
// Read the local domain data
|
||||
auto input_id = readMicroCT( *domain_db, comm );
|
||||
// Fill the halo (assuming GCW of 1)
|
||||
array<int,3> size0 = { (int) input_id.size(0), (int) input_id.size(1), (int) input_id.size(2) };
|
||||
ArraySize size1 = { (size_t) Mask->Nx, (size_t) Mask->Ny, (size_t) Mask->Nz };
|
||||
ASSERT( (int) size1[0] == size0[0]+2 && (int) size1[1] == size0[1]+2 && (int) size1[2] == size0[2]+2 );
|
||||
fillHalo<signed char> fill( comm, Mask->rank_info, size0, { 1, 1, 1 }, 0, 1 );
|
||||
Array<signed char> id_view;
|
||||
id_view.viewRaw( size1, Mask->id.data() );
|
||||
fill.copy( input_id, id_view );
|
||||
fill.fill( id_view );
|
||||
if (mrt_db->keyExists("tolerance")) {
|
||||
tolerance = mrt_db->getScalar<double>("tolerance");
|
||||
}
|
||||
else{
|
||||
Mask->ReadIDs();
|
||||
if (mrt_db->keyExists("tau")) {
|
||||
tau = mrt_db->getScalar<double>("tau");
|
||||
}
|
||||
if (mrt_db->keyExists("F")) {
|
||||
Fx = mrt_db->getVector<double>("F")[0];
|
||||
Fy = mrt_db->getVector<double>("F")[1];
|
||||
Fz = mrt_db->getVector<double>("F")[2];
|
||||
}
|
||||
if (mrt_db->keyExists("Restart")) {
|
||||
Restart = mrt_db->getScalar<bool>("Restart");
|
||||
}
|
||||
if (mrt_db->keyExists("din")) {
|
||||
din = mrt_db->getScalar<double>("din");
|
||||
}
|
||||
if (mrt_db->keyExists("dout")) {
|
||||
dout = mrt_db->getScalar<double>("dout");
|
||||
}
|
||||
if (mrt_db->keyExists("flux")) {
|
||||
flux = mrt_db->getScalar<double>("flux");
|
||||
}
|
||||
|
||||
// Read domain parameters
|
||||
if (mrt_db->keyExists("BoundaryCondition")) {
|
||||
BoundaryCondition = mrt_db->getScalar<int>("BC");
|
||||
} else if (domain_db->keyExists("BC")) {
|
||||
BoundaryCondition = domain_db->getScalar<int>("BC");
|
||||
}
|
||||
|
||||
mu = (tau - 0.5) / 3.0;
|
||||
}
|
||||
void ScaLBL_MRTModel::SetDomain() {
|
||||
Dm = std::shared_ptr<Domain>(
|
||||
new Domain(domain_db, comm)); // full domain for analysis
|
||||
Mask = std::shared_ptr<Domain>(
|
||||
new Domain(domain_db, comm)); // mask domain removes immobile phases
|
||||
|
||||
// domain parameters
|
||||
Nx = Dm->Nx;
|
||||
Ny = Dm->Ny;
|
||||
Nz = Dm->Nz;
|
||||
Lx = Dm->Lx;
|
||||
Ly = Dm->Ly;
|
||||
Lz = Dm->Lz;
|
||||
|
||||
N = Nx * Ny * Nz;
|
||||
Distance.resize(Nx, Ny, Nz);
|
||||
Velocity_x.resize(Nx, Ny, Nz);
|
||||
Velocity_y.resize(Nx, Ny, Nz);
|
||||
Velocity_z.resize(Nx, Ny, Nz);
|
||||
|
||||
for (int i = 0; i < Nx * Ny * Nz; i++)
|
||||
Dm->id[i] = 1; // initialize this way
|
||||
//Averages = std::shared_ptr<TwoPhase> ( new TwoPhase(Dm) ); // TwoPhase analysis object
|
||||
comm.barrier();
|
||||
Dm->CommInit();
|
||||
comm.barrier();
|
||||
|
||||
rank = Dm->rank();
|
||||
nprocx = Dm->nprocx();
|
||||
nprocy = Dm->nprocy();
|
||||
nprocz = Dm->nprocz();
|
||||
}
|
||||
|
||||
void ScaLBL_MRTModel::ReadInput() {
|
||||
|
||||
sprintf(LocalRankString, "%05d", Dm->rank());
|
||||
sprintf(LocalRankFilename, "%s%s", "ID.", LocalRankString);
|
||||
sprintf(LocalRestartFile, "%s%s", "Restart.", LocalRankString);
|
||||
|
||||
if (domain_db->keyExists("Filename")) {
|
||||
auto Filename = domain_db->getScalar<std::string>("Filename");
|
||||
Mask->Decomp(Filename);
|
||||
} else if (domain_db->keyExists("GridFile")) {
|
||||
// Read the local domain data
|
||||
auto input_id = readMicroCT(*domain_db, comm);
|
||||
// Fill the halo (assuming GCW of 1)
|
||||
array<int, 3> size0 = {(int)input_id.size(0), (int)input_id.size(1),
|
||||
(int)input_id.size(2)};
|
||||
ArraySize size1 = {(size_t)Mask->Nx, (size_t)Mask->Ny,
|
||||
(size_t)Mask->Nz};
|
||||
ASSERT((int)size1[0] == size0[0] + 2 && (int)size1[1] == size0[1] + 2 &&
|
||||
(int)size1[2] == size0[2] + 2);
|
||||
fillHalo<signed char> fill(comm, Mask->rank_info, size0, {1, 1, 1}, 0,
|
||||
1);
|
||||
Array<signed char> id_view;
|
||||
id_view.viewRaw(size1, Mask->id.data());
|
||||
fill.copy(input_id, id_view);
|
||||
fill.fill(id_view);
|
||||
} else {
|
||||
Mask->ReadIDs();
|
||||
}
|
||||
|
||||
// Generate the signed distance map
|
||||
// Initialize the domain and communication
|
||||
Array<char> id_solid(Nx,Ny,Nz);
|
||||
// Solve for the position of the solid phase
|
||||
for (int k=0;k<Nz;k++){
|
||||
for (int j=0;j<Ny;j++){
|
||||
for (int i=0;i<Nx;i++){
|
||||
int n = k*Nx*Ny+j*Nx+i;
|
||||
// Initialize the solid phase
|
||||
if (Mask->id[n] > 0) id_solid(i,j,k) = 1;
|
||||
else id_solid(i,j,k) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Initialize the signed distance function
|
||||
for (int k=0;k<Nz;k++){
|
||||
for (int j=0;j<Ny;j++){
|
||||
for (int i=0;i<Nx;i++){
|
||||
// Initialize distance to +/- 1
|
||||
Distance(i,j,k) = 2.0*double(id_solid(i,j,k))-1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// MeanFilter(Averages->SDs);
|
||||
if (rank==0) printf("Initialized solid phase -- Converting to Signed Distance function \n");
|
||||
CalcDist(Distance,id_solid,*Dm);
|
||||
if (rank == 0) cout << "Domain set." << endl;
|
||||
// Initialize the domain and communication
|
||||
Array<char> id_solid(Nx, Ny, Nz);
|
||||
// Solve for the position of the solid phase
|
||||
for (int k = 0; k < Nz; k++) {
|
||||
for (int j = 0; j < Ny; j++) {
|
||||
for (int i = 0; i < Nx; i++) {
|
||||
int n = k * Nx * Ny + j * Nx + i;
|
||||
// Initialize the solid phase
|
||||
if (Mask->id[n] > 0)
|
||||
id_solid(i, j, k) = 1;
|
||||
else
|
||||
id_solid(i, j, k) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Initialize the signed distance function
|
||||
for (int k = 0; k < Nz; k++) {
|
||||
for (int j = 0; j < Ny; j++) {
|
||||
for (int i = 0; i < Nx; i++) {
|
||||
// Initialize distance to +/- 1
|
||||
Distance(i, j, k) = 2.0 * double(id_solid(i, j, k)) - 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// MeanFilter(Averages->SDs);
|
||||
if (rank == 0)
|
||||
printf("Initialized solid phase -- Converting to Signed Distance "
|
||||
"function \n");
|
||||
CalcDist(Distance, id_solid, *Dm);
|
||||
if (rank == 0)
|
||||
cout << "Domain set." << endl;
|
||||
}
|
||||
|
||||
void ScaLBL_MRTModel::Create(){
|
||||
/*
|
||||
void ScaLBL_MRTModel::Create() {
|
||||
/*
|
||||
* This function creates the variables needed to run a LBM
|
||||
*/
|
||||
int rank=Mask->rank();
|
||||
//.........................................................
|
||||
// Initialize communication structures in averaging domain
|
||||
for (int i=0; i<Nx*Ny*Nz; i++) Dm->id[i] = Mask->id[i];
|
||||
Mask->CommInit();
|
||||
Np=Mask->PoreCount();
|
||||
//...........................................................................
|
||||
if (rank==0) printf ("Create ScaLBL_Communicator \n");
|
||||
// Create a communicator for the device (will use optimized layout)
|
||||
// ScaLBL_Communicator ScaLBL_Comm(Mask); // original
|
||||
ScaLBL_Comm = std::shared_ptr<ScaLBL_Communicator>(new ScaLBL_Communicator(Mask));
|
||||
int rank = Mask->rank();
|
||||
//.........................................................
|
||||
// Initialize communication structures in averaging domain
|
||||
for (int i = 0; i < Nx * Ny * Nz; i++)
|
||||
Dm->id[i] = Mask->id[i];
|
||||
Mask->CommInit();
|
||||
Np = Mask->PoreCount();
|
||||
//...........................................................................
|
||||
if (rank == 0)
|
||||
printf("Create ScaLBL_Communicator \n");
|
||||
// Create a communicator for the device (will use optimized layout)
|
||||
// ScaLBL_Communicator ScaLBL_Comm(Mask); // original
|
||||
ScaLBL_Comm =
|
||||
std::shared_ptr<ScaLBL_Communicator>(new ScaLBL_Communicator(Mask));
|
||||
|
||||
int Npad=(Np/16 + 2)*16;
|
||||
if (rank==0) printf ("Set up memory efficient layout \n");
|
||||
Map.resize(Nx,Ny,Nz); Map.fill(-2);
|
||||
auto neighborList= new int[18*Npad];
|
||||
Np = ScaLBL_Comm->MemoryOptimizedLayoutAA(Map,neighborList,Mask->id.data(),Np,1);
|
||||
comm.barrier();
|
||||
int Npad = (Np / 16 + 2) * 16;
|
||||
if (rank == 0)
|
||||
printf("Set up memory efficient layout \n");
|
||||
Map.resize(Nx, Ny, Nz);
|
||||
Map.fill(-2);
|
||||
auto neighborList = new int[18 * Npad];
|
||||
Np = ScaLBL_Comm->MemoryOptimizedLayoutAA(Map, neighborList,
|
||||
Mask->id.data(), Np, 1);
|
||||
comm.barrier();
|
||||
|
||||
//...........................................................................
|
||||
// MAIN VARIABLES ALLOCATED HERE
|
||||
//...........................................................................
|
||||
// LBM variables
|
||||
if (rank==0) printf ("Allocating distributions \n");
|
||||
//......................device distributions.................................
|
||||
int dist_mem_size = Np*sizeof(double);
|
||||
int neighborSize=18*(Np*sizeof(int));
|
||||
//...........................................................................
|
||||
ScaLBL_AllocateDeviceMemory((void **) &NeighborList, neighborSize);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &fq, 19*dist_mem_size);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Pressure, sizeof(double)*Np);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Velocity, 3*sizeof(double)*Np);
|
||||
//...........................................................................
|
||||
// Update GPU data structures
|
||||
if (rank==0) printf ("Setting up device map and neighbor list \n");
|
||||
// copy the neighbor list
|
||||
ScaLBL_CopyToDevice(NeighborList, neighborList, neighborSize);
|
||||
comm.barrier();
|
||||
double MLUPS = ScaLBL_Comm->GetPerformance(NeighborList,fq,Np);
|
||||
printf(" MLPUS=%f from rank %i\n",MLUPS,rank);
|
||||
}
|
||||
//...........................................................................
|
||||
// MAIN VARIABLES ALLOCATED HERE
|
||||
//...........................................................................
|
||||
// LBM variables
|
||||
if (rank == 0)
|
||||
printf("Allocating distributions \n");
|
||||
//......................device distributions.................................
|
||||
int dist_mem_size = Np * sizeof(double);
|
||||
int neighborSize = 18 * (Np * sizeof(int));
|
||||
//...........................................................................
|
||||
ScaLBL_AllocateDeviceMemory((void **)&NeighborList, neighborSize);
|
||||
ScaLBL_AllocateDeviceMemory((void **)&fq, 19 * dist_mem_size);
|
||||
ScaLBL_AllocateDeviceMemory((void **)&Pressure, sizeof(double) * Np);
|
||||
ScaLBL_AllocateDeviceMemory((void **)&Velocity, 3 * sizeof(double) * Np);
|
||||
//...........................................................................
|
||||
// Update GPU data structures
|
||||
if (rank == 0)
|
||||
printf("Setting up device map and neighbor list \n");
|
||||
// copy the neighbor list
|
||||
ScaLBL_CopyToDevice(NeighborList, neighborList, neighborSize);
|
||||
comm.barrier();
|
||||
double MLUPS = ScaLBL_Comm->GetPerformance(NeighborList, fq, Np);
|
||||
printf(" MLPUS=%f from rank %i\n", MLUPS, rank);
|
||||
}
|
||||
|
||||
void ScaLBL_MRTModel::Initialize(){
|
||||
/*
|
||||
void ScaLBL_MRTModel::Initialize() {
|
||||
/*
|
||||
* This function initializes model
|
||||
*/
|
||||
if (rank==0) printf ("Initializing distributions \n");
|
||||
if (rank == 0)
|
||||
printf("Initializing distributions \n");
|
||||
ScaLBL_D3Q19_Init(fq, Np);
|
||||
}
|
||||
|
||||
void ScaLBL_MRTModel::Run(){
|
||||
double rlx_setA=1.0/tau;
|
||||
double rlx_setB = 8.f*(2.f-rlx_setA)/(8.f-rlx_setA);
|
||||
|
||||
Minkowski Morphology(Mask);
|
||||
void ScaLBL_MRTModel::Run() {
|
||||
double rlx_setA = 1.0 / tau;
|
||||
double rlx_setB = 8.f * (2.f - rlx_setA) / (8.f - rlx_setA);
|
||||
|
||||
if (rank==0){
|
||||
bool WriteHeader=false;
|
||||
FILE *log_file = fopen("Permeability.csv","r");
|
||||
if (log_file != NULL)
|
||||
fclose(log_file);
|
||||
else
|
||||
WriteHeader=true;
|
||||
Minkowski Morphology(Mask);
|
||||
|
||||
if (WriteHeader){
|
||||
log_file = fopen("Permeability.csv","a+");
|
||||
fprintf(log_file,"time Fx Fy Fz mu Vs As Js Xs vx vy vz k\n");
|
||||
fclose(log_file);
|
||||
}
|
||||
}
|
||||
if (rank == 0) {
|
||||
bool WriteHeader = false;
|
||||
FILE *log_file = fopen("Permeability.csv", "r");
|
||||
if (log_file != NULL)
|
||||
fclose(log_file);
|
||||
else
|
||||
WriteHeader = true;
|
||||
|
||||
//.......create and start timer............
|
||||
ScaLBL_DeviceBarrier(); comm.barrier();
|
||||
if (rank==0) printf("Beginning AA timesteps, timestepMax = %i \n", timestepMax);
|
||||
if (rank==0) printf("********************************************************\n");
|
||||
timestep=0;
|
||||
double error = 1.0;
|
||||
double flow_rate_previous = 0.0;
|
||||
if (WriteHeader) {
|
||||
log_file = fopen("Permeability.csv", "a+");
|
||||
fprintf(log_file, "time Fx Fy Fz mu Vs As Js Xs vx vy vz k\n");
|
||||
fclose(log_file);
|
||||
}
|
||||
}
|
||||
|
||||
//.......create and start timer............
|
||||
ScaLBL_DeviceBarrier();
|
||||
comm.barrier();
|
||||
if (rank == 0)
|
||||
printf("Beginning AA timesteps, timestepMax = %i \n", timestepMax);
|
||||
if (rank == 0)
|
||||
printf("********************************************************\n");
|
||||
timestep = 0;
|
||||
double error = 1.0;
|
||||
double flow_rate_previous = 0.0;
|
||||
auto t1 = std::chrono::system_clock::now();
|
||||
while (timestep < timestepMax && error > tolerance) {
|
||||
//************************************************************************/
|
||||
timestep++;
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FROM NORMAL
|
||||
ScaLBL_D3Q19_AAodd_MRT(NeighborList, fq, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np, rlx_setA, rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_Comm->RecvD3Q19AA(fq); //WRITE INTO OPPOSITE
|
||||
// Set boundary conditions
|
||||
if (BoundaryCondition == 3){
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_z(NeighborList, fq, din, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
}
|
||||
else if (BoundaryCondition == 4){
|
||||
din = ScaLBL_Comm->D3Q19_Flux_BC_z(NeighborList, fq, flux, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
}
|
||||
else if (BoundaryCondition == 5){
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_z(fq);
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(fq);
|
||||
}
|
||||
ScaLBL_D3Q19_AAodd_MRT(NeighborList, fq, 0, ScaLBL_Comm->LastExterior(), Np, rlx_setA, rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_DeviceBarrier(); comm.barrier();
|
||||
timestep++;
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FORM NORMAL
|
||||
ScaLBL_D3Q19_AAeven_MRT(fq, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np, rlx_setA, rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_Comm->RecvD3Q19AA(fq); //WRITE INTO OPPOSITE
|
||||
// Set boundary conditions
|
||||
if (BoundaryCondition == 3){
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_z(NeighborList, fq, din, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
}
|
||||
else if (BoundaryCondition == 4){
|
||||
din = ScaLBL_Comm->D3Q19_Flux_BC_z(NeighborList, fq, flux, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
}
|
||||
else if (BoundaryCondition == 5){
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_z(fq);
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(fq);
|
||||
}
|
||||
ScaLBL_D3Q19_AAeven_MRT(fq, 0, ScaLBL_Comm->LastExterior(), Np, rlx_setA, rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_DeviceBarrier(); comm.barrier();
|
||||
//************************************************************************/
|
||||
|
||||
if (timestep%1000==0){
|
||||
ScaLBL_D3Q19_Momentum(fq,Velocity, Np);
|
||||
ScaLBL_DeviceBarrier(); comm.barrier();
|
||||
ScaLBL_Comm->RegularLayout(Map,&Velocity[0],Velocity_x);
|
||||
ScaLBL_Comm->RegularLayout(Map,&Velocity[Np],Velocity_y);
|
||||
ScaLBL_Comm->RegularLayout(Map,&Velocity[2*Np],Velocity_z);
|
||||
|
||||
double count_loc=0;
|
||||
double count;
|
||||
double vax,vay,vaz;
|
||||
double vax_loc,vay_loc,vaz_loc;
|
||||
vax_loc = vay_loc = vaz_loc = 0.f;
|
||||
for (int k=1; k<Nz-1; k++){
|
||||
for (int j=1; j<Ny-1; j++){
|
||||
for (int i=1; i<Nx-1; i++){
|
||||
if (Distance(i,j,k) > 0){
|
||||
vax_loc += Velocity_x(i,j,k);
|
||||
vay_loc += Velocity_y(i,j,k);
|
||||
vaz_loc += Velocity_z(i,j,k);
|
||||
count_loc+=1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vax=Dm->Comm.sumReduce( vax_loc);
|
||||
vay=Dm->Comm.sumReduce( vay_loc);
|
||||
vaz=Dm->Comm.sumReduce( vaz_loc);
|
||||
count=Dm->Comm.sumReduce( count_loc);
|
||||
|
||||
vax /= count;
|
||||
vay /= count;
|
||||
vaz /= count;
|
||||
|
||||
double force_mag = sqrt(Fx*Fx+Fy*Fy+Fz*Fz);
|
||||
double dir_x = Fx/force_mag;
|
||||
double dir_y = Fy/force_mag;
|
||||
double dir_z = Fz/force_mag;
|
||||
if (force_mag == 0.0){
|
||||
// default to z direction
|
||||
dir_x = 0.0;
|
||||
dir_y = 0.0;
|
||||
dir_z = 1.0;
|
||||
force_mag = 1.0;
|
||||
}
|
||||
double flow_rate = (vax*dir_x + vay*dir_y + vaz*dir_z);
|
||||
|
||||
error = fabs(flow_rate - flow_rate_previous) / fabs(flow_rate);
|
||||
flow_rate_previous = flow_rate;
|
||||
|
||||
//if (rank==0) printf("Computing Minkowski functionals \n");
|
||||
Morphology.ComputeScalar(Distance,0.f);
|
||||
//Morphology.PrintAll();
|
||||
double mu = (tau-0.5)/3.f;
|
||||
double Vs = Morphology.V();
|
||||
double As = Morphology.A();
|
||||
double Hs = Morphology.H();
|
||||
double Xs = Morphology.X();
|
||||
Vs=Dm->Comm.sumReduce( Vs);
|
||||
As=Dm->Comm.sumReduce( As);
|
||||
Hs=Dm->Comm.sumReduce( Hs);
|
||||
Xs=Dm->Comm.sumReduce( Xs);
|
||||
while (timestep < timestepMax && error > tolerance) {
|
||||
//************************************************************************/
|
||||
timestep++;
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FROM NORMAL
|
||||
ScaLBL_D3Q19_AAodd_MRT(NeighborList, fq, ScaLBL_Comm->FirstInterior(),
|
||||
ScaLBL_Comm->LastInterior(), Np, rlx_setA,
|
||||
rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_Comm->RecvD3Q19AA(fq); //WRITE INTO OPPOSITE
|
||||
// Set boundary conditions
|
||||
if (BoundaryCondition == 3) {
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_z(NeighborList, fq, din, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
} else if (BoundaryCondition == 4) {
|
||||
din =
|
||||
ScaLBL_Comm->D3Q19_Flux_BC_z(NeighborList, fq, flux, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
} else if (BoundaryCondition == 5) {
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_z(fq);
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(fq);
|
||||
}
|
||||
ScaLBL_D3Q19_AAodd_MRT(NeighborList, fq, 0, ScaLBL_Comm->LastExterior(),
|
||||
Np, rlx_setA, rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_DeviceBarrier();
|
||||
comm.barrier();
|
||||
timestep++;
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FORM NORMAL
|
||||
ScaLBL_D3Q19_AAeven_MRT(fq, ScaLBL_Comm->FirstInterior(),
|
||||
ScaLBL_Comm->LastInterior(), Np, rlx_setA,
|
||||
rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_Comm->RecvD3Q19AA(fq); //WRITE INTO OPPOSITE
|
||||
// Set boundary conditions
|
||||
if (BoundaryCondition == 3) {
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_z(NeighborList, fq, din, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
} else if (BoundaryCondition == 4) {
|
||||
din =
|
||||
ScaLBL_Comm->D3Q19_Flux_BC_z(NeighborList, fq, flux, timestep);
|
||||
ScaLBL_Comm->D3Q19_Pressure_BC_Z(NeighborList, fq, dout, timestep);
|
||||
} else if (BoundaryCondition == 5) {
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_z(fq);
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(fq);
|
||||
}
|
||||
ScaLBL_D3Q19_AAeven_MRT(fq, 0, ScaLBL_Comm->LastExterior(), Np,
|
||||
rlx_setA, rlx_setB, Fx, Fy, Fz);
|
||||
ScaLBL_DeviceBarrier();
|
||||
comm.barrier();
|
||||
//************************************************************************/
|
||||
|
||||
double h = Dm->voxel_length;
|
||||
double absperm = h*h*mu*Mask->Porosity()*flow_rate / force_mag;
|
||||
if (rank==0) {
|
||||
printf(" %f\n",absperm);
|
||||
FILE * log_file = fopen("Permeability.csv","a");
|
||||
fprintf(log_file,"%i %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g\n",timestep, Fx, Fy, Fz, mu,
|
||||
h*h*h*Vs,h*h*As,h*Hs,Xs,vax,vay,vaz, absperm);
|
||||
fclose(log_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
//************************************************************************/
|
||||
if (rank==0) printf("-------------------------------------------------------------------\n");
|
||||
// Compute the walltime per timestep
|
||||
if (timestep % 1000 == 0) {
|
||||
ScaLBL_D3Q19_Momentum(fq, Velocity, Np);
|
||||
ScaLBL_DeviceBarrier();
|
||||
comm.barrier();
|
||||
ScaLBL_Comm->RegularLayout(Map, &Velocity[0], Velocity_x);
|
||||
ScaLBL_Comm->RegularLayout(Map, &Velocity[Np], Velocity_y);
|
||||
ScaLBL_Comm->RegularLayout(Map, &Velocity[2 * Np], Velocity_z);
|
||||
|
||||
double count_loc = 0;
|
||||
double count;
|
||||
double vax, vay, vaz;
|
||||
double vax_loc, vay_loc, vaz_loc;
|
||||
vax_loc = vay_loc = vaz_loc = 0.f;
|
||||
for (int k = 1; k < Nz - 1; k++) {
|
||||
for (int j = 1; j < Ny - 1; j++) {
|
||||
for (int i = 1; i < Nx - 1; i++) {
|
||||
if (Distance(i, j, k) > 0) {
|
||||
vax_loc += Velocity_x(i, j, k);
|
||||
vay_loc += Velocity_y(i, j, k);
|
||||
vaz_loc += Velocity_z(i, j, k);
|
||||
count_loc += 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vax = Dm->Comm.sumReduce(vax_loc);
|
||||
vay = Dm->Comm.sumReduce(vay_loc);
|
||||
vaz = Dm->Comm.sumReduce(vaz_loc);
|
||||
count = Dm->Comm.sumReduce(count_loc);
|
||||
|
||||
vax /= count;
|
||||
vay /= count;
|
||||
vaz /= count;
|
||||
|
||||
double force_mag = sqrt(Fx * Fx + Fy * Fy + Fz * Fz);
|
||||
double dir_x = Fx / force_mag;
|
||||
double dir_y = Fy / force_mag;
|
||||
double dir_z = Fz / force_mag;
|
||||
if (force_mag == 0.0) {
|
||||
// default to z direction
|
||||
dir_x = 0.0;
|
||||
dir_y = 0.0;
|
||||
dir_z = 1.0;
|
||||
force_mag = 1.0;
|
||||
}
|
||||
double flow_rate = (vax * dir_x + vay * dir_y + vaz * dir_z);
|
||||
|
||||
error = fabs(flow_rate - flow_rate_previous) / fabs(flow_rate);
|
||||
flow_rate_previous = flow_rate;
|
||||
|
||||
//if (rank==0) printf("Computing Minkowski functionals \n");
|
||||
Morphology.ComputeScalar(Distance, 0.f);
|
||||
//Morphology.PrintAll();
|
||||
double mu = (tau - 0.5) / 3.f;
|
||||
double Vs = Morphology.V();
|
||||
double As = Morphology.A();
|
||||
double Hs = Morphology.H();
|
||||
double Xs = Morphology.X();
|
||||
Vs = Dm->Comm.sumReduce(Vs);
|
||||
As = Dm->Comm.sumReduce(As);
|
||||
Hs = Dm->Comm.sumReduce(Hs);
|
||||
Xs = Dm->Comm.sumReduce(Xs);
|
||||
|
||||
double h = Dm->voxel_length;
|
||||
double absperm =
|
||||
h * h * mu * Mask->Porosity() * flow_rate / force_mag;
|
||||
if (rank == 0) {
|
||||
printf(" %f\n", absperm);
|
||||
FILE *log_file = fopen("Permeability.csv", "a");
|
||||
fprintf(log_file,
|
||||
"%i %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g "
|
||||
"%.8g %.8g\n",
|
||||
timestep, Fx, Fy, Fz, mu, h * h * h * Vs, h * h * As,
|
||||
h * Hs, Xs, vax, vay, vaz, absperm);
|
||||
fclose(log_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
//************************************************************************/
|
||||
if (rank == 0)
|
||||
printf("---------------------------------------------------------------"
|
||||
"----\n");
|
||||
// Compute the walltime per timestep
|
||||
auto t2 = std::chrono::system_clock::now();
|
||||
double cputime = std::chrono::duration<double>( t2 - t1 ).count() / timestep;
|
||||
// Performance obtained from each node
|
||||
double MLUPS = double(Np)/cputime/1000000;
|
||||
|
||||
if (rank==0) printf("********************************************************\n");
|
||||
if (rank==0) printf("CPU time = %f \n", cputime);
|
||||
if (rank==0) printf("Lattice update rate (per core)= %f MLUPS \n", MLUPS);
|
||||
MLUPS *= nprocs;
|
||||
if (rank==0) printf("Lattice update rate (total)= %f MLUPS \n", MLUPS);
|
||||
if (rank==0) printf("********************************************************\n");
|
||||
double cputime = std::chrono::duration<double>(t2 - t1).count() / timestep;
|
||||
// Performance obtained from each node
|
||||
double MLUPS = double(Np) / cputime / 1000000;
|
||||
|
||||
if (rank == 0)
|
||||
printf("********************************************************\n");
|
||||
if (rank == 0)
|
||||
printf("CPU time = %f \n", cputime);
|
||||
if (rank == 0)
|
||||
printf("Lattice update rate (per core)= %f MLUPS \n", MLUPS);
|
||||
MLUPS *= nprocs;
|
||||
if (rank == 0)
|
||||
printf("Lattice update rate (total)= %f MLUPS \n", MLUPS);
|
||||
if (rank == 0)
|
||||
printf("********************************************************\n");
|
||||
}
|
||||
|
||||
void ScaLBL_MRTModel::VelocityField(){
|
||||
void ScaLBL_MRTModel::VelocityField() {
|
||||
|
||||
auto format = vis_db->getWithDefault<string>( "format", "silo" );
|
||||
auto format = vis_db->getWithDefault<string>("format", "silo");
|
||||
|
||||
/* memcpy(Morphology.SDn.data(), Distance.data(), Nx*Ny*Nz*sizeof(double));
|
||||
Morphology.Initialize();
|
||||
@@ -428,59 +461,63 @@ void ScaLBL_MRTModel::VelocityField(){
|
||||
if (rank==0) printf("%.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g\n",Fx, Fy, Fz, mu,
|
||||
Morphology.V(),Morphology.A(),Morphology.J(),Morphology.X(),vax,vay,vaz);
|
||||
*/
|
||||
vis_db = db->getDatabase( "Visualization" );
|
||||
if (vis_db->getWithDefault<bool>( "write_silo", false )){
|
||||
|
||||
std::vector<IO::MeshDataStruct> visData;
|
||||
fillHalo<double> fillData(Dm->Comm,Dm->rank_info,{Dm->Nx-2,Dm->Ny-2,Dm->Nz-2},{1,1,1},0,1);
|
||||
vis_db = db->getDatabase("Visualization");
|
||||
if (vis_db->getWithDefault<bool>("write_silo", false)) {
|
||||
|
||||
auto VxVar = std::make_shared<IO::Variable>();
|
||||
auto VyVar = std::make_shared<IO::Variable>();
|
||||
auto VzVar = std::make_shared<IO::Variable>();
|
||||
auto SignDistVar = std::make_shared<IO::Variable>();
|
||||
std::vector<IO::MeshDataStruct> visData;
|
||||
fillHalo<double> fillData(Dm->Comm, Dm->rank_info,
|
||||
{Dm->Nx - 2, Dm->Ny - 2, Dm->Nz - 2},
|
||||
{1, 1, 1}, 0, 1);
|
||||
|
||||
IO::initialize("",format,"false");
|
||||
// Create the MeshDataStruct
|
||||
visData.resize(1);
|
||||
visData[0].meshName = "domain";
|
||||
visData[0].mesh = std::make_shared<IO::DomainMesh>( Dm->rank_info,Dm->Nx-2,Dm->Ny-2,Dm->Nz-2,Dm->Lx,Dm->Ly,Dm->Lz );
|
||||
SignDistVar->name = "SignDist";
|
||||
SignDistVar->type = IO::VariableType::VolumeVariable;
|
||||
SignDistVar->dim = 1;
|
||||
SignDistVar->data.resize(Dm->Nx-2,Dm->Ny-2,Dm->Nz-2);
|
||||
visData[0].vars.push_back(SignDistVar);
|
||||
|
||||
VxVar->name = "Velocity_x";
|
||||
VxVar->type = IO::VariableType::VolumeVariable;
|
||||
VxVar->dim = 1;
|
||||
VxVar->data.resize(Dm->Nx-2,Dm->Ny-2,Dm->Nz-2);
|
||||
visData[0].vars.push_back(VxVar);
|
||||
VyVar->name = "Velocity_y";
|
||||
VyVar->type = IO::VariableType::VolumeVariable;
|
||||
VyVar->dim = 1;
|
||||
VyVar->data.resize(Dm->Nx-2,Dm->Ny-2,Dm->Nz-2);
|
||||
visData[0].vars.push_back(VyVar);
|
||||
VzVar->name = "Velocity_z";
|
||||
VzVar->type = IO::VariableType::VolumeVariable;
|
||||
VzVar->dim = 1;
|
||||
VzVar->data.resize(Dm->Nx-2,Dm->Ny-2,Dm->Nz-2);
|
||||
visData[0].vars.push_back(VzVar);
|
||||
|
||||
Array<double>& SignData = visData[0].vars[0]->data;
|
||||
Array<double>& VelxData = visData[0].vars[1]->data;
|
||||
Array<double>& VelyData = visData[0].vars[2]->data;
|
||||
Array<double>& VelzData = visData[0].vars[3]->data;
|
||||
|
||||
ASSERT(visData[0].vars[0]->name=="SignDist");
|
||||
ASSERT(visData[0].vars[1]->name=="Velocity_x");
|
||||
ASSERT(visData[0].vars[2]->name=="Velocity_y");
|
||||
ASSERT(visData[0].vars[3]->name=="Velocity_z");
|
||||
|
||||
fillData.copy(Distance,SignData);
|
||||
fillData.copy(Velocity_x,VelxData);
|
||||
fillData.copy(Velocity_y,VelyData);
|
||||
fillData.copy(Velocity_z,VelzData);
|
||||
|
||||
IO::writeData( timestep, visData, Dm->Comm );
|
||||
auto VxVar = std::make_shared<IO::Variable>();
|
||||
auto VyVar = std::make_shared<IO::Variable>();
|
||||
auto VzVar = std::make_shared<IO::Variable>();
|
||||
auto SignDistVar = std::make_shared<IO::Variable>();
|
||||
|
||||
IO::initialize("", format, "false");
|
||||
// Create the MeshDataStruct
|
||||
visData.resize(1);
|
||||
visData[0].meshName = "domain";
|
||||
visData[0].mesh = std::make_shared<IO::DomainMesh>(
|
||||
Dm->rank_info, Dm->Nx - 2, Dm->Ny - 2, Dm->Nz - 2, Dm->Lx, Dm->Ly,
|
||||
Dm->Lz);
|
||||
SignDistVar->name = "SignDist";
|
||||
SignDistVar->type = IO::VariableType::VolumeVariable;
|
||||
SignDistVar->dim = 1;
|
||||
SignDistVar->data.resize(Dm->Nx - 2, Dm->Ny - 2, Dm->Nz - 2);
|
||||
visData[0].vars.push_back(SignDistVar);
|
||||
|
||||
VxVar->name = "Velocity_x";
|
||||
VxVar->type = IO::VariableType::VolumeVariable;
|
||||
VxVar->dim = 1;
|
||||
VxVar->data.resize(Dm->Nx - 2, Dm->Ny - 2, Dm->Nz - 2);
|
||||
visData[0].vars.push_back(VxVar);
|
||||
VyVar->name = "Velocity_y";
|
||||
VyVar->type = IO::VariableType::VolumeVariable;
|
||||
VyVar->dim = 1;
|
||||
VyVar->data.resize(Dm->Nx - 2, Dm->Ny - 2, Dm->Nz - 2);
|
||||
visData[0].vars.push_back(VyVar);
|
||||
VzVar->name = "Velocity_z";
|
||||
VzVar->type = IO::VariableType::VolumeVariable;
|
||||
VzVar->dim = 1;
|
||||
VzVar->data.resize(Dm->Nx - 2, Dm->Ny - 2, Dm->Nz - 2);
|
||||
visData[0].vars.push_back(VzVar);
|
||||
|
||||
Array<double> &SignData = visData[0].vars[0]->data;
|
||||
Array<double> &VelxData = visData[0].vars[1]->data;
|
||||
Array<double> &VelyData = visData[0].vars[2]->data;
|
||||
Array<double> &VelzData = visData[0].vars[3]->data;
|
||||
|
||||
ASSERT(visData[0].vars[0]->name == "SignDist");
|
||||
ASSERT(visData[0].vars[1]->name == "Velocity_x");
|
||||
ASSERT(visData[0].vars[2]->name == "Velocity_y");
|
||||
ASSERT(visData[0].vars[3]->name == "Velocity_z");
|
||||
|
||||
fillData.copy(Distance, SignData);
|
||||
fillData.copy(Velocity_x, VelxData);
|
||||
fillData.copy(Velocity_y, VelyData);
|
||||
fillData.copy(Velocity_z, VelzData);
|
||||
|
||||
IO::writeData(timestep, visData, Dm->Comm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,36 +31,36 @@
|
||||
#include "analysis/Minkowski.h"
|
||||
#include "ProfilerApp.h"
|
||||
|
||||
class ScaLBL_MRTModel{
|
||||
class ScaLBL_MRTModel {
|
||||
public:
|
||||
ScaLBL_MRTModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_MRTModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run();
|
||||
void VelocityField();
|
||||
|
||||
bool Restart,pBC;
|
||||
int timestep,timestepMax;
|
||||
int BoundaryCondition;
|
||||
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;
|
||||
double Lx,Ly,Lz;
|
||||
ScaLBL_MRTModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_MRTModel();
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run();
|
||||
void VelocityField();
|
||||
|
||||
bool Restart, pBC;
|
||||
int timestep, timestepMax;
|
||||
int BoundaryCondition;
|
||||
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;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -73,20 +73,21 @@ public:
|
||||
double *fq;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
|
||||
|
||||
//Minkowski Morphology;
|
||||
|
||||
|
||||
DoubleArray Velocity_x;
|
||||
DoubleArray Velocity_y;
|
||||
DoubleArray Velocity_z;
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
};
|
||||
|
||||
@@ -1,51 +1,48 @@
|
||||
#include "models/MultiPhysController.h"
|
||||
|
||||
ScaLBL_Multiphys_Controller::ScaLBL_Multiphys_Controller(int RANK, int NP, const Utilities::MPI& COMM):
|
||||
rank(RANK),nprocs(NP),Restart(0),timestepMax(0),num_iter_Stokes(0),num_iter_Ion(0),
|
||||
analysis_interval(0),visualization_interval(0),tolerance(0),time_conv_max(0),comm(COMM)
|
||||
{
|
||||
ScaLBL_Multiphys_Controller::ScaLBL_Multiphys_Controller(
|
||||
int RANK, int NP, const Utilities::MPI &COMM)
|
||||
: rank(RANK), nprocs(NP), Restart(0), timestepMax(0), num_iter_Stokes(0),
|
||||
num_iter_Ion(0), analysis_interval(0), visualization_interval(0),
|
||||
tolerance(0), time_conv_max(0), comm(COMM) {}
|
||||
ScaLBL_Multiphys_Controller::~ScaLBL_Multiphys_Controller() {}
|
||||
|
||||
}
|
||||
ScaLBL_Multiphys_Controller::~ScaLBL_Multiphys_Controller(){
|
||||
void ScaLBL_Multiphys_Controller::ReadParams(string filename) {
|
||||
|
||||
}
|
||||
|
||||
void ScaLBL_Multiphys_Controller::ReadParams(string filename){
|
||||
|
||||
// read the input database
|
||||
db = std::make_shared<Database>( filename );
|
||||
study_db = db->getDatabase( "MultiphysController" );
|
||||
|
||||
// read the input database
|
||||
db = std::make_shared<Database>(filename);
|
||||
study_db = db->getDatabase("MultiphysController");
|
||||
|
||||
// Default parameters
|
||||
timestepMax = 10000;
|
||||
Restart = false;
|
||||
num_iter_Stokes=1;
|
||||
num_iter_Stokes = 1;
|
||||
num_iter_Ion.push_back(1);
|
||||
analysis_interval = 500;
|
||||
visualization_interval = 10000;
|
||||
tolerance = 1.0e-6;
|
||||
time_conv_max = 0.0;
|
||||
|
||||
|
||||
// load input parameters
|
||||
if (study_db->keyExists( "timestepMax" )){
|
||||
timestepMax = study_db->getScalar<int>( "timestepMax" );
|
||||
}
|
||||
if (study_db->keyExists( "analysis_interval" )){
|
||||
analysis_interval = study_db->getScalar<int>( "analysis_interval" );
|
||||
}
|
||||
if (study_db->keyExists( "visualization_interval" )){
|
||||
visualization_interval = study_db->getScalar<int>( "visualization_interval" );
|
||||
}
|
||||
if (study_db->keyExists( "tolerance" )){
|
||||
tolerance = study_db->getScalar<double>( "tolerance" );
|
||||
}
|
||||
//if (study_db->keyExists( "time_conv" )){
|
||||
// time_conv = study_db->getScalar<double>( "time_conv" );
|
||||
//}
|
||||
//if (study_db->keyExists( "Schmidt_Number" )){
|
||||
// SchmidtNum = study_db->getScalar<double>( "Schmidt_Number" );
|
||||
//}
|
||||
if (study_db->keyExists("timestepMax")) {
|
||||
timestepMax = study_db->getScalar<int>("timestepMax");
|
||||
}
|
||||
if (study_db->keyExists("analysis_interval")) {
|
||||
analysis_interval = study_db->getScalar<int>("analysis_interval");
|
||||
}
|
||||
if (study_db->keyExists("visualization_interval")) {
|
||||
visualization_interval =
|
||||
study_db->getScalar<int>("visualization_interval");
|
||||
}
|
||||
if (study_db->keyExists("tolerance")) {
|
||||
tolerance = study_db->getScalar<double>("tolerance");
|
||||
}
|
||||
//if (study_db->keyExists( "time_conv" )){
|
||||
// time_conv = study_db->getScalar<double>( "time_conv" );
|
||||
//}
|
||||
//if (study_db->keyExists( "Schmidt_Number" )){
|
||||
// SchmidtNum = study_db->getScalar<double>( "Schmidt_Number" );
|
||||
//}
|
||||
|
||||
// recalculate relevant parameters
|
||||
//if (SchmidtNum>1){
|
||||
@@ -61,87 +58,104 @@ void ScaLBL_Multiphys_Controller::ReadParams(string filename){
|
||||
// num_iter_Ion = 1;
|
||||
//}
|
||||
//else{
|
||||
// ERROR("Error: SchmidtNum (Schmidt number) must be a positive number! \n");
|
||||
// ERROR("Error: SchmidtNum (Schmidt number) must be a positive number! \n");
|
||||
//}
|
||||
|
||||
// load input parameters
|
||||
// in case user wants to have an absolute control over the iternal iteration
|
||||
if (study_db->keyExists( "num_iter_Ion_List" )){
|
||||
if (study_db->keyExists("num_iter_Ion_List")) {
|
||||
num_iter_Ion.clear();
|
||||
num_iter_Ion = study_db->getVector<int>( "num_iter_Ion_List" );
|
||||
num_iter_Ion = study_db->getVector<int>("num_iter_Ion_List");
|
||||
}
|
||||
if (study_db->keyExists( "num_iter_Stokes" )){
|
||||
num_iter_Stokes = study_db->getScalar<int>( "num_iter_Stokes" );
|
||||
if (study_db->keyExists("num_iter_Stokes")) {
|
||||
num_iter_Stokes = study_db->getScalar<int>("num_iter_Stokes");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int ScaLBL_Multiphys_Controller::getStokesNumIter_PNP_coupling(double StokesTimeConv,const vector<double> &IonTimeConv){
|
||||
int ScaLBL_Multiphys_Controller::getStokesNumIter_PNP_coupling(
|
||||
double StokesTimeConv, const vector<double> &IonTimeConv) {
|
||||
//Return number of internal iterations for the Stokes solver
|
||||
int num_iter_stokes;
|
||||
vector<double> TimeConv;
|
||||
|
||||
TimeConv.assign(IonTimeConv.begin(),IonTimeConv.end());
|
||||
TimeConv.insert(TimeConv.begin(),StokesTimeConv);
|
||||
vector<double>::iterator it_max = max_element(TimeConv.begin(),TimeConv.end());
|
||||
int idx_max = distance(TimeConv.begin(),it_max);
|
||||
if (idx_max==0){
|
||||
TimeConv.assign(IonTimeConv.begin(), IonTimeConv.end());
|
||||
TimeConv.insert(TimeConv.begin(), StokesTimeConv);
|
||||
vector<double>::iterator it_max =
|
||||
max_element(TimeConv.begin(), TimeConv.end());
|
||||
int idx_max = distance(TimeConv.begin(), it_max);
|
||||
if (idx_max == 0) {
|
||||
num_iter_stokes = 2;
|
||||
}
|
||||
else{
|
||||
double temp = 2*TimeConv[idx_max]/StokesTimeConv;//the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_stokes = int(round(temp/2)*2);
|
||||
} else {
|
||||
double temp =
|
||||
2 * TimeConv[idx_max] /
|
||||
StokesTimeConv; //the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_stokes = int(round(temp / 2) * 2);
|
||||
}
|
||||
return num_iter_stokes;
|
||||
}
|
||||
|
||||
vector<int> ScaLBL_Multiphys_Controller::getIonNumIter_PNP_coupling(double StokesTimeConv,const vector<double> &IonTimeConv){
|
||||
vector<int> ScaLBL_Multiphys_Controller::getIonNumIter_PNP_coupling(
|
||||
double StokesTimeConv, const vector<double> &IonTimeConv) {
|
||||
//Return number of internal iterations for the Ion transport solver
|
||||
vector<int> num_iter_ion;
|
||||
vector<double> TimeConv;
|
||||
TimeConv.assign(IonTimeConv.begin(),IonTimeConv.end());
|
||||
TimeConv.insert(TimeConv.begin(),StokesTimeConv);
|
||||
vector<double>::iterator it_max = max_element(TimeConv.begin(),TimeConv.end());
|
||||
unsigned int idx_max = distance(TimeConv.begin(),it_max);
|
||||
if (idx_max==0){
|
||||
for (unsigned int idx=1;idx<TimeConv.size();idx++){
|
||||
double temp = 2*StokesTimeConv/TimeConv[idx];//the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp/2)*2));
|
||||
TimeConv.assign(IonTimeConv.begin(), IonTimeConv.end());
|
||||
TimeConv.insert(TimeConv.begin(), StokesTimeConv);
|
||||
vector<double>::iterator it_max =
|
||||
max_element(TimeConv.begin(), TimeConv.end());
|
||||
unsigned int idx_max = distance(TimeConv.begin(), it_max);
|
||||
if (idx_max == 0) {
|
||||
for (unsigned int idx = 1; idx < TimeConv.size(); idx++) {
|
||||
double temp =
|
||||
2 * StokesTimeConv /
|
||||
TimeConv
|
||||
[idx]; //the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp / 2) * 2));
|
||||
}
|
||||
}
|
||||
else if (idx_max==1){
|
||||
} else if (idx_max == 1) {
|
||||
num_iter_ion.push_back(2);
|
||||
for (unsigned int idx=2;idx<TimeConv.size();idx++){
|
||||
double temp = 2*TimeConv[idx_max]/TimeConv[idx];//the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp/2)*2));
|
||||
for (unsigned int idx = 2; idx < TimeConv.size(); idx++) {
|
||||
double temp =
|
||||
2 * TimeConv[idx_max] /
|
||||
TimeConv
|
||||
[idx]; //the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp / 2) * 2));
|
||||
}
|
||||
}
|
||||
else if (idx_max==TimeConv.size()-1){
|
||||
for (unsigned int idx=1;idx<TimeConv.size()-1;idx++){
|
||||
double temp = 2*TimeConv[idx_max]/TimeConv[idx];//the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp/2)*2));
|
||||
} else if (idx_max == TimeConv.size() - 1) {
|
||||
for (unsigned int idx = 1; idx < TimeConv.size() - 1; idx++) {
|
||||
double temp =
|
||||
2 * TimeConv[idx_max] /
|
||||
TimeConv
|
||||
[idx]; //the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp / 2) * 2));
|
||||
}
|
||||
num_iter_ion.push_back(2);
|
||||
}
|
||||
else {
|
||||
for (unsigned int idx=1;idx<idx_max;idx++){
|
||||
double temp = 2*TimeConv[idx_max]/TimeConv[idx];//the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp/2)*2));
|
||||
} else {
|
||||
for (unsigned int idx = 1; idx < idx_max; idx++) {
|
||||
double temp =
|
||||
2 * TimeConv[idx_max] /
|
||||
TimeConv
|
||||
[idx]; //the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp / 2) * 2));
|
||||
}
|
||||
num_iter_ion.push_back(2);
|
||||
for (unsigned int idx=idx_max+1;idx<TimeConv.size();idx++){
|
||||
double temp = 2*TimeConv[idx_max]/TimeConv[idx];//the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp/2)*2));
|
||||
for (unsigned int idx = idx_max + 1; idx < TimeConv.size(); idx++) {
|
||||
double temp =
|
||||
2 * TimeConv[idx_max] /
|
||||
TimeConv
|
||||
[idx]; //the factor 2 is the number of iterations for the element has max time_conv
|
||||
num_iter_ion.push_back(int(round(temp / 2) * 2));
|
||||
}
|
||||
}
|
||||
return num_iter_ion;
|
||||
}
|
||||
|
||||
void ScaLBL_Multiphys_Controller::getTimeConvMax_PNP_coupling(double StokesTimeConv,const vector<double> &IonTimeConv){
|
||||
void ScaLBL_Multiphys_Controller::getTimeConvMax_PNP_coupling(
|
||||
double StokesTimeConv, const vector<double> &IonTimeConv) {
|
||||
//Return maximum of the time converting factor from Stokes and ion solvers
|
||||
vector<double> TimeConv;
|
||||
|
||||
TimeConv.assign(IonTimeConv.begin(),IonTimeConv.end());
|
||||
TimeConv.insert(TimeConv.begin(),StokesTimeConv);
|
||||
time_conv_max = *max_element(TimeConv.begin(),TimeConv.end());
|
||||
TimeConv.assign(IonTimeConv.begin(), IonTimeConv.end());
|
||||
TimeConv.insert(TimeConv.begin(), StokesTimeConv);
|
||||
time_conv_max = *max_element(TimeConv.begin(), TimeConv.end());
|
||||
}
|
||||
|
||||
@@ -17,19 +17,22 @@
|
||||
#include "analysis/Minkowski.h"
|
||||
#include "ProfilerApp.h"
|
||||
|
||||
class ScaLBL_Multiphys_Controller{
|
||||
class ScaLBL_Multiphys_Controller {
|
||||
public:
|
||||
ScaLBL_Multiphys_Controller(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_Multiphys_Controller();
|
||||
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
int getStokesNumIter_PNP_coupling(double StokesTimeConv,const vector<double> &IonTimeConv);
|
||||
vector<int> getIonNumIter_PNP_coupling(double StokesTimeConv,const vector<double> &IonTimeConv);
|
||||
ScaLBL_Multiphys_Controller(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_Multiphys_Controller();
|
||||
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
int getStokesNumIter_PNP_coupling(double StokesTimeConv,
|
||||
const vector<double> &IonTimeConv);
|
||||
vector<int> getIonNumIter_PNP_coupling(double StokesTimeConv,
|
||||
const vector<double> &IonTimeConv);
|
||||
//void getIonNumIter_PNP_coupling(double StokesTimeConv,vector<double> &IonTimeConv,vector<int> &IonTimeMax);
|
||||
void getTimeConvMax_PNP_coupling(double StokesTimeConv,const vector<double> &IonTimeConv);
|
||||
|
||||
bool Restart;
|
||||
void getTimeConvMax_PNP_coupling(double StokesTimeConv,
|
||||
const vector<double> &IonTimeConv);
|
||||
|
||||
bool Restart;
|
||||
int timestepMax;
|
||||
int num_iter_Stokes;
|
||||
vector<int> num_iter_Ion;
|
||||
@@ -39,20 +42,20 @@ public:
|
||||
double time_conv_max;
|
||||
//double SchmidtNum;//Schmidt number = kinematic_viscosity/mass_diffusivity
|
||||
|
||||
int rank,nprocs;
|
||||
int rank, nprocs;
|
||||
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> study_db;
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,56 +22,57 @@
|
||||
#ifndef ScaLBL_POISSON_INC
|
||||
#define ScaLBL_POISSON_INC
|
||||
|
||||
class ScaLBL_Poisson{
|
||||
class ScaLBL_Poisson {
|
||||
public:
|
||||
ScaLBL_Poisson(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_Poisson();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize(double time_conv_from_Study);
|
||||
void Run(double *ChargeDensity,int timestep_from_Study);
|
||||
ScaLBL_Poisson(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_Poisson();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize(double time_conv_from_Study);
|
||||
void Run(double *ChargeDensity, int timestep_from_Study);
|
||||
void getElectricPotential(DoubleArray &ReturnValues);
|
||||
void getElectricPotential_debug(int timestep);
|
||||
void getElectricField(DoubleArray &Values_x, DoubleArray &Values_y, DoubleArray &Values_z);
|
||||
void getElectricField(DoubleArray &Values_x, DoubleArray &Values_y,
|
||||
DoubleArray &Values_z);
|
||||
void getElectricField_debug(int timestep);
|
||||
void DummyChargeDensity();//for debugging
|
||||
void DummyChargeDensity(); //for debugging
|
||||
|
||||
//bool Restart,pBC;
|
||||
int timestep,timestepMax;
|
||||
//bool Restart,pBC;
|
||||
int timestep, timestepMax;
|
||||
int analysis_interval;
|
||||
int BoundaryConditionInlet;
|
||||
int BoundaryConditionOutlet;
|
||||
int BoundaryConditionInlet;
|
||||
int BoundaryConditionOutlet;
|
||||
int BoundaryConditionSolid;
|
||||
double tau;
|
||||
double tolerance;
|
||||
double tau;
|
||||
double tolerance;
|
||||
std::string tolerance_method;
|
||||
double k2_inv;
|
||||
double epsilon0,epsilon0_LB,epsilonR,epsilon_LB;
|
||||
double epsilon0, epsilon0_LB, epsilonR, epsilon_LB;
|
||||
double Vin, Vout;
|
||||
double chargeDen_dummy;//for debugging
|
||||
double chargeDen_dummy; //for debugging
|
||||
bool WriteLog;
|
||||
double Vin0,freqIn,t0_In,Vin_Type;
|
||||
double Vout0,freqOut,t0_Out,Vout_Type;
|
||||
bool TestPeriodic;
|
||||
double TestPeriodicTime;//unit: [sec]
|
||||
double TestPeriodicTimeConv; //unit [sec/lt]
|
||||
double Vin0, freqIn, t0_In, Vin_Type;
|
||||
double Vout0, freqOut, t0_Out, Vout_Type;
|
||||
bool TestPeriodic;
|
||||
double TestPeriodicTime; //unit: [sec]
|
||||
double TestPeriodicTimeConv; //unit [sec/lt]
|
||||
double TestPeriodicSaveInterval; //unit [sec]
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
double h;//image resolution
|
||||
double time_conv;//phys to LB time converting factor; unit=[sec/lt]
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
double h; //image resolution
|
||||
double time_conv; //phys to LB time converting factor; unit=[sec/lt]
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm_Regular;
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -85,24 +86,24 @@ public:
|
||||
int *dvcMap;
|
||||
//signed char *dvcID;
|
||||
double *fq;
|
||||
double *Psi;
|
||||
double *Psi;
|
||||
double *ElectricField;
|
||||
double *ChargeDensityDummy;// for debugging
|
||||
double *ChargeDensityDummy; // for debugging
|
||||
double *ResidualError;
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
FILE *TIMELOG;
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
FILE *TIMELOG;
|
||||
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
char OutputFilename[200];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void AssignSolidBoundary(double *poisson_solid);
|
||||
void Potential_Init(double *psi_init);
|
||||
void ElectricField_LB_to_Phys(DoubleArray &Efield_reg);
|
||||
@@ -111,8 +112,8 @@ private:
|
||||
//void SolveElectricField();
|
||||
void SolvePoissonAAodd(double *ChargeDensity);
|
||||
void SolvePoissonAAeven(double *ChargeDensity);
|
||||
void getConvergenceLog(int timestep,double error);
|
||||
double getBoundaryVoltagefromPeriodicBC(double V0,double freq,double t0,int V_type,int time_step);
|
||||
|
||||
void getConvergenceLog(int timestep, double error);
|
||||
double getBoundaryVoltagefromPeriodicBC(double V0, double freq, double t0,
|
||||
int V_type, int time_step);
|
||||
};
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,49 +18,51 @@
|
||||
#include "analysis/Minkowski.h"
|
||||
#include "ProfilerApp.h"
|
||||
|
||||
class ScaLBL_StokesModel{
|
||||
class ScaLBL_StokesModel {
|
||||
public:
|
||||
ScaLBL_StokesModel(int RANK, int NP, const Utilities::MPI& COMM);
|
||||
~ScaLBL_StokesModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename,int num_iter);
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run();
|
||||
void Run_Lite(double *ChargeDensity, double *ElectricField);
|
||||
void VelocityField();
|
||||
ScaLBL_StokesModel(int RANK, int NP, const Utilities::MPI &COMM);
|
||||
~ScaLBL_StokesModel();
|
||||
|
||||
// functions in they should be run
|
||||
void ReadParams(string filename, int num_iter);
|
||||
void ReadParams(string filename);
|
||||
void ReadParams(std::shared_ptr<Database> db0);
|
||||
void SetDomain();
|
||||
void ReadInput();
|
||||
void Create();
|
||||
void Initialize();
|
||||
void Run();
|
||||
void Run_Lite(double *ChargeDensity, double *ElectricField);
|
||||
void VelocityField();
|
||||
void getVelocity(DoubleArray &Velx, DoubleArray &Vel_y, DoubleArray &Vel_z);
|
||||
void getVelocity_debug(int timestep);
|
||||
double CalVelocityConvergence(double& flow_rate_previous,double *ChargeDensity, double *ElectricField);
|
||||
|
||||
bool Restart,pBC;
|
||||
int timestep,timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tau,mu;
|
||||
double CalVelocityConvergence(double &flow_rate_previous,
|
||||
double *ChargeDensity, double *ElectricField);
|
||||
|
||||
bool Restart, pBC;
|
||||
int timestep, timestepMax;
|
||||
int BoundaryCondition;
|
||||
double tau, mu;
|
||||
double rho0;
|
||||
double Fx,Fy,Fz,flux;
|
||||
double din,dout;
|
||||
double tolerance;
|
||||
double Fx, Fy, Fz, flux;
|
||||
double din, dout;
|
||||
double tolerance;
|
||||
double nu_phys;
|
||||
double rho_phys;
|
||||
double time_conv;
|
||||
double h;//image resolution
|
||||
double den_scale;//scale factor for density
|
||||
double epsilon0,epsilon0_LB,epsilonR,epsilon_LB;//Stokes solver also needs this for slipping velocity BC
|
||||
double h; //image resolution
|
||||
double den_scale; //scale factor for density
|
||||
double epsilon0, epsilon0_LB, epsilonR,
|
||||
epsilon_LB; //Stokes solver also needs this for slipping velocity BC
|
||||
bool UseSlippingVelBC;
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
double Lx,Ly,Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
int Nx, Ny, Nz, N, Np;
|
||||
int rank, nprocx, nprocy, nprocz, nprocs;
|
||||
double Lx, Ly, Lz;
|
||||
|
||||
std::shared_ptr<Domain> Dm; // this domain is for analysis
|
||||
std::shared_ptr<Domain> Mask; // this domain is for lbm
|
||||
std::shared_ptr<ScaLBL_Communicator> ScaLBL_Comm;
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
std::shared_ptr<Database> domain_db;
|
||||
@@ -74,24 +76,26 @@ public:
|
||||
double *Pressure;
|
||||
double *ZetaPotentialSolid;
|
||||
double *SolidGrad;
|
||||
|
||||
|
||||
//Minkowski Morphology;
|
||||
DoubleArray Velocity_x;
|
||||
DoubleArray Velocity_y;
|
||||
DoubleArray Velocity_z;
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
Utilities::MPI comm;
|
||||
|
||||
// filenames
|
||||
char LocalRankString[8];
|
||||
char LocalRankFilename[40];
|
||||
char LocalRestartFile[40];
|
||||
char OutputFilename[200];
|
||||
|
||||
|
||||
//int rank,nprocs;
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void Velocity_LB_to_Phys(DoubleArray &Vel_reg);
|
||||
vector<double> computeElectricForceAvg(double *ChargeDensity, double *ElectricField);
|
||||
vector<double> computeElectricForceAvg(double *ChargeDensity,
|
||||
double *ElectricField);
|
||||
void AssignSolidGrad(double *solid_grad);
|
||||
void AssignZetaPotentialSolid(double *zeta_potential_solid);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user