Changeset a67d19 for src/vector.cpp


Ignore:
Timestamp:
Apr 22, 2010, 2:00:03 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:
299554
Parents:
6613ec
Message:

Huge change: Log() << Verbose(.) --> DoLog(.) && (Log() << Verbose(.) << ...);

Most of the files are affected, but this is necessary as if DoLog() says verbosity is not enough, all the stream operators won"t get executed which saves substantial amount of computation time.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    r6613ec ra67d19  
    253253  Direction.SubtractVector(Origin);
    254254  Direction.Normalize();
    255   Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
     255  DoLog(1) && (Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl);
    256256  //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl;
    257257  factor = Direction.ScalarProduct(PlaneNormal);
    258258  if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane?
    259     Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;
     259    DoLog(1) && (Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl);
    260260    return false;
    261261  }
     
    264264  factor = helper.ScalarProduct(PlaneNormal)/factor;
    265265  if (fabs(factor) < MYEPSILON) { // Origin is in-plane
    266     Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;
     266    DoLog(1) && (Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl);
    267267    CopyVector(Origin);
    268268    return true;
     
    271271  Direction.Scale(factor);
    272272  CopyVector(Origin);
    273   Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;
     273  DoLog(1) && (Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl);
    274274  AddVector(&Direction);
    275275
     
    278278  helper.SubtractVector(PlaneOffset);
    279279  if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) {
    280     Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;
     280    DoLog(1) && (Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl);
    281281    return true;
    282282  } else {
     
    359359  //}
    360360  if (fabs(M->Determinant()) > MYEPSILON) {
    361     Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
     361    DoLog(1) && (Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl);
    362362    return false;
    363363  }
    364   Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
     364  DoLog(1) && (Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl);
    365365
    366366
     
    378378  d.CopyVector(Line2b);
    379379  d.SubtractVector(Line1b);
    380   Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
     380  DoLog(1) && (Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl);
    381381  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
    382382   Zero();
    383    Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
     383   DoLog(1) && (Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl);
    384384   return false;
    385385  }
     
    394394    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    395395      CopyVector(Line2a);
    396       Log() << Verbose(1) << "Lines conincide." << endl;
     396      DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    397397      return true;
    398398    } else {
     
    402402      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    403403        CopyVector(Line2b);
    404         Log() << Verbose(1) << "Lines conincide." << endl;
     404        DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    405405        return true;
    406406      }
    407407    }
    408     Log() << Verbose(1) << "Lines are parallel." << endl;
     408    DoLog(1) && (Log() << Verbose(1) << "Lines are parallel." << endl);
    409409    Zero();
    410410    return false;
     
    418418  temp2.CopyVector(&a);
    419419  temp2.VectorProduct(&b);
    420   Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
     420  DoLog(1) && (Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl);
    421421  if (fabs(temp2.NormSquared()) > MYEPSILON)
    422422    s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
    423423  else
    424424    s = 0.;
    425   Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
     425  DoLog(1) && (Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl);
    426426
    427427  // construct intersection
     
    429429  Scale(s);
    430430  AddVector(Line1a);
    431   Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
     431  DoLog(1) && (Log() << Verbose(1) << "Intersection is at " << *this << "." << endl);
    432432
    433433  return true;
     
    702702void Vector::Output() const
    703703{
    704   Log() << Verbose(0) << "(";
     704  DoLog(0) && (Log() << Verbose(0) << "(");
    705705  for (int i=0;i<NDIM;i++) {
    706     Log() << Verbose(0) << x[i];
     706    DoLog(0) && (Log() << Verbose(0) << x[i]);
    707707    if (i != 2)
    708       Log() << Verbose(0) << ",";
    709   }
    710   Log() << Verbose(0) << ")";
     708      DoLog(0) && (Log() << Verbose(0) << ",");
     709  }
     710  DoLog(0) && (Log() << Verbose(0) << ")");
    711711};
    712712
     
    843843  projection = ScalarProduct(n)/n->ScalarProduct(n);    // remove constancy from n (keep as logical one)
    844844  // withdraw projected vector twice from original one
    845   Log() << Verbose(1) << "Vector: ";
     845  DoLog(1) && (Log() << Verbose(1) << "Vector: ");
    846846  Output();
    847   Log() << Verbose(0) << "\t";
     847  DoLog(0) && (Log() << Verbose(0) << "\t");
    848848  for (int i=NDIM;i--;)
    849849    x[i] -= 2.*projection*n->x[i];
    850   Log() << Verbose(0) << "Projected vector: ";
     850  DoLog(0) && (Log() << Verbose(0) << "Projected vector: ");
    851851  Output();
    852   Log() << Verbose(0) << endl;
     852  DoLog(0) && (Log() << Verbose(0) << endl);
    853853};
    854854
     
    954954  double norm;
    955955
    956   Log() << Verbose(4);
     956  DoLog(4) && (Log() << Verbose(4));
    957957  GivenVector->Output();
    958   Log() << Verbose(0) << endl;
     958  DoLog(0) && (Log() << Verbose(0) << endl);
    959959  for (j=NDIM;j--;)
    960960    Components[j] = -1;
     
    963963    if (fabs(GivenVector->x[j]) > MYEPSILON)
    964964      Components[Last++] = j;
    965   Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;
     965  DoLog(4) && (Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl);
    966966
    967967  switch(Last) {
     
    10131013
    10141014  for (j=0;j<num;j++) {
    1015     Log() << Verbose(1) << j << "th atom's vector: ";
     1015    DoLog(1) && (Log() << Verbose(1) << j << "th atom's vector: ");
    10161016    (vectors[j])->Output();
    1017     Log() << Verbose(0) << endl;
     1017    DoLog(0) && (Log() << Verbose(0) << endl);
    10181018  }
    10191019
     
    11351135    j += i+1;
    11361136    do {
    1137       Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";
     1137      DoLog(0) && (Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ");
    11381138      cin >> x[i];
    11391139    } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check));
     
    11661166  B2 = cos(beta) * x2->Norm() * c;
    11671167  C = c * c;
    1168   Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl;
     1168  DoLog(2) && (Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl);
    11691169  int flag = 0;
    11701170  if (fabs(x1->x[0]) < MYEPSILON) { // check for zero components for the later flipping and back-flipping
     
    12051205  D2 = -y->x[0]/x1->x[0]*x1->x[2]+y->x[2];
    12061206  D3 = y->x[0]/x1->x[0]*A-B1;
    1207   Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n";
     1207  DoLog(2) && (Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n");
    12081208  if (fabs(D1) < MYEPSILON) {
    1209     Log() << Verbose(2) << "D1 == 0!\n";
     1209    DoLog(2) && (Log() << Verbose(2) << "D1 == 0!\n");
    12101210    if (fabs(D2) > MYEPSILON) {
    1211       Log() << Verbose(3) << "D2 != 0!\n";
     1211      DoLog(3) && (Log() << Verbose(3) << "D2 != 0!\n");
    12121212      x[2] = -D3/D2;
    12131213      E1 = A/x1->x[0] + x1->x[2]/x1->x[0]*D3/D2;
    12141214      E2 = -x1->x[1]/x1->x[0];
    1215       Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1215      DoLog(3) && (Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    12161216      F1 = E1*E1 + 1.;
    12171217      F2 = -E1*E2;
    12181218      F3 = E1*E1 + D3*D3/(D2*D2) - C;
    1219       Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1219      DoLog(3) && (Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    12201220      if (fabs(F1) < MYEPSILON) {
    1221         Log() << Verbose(4) << "F1 == 0!\n";
    1222         Log() << Verbose(4) << "Gleichungssystem linear\n";
     1221        DoLog(4) && (Log() << Verbose(4) << "F1 == 0!\n");
     1222        DoLog(4) && (Log() << Verbose(4) << "Gleichungssystem linear\n");
    12231223        x[1] = F3/(2.*F2);
    12241224      } else {
    12251225        p = F2/F1;
    12261226        q = p*p - F3/F1;
    1227         Log() << Verbose(4) << "p " << p << "\tq " << q << endl;
     1227        DoLog(4) && (Log() << Verbose(4) << "p " << p << "\tq " << q << endl);
    12281228        if (q < 0) {
    1229           Log() << Verbose(4) << "q < 0" << endl;
     1229          DoLog(4) && (Log() << Verbose(4) << "q < 0" << endl);
    12301230          return false;
    12311231        }
     
    12341234      x[0] =  A/x1->x[0] - x1->x[1]/x1->x[0]*x[1] + x1->x[2]/x1->x[0]*x[2];
    12351235    } else {
    1236       Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n";
     1236      DoLog(2) && (Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n");
    12371237      return false;
    12381238    }
     
    12401240    E1 = A/x1->x[0]+x1->x[1]/x1->x[0]*D3/D1;
    12411241    E2 = x1->x[1]/x1->x[0]*D2/D1 - x1->x[2];
    1242     Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1242    DoLog(2) && (Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    12431243    F1 = E2*E2 + D2*D2/(D1*D1) + 1.;
    12441244    F2 = -(E1*E2 + D2*D3/(D1*D1));
    12451245    F3 = E1*E1 + D3*D3/(D1*D1) - C;
    1246     Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1246    DoLog(2) && (Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    12471247    if (fabs(F1) < MYEPSILON) {
    1248       Log() << Verbose(3) << "F1 == 0!\n";
    1249       Log() << Verbose(3) << "Gleichungssystem linear\n";
     1248      DoLog(3) && (Log() << Verbose(3) << "F1 == 0!\n");
     1249      DoLog(3) && (Log() << Verbose(3) << "Gleichungssystem linear\n");
    12501250      x[2] = F3/(2.*F2);
    12511251    } else {
    12521252      p = F2/F1;
    12531253      q = p*p - F3/F1;
    1254       Log() << Verbose(3) << "p " << p << "\tq " << q << endl;
     1254      DoLog(3) && (Log() << Verbose(3) << "p " << p << "\tq " << q << endl);
    12551255      if (q < 0) {
    1256         Log() << Verbose(3) << "q < 0" << endl;
     1256        DoLog(3) && (Log() << Verbose(3) << "q < 0" << endl);
    12571257        return false;
    12581258      }
     
    12921292    for (j=2;j>=0;j--) {
    12931293      k = (i & pot(2,j)) << j;
    1294       Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl;
     1294      DoLog(2) && (Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl);
    12951295      sign[j] = (k == 0) ? 1. : -1.;
    12961296    }
    1297     Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n";
     1297    DoLog(2) && (Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n");
    12981298    // apply sign matrix
    12991299    for (j=NDIM;j--;)
     
    13011301    // calculate angle and check
    13021302    ang = x2->Angle (this);
    1303     Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t";
     1303    DoLog(1) && (Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t");
    13041304    if (fabs(ang - cos(beta)) < MYEPSILON) {
    13051305      break;
Note: See TracChangeset for help on using the changeset viewer.