Changeset bdc91e


Ignore:
Timestamp:
Jul 1, 2010, 2:33:13 PM (14 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
edb454
Parents:
8e0c63
git-author:
Frederik Heber <heber@…> (07/01/10 14:26:41)
git-committer:
Frederik Heber <heber@…> (07/01/10 14:33:13)
Message:

MEMFIXES: Tesselation routines were leaking memory.

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

Location:
src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AnalysisAction/MolecularVolumeAction.cpp

    r8e0c63 rbdc91e  
    4747    LCList = new LinkedCell(mol, 10.);
    4848    config * const configuration = World::getInstance().getConfig();
    49     //FindConvexBorder(mol, LCList, argv[argptr]);
     49    Boundaries *BoundaryPoints = NULL;
     50    //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
    5051    FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL);
    5152    //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
  • src/Actions/TesselationAction/ConvexEnvelopeAction.cpp

    r8e0c63 rbdc91e  
    7070    DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl);
    7171    LCList = new LinkedCell(mol, 100.);
    72     //FindConvexBorder(mol, LCList, argv[argptr]);
     72    Boundaries *BoundaryPoints = NULL;
     73    //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
    7374    // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests
    7475    FindNonConvexBorder(mol, TesselStruct, LCList, 50., filenameNonConvex.c_str());
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    r8e0c63 rbdc91e  
    6969        Repeater[axis] = 1;
    7070      }
    71       cell_size[(abs(axis+1) == 2) ? 2 : ((abs(axis+2) == 3) ? 5 : 0)] *= Repeater[axis];
     71      cell_size[ ((axis == 1) ? 2 : (axis == 2) ? 5 : 0) ] *= Repeater[axis];
    7272    }
    7373
  • src/Legacy/oldmenu.cpp

    r8e0c63 rbdc91e  
    576576        const LinkedCell *LCList = NULL;
    577577        LCList = new LinkedCell(mol, 10.);
    578         FindConvexBorder(mol, TesselStruct, LCList, NULL);
     578        Boundaries *BoundaryPoints = NULL;
     579        FindConvexBorder(mol, BoundaryPoints TesselStruct, LCList, NULL);
    579580        double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
    580581        Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
  • src/boundary.cpp

    r8e0c63 rbdc91e  
    296296 * \param *out output stream for debugging
    297297 * \param *mol molecule structure with Atom's and Bond's.
     298 * \param *BoundaryPts set of boundary points to use or NULL
    298299 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
    299300 * \param *LCList atoms in LinkedCell list
     
    301302 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename.
    302303 */
    303 void FindConvexBorder(const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
     304void FindConvexBorder(const molecule* mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
    304305{
    305306        Info FunctionInfo(__func__);
     
    312313
    313314  // 1. Find all points on the boundary
    314   if (BoundaryPoints == NULL) {
    315       BoundaryFreeFlag = true;
    316       BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
     315  if (BoundaryPts == NULL) {
     316    BoundaryFreeFlag = true;
     317    BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    317318  } else {
    318       DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
     319    BoundaryPoints = BoundaryPts;
     320    DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    319321  }
    320322
    321323// printing all inserted for debugging
    322   for (int axis=0; axis < NDIM; axis++)
    323     {
    324       DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
    325       int i=0;
    326       for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    327         if (runner != BoundaryPoints[axis].begin())
    328           DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
    329         else
    330           DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
    331         i++;
    332       }
    333       DoLog(0) && (Log() << Verbose(0) << endl);
    334     }
     324  for (int axis=0; axis < NDIM; axis++) {
     325    DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
     326    int i=0;
     327    for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
     328      if (runner != BoundaryPoints[axis].begin())
     329        DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
     330      else
     331        DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
     332      i++;
     333    }
     334    DoLog(0) && (Log() << Verbose(0) << endl);
     335  }
    335336
    336337  // 2. fill the boundary point list
     
    338339    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
    339340        if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0))
    340           DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl);
     341          DoLog(2) && (Log()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present." << endl);
    341342
    342343  DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl);
     
    672673
    673674  IsAngstroem = configuration->GetIsAngstroem();
     675  BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    674676  GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    675   BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    676677  LinkedCell *LCList = new LinkedCell(mol, 10.);
    677   FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL);
     678  FindConvexBorder(mol, BoundaryPoints, TesselStruct, (const LinkedCell *&)LCList, NULL);
    678679  delete (LCList);
     680  delete[] BoundaryPoints;
    679681
    680682
     
    684686  else
    685687    clustervolume = ClusterVolume;
     688
     689  delete TesselStruct;
    686690
    687691  for (int i = 0; i < NDIM; i++)
     
    736740    mol->CenterInBox();
    737741  }
     742  delete GreatestDiameter;
    738743  // update Box of atoms by boundary
    739744  mol->SetBoxDimension(&BoxLengths);
     
    892897            }
    893898      }
     899  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
     900    delete LCList[*ListRunner];
     901    delete TesselStruct[(*ListRunner)];
     902  }
    894903  delete[](M);
    895904  delete[](MInverse);
  • src/boundary.hpp

    r8e0c63 rbdc91e  
    5050double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
    5151molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);
    52 void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
     52void FindConvexBorder(const molecule* const mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
    5353Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol);
    5454void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);
  • src/linkedcell.cpp

    r8e0c63 rbdc91e  
    187187    N[i] = 0;
    188188  index = -1;
    189   max.Zero();
    190   min.Zero();
    191189};
    192190
     
    199197  for(int i=0;i<NDIM;i++)
    200198    status = status && ((n[i] >=0) && (n[i] < N[i]));
    201   if (!status)
    202   DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl);
     199//  if (!status)
     200//    DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl);
    203201  return status;
    204202};
     
    279277
    280278/** Calculates the interval bounds of the linked cell grid.
    281  * \param *lower lower bounds
    282  * \param *upper upper bounds
     279 * \param lower lower bounds
     280 * \param upper upper bounds
    283281 * \param step how deep to check the neighbouring cells (i.e. number of layers to check)
    284282 */
     
    286284{
    287285  for (int i=0;i<NDIM;i++) {
    288     lower[i] = n[i];
    289     for (int s=step; s>0;--s)
    290       if ((n[i]-s) >= 0) {
    291         lower[i] = n[i]-s;
    292         break;
    293       }
    294     upper[i] = n[i];
    295     for (int s=step; s>0;--s)
    296       if ((n[i]+s) < N[i]) {
    297         upper[i] = n[i]+s;
    298         break;
    299       }
     286    lower[i] = n[i]-step;
     287    if (lower[i] < 0)
     288      lower[i] = 0;
     289    if (lower[i] >= N[i])
     290      lower[i] = N[i]-1;
     291    upper[i] = n[i]+step;
     292    if (upper[i] >= N[i])
     293      upper[i] = N[i]-1;
     294    if (upper[i] < 0)
     295      upper[i] = 0;
    300296    //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl;
    301297  }
  • src/molecule_geometry.cpp

    r8e0c63 rbdc91e  
    120120      Center += (*iter)->x;
    121121    }
    122     Center.Scale(-1./Num); // divide through total number (and sign for direction)
     122    Center.Scale(-1./(double)Num); // divide through total number (and sign for direction)
    123123    Translate(&Center);
    124124    Center.Zero();
     
    142142      (*a) += (*iter)->x;
    143143    }
    144     a->Scale(1./Num); // divide through total mass (and sign for direction)
     144    a->Scale(1./(double)Num); // divide through total mass (and sign for direction)
    145145  }
    146146  return a;
     
    181181      (*a) += tmp;
    182182    }
    183     a->Scale(1./Num); // divide through total mass (and sign for direction)
     183    a->Scale(1./Num); // divide through total mass
    184184  }
    185185//  Log() << Verbose(1) << "Resulting center of gravity: ";
  • src/tesselation.cpp

    r8e0c63 rbdc91e  
    16481648  bool AddFlag = false;
    16491649  LinkedCell *BoundaryPoints = NULL;
     1650  bool SuccessFlag = true;
    16501651
    16511652  cloud->GoToFirst();
     
    16611662    // get the next triangle
    16621663    triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints);
    1663     BTS = triangles->front();
    1664     if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
     1664    if (triangles != NULL)
     1665      BTS = triangles->front();
     1666    else
     1667      BTS = NULL;
     1668    delete triangles;
     1669    if ((BTS == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
    16651670      DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl);
    16661671      cloud->GoToNext();
     
    17321737    } else { // something is wrong with FindClosestTriangleToPoint!
    17331738      DoeLog(1) && (eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl);
    1734       return false;
     1739      SuccessFlag = false;
     1740      break;
    17351741    }
    17361742    cloud->GoToNext();
     
    17391745  // exit
    17401746  delete (Center);
    1741   return true;
     1747  delete (BoundaryPoints);
     1748  return SuccessFlag;
    17421749}
    17431750;
     
    22422249  for (int i = 0; i < NDIM; i++) { // each axis
    22432250    LC->n[i] = LC->N[i] - 1; // current axis is topmost cell
    2244     for (LC->n[(i + 1) % NDIM] = 0; LC->n[(i + 1) % NDIM] < LC->N[(i + 1) % NDIM]; LC->n[(i + 1) % NDIM]++)
    2245       for (LC->n[(i + 2) % NDIM] = 0; LC->n[(i + 2) % NDIM] < LC->N[(i + 2) % NDIM]; LC->n[(i + 2) % NDIM]++) {
     2251    const int map[NDIM] = {i, (i + 1) % NDIM, (i + 2) % NDIM};
     2252    for (LC->n[map[1]] = 0; LC->n[map[1]] < LC->N[map[1]]; LC->n[map[1]]++)
     2253      for (LC->n[map[2]] = 0; LC->n[map[2]] < LC->N[map[2]]; LC->n[map[2]]++) {
    22462254        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    22472255        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    22482256        if (List != NULL) {
    22492257          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    2250             if ((*Runner)->node->at(i) > maxCoordinate[i]) {
    2251               DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl);
    2252               maxCoordinate[i] = (*Runner)->node->at(i);
    2253               MaxPoint[i] = (*Runner);
     2258            if ((*Runner)->node->at(map[0]) > maxCoordinate[map[0]]) {
     2259              DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl);
     2260              maxCoordinate[map[0]] = (*Runner)->node->at(map[0]);
     2261              MaxPoint[map[0]] = (*Runner);
    22542262            }
    22552263          }
  • src/tesselationhelpers.cpp

    r8e0c63 rbdc91e  
    589589          }
    590590        } else {
    591           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << ","
    592             << LC->n[2] << " is invalid!" << endl;
     591          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
    593592        }
    594593      }
     
    645644          }
    646645        } else {
    647           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << ","
    648             << LC->n[2] << " is invalid!" << endl;
     646          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
    649647        }
    650648      }
  • src/triangleintersectionlist.cpp

    r8e0c63 rbdc91e  
    1010
    1111#include "Helpers/MemDebug.hpp"
     12
     13#include <boost/scoped_ptr.hpp>
    1214
    1315#include "triangleintersectionlist.hpp"
     
    118120
    119121  // get closest points
    120   DistanceToPointMap * points = Tess->FindClosestBoundaryPointsToVector(Point,Vicinity);
     122  boost::scoped_ptr< DistanceToPointMap > points(Tess->FindClosestBoundaryPointsToVector(Point,Vicinity));
    121123  if (points == NULL) {
    122124    DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
Note: See TracChangeset for help on using the changeset viewer.