Skip to content

Commit

Permalink
Merge pull request #34 from RuhiRG/enumClassFix
Browse files Browse the repository at this point in the history
ENH: Enum class fix
  • Loading branch information
HaoZeke authored Jun 28, 2023
2 parents 1b52b69 + c71616a commit 13e0104
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 176 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,27 @@ TSWLatexianTemp*

# standalone packages
*.sta

# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"files.associations": {
"deque": "cpp",
"string": "cpp",
"vector": "cpp",
"alignedvector3": "cpp",
"any": "cpp",
"array": "cpp",
"chrono": "cpp",
"functional": "cpp",
"istream": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"variant": "cpp"
}
}
4 changes: 2 additions & 2 deletions src/bond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ bond::populateBonds(std::vector<std::vector<int>> nList,
for (int i = 0; i < nList.size(); i++) {
iatom = nList[i][0]; // Index of the i^th atom
// Skip for dummy atoms
if (atomTypes[iatom] == cage::dummy) {
if (atomTypes[iatom] == cage::iceType::dummy) {
continue;
} // Skip for dummy atoms
// Get the neighbours of iatom
for (int j = 1; j < nList[i].size(); j++) {
//
jatom = nList[iatom][j]; // Index of the neighbour
// Skip for dummy atoms
if (atomTypes[jatom] == cage::dummy) {
if (atomTypes[jatom] == cage::iceType::dummy) {
continue;
} // Skip for dummy atoms
// To avoid duplicates, skip all bonds such
Expand Down
80 changes: 40 additions & 40 deletions src/bop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ chill::getCorrel(molSys::PointCloud<molSys::Point<double>, double> *yCloud,
cij_real = complexCij.real();
temp_cij.c_value = cij_real;
if (cij_real < -0.8) {
temp_cij.classifier = molSys::staggered;
temp_cij.classifier = molSys::bond_type::staggered;
} else if (cij_real > -0.2 && cij_real < -0.05) {
temp_cij.classifier = molSys::eclipsed;
temp_cij.classifier = molSys::bond_type::eclipsed;
} else {
temp_cij.classifier = molSys::out_of_range;
temp_cij.classifier = molSys::bond_type::out_of_range;
}
yCloud->pts[iatomIndex].c_ij.push_back(temp_cij);
} // end loop over nearest neighbours
Expand Down Expand Up @@ -461,37 +461,37 @@ molSys::PointCloud<molSys::Point<double>, double> chill::getIceTypeNoPrint(
// Loop through the bond cij and get the number of staggered, eclipsed bonds
for (int j = 0; j < nnumNeighbours; j++) {
bondType = yCloud->pts[iatom].c_ij[j].classifier;
if (bondType == molSys::eclipsed) {
if (bondType == molSys::bond_type::eclipsed) {
num_eclipsd++;
} else if (bondType == molSys::staggered) {
} else if (bondType == molSys::bond_type::staggered) {
num_staggrd++;
} else {
na++;
}
} // End of loop through neighbours

// Add more tests later
yCloud->pts[iatom].iceType = molSys::unclassified; // default
yCloud->pts[iatom].iceType = molSys::atom_state_type::unclassified; // default
// Cubic ice
// if (num_eclipsd==0 && num_staggrd==4){
// yCloud->pts[iatom].iceType = molSys::cubic;
// ic++;
// }
if (num_staggrd >= 4) {
yCloud->pts[iatom].iceType = molSys::cubic;
yCloud->pts[iatom].iceType = molSys::atom_state_type::cubic;
ic++;
}
// Hexagonal
else if (num_eclipsd == 1 && num_staggrd == 3) {
yCloud->pts[iatom].iceType = molSys::hexagonal;
yCloud->pts[iatom].iceType = molSys::atom_state_type::hexagonal;
ih++;
}
// Interfacial
else if (isInterfacial(yCloud, nList, iatom, num_staggrd, num_eclipsd)) {
yCloud->pts[iatom].iceType = molSys::interfacial;
yCloud->pts[iatom].iceType = molSys::atom_state_type::interfacial;
interIce++;
} else {
yCloud->pts[iatom].iceType = molSys::water;
yCloud->pts[iatom].iceType = molSys::atom_state_type::water;
water++;
}

Expand Down Expand Up @@ -529,37 +529,37 @@ chill::getIceType(molSys::PointCloud<molSys::Point<double>, double> *yCloud,
// Loop through the bond cij and get the number of staggered, eclipsed bonds
for (int j = 0; j < nnumNeighbours; j++) {
bondType = yCloud->pts[iatom].c_ij[j].classifier;
if (bondType == molSys::eclipsed) {
if (bondType == molSys::bond_type::eclipsed) {
num_eclipsd++;
} else if (bondType == molSys::staggered) {
} else if (bondType == molSys::bond_type::staggered) {
num_staggrd++;
} else {
na++;
}
} // End of loop through neighbours

// Add more tests later
yCloud->pts[iatom].iceType = molSys::unclassified; // default
yCloud->pts[iatom].iceType = molSys::atom_state_type::unclassified; // default
// Cubic ice
// if (num_eclipsd==0 && num_staggrd==4){
// yCloud->pts[iatom].iceType = molSys::cubic;
// ic++;
// }
if (num_staggrd >= 4) {
yCloud->pts[iatom].iceType = molSys::cubic;
yCloud->pts[iatom].iceType = molSys::atom_state_type::cubic;
ic++;
}
// Hexagonal
else if (num_eclipsd == 1 && num_staggrd == 3) {
yCloud->pts[iatom].iceType = molSys::hexagonal;
yCloud->pts[iatom].iceType = molSys::atom_state_type::hexagonal;
ih++;
}
// Interfacial
else if (isInterfacial(yCloud, nList, iatom, num_staggrd, num_eclipsd)) {
yCloud->pts[iatom].iceType = molSys::interfacial;
yCloud->pts[iatom].iceType = molSys::atom_state_type::interfacial;
interIce++;
} else {
yCloud->pts[iatom].iceType = molSys::water;
yCloud->pts[iatom].iceType = molSys::atom_state_type::water;
water++;
}

Expand Down Expand Up @@ -723,11 +723,11 @@ chill::getCorrelPlus(molSys::PointCloud<molSys::Point<double>, double> *yCloud,
cij_real = complexCij.real();
temp_cij.c_value = cij_real;
if (cij_real <= -0.8) {
temp_cij.classifier = molSys::staggered;
temp_cij.classifier = molSys::bond_type::staggered;
} else if (cij_real >= -0.35 && cij_real <= 0.25) {
temp_cij.classifier = molSys::eclipsed;
temp_cij.classifier = molSys::bond_type::eclipsed;
} else {
temp_cij.classifier = molSys::out_of_range;
temp_cij.classifier = molSys::bond_type::out_of_range;
}
yCloud->pts[iatomIndex].c_ij.push_back(temp_cij);
} // end loop over nearest neighbours
Expand Down Expand Up @@ -782,50 +782,50 @@ chill::getIceTypePlus(molSys::PointCloud<molSys::Point<double>, double> *yCloud,
// Loop through the bond cij and get the number of staggered, eclipsed bonds
for (int j = 0; j < nnumNeighbours; j++) {
bondType = yCloud->pts[iatom].c_ij[j].classifier;
if (bondType == molSys::eclipsed) {
if (bondType == molSys::bond_type::eclipsed) {
num_eclipsd++;
} else if (bondType == molSys::staggered) {
} else if (bondType == molSys::bond_type::staggered) {
num_staggrd++;
} else {
na++;
}
} // End of loop through neighbours

// Add more tests later
yCloud->pts[iatom].iceType = molSys::unclassified; // default
yCloud->pts[iatom].iceType = molSys::atom_state_type::unclassified; // default
if (nnumNeighbours == 4) {
// Cubic ice
if (num_eclipsd == 0 && num_staggrd == 4) {
yCloud->pts[iatom].iceType = molSys::cubic;
yCloud->pts[iatom].iceType = molSys::atom_state_type::cubic;
ic++;
}
// Hexagonal
else if (num_eclipsd == 1 && num_staggrd == 3) {
yCloud->pts[iatom].iceType = molSys::hexagonal;
yCloud->pts[iatom].iceType = molSys::atom_state_type::hexagonal;
ih++;
}
// Interfacial
else if (isInterfacial(yCloud, nList, iatom, num_staggrd, num_eclipsd)) {
yCloud->pts[iatom].iceType = molSys::interfacial;
yCloud->pts[iatom].iceType = molSys::atom_state_type::interfacial;
interIce++;
}
// Clathrate
else if (num_eclipsd == 4 && num_staggrd == 0) {
yCloud->pts[iatom].iceType = molSys::clathrate;
yCloud->pts[iatom].iceType = molSys::atom_state_type::clathrate;
clath++;
}
// Interfacial clathrate
else if (num_eclipsd == 3) {
yCloud->pts[iatom].iceType = molSys::interClathrate;
yCloud->pts[iatom].iceType = molSys::atom_state_type::interClathrate;
interClath++;
}
// Water
else {
yCloud->pts[iatom].iceType = molSys::water;
yCloud->pts[iatom].iceType = molSys::atom_state_type::water;
water++;
}
} else {
yCloud->pts[iatom].iceType = molSys::water;
yCloud->pts[iatom].iceType = molSys::atom_state_type::water;
water++;
}

Expand Down Expand Up @@ -1019,7 +1019,7 @@ molSys::PointCloud<molSys::Point<double>, double> chill::reclassifyWater(

for (int iatom = 0; iatom < yCloud->nop; iatom++) {
// Check if it has been classified as water
if (yCloud->pts[iatom].iceType == molSys::water) {
if (yCloud->pts[iatom].iceType == molSys::atom_state_type::water) {
if ((*q6)[iatom] > 0.5) {
avgQ3 = 0.0; // init to zero
// Loop through all c_ij
Expand All @@ -1032,10 +1032,10 @@ molSys::PointCloud<molSys::Point<double>, double> chill::reclassifyWater(
// If averaged q3 < -0.75, then reclassify
if (avgQ3 <= -0.75) {
if (avgQ3 < -0.85) {
yCloud->pts[iatom].iceType = molSys::reCubic;
yCloud->pts[iatom].iceType = molSys::atom_state_type::reCubic;
} // molSys::cubic
else {
yCloud->pts[iatom].iceType = molSys::reHex;
yCloud->pts[iatom].iceType = molSys::atom_state_type::reHex;
} // molSys::hexagonal
} // end of reclassification
} // check for solid atom!
Expand Down Expand Up @@ -1074,17 +1074,17 @@ int chill::printIceType(
}
}
total++;
if (yCloud->pts[iatom].iceType == molSys::cubic) {
if (yCloud->pts[iatom].iceType == molSys::atom_state_type::cubic) {
ic++;
} else if (yCloud->pts[iatom].iceType == molSys::hexagonal) {
} else if (yCloud->pts[iatom].iceType == molSys::atom_state_type::hexagonal) {
ih++;
} else if (yCloud->pts[iatom].iceType == molSys::water) {
} else if (yCloud->pts[iatom].iceType == molSys::atom_state_type::water) {
water++;
} else if (yCloud->pts[iatom].iceType == molSys::interfacial) {
} else if (yCloud->pts[iatom].iceType == molSys::atom_state_type::interfacial) {
interIce++;
} else if (yCloud->pts[iatom].iceType == molSys::clathrate) {
} else if (yCloud->pts[iatom].iceType == molSys::atom_state_type::clathrate) {
clath++;
} else if (yCloud->pts[iatom].iceType == molSys::interClathrate) {
} else if (yCloud->pts[iatom].iceType == molSys::atom_state_type::interClathrate) {
interClath++;
} else {
unknown++;
Expand Down Expand Up @@ -1211,7 +1211,7 @@ int chill::numStaggered(
for (int i = 0; i < nnumNeighbours; i++) {
bondType = yCloud->pts[jatom].c_ij[i].classifier;
// If the bond is staggered increment the number of staggered bonds
if (bondType == molSys::staggered) {
if (bondType == molSys::bond_type::staggered) {
num_staggrd++;
}
} // end of loop over c_ij
Expand Down
14 changes: 7 additions & 7 deletions src/bulkTUM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,19 @@ int tum3::topoUnitMatchingBulk(
dumpAtomTypes.resize(atomTypes.size());
// Change from enum to int
for (int i = 0; i < atomTypes.size(); i++) {
if (atomTypes[i] == cage::hc) {
if (atomTypes[i] == cage::iceType::hc) {
dumpAtomTypes[i] = 1;
} // HC
else if (atomTypes[i] == cage::ddc) {
else if (atomTypes[i] == cage::iceType::ddc) {
dumpAtomTypes[i] = 2;
} // DDC
else if (atomTypes[i] == cage::mixed) {
else if (atomTypes[i] == cage::iceType::mixed) {
dumpAtomTypes[i] = 3;
} // mixed rings
else if (atomTypes[i] == cage::pnc) {
else if (atomTypes[i] == cage::iceType::pnc) {
dumpAtomTypes[i] = 4;
} // pnc
else if (atomTypes[i] == cage::mixed2) {
else if (atomTypes[i] == cage::iceType::mixed2) {
dumpAtomTypes[i] = 5;
} // shared by pnc and ddc/hc
else {
Expand Down Expand Up @@ -504,7 +504,7 @@ int tum3::updateRMSDatom(std::vector<std::vector<int>> rings,
iatom = rings[iring][j]; // Current atom index

// Skip for PNC atoms
if (atomTypes[iatom] == cage::pnc || atomTypes[iatom] == cage::mixed2) {
if (atomTypes[iatom] == cage::iceType::pnc || atomTypes[iatom] == cage::iceType::mixed2) {
continue;
} // Do not update if the atom is a PNC
//
Expand Down Expand Up @@ -730,7 +730,7 @@ int tum3::clusterCages(
// If only one cage is in the cluster
if (linkedList[i] == i) {
// Add to the number of single DDCs
if (cageList[i].type == cage::DoubleDiaC) {
if (cageList[i].type == cage::cageType::DoubleDiaC) {
singleDDCs++;
} // add to the single DDCs
else {
Expand Down
4 changes: 2 additions & 2 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@ int clump::clusterAnalysis(
// Assign values to isIce according to the CHILL algorithm
for (int iatom = 0; iatom < yCloud->nop; iatom++) {
// If it is an ice-like molecule, add it, otherwise skip
if (yCloud->pts[iatom].iceType == molSys::water) {
if (yCloud->pts[iatom].iceType == molSys::atom_state_type::water) {
continue;
} // water
if (yCloud->pts[iatom].iceType == molSys::unclassified) {
if (yCloud->pts[iatom].iceType == molSys::atom_state_type::unclassified) {
continue;
} // unclassified
isIce[iatom] = true; // is ice-like; by default false
Expand Down
3 changes: 2 additions & 1 deletion src/generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ int gen::prettyPrintYoda(
// Print out cij
// for(int c=0; c<yCloud->pts[i].c_ij.size(); c++){outputFile <<
// yCloud->pts[i].c_ij[c]<<"\t";} Print out the classifier
outputFile << yCloud->pts[i].iceType << "\n";
// TODO: Should print string representation
outputFile << static_cast<int>(yCloud->pts[i].iceType) << "\n";
}
}
// Close the file
Expand Down
Loading

0 comments on commit 13e0104

Please sign in to comment.