Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/analysis_correlation.cpp

    r014475 r112b09  
    1919#include "triangleintersectionlist.hpp"
    2020#include "vector.hpp"
    21 #include "Matrix.hpp"
    2221#include "verbose.hpp"
    2322#include "World.hpp"
    24 #include "Box.hpp"
    2523
    2624
    2725/** Calculates the pair correlation between given elements.
    2826 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    29  * \param *molecules list of molecules structure
    30  * \param &elements vector of elements to correlate
     27 * \param *out output stream for debugging
     28 * \param *molecules list of molecules structure
     29 * \param *type1 first element or NULL (if any element)
     30 * \param *type2 second element or NULL (if any element)
    3131 * \return Map of doubles with values the pair of the two atoms.
    3232 */
    33 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements)
     33PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2 )
    3434{
    3535  Info FunctionInfo(__func__);
    3636  PairCorrelationMap *outmap = NULL;
    3737  double distance = 0.;
    38   Box &domain = World::getInstance().getDomain();
    3938
    4039  if (molecules->ListOfMolecules.empty()) {
     
    4443  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    4544    (*MolWalker)->doCountAtoms();
    46 
    47   // create all possible pairs of elements
    48   set <pair<element *, element *> > PairsOfElements;
    49   if (elements.size() >= 2) {
    50     for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
    51       for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
    52         if (type1 != type2) {
    53           PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
    54           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
    55         }
    56   } else if (elements.size() == 1) { // one to all are valid
    57     element *elemental = *elements.begin();
    58     PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
    59     PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
    60   } else { // all elements valid
    61     PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
    62   }
    63 
    6445  outmap = new PairCorrelationMap;
    6546  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
     
    6950      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    7051        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    71         for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
    72           if ((*MolOtherWalker)->ActiveFlag) {
    73             DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    74             for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    75               DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    76               if ((*iter)->getId() < (*runner)->getId()){
    77                 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    78                   if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    79                     distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);
     52        if ((type1 == NULL) || ((*iter)->type == type1)) {
     53          for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
     54            if ((*MolOtherWalker)->ActiveFlag) {
     55              DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     56              for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     57                DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     58                if ((*iter)->getId() < (*runner)->getId()){
     59                  if ((type2 == NULL) || ((*runner)->type == type2)) {
     60                    distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  World::getInstance().getDomain());
    8061                    //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    8162                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    8263                  }
     64                }
    8365              }
    8466            }
     
    9375/** Calculates the pair correlation between given elements.
    9476 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    95  * \param *molecules list of molecules structure
    96  * \param &elements vector of elements to correlate
     77 * \param *out output stream for debugging
     78 * \param *molecules list of molecules structure
     79 * \param *type1 first element or NULL (if any element)
     80 * \param *type2 second element or NULL (if any element)
    9781 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
    9882 * \return Map of doubles with values the pair of the two atoms.
    9983 */
    100 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
     84PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )
    10185{
    10286  Info FunctionInfo(__func__);
     
    116100  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    117101    (*MolWalker)->doCountAtoms();
    118 
    119   // create all possible pairs of elements
    120   set <pair<element *, element *> > PairsOfElements;
    121   if (elements.size() >= 2) {
    122     for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
    123       for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
    124         if (type1 != type2) {
    125           PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
    126           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
    127         }
    128   } else if (elements.size() == 1) { // one to all are valid
    129     element *elemental = *elements.begin();
    130     PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
    131     PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
    132   } else { // all elements valid
    133     PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
    134   }
    135 
    136102  outmap = new PairCorrelationMap;
    137   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    138     if ((*MolWalker)->ActiveFlag) {
    139       Matrix FullMatrix = World::getInstance().getDomain().getM();
    140       Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     103  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     104    if ((*MolWalker)->ActiveFlag) {
     105      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
     106      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    141107      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    142       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    143108      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    144109        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    145         periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
    146         // go through every range in xyz and get distance
    147         for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    148           for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    149             for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    150               checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
    151               for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
    152                 if ((*MolOtherWalker)->ActiveFlag) {
    153                   DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    154                   for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    155                     DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    156                     if ((*iter)->getId() < (*runner)->getId()){
    157                       for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    158                         if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    159                           periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3
     110        if ((type1 == NULL) || ((*iter)->type == type1)) {
     111          periodicX = *(*iter)->node;
     112          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     113          // go through every range in xyz and get distance
     114          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     115            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     116              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     117                checkX = Vector(n[0], n[1], n[2]) + periodicX;
     118                checkX.MatrixMultiplication(FullMatrix);
     119                for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
     120                  if ((*MolOtherWalker)->ActiveFlag) {
     121                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     122                    for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     123                      DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     124                      if ((*iter)->nr < (*runner)->nr)
     125                        if ((type2 == NULL) || ((*runner)->type == type2)) {
     126                          periodicOtherX = *(*runner)->node;
     127                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    160128                          // go through every range in xyz and get distance
    161129                          for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
    162130                            for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
    163131                              for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
    164                                 checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX);
     132                                checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX;
     133                                checkOtherX.MatrixMultiplication(FullMatrix);
    165134                                distance = checkX.distance(checkOtherX);
    166135                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     
    168137                              }
    169138                        }
    170                     }
    171139                  }
    172                 }
    173140              }
    174141            }
    175       }
    176     }
    177   }
     142        }
     143      }
     144      delete[](FullMatrix);
     145      delete[](FullInverseMatrix);
     146    }
    178147
    179148  return outmap;
     
    181150
    182151/** Calculates the distance (pair) correlation between a given element and a point.
    183  * \param *molecules list of molecules structure
    184  * \param &elements vector of elements to correlate with point
     152 * \param *out output stream for debugging
     153 * \param *molecules list of molecules structure
     154 * \param *type element or NULL (if any element)
    185155 * \param *point vector to the correlation point
    186156 * \return Map of dobules with values as pairs of atom and the vector
    187157 */
    188 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point )
     158CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )
    189159{
    190160  Info FunctionInfo(__func__);
    191161  CorrelationToPointMap *outmap = NULL;
    192162  double distance = 0.;
    193   Box &domain = World::getInstance().getDomain();
    194163
    195164  if (molecules->ListOfMolecules.empty()) {
     
    205174      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    206175        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    207         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    208           if ((*type == NULL) || ((*iter)->type == *type)) {
    209             distance = domain.periodicDistance(*(*iter)->node,*point);
    210             DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    211             outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
    212           }
     176        if ((type == NULL) || ((*iter)->type == type)) {
     177          distance = (*iter)->node->PeriodicDistance(*point, World::getInstance().getDomain());
     178          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     179          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
     180        }
    213181      }
    214182    }
     
    218186
    219187/** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
    220  * \param *molecules list of molecules structure
    221  * \param &elements vector of elements to correlate to point
     188 * \param *out output stream for debugging
     189 * \param *molecules list of molecules structure
     190 * \param *type element or NULL (if any element)
    222191 * \param *point vector to the correlation point
    223192 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
    224193 * \return Map of dobules with values as pairs of atom and the vector
    225194 */
    226 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
     195CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )
    227196{
    228197  Info FunctionInfo(__func__);
     
    242211  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    243212    if ((*MolWalker)->ActiveFlag) {
    244       Matrix FullMatrix = World::getInstance().getDomain().getM();
    245       Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     213      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
     214      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    246215      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    247216      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    248217        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    249         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    250           if ((*type == NULL) || ((*iter)->type == *type)) {
    251             periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
    252             // go through every range in xyz and get distance
    253             for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    254               for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    255                 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    256                   checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
    257                   distance = checkX.distance(*point);
    258                   DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    259                   outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
    260                 }
    261           }
    262       }
     218        if ((type == NULL) || ((*iter)->type == type)) {
     219          periodicX = *(*iter)->node;
     220          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     221          // go through every range in xyz and get distance
     222          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     223            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     224              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     225                checkX = Vector(n[0], n[1], n[2]) + periodicX;
     226                checkX.MatrixMultiplication(FullMatrix);
     227                distance = checkX.distance(*point);
     228                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     229                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
     230              }
     231        }
     232      }
     233      delete[](FullMatrix);
     234      delete[](FullInverseMatrix);
    263235    }
    264236
     
    267239
    268240/** Calculates the distance (pair) correlation between a given element and a surface.
    269  * \param *molecules list of molecules structure
    270  * \param &elements vector of elements to correlate to surface
     241 * \param *out output stream for debugging
     242 * \param *molecules list of molecules structure
     243 * \param *type element or NULL (if any element)
    271244 * \param *Surface pointer to Tesselation class surface
    272245 * \param *LC LinkedCell structure to quickly find neighbouring atoms
    273246 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    274247 */
    275 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
     248CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )
    276249{
    277250  Info FunctionInfo(__func__);
     
    295268      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    296269        DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
    297         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    298           if ((*type == NULL) || ((*iter)->type == *type)) {
    299             TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
    300             distance = Intersections.GetSmallestDistance();
    301             triangle = Intersections.GetClosestTriangle();
    302             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
    303           }
     270        if ((type == NULL) || ((*iter)->type == type)) {
     271          TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
     272          distance = Intersections.GetSmallestDistance();
     273          triangle = Intersections.GetClosestTriangle();
     274          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
     275        }
    304276      }
    305277    } else {
     
    315287 * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into
    316288 * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane().
    317  * \param *molecules list of molecules structure
    318  * \param &elements vector of elements to correlate to surface
     289 * \param *out output stream for debugging
     290 * \param *molecules list of molecules structure
     291 * \param *type element or NULL (if any element)
    319292 * \param *Surface pointer to Tesselation class surface
    320293 * \param *LC LinkedCell structure to quickly find neighbouring atoms
     
    322295 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    323296 */
    324 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
     297CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    325298{
    326299  Info FunctionInfo(__func__);
     
    344317  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    345318    if ((*MolWalker)->ActiveFlag) {
    346       Matrix FullMatrix = World::getInstance().getDomain().getM();
    347       Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     319      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
     320      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    348321      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    349322      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    350323        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    351         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    352           if ((*type == NULL) || ((*iter)->type == *type)) {
    353             periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
    354             // go through every range in xyz and get distance
    355             ShortestDistance = -1.;
    356             for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    357               for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    358                 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    359                   checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
    360                   TriangleIntersectionList Intersections(&checkX,Surface,LC);
    361                   distance = Intersections.GetSmallestDistance();
    362                   triangle = Intersections.GetClosestTriangle();
    363                   if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    364                     ShortestDistance = distance;
    365                     ShortestTriangle = triangle;
    366                   }
     324        if ((type == NULL) || ((*iter)->type == type)) {
     325          periodicX = *(*iter)->node;
     326          periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3
     327          // go through every range in xyz and get distance
     328          ShortestDistance = -1.;
     329          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     330            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     331              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     332                checkX = Vector(n[0], n[1], n[2]) + periodicX;
     333                checkX.MatrixMultiplication(FullMatrix);
     334                TriangleIntersectionList Intersections(&checkX,Surface,LC);
     335                distance = Intersections.GetSmallestDistance();
     336                triangle = Intersections.GetClosestTriangle();
     337                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
     338                  ShortestDistance = distance;
     339                  ShortestTriangle = triangle;
    367340                }
    368             // insert
    369             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
    370             //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    371           }
    372       }
     341              }
     342          // insert
     343          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
     344          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     345        }
     346      }
     347      delete[](FullMatrix);
     348      delete[](FullInverseMatrix);
    373349    }
    374350
Note: See TracChangeset for help on using the changeset viewer.