Files
LBPM/models/GreyscaleColorModel.h

165 lines
4.0 KiB
C
Raw Normal View History

2020-06-09 15:42:45 -04:00
/*
Implementation of two-fluid greyscale color lattice boltzmann model
2020-06-09 15:42:45 -04:00
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <iostream>
#include <exception>
#include <stdexcept>
#include <fstream>
#include "common/Communication.h"
#include "analysis/GreyPhase.h"
2021-01-06 11:58:43 -05:00
#include "common/MPI.h"
2020-06-09 15:42:45 -04:00
#include "ProfilerApp.h"
#include "threadpool/thread_pool.h"
2021-10-08 12:10:03 -04:00
/**
* \class ScaLBL_GreyscaleColorModel
*
* @details
* The ScaLBL_GreyscaleColorModel class extends the standard color model incorporate transport
* through sub-resolution "greyscale" regions.
* Momentum transport equations are described by a D3Q19 scheme
* Mass transport equations are described by D3Q7 scheme
*/
class ScaLBL_GreyscaleColorModel{
2020-06-09 15:42:45 -04:00
public:
2021-10-08 12:10:03 -04:00
/**
* \brief Constructor
* @param RANK processor rank
* @param NP number of processors
* @param COMM MPI communicator
*/
2021-01-05 18:43:44 -05:00
ScaLBL_GreyscaleColorModel(int RANK, int NP, const Utilities::MPI& COMM);
~ScaLBL_GreyscaleColorModel();
2020-06-09 15:42:45 -04:00
// functions in they should be run
2021-10-08 12:10:03 -04:00
/**
* \brief Read simulation parameters
* @param filename input database file that includes "Color" section
*/
2020-06-09 15:42:45 -04:00
void ReadParams(string filename);
2021-10-08 12:10:03 -04:00
/**
* \brief Read simulation parameters
* @param db0 input database that includes "Color" section
*/
2020-06-09 15:42:45 -04:00
void ReadParams(std::shared_ptr<Database> db0);
2021-10-08 12:10:03 -04:00
/**
* \brief Create domain data structures
*/
2020-06-09 15:42:45 -04:00
void SetDomain();
2021-10-08 12:10:03 -04:00
/**
* \brief Read image data
*/
2020-06-09 15:42:45 -04:00
void ReadInput();
2021-10-08 12:10:03 -04:00
/**
* \brief Create color model data structures
*/
2020-06-09 15:42:45 -04:00
void Create();
2021-10-08 12:10:03 -04:00
/**
* \brief Initialize the simulation
*/
2020-06-09 15:42:45 -04:00
void Initialize();
2021-10-08 12:10:03 -04:00
/**
* \brief Run the simulation
*/
2020-06-09 15:42:45 -04:00
void Run();
2021-10-08 12:10:03 -04:00
/**
* \brief Debugging function to dump simulation state to disk
*/
2020-06-09 15:42:45 -04:00
void WriteDebug();
2021-10-21 20:38:18 -04:00
void WriteVisFiles();
2020-06-09 15:42:45 -04:00
bool Restart,pBC;
bool REVERSE_FLOW_DIRECTION;
int timestep,timestepMax;
int BoundaryCondition;
double tauA,tauB,rhoA,rhoB,alpha,beta;
double tauA_eff,tauB_eff;
2020-06-09 15:42:45 -04:00
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
2020-06-09 15:42:45 -04:00
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;
2021-03-03 20:53:36 -05:00
std::shared_ptr<GreyPhaseAnalysis> Averages;
2020-06-09 15:42:45 -04:00
// input database
std::shared_ptr<Database> db;
std::shared_ptr<Database> domain_db;
std::shared_ptr<Database> greyscaleColor_db;
2020-06-09 15:42:45 -04:00
std::shared_ptr<Database> analysis_db;
std::shared_ptr<Database> vis_db;
IntArray Map;
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;
double *GreySn;
double *GreySw;
2021-08-09 08:34:10 -04:00
double *GreyKn;
double *GreyKw;
2021-10-08 12:10:03 -04:00
double *MobilityRatio;
2020-06-09 15:42:45 -04:00
double *Velocity;
double *Pressure;
double *Porosity_dvc;
double *Permeability_dvc;
//double *Psi;
2020-06-09 15:42:45 -04:00
private:
2021-01-05 18:43:44 -05:00
Utilities::MPI comm;
2020-06-09 15:42:45 -04:00
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);
2021-10-08 12:10:03 -04:00
/**
* \brief Assign wetting affinity values
*/
void AssignComponentLabels();
2021-10-08 12:10:03 -04:00
/**
* \brief Assign wetting affinity values in greyscale regions
*/
void AssignGreySolidLabels();
2021-10-08 12:10:03 -04:00
/**
* \brief Assign porosity and permeability in greyscale regions
*/
void AssignGreyPoroPermLabels();
2021-10-08 12:10:03 -04:00
/**
* \brief Seed phase field
*/
2020-06-09 15:42:45 -04:00
double SeedPhaseField(const double seed_water_in_oil);
};