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

This commit is contained in:
James E McClure 2018-12-17 07:06:49 -05:00
commit 0e0bd27348
2 changed files with 68 additions and 2 deletions

View File

@ -209,7 +209,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)*nprocz);
printf(" label=%i, affinity=%f, volume fraction==%f\n",int(VALUE),AFFINITY,volume_fraction);
printf(" label=%i, affinity=%f, volume fraction=%f\n",int(VALUE),AFFINITY,volume_fraction);
}
}
@ -413,9 +413,11 @@ void ScaLBL_ColorModel::Run(){
bool MORPH_ADAPT = false;
bool USE_MORPH = false;
int morph_interval;
double morph_delta;
int morph_timesteps = 0;
int ramp_timesteps = 50000;
int MORPH_TIME = 0;
int MAX_MORPH_TIME = 20000;
double morph_delta;
double capillary_number;
double tolerance = 1.f;
double Ca_previous = 0.f;
@ -660,15 +662,24 @@ void ScaLBL_ColorModel::Run(){
if (morph_delta < 0.f){
if (volB/(volA + volB) > TARGET_SATURATION){
MORPH_ADAPT = false;
MORPH_TIME = 0;
TARGET_SATURATION = target_saturation[target_saturation_index++];
}
}
else{
if (volB/(volA + volB) < TARGET_SATURATION){
MORPH_ADAPT = false;
MORPH_TIME = 0;
TARGET_SATURATION = target_saturation[target_saturation_index++];
}
}
// maximum number of timesteps to spend on morphological adaptation
// this is to help get useful data when fluid connectivity breaks down
MORPH_TIME += analysis_interval;
if (MORPH_TIME > MAX_MORPH_TIME){
MORPH_ADAPT= false;
MORPH_TIME = 0;
}
MPI_Barrier(comm);
morph_timesteps = 0;
}

View File

@ -127,6 +127,61 @@ int main(int argc, char **argv)
// Run the morphological opening
MorphOpen(SignDist, id, Dm, SW);
// calculate distance to non-wetting fluid
if (domain_db->keyExists( "HistoryLabels" )){
if (rank==0) printf("Relabel solid components that touch fluid 1 \n");
auto LabelList = domain_db->getVector<char>( "ComponentLabels" );
auto HistoryLabels = domain_db->getVector<char>( "HistoryLabels" );
size_t NLABELS=LabelList.size();
if (rank==0){
for (unsigned int idx=0; idx < NLABELS; idx++){
char VALUE = LabelList[idx];
char NEWVAL = HistoryLabels[idx];
printf(" Relabel component %d as %d \n", VALUE, NEWVAL);
}
}
for (int k=0;k<nz;k++){
for (int j=0;j<ny;j++){
for (int i=0;i<nx;i++){
int n = k*nx*ny+j*nx+i;
// Initialize the solid phase
if (id[n] == 1) id_solid(i,j,k) = 0;
else id_solid(i,j,k) = 1;
}
}
}
// Initialize the signed distance function
for (int k=0;k<nz;k++){
for (int j=0;j<ny;j++){
for (int i=0;i<nx;i++){
int n = k*nx*ny+j*nx+i;
// Initialize distance to +/- 1
SignDist(i,j,k) = 2.0*double(id_solid(i,j,k))-1.0;
}
}
}
CalcDist(SignDist,id_solid,*Dm);
// re-label IDs near the non-wetting fluid
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;
signed char LOCVAL = id[n];
for (unsigned int idx=0; idx < NLABELS; idx++){
char VALUE=LabelList[idx];
char NEWVALUE=HistoryLabels[idx];
if (LOCVAL == VALUE){
idx = NLABELS;
if (SignDist(i,j,k) < 1.0){
id[n] = NEWVALUE;
}
}
}
}
}
}
}
if (rank==0) printf("Writing ID file \n");
sprintf(LocalRankFilename,"ID.%05i",rank);