Refactored component label assignment
This commit is contained in:
@@ -120,71 +120,17 @@ void ScaLBL_ColorModel::ReadInput(){
|
||||
}
|
||||
void ScaLBL_ColorModel::AssignComponentLabels(double *phase)
|
||||
{
|
||||
int rank=Dm->rank();
|
||||
int NLABELS=0;
|
||||
char VALUE=0;
|
||||
double AFFINITY=0.f;
|
||||
|
||||
vector <char> Label;
|
||||
vector <double> Affinity;
|
||||
// Read the labels
|
||||
if (rank==0){
|
||||
printf("Component labels:\n");
|
||||
ifstream iFILE("ComponentLabels.csv");
|
||||
if (iFILE.good()){
|
||||
int value;
|
||||
while (!iFILE.eof()){
|
||||
iFILE>>value;
|
||||
iFILE>>AFFINITY;
|
||||
VALUE=char(value);
|
||||
Label.push_back(value);
|
||||
Affinity.push_back(AFFINITY);
|
||||
NLABELS++;
|
||||
printf("%i %f\n",VALUE,AFFINITY);
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("Using default labels: Solid (0 --> -1.0), NWP (1 --> 1.0), WP (2 --> -1.0)\n");
|
||||
// Set default values
|
||||
VALUE=0; AFFINITY=-1.0;
|
||||
Label.push_back(VALUE);
|
||||
Affinity.push_back(AFFINITY);
|
||||
NLABELS++;
|
||||
VALUE=1; AFFINITY=1.0;
|
||||
Label.push_back(VALUE);
|
||||
Affinity.push_back(AFFINITY);
|
||||
NLABELS++;
|
||||
VALUE=2; AFFINITY=-1.0;
|
||||
Label.push_back(VALUE);
|
||||
Affinity.push_back(AFFINITY);
|
||||
NLABELS++;
|
||||
}
|
||||
}
|
||||
MPI_Barrier(comm);
|
||||
|
||||
// Broadcast the list
|
||||
MPI_Bcast(&NLABELS,1,MPI_INT,0,comm);
|
||||
//printf("rank=%i, NLABELS=%i \n ",rank(),NLABELS);
|
||||
auto LabelList = color_db->getVector<char>( "ComponentLabels" );
|
||||
auto AffinityList = color_db->getVector<double>( "ComponentAffinity" );
|
||||
|
||||
// Copy into contiguous buffers
|
||||
char *LabelList;
|
||||
double * AffinityList;
|
||||
LabelList=new char[NLABELS];
|
||||
AffinityList=new double[NLABELS];
|
||||
|
||||
if (rank==0){
|
||||
for (int idx=0; idx < NLABELS; idx++){
|
||||
VALUE=Label[idx];
|
||||
AFFINITY=Affinity[idx];
|
||||
printf("rank=%i, idx=%i, value=%d, affinity=%f \n",rank,idx,VALUE,AFFINITY);
|
||||
LabelList[idx]=VALUE;
|
||||
AffinityList[idx]=AFFINITY;
|
||||
}
|
||||
NLABELS=LabelList.size();
|
||||
if (NLABELS != AffinityList.size()){
|
||||
ERROR("Error: ComponentLabels and ComponentAffinity must be the same length! \n");
|
||||
}
|
||||
MPI_Barrier(comm);
|
||||
|
||||
MPI_Bcast(LabelList,NLABELS,MPI_CHAR,0,comm);
|
||||
MPI_Bcast(AffinityList,NLABELS,MPI_DOUBLE,0,comm);
|
||||
|
||||
// Assign the labels
|
||||
for (int k=0;k<Nz;k++){
|
||||
|
||||
Reference in New Issue
Block a user