Changeset 80ca29


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.

Files:
7 added
2 deleted
8 edited
1 moved

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
  • tests/regression/Filling/RegularGrid/pre/water.data

    r72e4c95 r80ca29  
    1 # ATOMDATA      Id      type    x=3     neighbors=4
    2 1       OW      0       0       0       2       3       0       0       
    3 2       HW      0.759   0       0.504   1       0       0       0       
    4 3       HW      0.759   0       -0.504  1       0       0       0       
     1# ATOMDATA      Id      name    resName chainID x=3     type    neighbors=4     charge
     21       OW      TIP3    0       0       0       0       OW      2       3       0       0       -0.834
     32       HW      TIP3    0       0.759   0       0.504   HW      1       0       0       0       0.417
     43       HW      TIP3    0       0.759   0       -0.504  HW      1       0       0       0       0.417
  • tests/regression/Filling/RegularGrid/testsuite-molecules-fill-regular-grid.at

    r72e4c95 r80ca29  
    11### fill regular grid
    22
    3 AT_SETUP([Molecules - Fill regular grid])
    4 AT_KEYWORDS([molecules filling fill-regular-grid add-empty-boundary])
     3AT_SETUP([Filling - Fill regular grid])
     4AT_KEYWORDS([filling fill-regular-grid add-empty-boundary])
    55
    6 file=tensid.data
    7 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/tensid.data $file], 0)
    8 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/tensid.potentials .], 0)
     6file=solved_single_sles.data
     7AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/single_sles.data $file], 0)
    98AT_CHECK([chmod u+w $file], 0)
    10 AT_CHECK([../../molecuilder --parse-tremolo-potentials tensid.potentials -i $file --add-empty-boundary "10,10,10" --load water.data --select-molecule-by-order -1 --fill-regular-grid --mesh-size "33,33,33" --mesh-offset "0.5,0.5,0.5" --tesselation-radius 10 --min-distance 3.1], 0, [stdout], [stderr])
    11 AT_CHECK([grep "194 out of 194 returned true from predicate" stdout], 0, [ignore], [ignore])
    12 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/post/tensid.data], 0, [ignore], [ignore])
     9AT_CHECK([../../molecuilder --parse-tremolo-potentials ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/sles.potentials -i $file -B "14.199,0,16.6216,0,0,33.9159" --load ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/water.data --select-molecule-by-order -1 --fill-regular-grid --mesh-size "5,5,11" --mesh-offset "0.5,0.5,0.5" --min-distance 3.1], 0, [stdout], [stderr])
     10AT_CHECK([grep "222 out of 275 returned true from predicate" stdout], 0, [ignore], [ignore])
     11AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/post/$file], 0, [ignore], [ignore])
    1312
    1413AT_CLEANUP
    1514
    1615
    17 AT_SETUP([Molecules - Fill regular grid with Undo])
    18 AT_KEYWORDS([molecules filling fill-regular-grid undo])
     16AT_SETUP([Filling - Fill regular grid with Undo])
     17AT_KEYWORDS([filling fill-regular-grid undo])
    1918
    20 file=tensid.data
    21 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/tensid.data $file], 0)
    22 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/tensid.potentials .], 0)
     19file=solved_single_sles.data
     20AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/single_sles.data $file], 0)
    2321AT_CHECK([chmod u+w $file], 0)
    24 AT_CHECK([../../molecuilder --parse-tremolo-potentials tensid.potentials -i $file --add-empty-boundary "10,10,10" --load water.data --select-molecule-by-order -1 --fill-regular-grid --mesh-size "33,33,33" --mesh-offset "0.5,0.5,0.5" --tesselation-radius 10 --min-distance 3.1 --undo], 0, [stdout], [stderr])
    25 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/$file], 0, [ignore], [ignore])
     22AT_CHECK([../../molecuilder --parse-tremolo-potentials ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/sles.potentials -i $file -B "14.199,0,16.6216,0,0,33.9159" --load ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/water.data --select-molecule-by-order -1 --fill-regular-grid --mesh-size "5,5,11" --mesh-offset "0.5,0.5,0.5" --min-distance 3.1 --undo], 0, [stdout], [stderr])
     23AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/post/single_sles-undo.data], 0, [ignore], [ignore])
    2624
    2725AT_CLEANUP
    2826
    2927
    30 AT_SETUP([Molecules - Fill regular grid with Redo])
    31 AT_KEYWORDS([molecules filling fill-regular-grid redo])
     28AT_SETUP([Filling - Fill regular grid with Redo])
     29AT_KEYWORDS([filling fill-regular-grid redo])
    3230
    33 file=tensid.data
    34 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/tensid.data $file], 0)
    35 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/tensid.potentials .], 0)
     31file=solved_single_sles.data
     32AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/single_sles.data $file], 0)
    3633AT_CHECK([chmod u+w $file], 0)
    37 AT_CHECK([../../molecuilder --parse-tremolo-potentials tensid.potentials -i $file --add-empty-boundary "10,10,10" --load water.data --select-molecule-by-order -1 --fill-regular-grid --mesh-size "33,33,33" --mesh-offset "0.5,0.5,0.5" --tesselation-radius 10 --min-distance 3.1 --undo --redo], 0, [stdout], [stderr])
    38 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/post/tensid.data], 0, [ignore], [ignore])
     34AT_CHECK([../../molecuilder --parse-tremolo-potentials ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/sles.potentials -i $file -B "14.199,0,16.6216,0,0,33.9159" --load ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/pre/water.data --select-molecule-by-order -1 --fill-regular-grid --mesh-size "5,5,11" --mesh-offset "0.5,0.5,0.5" --min-distance 3.1 --undo --redo], 0, [stdout], [stderr])
     35AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Filling/RegularGrid/post/$file], 0, [ignore], [ignore])
    3936
    4037AT_CLEANUP
  • tests/regression/Filling/testsuite-filling.at

    r72e4c95 r80ca29  
    1818# fill regular grid
    1919m4_include([Filling/RegularGrid/testsuite-molecules-fill-regular-grid.at])
     20m4_include([Filling/RegularGrid/testsuite-molecules-fill-regular-grid-with-surface.at])
    2021
  • tests/regression/Makefile.am

    r72e4c95 r80ca29  
    6262        $(srcdir)/Filling/SuspendInWater/testsuite-suspend-in-water.at \
    6363        $(srcdir)/Filling/RegularGrid/testsuite-molecules-fill-regular-grid.at \
     64        $(srcdir)/Filling/RegularGrid/testsuite-molecules-fill-regular-grid-with-surface.at \
    6465        $(srcdir)/Filling/SphericalSurface/testsuite-molecules-fill-spherical-surface.at \
    6566        $(srcdir)/Filling/FillVoidWithMolecule/testsuite-fill-void-with-molecule.at \
Note: See TracChangeset for help on using the changeset viewer.