Ignore:
Timestamp:
Jul 28, 2010, 9:21:14 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
400170, a7b777c
Parents:
7067bd6 (diff), 0430e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'stable' into StructureRefactoring

Conflicts:

src/Makefile.am

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/WorldAction/RepeatBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
     
    2526#include "UIElements/UIFactory.hpp"
    2627#include "UIElements/Dialog.hpp"
    27 #include "Actions/MapOfActions.hpp"
     28#include "UIElements/ValueStorage.hpp"
    2829#include "Descriptors/MoleculeDescriptor.hpp"
    2930#include "Descriptors/MoleculePtrDescriptor.hpp"
     
    3839{}
    3940
     41void WorldRepeatBox(Vector &Repeater) {
     42  ValueStorage::getInstance().setCurrentValue(WorldRepeatBoxAction::NAME, Repeater);
     43  ActionRegistry::getInstance().getActionByName(WorldRepeatBoxAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog * WorldRepeatBoxAction::createDialog() {
     47  Dialog *dialog = UIFactory::getInstance().makeDialog();
     48
     49  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     50
     51  return dialog;
     52}
     53
    4054Action::state_ptr WorldRepeatBoxAction::performCall() {
    41   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4255  Vector Repeater;
    4356  int count;
     
    4861  MoleculeListClass *molecules = World::getInstance().getMolecules();
    4962
    50   dialog->queryVector(NAME, &Repeater, false, MapOfActions::getInstance().getDescription(NAME));
    51   //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id"));
     63  ValueStorage::getInstance().queryCurrentValue(NAME, Repeater);
     64
    5265  vector<molecule *> AllMolecules;
    5366  if (mol != NULL) {
     
    5972  }
    6073
    61   if(dialog->display()) {
    62     (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
    63     Matrix M = World::getInstance().getDomain().getM();
    64     Matrix newM = M;
    65     Vector x,y;
    66     int n[NDIM];
    67     Matrix repMat;
    68     for (int axis = 0; axis < NDIM; axis++) {
    69       Repeater[axis] = floor(Repeater[axis]);
    70       if (Repeater[axis] < 1) {
    71         DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
    72         Repeater[axis] = 1;
    73       }
    74       repMat.at(axis,axis) = Repeater[axis];
     74  (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
     75  Matrix M = World::getInstance().getDomain().getM();
     76  Matrix newM = M;
     77  Vector x,y;
     78  int n[NDIM];
     79  Matrix repMat;
     80  for (int axis = 0; axis < NDIM; axis++) {
     81    Repeater[axis] = floor(Repeater[axis]);
     82    if (Repeater[axis] < 1) {
     83      DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
     84      Repeater[axis] = 1;
    7585    }
    76     newM *= repMat;
    77     World::getInstance().setDomain(newM);
     86    repMat.at(axis,axis) = Repeater[axis];
     87  }
     88  newM *= repMat;
     89  World::getInstance().setDomain(newM);
    7890
    79     molecule *newmol = NULL;
    80     Vector ** vectors = NULL;
    81     for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
    82       y[0] = n[0];
    83       for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
    84         y[1] = n[1];
    85         for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
    86           y[2] = n[2];
    87           if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0))
    88             continue;
    89           for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
    90             mol = *MolRunner;
    91             DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
    92             count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
    93             if (count != 0) {  // if there is more than none
    94               Elements = new const element *[count];
    95               vectors = new Vector *[count];
    96               j = 0;
    97               for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
    98                 Elements[j] = (*AtomRunner)->type;
    99                 vectors[j] = &(*AtomRunner)->x;
    100                 j++;
    101               }
    102               if (count != j)
    103                 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    104               x = y;
    105               x *= M;
    106               newmol = World::getInstance().createMolecule();
    107               molecules->insert(newmol);
    108               for (int k=count;k--;) { // go through every atom of the original cell
    109                 Walker = World::getInstance().createAtom(); // create a new body
    110                 Walker->x = (*vectors[k]) + x;
    111                 Walker->type = Elements[k];  // insert original element
    112                 cout << "new atom is " << *Walker << endl;
    113                 newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    114               }
    115               // free memory
    116               delete[](Elements);
    117               delete[](vectors);
    118             } else {
    119               DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
     91  molecule *newmol = NULL;
     92  Vector ** vectors = NULL;
     93  for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
     94    y[0] = n[0];
     95    for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
     96      y[1] = n[1];
     97      for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
     98        y[2] = n[2];
     99        if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0))
     100          continue;
     101        for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     102          mol = *MolRunner;
     103          DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
     104          count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
     105          if (count != 0) {  // if there is more than none
     106            Elements = new const element *[count];
     107            vectors = new Vector *[count];
     108            j = 0;
     109            for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
     110              Elements[j] = (*AtomRunner)->type;
     111              vectors[j] = &(*AtomRunner)->x;
     112              j++;
    120113            }
     114            if (count != j)
     115              DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
     116            x = y;
     117            x *= M;
     118            newmol = World::getInstance().createMolecule();
     119            molecules->insert(newmol);
     120            for (int k=count;k--;) { // go through every atom of the original cell
     121              Walker = World::getInstance().createAtom(); // create a new body
     122              Walker->x = (*vectors[k]) + x;
     123              Walker->type = Elements[k];  // insert original element
     124              cout << "new atom is " << *Walker << endl;
     125              newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     126            }
     127            // free memory
     128            delete[](Elements);
     129            delete[](vectors);
     130          } else {
     131            DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
    121132          }
    122133        }
    123134      }
    124135    }
    125     delete dialog;
    126     return Action::success;
    127   } else {
    128     delete dialog;
    129     return Action::failure;
    130136  }
     137  return Action::success;
    131138}
    132139
Note: See TracChangeset for help on using the changeset viewer.