Merge branch 'FOM' of github.com:JamesEMcClure/LBPM-WIA into FOM
This commit is contained in:
@@ -93,7 +93,7 @@ SubPhase::SubPhase(std::shared_ptr <Domain> dm):
|
||||
{
|
||||
// If timelog is empty, write a short header to list the averages
|
||||
//fprintf(TIMELOG,"--------------------------------------------------------------------------------------\n");
|
||||
fprintf(TIMELOG,"sw krw krn vw vn pw pn wet\n");
|
||||
fprintf(TIMELOG,"sw krw krn vw vn force pw pn wet\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,7 +348,7 @@ void SubPhase::Basic(){
|
||||
double krn = h*h*nu_n*not_water_flow_rate / force_mag ;
|
||||
double krw = h*h*nu_w*water_flow_rate / force_mag;
|
||||
//printf(" water saturation = %f, fractional flow =%f \n",saturation,fractional_flow);
|
||||
fprintf(TIMELOG,"%.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g\n",saturation,krw,krn,h*water_flow_rate,h*not_water_flow_rate, gwb.p, gnb.p, total_wetting_interaction_global);
|
||||
fprintf(TIMELOG,"%.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g\n",saturation,krw,krn,h*water_flow_rate,h*not_water_flow_rate, force_mag, gwb.p, gnb.p, total_wetting_interaction_global);
|
||||
fflush(TIMELOG);
|
||||
}
|
||||
if (err==true){
|
||||
|
||||
@@ -320,6 +320,8 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
|
||||
DoubleArray phase(nx,ny,nz);
|
||||
IntArray phase_label(nx,ny,nz);
|
||||
Array<char> ID(nx,ny,nz);
|
||||
fillHalo<char> fillChar(Dm->Comm,Dm->rank_info,{nx-2,ny-2,nz-2},{1,1,1},0,1);
|
||||
|
||||
int n;
|
||||
double final_void_fraction;
|
||||
@@ -337,10 +339,11 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
count += 1.0;
|
||||
id[n] = 2;
|
||||
}
|
||||
ID(i,j,k) = id[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fillChar.fill(ID);
|
||||
Dm->Comm.barrier();
|
||||
|
||||
// total Global is the number of nodes in the pore-space
|
||||
@@ -351,7 +354,8 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
if (rank==0) printf("Volume fraction for morphological opening: %f \n",volume_fraction);
|
||||
if (rank==0) printf("Maximum pore size: %f \n",maxdistGlobal);
|
||||
|
||||
// Communication buffers
|
||||
|
||||
/* // Communication buffers
|
||||
signed char *sendID_x, *sendID_y, *sendID_z, *sendID_X, *sendID_Y, *sendID_Z;
|
||||
signed char *sendID_xy, *sendID_yz, *sendID_xz, *sendID_Xy, *sendID_Yz, *sendID_xZ;
|
||||
signed char *sendID_xY, *sendID_yZ, *sendID_Xz, *sendID_XY, *sendID_YZ, *sendID_XZ;
|
||||
@@ -400,7 +404,7 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
//......................................................................................
|
||||
int sendtag,recvtag;
|
||||
sendtag = recvtag = 7;
|
||||
|
||||
*/
|
||||
int ii,jj,kk;
|
||||
int Nx = nx;
|
||||
int Ny = ny;
|
||||
@@ -455,9 +459,10 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
for (ii=imin; ii<imax; ii++){
|
||||
int nn = kk*nx*ny+jj*nx+ii;
|
||||
double dsq = double((ii-i)*(ii-i)+(jj-j)*(jj-j)+(kk-k)*(kk-k));
|
||||
if (id[nn] == 2 && dsq <= (Rcrit_new+1)*(Rcrit_new+1)){
|
||||
if (ID(ii,jj,kk) == 2 && dsq <= (Rcrit_new+1)*(Rcrit_new+1)){
|
||||
LocalNumber+=1.0;
|
||||
id[nn]=1;
|
||||
//id[nn]=1;
|
||||
ID(ii,jj,kk)=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,8 +473,9 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
}
|
||||
}
|
||||
}
|
||||
fillChar.fill(ID);
|
||||
// Pack and send the updated ID values
|
||||
PackID(Dm->sendList("x"), Dm->sendCount("x") ,sendID_x, id);
|
||||
/* PackID(Dm->sendList("x"), Dm->sendCount("x") ,sendID_x, id);
|
||||
PackID(Dm->sendList("X"), Dm->sendCount("X") ,sendID_X, id);
|
||||
PackID(Dm->sendList("y"), Dm->sendCount("y") ,sendID_y, id);
|
||||
PackID(Dm->sendList("Y"), Dm->sendCount("Y") ,sendID_Y, id);
|
||||
@@ -527,12 +533,12 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
UnpackID(Dm->recvList("YZ"), Dm->recvCount("YZ") ,recvID_YZ, id);
|
||||
//......................................................................................
|
||||
// double GlobalNumber = Dm->Comm.sumReduce( LocalNumber );
|
||||
|
||||
*/
|
||||
for (int k=0; k<nz; k++){
|
||||
for (int j=0; j<ny; j++){
|
||||
for (int i=0; i<nx; i++){
|
||||
n=k*nx*ny+j*nx+i;
|
||||
if (id[n] == 1){
|
||||
if (ID(i,j,k) == 1){
|
||||
phase(i,j,k) = 1.0;
|
||||
}
|
||||
else
|
||||
@@ -550,9 +556,10 @@ double MorphDrain(DoubleArray &SignDist, signed char *id, std::shared_ptr<Domain
|
||||
for (int j=0; j<ny; j++){
|
||||
for (int i=0; i<nx; i++){
|
||||
n=k*nx*ny+j*nx+i;
|
||||
if (id[n] == 1 && phase_label(i,j,k) > 1){
|
||||
id[n] = 2;
|
||||
if (ID(i,j,k) == 1 && phase_label(i,j,k) > 1){
|
||||
ID(i,j,k) = 2;
|
||||
}
|
||||
id[n] = ID(i,j,k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ void Domain::initialize( std::shared_ptr<Database> db )
|
||||
if (rank_info.kz < nproc[2]-1) outlet_layers_z = 0;
|
||||
// Fill remaining variables
|
||||
N = Nx*Ny*Nz;
|
||||
Volume = nx*ny*nx*nproc[0]*nproc[1]*nproc[2]*1.0;
|
||||
Volume = nx*ny*nz*nproc[0]*nproc[1]*nproc[2]*1.0;
|
||||
|
||||
if (myrank==0) printf("voxel length = %f micron \n", voxel_length);
|
||||
|
||||
@@ -620,12 +620,16 @@ void Domain::Decomp( const std::string& Filename )
|
||||
Comm.recv(id.data(),N,0,15);
|
||||
}
|
||||
Comm.barrier();
|
||||
|
||||
ComputePorosity();
|
||||
delete [] SegData;
|
||||
}
|
||||
|
||||
void Domain::ComputePorosity(){
|
||||
// Compute the porosity
|
||||
double sum;
|
||||
double sum_local=0.0;
|
||||
double iVol_global = 1.0/(1.0*(Nx-2)*(Ny-2)*(Nz-2)*nprocs);
|
||||
if (BoundaryCondition > 0 && BoundaryCondition !=5) iVol_global = 1.0/(1.0*(Nx-2)*nprocx*(Ny-2)*nprocy*((Nz-2)*nprocz-6));
|
||||
double iVol_global = 1.0/(1.0*(Nx-2)*(Ny-2)*(Nz-2)*nprocx()*nprocy()*nprocz());
|
||||
if (BoundaryCondition > 0 && BoundaryCondition !=5) iVol_global = 1.0/(1.0*(Nx-2)*nprocx()*(Ny-2)*nprocy()*((Nz-2)*nprocz()-6));
|
||||
//.........................................................
|
||||
for (int k=inlet_layers_z+1; k<Nz-outlet_layers_z-1;k++){
|
||||
for (int j=1;j<Ny-1;j++){
|
||||
@@ -640,8 +644,8 @@ void Domain::Decomp( const std::string& Filename )
|
||||
sum = Comm.sumReduce(sum_local);
|
||||
porosity = sum*iVol_global;
|
||||
if (rank()==0) printf("Media porosity = %f \n",porosity);
|
||||
//.........................................................
|
||||
delete [] SegData;
|
||||
//.........................................................
|
||||
|
||||
}
|
||||
|
||||
void Domain::AggregateLabels( const std::string& filename ){
|
||||
@@ -1450,4 +1454,3 @@ void Domain::AggregateLabels( const std::string& filename, DoubleArray &UserData
|
||||
Comm.barrier();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,7 @@ public: // Public variables (need to create accessors instead)
|
||||
std::vector<signed char> id;
|
||||
|
||||
void ReadIDs();
|
||||
void ComputePorosity();
|
||||
void Decomp( const std::string& filename );
|
||||
void CommunicateMeshHalo(DoubleArray &Mesh);
|
||||
void CommInit();
|
||||
|
||||
@@ -973,7 +973,7 @@ int ScaLBL_Communicator::MemoryOptimizedLayoutAA(IntArray &Map, int *neighborLis
|
||||
}
|
||||
|
||||
|
||||
void ScaLBL_Communicator::SetupBounceBackList(IntArray &Map, signed char *id, int Np)
|
||||
void ScaLBL_Communicator::SetupBounceBackList(IntArray &Map, signed char *id, int Np, bool SlippingVelBC)
|
||||
{
|
||||
|
||||
int idx,i,j,k;
|
||||
@@ -1051,6 +1051,23 @@ void ScaLBL_Communicator::SetupBounceBackList(IntArray &Map, signed char *id, in
|
||||
int *bb_interactions_tmp = new int [local_count];
|
||||
ScaLBL_AllocateDeviceMemory((void **) &bb_dist, sizeof(int)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &bb_interactions, sizeof(int)*local_count);
|
||||
int *fluid_boundary_tmp;
|
||||
double *lattice_weight_tmp;
|
||||
float *lattice_cx_tmp;
|
||||
float *lattice_cy_tmp;
|
||||
float *lattice_cz_tmp;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp = new int [local_count];
|
||||
lattice_weight_tmp = new double [local_count];
|
||||
lattice_cx_tmp = new float [local_count];
|
||||
lattice_cy_tmp = new float [local_count];
|
||||
lattice_cz_tmp = new float [local_count];
|
||||
ScaLBL_AllocateDeviceMemory((void **) &fluid_boundary, sizeof(int)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_weight, sizeof(double)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cx, sizeof(float)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cy, sizeof(float)*local_count);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &lattice_cz, sizeof(float)*local_count);
|
||||
}
|
||||
|
||||
local_count=0;
|
||||
for (k=1;k<Nz-1;k++){
|
||||
@@ -1064,36 +1081,78 @@ void ScaLBL_Communicator::SetupBounceBackList(IntArray &Map, signed char *id, in
|
||||
neighbor=Map(i-1,j,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 2*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++] = idx + 1*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 4*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j+1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 3*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 6*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/18.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 5*Np;
|
||||
}
|
||||
}
|
||||
@@ -1111,72 +1170,156 @@ void ScaLBL_Communicator::SetupBounceBackList(IntArray &Map, signed char *id, in
|
||||
neighbor=Map(i-1,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 8*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j+1,k);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 7*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i-1,j+1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j+1)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 10*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j-1,k);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j-1)*Nx + (k)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 0.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 9*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i-1,j,k-1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 12*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 11*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i-1,j,k+1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i-1) + (j)*Nx + (k+1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = -1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 14*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i+1,j,k-1);
|
||||
if (neighbor==-1) {
|
||||
bb_interactions_tmp[local_count] = (i+1) + (j)*Nx + (k-1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 1.0;
|
||||
lattice_cy_tmp[local_count] = 0.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 13*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j-1,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k-1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 16*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j+1,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k+1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 15*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j-1,k+1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j-1)*Nx + (k+1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = -1.0;
|
||||
lattice_cz_tmp[local_count] = 1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 18*Np;
|
||||
}
|
||||
|
||||
neighbor=Map(i,j+1,k-1);
|
||||
if (neighbor==-1){
|
||||
bb_interactions_tmp[local_count] = (i) + (j+1)*Nx + (k-1)*Nx*Ny;
|
||||
if(SlippingVelBC==true){
|
||||
fluid_boundary_tmp[local_count] = idx;
|
||||
lattice_weight_tmp[local_count] = 1.0/36.0;
|
||||
lattice_cx_tmp[local_count] = 0.0;
|
||||
lattice_cy_tmp[local_count] = 1.0;
|
||||
lattice_cz_tmp[local_count] = -1.0;
|
||||
}
|
||||
bb_dist_tmp[local_count++]=idx + 17*Np;
|
||||
}
|
||||
}
|
||||
@@ -1186,10 +1329,24 @@ void ScaLBL_Communicator::SetupBounceBackList(IntArray &Map, signed char *id, in
|
||||
n_bb_d3q19 = local_count; // this gives the d3q19 distributions not part of d3q7 model
|
||||
ScaLBL_CopyToDevice(bb_dist, bb_dist_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(bb_interactions, bb_interactions_tmp, local_count*sizeof(int));
|
||||
if(SlippingVelBC==true){
|
||||
ScaLBL_CopyToDevice(fluid_boundary, fluid_boundary_tmp, local_count*sizeof(int));
|
||||
ScaLBL_CopyToDevice(lattice_weight, lattice_weight_tmp, local_count*sizeof(double));
|
||||
ScaLBL_CopyToDevice(lattice_cx, lattice_cx_tmp, local_count*sizeof(float));
|
||||
ScaLBL_CopyToDevice(lattice_cy, lattice_cy_tmp, local_count*sizeof(float));
|
||||
ScaLBL_CopyToDevice(lattice_cz, lattice_cz_tmp, local_count*sizeof(float));
|
||||
}
|
||||
ScaLBL_DeviceBarrier();
|
||||
|
||||
delete [] bb_dist_tmp;
|
||||
delete [] bb_interactions_tmp;
|
||||
if(SlippingVelBC==true){
|
||||
delete [] fluid_boundary_tmp;
|
||||
delete [] lattice_weight_tmp;
|
||||
delete [] lattice_cx_tmp;
|
||||
delete [] lattice_cy_tmp;
|
||||
delete [] lattice_cz_tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void ScaLBL_Communicator::SolidDirichletD3Q7(double *fq, double *BoundaryValue){
|
||||
@@ -1204,6 +1361,14 @@ void ScaLBL_Communicator::SolidNeumannD3Q7(double *fq, double *BoundaryValue){
|
||||
ScaLBL_Solid_Neumann_D3Q7(fq,BoundaryValue,bb_dist,bb_interactions,n_bb_d3q7);
|
||||
}
|
||||
|
||||
void ScaLBL_Communicator::SolidSlippingVelocityBCD3Q19(double *fq, double *zeta_potential, double *ElectricField, double *SolidGrad,
|
||||
double epsilon_LB, double tau, double rho0, double den_scale,double h, double time_conv){
|
||||
// fq is a D3Q19 distribution
|
||||
// BoundaryValues is a list of values to assign at bounce-back solid sites
|
||||
ScaLBL_Solid_SlippingVelocityBC_D3Q19(fq,zeta_potential,ElectricField,SolidGrad,epsilon_LB,tau,rho0,den_scale,h,time_conv,
|
||||
bb_dist,bb_interactions,fluid_boundary,lattice_weight,lattice_cx,lattice_cy,lattice_cz,n_bb_d3q19,N);
|
||||
}
|
||||
|
||||
void ScaLBL_Communicator::SendD3Q19AA(double *dist){
|
||||
|
||||
// NOTE: the center distribution f0 must NOT be at the start of feven, provide offset to start of f2
|
||||
|
||||
@@ -87,6 +87,19 @@ extern "C" void ScaLBL_D3Q19_AAodd_GreyscaleColor(int *d_neighborList, int *Map,
|
||||
double rhoA, double rhoB, double tauA, double tauB, double tauA_eff,double tauB_eff, double alpha, double beta,
|
||||
double Fx, double Fy, double Fz, int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q19_AAeven_GreyscaleColor_CP(int *Map, double *dist, double *Aq, double *Bq, double *Den,
|
||||
double *Phi, double *GreySolidW, double *Poros,double *Perm,double *Vel, double *Pressure,
|
||||
double rhoA, double rhoB, double tauA, double tauB,double tauA_eff,double tauB_eff, double alpha, double beta,
|
||||
double Fx, double Fy, double Fz, bool RecoloringOff, int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q19_AAodd_GreyscaleColor_CP(int *d_neighborList, int *Map, double *dist, double *Aq, double *Bq, double *Den,
|
||||
double *Phi, double *GreySolidW, double *Poros,double *Perm,double *Vel,double *Pressure,
|
||||
double rhoA, double rhoB, double tauA, double tauB, double tauA_eff,double tauB_eff, double alpha, double beta,
|
||||
double Fx, double Fy, double Fz, bool RecoloringOff, int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
//extern "C" void ScaLBL_Update_GreyscalePotential(int *Map, double *Phi, double *Psi, double *Poro, double *Perm, double alpha, double W,
|
||||
// int start, int finish, int Np);
|
||||
|
||||
// ION TRANSPORT MODEL
|
||||
|
||||
extern "C" void ScaLBL_D3Q7_AAodd_IonConcentration(int *neighborList, double *dist, double *Den, int start, int finish, int Np);
|
||||
@@ -193,11 +206,12 @@ extern "C" void ScaLBL_D3Q19_FreeLeeModel_SingleFluid_Init(double *gqbar, double
|
||||
extern "C" void ScaLBL_FreeLeeModel_PhaseField_Init(int *Map, double *Phi, double *Den, double *hq, double *ColorGrad,
|
||||
double rhonA, double rhoB, double tauM, double W, int start, int finish, int Np);
|
||||
|
||||
//extern "C" void ScaLBL_D3Q7_AAodd_FreeLeeModel_PhaseField(int *neighborList, int *Map, double *hq, double *Den, double *Phi,
|
||||
// double rhoA, double rhoB, int start, int finish, int Np);
|
||||
extern "C" void ScaLBL_D3Q7_AAodd_FreeLeeModel_PhaseField(int *neighborList, int *Map, double *hq, double *Den, double *Phi,
|
||||
double rhoA, double rhoB, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q7_AAeven_FreeLeeModel_PhaseField(int *Map, double *hq, double *Den, double *Phi,
|
||||
double rhoA, double rhoB, int start, int finish, int Np);
|
||||
|
||||
//extern "C" void ScaLBL_D3Q7_AAeven_FreeLeeModel_PhaseField(int *Map, double *hq, double *Den, double *Phi,
|
||||
// double rhoA, double rhoB, int start, int finish, int Np);
|
||||
extern "C" void ScaLBL_D3Q7_AAodd_FreeLee_PhaseField(int *neighborList, int *Map, double *hq, double *Den, double *Phi, double *ColorGrad, double *Vel,
|
||||
double rhoA, double rhoB, double tauM, double W, int start, int finish, int Np);
|
||||
|
||||
@@ -214,6 +228,22 @@ extern "C" void ScaLBL_D3Q19_AAeven_FreeLeeModel(int *Map, double *dist, double
|
||||
double rhoA, double rhoB, double tauA, double tauB, double kappa, double beta, double W, double Fx, double Fy, double Fz,
|
||||
int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q19_AAodd_FreeLeeModel_Combined(int *neighborList, int *Map, double *dist, double *hq, double *Den, double *Phi, double *mu_phi, double *Vel, double *Pressure, double *ColorGrad,
|
||||
double rhoA, double rhoB, double tauA, double tauB, double tauM, double kappa, double beta, double W, double Fx, double Fy, double Fz,
|
||||
int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q19_AAeven_FreeLeeModel_Combined(int *Map, double *dist, double *hq, double *Den, double *Phi, double *mu_phi, double *Vel, double *Pressure, double *ColorGrad,
|
||||
double rhoA, double rhoB, double tauA, double tauB, double tauM, double kappa, double beta, double W, double Fx, double Fy, double Fz,
|
||||
int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q19_AAodd_FreeLeeModel_Combined_HigherOrder(int *neighborList, int *Map, double *dist, double *hq, double *Den, double *Phi, double *mu_phi, double *Vel, double *Pressure, double *ColorGrad,
|
||||
double rhoA, double rhoB, double tauA, double tauB, double tauM, double kappa, double beta, double W, double Fx, double Fy, double Fz,
|
||||
int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q19_AAeven_FreeLeeModel_Combined_HigherOrder(int *Map, double *dist, double *hq, double *Den, double *Phi, double *mu_phi, double *Vel, double *Pressure, double *ColorGrad,
|
||||
double rhoA, double rhoB, double tauA, double tauB, double tauM, double kappa, double beta, double W, double Fx, double Fy, double Fz,
|
||||
int strideY, int strideZ, int start, int finish, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q19_AAodd_FreeLeeModel_SingleFluid_BGK(int *neighborList, double *dist, double *Vel, double *Pressure,
|
||||
double tau, double rho0, double Fx, double Fy, double Fz, int start, int finish, int Np);
|
||||
|
||||
@@ -258,6 +288,12 @@ extern "C" void ScaLBL_Solid_Dirichlet_D3Q7(double *dist,double *BoundaryValue,i
|
||||
|
||||
extern "C" void ScaLBL_Solid_Neumann_D3Q7(double *dist,double *BoundaryValue,int *BounceBackDist_list,int *BounceBackSolid_list,int N);
|
||||
|
||||
extern "C" void ScaLBL_Solid_SlippingVelocityBC_D3Q19(double *dist, double *zeta_potential, double *ElectricField, double *SolidGrad,
|
||||
double epsilon_LB, double tau, double rho0,double den_scale, double h, double time_conv,
|
||||
int *BounceBackDist_list, int *BounceBackSolid_list, int *FluidBoundary_list,
|
||||
double *lattice_weight, float *lattice_cx, float *lattice_cy, float *lattice_cz,
|
||||
int count, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q7_AAeven_Poisson_Potential_BC_z(int *list, double *dist, double Vin, int count, int Np);
|
||||
|
||||
extern "C" void ScaLBL_D3Q7_AAeven_Poisson_Potential_BC_Z(int *list, double *dist, double Vout, int count, int Np);
|
||||
@@ -337,9 +373,11 @@ public:
|
||||
void RecvHalo(double *data);
|
||||
void RecvGrad(double *Phi, double *Gradient);
|
||||
void RegularLayout(IntArray map, const double *data, DoubleArray ®data);
|
||||
void SetupBounceBackList(IntArray &Map, signed char *id, int Np);
|
||||
void SetupBounceBackList(IntArray &Map, signed char *id, int Np, bool SlippingVelBC=false);
|
||||
void SolidDirichletD3Q7(double *fq, double *BoundaryValue);
|
||||
void SolidNeumannD3Q7(double *fq, double *BoundaryValue);
|
||||
void SolidSlippingVelocityBCD3Q19(double *fq, double *zeta_potential, double *ElectricField, double *SolidGrad,
|
||||
double epslion_LB, double tau, double rho0, double den_scale,double h, double time_conv);
|
||||
|
||||
// Routines to set boundary conditions
|
||||
void Color_BC_z(int *Map, double *Phi, double *Den, double vA, double vB);
|
||||
@@ -414,6 +452,9 @@ private:
|
||||
//......................................................................................
|
||||
int *bb_dist;
|
||||
int *bb_interactions;
|
||||
int *fluid_boundary;
|
||||
double *lattice_weight;
|
||||
float *lattice_cx, *lattice_cy, *lattice_cz;
|
||||
//......................................................................................
|
||||
|
||||
};
|
||||
|
||||
@@ -30,6 +30,57 @@ extern "C" void ScaLBL_Solid_Neumann_D3Q7(double *dist,double *BoundaryValue,int
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void ScaLBL_Solid_SlippingVelocityBC_D3Q19(double *dist, double *zeta_potential, double *ElectricField, double *SolidGrad,
|
||||
double epsilon_LB, double tau, double rho0,double den_scale, double h, double time_conv,
|
||||
int *BounceBackDist_list, int *BounceBackSolid_list, int *FluidBoundary_list,
|
||||
double *lattice_weight, float *lattice_cx, float *lattice_cy, float *lattice_cz,
|
||||
int count, int Np){
|
||||
|
||||
int idx;
|
||||
int iq,ib,ifluidBC;
|
||||
double value_b,value_q;
|
||||
double Ex,Ey,Ez;
|
||||
double Etx,Ety,Etz;//tangential part of electric field
|
||||
double E_mag_normal;
|
||||
double nsx,nsy,nsz;//unit normal solid gradient
|
||||
double ubx,uby,ubz;//slipping velocity at fluid boundary nodes
|
||||
float cx,cy,cz;//lattice velocity (D3Q19)
|
||||
double LB_weight;//lattice weighting coefficient (D3Q19)
|
||||
double cs2_inv = 3.0;//inverse of cs^2 for D3Q19
|
||||
double nu_LB = (tau-0.5)/cs2_inv;
|
||||
|
||||
for (idx=0; idx<count; idx++){
|
||||
iq = BounceBackDist_list[idx];
|
||||
ib = BounceBackSolid_list[idx];
|
||||
ifluidBC = FluidBoundary_list[idx];
|
||||
value_b = zeta_potential[ib];//get zeta potential from a solid site
|
||||
value_q = dist[iq];
|
||||
|
||||
//Load electric field and compute its tangential componet
|
||||
Ex = ElectricField[ifluidBC+0*Np];
|
||||
Ey = ElectricField[ifluidBC+1*Np];
|
||||
Ez = ElectricField[ifluidBC+2*Np];
|
||||
nsx = SolidGrad[ifluidBC+0*Np];
|
||||
nsy = SolidGrad[ifluidBC+1*Np];
|
||||
nsz = SolidGrad[ifluidBC+2*Np];
|
||||
E_mag_normal = Ex*nsx+Ey*nsy+Ez*nsz;//magnitude of electric field in the direction normal to solid nodes
|
||||
//compute tangential electric field
|
||||
Etx = Ex - E_mag_normal*nsx;
|
||||
Ety = Ey - E_mag_normal*nsy;
|
||||
Etz = Ez - E_mag_normal*nsz;
|
||||
ubx = -epsilon_LB*value_b*Etx/(nu_LB*rho0)*time_conv*time_conv/(h*h*1.0e-12)/den_scale;
|
||||
uby = -epsilon_LB*value_b*Ety/(nu_LB*rho0)*time_conv*time_conv/(h*h*1.0e-12)/den_scale;
|
||||
ubz = -epsilon_LB*value_b*Etz/(nu_LB*rho0)*time_conv*time_conv/(h*h*1.0e-12)/den_scale;
|
||||
|
||||
//compute bounce-back distribution
|
||||
LB_weight = lattice_weight[idx];
|
||||
cx = lattice_cx[idx];
|
||||
cy = lattice_cy[idx];
|
||||
cz = lattice_cz[idx];
|
||||
dist[iq] = value_q - 2.0*LB_weight*rho0*cs2_inv*(cx*ubx+cy*uby+cz*ubz);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void ScaLBL_D3Q7_AAeven_Poisson_Potential_BC_z(int *list, double *dist, double Vin, int count, int Np){
|
||||
for (int idx=0; idx<count; idx++){
|
||||
int n = list[idx];
|
||||
|
||||
2703
cpu/FreeLee.cpp
2703
cpu/FreeLee.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ extern "C" void ScaLBL_D3Q19_MixedGradient(int *Map, double *Phi, double *Gradie
|
||||
{1,0,1},{-1,0,-1},{1,0,-1},{-1,0,1},
|
||||
{0,1,1},{0,-1,-1},{0,1,-1},{0,-1,1}};
|
||||
|
||||
int i,j,k,n,N;
|
||||
int i,j,k,n;
|
||||
int np,np2,nm; // neighbors
|
||||
double v,vp,vp2,vm; // values at neighbors
|
||||
double grad;
|
||||
|
||||
@@ -38,6 +38,57 @@ __global__ void dvc_ScaLBL_Solid_Neumann_D3Q7(double *dist, double *BoundaryValu
|
||||
}
|
||||
}
|
||||
|
||||
__global__ void dvc_ScaLBL_Solid_SlippingVelocityBC_D3Q19(double *dist, double *zeta_potential, double *ElectricField, double *SolidGrad,
|
||||
double epsilon_LB, double tau, double rho0,double den_scale, double h, double time_conv,
|
||||
int *BounceBackDist_list, int *BounceBackSolid_list, int *FluidBoundary_list,
|
||||
double *lattice_weight, float *lattice_cx, float *lattice_cy, float *lattice_cz,
|
||||
int count, int Np)
|
||||
{
|
||||
int idx;
|
||||
int iq,ib,ifluidBC;
|
||||
double value_b,value_q;
|
||||
double Ex,Ey,Ez;
|
||||
double Etx,Ety,Etz;//tangential part of electric field
|
||||
double E_mag_normal;
|
||||
double nsx,nsy,nsz;//unit normal solid gradient
|
||||
double ubx,uby,ubz;//slipping velocity at fluid boundary nodes
|
||||
float cx,cy,cz;//lattice velocity (D3Q19)
|
||||
double LB_weight;//lattice weighting coefficient (D3Q19)
|
||||
double cs2_inv = 3.0;//inverse of cs^2 for D3Q19
|
||||
double nu_LB = (tau-0.5)/cs2_inv;
|
||||
idx = blockIdx.x*blockDim.x + threadIdx.x;
|
||||
if (idx < count){
|
||||
iq = BounceBackDist_list[idx];
|
||||
ib = BounceBackSolid_list[idx];
|
||||
ifluidBC = FluidBoundary_list[idx];
|
||||
value_b = zeta_potential[ib];//get zeta potential from a solid site
|
||||
value_q = dist[iq];
|
||||
|
||||
//Load electric field and compute its tangential componet
|
||||
Ex = ElectricField[ifluidBC+0*Np];
|
||||
Ey = ElectricField[ifluidBC+1*Np];
|
||||
Ez = ElectricField[ifluidBC+2*Np];
|
||||
nsx = SolidGrad[ifluidBC+0*Np];
|
||||
nsy = SolidGrad[ifluidBC+1*Np];
|
||||
nsz = SolidGrad[ifluidBC+2*Np];
|
||||
E_mag_normal = Ex*nsx+Ey*nsy+Ez*nsz;//magnitude of electric field in the direction normal to solid nodes
|
||||
//compute tangential electric field
|
||||
Etx = Ex - E_mag_normal*nsx;
|
||||
Ety = Ey - E_mag_normal*nsy;
|
||||
Etz = Ez - E_mag_normal*nsz;
|
||||
ubx = -epsilon_LB*value_b*Etx/(nu_LB*rho0)*time_conv*time_conv/(h*h*1.0e-12)/den_scale;
|
||||
uby = -epsilon_LB*value_b*Ety/(nu_LB*rho0)*time_conv*time_conv/(h*h*1.0e-12)/den_scale;
|
||||
ubz = -epsilon_LB*value_b*Etz/(nu_LB*rho0)*time_conv*time_conv/(h*h*1.0e-12)/den_scale;
|
||||
|
||||
//compute bounce-back distribution
|
||||
LB_weight = lattice_weight[idx];
|
||||
cx = lattice_cx[idx];
|
||||
cy = lattice_cy[idx];
|
||||
cz = lattice_cz[idx];
|
||||
dist[iq] = value_q - 2.0*LB_weight*rho0*cs2_inv*(cx*ubx+cy*uby+cz*ubz);
|
||||
}
|
||||
}
|
||||
|
||||
__global__ void dvc_ScaLBL_D3Q7_AAeven_Poisson_Potential_BC_z(int *list, double *dist, double Vin, int count, int Np)
|
||||
{
|
||||
int idx,n;
|
||||
@@ -410,6 +461,23 @@ extern "C" void ScaLBL_Solid_Neumann_D3Q7(double *dist, double *BoundaryValue, i
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void ScaLBL_Solid_SlippingVelocityBC_D3Q19(double *dist, double *zeta_potential, double *ElectricField, double *SolidGrad,
|
||||
double epsilon_LB, double tau, double rho0,double den_scale, double h, double time_conv,
|
||||
int *BounceBackDist_list, int *BounceBackSolid_list, int *FluidBoundary_list,
|
||||
double *lattice_weight, float *lattice_cx, float *lattice_cy, float *lattice_cz,
|
||||
int count, int Np){
|
||||
int GRID = count / 512 + 1;
|
||||
dvc_ScaLBL_Solid_SlippingVelocityBC_D3Q19<<<GRID,512>>>(dist, zeta_potential, ElectricField, SolidGrad,
|
||||
epsilon_LB, tau, rho0, den_scale, h, time_conv,
|
||||
BounceBackDist_list, BounceBackSolid_list, FluidBoundary_list,
|
||||
lattice_weight, lattice_cx, lattice_cy, lattice_cz,
|
||||
count, Np);
|
||||
cudaError_t err = cudaGetLastError();
|
||||
if (cudaSuccess != err){
|
||||
printf("CUDA error in ScaLBL_Solid_SlippingVelocityBC_D3Q19 (kernel): %s \n",cudaGetErrorString(err));
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void ScaLBL_D3Q7_AAeven_Poisson_Potential_BC_z(int *list, double *dist, double Vin, int count, int Np){
|
||||
int GRID = count / 512 + 1;
|
||||
dvc_ScaLBL_D3Q7_AAeven_Poisson_Potential_BC_z<<<GRID,512>>>(list, dist, Vin, count, Np);
|
||||
|
||||
4358
cuda/FreeLee.cu
4358
cuda/FreeLee.cu
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,22 @@ Color {
|
||||
ComponentAffinity = -1.0, 1.0, -1.0
|
||||
}
|
||||
|
||||
FreeLee {
|
||||
tauA = 1.0;
|
||||
tauB = 1.0;
|
||||
tauM = 1.0;//relaxation parameter for the phase field
|
||||
rhoA = 1.0;
|
||||
rhoB = 1.0;
|
||||
gamma = 1.0e-4;//surface tension parameter in Lee model
|
||||
W = 3.0; //theoretical interfacial thickness in Lee model; unit:[voxel]
|
||||
F = 0, 0, 0
|
||||
Restart = false
|
||||
timestepMax = 1000
|
||||
flux = 0.0
|
||||
ComponentLabels = 0
|
||||
ComponentAffinity = -1.0
|
||||
}
|
||||
|
||||
Domain {
|
||||
nproc = 1, 1, 1 // Number of processors (Npx,Npy,Npz)
|
||||
n = 80, 80, 80 // Size of local domain (Nx,Ny,Nz)
|
||||
|
||||
1465
hip/FreeLee.cu
1465
hip/FreeLee.cu
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1610,7 +1610,7 @@ double ScaLBL_ColorModel::MorphInit(const double beta, const double target_delta
|
||||
|
||||
delta_volume = (volume_final-volume_initial);
|
||||
if (rank == 0) printf("MorphInit: change fluid volume fraction by %f \n", delta_volume/volume_initial);
|
||||
if (rank == 0) printf(" new saturation = %f \n", volume_final/(0.238323*double((Nx-2)*(Ny-2)*(Nz-2)*nprocs)));
|
||||
if (rank == 0) printf(" new saturation = %f \n", volume_final/(Mask->Porosity()*double((Nx-2)*(Ny-2)*(Nz-2)*nprocs)));
|
||||
|
||||
// 6. copy back to the device
|
||||
//if (rank==0) printf("MorphInit: copy data back to device\n");
|
||||
|
||||
@@ -59,6 +59,30 @@ void ScaLBL_FreeLeeModel::getVelocity(DoubleArray &Vel_x, DoubleArray &Vel_y, Do
|
||||
ScaLBL_Comm->Barrier(); comm.barrier();
|
||||
}
|
||||
|
||||
void ScaLBL_FreeLeeModel::getData_RegularLayout(const double *data, DoubleArray ®data){
|
||||
// Gets data (in optimized layout) from the HOST and stores in regular layout
|
||||
// Primarly for debugging
|
||||
int i,j,k,idx;
|
||||
int n;
|
||||
|
||||
// initialize the array
|
||||
regdata.fill(0.f);
|
||||
|
||||
double value;
|
||||
for (k=0; k<Nz; k++){
|
||||
for (j=0; j<Ny; j++){
|
||||
for (i=0; i<Nx; i++){
|
||||
n=k*Nx*Ny+j*Nx+i;
|
||||
idx=Map(i,j,k);
|
||||
if (!(idx<0)){
|
||||
value=data[idx];
|
||||
regdata(i,j,k)=value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScaLBL_FreeLeeModel::ReadParams(string filename){
|
||||
// read the input database
|
||||
db = std::make_shared<Database>( filename );
|
||||
@@ -77,8 +101,10 @@ void ScaLBL_FreeLeeModel::ReadParams(string filename){
|
||||
Fx = Fy = Fz = 0.0;
|
||||
gamma=1e-3;//surface tension
|
||||
W=5.0;//interfacial thickness
|
||||
beta = 12.0*gamma/W;
|
||||
kappa = 3.0*gamma*W/2.0;//beta and kappa are related to surface tension \gamma
|
||||
//beta = 12.0*gamma/W;
|
||||
//kappa = 3.0*gamma*W/2.0;//beta and kappa are related to surface tension \gamma
|
||||
beta = 0.75*gamma/W;
|
||||
kappa = 0.375*gamma*W;//beta and kappa are related to surface tension \gamma
|
||||
Restart=false;
|
||||
din=dout=1.0;
|
||||
flux=0.0;
|
||||
@@ -136,8 +162,10 @@ void ScaLBL_FreeLeeModel::ReadParams(string filename){
|
||||
outletA=0.f;
|
||||
outletB=1.f;
|
||||
//update secondary parameters
|
||||
beta = 12.0*gamma/W;
|
||||
kappa = 3.0*gamma*W/2.0;//beta and kappa are related to surface tension \gamma
|
||||
//beta = 12.0*gamma/W;
|
||||
//kappa = 3.0*gamma*W/2.0;//beta and kappa are related to surface tension \gamma
|
||||
beta = 0.75*gamma/W;
|
||||
kappa = 0.375*gamma*W;//beta and kappa are related to surface tension \gamma
|
||||
//if (BoundaryCondition==4) flux *= rhoA; // mass flux must adjust for density (see formulation for details)
|
||||
|
||||
BoundaryCondition = 0;
|
||||
@@ -570,27 +598,28 @@ void ScaLBL_FreeLeeModel::AssignComponentLabels_ChemPotential_ColorGrad()
|
||||
|
||||
DoubleArray PhaseField(Nx,Ny,Nz);
|
||||
FILE *OUTFILE;
|
||||
ScaLBL_Comm->RegularLayout(Map,mu_phi_host,PhaseField);
|
||||
|
||||
getData_RegularLayout(mu_phi_host,PhaseField);
|
||||
sprintf(LocalRankFilename,"Chem_Init.%05i.raw",rank);
|
||||
OUTFILE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(PhaseField.data(),8,N,OUTFILE);
|
||||
fclose(OUTFILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&ColorGrad_host[0],PhaseField);
|
||||
getData_RegularLayout(&ColorGrad_host[0],PhaseField);
|
||||
FILE *CGX_FILE;
|
||||
sprintf(LocalRankFilename,"Gradient_X_Init.%05i.raw",rank);
|
||||
CGX_FILE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(PhaseField.data(),8,N,CGX_FILE);
|
||||
fclose(CGX_FILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&ColorGrad_host[Np],PhaseField);
|
||||
getData_RegularLayout(&ColorGrad_host[Np],PhaseField);
|
||||
FILE *CGY_FILE;
|
||||
sprintf(LocalRankFilename,"Gradient_Y_Init.%05i.raw",rank);
|
||||
CGY_FILE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(PhaseField.data(),8,N,CGY_FILE);
|
||||
fclose(CGY_FILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&ColorGrad_host[2*Np],PhaseField);
|
||||
getData_RegularLayout(&ColorGrad_host[2*Np],PhaseField);
|
||||
FILE *CGZ_FILE;
|
||||
sprintf(LocalRankFilename,"Gradient_Z_Init.%05i.raw",rank);
|
||||
CGZ_FILE = fopen(LocalRankFilename,"wb");
|
||||
@@ -795,27 +824,31 @@ double ScaLBL_FreeLeeModel::Run_TwoFluid(int returntime){
|
||||
// Compute the Phase indicator field
|
||||
// Read for hq happens in this routine (requires communication)
|
||||
ScaLBL_Comm->SendD3Q7AA(hq,0); //READ FROM NORMAL
|
||||
ScaLBL_D3Q7_AAodd_FreeLee_PhaseField(NeighborList, dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_D3Q7_AAodd_FreeLeeModel_PhaseField(NeighborList, dvcMap, hq, Den, Phi, rhoA, rhoB, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
//ScaLBL_D3Q7_AAodd_FreeLee_PhaseField(NeighborList, dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_Comm->RecvD3Q7AA(hq,0); //WRITE INTO OPPOSITE
|
||||
ScaLBL_Comm->Barrier();
|
||||
ScaLBL_D3Q7_AAodd_FreeLee_PhaseField(NeighborList, dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
ScaLBL_D3Q7_AAodd_FreeLeeModel_PhaseField(NeighborList, dvcMap, hq, Den, Phi, rhoA, rhoB, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
//ScaLBL_D3Q7_AAodd_FreeLee_PhaseField(NeighborList, dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
|
||||
// Perform the collision operation
|
||||
// Halo exchange for phase field
|
||||
ScaLBL_D3Q7_ComputePhaseField(dvcMap, hq, Den, Phi, rhoA, rhoB, 0, ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_Comm_WideHalo->Send(Phi);
|
||||
ScaLBL_Comm_WideHalo->Recv(Phi);
|
||||
//ScaLBL_D3Q7_ComputePhaseField(dvcMap, hq, Den, Phi, rhoA, rhoB, 0, ScaLBL_Comm->LastInterior(), Np);
|
||||
//ScaLBL_Comm_WideHalo->Send(Phi);
|
||||
//ScaLBL_Comm_WideHalo->Recv(Phi);
|
||||
ScaLBL_Comm->SendD3Q19AA(gqbar); //READ FROM NORMAL
|
||||
if (BoundaryCondition > 0 && BoundaryCondition < 5){
|
||||
//TODO to be revised
|
||||
// Need to add BC for hq!!!
|
||||
ScaLBL_Comm->Color_BC_z(dvcMap, Phi, Den, inletA, inletB);
|
||||
ScaLBL_Comm->Color_BC_Z(dvcMap, Phi, Den, outletA, outletB);
|
||||
}
|
||||
|
||||
ScaLBL_Comm->SendD3Q19AA(gqbar); //READ FROM NORMAL
|
||||
ScaLBL_D3Q19_AAodd_FreeLeeModel(NeighborList, dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
// Halo exchange for phase field
|
||||
ScaLBL_Comm_WideHalo->Send(Phi);
|
||||
//ScaLBL_D3Q19_AAodd_FreeLeeModel(NeighborList, dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
// kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_D3Q19_AAodd_FreeLeeModel_Combined(NeighborList, dvcMap, gqbar, hq, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB, tauM,
|
||||
kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
|
||||
ScaLBL_Comm_WideHalo->Recv(Phi);
|
||||
ScaLBL_Comm->RecvD3Q19AA(gqbar); //WRITE INTO OPPOSITE
|
||||
ScaLBL_Comm->Barrier();
|
||||
// Set BCs
|
||||
@@ -832,7 +865,9 @@ double ScaLBL_FreeLeeModel::Run_TwoFluid(int returntime){
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(gqbar);
|
||||
}
|
||||
|
||||
ScaLBL_D3Q19_AAodd_FreeLeeModel(NeighborList, dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
//ScaLBL_D3Q19_AAodd_FreeLeeModel(NeighborList, dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
// kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
ScaLBL_D3Q19_AAodd_FreeLeeModel_Combined(NeighborList, dvcMap, gqbar, hq, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB, tauM,
|
||||
kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
ScaLBL_Comm->Barrier();
|
||||
|
||||
@@ -841,24 +876,29 @@ double ScaLBL_FreeLeeModel::Run_TwoFluid(int returntime){
|
||||
timestep++;
|
||||
// Compute the Phase indicator field
|
||||
ScaLBL_Comm->SendD3Q7AA(hq,0); //READ FROM NORMA
|
||||
ScaLBL_D3Q7_AAeven_FreeLee_PhaseField(dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_D3Q7_AAeven_FreeLeeModel_PhaseField(dvcMap, hq, Den, Phi, rhoA, rhoB, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
//ScaLBL_D3Q7_AAeven_FreeLee_PhaseField(dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_Comm->RecvD3Q7AA(hq,0); //WRITE INTO OPPOSITE
|
||||
ScaLBL_Comm->Barrier();
|
||||
ScaLBL_D3Q7_AAeven_FreeLee_PhaseField(dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
ScaLBL_D3Q7_AAeven_FreeLeeModel_PhaseField(dvcMap, hq, Den, Phi, rhoA, rhoB, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
//ScaLBL_D3Q7_AAeven_FreeLee_PhaseField(dvcMap, hq, Den, Phi, ColorGrad, Velocity, rhoA, rhoB, tauM, W, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
|
||||
// Perform the collision operation
|
||||
// Halo exchange for phase field
|
||||
ScaLBL_D3Q7_ComputePhaseField(dvcMap, hq, Den, Phi, rhoA, rhoB, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_Comm_WideHalo->Send(Phi);
|
||||
ScaLBL_Comm_WideHalo->Recv(Phi);
|
||||
//ScaLBL_D3Q7_ComputePhaseField(dvcMap, hq, Den, Phi, rhoA, rhoB, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
//ScaLBL_Comm_WideHalo->Send(Phi);
|
||||
//ScaLBL_Comm_WideHalo->Recv(Phi);
|
||||
ScaLBL_Comm->SendD3Q19AA(gqbar); //READ FORM NORMAL
|
||||
if (BoundaryCondition > 0 && BoundaryCondition < 5){
|
||||
ScaLBL_Comm->Color_BC_z(dvcMap, Phi, Den, inletA, inletB);
|
||||
ScaLBL_Comm->Color_BC_Z(dvcMap, Phi, Den, outletA, outletB);
|
||||
}
|
||||
ScaLBL_Comm->SendD3Q19AA(gqbar); //READ FORM NORMAL
|
||||
|
||||
ScaLBL_D3Q19_AAeven_FreeLeeModel(dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
// Halo exchange for phase field
|
||||
ScaLBL_Comm_WideHalo->Send(Phi);
|
||||
//ScaLBL_D3Q19_AAeven_FreeLeeModel(dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
// kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_D3Q19_AAeven_FreeLeeModel_Combined(dvcMap, gqbar, hq, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB, tauM,
|
||||
kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_Comm_WideHalo->Recv(Phi);
|
||||
ScaLBL_Comm->RecvD3Q19AA(gqbar); //WRITE INTO OPPOSITE
|
||||
ScaLBL_Comm->Barrier();
|
||||
// Set boundary conditions
|
||||
@@ -874,7 +914,9 @@ double ScaLBL_FreeLeeModel::Run_TwoFluid(int returntime){
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_z(gqbar);
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(gqbar);
|
||||
}
|
||||
ScaLBL_D3Q19_AAeven_FreeLeeModel(dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
//ScaLBL_D3Q19_AAeven_FreeLeeModel(dvcMap, gqbar, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB,
|
||||
// kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
ScaLBL_D3Q19_AAeven_FreeLeeModel_Combined(dvcMap, gqbar, hq, Den, Phi, mu_phi, Velocity, Pressure, ColorGrad, rhoA, rhoB, tauA, tauB, tauM,
|
||||
kappa, beta, W, Fx, Fy, Fz, Nxh, Nxh*Nyh, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
ScaLBL_Comm->Barrier();
|
||||
//************************************************************************
|
||||
@@ -1055,6 +1097,13 @@ void ScaLBL_FreeLeeModel::WriteDebug_TwoFluid(){
|
||||
fwrite(PhaseField.data(),8,N,PFILE);
|
||||
fclose(PFILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,mu_phi,PhaseField);
|
||||
FILE *CHEMFILE;
|
||||
sprintf(LocalRankFilename,"ChemPotential.%05i.raw",rank);
|
||||
CHEMFILE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(PhaseField.data(),8,N,CHEMFILE);
|
||||
fclose(CHEMFILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&Velocity[0],PhaseField);
|
||||
FILE *VELX_FILE;
|
||||
sprintf(LocalRankFilename,"Velocity_X.%05i.raw",rank);
|
||||
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
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;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ void DeleteArray( const TYPE *p )
|
||||
|
||||
ScaLBL_GreyscaleColorModel::ScaLBL_GreyscaleColorModel(int RANK, int NP, const Utilities::MPI& COMM):
|
||||
rank(RANK), nprocs(NP), Restart(0),timestep(0),timestepMax(0),tauA(0),tauB(0),tauA_eff(0),tauB_eff(0),rhoA(0),rhoB(0),alpha(0),beta(0),
|
||||
Fx(0),Fy(0),Fz(0),flux(0),din(0),dout(0),inletA(0),inletB(0),outletA(0),outletB(0),GreyPorosity(0),
|
||||
Fx(0),Fy(0),Fz(0),flux(0),din(0),dout(0),inletA(0),inletB(0),outletA(0),outletB(0),GreyPorosity(0),RecoloringOff(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)
|
||||
{
|
||||
REVERSE_FLOW_DIRECTION = false;
|
||||
@@ -43,6 +43,8 @@ void ScaLBL_GreyscaleColorModel::ReadParams(string filename){
|
||||
Restart=false;
|
||||
din=dout=1.0;
|
||||
flux=0.0;
|
||||
RecoloringOff = false;
|
||||
//W=1.0;
|
||||
|
||||
// Color Model parameters
|
||||
if (greyscaleColor_db->keyExists( "timestepMax" )){
|
||||
@@ -85,6 +87,9 @@ void ScaLBL_GreyscaleColorModel::ReadParams(string filename){
|
||||
if (greyscaleColor_db->keyExists( "flux" )){
|
||||
flux = greyscaleColor_db->getScalar<double>( "flux" );
|
||||
}
|
||||
if (greyscaleColor_db->keyExists( "RecoloringOff" )){
|
||||
RecoloringOff = greyscaleColor_db->getScalar<bool>( "RecoloringOff" );
|
||||
}
|
||||
inletA=1.f;
|
||||
inletB=0.f;
|
||||
outletA=0.f;
|
||||
@@ -212,6 +217,7 @@ void ScaLBL_GreyscaleColorModel::ReadInput(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ScaLBL_GreyscaleColorModel::AssignComponentLabels()
|
||||
{
|
||||
// Initialize impermeability solid nodes and grey nodes
|
||||
@@ -256,6 +262,7 @@ void ScaLBL_GreyscaleColorModel::AssignComponentLabels()
|
||||
//printf("idx=%i, value=%i, %i, \n",idx, VALUE,LabelList[idx]);
|
||||
if (VALUE == LabelList[idx]){
|
||||
AFFINITY=AffinityList[idx];
|
||||
|
||||
label_count[idx] += 1.0;
|
||||
idx = NLABELS;
|
||||
//Mask->id[n] = 0; // set mask to zero since this is an immobile component
|
||||
@@ -290,19 +297,18 @@ void ScaLBL_GreyscaleColorModel::AssignComponentLabels()
|
||||
delete [] phase;
|
||||
}
|
||||
|
||||
void ScaLBL_GreyscaleColorModel::AssignGreySolidLabels()//Model-4
|
||||
void ScaLBL_GreyscaleColorModel::AssignGreySolidLabels()//apply capillary penalty wetting strength W
|
||||
{
|
||||
// ONLY initialize grey nodes
|
||||
// Key input parameters:
|
||||
// 1. GreySolidLabels
|
||||
// labels for grey nodes
|
||||
// 2. GreySolidAffinity
|
||||
// affinity ranges [-1,1]
|
||||
// oil-wet > 0
|
||||
// water-wet < 0
|
||||
// neutral = 0
|
||||
double *SolidPotential_host = new double [Nx*Ny*Nz];
|
||||
double *GreySolidGrad_host = new double [3*Np];
|
||||
// ranges [-1,1]
|
||||
// water-wet > 0
|
||||
// oil-wet < 0
|
||||
// neutral = 0 (i.e. no penalty)
|
||||
double *GreySolidW_host = new double [Np];
|
||||
|
||||
size_t NLABELS=0;
|
||||
signed char VALUE=0;
|
||||
@@ -324,117 +330,19 @@ void ScaLBL_GreyscaleColorModel::AssignGreySolidLabels()//Model-4
|
||||
AFFINITY=0.f;//all nodes except the specified grey nodes have grey-solid affinity = 0.0
|
||||
// Assign the affinity from the paired list
|
||||
for (unsigned int idx=0; idx < NLABELS; idx++){
|
||||
//printf("idx=%i, value=%i, %i, \n",idx, VALUE,LabelList[idx]);
|
||||
if (VALUE == LabelList[idx]){
|
||||
AFFINITY=AffinityList[idx];
|
||||
idx = NLABELS;
|
||||
//Mask->id[n] = 0; // set mask to zero since this is an immobile component
|
||||
}
|
||||
}
|
||||
SolidPotential_host[n] = AFFINITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate grey-solid color-gradient
|
||||
double *Dst;
|
||||
Dst = new double [3*3*3];
|
||||
for (int kk=0; kk<3; kk++){
|
||||
for (int jj=0; jj<3; jj++){
|
||||
for (int ii=0; ii<3; ii++){
|
||||
int index = kk*9+jj*3+ii;
|
||||
Dst[index] = sqrt(double(ii-1)*double(ii-1) + double(jj-1)*double(jj-1)+ double(kk-1)*double(kk-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
double w_face = 1.f;
|
||||
double w_edge = 0.5;
|
||||
double w_corner = 0.f;
|
||||
//local
|
||||
Dst[13] = 0.f;
|
||||
//faces
|
||||
Dst[4] = w_face;
|
||||
Dst[10] = w_face;
|
||||
Dst[12] = w_face;
|
||||
Dst[14] = w_face;
|
||||
Dst[16] = w_face;
|
||||
Dst[22] = w_face;
|
||||
// corners
|
||||
Dst[0] = w_corner;
|
||||
Dst[2] = w_corner;
|
||||
Dst[6] = w_corner;
|
||||
Dst[8] = w_corner;
|
||||
Dst[18] = w_corner;
|
||||
Dst[20] = w_corner;
|
||||
Dst[24] = w_corner;
|
||||
Dst[26] = w_corner;
|
||||
// edges
|
||||
Dst[1] = w_edge;
|
||||
Dst[3] = w_edge;
|
||||
Dst[5] = w_edge;
|
||||
Dst[7] = w_edge;
|
||||
Dst[9] = w_edge;
|
||||
Dst[11] = w_edge;
|
||||
Dst[15] = w_edge;
|
||||
Dst[17] = w_edge;
|
||||
Dst[19] = w_edge;
|
||||
Dst[21] = w_edge;
|
||||
Dst[23] = w_edge;
|
||||
Dst[25] = w_edge;
|
||||
|
||||
for (int k=1; k<Nz-1; k++){
|
||||
for (int j=1; j<Ny-1; j++){
|
||||
for (int i=1; i<Nx-1; i++){
|
||||
int idx=Map(i,j,k);
|
||||
int idx = Map(i,j,k);
|
||||
if (!(idx < 0)){
|
||||
double phi_x = 0.f;
|
||||
double phi_y = 0.f;
|
||||
double phi_z = 0.f;
|
||||
for (int kk=0; kk<3; kk++){
|
||||
for (int jj=0; jj<3; jj++){
|
||||
for (int ii=0; ii<3; ii++){
|
||||
|
||||
int index = kk*9+jj*3+ii;
|
||||
double weight= Dst[index];
|
||||
|
||||
int idi=i+ii-1;
|
||||
int idj=j+jj-1;
|
||||
int idk=k+kk-1;
|
||||
|
||||
if (idi < 0) idi=0;
|
||||
if (idj < 0) idj=0;
|
||||
if (idk < 0) idk=0;
|
||||
if (!(idi < Nx)) idi=Nx-1;
|
||||
if (!(idj < Ny)) idj=Ny-1;
|
||||
if (!(idk < Nz)) idk=Nz-1;
|
||||
|
||||
int nn = idk*Nx*Ny + idj*Nx + idi;
|
||||
double vec_x = double(ii-1);
|
||||
double vec_y = double(jj-1);
|
||||
double vec_z = double(kk-1);
|
||||
double GWNS=SolidPotential_host[nn];
|
||||
phi_x += GWNS*weight*vec_x;
|
||||
phi_y += GWNS*weight*vec_y;
|
||||
phi_z += GWNS*weight*vec_z;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Averages->SDs(i,j,k)<2.0){
|
||||
GreySolidGrad_host[idx+0*Np] = phi_x;
|
||||
GreySolidGrad_host[idx+1*Np] = phi_y;
|
||||
GreySolidGrad_host[idx+2*Np] = phi_z;
|
||||
}
|
||||
else{
|
||||
GreySolidGrad_host[idx+0*Np] = 0.0;
|
||||
GreySolidGrad_host[idx+1*Np] = 0.0;
|
||||
GreySolidGrad_host[idx+2*Np] = 0.0;
|
||||
}
|
||||
}
|
||||
GreySolidW_host[idx] = AFFINITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rank==0){
|
||||
printf("Number of Grey-solid labels: %lu \n",NLABELS);
|
||||
for (unsigned int idx=0; idx<NLABELS; idx++){
|
||||
@@ -442,14 +350,13 @@ void ScaLBL_GreyscaleColorModel::AssignGreySolidLabels()//Model-4
|
||||
AFFINITY=AffinityList[idx];
|
||||
printf(" grey-solid label=%d, grey-solid affinity=%f\n",VALUE,AFFINITY);
|
||||
}
|
||||
printf("NOTE: grey-solid affinity>0: water-wet || grey-solid affinity<0: oil-wet \n");
|
||||
}
|
||||
|
||||
|
||||
ScaLBL_CopyToDevice(GreySolidGrad, GreySolidGrad_host, 3*Np*sizeof(double));
|
||||
ScaLBL_CopyToDevice(GreySolidW, GreySolidW_host, Np*sizeof(double));
|
||||
ScaLBL_Comm->Barrier();
|
||||
delete [] SolidPotential_host;
|
||||
delete [] GreySolidGrad_host;
|
||||
delete [] Dst;
|
||||
delete [] GreySolidW_host;
|
||||
}
|
||||
////----------------------------------------------------------------------------------------------------------//
|
||||
|
||||
@@ -575,6 +482,71 @@ void ScaLBL_GreyscaleColorModel::AssignGreyPoroPermLabels()
|
||||
delete [] Permeability;
|
||||
}
|
||||
|
||||
//void ScaLBL_GreyscaleColorModel::AssignGreyscalePotential()
|
||||
//{
|
||||
// double *psi;//greyscale potential
|
||||
// psi = new double[N];
|
||||
//
|
||||
// size_t NLABELS=0;
|
||||
// signed char VALUE=0;
|
||||
// double AFFINITY=0.f;
|
||||
//
|
||||
// auto LabelList = greyscaleColor_db->getVector<int>( "ComponentLabels" );
|
||||
// auto AffinityList = greyscaleColor_db->getVector<double>( "ComponentAffinity" );
|
||||
// NLABELS=LabelList.size();
|
||||
//
|
||||
// //first, copy over normal phase field
|
||||
// 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;
|
||||
// VALUE=id[n];
|
||||
// // Assign the affinity from the paired list
|
||||
// for (unsigned int idx=0; idx < NLABELS; idx++){
|
||||
// //printf("idx=%i, value=%i, %i, \n",idx, VALUE,LabelList[idx]);
|
||||
// if (VALUE == LabelList[idx]){
|
||||
// AFFINITY=AffinityList[idx];
|
||||
// idx = NLABELS;
|
||||
// }
|
||||
// }
|
||||
// // fluid labels are reserved
|
||||
// if (VALUE == 1) AFFINITY=1.0;
|
||||
// else if (VALUE == 2) AFFINITY=-1.0;
|
||||
// psi[n] = AFFINITY;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //second, scale the phase field for grey nodes
|
||||
// double Cap_Penalty=1.f;
|
||||
// auto GreyLabelList = greyscaleColor_db->getVector<int>( "GreySolidLabels" );
|
||||
// auto PermeabilityList = greyscaleColor_db->getVector<double>( "PermeabilityList" );
|
||||
// NLABELS=GreyLabelList.size();
|
||||
//
|
||||
// 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;
|
||||
// VALUE=id[n];
|
||||
// Cap_Penalty=1.f;
|
||||
// // Assign the affinity from the paired list
|
||||
// for (unsigned int idx=0; idx < NLABELS; idx++){
|
||||
// if (VALUE == GreyLabelList[idx]){
|
||||
// Cap_Penalty=alpha*W/sqrt(PermeabilityList[idx]/Dm->voxel_length/Dm->voxel_length);
|
||||
// idx = NLABELS;
|
||||
// }
|
||||
// }
|
||||
// //update greyscale potential
|
||||
// psi[n] = psi[n]*Cap_Penalty;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ScaLBL_CopyToDevice(Psi, psi, N*sizeof(double));
|
||||
// ScaLBL_Comm->Barrier();
|
||||
// delete [] psi;
|
||||
//}
|
||||
|
||||
void ScaLBL_GreyscaleColorModel::Create(){
|
||||
/*
|
||||
* This function creates the variables needed to run a LBM
|
||||
@@ -619,11 +591,13 @@ void ScaLBL_GreyscaleColorModel::Create(){
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Bq, 7*dist_mem_size);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Den, 2*dist_mem_size);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Phi, sizeof(double)*Nx*Ny*Nz);
|
||||
//ScaLBL_AllocateDeviceMemory((void **) &Psi, sizeof(double)*Nx*Ny*Nz);//greyscale potential
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Pressure, sizeof(double)*Np);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Velocity, 3*sizeof(double)*Np);
|
||||
//ScaLBL_AllocateDeviceMemory((void **) &ColorGrad, 3*sizeof(double)*Np);
|
||||
//ScaLBL_AllocateDeviceMemory((void **) &GreySolidPhi, sizeof(double)*Nx*Ny*Nz);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &GreySolidGrad, 3*sizeof(double)*Np);
|
||||
//ScaLBL_AllocateDeviceMemory((void **) &GreySolidGrad, 3*sizeof(double)*Np);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &GreySolidW, sizeof(double)*Np);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Porosity_dvc, sizeof(double)*Np);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &Permeability_dvc, sizeof(double)*Np);
|
||||
//...........................................................................
|
||||
@@ -667,6 +641,7 @@ void ScaLBL_GreyscaleColorModel::Create(){
|
||||
AssignComponentLabels();//do open/black/grey nodes initialization
|
||||
AssignGreySolidLabels();
|
||||
AssignGreyPoroPermLabels();
|
||||
//AssignGreyscalePotential();
|
||||
Averages->SetParams(rhoA,rhoB,tauA,tauB,Fx,Fy,Fz,alpha,beta,GreyPorosity);
|
||||
ScaLBL_Comm->RegularLayout(Map,Porosity_dvc,Averages->Porosity);//porosity doesn't change over time
|
||||
}
|
||||
@@ -931,9 +906,11 @@ void ScaLBL_GreyscaleColorModel::Run(){
|
||||
// Read for Aq, Bq happens in this routine (requires communication)
|
||||
ScaLBL_Comm->BiSendD3Q7AA(Aq,Bq); //READ FROM NORMAL
|
||||
ScaLBL_D3Q7_AAodd_PhaseField(NeighborList, dvcMap, Aq, Bq, Den, Phi, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
//ScaLBL_Update_GreyscalePotential(dvcMap,Phi,Psi,Porosity_dvc,Permeability_dvc,alpha,W,ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_Comm->BiRecvD3Q7AA(Aq,Bq); //WRITE INTO OPPOSITE
|
||||
ScaLBL_Comm->Barrier();
|
||||
ScaLBL_D3Q7_AAodd_PhaseField(NeighborList, dvcMap, Aq, Bq, Den, Phi, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
//ScaLBL_Update_GreyscalePotential(dvcMap,Phi,Psi,Porosity_dvc,Permeability_dvc,alpha,W,0,ScaLBL_Comm->LastExterior(), Np);
|
||||
|
||||
// Perform the collision operation
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FROM NORMAL
|
||||
@@ -943,10 +920,14 @@ void ScaLBL_GreyscaleColorModel::Run(){
|
||||
}
|
||||
// Halo exchange for phase field
|
||||
ScaLBL_Comm_Regular->SendHalo(Phi);
|
||||
//Model-1&4
|
||||
ScaLBL_D3Q19_AAodd_GreyscaleColor(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
//Model-1&4 with capillary pressure penalty for grey nodes
|
||||
ScaLBL_D3Q19_AAodd_GreyscaleColor_CP(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi, GreySolidW,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
alpha, beta, Fx, Fy, Fz, RecoloringOff, Nx, Nx*Ny, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
//Model-1&4
|
||||
//ScaLBL_D3Q19_AAodd_GreyscaleColor(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
// alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
////Model-2&3
|
||||
//ScaLBL_D3Q19_AAodd_GreyscaleColor(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi,GreySolidPhi,Porosity_dvc,Permeability_dvc,Velocity,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
@@ -968,10 +949,14 @@ void ScaLBL_GreyscaleColorModel::Run(){
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(fq);
|
||||
}
|
||||
|
||||
//Model-1&4
|
||||
ScaLBL_D3Q19_AAodd_GreyscaleColor(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
//Model-1&4 with capillary pressure penalty for grey nodes
|
||||
ScaLBL_D3Q19_AAodd_GreyscaleColor_CP(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi, GreySolidW,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
alpha, beta, Fx, Fy, Fz, RecoloringOff, Nx, Nx*Ny, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
//Model-1&4
|
||||
//ScaLBL_D3Q19_AAodd_GreyscaleColor(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
// alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
////Model-2&3
|
||||
//ScaLBL_D3Q19_AAodd_GreyscaleColor(NeighborList, dvcMap, fq, Aq, Bq, Den, Phi,GreySolidPhi,Porosity_dvc,Permeability_dvc,Velocity,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
@@ -983,9 +968,11 @@ void ScaLBL_GreyscaleColorModel::Run(){
|
||||
// Compute the Phase indicator field
|
||||
ScaLBL_Comm->BiSendD3Q7AA(Aq,Bq); //READ FROM NORMAL
|
||||
ScaLBL_D3Q7_AAeven_PhaseField(dvcMap, Aq, Bq, Den, Phi, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
//ScaLBL_Update_GreyscalePotential(dvcMap,Phi,Psi,Porosity_dvc,Permeability_dvc,alpha,W,ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
ScaLBL_Comm->BiRecvD3Q7AA(Aq,Bq); //WRITE INTO OPPOSITE
|
||||
ScaLBL_Comm->Barrier();
|
||||
ScaLBL_D3Q7_AAeven_PhaseField(dvcMap, Aq, Bq, Den, Phi, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
//ScaLBL_Update_GreyscalePotential(dvcMap,Phi,Psi,Porosity_dvc,Permeability_dvc,alpha,W,0,ScaLBL_Comm->LastExterior(), Np);
|
||||
|
||||
// Perform the collision operation
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FORM NORMAL
|
||||
@@ -995,10 +982,14 @@ void ScaLBL_GreyscaleColorModel::Run(){
|
||||
ScaLBL_Comm->Color_BC_Z(dvcMap, Phi, Den, outletA, outletB);
|
||||
}
|
||||
ScaLBL_Comm_Regular->SendHalo(Phi);
|
||||
//Model-1&4
|
||||
ScaLBL_D3Q19_AAeven_GreyscaleColor(dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
//Model-1&4 with capillary pressure penalty for grey nodes
|
||||
ScaLBL_D3Q19_AAeven_GreyscaleColor_CP(dvcMap, fq, Aq, Bq, Den, Phi, GreySolidW,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
alpha, beta, Fx, Fy, Fz, RecoloringOff, Nx, Nx*Ny, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
//Model-1&4
|
||||
//ScaLBL_D3Q19_AAeven_GreyscaleColor(dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
// alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior(), Np);
|
||||
////Model-2&3
|
||||
//ScaLBL_D3Q19_AAeven_GreyscaleColor(dvcMap, fq, Aq, Bq, Den, Phi,GreySolidPhi,Porosity_dvc,Permeability_dvc,Velocity,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
@@ -1020,10 +1011,14 @@ void ScaLBL_GreyscaleColorModel::Run(){
|
||||
ScaLBL_Comm->D3Q19_Reflection_BC_Z(fq);
|
||||
}
|
||||
|
||||
//Model-1&4
|
||||
ScaLBL_D3Q19_AAeven_GreyscaleColor(dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
//Model-1&4 with capillary pressure penalty for grey nodes
|
||||
ScaLBL_D3Q19_AAeven_GreyscaleColor_CP(dvcMap, fq, Aq, Bq, Den, Phi, GreySolidW,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
alpha, beta, Fx, Fy, Fz, RecoloringOff, Nx, Nx*Ny, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
//Model-1&4
|
||||
//ScaLBL_D3Q19_AAeven_GreyscaleColor(dvcMap, fq, Aq, Bq, Den, Phi,GreySolidGrad,Porosity_dvc,Permeability_dvc,Velocity,Pressure,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
// alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, 0, ScaLBL_Comm->LastExterior(), Np);
|
||||
////Model-2&3
|
||||
//ScaLBL_D3Q19_AAeven_GreyscaleColor(dvcMap, fq, Aq, Bq, Den, Phi,GreySolidPhi,Porosity_dvc,Permeability_dvc,Velocity,
|
||||
// rhoA, rhoB, tauA, tauB,tauA_eff, tauB_eff,
|
||||
@@ -1575,6 +1570,13 @@ void ScaLBL_GreyscaleColorModel::WriteDebug(){
|
||||
fwrite(PhaseField.data(),8,N,OUTFILE);
|
||||
fclose(OUTFILE);
|
||||
|
||||
//ScaLBL_CopyToHost(PhaseField.data(), Psi, sizeof(double)*N);
|
||||
//FILE *PSIFILE;
|
||||
//sprintf(LocalRankFilename,"Psi.%05i.raw",rank);
|
||||
//PSIFILE = fopen(LocalRankFilename,"wb");
|
||||
//fwrite(PhaseField.data(),8,N,PSIFILE);
|
||||
//fclose(PSIFILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&Den[0],PhaseField);
|
||||
FILE *AFILE;
|
||||
sprintf(LocalRankFilename,"A.%05i.raw",rank);
|
||||
@@ -1631,26 +1633,26 @@ void ScaLBL_GreyscaleColorModel::WriteDebug(){
|
||||
fwrite(PhaseField.data(),8,N,PERM_FILE);
|
||||
fclose(PERM_FILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&GreySolidGrad[0],PhaseField);
|
||||
FILE *GreySG_X_FILE;
|
||||
sprintf(LocalRankFilename,"GreySolidGrad_X.%05i.raw",rank);
|
||||
GreySG_X_FILE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(PhaseField.data(),8,N,GreySG_X_FILE);
|
||||
fclose(GreySG_X_FILE);
|
||||
//ScaLBL_Comm->RegularLayout(Map,&GreySolidGrad[0],PhaseField);
|
||||
//FILE *GreySG_X_FILE;
|
||||
//sprintf(LocalRankFilename,"GreySolidGrad_X.%05i.raw",rank);
|
||||
//GreySG_X_FILE = fopen(LocalRankFilename,"wb");
|
||||
//fwrite(PhaseField.data(),8,N,GreySG_X_FILE);
|
||||
//fclose(GreySG_X_FILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&GreySolidGrad[Np],PhaseField);
|
||||
FILE *GreySG_Y_FILE;
|
||||
sprintf(LocalRankFilename,"GreySolidGrad_Y.%05i.raw",rank);
|
||||
GreySG_Y_FILE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(PhaseField.data(),8,N,GreySG_Y_FILE);
|
||||
fclose(GreySG_Y_FILE);
|
||||
//ScaLBL_Comm->RegularLayout(Map,&GreySolidGrad[Np],PhaseField);
|
||||
//FILE *GreySG_Y_FILE;
|
||||
//sprintf(LocalRankFilename,"GreySolidGrad_Y.%05i.raw",rank);
|
||||
//GreySG_Y_FILE = fopen(LocalRankFilename,"wb");
|
||||
//fwrite(PhaseField.data(),8,N,GreySG_Y_FILE);
|
||||
//fclose(GreySG_Y_FILE);
|
||||
|
||||
ScaLBL_Comm->RegularLayout(Map,&GreySolidGrad[2*Np],PhaseField);
|
||||
FILE *GreySG_Z_FILE;
|
||||
sprintf(LocalRankFilename,"GreySolidGrad_Z.%05i.raw",rank);
|
||||
GreySG_Z_FILE = fopen(LocalRankFilename,"wb");
|
||||
fwrite(PhaseField.data(),8,N,GreySG_Z_FILE);
|
||||
fclose(GreySG_Z_FILE);
|
||||
//ScaLBL_Comm->RegularLayout(Map,&GreySolidGrad[2*Np],PhaseField);
|
||||
//FILE *GreySG_Z_FILE;
|
||||
//sprintf(LocalRankFilename,"GreySolidGrad_Z.%05i.raw",rank);
|
||||
//GreySG_Z_FILE = fopen(LocalRankFilename,"wb");
|
||||
//fwrite(PhaseField.data(),8,N,GreySG_Z_FILE);
|
||||
//fclose(GreySG_Z_FILE);
|
||||
|
||||
/* ScaLBL_Comm->RegularLayout(Map,&ColorGrad[0],PhaseField);
|
||||
FILE *CGX_FILE;
|
||||
@@ -1984,6 +1986,169 @@ void ScaLBL_GreyscaleColorModel::WriteDebug(){
|
||||
// delete [] Dst;
|
||||
//}
|
||||
|
||||
//void ScaLBL_GreyscaleColorModel::AssignGreySolidLabels()//Model-4
|
||||
//{
|
||||
// // ONLY initialize grey nodes
|
||||
// // Key input parameters:
|
||||
// // 1. GreySolidLabels
|
||||
// // labels for grey nodes
|
||||
// // 2. GreySolidAffinity
|
||||
// // affinity ranges [-1,1]
|
||||
// // oil-wet > 0
|
||||
// // water-wet < 0
|
||||
// // neutral = 0
|
||||
// double *SolidPotential_host = new double [Nx*Ny*Nz];
|
||||
// double *GreySolidGrad_host = new double [3*Np];
|
||||
//
|
||||
// size_t NLABELS=0;
|
||||
// signed char VALUE=0;
|
||||
// double AFFINITY=0.f;
|
||||
//
|
||||
// auto LabelList = greyscaleColor_db->getVector<int>( "GreySolidLabels" );
|
||||
// auto AffinityList = greyscaleColor_db->getVector<double>( "GreySolidAffinity" );
|
||||
//
|
||||
// NLABELS=LabelList.size();
|
||||
// if (NLABELS != AffinityList.size()){
|
||||
// ERROR("Error: GreySolidLabels and GreySolidAffinity must be the same length! \n");
|
||||
// }
|
||||
//
|
||||
// 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;
|
||||
// VALUE=id[n];
|
||||
// AFFINITY=0.f;//all nodes except the specified grey nodes have grey-solid affinity = 0.0
|
||||
// // Assign the affinity from the paired list
|
||||
// for (unsigned int idx=0; idx < NLABELS; idx++){
|
||||
// //printf("idx=%i, value=%i, %i, \n",idx, VALUE,LabelList[idx]);
|
||||
// if (VALUE == LabelList[idx]){
|
||||
// AFFINITY=AffinityList[idx];
|
||||
// idx = NLABELS;
|
||||
// //Mask->id[n] = 0; // set mask to zero since this is an immobile component
|
||||
// }
|
||||
// }
|
||||
// SolidPotential_host[n] = AFFINITY;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Calculate grey-solid color-gradient
|
||||
// double *Dst;
|
||||
// Dst = new double [3*3*3];
|
||||
// for (int kk=0; kk<3; kk++){
|
||||
// for (int jj=0; jj<3; jj++){
|
||||
// for (int ii=0; ii<3; ii++){
|
||||
// int index = kk*9+jj*3+ii;
|
||||
// Dst[index] = sqrt(double(ii-1)*double(ii-1) + double(jj-1)*double(jj-1)+ double(kk-1)*double(kk-1));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// double w_face = 1.f;
|
||||
// double w_edge = 0.5;
|
||||
// double w_corner = 0.f;
|
||||
// //local
|
||||
// Dst[13] = 0.f;
|
||||
// //faces
|
||||
// Dst[4] = w_face;
|
||||
// Dst[10] = w_face;
|
||||
// Dst[12] = w_face;
|
||||
// Dst[14] = w_face;
|
||||
// Dst[16] = w_face;
|
||||
// Dst[22] = w_face;
|
||||
// // corners
|
||||
// Dst[0] = w_corner;
|
||||
// Dst[2] = w_corner;
|
||||
// Dst[6] = w_corner;
|
||||
// Dst[8] = w_corner;
|
||||
// Dst[18] = w_corner;
|
||||
// Dst[20] = w_corner;
|
||||
// Dst[24] = w_corner;
|
||||
// Dst[26] = w_corner;
|
||||
// // edges
|
||||
// Dst[1] = w_edge;
|
||||
// Dst[3] = w_edge;
|
||||
// Dst[5] = w_edge;
|
||||
// Dst[7] = w_edge;
|
||||
// Dst[9] = w_edge;
|
||||
// Dst[11] = w_edge;
|
||||
// Dst[15] = w_edge;
|
||||
// Dst[17] = w_edge;
|
||||
// Dst[19] = w_edge;
|
||||
// Dst[21] = w_edge;
|
||||
// Dst[23] = w_edge;
|
||||
// Dst[25] = w_edge;
|
||||
//
|
||||
// for (int k=1; k<Nz-1; k++){
|
||||
// for (int j=1; j<Ny-1; j++){
|
||||
// for (int i=1; i<Nx-1; i++){
|
||||
// int idx=Map(i,j,k);
|
||||
// if (!(idx < 0)){
|
||||
// double phi_x = 0.f;
|
||||
// double phi_y = 0.f;
|
||||
// double phi_z = 0.f;
|
||||
// for (int kk=0; kk<3; kk++){
|
||||
// for (int jj=0; jj<3; jj++){
|
||||
// for (int ii=0; ii<3; ii++){
|
||||
//
|
||||
// int index = kk*9+jj*3+ii;
|
||||
// double weight= Dst[index];
|
||||
//
|
||||
// int idi=i+ii-1;
|
||||
// int idj=j+jj-1;
|
||||
// int idk=k+kk-1;
|
||||
//
|
||||
// if (idi < 0) idi=0;
|
||||
// if (idj < 0) idj=0;
|
||||
// if (idk < 0) idk=0;
|
||||
// if (!(idi < Nx)) idi=Nx-1;
|
||||
// if (!(idj < Ny)) idj=Ny-1;
|
||||
// if (!(idk < Nz)) idk=Nz-1;
|
||||
//
|
||||
// int nn = idk*Nx*Ny + idj*Nx + idi;
|
||||
// double vec_x = double(ii-1);
|
||||
// double vec_y = double(jj-1);
|
||||
// double vec_z = double(kk-1);
|
||||
// double GWNS=SolidPotential_host[nn];
|
||||
// phi_x += GWNS*weight*vec_x;
|
||||
// phi_y += GWNS*weight*vec_y;
|
||||
// phi_z += GWNS*weight*vec_z;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (Averages->SDs(i,j,k)<2.0){
|
||||
// GreySolidGrad_host[idx+0*Np] = phi_x;
|
||||
// GreySolidGrad_host[idx+1*Np] = phi_y;
|
||||
// GreySolidGrad_host[idx+2*Np] = phi_z;
|
||||
// }
|
||||
// else{
|
||||
// GreySolidGrad_host[idx+0*Np] = 0.0;
|
||||
// GreySolidGrad_host[idx+1*Np] = 0.0;
|
||||
// GreySolidGrad_host[idx+2*Np] = 0.0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (rank==0){
|
||||
// printf("Number of Grey-solid labels: %lu \n",NLABELS);
|
||||
// for (unsigned int idx=0; idx<NLABELS; idx++){
|
||||
// VALUE=LabelList[idx];
|
||||
// AFFINITY=AffinityList[idx];
|
||||
// printf(" grey-solid label=%d, grey-solid affinity=%f\n",VALUE,AFFINITY);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// ScaLBL_CopyToDevice(GreySolidGrad, GreySolidGrad_host, 3*Np*sizeof(double));
|
||||
// ScaLBL_Comm->Barrier();
|
||||
// delete [] SolidPotential_host;
|
||||
// delete [] GreySolidGrad_host;
|
||||
// delete [] Dst;
|
||||
//}
|
||||
|
||||
|
||||
//--------- This is another old version of calculating greyscale-solid color-gradient modification-------//
|
||||
// **not working effectively, to be deprecated
|
||||
//void ScaLBL_GreyscaleColorModel::AssignGreySolidLabels()
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
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;
|
||||
@@ -48,7 +50,7 @@ public:
|
||||
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;
|
||||
std::shared_ptr<GreyPhaseAnalysis> Averages;
|
||||
|
||||
// input database
|
||||
std::shared_ptr<Database> db;
|
||||
@@ -64,12 +66,14 @@ public:
|
||||
double *fq, *Aq, *Bq;
|
||||
double *Den, *Phi;
|
||||
//double *GreySolidPhi; //Model 2 & 3
|
||||
double *GreySolidGrad;//Model 1 & 4
|
||||
//double *GreySolidGrad;//Model 1 & 4
|
||||
double *GreySolidW;
|
||||
//double *ColorGrad;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
double *Porosity_dvc;
|
||||
double *Permeability_dvc;
|
||||
//double *Psi;
|
||||
|
||||
private:
|
||||
Utilities::MPI comm;
|
||||
@@ -86,6 +90,7 @@ private:
|
||||
void AssignComponentLabels();
|
||||
void AssignGreySolidLabels();
|
||||
void AssignGreyPoroPermLabels();
|
||||
//void AssignGreyscalePotential();
|
||||
void ImageInit(std::string filename);
|
||||
double MorphInit(const double beta, const double morph_delta);
|
||||
double SeedPhaseField(const double seed_water_in_oil);
|
||||
|
||||
@@ -831,8 +831,8 @@ void ScaLBL_IonModel::Run(double *Velocity, double *ElectricField){
|
||||
if (BoundaryConditionSolid==1){
|
||||
//TODO IonSolid may also be species-dependent
|
||||
ScaLBL_Comm->SolidDirichletD3Q7(&fq[ic*Np*7], IonSolid);
|
||||
ScaLBL_Comm->Barrier(); comm.barrier();
|
||||
}
|
||||
ScaLBL_Comm->Barrier(); comm.barrier();
|
||||
|
||||
// *************EVEN TIMESTEP*************//
|
||||
timestep++;
|
||||
@@ -875,8 +875,8 @@ void ScaLBL_IonModel::Run(double *Velocity, double *ElectricField){
|
||||
if (BoundaryConditionSolid==1){
|
||||
//TODO IonSolid may also be species-dependent
|
||||
ScaLBL_Comm->SolidDirichletD3Q7(&fq[ic*Np*7], IonSolid);
|
||||
ScaLBL_Comm->Barrier(); comm.barrier();
|
||||
}
|
||||
ScaLBL_Comm->Barrier(); comm.barrier();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,6 @@ void ScaLBL_Poisson::ReadParams(string filename){
|
||||
h = domain_db->getScalar<double>( "voxel_length" );
|
||||
}
|
||||
|
||||
|
||||
//Re-calcualte model parameters if user updates input
|
||||
epsilon0_LB = epsilon0*(h*1.0e-6);//unit:[C/(V*lu)]
|
||||
epsilon_LB = epsilon0_LB*epsilonR;//electric permittivity
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
ScaLBL_StokesModel::ScaLBL_StokesModel(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),h(0),nu_phys(0),rho_phys(0),rho0(0),den_scale(0),time_conv(0),tolerance(0),
|
||||
epsilon0(0),epsilon0_LB(0),epsilonR(0),epsilon_LB(0),UseSlippingVelBC(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)
|
||||
{
|
||||
|
||||
@@ -38,6 +39,12 @@ void ScaLBL_StokesModel::ReadParams(string filename,int num_iter){
|
||||
tolerance = 1.0e-8;
|
||||
Fx = Fy = 0.0;
|
||||
Fz = 1.0e-5;
|
||||
//Stokes solver also needs the following parameters for slipping velocity BC
|
||||
epsilon0 = 8.85e-12;//electric permittivity of vaccum; unit:[C/(V*m)]
|
||||
epsilon0_LB = epsilon0*(h*1.0e-6);//unit:[C/(V*lu)]
|
||||
epsilonR = 78.4;//default dielectric constant of water
|
||||
epsilon_LB = epsilon0_LB*epsilonR;//electric permittivity
|
||||
UseSlippingVelBC = false;
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
// Read domain parameters
|
||||
@@ -85,12 +92,19 @@ void ScaLBL_StokesModel::ReadParams(string filename,int num_iter){
|
||||
if (stokes_db->keyExists( "flux" )){
|
||||
flux = stokes_db->getScalar<double>( "flux" );
|
||||
}
|
||||
if (stokes_db->keyExists( "UseElectroosmoticVelocityBC" )){
|
||||
UseSlippingVelBC = stokes_db->getScalar<bool>( "UseElectroosmoticVelocityBC" );
|
||||
}
|
||||
if (stokes_db->keyExists( "epsilonR" )){
|
||||
epsilonR = stokes_db->getScalar<double>( "epsilonR" );
|
||||
}
|
||||
|
||||
// Re-calculate model parameters due to parameter read
|
||||
mu=(tau-0.5)/3.0;
|
||||
time_conv = (h*h*1.0e-12)*mu/nu_phys;//time conversion factor from physical to LB unit; [sec/lt]
|
||||
den_scale = rho_phys/rho0*(h*h*h*1.0e-18);//scale factor for density
|
||||
|
||||
epsilon0_LB = epsilon0*(h*1.0e-6);//unit:[C/(V*lu)]
|
||||
epsilon_LB = epsilon0_LB*epsilonR;//electric permittivity
|
||||
}
|
||||
|
||||
void ScaLBL_StokesModel::ReadParams(string filename){
|
||||
@@ -100,7 +114,6 @@ void ScaLBL_StokesModel::ReadParams(string filename){
|
||||
db = std::make_shared<Database>( filename );
|
||||
domain_db = db->getDatabase( "Domain" );
|
||||
stokes_db = db->getDatabase( "Stokes" );
|
||||
|
||||
|
||||
//---------------------- Default model parameters --------------------------//
|
||||
rho_phys = 1000.0; //by default use water density; unit [kg/m^3]
|
||||
@@ -114,6 +127,12 @@ void ScaLBL_StokesModel::ReadParams(string filename){
|
||||
tolerance = 1.0e-8;
|
||||
Fx = Fy = 0.0;
|
||||
Fz = 1.0e-5;
|
||||
//Stokes solver also needs the following parameters for slipping velocity BC
|
||||
epsilon0 = 8.85e-12;//electric permittivity of vaccum; unit:[C/(V*m)]
|
||||
epsilon0_LB = epsilon0*(h*1.0e-6);//unit:[C/(V*lu)]
|
||||
epsilonR = 78.4;//default dielectric constant of water
|
||||
epsilon_LB = epsilon0_LB*epsilonR;//electric permittivity
|
||||
UseSlippingVelBC = false;
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
// Read domain parameters
|
||||
@@ -161,12 +180,19 @@ void ScaLBL_StokesModel::ReadParams(string filename){
|
||||
if (stokes_db->keyExists( "flux" )){
|
||||
flux = stokes_db->getScalar<double>( "flux" );
|
||||
}
|
||||
if (stokes_db->keyExists( "UseElectroosmoticVelocityBC" )){
|
||||
UseSlippingVelBC = stokes_db->getScalar<bool>( "UseElectroosmoticVelocityBC" );
|
||||
}
|
||||
if (stokes_db->keyExists( "epsilonR" )){
|
||||
epsilonR = stokes_db->getScalar<double>( "epsilonR" );
|
||||
}
|
||||
|
||||
// Re-calculate model parameters due to parameter read
|
||||
mu=(tau-0.5)/3.0;
|
||||
time_conv = (h*h*1.0e-12)*mu/nu_phys;//time conversion factor from physical to LB unit; [sec/lt]
|
||||
den_scale = rho_phys/rho0*(h*h*h*1.0e-18);//scale factor for density
|
||||
|
||||
epsilon0_LB = epsilon0*(h*1.0e-6);//unit:[C/(V*lu)]
|
||||
epsilon_LB = epsilon0_LB*epsilonR;//electric permittivity
|
||||
}
|
||||
|
||||
void ScaLBL_StokesModel::SetDomain(){
|
||||
@@ -258,6 +284,159 @@ void ScaLBL_StokesModel::ReadInput(){
|
||||
if (rank == 0) cout << " Domain set." << endl;
|
||||
}
|
||||
|
||||
void ScaLBL_StokesModel::AssignZetaPotentialSolid(double *zeta_potential_solid)
|
||||
{
|
||||
size_t NLABELS=0;
|
||||
signed char VALUE=0;
|
||||
double AFFINITY=0.f;
|
||||
|
||||
auto LabelList = stokes_db->getVector<int>( "SolidLabels" );
|
||||
auto AffinityList = stokes_db->getVector<double>( "ZetaPotentialSolidList" );
|
||||
|
||||
NLABELS=LabelList.size();
|
||||
if (NLABELS != AffinityList.size()){
|
||||
ERROR("Error: LB Stokes Solver: SolidLabels and ZetaPotentialSolidList must be the same length! \n");
|
||||
}
|
||||
|
||||
double label_count[NLABELS];
|
||||
double label_count_global[NLABELS];
|
||||
|
||||
for (size_t idx=0; idx<NLABELS; idx++) label_count[idx]=0;
|
||||
|
||||
// Assign the labels
|
||||
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;
|
||||
VALUE=Mask->id[n];
|
||||
AFFINITY=0.f;
|
||||
// Assign the affinity from the paired list
|
||||
for (unsigned int idx=0; idx < NLABELS; idx++){
|
||||
if (VALUE == LabelList[idx]){
|
||||
AFFINITY=AffinityList[idx];//no need to convert unit for zeta potential (i.e. volt)
|
||||
label_count[idx] += 1.0;
|
||||
idx = NLABELS;
|
||||
}
|
||||
}
|
||||
zeta_potential_solid[n] = AFFINITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t idx=0; idx<NLABELS; idx++)
|
||||
label_count_global[idx]=Dm->Comm.sumReduce( label_count[idx]);
|
||||
|
||||
if (rank==0){
|
||||
printf("LB Stokes Solver: number of solid labels: %lu \n",NLABELS);
|
||||
for (unsigned int idx=0; idx<NLABELS; idx++){
|
||||
VALUE=LabelList[idx];
|
||||
AFFINITY=AffinityList[idx];
|
||||
double volume_fraction = double(label_count_global[idx])/double((Nx-2)*(Ny-2)*(Nz-2)*nprocs);
|
||||
printf(" label=%d, zeta potential=%.3g [V], volume fraction=%.2g\n",VALUE,AFFINITY,volume_fraction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScaLBL_StokesModel::AssignSolidGrad(double *solid_grad)
|
||||
{
|
||||
double *Dst;
|
||||
Dst = new double [3*3*3];
|
||||
for (int kk=0; kk<3; kk++){
|
||||
for (int jj=0; jj<3; jj++){
|
||||
for (int ii=0; ii<3; ii++){
|
||||
int index = kk*9+jj*3+ii;
|
||||
Dst[index] = sqrt(double(ii-1)*double(ii-1) + double(jj-1)*double(jj-1)+ double(kk-1)*double(kk-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
//implement a D3Q19 lattice
|
||||
double w_face = 1.0/18.0;
|
||||
double w_edge = 0.5*w_face;
|
||||
double w_corner = 0.0;
|
||||
//local
|
||||
Dst[13] = 0.f;
|
||||
//faces
|
||||
Dst[4] = w_face;
|
||||
Dst[10] = w_face;
|
||||
Dst[12] = w_face;
|
||||
Dst[14] = w_face;
|
||||
Dst[16] = w_face;
|
||||
Dst[22] = w_face;
|
||||
// corners
|
||||
Dst[0] = w_corner;
|
||||
Dst[2] = w_corner;
|
||||
Dst[6] = w_corner;
|
||||
Dst[8] = w_corner;
|
||||
Dst[18] = w_corner;
|
||||
Dst[20] = w_corner;
|
||||
Dst[24] = w_corner;
|
||||
Dst[26] = w_corner;
|
||||
// edges
|
||||
Dst[1] = w_edge;
|
||||
Dst[3] = w_edge;
|
||||
Dst[5] = w_edge;
|
||||
Dst[7] = w_edge;
|
||||
Dst[9] = w_edge;
|
||||
Dst[11] = w_edge;
|
||||
Dst[15] = w_edge;
|
||||
Dst[17] = w_edge;
|
||||
Dst[19] = w_edge;
|
||||
Dst[21] = w_edge;
|
||||
Dst[23] = w_edge;
|
||||
Dst[25] = w_edge;
|
||||
|
||||
for (int k=1; k<Nz-1; k++){
|
||||
for (int j=1; j<Ny-1; j++){
|
||||
for (int i=1; i<Nx-1; i++){
|
||||
int idx=Map(i,j,k);
|
||||
if (!(idx < 0)){
|
||||
double phi_x = 0.f;
|
||||
double phi_y = 0.f;
|
||||
double phi_z = 0.f;
|
||||
for (int kk=0; kk<3; kk++){
|
||||
for (int jj=0; jj<3; jj++){
|
||||
for (int ii=0; ii<3; ii++){
|
||||
|
||||
int index = kk*9+jj*3+ii;
|
||||
double weight= Dst[index];
|
||||
|
||||
int idi=i+ii-1;
|
||||
int idj=j+jj-1;
|
||||
int idk=k+kk-1;
|
||||
|
||||
if (idi < 0) idi=0;
|
||||
if (idj < 0) idj=0;
|
||||
if (idk < 0) idk=0;
|
||||
if (!(idi < Nx)) idi=Nx-1;
|
||||
if (!(idj < Ny)) idj=Ny-1;
|
||||
if (!(idk < Nz)) idk=Nz-1;
|
||||
|
||||
int nn = idk*Nx*Ny + idj*Nx + idi;
|
||||
double vec_x = double(ii-1);
|
||||
double vec_y = double(jj-1);
|
||||
double vec_z = double(kk-1);
|
||||
double GWNS = double(Mask->id[nn]);
|
||||
//Since the solid unit normal vector is wanted, treat
|
||||
//wet node as 0.0 and solid node as 1.0
|
||||
GWNS = (GWNS>0.0) ? 0.0:1.0;
|
||||
phi_x += GWNS*weight*vec_x;
|
||||
phi_y += GWNS*weight*vec_y;
|
||||
phi_z += GWNS*weight*vec_z;
|
||||
}
|
||||
}
|
||||
}
|
||||
//solid_grad normalization
|
||||
double phi_mag=sqrt(phi_x*phi_x+phi_y*phi_y+phi_z*phi_z);
|
||||
if (phi_mag==0.0) phi_mag=1.0;
|
||||
solid_grad[idx+0*Np] = phi_x/phi_mag;
|
||||
solid_grad[idx+1*Np] = phi_y/phi_mag;
|
||||
solid_grad[idx+2*Np] = phi_z/phi_mag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScaLBL_StokesModel::Create(){
|
||||
/*
|
||||
* This function creates the variables needed to run a LBM
|
||||
@@ -301,6 +480,26 @@ void ScaLBL_StokesModel::Create(){
|
||||
ScaLBL_CopyToDevice(NeighborList, neighborList, neighborSize);
|
||||
comm.barrier();
|
||||
|
||||
if (UseSlippingVelBC==true){
|
||||
ScaLBL_Comm->SetupBounceBackList(Map, Mask->id.data(), Np,1);
|
||||
comm.barrier();
|
||||
|
||||
//For slipping velocity BC, need zeta potential and solid unit normal vector
|
||||
ScaLBL_AllocateDeviceMemory((void **) &ZetaPotentialSolid, sizeof(double)*Nx*Ny*Nz);
|
||||
ScaLBL_AllocateDeviceMemory((void **) &SolidGrad, sizeof(double)*3*Np); //unit normal vector of solid nodes
|
||||
|
||||
double *ZetaPotentialSolid_host;
|
||||
ZetaPotentialSolid_host = new double[Nx*Ny*Nz];
|
||||
AssignZetaPotentialSolid(ZetaPotentialSolid_host);
|
||||
double *SolidGrad_host;
|
||||
SolidGrad_host = new double[3*Np];
|
||||
AssignSolidGrad(SolidGrad_host);
|
||||
ScaLBL_CopyToDevice(ZetaPotentialSolid, ZetaPotentialSolid_host, Nx*Ny*Nz*sizeof(double));
|
||||
ScaLBL_CopyToDevice(SolidGrad, SolidGrad_host, 3*Np*sizeof(double));
|
||||
ScaLBL_Comm->Barrier();
|
||||
delete [] ZetaPotentialSolid_host;
|
||||
delete [] SolidGrad_host;
|
||||
}
|
||||
}
|
||||
|
||||
void ScaLBL_StokesModel::Initialize(){
|
||||
@@ -324,6 +523,7 @@ void ScaLBL_StokesModel::Run_Lite(double *ChargeDensity, double *ElectricField){
|
||||
timestep = 0;
|
||||
while (timestep < timestepMax) {
|
||||
//************************************************************************/
|
||||
//**************ODD TIMESTEP*************//
|
||||
timestep++;
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FROM NORMAL
|
||||
ScaLBL_D3Q19_AAodd_StokesMRT(NeighborList, fq, Velocity, ChargeDensity, ElectricField, rlx_setA, rlx_setB, Fx, Fy, Fz,rho0,den_scale,h,time_conv,
|
||||
@@ -344,8 +544,14 @@ void ScaLBL_StokesModel::Run_Lite(double *ChargeDensity, double *ElectricField){
|
||||
}
|
||||
ScaLBL_D3Q19_AAodd_StokesMRT(NeighborList, fq, Velocity, ChargeDensity, ElectricField, rlx_setA, rlx_setB, Fx, Fy, Fz,rho0,den_scale,h,time_conv,
|
||||
0, ScaLBL_Comm->LastExterior(), Np);
|
||||
|
||||
if (UseSlippingVelBC==true){
|
||||
ScaLBL_Comm->SolidSlippingVelocityBCD3Q19(fq, ZetaPotentialSolid, ElectricField, SolidGrad,
|
||||
epsilon_LB, 1.0/rlx_setA, rho0, den_scale, h, time_conv);
|
||||
}
|
||||
ScaLBL_Comm->Barrier(); comm.barrier();
|
||||
|
||||
//**************EVEN TIMESTEP*************//
|
||||
timestep++;
|
||||
ScaLBL_Comm->SendD3Q19AA(fq); //READ FORM NORMAL
|
||||
ScaLBL_D3Q19_AAeven_StokesMRT(fq, Velocity, ChargeDensity, ElectricField, rlx_setA, rlx_setB, Fx, Fy, Fz,rho0,den_scale,h,time_conv,
|
||||
@@ -366,6 +572,10 @@ void ScaLBL_StokesModel::Run_Lite(double *ChargeDensity, double *ElectricField){
|
||||
}
|
||||
ScaLBL_D3Q19_AAeven_StokesMRT(fq, Velocity, ChargeDensity, ElectricField, rlx_setA, rlx_setB, Fx, Fy, Fz,rho0,den_scale,h,time_conv,
|
||||
0, ScaLBL_Comm->LastExterior(), Np);
|
||||
if (UseSlippingVelBC==true){
|
||||
ScaLBL_Comm->SolidSlippingVelocityBCD3Q19(fq, ZetaPotentialSolid, ElectricField, SolidGrad,
|
||||
epsilon_LB, 1.0/rlx_setA, rho0, den_scale, h, time_conv);
|
||||
}
|
||||
ScaLBL_Comm->Barrier(); comm.barrier();
|
||||
//************************************************************************/
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
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
|
||||
bool UseSlippingVelBC;
|
||||
|
||||
int Nx,Ny,Nz,N,Np;
|
||||
int rank,nprocx,nprocy,nprocz,nprocs;
|
||||
@@ -70,6 +72,8 @@ public:
|
||||
double *fq;
|
||||
double *Velocity;
|
||||
double *Pressure;
|
||||
double *ZetaPotentialSolid;
|
||||
double *SolidGrad;
|
||||
|
||||
//Minkowski Morphology;
|
||||
DoubleArray Velocity_x;
|
||||
@@ -88,5 +92,7 @@ private:
|
||||
void LoadParams(std::shared_ptr<Database> db0);
|
||||
void Velocity_LB_to_Phys(DoubleArray &Vel_reg);
|
||||
vector<double> computeElectricForceAvg(double *ChargeDensity, double *ElectricField);
|
||||
void AssignSolidGrad(double *solid_grad);
|
||||
void AssignZetaPotentialSolid(double *zeta_potential_solid);
|
||||
};
|
||||
#endif
|
||||
|
||||
34
sample_scripts/configure_lonestar
Executable file
34
sample_scripts/configure_lonestar
Executable file
@@ -0,0 +1,34 @@
|
||||
# load the module for cmake
|
||||
#module load cmake
|
||||
|
||||
#source /gpfs/gpfs_stage1/b6p315aa/setup/setup-mpi.sh
|
||||
module load cmake gcc
|
||||
module load cuda
|
||||
|
||||
export HDF5_DIR=$HOME/local/hdf5/1.8.12/
|
||||
export SILO_DIR=$HOME/local/silo/4.10.2/
|
||||
export NETCDF_DIR=$HOME/local/netcdf/4.6.1
|
||||
|
||||
# configure
|
||||
rm -rf CMake*
|
||||
cmake \
|
||||
-D CMAKE_BUILD_TYPE:STRING=Release \
|
||||
-D CMAKE_C_COMPILER:PATH=mpicc \
|
||||
-D CMAKE_CXX_COMPILER:PATH=mpicxx \
|
||||
-D CMAKE_CXX_STANDARD=14 \
|
||||
-D USE_CUDA=1 \
|
||||
-D CMAKE_CUDA_FLAGS="-arch sm_70 -Xptxas=-v -Xptxas -dlcm=cg -lineinfo" \
|
||||
-D CMAKE_CUDA_HOST_COMPILER="/opt/apps/gcc/7.3.0/bin/gcc" \
|
||||
-D USE_HDF5=1 \
|
||||
-D HDF5_DIRECTORY="$HDF5_DIR" \
|
||||
-D HDF5_LIB="$HDF5_DIR/lib/libhdf5.a" \
|
||||
-D USE_SILO=1 \
|
||||
-D SILO_LIB="$SILO_DIR/lib/libsiloh5.a" \
|
||||
-D SILO_DIRECTORY="$SILO_DIR" \
|
||||
-D USE_NETCDF=0 \
|
||||
-D NETCDF_DIRECTORY="$NETCDF_DIR" \
|
||||
-D USE_DOXYGEN:BOOL=false \
|
||||
-D USE_TIMER=0 \
|
||||
~/src/LBPM
|
||||
|
||||
make VERBOSE=1 -j1 && make install
|
||||
@@ -4,7 +4,7 @@
|
||||
#source /gpfs/gpfs_stage1/b6p315aa/setup/setup-mpi.sh
|
||||
module load cmake gcc
|
||||
module load cuda
|
||||
|
||||
#/ccs/proj/csc380/mcclurej
|
||||
export HDF5_DIR=/ccs/proj/csc380/mcclurej/install/hdf5/1.8.12/
|
||||
export SILO_DIR=/ccs/proj/csc380/mcclurej/install/silo/4.10.2/
|
||||
export NETCDF_DIR=/ccs/proj/geo136/install/netcdf/4.6.1
|
||||
@@ -28,7 +28,7 @@ cmake \
|
||||
-D USE_SILO=1 \
|
||||
-D SILO_LIB="$SILO_DIR/lib/libsiloh5.a" \
|
||||
-D SILO_DIRECTORY="$SILO_DIR" \
|
||||
-D USE_NETCDF=1 \
|
||||
-D USE_NETCDF=0 \
|
||||
-D NETCDF_DIRECTORY="$NETCDF_DIR" \
|
||||
-D USE_DOXYGEN:BOOL=false \
|
||||
-D USE_TIMER=0 \
|
||||
|
||||
@@ -62,7 +62,7 @@ ADD_LBPM_TEST( TestMap )
|
||||
ADD_LBPM_TEST( TestWideHalo )
|
||||
ADD_LBPM_TEST( TestColorGradDFH )
|
||||
ADD_LBPM_TEST( TestBubbleDFH ../example/Bubble/input.db)
|
||||
ADD_LBPM_TEST( testGlobalMassFreeLee ../example/Bubble/input.db)
|
||||
#ADD_LBPM_TEST( testGlobalMassFreeLee ../example/Bubble/input.db)
|
||||
#ADD_LBPM_TEST( TestColorMassBounceback ../example/Bubble/input.db)
|
||||
ADD_LBPM_TEST( TestPressVel ../example/Bubble/input.db)
|
||||
ADD_LBPM_TEST( TestPoiseuille ../example/Piston/poiseuille.db)
|
||||
|
||||
@@ -84,12 +84,11 @@ int main( int argc, char **argv )
|
||||
|
||||
Adapt.MoveInterface(ColorModel);
|
||||
}
|
||||
ColorModel.WriteDebug();
|
||||
} //Analysis.WriteVis(LeeModel,LeeModel.db, timestep);
|
||||
|
||||
else
|
||||
ColorModel.Run();
|
||||
|
||||
ColorModel.WriteDebug();
|
||||
ColorModel.Run();
|
||||
|
||||
PROFILE_STOP( "Main" );
|
||||
auto file = db->getWithDefault<std::string>( "TimerFile", "lbpm_color_simulator" );
|
||||
|
||||
@@ -72,7 +72,7 @@ int main( int argc, char **argv )
|
||||
Analysis.WriteVis(LeeModel,LeeModel.db, timestep);
|
||||
timestep += visualization_time;
|
||||
}
|
||||
//LeeModel.WriteDebug_TwoFluid();
|
||||
LeeModel.WriteDebug_TwoFluid();
|
||||
if (rank==0) printf("********************************************************\n");
|
||||
if (rank==0) printf("Lattice update rate (per core)= %f MLUPS \n", MLUPS);
|
||||
MLUPS *= nprocs;
|
||||
|
||||
Reference in New Issue
Block a user