Changeset 2a0271 for src


Ignore:
Timestamp:
Feb 22, 2012, 11:29:22 AM (13 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:
7e3065
Parents:
c96423
git-author:
Frederik Heber <heber@…> (01/18/12 18:13:52)
git-committer:
Frederik Heber <heber@…> (02/22/12 11:29:22)
Message:

New function Box::isValid() to be discerned from ::isInside().

  • isValid checks with and isInside without boundary conditions.
  • added Box::isValid() check to LinkedCell_Model::getIndexToVector().
  • TESTFIX: regression test Atoms/Add needed Ignore BCs.
Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Values.cpp

    rc96423 r2a0271  
    4141  static_cast<Vector>(returnVector) = Vector(vector); // under its hood it's still a Vector
    4242
    43   ASSERT(_box.isInside(returnVector),
     43  ASSERT(_box.isValid(returnVector),
    4444      "VectorValue::toBoxVector() - vector "+toString(toVector())+" does not lie within box "+toString(_box)+".");
    4545
  • src/Box.cpp

    rc96423 r2a0271  
    169169    result = result &&
    170170              ((conditions[i] == BoundaryConditions::Ignore) ||
     171               ((tester[i] >= -MYEPSILON) &&
     172               ((tester[i] - 1.) < MYEPSILON)));
     173
     174  return result;
     175}
     176
     177bool Box::isValid(const Vector &point) const
     178{
     179  bool result = true;
     180  Vector tester = translateOut(point);
     181
     182  for(int i=0;i<NDIM;i++)
     183    result = result &&
     184              ((conditions[i] != BoundaryConditions::Ignore) ||
    171185               ((tester[i] >= -MYEPSILON) &&
    172186               ((tester[i] - 1.) < MYEPSILON)));
  • src/Box.hpp

    rc96423 r2a0271  
    8383
    8484  /**
    85    * Checks whether a given vector is inside the box.
     85   * Checks whether a given vector is inside the box not accounting for boundary conditions.
    8686   */
    8787  bool isInside(const Vector &point) const;
     88
     89  /**
     90   * Checks whether a given vector is inside the box under the given boundary conditions.
     91   */
     92  bool isValid(const Vector &point) const;
     93
    8894
    8995  /**
     
    146152  void internal_explode(const Vector &point,int n) const;
    147153
     154
    148155  //!> Internal vector list for exploding vectors used in Box::internal_explode().
    149156  mutable VECTORSET(std::vector) internal_list;
  • src/LinkedCell/LinkedCell_Model.cpp

    rc96423 r2a0271  
    288288const LinkedCell::tripleIndex LinkedCell::LinkedCell_Model::getIndexToVector(const Vector &position) const
    289289{
     290  ASSERT(domain.isValid(position),
     291      "LinkedCell::LinkedCell_Model::getIndexToVector() - specified position "+toString(position)
     292      +"is not valid in the current domain.");
    290293  tripleIndex index;
    291294  Vector x(Partition*domain.enforceBoundaryConditions(position));
  • src/LinkedCell/unittests/stubs/ObserverBoxStub.cpp

    rc96423 r2a0271  
    7070}
    7171
     72bool Box::isValid(const Vector &p) const
     73{
     74  return true;
     75}
     76
    7277void Box::setM(RealSpaceMatrix _M)
    7378{
  • src/Tesselation/boundary.cpp

    rc96423 r2a0271  
    11751175              boundary,
    11761176              CurrentPosition);
    1177           FillIt = FillIt && (Domain.isInside(CurrentPosition))
     1177          FillIt = FillIt && (Domain.isValid(CurrentPosition))
    11781178              && ((Domain.DistanceToBoundary(CurrentPosition) - MinDistance) > -MYEPSILON);
    11791179          if (!FillIt)
     
    12401240};
    12411241
     1242
     1243/** Fills the empty space around other molecules' surface of the simulation box with a filler.
     1244 *
     1245 * Note that we use \a FindNonConvexBorder to determine the surface of the found molecules.
     1246 * There, we use a radius of twice the given \a boundary.
     1247 *
     1248 * \param *out output stream for debugging
     1249 * \param *List list of molecules already present in box
     1250 * \param *TesselStruct contains tesselated surface
     1251 * \param *filler molecule which the box is to be filled with
     1252 * \param configuration contains box dimensions
     1253 * \param MaxSurfaceDistance fills in molecules only up to this distance (set to -1 if whole of the domain)
     1254 * \param distance[NDIM] distance between filling molecules in each direction
     1255 * \param boundary length of boundary zone between molecule and filling molecules
     1256 * \param MinDistance distance to boundary of domain which is not filled
     1257 * \param RandAtomDisplacement maximum distance for random displacement per atom
     1258 * \param RandMolDisplacement maximum distance for random displacement per filler molecule
     1259 * \param DoRandomRotation true - do random rotations, false - don't
     1260 */
     1261void FillBoxWithMolecule(
     1262    MoleculeListClass *MolList,
     1263    molecule *filler,
     1264    config &configuration,
     1265    const double MaxSurfaceDistance,
     1266    const double distance[NDIM],
     1267    const double boundary,
     1268    const double MinDistance,
     1269    const double RandomAtomDisplacement,
     1270    const double RandomMolDisplacement,
     1271    const bool DoRandomRotation)
     1272{
     1273  Info FunctionInfo(__func__);
     1274  molecule *Filling = NULL;
     1275  Vector CurrentPosition;
     1276  int N[NDIM];
     1277  int n[NDIM];
     1278  const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
     1279  RealSpaceMatrix Rotations;
     1280  const RealSpaceMatrix &MInverse = World::getInstance().getDomain().getMinv();
     1281  Vector FillerTranslations;
     1282  Vector FillerDistance;
     1283  Vector Inserter;
     1284  double FillIt = false;
     1285  Vector firstInserter;
     1286  bool firstInsertion = true;
     1287  const Box &Domain = World::getInstance().getDomain();
     1288  map<molecule *, LinkedCell_deprecated *> LCList;
     1289  std::vector<molecule *> List = World::getInstance().getAllMolecules();
     1290  map<molecule *, Tesselation *> TesselStruct;
     1291
     1292  for (MoleculeList::iterator ListRunner = MolList->ListOfMolecules.begin(); ListRunner != MolList->ListOfMolecules.end(); ListRunner++)
     1293    if ((*ListRunner)->getAtomCount() > 0) {
     1294      LOG(1, "Pre-creating linked cell lists for molecule " << *ListRunner << ".");
     1295      PointCloudAdaptor< molecule > cloud(*ListRunner, (*ListRunner)->name);
     1296      LCList[(*ListRunner)] = new LinkedCell_deprecated(cloud, 4.*boundary); // get linked cell list
     1297      LOG(1, "Pre-creating tesselation for molecule " << *ListRunner << ".");
     1298      TesselStruct[(*ListRunner)] = NULL;
     1299      FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell_deprecated *&)LCList[(*ListRunner)], 2.*boundary, NULL);
     1300    }
     1301
     1302  // Center filler at origin
     1303  filler->CenterEdge(&Inserter);
     1304  const int FillerCount = filler->getAtomCount();
     1305  LOG(2, "INFO: Filler molecule has the following bonds:");
     1306  for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
     1307    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     1308    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     1309        BondRunner != ListOfBonds.end();
     1310        ++BondRunner) {
     1311      if ((*BondRunner)->leftatom == *AtomRunner)
     1312        LOG(2, "  " << *(*BondRunner));
     1313    }
     1314  }
     1315
     1316  atom * CopyAtoms[FillerCount];
     1317
     1318  setVerbosity(4);
     1319
     1320  // calculate filler grid in [0,1]^3
     1321  FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]);
     1322  for(int i=0;i<NDIM;i++)
     1323    N[i] = (int) ceil(1./FillerDistance[i]);
     1324  LOG(1, "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << ".");
     1325
     1326  // initialize seed of random number generator to current time
     1327  RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();
     1328  const double rng_min = random.min();
     1329  const double rng_max = random.max();
     1330  //srand ( time(NULL) );
     1331
     1332  // go over [0,1]^3 filler grid
     1333  for (n[0] = 0; n[0] < N[0]; n[0]++)
     1334    for (n[1] = 0; n[1] < N[1]; n[1]++)
     1335      for (n[2] = 0; n[2] < N[2]; n[2]++) {
     1336        // calculate position of current grid vector in untransformed box
     1337        CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
     1338        // create molecule random translation vector ...
     1339        for (int i=0;i<NDIM;i++)
     1340          FillerTranslations[i] = RandomMolDisplacement*(random()/((rng_max-rng_min)/2.) - 1.);
     1341        LOG(1, "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << ".");
     1342
     1343        // ... and rotation matrix
     1344        if (DoRandomRotation)
     1345          setRandomRotation(Rotations);
     1346        else
     1347          Rotations.setIdentity();
     1348
     1349
     1350        // Check whether there is anything too close by and whether atom is outside of domain
     1351        FillIt = true;
     1352        for (std::map<molecule *, LinkedCell_deprecated *>::iterator ListRunner = LCList.begin(); ListRunner != LCList.end(); ++ListRunner) {
     1353          // check whether its void
     1354          FillIt = FillIt && isSpaceAroundPointVoid(
     1355              ListRunner->second,
     1356              (firstInsertion ? filler : NULL),
     1357              boundary,
     1358              CurrentPosition);
     1359          if (!FillIt) {
     1360            LOG(2, "REJECT: Position at " << Inserter << " is non-void.");
     1361            break;
     1362          }
     1363          // check whether inside domain
     1364          FillIt = FillIt && (Domain.isValid(CurrentPosition));
     1365          if (!FillIt) {
     1366            LOG(2, "REJECT: Position at " << CurrentPosition << " is "
     1367                << distance << ", hence outside of domain.");
     1368            break;
     1369          }
     1370          // check minimum distance to boundary
     1371          const double distance = (Domain.DistanceToBoundary(CurrentPosition) - MinDistance);
     1372          FillIt = FillIt && (distance > -MYEPSILON);
     1373          if (!FillIt) {
     1374            LOG(2, "REJECT: Position at " << CurrentPosition << " is " << distance << ", less than "
     1375                << MinDistance << " hence, too close to boundary.");
     1376            break;
     1377          }
     1378        }
     1379        // Check whether point is in- or outside of tesselations
     1380        if (FillIt) {
     1381          for (MoleculeList::iterator ListRunner = MolList->ListOfMolecules.begin(); ListRunner != MolList->ListOfMolecules.end(); ListRunner++) {
     1382            // get linked cell list
     1383            if (TesselStruct[(*ListRunner)] != NULL) {
     1384              const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)]));
     1385              LOG(2, "INFO: Distance to surface is " << distance << ".");
     1386              FillIt = FillIt && ((distance == -1.) || (distance > boundary)) && ((MaxSurfaceDistance < 0) || (MaxSurfaceDistance > distance));
     1387              if (!FillIt) {
     1388                LOG(2, "REJECT: Position at " << CurrentPosition << " is in distance of " << distance
     1389                    << " to a surface, less than " << MaxSurfaceDistance  << " hence, too close.");
     1390                break;
     1391              }
     1392            }
     1393          }
     1394        }
     1395
     1396        // insert into Filling
     1397        if (FillIt) {
     1398          Inserter = CurrentPosition + FillerTranslations;
     1399          LOG(2, "ACCEPT: Position at " << CurrentPosition << " is void point.");
     1400          // fill!
     1401          Filling = filler->CopyMolecule();
     1402          RandomizeMoleculePositions(Filling, RandomAtomDisplacement, Rotations, random);
     1403          // translation
     1404          Filling->Translate(&Inserter);
     1405          // remove out-of-bounds atoms
     1406          const bool status = RemoveAtomsOutsideDomain(Filling);
     1407          if ((firstInsertion) && (!status)) { // no atom has been removed
     1408            // remove copied atoms and molecule again
     1409            Filling->removeAtomsinMolecule();
     1410            World::getInstance().destroyMolecule(Filling);
     1411            // and mark is final filler position
     1412            Filling = filler;
     1413            firstInsertion = false;
     1414            firstInserter = Inserter;
     1415          } else {
     1416            // TODO: Remove when World has no MoleculeListClass anymore
     1417            if (Filling)
     1418              MolList->insert(Filling);
     1419          }
     1420        } else {
     1421          LOG(2, "REJECT: Position at " << CurrentPosition << " is non-void point, within boundary or outside of MaxSurfaceDistance.");
     1422          continue;
     1423        }
     1424      }
     1425
     1426  // have we inserted any molecules?
     1427  if (firstInsertion) {
     1428    // If not remove filler
     1429    for(molecule::iterator miter = filler->begin(); !filler->empty(); miter = filler->begin()) {
     1430      atom *Walker = *miter;
     1431      World::getInstance().destroyAtom(Walker);
     1432    }
     1433    World::getInstance().destroyMolecule(filler);
     1434  } else {
     1435    // otherwise translate and randomize to final position
     1436    if (DoRandomRotation)
     1437      setRandomRotation(Rotations);
     1438    else
     1439      Rotations.setIdentity();
     1440    RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random);
     1441    // translation
     1442    filler->Translate(&firstInserter);
     1443    // remove out-of-bounds atoms
     1444    RemoveAtomsOutsideDomain(filler);
     1445  }
     1446
     1447  LOG(0, MolList->ListOfMolecules.size() << " molecules have been inserted.");
     1448
     1449  for (std::map<molecule *, LinkedCell_deprecated *>::iterator ListRunner = LCList.begin(); !LCList.empty(); ListRunner = LCList.begin()) {
     1450    delete ListRunner->second;
     1451    LCList.erase(ListRunner);
     1452  }
     1453};
     1454
    12421455/** Tesselates the non convex boundary by rolling a virtual sphere along the surface of the molecule.
    12431456 * \param *out output stream for debugging
  • src/UIElements/CommandLineUI/Query/VectorCommandLineQuery.cpp

    rc96423 r2a0271  
    4141    temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
    4242    tmp = temp.toVector();
    43     if ((check) && (!World::getInstance().getDomain().isInside(tmp))) {
     43    if ((check) && (!World::getInstance().getDomain().isValid(tmp))) {
    4444      ELOG(1, "Vector " << tmp << " would be outside of box domain.");
    4545      return false;
  • src/UIElements/CommandLineUI/Query/VectorsCommandLineQuery.cpp

    rc96423 r2a0271  
    4242    for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) {
    4343      temp = (*iter).toVector();
    44       if ((!check) || (World::getInstance().getDomain().isInside(temp)))
     44      if ((!check) || (World::getInstance().getDomain().isValid(temp)))
    4545        tmp.push_back(temp);
    4646      else
  • src/UIElements/TextUI/Query/VectorTextQuery.cpp

    rc96423 r2a0271  
    6767
    6868  // check vector
    69   return World::getInstance().getDomain().isInside(tmp);
     69  return World::getInstance().getDomain().isValid(tmp);
    7070}
    7171
  • src/UIElements/TextUI/Query/VectorsTextQuery.cpp

    rc96423 r2a0271  
    7171        temp[counter++] = coord;
    7272      }
    73       if (World::getInstance().getDomain().isInside(temp))
     73      if (World::getInstance().getDomain().isValid(temp))
    7474        tmp.push_back(temp);
    7575      olditerspace = vectoriter;
Note: See TracChangeset for help on using the changeset viewer.