Ignore:
Timestamp:
Apr 27, 2010, 2:25:42 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
90c4460
Parents:
1561e2 (diff), 2bc713 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'Analysis_PairCorrelation' into StructureRefactoring

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/World.cpp
molecuilder/src/World.hpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/log.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/periodentafel.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/Makefile.am
molecuilder/src/unittests/bondgraphunittest.cpp
molecuilder/src/unittests/gslvectorunittest.cpp
molecuilder/src/unittests/logunittest.cpp
molecuilder/src/unittests/tesselation_boundarytriangleunittest.hpp
molecuilder/src/vector.cpp
molecuilder/tests/Tesselations/defs.in

Conflicts have been many and too numerous to listen here, just the few general cases

  • new molecule() replaced by World::getInstance().createMolecule()
  • new atom() replaced by World::getInstance().createAtom() where appropriate.
  • Some DoLog()s added interfered with changes to the message produced by Log() << Verbose(.) << ...
  • DoLog() has been erroneously added to TestRunner.cpp as well, there cout is appropriate
  • ...

Additionally, there was a bug in atom::clone(), sort was set to atom::nr of the atom to clone not of the clone itself. This caused a failure of the fragmentation.

This merge has been fully checked from a clean build directory with subsequent configure,make all install and make check.
It configures, compiles and runs all test cases and the test suite without errors.

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/analysis_correlation.cpp

    r1561e2 r075729  
    1515#include "tesselation.hpp"
    1616#include "tesselationhelpers.hpp"
     17#include "triangleintersectionlist.hpp"
    1718#include "vector.hpp"
    1819#include "verbose.hpp"
     20#include "World.hpp"
    1921
    2022
     
    3436
    3537  if (molecules->ListOfMolecules.empty()) {
    36     eLog() << Verbose(1) <<"No molecule given." << endl;
     38    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    3739    return outmap;
    3840  }
     
    4042  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    4143    if ((*MolWalker)->ActiveFlag) {
    42       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    43       atom *Walker = (*MolWalker)->start;
    44       while (Walker->next != (*MolWalker)->end) {
    45         Walker = Walker->next;
    46         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     44      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     45      atom *Walker = (*MolWalker)->start;
     46      while (Walker->next != (*MolWalker)->end) {
     47        Walker = Walker->next;
     48        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    4749        if ((type1 == NULL) || (Walker->type == type1)) {
    4850          for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    4951            if ((*MolOtherWalker)->ActiveFlag) {
    50               Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
     52              DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    5153              atom *OtherWalker = (*MolOtherWalker)->start;
    5254              while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    5355                OtherWalker = OtherWalker->next;
    54                 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
     56                DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    5557                if (Walker->nr < OtherWalker->nr)
    5658                  if ((type2 == NULL) || (OtherWalker->type == type2)) {
    57                     distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);
     59                    distance = Walker->node->PeriodicDistance(OtherWalker->node, World::getInstance().getDomain());
    5860                    //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    5961                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     
    9092
    9193  if (molecules->ListOfMolecules.empty()) {
    92     eLog() << Verbose(1) <<"No molecule given." << endl;
     94    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    9395    return outmap;
    9496  }
     
    9698  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    9799    if ((*MolWalker)->ActiveFlag) {
    98       double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
     100      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    99101      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    100       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    101       atom *Walker = (*MolWalker)->start;
    102       while (Walker->next != (*MolWalker)->end) {
    103         Walker = Walker->next;
    104         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     102      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     103      atom *Walker = (*MolWalker)->start;
     104      while (Walker->next != (*MolWalker)->end) {
     105        Walker = Walker->next;
     106        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    105107        if ((type1 == NULL) || (Walker->type == type1)) {
    106108          periodicX.CopyVector(Walker->node);
     
    115117                for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    116118                  if ((*MolOtherWalker)->ActiveFlag) {
    117                     Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
     119                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    118120                    atom *OtherWalker = (*MolOtherWalker)->start;
    119121                    while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    120122                      OtherWalker = OtherWalker->next;
    121                       Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
     123                      DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    122124                      if (Walker->nr < OtherWalker->nr)
    123125                        if ((type2 == NULL) || (OtherWalker->type == type2)) {
     
    162164
    163165  if (molecules->ListOfMolecules.empty()) {
    164     Log() << Verbose(1) <<"No molecule given." << endl;
     166    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    165167    return outmap;
    166168  }
     
    168170  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    169171    if ((*MolWalker)->ActiveFlag) {
    170       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    171       atom *Walker = (*MolWalker)->start;
    172       while (Walker->next != (*MolWalker)->end) {
    173         Walker = Walker->next;
    174         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     172      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     173      atom *Walker = (*MolWalker)->start;
     174      while (Walker->next != (*MolWalker)->end) {
     175        Walker = Walker->next;
     176        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    175177        if ((type == NULL) || (Walker->type == type)) {
    176           distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);
    177           Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
     178          distance = Walker->node->PeriodicDistance(point, World::getInstance().getDomain());
     179          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    178180          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    179181        }
     
    202204
    203205  if (molecules->ListOfMolecules.empty()) {
    204     Log() << Verbose(1) <<"No molecule given." << endl;
     206    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    205207    return outmap;
    206208  }
     
    208210  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    209211    if ((*MolWalker)->ActiveFlag) {
    210       double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
     212      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    211213      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    213       atom *Walker = (*MolWalker)->start;
    214       while (Walker->next != (*MolWalker)->end) {
    215         Walker = Walker->next;
    216         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     214      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     215      atom *Walker = (*MolWalker)->start;
     216      while (Walker->next != (*MolWalker)->end) {
     217        Walker = Walker->next;
     218        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    217219        if ((type == NULL) || (Walker->type == type)) {
    218220          periodicX.CopyVector(Walker->node);
     
    226228                checkX.MatrixMultiplication(FullMatrix);
    227229                distance = checkX.Distance(point);
    228                 Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
     230                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    229231                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    230232              }
     
    255257
    256258  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
    257     Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
     259    DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    258260    return outmap;
    259261  }
     
    261263  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    262264    if ((*MolWalker)->ActiveFlag) {
    263       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    264       atom *Walker = (*MolWalker)->start;
    265       while (Walker->next != (*MolWalker)->end) {
    266         Walker = Walker->next;
    267         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     265      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
     266      atom *Walker = (*MolWalker)->start;
     267      while (Walker->next != (*MolWalker)->end) {
     268        Walker = Walker->next;
     269        //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl;
    268270        if ((type == NULL) || (Walker->type == type)) {
    269           triangle = Surface->FindClosestTriangleToVector(Walker->node, LC );
    270           if (triangle != NULL) {
    271             distance = DistanceToTrianglePlane(Walker->node, triangle);
    272             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
    273           }
    274         }
    275       }
    276     }
     271          TriangleIntersectionList Intersections(Walker->node,Surface,LC);
     272          distance = Intersections.GetSmallestDistance();
     273          triangle = Intersections.GetClosestTriangle();
     274          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     275        }
     276      }
     277    } else
     278      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
    277279
    278280  return outmap;
     
    304306
    305307  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
    306     Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
     308    DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    307309    return outmap;
    308310  }
     
    312314  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    313315    if ((*MolWalker)->ActiveFlag) {
    314       double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
     316      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    315317      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    316       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    317       atom *Walker = (*MolWalker)->start;
    318       while (Walker->next != (*MolWalker)->end) {
    319         Walker = Walker->next;
    320         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     318      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     319      atom *Walker = (*MolWalker)->start;
     320      while (Walker->next != (*MolWalker)->end) {
     321        Walker = Walker->next;
     322        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    321323        if ((type == NULL) || (Walker->type == type)) {
    322324          periodicX.CopyVector(Walker->node);
     
    330332                checkX.AddVector(&periodicX);
    331333                checkX.MatrixMultiplication(FullMatrix);
    332                 triangle = Surface->FindClosestTriangleToVector(&checkX, LC);
    333                 distance = Surface->GetDistanceSquaredToTriangle(checkX, triangle);
     334                TriangleIntersectionList Intersections(&checkX,Surface,LC);
     335                distance = Intersections.GetSmallestDistance();
     336                triangle = Intersections.GetClosestTriangle();
    334337                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    335338                  ShortestDistance = distance;
     
    338341              }
    339342          // insert
    340           ShortestDistance = sqrt(ShortestDistance);
    341343          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
    342344          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     
    350352};
    351353
    352 /** Returns the start of the bin for a given value.
     354/** Returns the index of the bin for a given value.
    353355 * \param value value whose bin to look for
    354356 * \param BinWidth width of bin
    355357 * \param BinStart first bin
    356358 */
    357 double GetBin ( const double value, const double BinWidth, const double BinStart )
    358 {
    359   Info FunctionInfo(__func__);
    360   double bin =(double) (floor((value - BinStart)/BinWidth));
    361   return (bin*BinWidth+BinStart);
     359int GetBin ( const double value, const double BinWidth, const double BinStart )
     360{
     361  Info FunctionInfo(__func__);
     362  int bin =(int) (floor((value - BinStart)/BinWidth));
     363  return (bin);
    362364};
    363365
     
    372374  *file << "BinStart\tCount" << endl;
    373375  for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    374     *file << runner->first << "\t" << runner->second << endl;
     376    *file << setprecision(8) << runner->first << "\t" << runner->second << endl;
    375377  }
    376378};
     
    385387  *file << "BinStart\tAtom1\tAtom2" << endl;
    386388  for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    387     *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
     389    *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
    388390  }
    389391};
     
    400402    *file << runner->first;
    401403    for (int i=0;i<NDIM;i++)
    402       *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]);
     404      *file << "\t" << setprecision(8) << (runner->second.first->node->x[i] - runner->second.second->x[i]);
    403405    *file << endl;
    404406  }
     
    413415  Info FunctionInfo(__func__);
    414416  *file << "BinStart\tTriangle" << endl;
    415   for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    416     *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
    417   }
    418 };
    419 
     417  if (!map->empty())
     418    for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
     419      *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
     420    }
     421};
     422
Note: See TracChangeset for help on using the changeset viewer.