Changeset 09898c


Ignore:
Timestamp:
Apr 12, 2010, 4:44:29 PM (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:
f8bd7d
Parents:
ffe885
git-author:
Frederik Heber <heber@…> (04/12/10 16:35:12)
git-committer:
Frederik Heber <heber@…> (04/12/10 16:44:29)
Message:

Changes to BoundaryTriangleSet and CandidateForTesselation.

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

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    rffe885 r09898c  
    326326 */
    327327BoundaryTriangleSet::BoundaryTriangleSet() :
     328  top(NULL),
     329  AngleFromTop(-1.),
    328330  Nr(-1)
    329331{
     
    341343 */
    342344BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) :
     345  top(NULL),
     346  AngleFromTop(-1.),
    343347  Nr(number)
    344348{
     
    393397  }
    394398  //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl;
     399};
     400
     401void BoundaryTriangleSet::SetTopNode(const BoundaryTriangleSet * const topnode)
     402{
     403  top = topnode;
    395404};
    396405
     
    9951004CandidateForTesselation::CandidateForTesselation (BoundaryLineSet* line) :
    9961005  BaseLine(line),
     1006  ThirdPoint(NULL),
     1007  T(NULL),
    9971008  ShortestAngle(2.*M_PI),
    9981009  OtherShortestAngle(2.*M_PI)
     
    10041015/** Constructor of class CandidateForTesselation.
    10051016 */
    1006 CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
     1017CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
    10071018    BaseLine(line),
     1019    ThirdPoint(point),
     1020    T(NULL),
    10081021    ShortestAngle(2.*M_PI),
    10091022    OtherShortestAngle(2.*M_PI)
     
    10171030 */
    10181031CandidateForTesselation::~CandidateForTesselation() {
    1019   BaseLine = NULL;
    10201032};
    10211033
     
    10281040bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell *LC) const
    10291041{
     1042  Info FunctionInfo(__func__);
     1043
    10301044  const double radiusSquared = RADIUS;
    10311045  list<const Vector *> VectorList;
    10321046  VectorList.push_back(&OptCenter);
    1033   VectorList.push_back(&OtherOptCenter);
    1034 
     1047  //VectorList.push_back(&OtherOptCenter);  // don't check the other (wrong) center
     1048
     1049  if (!pointlist.empty())
     1050    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list " << *(*pointlist.begin()) << " and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
     1051  else
     1052    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
    10351053  // check baseline for OptCenter and OtherOptCenter being on sphere's surface
    10361054  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
    10371055    for (int i=0;i<2;i++)
    10381056      if (fabs((*VRunner)->DistanceSquared(BaseLine->endpoints[i]->node->node) - radiusSquared) < MYEPSILON) {
    1039         DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << BaseLine->endpoints[i] << " is out of sphere at " << (*VRunner) << "." << endl);
     1057        DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << "." << endl);
    10401058        return false;
    10411059      }
     
    10471065    for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
    10481066      if (fabs((*VRunner)->DistanceSquared(Walker->node) - radiusSquared) < MYEPSILON) {
    1049         DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << Walker << " is out of sphere at " << (*VRunner) << "." << endl);
     1067        DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << Walker << " is out of sphere at " << *(*VRunner) << "." << endl);
    10501068        return false;
    10511069      }
     
    10531071  }
    10541072
    1055   // check for no other points being inside the sphere
     1073  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl);
    10561074  bool flag = true;
    10571075  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
    10581076    // get all points inside the sphere
    10591077    TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));
    1060     cout << Verbose(1) << "CheckValidity: There are " << ListofPoints->size() << " points inside the sphere at " << (*VRunner) << "." << endl;
    10611078    // remove baseline's endpoints and candidates
    10621079    for (int i=0;i<2;i++)
    10631080      ListofPoints->remove(BaseLine->endpoints[i]->node);
    1064     for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.begin(); ++Runner)
     1081    for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner)
    10651082      ListofPoints->remove(*Runner);
    10661083    if (!ListofPoints->empty()) {
     1084      cout << Verbose(1) << "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere." << endl;
    10671085      flag = false;
    1068       DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << (*VRunner) << ":" << endl);
    1069       for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->begin(); ++Runner)
    1070         DoeLog(1) && (eLog() << Verbose(1) << "  " << *Runner << endl);
     1086      DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl);
     1087      for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
     1088        DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << endl);
    10711089    }
    10721090    delete(ListofPoints);
     1091
     1092    // check with animate_sphere.tcl VMD script
     1093    if (ThirdPoint != NULL) {
     1094      cout << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr+1 << " " << BaseLine->endpoints[1]->Nr+1 << " " << ThirdPoint->Nr+1 << " " << RADIUS << " ";
     1095      cout << OldCenter.x[0] << " " << OldCenter.x[1] << " " << OldCenter.x[2] << " ";
     1096      cout << (*VRunner)->x[0] << " " << (*VRunner)->x[1] << " " << (*VRunner)->x[2] << endl;
     1097    } else {
     1098      cout << Verbose(1) << "Check by: ... missing third point ..." << endl;
     1099      cout << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr+1 << " " << BaseLine->endpoints[1]->Nr+1 << " ??? " << RADIUS << " ";
     1100      cout << OldCenter.x[0] << " " << OldCenter.x[1] << " " << OldCenter.x[2] << " ";
     1101      cout << (*VRunner)->x[0] << " " << (*VRunner)->x[1] << " " << (*VRunner)->x[2] << endl;
     1102    }
    10731103  }
    10741104  return flag;
     
    23622392  Vector SearchDirection;
    23632393  Vector helper;
    2364   TesselPoint *ThirdNode = NULL;
     2394  BoundaryPointSet *ThirdPoint = NULL;
    23652395  LineMap::iterator testline;
    23662396  double radius, CircleRadius;
    23672397
    23682398  for (int i=0;i<3;i++)
    2369     if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) {
    2370       ThirdNode = T.endpoints[i]->node;
     2399    if ((T.endpoints[i] != CandidateLine.BaseLine->endpoints[0]) && (T.endpoints[i] != CandidateLine.BaseLine->endpoints[1])) {
     2400      ThirdPoint = T.endpoints[i];
    23712401      break;
    23722402    }
    2373   Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdNode " << *ThirdNode << " of triangle " << T << "." << endl;
     2403  Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdPoint " << *ThirdPoint << " of triangle " << T << "." << endl;
     2404
     2405  CandidateLine.T = &T;
    23742406
    23752407  // construct center of circle
     
    23982430    SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal);
    23992431    helper.CopyVector(&CircleCenter);
    2400     helper.SubtractVector(ThirdNode->node);
     2432    helper.SubtractVector(ThirdPoint->node->node);
    24012433    if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
    24022434      SearchDirection.Scale(-1.);
     
    24082440
    24092441    // add third point
    2410     FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdNode, RADIUS, LC);
     2442    FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdPoint, RADIUS, LC);
    24112443
    24122444  } else {
     
    25192551  Vector Center;
    25202552  TesselPoint * const TurningPoint = CandidateLine.BaseLine->endpoints[0]->node;
     2553  TesselPointList::iterator Runner;
     2554  TesselPointList::iterator Sprinter;
    25212555
    25222556  // fill the set of neighbours
     
    25272561  TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->node);
    25282562
    2529   // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles)
    25302563  Log() << Verbose(0) << "List of Candidates for Turning Point " << *TurningPoint << ":" << endl;
    25312564  for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner)
    25322565    Log() << Verbose(0) << " " << **TesselRunner << endl;
    2533   TesselPointList::iterator Runner = connectedClosestPoints->begin();
    2534   TesselPointList::iterator Sprinter = Runner;
     2566
     2567  // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles)
     2568  Runner = connectedClosestPoints->begin();
     2569  Sprinter = Runner;
    25352570  Sprinter++;
    25362571  while(Sprinter != connectedClosestPoints->end()) {
     
    25492584    AddTesselationTriangle();
    25502585    BTS->GetCenter(&Center);
     2586    BTS->SetTopNode(CandidateLine.T);
     2587    if (CandidateLine.T != NULL)  // start triangle has angle from top of -1
     2588      BTS->AngleFromTop = CandidateLine.ShortestAngle;
     2589    else
     2590      BTS->AngleFromTop = -1.;
    25512591    Center.SubtractVector(&CandidateLine.OptCenter);
    25522592    BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter);
    25532593    BTS->GetNormalVector(Center);
    25542594
    2555     Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << "." << endl;
     2595    if (CandidateLine.T != NULL)
     2596      Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl;
     2597    else
     2598      Log() << Verbose(0) << "--> New starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl;
    25562599    Runner = Sprinter;
    25572600    Sprinter++;
     
    29462989 * @param OldSphereCenter center of sphere for base triangle, relative to center of BaseLine, giving null angle for the parameter circle
    29472990 * @param CandidateLine CandidateForTesselation with the current base line and list of candidates and ShortestAngle
    2948  * @param ThirdNode third point to avoid in search
     2991 * @param ThirdPoint third point to avoid in search
    29492992 * @param RADIUS radius of sphere
    29502993 * @param *LC LinkedCell structure with neighbouring points
    29512994 */
    2952 void Tesselation::FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const
     2995void Tesselation::FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet  * const ThirdPoint, const double RADIUS, const LinkedCell *LC) const
    29532996{
    29542997        Info FunctionInfo(__func__);
     
    29713014  Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl;
    29723015
     3016  // copy old center
     3017  CandidateLine.OldCenter.CopyVector(&OldSphereCenter);
     3018  CandidateLine.ThirdPoint = ThirdPoint;
     3019  CandidateLine.pointlist.clear();
     3020
    29733021  // construct center of circle
    29743022  CircleCenter.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
     
    29833031  RelativeOldSphereCenter.SubtractVector(&CircleCenter);
    29843032
    2985   // calculate squared radius TesselPoint *ThirdNode,f circle
     3033  // calculate squared radius TesselPoint *ThirdPoint,f circle
    29863034  radius = CirclePlaneNormal.NormSquared()/4.;
    29873035  if (radius < RADIUS*RADIUS) {
     
    30953143                      } else {
    30963144                        if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) {
    3097                           Log() << Verbose(1) << "REJECT: Old candidate " << *(CandidateLine.pointlist.begin()) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl;
     3145                          Log() << Verbose(1) << "REJECT: Old candidate " << *(*CandidateLine.pointlist.begin()) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl;
    30983146                        } else {
    30993147                          Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl;
     
    31073155                  }
    31083156                } else {
    3109                   if (ThirdNode != NULL) {
    3110                     Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdNode << " contains Candidate " << *Candidate << "." << endl;
     3157                  if (ThirdPoint != NULL) {
     3158                    Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdPoint << " contains Candidate " << *Candidate << "." << endl;
    31113159                  } else {
    31123160                    Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " contains Candidate " << *Candidate << "." << endl;
     
    31203168    }
    31213169  } else {
    3122     if (ThirdNode != NULL)
    3123       Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdNode << " is too big!" << endl;
     3170    if (ThirdPoint != NULL)
     3171      Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdPoint << " is too big!" << endl;
    31243172    else
    31253173      Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl;
    31263174  }
    31273175
    3128   DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list and baseline only ..." << endl);
    31293176  if (!CandidateLine.CheckValidity(RADIUS, LC)) {
    31303177    DoeLog(0) && (eLog() << Verbose(0) << "There were other points contained in the rolling sphere as well!" << endl);
  • src/tesselation.hpp

    rffe885 r09898c  
    4242
    4343#define DoTecplotOutput 1
    44 #define DoRaster3DOutput 0
     44#define DoRaster3DOutput 1
    4545#define DoVRMLOutput 0
    4646#define TecplotSuffix ".dat"
     
    163163    bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
    164164    bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
     165    void SetTopNode(const BoundaryTriangleSet * const topnode);
    165166
    166167    class BoundaryPointSet *endpoints[3];
    167168    class BoundaryLineSet *lines[3];
     169    const BoundaryTriangleSet *top; //!< triangle was instantiated during tesselation from this triangle
     170    double AngleFromTop;
    168171    Vector NormalVector;
    169172    Vector SphereCenter;
     
    249252  public :
    250253  CandidateForTesselation(BoundaryLineSet* currentBaseLine);
    251   CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
     254  CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
    252255  ~CandidateForTesselation();
    253256
     
    255258
    256259  TesselPointList pointlist;
    257   BoundaryLineSet *BaseLine;
     260  const BoundaryLineSet * BaseLine;
     261  const BoundaryPointSet * ThirdPoint;
     262  const BoundaryTriangleSet *T;
     263  Vector OldCenter;
    258264  Vector OptCenter;
    259265  Vector OtherOptCenter;
     
    289295    void FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
    290296    void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
    291     void FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const;
     297    void FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const;
    292298    bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
    293299    int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
Note: See TracChangeset for help on using the changeset viewer.