update growth algorithm
This commit is contained in:
@@ -326,26 +326,46 @@ double MorphGrow(DoubleArray &BoundaryDist, DoubleArray &Dist, Array<char> &id,
|
||||
}
|
||||
double count_original=sumReduce( Dm->Comm, count);
|
||||
|
||||
// Figure out a good guess to morph_delta
|
||||
double morph_delta = 0.5;
|
||||
count = 0.0;
|
||||
for (int k=0; k<Nz; k++){
|
||||
for (int j=0; j<Ny; j++){
|
||||
for (int i=0; i<Nx; i++){
|
||||
double walldist=BoundaryDist(i,j,k);
|
||||
double wallweight = 1.f / (1+exp(-5.f*(walldist-1.f)));
|
||||
if (Dist(i,j,k) - wallweight*morph_delta > 0.0){
|
||||
count+=1.0;
|
||||
// Estimate morph_delta
|
||||
double morph_delta = 0.0;
|
||||
if (TargetGrowth > 0.0) morph_delta = 0.5;
|
||||
else morph_delta = -0.5;
|
||||
|
||||
double GrowthEstimate = 0.0;
|
||||
double MAX_DISPLACEMENT = 0.0;
|
||||
int COUNT_FOR_LOOP = 0;
|
||||
if (rank == 0) printf("Estimate delta for growth=%f \n",TargetGrowth);
|
||||
while (!(GrowthEstimate*TargetGrowth > TargetGrowth*TargetGrowth) && COUNT_FOR_LOOP < 10 ){
|
||||
COUNT_FOR_LOOP++;
|
||||
count = 0.0;
|
||||
for (int k=0; k<Nz; k++){
|
||||
for (int j=0; j<Ny; j++){
|
||||
for (int i=0; i<Nx; i++){
|
||||
//double walldist=BoundaryDist(i,j,k);
|
||||
//double wallweight = 1.f / (1+exp(-5.f*(walldist-1.f)));
|
||||
double wallweight = 1.f;
|
||||
if (fabs(wallweight*morph_delta) > MAX_DISPLACEMENT) MAX_DISPLACEMENT= fabs(wallweight*morph_delta);
|
||||
|
||||
if (Dist(i,j,k) - wallweight*morph_delta > 0.0){
|
||||
count+=1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
count=sumReduce( Dm->Comm, count);
|
||||
count=sumReduce( Dm->Comm, count);
|
||||
MAX_DISPLACEMENT = sumReduce( Dm->Comm, MAX_DISPLACEMENT);
|
||||
GrowthEstimate = count;
|
||||
|
||||
if (rank == 0) prinf(" delta=%f, growth=%f, max. displacement = %f \n",morph_delta, GrowthEstimate, MAX_DISPLACEMENT);
|
||||
// Now adjust morph_delta
|
||||
morph_delta *= TargetGrowth/(count - count_original);
|
||||
if (MAX_DISPLACEMENT > 2.0 ){
|
||||
morph_delta /= 0.5*MAX_DISPLACEMENT;
|
||||
COUNT_FOR_LOOP = 100; // exit loop if displacement is too large
|
||||
}
|
||||
}
|
||||
if (rank == 0) printf("Final delta=%f \n",morph_delta);
|
||||
|
||||
// Now adjust morph_delta
|
||||
morph_delta = 0.5*TargetGrowth/(count_original-count);
|
||||
if (morph_delta > 3.0 ) morph_delta=3.0;
|
||||
|
||||
count = 0.0;
|
||||
for (int k=0; k<Nz; k++){
|
||||
for (int j=0; j<Ny; j++){
|
||||
|
||||
@@ -786,10 +786,10 @@ double ScaLBL_ColorModel::MorphInit(const double beta, const double target_delta
|
||||
}
|
||||
*/
|
||||
|
||||
if (target_delta_volume > 0.0){
|
||||
//if (target_delta_volume > 0.0){
|
||||
if (rank==0) printf("MorphGrow with target volume fraction change %f \n", target_delta_volume/volume_initial);
|
||||
delta_volume = MorphGrow(Averages->SDs,phase_distance,phase_id,Averages->Dm,target_delta_volume);
|
||||
}
|
||||
/*}
|
||||
else{
|
||||
double target_void_fraction = 1.0- (volume_initial+target_delta_volume)/volume_initial;
|
||||
if (rank==0) printf("MorphOpen with volume fraction %f \n", target_void_fraction);
|
||||
@@ -813,7 +813,7 @@ double ScaLBL_ColorModel::MorphInit(const double beta, const double target_delta
|
||||
}
|
||||
CalcDist(phase_distance,phase_id,*Dm); // re-calculate distance
|
||||
}
|
||||
|
||||
*/
|
||||
// 5. Update phase indicator field based on new distnace
|
||||
for (int k=0; k<Nz; k++){
|
||||
for (int j=0; j<Ny; j++){
|
||||
|
||||
Reference in New Issue
Block a user