Changeset e138de for src/ellipsoid.cpp


Ignore:
Timestamp:
Nov 4, 2009, 7:56:04 PM (16 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:
1614174, e5ad5c
Parents:
7326b2
Message:

Huge change from ofstream * (const) out --> Log().

  • first shift was done via regular expressions
  • then via error messages from the code
  • note that class atom, class element and class molecule kept in parts their output stream, was they print to file.
  • make check runs fine
  • MISSING: Verbosity is not fixed for everything (i.e. if no endl; is present and next has Verbose(0) ...)

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ellipsoid.cpp

    r7326b2 re138de  
    1616#include "ellipsoid.hpp"
    1717#include "linkedcell.hpp"
     18#include "log.hpp"
    1819#include "tesselation.hpp"
    1920#include "vector.hpp"
     
    3536  double psi,theta,phi; // euler angles in ZX'Z'' convention
    3637
    37   //cout << Verbose(3) << "Begin of SquaredDistanceToEllipsoid" << endl;
     38  //Log() << Verbose(3) << "Begin of SquaredDistanceToEllipsoid" << endl;
    3839
    3940  for(int i=0;i<3;i++)
     
    4445  helper.SubtractVector(&EllipsoidCenter);
    4546  RefPoint.CopyVector(&helper);
    46   //cout << Verbose(4) << "Translated given point is at " << RefPoint << "." << endl;
     47  //Log() << Verbose(4) << "Translated given point is at " << RefPoint << "." << endl;
    4748
    4849  // 2. transform coordinate system by inverse of rotation matrix and of diagonal matrix
     
    6162  helper.MatrixMultiplication(Matrix);
    6263  helper.Scale(InverseLength);
    63   //cout << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl;
     64  //Log() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl;
    6465
    6566  // 3. construct intersection point with unit sphere and ray between origin and x
    6667  helper.Normalize(); // is simply normalizes vector in distance direction
    67   //cout << Verbose(4) << "Transformed intersection is at " << helper << "." << endl;
     68  //Log() << Verbose(4) << "Transformed intersection is at " << helper << "." << endl;
    6869
    6970  // 4. transform back the constructed intersection point
     
    8283  Matrix[8] = cos(theta);
    8384  helper.MatrixMultiplication(Matrix);
    84   //cout << Verbose(4) << "Intersection is at " << helper << "." << endl;
     85  //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl;
    8586
    8687  // 5. determine distance between backtransformed point and x
    8788  distance = RefPoint.DistanceSquared(&helper);
    88   //cout << Verbose(4) << "Squared distance between intersection and RefPoint is " << distance << "." << endl;
     89  //Log() << Verbose(4) << "Squared distance between intersection and RefPoint is " << distance << "." << endl;
    8990
    9091  return distance;
    91   //cout << Verbose(3) << "End of SquaredDistanceToEllipsoid" << endl;
     92  //Log() << Verbose(3) << "End of SquaredDistanceToEllipsoid" << endl;
    9293};
    9394
     
    131132  }
    132133
    133   //cout << "Current summed distance is " << SumDistance << "." << endl;
     134  //Log() << Verbose(0) << "Current summed distance is " << SumDistance << "." << endl;
    134135  return SumDistance;
    135136};
     
    142143 * \return true - fit successful, false - fit impossible
    143144 */
    144 bool FitPointSetToEllipsoid(ofstream *out, Vector *set, int N, Vector *EllipsoidCenter, double *EllipsoidLength, double *EllipsoidAngle)
     145bool FitPointSetToEllipsoid(Vector *set, int N, Vector *EllipsoidCenter, double *EllipsoidLength, double *EllipsoidAngle)
    145146{
    146147  int status = GSL_SUCCESS;
    147   *out << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl;
     148  Log() << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl;
    148149  if (N >= 3) { // check that enough points are given (9 d.o.f.)
    149150    struct EllipsoidMinimisation par;
     
    198199          EllipsoidAngle[i] = gsl_vector_get (s->x, i+6);
    199200        }
    200         *out << setprecision(3) << Verbose(4) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl;
     201        Log() << Verbose(4) << setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl;
    201202      }
    202203
     
    208209
    209210  } else {
    210     *out << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl;
     211    Log() << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl;
    211212    return false;
    212213  }
    213   *out << Verbose(2) << "End of FitPointSetToEllipsoid" << endl;
     214  Log() << Verbose(2) << "End of FitPointSetToEllipsoid" << endl;
    214215  if (status == GSL_SUCCESS)
    215216    return true;
     
    225226 * \param PointsToPick number of points in set to pick
    226227 */
    227 void PickRandomNeighbouredPointSet(ofstream *out, class Tesselation *T, class LinkedCell *LC, Vector *&x, size_t PointsToPick)
     228void PickRandomNeighbouredPointSet(class Tesselation *T, class LinkedCell *LC, Vector *&x, size_t PointsToPick)
    228229{
    229230  size_t PointsLeft = 0;
     
    234235  int index;
    235236  TesselPoint *Candidate = NULL;
    236   *out << Verbose(2) << "Begin of PickRandomPointSet" << endl;
     237  Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl;
    237238
    238239  // allocate array
     
    240241    x = new Vector[PointsToPick];
    241242  } else {
    242     *out << "WARNING: Given pointer to vector array seems already allocated." << endl;
     243    eLog() << Verbose(2) << "WARNING: Given pointer to vector array seems already allocated." << endl;
    243244  }
    244245
     
    246247    for(int i=0;i<NDIM;i++) // pick three random indices
    247248      LC->n[i] = (rand() % LC->N[i]);
    248     *out << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... ";
     249    Log() << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... ";
    249250    // get random cell
    250251    const LinkedNodes *List = LC->GetCurrentCell();
     
    252253      continue;
    253254    }
    254     *out << "with No. " << LC->index << "." << endl;
    255 
    256     *out << Verbose(2) << "LC Intervals:";
     255    Log() << Verbose(2) << "with No. " << LC->index << "." << endl;
     256
     257    Log() << Verbose(2) << "LC Intervals:";
    257258    for (int i=0;i<NDIM;i++) {
    258259      Nlower[i] = ((LC->n[i]-1) >= 0) ? LC->n[i]-1 : 0;
    259260      Nupper[i] = ((LC->n[i]+1) < LC->N[i]) ? LC->n[i]+1 : LC->N[i]-1;
    260       *out << " [" << Nlower[i] << "," << Nupper[i] << "] ";
    261     }
    262     *out << endl;
     261      Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
     262    }
     263    Log() << Verbose(0) << endl;
    263264
    264265    // count whether there are sufficient atoms in this cell+neighbors
     
    270271          PointsLeft += List->size();
    271272        }
    272     *out << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl;
     273    Log() << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl;
    273274    if (PointsLeft < PointsToPick) {  // ensure that we can pick enough points in its neighbourhood at all.
    274275      continue;
     
    281282      current = PickedAtomNrs.find(index);  // not present?
    282283      if (current == PickedAtomNrs.end()) {
    283         //*out << Verbose(2) << "Picking atom nr. " << index << "." << endl;
     284        //Log() << Verbose(2) << "Picking atom nr. " << index << "." << endl;
    284285        PickedAtomNrs.insert(index);
    285286      }
     
    293294        for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    294295          const LinkedNodes *List = LC->GetCurrentCell();
    295 //          *out << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
     296//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    296297          if (List != NULL) {
    297298//            if (List->begin() != List->end())
    298 //              *out << Verbose(2) << "Going through candidates ... " << endl;
     299//              Log() << Verbose(2) << "Going through candidates ... " << endl;
    299300//            else
    300 //              *out << Verbose(2) << "Cell is empty ... " << endl;
     301//              Log() << Verbose(2) << "Cell is empty ... " << endl;
    301302            for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    302303              if ((current != PickedAtomNrs.end()) && (*current == index)) {
    303304                Candidate = (*Runner);
    304                 *out << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl;
     305                Log() << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl;
    305306                x[PointsPicked++].CopyVector(Candidate->node);    // we have one more atom picked
    306307                current++;    // next pre-picked atom
     
    309310            }
    310311//          } else {
    311 //            *out << Verbose(2) << "List for this index not allocated!" << endl;
     312//            Log() << Verbose(2) << "List for this index not allocated!" << endl;
    312313          }
    313314        }
    314     *out << Verbose(2) << "The following points were picked: " << endl;
     315    Log() << Verbose(2) << "The following points were picked: " << endl;
    315316    for (size_t i=0;i<PointsPicked;i++)
    316       *out << Verbose(2) << x[i] << endl;
     317      Log() << Verbose(2) << x[i] << endl;
    317318    if (PointsPicked == PointsToPick)  // break out of loop if we have all
    318319      break;
    319320  } while(1);
    320321
    321   *out << Verbose(2) << "End of PickRandomPointSet" << endl;
     322  Log() << Verbose(2) << "End of PickRandomPointSet" << endl;
    322323};
    323324
     
    328329 * \param PointsToPick number of points in set to pick
    329330 */
    330 void PickRandomPointSet(ofstream *out, class Tesselation *T, Vector *&x, size_t PointsToPick)
     331void PickRandomPointSet(class Tesselation *T, Vector *&x, size_t PointsToPick)
    331332{
    332333  size_t PointsLeft = (size_t) T->PointsOnBoundaryCount;
     
    334335  double value, threshold;
    335336  PointMap *List = &T->PointsOnBoundary;
    336   *out << Verbose(2) << "Begin of PickRandomPointSet" << endl;
     337  Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl;
    337338
    338339  // allocate array
     
    340341    x = new Vector[PointsToPick];
    341342  } else {
    342     *out << "WARNING: Given pointer to vector array seems already allocated." << endl;
     343    eLog() << Verbose(2) << "WARNING: Given pointer to vector array seems already allocated." << endl;
    343344  }
    344345
     
    347348      threshold = 1. - (double)(PointsToPick - PointsPicked)/(double)PointsLeft;
    348349      value = (double)rand()/(double)RAND_MAX;
    349       //*out << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": ";
     350      //Log() << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": ";
    350351      if (value > threshold) {
    351352        x[PointsPicked].CopyVector(Runner->second->node->node);
    352353        PointsPicked++;
    353         //*out << "IN." << endl;
     354        //Log() << Verbose(0) << "IN." << endl;
    354355      } else {
    355         //*out << "OUT." << endl;
     356        //Log() << Verbose(0) << "OUT." << endl;
    356357      }
    357358      PointsLeft--;
    358359    }
    359   *out << Verbose(2) << "The following points were picked: " << endl;
     360  Log() << Verbose(2) << "The following points were picked: " << endl;
    360361  for (size_t i=0;i<PointsPicked;i++)
    361     *out << Verbose(3) << x[i] << endl;
    362 
    363   *out << Verbose(2) << "End of PickRandomPointSet" << endl;
     362    Log() << Verbose(3) << x[i] << endl;
     363
     364  Log() << Verbose(2) << "End of PickRandomPointSet" << endl;
    364365};
    365366
     
    372373 * \param *filename name for output file
    373374 */
    374 void FindDistributionOfEllipsoids(ofstream *out, class Tesselation *T, class LinkedCell *LCList, int N, int number, const char *filename)
     375void FindDistributionOfEllipsoids(class Tesselation *T, class LinkedCell *LCList, int N, int number, const char *filename)
    375376{
    376377  ofstream output;
     
    381382  double EllipsoidAngle[3];
    382383  double distance, MaxDistance, MinDistance;
    383   *out << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl;
     384  Log() << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl;
    384385
    385386  // construct center of gravity of boundary point set for initial ellipsoid center
     
    388389    Center.AddVector(Runner->second->node->node);
    389390  Center.Scale(1./T->PointsOnBoundaryCount);
    390   *out << Verbose(1) << "Center is at " << Center << "." << endl;
     391  Log() << Verbose(1) << "Center is at " << Center << "." << endl;
    391392
    392393  // Output header
     
    396397  // loop over desired number of parameter sets
    397398  for (;number >0;number--) {
    398     *out << Verbose(1) << "Determining data set " << number << " ... " << endl;
     399    Log() << Verbose(1) << "Determining data set " << number << " ... " << endl;
    399400    // pick the point set
    400401    x = NULL;
    401     //PickRandomPointSet(out, T, LCList, x, N);
    402     PickRandomNeighbouredPointSet(out, T, LCList, x, N);
     402    //PickRandomPointSet(T, LCList, x, N);
     403    PickRandomNeighbouredPointSet(T, LCList, x, N);
    403404
    404405    // calculate some sensible starting values for parameter fit
     
    412413        MinDistance = distance;
    413414    }
    414     //*out << Verbose(2) << "MinDistance " << MinDistance << ", MaxDistance " << MaxDistance << "." << endl;
     415    //Log() << Verbose(2) << "MinDistance " << MinDistance << ", MaxDistance " << MaxDistance << "." << endl;
    415416    EllipsoidCenter.CopyVector(&Center);  // use Center of Gravity as initial center of ellipsoid
    416417    for (int i=0;i<3;i++)
     
    421422
    422423    // fit the parameters
    423     if (FitPointSetToEllipsoid(out, x, N, &EllipsoidCenter, &EllipsoidLength[0], &EllipsoidAngle[0])) {
    424       *out << Verbose(1) << "Picking succeeded!" << endl;
     424    if (FitPointSetToEllipsoid(x, N, &EllipsoidCenter, &EllipsoidLength[0], &EllipsoidAngle[0])) {
     425      Log() << Verbose(1) << "Picking succeeded!" << endl;
    425426      // output obtained parameter set
    426427      output << number << "\t";
     
    433434      output << endl;
    434435    } else { // increase N to pick one more
    435       *out << Verbose(1) << "Picking failed!" << endl;
     436      Log() << Verbose(1) << "Picking failed!" << endl;
    436437      number++;
    437438    }
     
    441442  output.close();
    442443
    443   *out << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl;
    444 };
     444  Log() << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl;
     445};
Note: See TracChangeset for help on using the changeset viewer.