Changeset 0a4f7f for src/boundary.cpp


Ignore:
Timestamp:
Apr 7, 2010, 3:45:38 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
72e7fa
Parents:
f9352d
Message:

Made data internal data-structure of vector class private

  • Replaced occurences of access to internals with operator
  • moved Vector-class into LinAlg-Module
  • Reworked Vector to allow clean modularization
  • Added Plane class to describe arbitrary planes in 3d space
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    rf9352d r0a4f7f  
    1818#include "tesselation.hpp"
    1919#include "tesselationhelpers.hpp"
     20#include "Plane.hpp"
    2021
    2122#include<gsl/gsl_poly.h>
     
    8081              DistanceVector.SubtractVector(&Neighbour->second.second->x);
    8182              do { // seek for neighbour pair where it flips
    82                   OldComponent = DistanceVector.x[Othercomponent];
     83                  OldComponent = DistanceVector[Othercomponent];
    8384                  Neighbour++;
    8485                  if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
     
    8889                  //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
    8990                } while ((runner != Neighbour) && (fabs(OldComponent / fabs(
    90                   OldComponent) - DistanceVector.x[Othercomponent] / fabs(
    91                   DistanceVector.x[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
     91                  OldComponent) - DistanceVector[Othercomponent] / fabs(
     92                  DistanceVector[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
    9293              if (runner != Neighbour) {
    9394                  OtherNeighbour = Neighbour;
     
    102103                  //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;
    103104                  // do linear interpolation between points (is exact) to extract exact intersection between Neighbour and OtherNeighbour
    104                   w1 = fabs(OtherVector.x[Othercomponent]);
    105                   w2 = fabs(DistanceVector.x[Othercomponent]);
    106                   tmp = fabs((w1 * DistanceVector.x[component] + w2
    107                       * OtherVector.x[component]) / (w1 + w2));
     105                  w1 = fabs(OtherVector[Othercomponent]);
     106                  w2 = fabs(DistanceVector[Othercomponent]);
     107                  tmp = fabs((w1 * DistanceVector[component] + w2
     108                      * OtherVector[component]) / (w1 + w2));
    108109                  // mark if it has greater diameter
    109110                  //Log() << Verbose(1) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl;
     
    159160    AngleReferenceVector.Zero();
    160161    AngleReferenceNormalVector.Zero();
    161     AxisVector.x[axis] = 1.;
    162     AngleReferenceVector.x[(axis + 1) % NDIM] = 1.;
    163     AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.;
     162    AxisVector[axis] = 1.;
     163    AngleReferenceVector[(axis + 1) % NDIM] = 1.;
     164    AngleReferenceNormalVector[(axis + 2) % NDIM] = 1.;
    164165
    165166    Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
     
    636637      const double c = sqrt(runner->second->endpoints[2]->node->node->DistanceSquared(runner->second->endpoints[1]->node->node));
    637638      const double G = sqrt(((a + b + c) * (a + b + c) - 2 * (a * a + b * b + c * c)) / 16.); // area of tesselated triangle
    638       x.MakeNormalVector(runner->second->endpoints[0]->node->node, runner->second->endpoints[1]->node->node, runner->second->endpoints[2]->node->node);
     639      x = Plane(*(runner->second->endpoints[0]->node->node),
     640                *(runner->second->endpoints[1]->node->node),
     641                *(runner->second->endpoints[2]->node->node)).getNormal();
    639642      x.Scale(runner->second->endpoints[1]->node->node->ScalarProduct(&x));
    640643      const double h = x.Norm(); // distance of CoG to triangle
     
    751754    Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl;
    752755    for (int i = 0; i < NDIM; i++)
    753       BoxLengths.x[i] = GreatestDiameter[i];
     756      BoxLengths[i] = GreatestDiameter[i];
    754757    mol->CenterEdge(&BoxLengths);
    755758  } else {
    756     BoxLengths.x[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
    757     BoxLengths.x[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
    758     BoxLengths.x[2] = minimumvolume - cellvolume;
     759    BoxLengths[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
     760    BoxLengths[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
     761    BoxLengths[2] = minimumvolume - cellvolume;
    759762    double x0 = 0.;
    760763    double x1 = 0.;
    761764    double x2 = 0.;
    762     if (gsl_poly_solve_cubic(BoxLengths.x[0], BoxLengths.x[1], BoxLengths.x[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
     765    if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
    763766      Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;
    764767    else {
     
    769772    cellvolume = 1.;
    770773    for (int i = 0; i < NDIM; i++) {
    771       BoxLengths.x[i] = repetition[i] * (x0 + GreatestDiameter[i]);
    772       cellvolume *= BoxLengths.x[i];
     774      BoxLengths[i] = repetition[i] * (x0 + GreatestDiameter[i]);
     775      cellvolume *= BoxLengths[i];
    773776    }
    774777
     
    780783  // update Box of atoms by boundary
    781784  mol->SetBoxDimension(&BoxLengths);
    782   Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     785  Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths[0] << " and " << BoxLengths[1] << " and " << BoxLengths[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
    783786};
    784787
     
    839842  FillerDistance.InverseMatrixMultiplication(M);
    840843  for(int i=0;i<NDIM;i++)
    841     N[i] = (int) ceil(1./FillerDistance.x[i]);
     844    N[i] = static_cast<int>(ceil(1./FillerDistance[i]));
    842845  Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
    843846
     
    880883          // create molecule random translation vector ...
    881884          for (int i=0;i<NDIM;i++)
    882             FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     885            FillerTranslations[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    883886          Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl;
    884887
     
    892895            // create atomic random translation vector ...
    893896            for (int i=0;i<NDIM;i++)
    894               AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     897              AtomTranslations[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    895898
    896899            // ... and rotation matrix
Note: See TracChangeset for help on using the changeset viewer.