Merge branch 'morphLBM' of github.com:JamesEMcClure/LBPM-WIA into morphLBM

This commit is contained in:
James E McClure
2019-03-24 20:21:15 -04:00
2 changed files with 32 additions and 52 deletions

View File

@@ -910,7 +910,27 @@ void runAnalysis::basic( int timestep, SubPhase &Averages, const double *Phi, do
work->add_dependency(d_wait_analysis); // Make sure we are done using analysis before modifying
d_wait_analysis = d_tpool.add_work(work);
}
if (timestep%d_restart_interval==0){
std::shared_ptr<double> cfq,cDen;
// Copy restart data to the CPU
cDen = std::shared_ptr<double>(new double[2*d_Np],DeleteArray<double>);
cfq = std::shared_ptr<double>(new double[19*d_Np],DeleteArray<double>);
ScaLBL_CopyToHost(cfq.get(),fq,19*d_Np*sizeof(double));
ScaLBL_CopyToHost(cDen.get(),Den,2*d_Np*sizeof(double));
if (d_rank==0) {
FILE *Rst = fopen("Restart.txt","w");
fprintf(Rst,"%i\n",timestep+4);
fclose(Rst);
}
// Write the restart file (using a seperate thread)
auto work1 = new WriteRestartWorkItem(d_restartFile.c_str(),cDen,cfq,d_Np);
work1->add_dependency(d_wait_restart);
d_wait_restart = d_tpool.add_work(work1);
}
PROFILE_STOP("run");
}
@@ -931,50 +951,10 @@ void runAnalysis::WriteVisData( int timestep, SubPhase &Averages, const double *
// Copy the appropriate variables to the host (so we can spawn new threads)
ScaLBL_DeviceBarrier();
/* PROFILE_START("Copy data to host",1);
//if ( matches(type,AnalysisType::CopySimState) ) {
if ( timestep%d_analysis_interval == 0 ) {
// Copy the members of Averages to the cpu (phase was copied above)
PROFILE_START("Copy-Pressure",1);
ScaLBL_D3Q19_Pressure(fq,Pressure,d_Np);
//ScaLBL_D3Q19_Momentum(fq,Velocity,d_Np);
ScaLBL_DeviceBarrier();
PROFILE_STOP("Copy-Pressure",1);
PROFILE_START("Copy-Wait",1);
PROFILE_STOP("Copy-Wait",1);
PROFILE_START("Copy-State",1);
// copy other variables
d_ScaLBL_Comm->RegularLayout(d_Map,Pressure,Averages.Pressure);
d_ScaLBL_Comm->RegularLayout(d_Map,&Den[0],Averages.Rho_n);
d_ScaLBL_Comm->RegularLayout(d_Map,&Den[d_Np],Averages.Rho_w);
d_ScaLBL_Comm->RegularLayout(d_Map,&Velocity[0],Averages.Vel_x);
d_ScaLBL_Comm->RegularLayout(d_Map,&Velocity[d_Np],Averages.Vel_y);
d_ScaLBL_Comm->RegularLayout(d_Map,&Velocity[2*d_Np],Averages.Vel_z);
PROFILE_STOP("Copy-State",1);
}
PROFILE_STOP("Copy data to host");
*/
PROFILE_START("write vis",1);
// if (Averages.WriteVis == true){
std::shared_ptr<double> cfq,cDen;
// Copy restart data to the CPU
cDen = std::shared_ptr<double>(new double[2*d_Np],DeleteArray<double>);
cfq = std::shared_ptr<double>(new double[19*d_Np],DeleteArray<double>);
ScaLBL_CopyToHost(cfq.get(),fq,19*d_Np*sizeof(double));
ScaLBL_CopyToHost(cDen.get(),Den,2*d_Np*sizeof(double));
if (d_rank==0) {
FILE *Rst = fopen("Restart.txt","w");
fprintf(Rst,"%i\n",timestep+4);
fclose(Rst);
}
// Write the restart file (using a seperate thread)
auto work1 = new WriteRestartWorkItem(d_restartFile.c_str(),cDen,cfq,d_Np);
work1->add_dependency(d_wait_restart);
d_wait_restart = d_tpool.add_work(work1);
auto work2 = new IOWorkItem( timestep, d_meshData, Averages, d_fillData, getComm() );
work2->add_dependency(d_wait_vis);
d_wait_vis = d_tpool.add_work(work2);

View File

@@ -225,7 +225,7 @@ void ScaLBL_ColorModel::AssignComponentLabels(double *phase)
VALUE=LabelList[idx];
AFFINITY=AffinityList[idx];
double volume_fraction = double(label_count_global[idx])/double((Nx-2)*(Ny-2)*(Nz-2)*nprocs);
printf(" label=%i, affinity=%f, volume fraction==%f\n",int(VALUE),AFFINITY,volume_fraction);
printf(" label=%hhd, affinity=%f, volume fraction==%f\n",VALUE,AFFINITY,volume_fraction);
}
}
@@ -611,15 +611,6 @@ void ScaLBL_ColorModel::Run(){
fprintf(kr_log_file,"%i %.5g %.5g %.5g %.5g %.5g %.5g ",CURRENT_STEADY_TIMESTEPS,muA,muB,5.796*alpha,Fx,Fy,Fz);
fprintf(kr_log_file,"%.5g %.5g %.5g %.5g %.5g %.5g %.5g %.5g\n",volA,volB,vA_x,vA_y,vA_z,vB_x,vB_y,vB_z);
fclose(kr_log_file);
// flow reversal criteria based on fractional flow
if (delta_volume_target < 0.0 &&
volA*sqrt(vA_x*vA_x + vA_y*vA_y + vA_z*vA_z)/(volB*sqrt(vB_x*vB_x + vB_y*vB_y + vB_z*vB_z)) < RESIDUAL_ENDPOINT_THRESHOLD){
delta_volume_target *= (-1.0);
}
else if (delta_volume_target > 0.0 &&
(volB*sqrt(vB_x*vB_x + vB_y*vB_y + vB_z*vB_z)) / (volA*sqrt(vA_x*vA_x + vA_y*vA_y + vA_z*vA_z)) < RESIDUAL_ENDPOINT_THRESHOLD){
delta_volume_target *= (-1.0);
}
printf(" Measured capillary number %f \n ",Ca);
}
@@ -634,7 +625,7 @@ void ScaLBL_ColorModel::Run(){
Fy *= 1e-3/force_magnitude;
Fz *= 1e-3/force_magnitude;
}
if (force_magnitude < 1e-6){
if (force_magnitude < 1e-7){
Fx *= 1e-6/force_magnitude; // impose floor
Fy *= 1e-6/force_magnitude;
Fz *= 1e-6/force_magnitude;
@@ -642,6 +633,15 @@ void ScaLBL_ColorModel::Run(){
if (rank == 0) printf(" -- adjust force by factor %f \n ",capillary_number / Ca);
Averages->SetParams(rhoA,rhoB,tauA,tauB,Fx,Fy,Fz,alpha,beta);
}
// flow reversal criteria based on fractional flow rate
if (delta_volume_target < 0.0 &&
volA*flow_rate_A/(volA*flow_rate_A+volB*flow_rate_B) < RESIDUAL_ENDPOINT_THRESHOLD){
delta_volume_target *= (-1.0);
}
else if (delta_volume_target > 0.0 &&
volB*flow_rate_B/(volA*flow_rate_A+volB*flow_rate_B) < RESIDUAL_ENDPOINT_THRESHOLD){
delta_volume_target *= (-1.0);
}
}
else{
if (rank==0){