source: src/cleanUp.cpp@ bcfb77

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
Last change on this file since bcfb77 was 949953, checked in by Frederik Heber <heber@…>, 13 years ago

pyMoleCuilder now has full functionality.

  • For each header file there is a COMMAND_stringargs() function defined.
  • boost python module exports all Action's COMMAND_stringargs() that are present in GlobalListOfActions.hpp.
  • new source file AllActionPython.hpp is created in Actions/Makefile.am that enlists all the headers.
  • New implemenations:
    • Action_impl_python.hpp: defines COMMAND_stringargs() via some boost:: preprocessor magic.
    • Action_impl_undef.hpp: contains undefs to the Action's .def files.
  • also docstrings are working, both for module and for each exported function.
  • so far, all arguments have a (in NODEFAULT case empty) default value. This is because we cannot perform string comparisons with the preprocessor only numeric ones (i.e. NODEFAULT would have to be 0 or alike).
  • Extracted cleanUp() from builder_init.cpp and placed into own module.
  • cleanUp() is now also registered atexit() for pyMoleCuilder where it is needed as well.
  • AddStaticEntitiestoIgnoreList() has likewise been extracted.
  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[949953]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * cleanUp.cpp
10 *
11 * Created on: Oct 28, 2011
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <iostream>
21#include <iomanip>
22
23#include "CodePatterns/MemDebug.hpp"
24
25#include "cleanUp.hpp"
26
27#include "CodePatterns/Chronos.hpp"
28#include "CodePatterns/errorlogger.hpp"
29#include "CodePatterns/logger.hpp"
30
31#include "Actions/ActionHistory.hpp"
32#include "Actions/ActionRegistry.hpp"
33#include "Actions/OptionRegistry.hpp"
34#include "Actions/ValueStorage.hpp"
35
36#include "RandomNumbers/RandomNumberDistributionFactory.hpp"
37#include "RandomNumbers/RandomNumberEngineFactory.hpp"
38#include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
39
40#include "Parser/ChangeTracker.hpp"
41#include "Parser/FormatParserStorage.hpp"
42
43#include "UIElements/CommandLineUI/CommandLineParser.hpp"
44#include "UIElements/Menu/MenuDescription.hpp"
45#include "UIElements/UIFactory.hpp"
46#include "World.hpp"
47
48/** In this function all dynamicly allocated member variables to static/global
49 * variables are added to the ignore list of Memory/MemDebug.
50 *
51 * Use this to prevent their listing in the Memory::getState() at the end of the
52 * program. Check with valgrind that truely no memory leak occurs!
53 */
54void AddStaticEntitiestoIgnoreList()
55{
56 // zeroVec and unitVec are global variables (on the stack) but vectorContent
57 // within is situated on the heap and has to be ignored
58 Memory::ignore(zeroVec.get());
59 Memory::ignore(unitVec[0].get());
60 Memory::ignore(unitVec[1].get());
61 Memory::ignore(unitVec[2].get());
62}
63
64/** Cleans all singleton instances in an orderly fashion.
65 * C++ does not guarantee any specific sequence of removal of single instances
66 * which have static/global variables. Some singletons depend on others hence we
67 * acertain a specific ordering here, which is is used via the atexit() hook.
68 */
69void cleanUp()
70{
71 printTimings();
72 Chronos::purgeInstance();
73
74 RandomNumberDistributionFactory::purgeInstance();
75 RandomNumberEngineFactory::purgeInstance();
76 RandomNumberGeneratorFactory::purgeInstance();
77 FormatParserStorage::purgeInstance();
78 ChangeTracker::purgeInstance();
79 World::purgeInstance();
80 MenuDescription::purgeInstance();
81 UIFactory::purgeInstance();
82 ValueStorage::purgeInstance();
83 CommandLineParser::purgeInstance();
84 MoleCuilder::ActionRegistry::purgeInstance();
85 MoleCuilder::OptionRegistry::purgeInstance();
86 MoleCuilder::ActionHistory::purgeInstance();
87 // we have to remove these two static as otherwise their boost::shared_ptrs are still present
88 MoleCuilder::Action::removeStaticStateEntities();
89 // put some static variables' dynamic contents on the Memory::ignore map to avoid their
90 // admonishing lateron
91 AddStaticEntitiestoIgnoreList();
92 logger::purgeInstance();
93 errorLogger::purgeInstance();
94#ifdef LOG_OBSERVER
95 cout << observerLog().getLog();
96#endif
97 Memory::getState();
98}
99
100/** We give a list of all times per action and a total time.
101 *
102 */
103void printTimings()
104{
105 const MoleCuilder::ActionRegistry &AR = MoleCuilder::ActionRegistry::getInstance();
106 const Chronos &Chron = Chronos::getInstance();
107 std::cout << "(Non-zero) Times used per Action [seconds]:" << std::endl;
108 for (MoleCuilder::ActionRegistry::const_iterator iter = AR.getBeginIter(); iter != AR.getEndIter(); ++iter)
109 if (Chron.getTime(iter->first) != 0.) { // dont give if action has not been used
110 std::cout << " " << setiosflags(ios::left) << setw(24) << setfill('.') << iter->first;
111 std::cout << setiosflags(ios::left) << setprecision(6) << fixed << Chron.getTime(iter->first) << std::endl;
112 }
113 std::cout << "Total Time: " << Chron.SumUpTotalTime() << " seconds" << std::endl;
114 std::cout << "Total Actions called: " << Chron.SumUpTotalFunctions() << std::endl;
115}
Note: See TracBrowser for help on using the repository browser.