Commit b9ecf050 authored by pmla's avatar pmla

reintegrated orphan atom adoption

parent 12a45972
......@@ -403,12 +403,8 @@ int ptm_index(ptm_local_handle_t local_handle,
}
}
if (res.ref_struct == NULL) {
if (output_env != NULL) {
memcpy(output_env, &env, sizeof(ptm_atomicenv_t));
}
if (res.ref_struct == NULL)
return PTM_NO_ERROR;
}
ptm_atomicenv_t* res_env = &env;
if (res.ref_struct->type == PTM_MATCH_DCUB || res.ref_struct->type == PTM_MATCH_DHEX)
......
......@@ -81,21 +81,26 @@ void GrainSegmentationEngine::perform()
******************************************************************************/
bool GrainSegmentationEngine::identifyAtomicStructures()
{
// Initialize the PTMAlgorithm object.
boost::optional<PTMAlgorithm> _algorithm;
_algorithm.emplace();
_algorithm->setRmsdCutoff(0.0); // Note: We do our own RMSD threshold filtering in postProcessStructureTypes().
// Specify the structure types the PTM should look for.
for(int i = 0; i < typesToIdentify().size() && i < PTMAlgorithm::NUM_STRUCTURE_TYPES; i++) {
_algorithm->setStructureTypeIdentification(static_cast<PTMAlgorithm::StructureType>(i), typesToIdentify()[i]);
}
// Initialize the algorithm object.
if(!_algorithm->prepare(*positions(), cell(), selection().get(), task().get()))
return false;
// Initialize the neighbor finder for disordered atoms
// Don't need more than 12 neighbors for defect atoms.
#define MAX_DISORDERED_NEIGHBORS 12
NearestNeighborFinder neighFinder(MAX_DISORDERED_NEIGHBORS);
if(!neighFinder.prepare(*positions(), cell(), selection().get(), task().get()))
return false;
task()->setProgressValue(0);
task()->setProgressMaximum(positions()->size());
task()->setProgressText(GrainSegmentationModifier::tr("Pre-calculating neighbor ordering"));
......@@ -139,11 +144,14 @@ bool GrainSegmentationEngine::identifyAtomicStructures()
// Perform analysis on each particle.
parallelForChunks(positions()->size(), *task(), [this, &cachedNeighbors, &_algorithm](size_t startIndex, size_t count, Task& task) {
parallelForChunks(positions()->size(), *task(), [this, &cachedNeighbors, &_algorithm, &neighFinder](size_t startIndex, size_t count, Task& task) {
// Create a thread-local kernel for the PTM algorithm.
PTMAlgorithm::Kernel kernel(*_algorithm);
// Create a neighbor query for disordered atoms
NearestNeighborFinder::Query<MAX_DISORDERED_NEIGHBORS> neighQuery(neighFinder);
//size_t startIndex = 0, count = positions()->size();
// Loop over input particles.
size_t endIndex = startIndex + count;
......@@ -199,10 +207,12 @@ bool GrainSegmentationEngine::identifyAtomicStructures()
else {
rmsd()->setFloat(index, 0);
// Store neighbor list. Don't need more than 12 neighbors for defect atoms.
int numNeighbors = std::min(kernel._env.num - 1, 12);
neighQuery.findNeighbors(index);
int numNeighbors = neighQuery.results().size();
// Store neighbor list.
for(int j = 0; j < numNeighbors; j++) {
_neighborLists->setInt64Component(index, j, kernel._env.atom_indices[j + 1]);
_neighborLists->setInt64Component(index, j, neighQuery.results()[j].index);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment