Changeset 99f4ee for src/Box.cpp
- Timestamp:
- Jan 2, 2012, 1:34:58 PM (13 years ago)
- 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:
- 4a8169
- Parents:
- 9ed706
- git-author:
- Frederik Heber <heber@…> (12/21/11 18:02:07)
- git-committer:
- Frederik Heber <heber@…> (01/02/12 13:34:58)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Box.cpp
r9ed706 r99f4ee 28 28 #include "CodePatterns/Assert.hpp" 29 29 #include "CodePatterns/Log.hpp" 30 #include "CodePatterns/Observer/Channels.hpp" 31 #include "CodePatterns/Observer/Notification.hpp" 30 32 #include "CodePatterns/Verbose.hpp" 31 33 #include "Helpers/defs.hpp" … … 38 40 39 41 Box::Box() : 42 Observable("Box"), 40 43 M(new RealSpaceMatrix()), 41 44 Minv(new RealSpaceMatrix()) … … 44 47 coords.reserve(NDIM); 45 48 index.reserve(NDIM); 49 50 // observable stuff 51 Channels *OurChannel = new Channels; 52 NotificationChannels.insert( std::make_pair(this, OurChannel) ); 53 // add instance for each notification type 54 for (size_t type = 0; type < NotificationType_MAX; ++type) 55 OurChannel->addChannel(type); 56 46 57 M->setIdentity(); 47 58 Minv->setIdentity(); … … 51 62 52 63 Box::Box(const Box& src) : 53 conditions(src.conditions), 54 M(new RealSpaceMatrix(*src.M)), 55 Minv(new RealSpaceMatrix(*src.Minv)) 64 Observable("Box"), 65 conditions(src.conditions), 66 M(new RealSpaceMatrix(*src.M)), 67 Minv(new RealSpaceMatrix(*src.Minv)) 56 68 { 57 69 internal_list.reserve(pow(3,3)); 58 70 coords.reserve(NDIM); 59 71 index.reserve(NDIM); 72 73 // observable stuff 74 Channels *OurChannel = new Channels; 75 NotificationChannels.insert( std::make_pair(this, OurChannel) ); 76 // add instance for each notification type 77 for (size_t type = 0; type < NotificationType_MAX; ++type) 78 OurChannel->addChannel(type); 60 79 } 61 80 62 81 Box::Box(RealSpaceMatrix _M) : 82 Observable("Box"), 63 83 M(new RealSpaceMatrix(_M)), 64 84 Minv(new RealSpaceMatrix()) … … 67 87 coords.reserve(NDIM); 68 88 index.reserve(NDIM); 89 90 // observable stuff 91 Channels *OurChannel = new Channels; 92 NotificationChannels.insert( std::make_pair(this, OurChannel) ); 93 // add instance for each notification type 94 for (size_t type = 0; type < NotificationType_MAX; ++type) 95 OurChannel->addChannel(type); 96 69 97 ASSERT(M->determinant()!=0,"Matrix in Box construction was not invertible"); 70 98 *Minv = M->invert(); … … 75 103 Box::~Box() 76 104 { 105 // observable stuff 106 std::map<Observable *, Channels*>::iterator iter = NotificationChannels.find(this); 107 delete iter->second; 108 NotificationChannels.erase(iter); 109 77 110 delete M; 78 111 delete Minv; … … 88 121 void Box::setM(RealSpaceMatrix _M){ 89 122 ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible"); 123 OBSERVE; 124 NOTIFY(MatrixChanged); 90 125 *M =_M; 91 126 *Minv = M->invert(); … … 278 313 } 279 314 280 void Box::setCondition(int i,Box::BoundaryCondition_t condition){ 315 void Box::setCondition(int i,Box::BoundaryCondition_t condition) 316 { 317 OBSERVE; 318 NOTIFY(BoundaryConditionsChanged); 281 319 conditions[i]=condition; 282 320 } … … 303 341 } 304 342 305 void Box::setCuboid(const Vector &endpoint){ 343 void Box::setCuboid(const Vector &endpoint) 344 { 345 OBSERVE; 346 NOTIFY(MatrixChanged); 306 347 ASSERT(endpoint[0]>0 && endpoint[1]>0 && endpoint[2]>0,"Vector does not define a full cuboid"); 307 348 M->setIdentity(); … … 312 353 } 313 354 314 Box &Box::operator=(const Box &src){ 355 Box &Box::operator=(const Box &src) 356 { 315 357 if(&src!=this){ 358 OBSERVE; 359 // new matrix 360 NOTIFY(MatrixChanged); 316 361 delete M; 317 362 delete Minv; 318 363 M = new RealSpaceMatrix(*src.M); 319 364 Minv = new RealSpaceMatrix(*src.Minv); 365 // new boundary conditions 366 NOTIFY(BoundaryConditionsChanged); 320 367 conditions = src.conditions; 321 368 } … … 323 370 } 324 371 325 Box &Box::operator=(const RealSpaceMatrix &mat){ 372 Box &Box::operator=(const RealSpaceMatrix &mat) 373 { 374 OBSERVE; 375 NOTIFY(MatrixChanged); 326 376 setM(mat); 327 377 return *this;
Note:
See TracChangeset
for help on using the changeset viewer.