Changeset d30402 for src/boundary.cpp


Ignore:
Timestamp:
Jul 27, 2009, 8:16:03 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:
a20e6a
Parents:
36ec71
Message:

Split VolumeOfConvexEnvelope() into find_convex_border() and remainder.

  • Convex envelope is not working anymore, in the state of fixing it and trying to refactor code a bit.
  • planned to have VolumeOfConvexEnvelope() to be replaced by VolumeOfEnvelope(), which can also do Non-Convex-Envelopes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r36ec71 rd30402  
    760760}
    761761
    762 /** Determines the volume of a cluster.
    763  * Determines first the convex envelope, then tesselates it and calculates its volume.
     762/** Tesselates the convex boundary by finding all boundary points.
    764763 * \param *out output stream for debugging
     764 * \param *mol molecule structure with Atom's and Bond's
     765 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
     766 * \param *LCList atoms in LinkedCell list
    765767 * \param *filename filename prefix for output of vertex data
    766  * \param *configuration needed for path to store convex envelope file
    767  * \param *BoundaryPoints NDIM set of boundary points on the projected plane per axis, on return if desired
    768  * \param *mol molecule structure representing the cluster
    769  * \return determined volume of the cluster in cubed config:GetIsAngstroem()
    770  */
    771 double
    772 VolumeOfConvexEnvelope(ofstream *out, const char *filename, config *configuration,
    773     Boundaries *BoundaryPtr, molecule *mol)
    774 {
    775   bool IsAngstroem = configuration->GetIsAngstroem();
     768 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename.
     769 */
     770void Find_convex_border(ofstream *out, molecule* mol, class Tesselation *&TesselStruct, class LinkedCell *LCList, const char *filename)
     771{
    776772  atom *Walker = NULL;
    777   struct Tesselation *TesselStruct = new Tesselation;
    778773  bool BoundaryFreeFlag = false;
    779   Boundaries *BoundaryPoints = BoundaryPtr;
    780   double volume = 0.;
    781   double PyramidVolume = 0.;
    782   double G, h;
    783   Vector x, y;
    784   double a, b, c;
    785 
    786   //Find_non_convex_border(out, tecplot, *TesselStruct, mol); // Is now called from command line.
     774  Boundaries *BoundaryPoints = NULL;
     775
     776  if (TesselStruct != NULL) // free if allocated
     777    delete(TesselStruct);
     778  TesselStruct = new class Tesselation;
    787779
    788780  // 1. calculate center of gravity
     
    793785  *out << Verbose(1) << "Translating system to Center of Gravity." << endl;
    794786  Walker = mol->start;
    795   while (Walker->next != mol->end)
    796     {
    797       Walker = Walker->next;
    798       Walker->x.Translate(CenterOfGravity);
    799     }
     787  while (Walker->next != mol->end) {
     788    Walker = Walker->next;
     789    Walker->x.Translate(CenterOfGravity);
     790  }
    800791
    801792  // 3. Find all points on the boundary
    802   if (BoundaryPoints == NULL)
    803     {
     793  if (BoundaryPoints == NULL) {
    804794      BoundaryFreeFlag = true;
    805795      BoundaryPoints = GetBoundaryPoints(out, mol);
    806     }
    807   else
    808     {
     796  } else {
    809797      *out << Verbose(1) << "Using given boundary points set." << endl;
    810     }
     798  }
    811799
    812800  // 4. fill the boundary point list
    813801  for (int axis = 0; axis < NDIM; axis++)
    814     for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner
    815         != BoundaryPoints[axis].end(); runner++)
    816       {
     802    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
    817803        TesselStruct->AddPoint(runner->second.second);
    818       }
    819804
    820805  *out << Verbose(2) << "I found " << TesselStruct->PointsOnBoundaryCount
     
    833818
    834819  // 5b. go through all lines, that are not yet part of two triangles (only of one so far)
    835   TesselStruct->TesselateOnBoundary(out, configuration, mol);
     820  TesselStruct->TesselateOnBoundary(out, mol);
    836821
    837822  *out << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundaryCount
     
    839824      << " lines and " << TesselStruct->PointsOnBoundaryCount << " points."
    840825      << endl;
     826
     827  // 6. translate all points back from CoG
     828  *out << Verbose(1) << "Translating system back from Center of Gravity."
     829      << endl;
     830  CenterOfGravity->Scale(-1);
     831  Walker = mol->start;
     832  while (Walker->next != mol->end)
     833    {
     834      Walker = Walker->next;
     835      Walker->x.Translate(CenterOfGravity);
     836    }
     837
     838  // 7. Store triangles in tecplot file
     839  if (filename != NULL) {
     840    string OutputName(filename);
     841    OutputName.append(TecplotSuffix);
     842    ofstream *tecplot = new ofstream(OutputName.c_str());
     843    write_tecplot_file(out, tecplot, TesselStruct, mol, 0);
     844    tecplot->close();
     845    delete(tecplot);
     846    ofstream *rasterplot = new ofstream(OutputName.c_str());
     847    write_raster3d_file(out, rasterplot, TesselStruct, mol);
     848    rasterplot->close();
     849    delete(rasterplot);
     850  }
     851
     852  // free reference lists
     853  if (BoundaryFreeFlag)
     854    delete[] (BoundaryPoints);
     855
     856};
     857
     858
     859/** Determines the volume of a cluster.
     860 * Determines first the convex envelope, then tesselates it and calculates its volume.
     861 * \param *out output stream for debugging
     862 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
     863 * \param *configuration needed for path to store convex envelope file
     864 * \return determined volume of the cluster in cubed config:GetIsAngstroem()
     865 */
     866double
     867VolumeOfConvexEnvelope(ofstream *out, class Tesselation *TesselStruct, class config *configuration)
     868{
     869  bool IsAngstroem = configuration->GetIsAngstroem();
     870  double volume = 0.;
     871  double PyramidVolume = 0.;
     872  double G, h;
     873  Vector x, y;
     874  double a, b, c;
    841875
    842876  // 6a. Every triangle forms a pyramid with the center of gravity as its peak, sum up the volumes
     
    874908      << endl;
    875909
    876   // 7. translate all points back from CoG
    877   *out << Verbose(1) << "Translating system back from Center of Gravity."
    878       << endl;
    879   CenterOfGravity->Scale(-1);
    880   Walker = mol->start;
    881   while (Walker->next != mol->end)
    882     {
    883       Walker = Walker->next;
    884       Walker->x.Translate(CenterOfGravity);
    885     }
    886 
    887   // 8. Store triangles in tecplot file
    888   string OutputName(filename);
    889   OutputName.append(TecplotSuffix);
    890   ofstream *tecplot = new ofstream(OutputName.c_str());
    891   write_tecplot_file(out, tecplot, TesselStruct, mol, 0);
    892   tecplot->close();
    893   delete(tecplot);
    894 
    895   // free reference lists
    896   if (BoundaryFreeFlag)
    897     delete[] (BoundaryPoints);
    898 
    899910  return volume;
    900911}
     
    919930  bool IsAngstroem = configuration->GetIsAngstroem();
    920931  Boundaries *BoundaryPoints = GetBoundaryPoints(out, mol);
     932  class Tesselation *TesselStruct = NULL;
     933  LinkedCell LCList(mol, 10.);
     934  Find_convex_border(out, mol, TesselStruct, &LCList, NULL);
    921935  double clustervolume;
    922936  if (ClusterVolume == 0)
    923     clustervolume = VolumeOfConvexEnvelope(out, NULL, configuration,
    924         BoundaryPoints, mol);
     937    clustervolume = VolumeOfConvexEnvelope(out, TesselStruct, configuration);
    925938  else
    926939    clustervolume = ClusterVolume;
    927   double *GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, mol,
    928       IsAngstroem);
     940  double *GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, mol, IsAngstroem);
    929941  Vector BoxLengths;
    930942  int repetition[NDIM] =
     
    12291241 */
    12301242void
    1231 Tesselation::TesselateOnBoundary(ofstream *out, config *configuration,
    1232     molecule *mol)
     1243Tesselation::TesselateOnBoundary(ofstream *out, molecule *mol)
    12331244{
    12341245  bool flag;
     
    27922803 * \param *mol molecule structure with Atom's and Bond's
    27932804 * \param *Tess Tesselation filled with points, lines and triangles on boundary on return
     2805 * \param *LCList atoms in LinkedCell list
    27942806 * \param *filename filename prefix for output of vertex data
    27952807 * \para RADIUS radius of the virtual sphere
Note: See TracChangeset for help on using the changeset viewer.