source: src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp@ f4b5b7

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 f4b5b7 was 861874, checked in by Frederik Heber <heber@…>, 15 years ago

libMolecuilderAction is now a shared lib via libtool.

This is all taken from the example available at http://www.openismus.com/documents/linux/building_libraries/building_libraries/building_libraries.shtml.

Necessary changes:

  • ValueStorage is now part of Actions, not of UIElements anymore (which is actually as it should have been right away, only Dialog uses ValueStorage and for all Actions ValueStorage is the simple adapter pattern to MapOfActions needed the relax (compilation) dependencies).
  • new files:
    • config/ltmain.sh (scipt for libtool)
    • libmolecuilder_config.h.in (extra config.h which is copied along with lib to contain how it has been compiled)
    • molecuilder.pc.in (package config information
  • BUGFIX: m4/gwqt4.m4 added -L$X_libraries, however $X_libraries was nowhere set and libtool admonished the empty "-L"
  • libMolecuilderUI now depends on libMolecuilderAction
  • all unit tests now have libMolecuilderAction and libMolecuilderUI due to non-interactive calls of actions
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 * SurfaceCorrelationAction.cpp
3 *
4 * Created on: May 9, 2010
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
11#include "Actions/ActionRegistry.hpp"
12#include "analysis_correlation.hpp"
13#include "boundary.hpp"
14#include "linkedcell.hpp"
15#include "verbose.hpp"
16#include "log.hpp"
17#include "element.hpp"
18#include "molecule.hpp"
19#include "periodentafel.hpp"
20#include "vector.hpp"
21#include "World.hpp"
22
23#include <iostream>
24#include <string>
25
26using namespace std;
27
28#include "UIElements/UIFactory.hpp"
29#include "UIElements/Dialog.hpp"
30#include "Actions/ValueStorage.hpp"
31
32const char AnalysisSurfaceCorrelationAction::NAME[] = "surface-correlation";
33
34AnalysisSurfaceCorrelationAction::AnalysisSurfaceCorrelationAction() :
35 Action(NAME)
36{}
37
38AnalysisSurfaceCorrelationAction::~AnalysisSurfaceCorrelationAction()
39{}
40
41void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic) {
42 ValueStorage::getInstance().setCurrentValue("elements", elements);
43 ValueStorage::getInstance().setCurrentValue("molecule-by-id", mol);
44 ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
45 ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
46 ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
47 ValueStorage::getInstance().setCurrentValue("output-file", outputname);
48 ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
49 ValueStorage::getInstance().setCurrentValue("periodic", periodic);
50 ActionRegistry::getInstance().getActionByName(AnalysisSurfaceCorrelationAction::NAME)->call(Action::NonInteractive);
51};
52
53
54Dialog* AnalysisSurfaceCorrelationAction::fillDialog(Dialog *dialog) {
55 ASSERT(dialog,"No Dialog given when filling action dialog");
56
57 dialog->queryMolecule("molecule-by-id", ValueStorage::getInstance().getDescription("molecule-by-id"));
58 dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
59 dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
60 dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
61 dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
62 dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
63 dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
64 dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
65
66 return dialog;
67}
68
69Action::state_ptr AnalysisSurfaceCorrelationAction::performCall() {
70 int ranges[3] = {1, 1, 1};
71 double BinEnd = 0.;
72 double BinStart = 0.;
73 double BinWidth = 0.;
74 molecule *Boundary = NULL;
75 string outputname;
76 string binoutputname;
77 bool periodic;
78 ofstream output;
79 ofstream binoutput;
80 std::vector< element *> elements;
81 string type;
82 Vector Point;
83 BinPairMap *binmap = NULL;
84
85 // obtain information
86 ValueStorage::getInstance().queryCurrentValue("molecule-by-id", Boundary);
87 ValueStorage::getInstance().queryCurrentValue("elements", elements);
88 ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
89 ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
90 ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
91 ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
92 ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
93 ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
94
95 // execute action
96 output.open(outputname.c_str());
97 binoutput.open(binoutputname.c_str());
98 ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
99 const double radius = 4.;
100 double LCWidth = 20.;
101 if (BinEnd > 0) {
102 if (BinEnd > 2.*radius)
103 LCWidth = BinEnd;
104 else
105 LCWidth = 2.*radius;
106 }
107
108 // get the boundary
109 class Tesselation *TesselStruct = NULL;
110 const LinkedCell *LCList = NULL;
111 // find biggest molecule
112 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
113 int counter = molecules.size();
114 LCList = new LinkedCell(Boundary, LCWidth);
115 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
116 CorrelationToSurfaceMap *surfacemap = NULL;
117 if (periodic)
118 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
119 else
120 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
121 delete LCList;
122 OutputCorrelationToSurface(&output, surfacemap);
123 // check whether radius was appropriate
124 {
125 double start; double end;
126 GetMinMax( surfacemap, start, end);
127 if (LCWidth < end)
128 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
129 }
130 binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
131 OutputCorrelation ( &binoutput, binmap );
132 delete TesselStruct; // surfacemap contains refs to triangles! delete here, not earlier!
133 delete(binmap);
134 delete(surfacemap);
135 output.close();
136 binoutput.close();
137 return Action::success;
138}
139
140Action::state_ptr AnalysisSurfaceCorrelationAction::performUndo(Action::state_ptr _state) {
141 return Action::success;
142}
143
144Action::state_ptr AnalysisSurfaceCorrelationAction::performRedo(Action::state_ptr _state){
145 return Action::success;
146}
147
148bool AnalysisSurfaceCorrelationAction::canUndo() {
149 return true;
150}
151
152bool AnalysisSurfaceCorrelationAction::shouldUndo() {
153 return true;
154}
155
156const string AnalysisSurfaceCorrelationAction::getName() {
157 return NAME;
158}
Note: See TracBrowser for help on using the repository browser.