Changeset 86234b for src/boundary.cpp


Ignore:
Timestamp:
Jul 9, 2009, 9:45:00 AM (15 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:
542ab3
Parents:
018741
Message:

BUGFIX: Memory leak due to special triangles and similar lines in BoundaryPointSet::lines multimap, corrected some output messages, AddTriangleToLines()->AddTriangle()

  • BUGFIX: destructor of BoundaryLineSet erases in the BoundaryPointSet::lines _all_ lines with key endpoints[i]->Nr instead of just the one line we are just removing (note: due to degenerated triangles, there may be more than one line with the same endpoints, the key in LineMap however is just the endpoint number). Now, we do equal_range and check whether the line === this.
  • BoundaryPointSet::AddLine() has more sensible message, stating that line is added to a point not other wat round
  • some identation and automated line wraps fixed
  • AddTriangleToLines() renamed to AddTriangle(), as the triangle to line adding is done in the triangles constructor. Here, we just add the triangle to tesselation class' global list
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r018741 r86234b  
    88
    99#define DEBUG 1
    10 #define DoSingleStepOutput 1
     10#define DoSingleStepOutput 0
    1111#define DoTecplotOutput 1
    12 #define DoRaster3DOutput 1
     12#define DoRaster3DOutput 0
    1313#define DoVRMLOutput 1
    1414#define TecplotSuffix ".dat"
     
    4545void BoundaryPointSet::AddLine(class BoundaryLineSet *line)
    4646{
    47   cout << Verbose(6) << "Adding " << *this << " to line " << *line << "."
    48       << endl;
     47  cout << Verbose(6) << "Adding line " << *line << " to " << *this << "." << endl;
    4948  if (line->endpoints[0] == this)
    5049    {
     
    10099  for (int i = 0; i < 2; i++) {
    101100    cout << Verbose(5) << "Erasing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
    102     endpoints[i]->lines.erase(Numbers[i]);
     101    // as there may be multiple lines with same endpoints, we have to go through each and find in the endpoint's line list this line set
     102    pair<LineMap::iterator, LineMap::iterator> erasor = endpoints[i]->lines.equal_range(Numbers[i]);
     103    for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
     104      if ((*Runner).second == this) {
     105        endpoints[i]->lines.erase(Runner);
     106        break;
     107      }
    103108    if (endpoints[i]->lines.empty()) {
    104109      cout << Verbose(5) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;
     
    196201    lines[i]->triangles.erase(Nr);
    197202    if (lines[i]->triangles.empty()) {
    198       cout << Verbose(5) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
    199203      if (lines[i] != NULL) {
     204        cout << Verbose(5) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
    200205        delete (lines[i]);
    201206        lines[i] = NULL;
     
    203208        cerr << "ERROR: This line " << i << " has already been free'd." << endl;
    204209    } else
    205       cout << Verbose(5) << *lines[i] << " is still attached to a triangle." << endl;
     210      cout << Verbose(5) << *lines[i] << " is still attached to another triangle." << endl;
    206211  }
    207212}
     
    14711476  TPS[n] = new class BoundaryPointSet(Candidate);
    14721477  InsertUnique = PointsOnBoundary.insert(PointPair(Candidate->nr, TPS[n]));
    1473   if (InsertUnique.second) // if new point was not present before, increase counter
    1474     {
    1475       PointsOnBoundaryCount++;
    1476     }
    1477   else
    1478     {
    1479       delete TPS[n];
    1480       cout << Verbose(2) << "Atom " << *((InsertUnique.first)->second->node)
    1481           << " gibt's schon in der PointMap." << endl;
    1482       TPS[n] = (InsertUnique.first)->second;
    1483     }
     1478  if (InsertUnique.second) { // if new point was not present before, increase counter
     1479    PointsOnBoundaryCount++;
     1480  } else {
     1481    delete TPS[n];
     1482    cout << Verbose(2) << "Atom " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl;
     1483    TPS[n] = (InsertUnique.first)->second;
     1484  }
    14841485}
    14851486;
     
    15041505      if (FindLine->second->TrianglesCount < 2) {
    15051506        insertNewLine = false;
    1506         cout << Verbose(2)
    1507         << "Using existing line " << *FindLine->second << endl;
     1507        cout << Verbose(2) << "Using existing line " << *FindLine->second << endl;
    15081508
    15091509        BPS[0] = FindLine->second->endpoints[0];
     
    15321532void Tesselation::AlwaysAddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n)
    15331533{
    1534   cout << Verbose(2)
    1535     << "Adding line which has not been used before between "
    1536     << *(a->node) << " and " << *(b->node) << "." << endl;
     1534  cout << Verbose(2) << "Adding line between " << *(a->node) << " and " << *(b->node) << "." << endl;
    15371535  BPS[0] = a;
    15381536  BPS[1] = b;
    1539   BLS[n] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1540 
     1537  BLS[n] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);  // this also adds the line to the local maps
     1538  // add line to global map
    15411539  LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BLS[n]));
     1540  // increase counter
    15421541  LinesOnBoundaryCount++;
    15431542};
     
    15471546 */
    15481547void
    1549 Tesselation::AddTriangleToLines()
    1550 {
    1551 
    1552   cout << Verbose(1) << "Adding triangle to its lines" << endl;
    1553   int i = 0;
     1548Tesselation::AddTriangle()
     1549{
     1550  cout << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;
     1551
     1552  // add triangle to global map
    15541553  TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
    15551554  TrianglesOnBoundaryCount++;
    15561555
    1557   /*
    1558    * this is apparently done when constructing triangle
    1559 
    1560    for (i=0; i<3; i++)
    1561    {
    1562    BLS[i]->AddTriangle(BTS);
    1563    }
    1564    */
     1556  // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet
    15651557}
    15661558;
     
    28682860          // ... and triangles to the Maps of the Tesselation class
    28692861          BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    2870           AddTriangleToLines();
     2862          AddTriangle();
    28712863          // ... and calculate its normal vector (with correct orientation)
    28722864          (*it)->OptCenter.Scale(-1.);
     
    29212913    }
    29222914  if (counter > 1) {
    2923     cout << Verbose(2) << "INFO: Degenerate triangle is ok, there is only at most " << counter << " new line needed." << endl;
     2915    cout << Verbose(2) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl;
    29242916    result = true;
    29252917  }
     
    30503042
    30513043      BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    3052       AddTriangleToLines();
     3044      AddTriangle();
    30533045      (*it)->OptCenter.Scale(-1.);
    30543046      BTS->GetNormalVector((*it)->OptCenter);
     
    30713063
    30723064          BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    3073           //TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
    3074           AddTriangleToLines();
     3065          AddTriangle();
    30753066
    30763067          (*it)->OtherOptCenter.Scale(-1.);
Note: See TracChangeset for help on using the changeset viewer.