Changeset 80ca29 for src


Ignore:
Timestamp:
Apr 6, 2012, 11:44:51 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:
531f27
Parents:
72e4c95
git-author:
Frederik Heber <heber@…> (04/05/12 15:42:12)
git-committer:
Frederik Heber <heber@…> (04/06/12 11:44:51)
Message:

Added regression test Filling/RegularGrid with and without a tesselated surface.

Location:
src/Actions/FillAction
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FillAction/FillRegularGridAction.cpp

    r72e4c95 r80ca29  
    2424#include "Atom/AtomicInfo.hpp"
    2525#include "Atom/CopyAtoms/CopyAtoms_withBonds.hpp"
     26#include "Bond/BondInfo.hpp"
    2627#include "CodePatterns/Log.hpp"
    2728#include "Descriptors/MoleculeOrderDescriptor.hpp"
     
    6768  getParametersfromValueStorage();
    6869
    69   // get the filler molecule and move to origin
     70  // get the filler molecule
     71  std::vector<AtomicInfo> movedatoms;
    7072  const std::vector< molecule *> molecules = World::getInstance().getSelectedMolecules();
    7173  if (molecules.size() != 1) {
     
    7476  }
    7577  molecule *filler = *(molecules.begin());
     78  for(molecule::const_iterator iter = filler->begin(); iter != filler->end(); ++iter)
     79    movedatoms.push_back( AtomicInfo(*(*iter)) );
    7680  LOG(1, "INFO: Chosen molecule has " << filler->size() << " atoms.");
    7781
     
    8286  Tesselation * TesselStruct = NULL;
    8387  if (params.SphereRadius != 0.) {
    84     if ( molecules.size() == 0) {
     88    if ( atoms.size() == 0) {
    8589      ELOG(1, "You have given a sphere radius " << params.SphereRadius
    8690          << " != 0, but have not select any molecules.");
     91      return Action::failure;
    8792    }
    8893    // create adaptor for the selected atoms
     
    99104
    100105  // create predicate, mesh, and filler
    101   std::vector<AtomicInfo> clonedatoms;
     106  FillRegularGridState *UndoState = NULL;
    102107  bool successflag = false;
    103108  {
     
    129134      delete fillerFunction;
    130135
    131       // append each cluster's atoms to clonedatoms
     136      // append each cluster's atoms to clonedatoms (however not selected ones)
     137      std::vector<const atom *> clonedatoms;
     138      std::vector<AtomicInfo> clonedatominfos;
    132139      for (Filler::ClusterVector_t::const_iterator iter = ClonedClusters.begin();
    133140          iter != ClonedClusters.end(); ++iter) {
     
    135142        clonedatoms.reserve(clonedatoms.size()+atoms.size());
    136143        for (AtomIdSet::const_iterator atomiter = atoms.begin(); atomiter != atoms.end(); ++atomiter)
    137           clonedatoms.push_back( AtomicInfo(*(*atomiter)) );
     144          if (!filler->containsAtom(*atomiter)) {
     145            clonedatoms.push_back( *atomiter );
     146            clonedatominfos.push_back( AtomicInfo(*(*atomiter)) );
     147          }
    138148      }
     149      std::vector< BondInfo > clonedbonds;
     150      StoreBondInformationFromAtoms(clonedatoms, clonedbonds);
     151      LOG(2, "DEBUG: There are " << clonedatominfos.size() << " newly created atoms.");
     152
    139153      if (!successflag) {
    140         ELOG(1, "Insertion failed, removing inserted clusters again.");
    141         RemoveAtomsFromAtomicInfo(clonedatoms);
     154        ELOG(1, "Insertion failed, removing inserted clusters, translating original one back");
     155        RemoveAtomsFromAtomicInfo(clonedatominfos);
    142156        clonedatoms.clear();
     157        SetAtomsFromAtomicInfo(movedatoms);
     158      } else {
     159        std::vector<Vector> MovedToVector(filler->size(), zeroVec);
     160        std::transform(filler->begin(), filler->end(), MovedToVector.begin(),
     161            boost::bind(&AtomInfo::getPosition, _1) );
     162        UndoState = new FillRegularGridState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params);
    143163      }
    144164    }
     
    154174
    155175  if (successflag)
    156     return Action::state_ptr(new FillRegularGridState(clonedatoms,params));
     176    return Action::state_ptr(UndoState);
    157177  else
    158178    return Action::failure;
     
    164184  // remove all created atoms
    165185  RemoveAtomsFromAtomicInfo(state->clonedatoms);
     186  // add the original cluster
     187  SetAtomsFromAtomicInfo(state->movedatoms);
    166188
    167189  return Action::state_ptr(_state);
     
    171193  FillRegularGridState *state = assert_cast<FillRegularGridState*>(_state.get());
    172194
    173   if (AddAtomsFromAtomicInfo(state->clonedatoms))
     195  // place filler cluster again at new spot
     196  ResetAtomPosition(state->movedatoms, state->MovedToVector);
     197
     198  // re-create all clusters
     199  bool statusflag = AddAtomsFromAtomicInfo(state->clonedatoms);
     200
     201  // re-create the bonds
     202  if (statusflag)
     203    AddBondsFromBondInfo(state->clonedbonds);
     204  if (statusflag)
    174205    return Action::state_ptr(_state);
    175206  else
  • src/Actions/FillAction/FillRegularGridAction.def

    r72e4c95 r80ca29  
    77
    88// all includes and forward declarations necessary for non-integral types below
    9 class atom;
     9#include <vector>
     10#include "Atom/AtomicInfo.hpp"
     11#include "Bond/BondInfo.hpp"
     12#include "types.hpp"
    1013
    1114// i.e. there is an integer with variable name Z that can be found in
     
    1821#define paramreferences (counts)(offset)(mindistance)(SphereRadius)(RandAtomDisplacement)(RandMoleculeDisplacement)(DoRotate)
    1922
    20 #define statetypes (std::vector<AtomicInfo>) 
    21 #define statereferences (clonedatoms) 
     23#define statetypes (std::vector<AtomicInfo>)(std::vector<BondInfo>)(std::vector<AtomicInfo>)(std::vector<Vector>)
     24#define statereferences (clonedatoms)(clonedbonds)(movedatoms)(MovedToVector)
    2225
    2326// some defines for all the names, you may use ACTION, STATE and PARAMS
  • src/Actions/FillAction/FillSphericalSurfaceAction.cpp

    r72e4c95 r80ca29  
    2121
    2222#include "Actions/UndoRedoHelpers.hpp"
     23#include "Atom/atom.hpp"
    2324#include "Atom/AtomicInfo.hpp"
    2425#include "Atom/CopyAtoms/CopyAtoms_withBonds.hpp"
     
    5455  getParametersfromValueStorage();
    5556
    56   // check for selected atoms
    57   // get the filler molecule and move to origin
     57  // get the filler molecule
    5858  const std::vector< molecule *> molecules = World::getInstance().getSelectedMolecules();
     59  std::vector<AtomicInfo> movedatoms;
    5960  if (molecules.size() != 1) {
    6061    ELOG(1, "No exactly one molecule selected, aborting,");
     
    6263  }
    6364  molecule *filler = *(molecules.begin());
     65  for(molecule::const_iterator iter = filler->begin(); iter != filler->end(); ++iter)
     66    movedatoms.push_back( AtomicInfo(*(*iter)) );
    6467  LOG(1, "INFO: Chosen molecule has " << filler->size() << " atoms.");
    6568
     
    8487
    8588  // create predicate, mesh, and filler
    86   std::vector<AtomicInfo> clonedatoms;
     89  FillSphericalSurfaceState *UndoState = NULL;
    8790  bool successflag = false;
    8891  {
     
    108111      delete fillerFunction;
    109112
    110       // append each cluster's atoms to clonedatoms
     113      // append each cluster's atoms to clonedatoms (however not selected ones)
     114      std::vector<const atom *> clonedatoms;
     115      std::vector<AtomicInfo> clonedatominfos;
    111116      for (Filler::ClusterVector_t::const_iterator iter = ClonedClusters.begin();
    112117          iter != ClonedClusters.end(); ++iter) {
     
    114119        clonedatoms.reserve(clonedatoms.size()+atoms.size());
    115120        for (AtomIdSet::const_iterator atomiter = atoms.begin(); atomiter != atoms.end(); ++atomiter)
    116           clonedatoms.push_back( AtomicInfo(*(*atomiter)) );
     121          if (!filler->containsAtom(*atomiter)) {
     122            clonedatoms.push_back( *atomiter );
     123            clonedatominfos.push_back( AtomicInfo(*(*atomiter)) );
     124          }
    117125      }
     126      std::vector< BondInfo > clonedbonds;
     127      StoreBondInformationFromAtoms(clonedatoms, clonedbonds);
     128      LOG(2, "DEBUG: There are " << clonedatominfos.size() << " newly created atoms with "
     129          << clonedbonds.size()/2 << " bonds.");
     130
    118131      if (!successflag) {
    119         ELOG(1, "Insertion failed, removing inserted clusters again.");
    120         RemoveAtomsFromAtomicInfo(clonedatoms);
     132        ELOG(1, "Insertion failed, removing inserted clusters, translating original one back");
     133        RemoveAtomsFromAtomicInfo(clonedatominfos);
    121134        clonedatoms.clear();
     135        SetAtomsFromAtomicInfo(movedatoms);
     136      } else {
     137        std::vector<Vector> MovedToVector(filler->size(), zeroVec);
     138        std::transform(filler->begin(), filler->end(), MovedToVector.begin(),
     139            boost::bind(&AtomInfo::getPosition, _1) );
     140        UndoState = new FillSphericalSurfaceState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params);
    122141      }
    123142    }
    124 
    125143
    126144    // remove
     
    131149
    132150  if (successflag)
    133     return Action::state_ptr(new FillSphericalSurfaceState(clonedatoms,params));
     151    return Action::state_ptr(UndoState);
    134152  else
    135153    return Action::failure;
     
    141159  // remove all created atoms
    142160  RemoveAtomsFromAtomicInfo(state->clonedatoms);
     161  // add the original cluster
     162  SetAtomsFromAtomicInfo(state->movedatoms);
    143163
    144164  return Action::state_ptr(_state);
     
    148168  FillSphericalSurfaceState *state = assert_cast<FillSphericalSurfaceState*>(_state.get());
    149169
    150   if (AddAtomsFromAtomicInfo(state->clonedatoms))
     170  // place filler cluster again at new spot
     171  ResetAtomPosition(state->movedatoms, state->MovedToVector);
     172
     173  // re-create all clusters
     174  bool statusflag = AddAtomsFromAtomicInfo(state->clonedatoms);
     175
     176  // re-create the bonds
     177  statusflag = statusflag && AddBondsFromBondInfo(state->clonedbonds);
     178  if (statusflag)
    151179    return Action::state_ptr(_state);
    152180  else
  • src/Actions/FillAction/FillSphericalSurfaceAction.def

    r72e4c95 r80ca29  
    99#include <vector>
    1010#include "Atom/AtomicInfo.hpp"
    11 #include "LinearAlgebra/Vector.hpp"
     11#include "Bond/BondInfo.hpp"
     12#include "types.hpp"
    1213
    1314// i.e. there is an integer with variable name Z that can be found in
     
    2021#define paramreferences (center)(radius)(N)(mindistance)(AlignedAxis)
    2122
    22 #define statetypes (std::vector<AtomicInfo>) 
    23 #define statereferences (clonedatoms) 
     23#define statetypes (std::vector<AtomicInfo>)(std::vector<BondInfo>)(std::vector<AtomicInfo>)(std::vector<Vector>)
     24#define statereferences (clonedatoms)(clonedbonds)(movedatoms)(MovedToVector)
    2425
    2526// some defines for all the names, you may use ACTION, STATE and PARAMS
Note: See TracChangeset for help on using the changeset viewer.