Changes in / [06f4ef6:b6da28]
- Files:
-
- 136 added
- 24 deleted
- 295 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r06f4ef6 rb6da28 1 18.04.2008 2 + essential switch in structure of ESPACK. Instead of having everything 3 relative to pcp, we now have three tantamount packages: pcp, utilities and 4 molecuilder -
Makefile.am
r06f4ef6 rb6da28 7 7 doc: 8 8 cd doc && make doxygen-docs 9 10 unity: 11 cd src && make unity -
README
r06f4ef6 rb6da28 1 <<<<<<< HEAD 1 2 # Project: Molecuilder 2 3 # … … 6 7 7 8 ... is a tool that started as a mean to edit pcp configuration files (adding/remvoing groups of atoms, measuring bond lengths and so forth) and has grown into the many-body fragmentation test base of a new method coined BOSSANOVA (Bond Order diSSection in an ANOVA (ANalysis Of VAriance) -like fashion). It spills out configuration files for each fragment and includes joining and analyzing programs, to put together the partial energies and forces of each fragment to the total energy and forces. It allows for a complete Born-Oppenheimer molecular dynamics run. 9 ======= 10 # Project: ParallelCarParrinello 11 # Jan Hamaekers 12 # Frederik Heber 13 # 2005 14 # 15 # File: README 16 17 Electronic Structure PACKage 18 19 Is a collection of mathematical-physical programs to calculate via various ab-initio methods 20 such as density functional theory or Hartree-Fock electronic(-magnetic) properties including 21 the molecular (Car&Parrinello) dynamics of a many electron system. Especially, the linear 22 response of the system to a external magnetic field in a perturbation approach in terms of 23 susceptibility and chemical shielding is implemented via the Density Functional Perturbation 24 Theory. It was developed mainly by Jan Hamaekers (pcp) with additional code by Frederik Heber 25 (dfpt part in pcp) and also Ralf Wildenhuis (Gauss) at the Institute for Numerical Simulation 26 at the University of Bonn[1]. 27 28 29 >>>>>>> FETCH_HEAD 8 30 9 31 INSTALLATION NOTES 10 32 ================== 11 33 34 <<<<<<< HEAD 12 35 The following packages are needed 13 36 * GCC or alike 14 37 * GSL (GNU Scientific Library, available at http://www.gnu.org/software/gsl) 38 * Boost 1.4 or newer 39 ======= 40 In general gcc or alike is needed to compile the sources, for more specific demands see the README files in the sub directory of each package part. 41 42 LINKS 43 ===== 44 [1] http://www.ins.uni-bonn.de/ 45 >>>>>>> FETCH_HEAD -
configure.ac
r06f4ef6 rb6da28 8 8 AC_CONFIG_HEADER([config.h]) 9 9 10 AM_INIT_AUTOMAKE(dist-bzip2 )10 AM_INIT_AUTOMAKE(dist-bzip2 parallel-tests) 11 11 12 12 # Checks for programs. … … 33 33 AX_BOOST_THREAD 34 34 #AX_BOOST_SERIALIZATION 35 36 #QT4 libraries 37 gw_CHECK_QT4 38 AX_CHECK_GLU 39 AC_MSG_NOTICE(["GLU_CFLAGS: $GLU_CFLAGS, GLU_CXXFLAGS: $GLU_CXXFLAGS, GLU_LDFLAGS: $GLU_LDFLAGS, GLU_LIBS: $GLU_LIBS"]) 40 35 41 36 42 # Checks for header files. … … 66 72 67 73 # add replacement/saturation hydrogen or not 68 AC_ARG_ENABLE([ecut],AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient (default is yes)]),69 [enable_ecut=$enableval], [enable_ecut= yes])74 AC_ARG_ENABLE([ecut],AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient (default is no)]), 75 [enable_ecut=$enableval], [enable_ecut=no]) 70 76 if test x"$enable_ecut" = xyes; then 71 77 AC_DEFINE(HAVE_ECUT,1, ["Use ECut TestRunnerClient instead of our own."]) -
doc/Doxyfile
r06f4ef6 rb6da28 258 258 # Configuration::additions related to the search engine 259 259 #--------------------------------------------------------------------------- 260 SEARCHENGINE = NO260 SEARCHENGINE = YES -
doc/class structure.uxf
r06f4ef6 rb6da28 21 21 22 22 23 // This text will be stored with each diagram; use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1855</x><y>2 94</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo23 // This text will be stored with each diagram; use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1855</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo 24 24 -- 25 25 -x,v,F: Vector … … 28 28 #AtomInfo(); 29 29 #~AtomInfo(); 30 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1645</x><y> 315</y><w>223</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>210;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1274</x><y>147</y><w>392</w><h>259</h></coordinates><panel_attributes>Element30 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1645</x><y>231</y><w>223</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>210;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1274</x><y>63</y><w>392</w><h>259</h></coordinates><panel_attributes>Element 31 31 -- 32 32 mass: double … … 49 49 #~element(); 50 50 #Output(ofstream * const out) const: bool 51 #Checkout(ofstream * const out, const int No, const int NoOfAtoms) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1960</x><y> 532</y><w>280</w><h>161</h></coordinates><panel_attributes>BondedParticle51 #Checkout(ofstream * const out, const int No, const int NoOfAtoms) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1960</x><y>448</y><w>280</w><h>161</h></coordinates><panel_attributes>BondedParticle 52 52 -- 53 53 -- … … 63 63 #OutputBondOfAtom() const 64 64 #OutputAdjacency(ofstream *AdjacencyFile) const 65 #OutputOrder(ofstream *file) const</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y> 343</y><w>258</w><h>202</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>245;21;245;154;21;154;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1925</x><y>343</y><w>293</w><h>202</h></coordinates><panel_attributes>lt=<<-66 </panel_attributes><additional_attributes>21;21;21;154;280;154;280;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y> 343</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2359</x><y>294</y><w>147</w><h>70</h></coordinates><panel_attributes>BondedParticleInfo65 #OutputOrder(ofstream *file) const</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>258</w><h>202</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>245;21;245;154;21;154;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1925</x><y>259</y><w>293</w><h>202</h></coordinates><panel_attributes>lt=<<- 66 </panel_attributes><additional_attributes>21;21;21;154;280;154;280;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2359</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>BondedParticleInfo 67 67 -- 68 68 AdaptiveOrder: unsigned char … … 71 71 #BondedParticleInfo() 72 72 #~BondedParticleInfo() 73 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2079</x><y> 280</y><w>217</w><h>84</h></coordinates><panel_attributes>ParticleInfo73 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2079</x><y>196</y><w>217</w><h>84</h></coordinates><panel_attributes>ParticleInfo 74 74 -- 75 75 nr: int … … 79 79 #~ParticleInfo() 80 80 #ostream & operator << (ostream &ost) const 81 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2485</x><y> 315</y><w>174</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;161;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2646</x><y>245</y><w>147</w><h>133</h></coordinates><panel_attributes>BondList81 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2485</x><y>231</y><w>174</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;161;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2646</x><y>161</y><w>147</w><h>133</h></coordinates><panel_attributes>BondList 82 82 {Some Properties} 83 83 -- … … 90 90 Responsibilities 91 91 -- Resp1 92 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1372</x><y> 427</y><w>147</w><h>105</h></coordinates><panel_attributes>GraphNodeInfo92 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1372</x><y>343</y><w>147</w><h>105</h></coordinates><panel_attributes>GraphNodeInfo 93 93 -- 94 94 -- … … 102 102 #GraphNodeInfo() 103 103 #~GraphNodeInfo() 104 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y> 609</y><w>126</w><h>70</h></coordinates><panel_attributes>GraphNode104 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y>525</y><w>126</w><h>70</h></coordinates><panel_attributes>GraphNode 105 105 -- 106 106 -- … … 109 109 #OutputGraphInfo() const 110 110 #OutputComponentNumber() const 111 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y> 343</y><w>748</w><h>279</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>735;21;735;70;217;70;217;210;21;210;21;266</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>511</y><w>34</w><h>111</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>756</y><w>588</w><h>245</h></coordinates><panel_attributes>Atom111 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>259</y><w>748</w><h>279</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>735;21;735;70;217;70;217;210;21;210;21;266</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>427</y><w>34</w><h>111</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>672</y><w>588</w><h>245</h></coordinates><panel_attributes>Atom 112 112 -- 113 113 sort: int* … … 129 129 #DistanceToVector(const Vector &origin) const: double 130 130 #DistanceSquaredToVector(const Vector &origin) const: double 131 #IsInParallelepiped(const Vector offset, const double *parallelepiped) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1379</x><y> 511</y><w>83</w><h>258</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;21;182;70;182;70;245</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2226</x><y>749</y><w>504</w><h>210</h></coordinates><panel_attributes>TrajectoryParticle131 #IsInParallelepiped(const Vector offset, const double *parallelepiped) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1379</x><y>427</y><w>83</w><h>258</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;21;182;70;182;70;245</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2226</x><y>665</y><w>504</w><h>210</h></coordinates><panel_attributes>TrajectoryParticle 132 132 -- 133 133 -- … … 147 147 #Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration) 148 148 #Thermostat_NoseHoover_init(int Step, double *delta_alpha) 149 #Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2149</x><y> 343</y><w>209</w><h>419</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;112;196;112;196;406</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1967</x><y>343</y><w>391</w><h>419</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;112;378;112;378;406</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1617</x><y>574</y><w>203</w><h>70</h></coordinates><panel_attributes>TrajectoryParticleInfo149 #Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2149</x><y>259</y><w>209</w><h>419</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;112;196;112;196;406</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1967</x><y>259</y><w>391</w><h>419</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;112;378;112;378;406</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1617</x><y>490</y><w>203</w><h>70</h></coordinates><panel_attributes>TrajectoryParticleInfo 150 150 -- 151 151 Trajectory: struct {vector<Vector> R,U,V} … … 153 153 -- 154 154 #TrajectoryParticleInfo() 155 #~TrajectoryParticleInfo()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1757</x><y> 623</y><w>601</w><h>139</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;105;588;105;588;126</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>623</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1519</x><y>658</y><w>244</w><h>111</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;56;231;56;231;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>448</y><w>147</w><h>112</h></coordinates><panel_attributes>TesselPoint155 #~TrajectoryParticleInfo()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1757</x><y>539</y><w>601</w><h>139</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;105;588;105;588;126</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>539</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1519</x><y>574</y><w>244</w><h>111</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>21;21;21;56;231;56;231;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>364</y><w>147</w><h>112</h></coordinates><panel_attributes>TesselPoint 156 156 -- 157 157 -id: Long … … 163 163 Responsibilities 164 164 -- Resp1 165 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y> 539</y><w>146</w><h>230</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>133;21;133;175;21;175;21;217</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>672</y><w>398</w><h>97</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>385;21;385;42;21;42;21;84</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>343</y><w>398</w><h>426</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>385;21;385;168;196;168;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>343</y><w>209</w><h>426</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>196;21;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>833</x><y>854</y><w>357</w><h>224</h></coordinates><panel_attributes>Bond165 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>455</y><w>146</w><h>230</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>133;21;133;175;21;175;21;217</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>588</y><w>398</w><h>97</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>385;21;385;42;21;42;21;84</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>398</w><h>426</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>385;21;385;168;196;168;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>209</w><h>426</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>196;21;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>833</x><y>770</y><w>357</w><h>224</h></coordinates><panel_attributes>Bond 166 166 -- 167 167 HydrogenBond: int … … 182 182 #bond() 183 183 #bond(atom *left, atom *right, const int degree=1, const int number=0) 184 #~bond()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1834</x><y> 707</y><w>107</w><h>125</h></coordinates><panel_attributes>lt=<<<<-185 3</panel_attributes><additional_attributes>42;112;91;112;91;35;21;35;21;49</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>8 96</y><w>132</w><h>49</h></coordinates><panel_attributes>lt=<<<<-186 2</panel_attributes><additional_attributes>21;35;119;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>770</x><y> 742</y><w>111</w><h>167</h></coordinates><panel_attributes>lt=<<<<-187 2</panel_attributes><additional_attributes>63;154;28;154;28;35;98;35;98;112</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1113</x><y>1 330</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph184 #~bond()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1834</x><y>623</y><w>107</w><h>125</h></coordinates><panel_attributes>lt=<<<<- 185 3</panel_attributes><additional_attributes>42;112;91;112;91;35;21;35;21;49</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>812</y><w>132</w><h>49</h></coordinates><panel_attributes>lt=<<<<- 186 2</panel_attributes><additional_attributes>21;35;119;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>770</x><y>658</y><w>111</w><h>167</h></coordinates><panel_attributes>lt=<<<<- 187 2</panel_attributes><additional_attributes>63;154;28;154;28;35;98;35;98;112</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1113</x><y>1246</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph 188 188 -- 189 189 max_distance: double … … 199 199 double &MinDistance, double &MaxDistance, bool IsAngstroem) 200 200 #CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, 201 double &MinDistance, double &MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1 407</y><w>167</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;154;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1750</x><y>1365</y><w>147</w><h>133</h></coordinates><panel_attributes>MatrixContainer201 double &MinDistance, double &MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1323</y><w>167</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;154;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1750</x><y>1281</y><w>147</w><h>133</h></coordinates><panel_attributes>MatrixContainer 202 202 -- 203 203 -id: Long … … 209 209 Responsibilities 210 210 -- Resp1 211 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y> 539</y><w>511</w><h>1050</h></coordinates><panel_attributes>config211 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y>455</y><w>511</w><h>1050</h></coordinates><panel_attributes>config 212 212 -- 213 213 PsiType: int … … 297 297 #SetDefaultPath(const char * const path); 298 298 #InitThermostats(); 299 #ParseThermostats(class ConfigFileBuffer * const fb);</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1 428</y><w>636</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;623;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>84</y><w>121</w><h>139</h></coordinates><panel_attributes>lt=<<<<-300 2</panel_attributes><additional_attributes>70;126;105;126;105;35;21;35;21;63</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2520</x><y> 980</y><w>224</w><h>140</h></coordinates><panel_attributes><<Singleton>>299 #ParseThermostats(class ConfigFileBuffer * const fb);</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1344</y><w>636</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;623;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>0</y><w>121</w><h>139</h></coordinates><panel_attributes>lt=<<<<- 300 2</panel_attributes><additional_attributes>70;126;105;126;105;35;21;35;21;63</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2520</x><y>896</y><w>224</w><h>140</h></coordinates><panel_attributes><<Singleton>> 301 301 errorLogger 302 302 -- … … 310 310 #static setVerbosity(int verbosityLevel); 311 311 #protected errorLogger() 312 #protected ~errorLogger()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2093</x><y> 1064</y><w>364</w><h>35</h></coordinates><panel_attributes>KeyCompare312 #protected ~errorLogger()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2093</x><y>980</y><w>364</w><h>35</h></coordinates><panel_attributes>KeyCompare 313 313 -- 314 314 -- 315 315 #operator() (const KeySet SubgraphA, const KeySet SubgraphB) const: bool 316 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1169</x><y>1 218</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments316 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1169</x><y>1134</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments 317 317 -- 318 318 ANOVAOrder: int … … 322 322 ShortestPathList: int * 323 323 UsedList: bool ** 324 BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1 253</y><w>692</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>679;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1120</x><y>980</y><w>251</w><h>307</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>49;294;21;294;21;224;238;224;238;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>840</x><y>1127</y><w>245</w><h>28</h></coordinates><panel_attributes>Graph324 BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1169</y><w>692</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>679;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1120</x><y>896</y><w>251</w><h>307</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>49;294;21;294;21;224;238;224;238;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>840</x><y>1043</y><w>245</w><h>28</h></coordinates><panel_attributes>Graph 325 325 {map <KeySet, NumberValuePair, KeyCompare>} 326 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1 134</y><w>321</w><h>153</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>308;140;21;140;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>945</x><y>1190</y><w>56</w><h>28</h></coordinates><panel_attributes>KeySet327 {set<int>}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>11 97</y><w>237</w><h>90</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>224;77;21;77;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1085</x><y>1057</y><w>99</w><h>230</h></coordinates><panel_attributes>lt=<<<<-328 0...N X 0...N</panel_attributes><additional_attributes>84;217;56;217;56;112;21;112;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>2 282</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params326 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1050</y><w>321</w><h>153</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>308;140;21;140;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>945</x><y>1106</y><w>56</w><h>28</h></coordinates><panel_attributes>KeySet 327 {set<int>}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>1113</y><w>237</w><h>90</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>224;77;21;77;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1085</x><y>973</y><w>99</w><h>230</h></coordinates><panel_attributes>lt=<<<<- 328 0...N X 0...N</panel_attributes><additional_attributes>84;217;56;217;56;112;21;112;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>2198</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params 329 329 -- 330 330 vectors: const Vector ** 331 331 num: int 332 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1043</x><y> 266</y><w>147</w><h>35</h></coordinates><panel_attributes>lsq_params333 -- 334 x: gsl_vector *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y> 266</y><w>118</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram>332 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1043</x><y>182</y><w>147</w><h>35</h></coordinates><panel_attributes>lsq_params 333 -- 334 x: gsl_vector *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>182</y><w>118</w><h>34</h></coordinates><panel_attributes>lt=<<<<-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram> -
src/Actions/Action.cpp
r06f4ef6 rb6da28 13 13 #include "Actions/ActionRegistry.hpp" 14 14 #include "Actions/ActionHistory.hpp" 15 #include "Exceptions/MissingValueException.hpp" 16 #include "UIElements/Dialog.hpp" 15 17 #include "Helpers/MemDebug.hpp" 18 #include "UIElements/UIFactory.hpp" 19 20 #include "log.hpp" 21 #include "verbose.hpp" 16 22 17 23 using namespace std; … … 29 35 { 30 36 if(_doRegister){ 31 ActionRegistry::getInstance().register Action(this);37 ActionRegistry::getInstance().registerInstance(this); 32 38 } 33 39 } … … 40 46 } 41 47 42 void Action::call(){ 48 Dialog * Action::createDialog(){ 49 Dialog *dialog = UIFactory::getInstance().makeDialog(); 50 return fillDialog(dialog); 51 } 52 53 void Action::call(enum QueryOptions flag){ 43 54 if(!isActive()){ 44 55 return; 45 56 } 46 57 // forward to private virtual 47 state_ptr state = performCall(); 58 if (flag == Interactive) { 59 Dialog* dialog = createDialog(); 60 if (dialog->hasQueries()) { 61 dialog->display(); 62 } 63 delete(dialog); 64 } 65 state_ptr state = Action::failure; 66 // try { 67 state = performCall(); 68 // } catch(MissingValueException&) { 69 // DoeLog(0) && (eLog() << Verbose(0) << "There is a value missing for action " << getName() << endl); 70 // }; 71 48 72 if(shouldUndo() && state != failure){ 49 73 if(canUndo()){ -
src/Actions/Action.hpp
r06f4ef6 rb6da28 16 16 class ActionState; 17 17 class ActionSequence; 18 class Dialog; 18 19 19 20 /** … … 44 45 * hasRedo() method respectively. 45 46 * 47 * Note that an Action always has two functions createDialog() and performCall(). The former 48 * returns a Dialog filled with query...() functions for all information that we need from the 49 * user. The latter must not contain any interaction but just uses these values (which are 50 * temporarily stored by class ValueStorage) to perform the Action. 51 * 52 * Furthermore, there is a global action function that makes the action callable with already 53 * present parameters (i.e. without user interaction and for internal use within the code only). 54 * This function is basically just a macro, that puts the parameters into the ValueStorage and 55 * calls Action::call(Action::NonInteractive). 56 * 46 57 * Actions can be set to be active or inactive. If an action is set to inactive it is signaling, that 47 58 * some condition necessary for this action to be executed is not currently met. For example the … … 78 89 * Building actions is fairly easy. Simply derive from the abstract Action base class and implement 79 90 * the virtual methods. The main code that needs to be executed upon call() should be implemented in 80 * the performCall() method. You should also indicate whether the action supports undo by implementing 91 * the performCall() method. Any user interaction should be placed into the dialog returned by 92 * createDialog(). You should also indicate whether the action supports undo by implementing 81 93 * the shouldUndo() and canUndo() methods to return the appropriate flags. 94 * 95 * Also, create the global function to allow for easy calling of your function internally (i.e. 96 * without user interaction). It should have the name of the Action class without the suffix Action. 82 97 * 83 98 * The constructor of your derived class also needs to call the Base constructor, passing it the … … 122 137 * <li/> derive YourAction from Action 123 138 * <li/> pass name and flag for registry to the base constructor 124 * <li/> implement performCall(), performUndo(), performRedo() 139 * <li/> implement createDialog(), performCall(), performUndo(), performRedo() 140 * <li/> implement the global function call/macro. 125 141 * <li/> implement the functions that return the flags for the undo mechanism 126 142 * <li/> Derive YourActionState from ActionState as necessary … … 130 146 * 131 147 * <ul> 148 * <li/> createDialog(): 149 * <ul> 150 * <li/> Call makeDialog() from the UIFactory. 151 * <li/> Call any needed Dialog->Query...() for the values you need with specific keywords. 152 * <li/> if the action needs to save a state return a custom state object 153 * <li/> otherwise return Action::success 154 * </ul> 132 155 * <li/> performCall(): 133 156 * <ul> 157 * <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching 158 * key words from createDialog(). 134 159 * <li/> do whatever is needed to make the action work 135 160 * <li/> if the action was abborted return Action::failure … … 256 281 public: 257 282 283 enum QueryOptions {Interactive, NonInteractive}; 284 258 285 /** 259 286 * This type is used to store pointers to ActionStates while allowing multiple ownership … … 278 305 * If the call needs to undone you have to use the History, to avoid destroying 279 306 * invariants used by the History. 280 */ 281 void call(); 307 * 308 * Note that this call can be Interactive (i.e. a dialog will ask the user for 309 * necessary information) and NonInteractive (i.e. the information will have to 310 * be present already within the ValueStorage class or else a MissingArgumentException 311 * is thrown) 312 */ 313 void call(enum QueryOptions state = Interactive); 282 314 283 315 /** … … 337 369 static state_ptr failure; 338 370 371 /** 372 * This creates the dialog requesting the information needed for this action from the user 373 * via means of the user interface. 374 */ 375 Dialog * createDialog(); 376 339 377 private: 340 /** 341 * This is called internally when the call is being done. Implement this method to do the actuall 378 379 virtual Dialog * fillDialog(Dialog*)=0; 380 381 /** 382 * This is called internally when the call is being done. Implement this method to do the actual 342 383 * work of the Action. Implement this in your Derived classes. Needs to return a state that can be 343 384 * used to undo the action. -
src/Actions/ActionHistory.cpp
r06f4ef6 rb6da28 86 86 } 87 87 88 Dialog* ActionHistory::UndoAction::fillDialog(Dialog *dialog){ 89 ASSERT(dialog,"No Dialog given when filling action dialog"); 90 return dialog; 91 } 92 88 93 Action::state_ptr ActionHistory::UndoAction::performCall(){ 89 94 hist->undoLast(); … … 120 125 } 121 126 127 Dialog* ActionHistory::RedoAction::fillDialog(Dialog *dialog){ 128 ASSERT(dialog,"No Dialog given when filling action dialog"); 129 return dialog; 130 } 131 122 132 Action::state_ptr ActionHistory::RedoAction::performCall(){ 123 133 hist->redoLast(); -
src/Actions/ActionHistory.hpp
r06f4ef6 rb6da28 38 38 39 39 virtual bool isActive(); 40 40 protected: 41 virtual Dialog * fillDialog(Dialog *dialog); 41 42 private: 42 43 virtual Action::state_ptr performCall(); … … 57 58 virtual bool isActive(); 58 59 60 protected: 61 virtual Dialog * fillDialog(Dialog *dialog); 59 62 private: 60 63 virtual Action::state_ptr performCall(); -
src/Actions/ActionRegistry.cpp
r06f4ef6 rb6da28 1 1 /* 2 * ActionRegistry.cpp2 * Registry<Action>.cpp 3 3 * 4 4 * Created on: Jan 7, 2010 … … 9 9 10 10 #include "Actions/ActionRegistry.hpp" 11 #include "Actions/Action.hpp" 11 #include "Patterns/Singleton_impl.hpp" 12 #include "Patterns/Registry_impl.hpp" 12 13 13 #include "Patterns/Singleton_impl.hpp" 14 /** Constructor for class ActionRegistry. 15 */ 16 ActionRegistry::ActionRegistry() 17 {} 14 18 15 #include <string> 16 #include "Helpers/Assert.hpp" 17 #include <iostream> 19 /** Destructor for class ActionRegistry. 20 */ 21 ActionRegistry::~ActionRegistry() 22 {} 18 23 19 using namespace std; 20 21 ActionRegistry::ActionRegistry() 24 /** Just passes on call to Registry<Action>::getByName(). 25 * \param name name of Action 26 * \return pointer to Action 27 */ 28 Action* ActionRegistry::getActionByName(const std::string name) 22 29 { 30 return getByName(name); 23 31 } 24 32 25 ActionRegistry::~ActionRegistry() 33 /** Just passes on call to Registry<Action>::isPresentByName(). 34 * \param name name of Action 35 * \return true - Action instance present, false - not 36 */ 37 bool ActionRegistry::isActionPresentByName(const std::string name) 26 38 { 27 map<const string,Action*>::iterator iter; 28 for(iter=actionMap.begin();iter!=actionMap.end();++iter) { 29 delete iter->second; 30 } 31 actionMap.clear(); 32 } 33 34 Action* ActionRegistry::getActionByName(const std::string name){ 35 map<const string,Action*>::iterator iter; 36 iter = actionMap.find(name); 37 ASSERT(iter!=actionMap.end(),"Query for an action not stored in registry"); 38 return iter->second; 39 } 40 41 bool ActionRegistry::isActionByNamePresent(const std::string name){ 42 map<const string,Action*>::iterator iter; 43 iter = actionMap.find(name); 44 return iter!=actionMap.end(); 45 } 46 47 void ActionRegistry::registerAction(Action* action){ 48 pair<map<const string,Action*>::iterator,bool> ret; 49 ret = actionMap.insert(pair<const string,Action*>(action->getName(),action)); 50 ASSERT(ret.second,"Two actions with the same name added to registry"); 51 } 52 53 void ActionRegistry::unregisterAction(Action* action){ 54 actionMap.erase(action->getName()); 55 } 56 57 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter() 58 { 59 return actionMap.begin(); 60 } 61 62 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter() 63 { 64 return actionMap.end(); 39 return isPresentByName(name); 65 40 } 66 41 67 42 CONSTRUCT_SINGLETON(ActionRegistry) 43 CONSTRUCT_REGISTRY(Action) -
src/Actions/ActionRegistry.hpp
r06f4ef6 rb6da28 1 1 /* 2 * ActionRegistry.hpp2 * Registry<Action>.hpp 3 3 * 4 4 * Created on: Jan 7, 2010 … … 9 9 #define ACTIONREGISTRY_HPP_ 10 10 11 #include <iosfwd> 11 12 #include <string> 12 13 #include <map> 13 14 15 #include "Patterns/Registry.hpp" 14 16 #include "Patterns/Singleton.hpp" 17 #include "Actions/Action.hpp" 15 18 16 class Action; 17 18 class ActionRegistry : public Singleton<ActionRegistry> 19 /** Action Registry. 20 * 21 * The Action registry is a storage for any Action instance to retrieved by name. 22 * It is a singleton and can be called from anywhere. 23 * 24 */ 25 class ActionRegistry : public Singleton<ActionRegistry>, public Registry<Action> 19 26 { 20 27 friend class Singleton<ActionRegistry>; 28 //friend class Registry<Action>; 29 21 30 public: 22 Action* getActionByName(const std::string); 23 bool isActionByNamePresent(const std::string name); 24 void registerAction(Action*); 25 void unregisterAction(Action*); 26 27 std::map<const std::string,Action*>::iterator getBeginIter(); 28 std::map<const std::string,Action*>::iterator getEndIter(); 29 30 private: 31 std::map<const std::string,Action*> actionMap; 31 Action* getActionByName(const std::string name); 32 bool isActionPresentByName(const std::string name); 32 33 33 34 private: 34 35 ActionRegistry(); 35 virtual~ActionRegistry();36 ~ActionRegistry(); 36 37 }; 37 38 -
src/Actions/ActionSequence.cpp
r06f4ef6 rb6da28 10 10 #include "Actions/ActionSequence.hpp" 11 11 #include "Actions/Action.hpp" 12 #include "UIElements/Dialog.hpp" 12 13 13 14 #include "Helpers/Assert.hpp" … … 36 37 return theAction; 37 38 } 39 } 40 41 // this method is used outside the ActionModule 42 // Each action registers itself with the history 43 Dialog* ActionSequence::fillAllDialogs(Dialog *dialog){ 44 for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){ 45 dialog = (*it)->fillDialog(dialog); 46 } 47 return dialog; 38 48 } 39 49 -
src/Actions/ActionSequence.hpp
r06f4ef6 rb6da28 36 36 protected: 37 37 stateSet callAll(bool); // Dummy parameter to allow overloading 38 Dialog* fillAllDialogs(Dialog *dialog); 38 39 stateSet undoAll(stateSet); 39 40 stateSet redoAll(stateSet); -
src/Actions/AnalysisAction/MolecularVolumeAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "boundary.hpp" 12 13 #include "config.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume"; … … 35 36 {} 36 37 38 void AnalysisMolecularVolume() { 39 ActionRegistry::getInstance().getActionByName(AnalysisMolecularVolumeAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog * AnalysisMolecularVolumeAction::fillDialog(Dialog *dialog) { 43 ASSERT(dialog,"No Dialog given when filling action dialog"); 44 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 37 49 Action::state_ptr AnalysisMolecularVolumeAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog(); 39 molecule *mol = NULL; 50 int molID = -1; 51 // obtain information 52 ValueStorage::getInstance().queryCurrentValue(NAME, molID); 40 53 41 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));42 43 if(dialog->display()) {54 // execute action 55 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 56 molecule *mol = iter->second; 44 57 class Tesselation *TesselStruct = NULL; 45 58 const LinkedCell *LCList = NULL; … … 47 60 LCList = new LinkedCell(mol, 10.); 48 61 config * const configuration = World::getInstance().getConfig(); 49 //FindConvexBorder(mol, LCList, argv[argptr]); 62 Boundaries *BoundaryPoints = NULL; 63 //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); 50 64 FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL); 51 65 //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]); … … 56 70 delete(TesselStruct); 57 71 delete(LCList); 58 delete dialog;59 return Action::success;60 } else {61 delete dialog;62 return Action::failure;63 72 } 73 return Action::success; 64 74 } 65 75 66 76 Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) { 67 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 68 69 return Action::failure; 70 // string newName = state->mol->getName(); 71 // state->mol->setName(state->lastName); 72 // 73 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 77 return Action::success; 74 78 } 75 79 76 80 Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){ 77 return Action:: failure;81 return Action::success; 78 82 } 79 83 80 84 bool AnalysisMolecularVolumeAction::canUndo() { 81 return false;85 return true; 82 86 } 83 87 84 88 bool AnalysisMolecularVolumeAction::shouldUndo() { 85 return false;89 return true; 86 90 } 87 91 -
src/Actions/AnalysisAction/MolecularVolumeAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void AnalysisMolecularVolume(); 14 13 15 class AnalysisMolecularVolumeAction : public Action { 16 friend void AnalysisMolecularVolume(); 14 17 public: 15 18 AnalysisMolecularVolumeAction(); … … 20 23 21 24 virtual const std::string getName(); 25 26 protected: 27 virtual Dialog * fillDialog(Dialog*); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/AnalysisAction/PairCorrelationAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "analysis_correlation.hpp" 12 13 #include "boundary.hpp" 13 14 #include "linkedcell.hpp" 15 #include "verbose.hpp" 14 16 #include "log.hpp" 15 17 #include "element.hpp" … … 26 28 #include "UIElements/UIFactory.hpp" 27 29 #include "UIElements/Dialog.hpp" 28 #include " Actions/MapOfActions.hpp"30 #include "UIElements/ValueStorage.hpp" 29 31 30 32 const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation"; … … 37 39 {} 38 40 41 void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) { 42 ValueStorage::getInstance().setCurrentValue("elements", elements); 43 ValueStorage::getInstance().setCurrentValue("bin-start", BinStart); 44 ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth); 45 ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd); 46 ValueStorage::getInstance().setCurrentValue("output-file", outputname); 47 ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname); 48 ValueStorage::getInstance().setCurrentValue("periodic", periodic); 49 ActionRegistry::getInstance().getActionByName(AnalysisPairCorrelationAction::NAME)->call(Action::NonInteractive); 50 }; 51 52 53 Dialog* AnalysisPairCorrelationAction::fillDialog(Dialog* dialog) { 54 ASSERT(dialog,"No Dialog given when filling action dialog"); 55 56 dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements")); 57 dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start")); 58 dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width")); 59 dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end")); 60 dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file")); 61 dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file")); 62 dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic")); 63 64 return dialog; 65 } 66 39 67 Action::state_ptr AnalysisPairCorrelationAction::performCall() { 40 Dialog *dialog = UIFactory::getInstance().makeDialog();41 68 int ranges[3] = {1, 1, 1}; 42 69 double BinEnd = 0.; … … 53 80 Vector Point; 54 81 BinPairMap *binmap = NULL; 55 MoleculeListClass *molecules = World::getInstance().getMolecules();56 82 57 // first dialog: Obtain which type of correlation58 dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME));59 if(dialog->display()) {60 delete dialog;61 } else {62 delete dialog;63 return Action::failure;64 }83 // obtain information 84 ValueStorage::getInstance().queryCurrentValue("elements", elements); 85 ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart); 86 ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth); 87 ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd); 88 ValueStorage::getInstance().queryCurrentValue("output-file", outputname); 89 ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname); 90 ValueStorage::getInstance().queryCurrentValue("periodic", periodic); 65 91 66 // second dialog: Obtain parameters specific to this type 67 dialog = UIFactory::getInstance().makeDialog(); 68 if (type == "P") 69 dialog->queryVector("position", &Point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position")); 70 if (type == "S") 71 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id")); 72 dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements")); 73 dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start")); 74 dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width")); 75 dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end")); 76 dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file")); 77 dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file")); 78 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic")); 79 80 if(dialog->display()) { 81 output.open(outputname.c_str()); 82 binoutput.open(binoutputname.c_str()); 83 PairCorrelationMap *correlationmap = NULL; 84 if (type == "E") { 85 PairCorrelationMap *correlationmap = NULL; 86 if (periodic) 87 correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges); 88 else 89 correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements); 90 //OutputCorrelationToSurface(&output, correlationmap); 91 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 92 } else if (type == "P") { 93 cout << "Point to correlate to is " << Point << endl; 94 CorrelationToPointMap *correlationmap = NULL; 95 if (periodic) 96 correlationmap = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges); 97 else 98 correlationmap = CorrelationToPoint(molecules, elements, &Point); 99 //OutputCorrelationToSurface(&output, correlationmap); 100 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 101 } else if (type == "S") { 102 ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation."); 103 const double radius = 4.; 104 double LCWidth = 20.; 105 if (BinEnd > 0) { 106 if (BinEnd > 2.*radius) 107 LCWidth = BinEnd; 108 else 109 LCWidth = 2.*radius; 110 } 111 112 // get the boundary 113 class Tesselation *TesselStruct = NULL; 114 const LinkedCell *LCList = NULL; 115 // find biggest molecule 116 int counter = molecules->ListOfMolecules.size(); 117 bool *Actives = new bool[counter]; 118 counter = 0; 119 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 120 Actives[counter++] = (*BigFinder)->ActiveFlag; 121 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 122 } 123 LCList = new LinkedCell(Boundary, LCWidth); 124 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 125 CorrelationToSurfaceMap *surfacemap = NULL; 126 if (periodic) 127 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges); 128 else 129 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList); 130 OutputCorrelationToSurface(&output, surfacemap); 131 // check whether radius was appropriate 132 { 133 double start; double end; 134 GetMinMax( surfacemap, start, end); 135 if (LCWidth < end) 136 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); 137 } 138 binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd ); 139 } else 140 return Action::failure; 141 OutputCorrelation ( &binoutput, binmap ); 142 output.close(); 143 binoutput.close(); 144 delete(binmap); 145 delete(correlationmap); 146 delete dialog; 147 return Action::success; 148 } else { 149 delete dialog; 150 return Action::failure; 151 } 92 // execute action 93 output.open(outputname.c_str()); 94 binoutput.open(binoutputname.c_str()); 95 PairCorrelationMap *correlationmap = NULL; 96 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules(); 97 if (periodic) 98 correlationmap = PeriodicPairCorrelation(molecules, elements, ranges); 99 else 100 correlationmap = PairCorrelation(molecules, elements); 101 OutputPairCorrelation(&output, correlationmap); 102 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 103 OutputCorrelation ( &binoutput, binmap ); 104 delete(binmap); 105 delete(correlationmap); 106 output.close(); 107 binoutput.close(); 108 return Action::success; 152 109 } 153 110 154 111 Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) { 155 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 156 157 return Action::failure; 158 // string newName = state->mol->getName(); 159 // state->mol->setName(state->lastName); 160 // 161 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 112 return Action::success; 162 113 } 163 114 164 115 Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){ 165 return Action:: failure;116 return Action::success; 166 117 } 167 118 168 119 bool AnalysisPairCorrelationAction::canUndo() { 169 return false;120 return true; 170 121 } 171 122 172 123 bool AnalysisPairCorrelationAction::shouldUndo() { 173 return false;124 return true; 174 125 } 175 126 -
src/Actions/AnalysisAction/PairCorrelationAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include <string> 13 #include <vector> 14 15 class element; 16 17 void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic); 12 18 13 19 class AnalysisPairCorrelationAction : public Action { 20 friend void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic); 14 21 public: 15 22 AnalysisPairCorrelationAction(); … … 20 27 21 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog*); 22 31 private: 23 virtual Action::state_ptr performCall();32 virtual Action::state_ptr performCall(); 24 33 virtual Action::state_ptr performUndo(Action::state_ptr); 25 34 virtual Action::state_ptr performRedo(Action::state_ptr); -
src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "molecule.hpp" 12 13 #include "log.hpp" … … 20 21 #include "UIElements/UIFactory.hpp" 21 22 #include "UIElements/Dialog.hpp" 22 #include " Actions/MapOfActions.hpp"23 #include "UIElements/ValueStorage.hpp" 23 24 24 25 const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system"; … … 31 32 {} 32 33 34 void AnalysisPrincipalAxisSystem() { 35 ActionRegistry::getInstance().getActionByName(AnalysisPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive); 36 }; 37 38 Dialog* AnalysisPrincipalAxisSystemAction::fillDialog(Dialog *dialog) { 39 ASSERT(dialog,"No Dialog given when filling action dialog"); 40 41 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 42 43 return dialog; 44 } 45 33 46 Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() { 34 Dialog *dialog = UIFactory::getInstance().makeDialog();35 47 molecule *mol = NULL; 36 48 37 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));38 39 if(dialog->display()) {40 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);49 ValueStorage::getInstance().queryCurrentValue(NAME, mol); 50 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl); 51 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 52 molecule *mol = iter->second; 41 53 mol->PrincipalAxisSystem(false); 42 delete dialog;43 return Action::success;44 } else {45 delete dialog;46 return Action::failure;47 54 } 55 return Action::success; 48 56 } 49 57 50 58 Action::state_ptr AnalysisPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) { 51 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 52 53 return Action::failure; 54 // string newName = state->mol->getName(); 55 // state->mol->setName(state->lastName); 56 // 57 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 59 return Action::success; 58 60 } 59 61 60 62 Action::state_ptr AnalysisPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){ 61 return Action:: failure;63 return Action::success; 62 64 } 63 65 64 66 bool AnalysisPrincipalAxisSystemAction::canUndo() { 65 return false;67 return true; 66 68 } 67 69 68 70 bool AnalysisPrincipalAxisSystemAction::shouldUndo() { 69 return false;71 return true; 70 72 } 71 73 -
src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void AnalysisPrincipalAxisSystem(); 14 13 15 class AnalysisPrincipalAxisSystemAction : public Action { 16 friend void AnalysisPrincipalAxisSystem(); 17 14 18 public: 15 19 AnalysisPrincipalAxisSystemAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/AtomAction/AddAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/AtomAction/AddAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "element.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char AtomAddAction::NAME[] = "add-atom"; … … 35 36 {} 36 37 38 void AtomAdd(element *elemental, Vector &position) { 39 ValueStorage::getInstance().setCurrentValue(AtomAddAction::NAME, elemental); 40 ValueStorage::getInstance().setCurrentValue("position", elemental); 41 ActionRegistry::getInstance().getActionByName(AtomAddAction::NAME)->call(Action::NonInteractive); 42 }; 43 44 Dialog * AtomAddAction::fillDialog(Dialog *dialog) { 45 ASSERT(dialog,"No Dialog given when filling action dialog"); 46 47 dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME)); 48 dialog->queryVector("position", true, ValueStorage::getInstance().getDescription("position")); 49 50 return dialog; 51 } 52 37 53 Action::state_ptr AtomAddAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog(); 39 std::vector<element *> elements; 54 element * elemental = NULL; 40 55 Vector position; 41 56 42 dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));43 dialog->queryVector("position", &position, World::getInstance().getDomain(), true, MapOfActions::getInstance().getDescription("position"));44 cout << "pre-dialog" << endl;57 // obtain information 58 ValueStorage::getInstance().queryCurrentValue(NAME, elemental); 59 ValueStorage::getInstance().queryCurrentValue("position", position); 45 60 46 if(dialog->display()) { 47 cout << "post-dialog" << endl; 48 delete dialog; 49 if (elements.size() == 1) { 50 atom * first = World::getInstance().createAtom(); 51 first->type = *(elements.begin()); 52 first->x = position; 53 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl); 54 // TODO: remove when all of World's atoms are stored. 55 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 56 if (!molecules.empty()) { 57 std::vector<molecule *>::iterator iter = molecules.begin(); 58 (*iter)->AddAtom(first); 59 } 60 return Action::success; 61 } else { 62 DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl); 63 return Action::failure; 64 } 65 } else { 66 delete dialog; 67 return Action::failure; 61 // execute action 62 atom * first = World::getInstance().createAtom(); 63 first->type = elemental; 64 first->x = position; 65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl); 66 // TODO: remove when all of World's atoms are stored. 67 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 68 if (!molecules.empty()) { 69 std::vector<molecule *>::iterator iter = molecules.begin(); 70 (*iter)->AddAtom(first); 68 71 } 69 72 return Action::success; 70 73 } 71 74 -
src/Actions/AtomAction/AddAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 class element; 15 16 void AtomAdd(element *elemental, Vector &position); 12 17 13 18 class AtomAddAction : public Action { 19 friend void AtomAdd(element *elemental, Vector &position); 20 14 21 public: 15 22 AtomAddAction(); … … 20 27 21 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *); 22 31 private: 23 32 virtual Action::state_ptr performCall(); -
src/Actions/AtomAction/ChangeElementAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/AtomAction/ChangeElementAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 13 #include "element.hpp" 12 14 #include "log.hpp" 13 15 #include "vector.hpp" … … 22 24 #include "UIElements/UIFactory.hpp" 23 25 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"26 #include "UIElements/ValueStorage.hpp" 25 27 26 28 const char AtomChangeElementAction::NAME[] = "change-element"; … … 33 35 {} 34 36 37 void AtomChangeElement(element *elemental) { 38 ValueStorage::getInstance().setCurrentValue(AtomChangeElementAction::NAME, elemental); 39 ActionRegistry::getInstance().getActionByName(AtomChangeElementAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* AtomChangeElementAction::fillDialog(Dialog *dialog) { 43 ASSERT(dialog,"No Dialog given when filling action dialog"); 44 45 dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME)); 46 47 return dialog; 48 } 49 35 50 Action::state_ptr AtomChangeElementAction::performCall() { 36 Dialog *dialog = UIFactory::getInstance().makeDialog();37 51 atom *first = NULL; 38 std::vector<element *> elements;52 element *elemental = NULL; 39 53 40 dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME)); 41 dialog->queryElement("element", &elements, MapOfActions::getInstance().getDescription("element")); 54 ValueStorage::getInstance().queryCurrentValue(NAME, elemental); 42 55 43 if(dialog->display()) { 44 delete dialog; 45 ASSERT(elements.size() == 1, "Unequal to one element specified when changing an atom's element"); 46 ASSERT(first != NULL, "No valid atom specified"); 47 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elements.at(0) << "." << endl); 48 if (elements.at(0) != NULL) { 49 first->type = elements.at(0); 50 return Action::success; 51 } else 52 return Action::failure; 53 } else { 54 delete dialog; 55 return Action::failure; 56 for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) { 57 first = iter->second; 58 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elemental->symbol << "." << endl); 59 first->type = elemental; 56 60 } 57 61 return Action::success; 58 62 } 59 63 -
src/Actions/AtomAction/ChangeElementAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 class element; 14 15 void AtomChangeElement(element *elemental); 16 13 17 class AtomChangeElementAction : public Action { 18 friend void AtomChangeElement(element *elemental); 19 14 20 public: 15 21 AtomChangeElementAction(); … … 20 26 21 27 virtual const std::string getName(); 28 protected: 29 virtual Dialog * fillDialog(Dialog*); 22 30 private: 23 31 virtual Action::state_ptr performCall(); -
src/Actions/AtomAction/RemoveAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/AtomAction/RemoveAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "Descriptors/AtomDescriptor.hpp" … … 23 24 #include "UIElements/UIFactory.hpp" 24 25 #include "UIElements/Dialog.hpp" 25 #include " Actions/MapOfActions.hpp"26 #include "UIElements/ValueStorage.hpp" 26 27 27 28 const char AtomRemoveAction::NAME[] = "remove-atom"; … … 34 35 {} 35 36 37 void AtomRemove() { 38 ActionRegistry::getInstance().getActionByName(AtomRemoveAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* AtomRemoveAction::fillDialog(Dialog *dialog) { 42 ASSERT(dialog,"No Dialog given when filling action dialog"); 43 44 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 36 49 Action::state_ptr AtomRemoveAction::performCall() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 50 atom *first = NULL; 39 51 40 dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME)); 41 42 if(dialog->display()) { 43 delete dialog; 52 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 53 for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) { 54 first = iter->second; 44 55 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << first->getId() << "." << endl); 45 56 // TODO: this is not necessary when atoms and their storing to file are handled by the World 46 57 // simply try to erase in every molecule found 47 std::vector<molecule *> molecules = World::getInstance().getAllMolecules();48 58 for (std::vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end(); ++iter) { 49 59 (*iter)->erase(first); 50 60 } 51 61 World::getInstance().destroyAtom(first); 52 return Action::success;53 } else {54 delete dialog;55 return Action::failure;56 62 } 57 63 return Action::success; 58 64 } 59 65 -
src/Actions/AtomAction/RemoveAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void AtomRemove(); 14 13 15 class AtomRemoveAction : public Action { 16 friend void AtomRemove(); 17 14 18 public: 15 19 AtomRemoveAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog*); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/AtomsCalculation.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Calculation.hpp" 12 12 13 class Dialog; 14 13 15 template<typename T> 14 16 class AtomsCalculation : public Calculation<std::vector<T> > … … 20 22 protected: 21 23 virtual std::vector<T>* doCalc(); 24 virtual Dialog *fillDialog(Dialog *dialog); 22 25 23 26 private: -
src/Actions/AtomsCalculation_impl.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/AtomsCalculation.hpp" 12 12 #include "Actions/Calculation_impl.hpp" 13 14 #include <iostream>15 13 16 14 using namespace std; … … 35 33 Process::setMaxSteps(steps); 36 34 Process::start(); 37 for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){ 35 for(World::internal_AtomIterator 36 iter=world->getAtomIter_internal(descr); 37 iter!=world->atomEnd_internal(); 38 ++iter){ 39 38 40 Process::setCurrStep(iter.getCount()); 39 41 res->push_back(op(*iter)); … … 43 45 } 44 46 47 template<typename T> 48 Dialog *AtomsCalculation<T>::fillDialog(Dialog *dialog){ 49 ASSERT(dialog,"No Dialog given when filling action dialog"); 50 return dialog; 51 } 45 52 46 53 #endif /* ATOMSCALCULATION_IMPL_HPP_ */ -
src/Actions/CmdAction/BondLengthTableAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/CmdAction/BondLengthTableAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "bondgraph.hpp" 11 13 #include "config.hpp" 12 14 #include "log.hpp" … … 21 23 #include "UIElements/UIFactory.hpp" 22 24 #include "UIElements/Dialog.hpp" 23 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 24 26 25 27 const char CommandLineBondLengthTableAction::NAME[] = "bond-table"; … … 32 34 {} 33 35 36 void CommandBondLengthTable(std::string &BondGraphFileName) { 37 ValueStorage::getInstance().setCurrentValue(CommandLineBondLengthTableAction::NAME, BondGraphFileName); 38 ActionRegistry::getInstance().getActionByName(CommandLineBondLengthTableAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* CommandLineBondLengthTableAction::fillDialog(Dialog *dialog) { 42 ASSERT(dialog,"No Dialog given when filling action dialog"); 43 44 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 34 49 Action::state_ptr CommandLineBondLengthTableAction::performCall() { 35 50 ostringstream usage; 36 51 string BondGraphFileName; 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 52 53 ValueStorage::getInstance().queryCurrentValue(NAME, BondGraphFileName); 54 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl); 39 55 config *configuration = World::getInstance().getConfig(); 40 dialog->queryString(NAME, &BondGraphFileName, MapOfActions::getInstance().getDescription(NAME));41 42 if(dialog->display()) {43 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);44 delete dialog;45 } else {46 delete dialog;47 return Action::failure;48 }49 50 56 if (configuration->BG == NULL) { 51 57 configuration->BG = new BondGraph(configuration->GetIsAngstroem()); -
src/Actions/CmdAction/BondLengthTableAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandBondLengthTable(std::string &BondGraphFileName); 14 13 15 class CommandLineBondLengthTableAction : public Action { 16 friend void CommandBondLengthTable(std::string &BondGraphFileName); 17 14 18 public: 15 19 CommandLineBondLengthTableAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/CmdAction/ElementDbAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/CmdAction/ElementDbAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 const char CommandLineElementDbAction::NAME[] = "element-db"; … … 33 34 {} 34 35 36 void CommandElementDb(std::string &databasepath) { 37 ValueStorage::getInstance().setCurrentValue(CommandLineElementDbAction::NAME, databasepath); 38 ActionRegistry::getInstance().getActionByName(CommandLineElementDbAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* CommandLineElementDbAction::fillDialog(Dialog *dialog) { 42 ASSERT(dialog,"No Dialog given when filling action dialog"); 43 44 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 35 49 Action::state_ptr CommandLineElementDbAction::performCall() { 36 50 ostringstream usage; 37 51 string databasepath; 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 52 40 53 // get the path 41 54 // TODO: Make databasepath a std::string 42 55 config *configuration = World::getInstance().getConfig(); 43 dialog->queryString(NAME, &databasepath, MapOfActions::getInstance().getDescription(NAME)); 44 45 if(dialog->display()) { 46 strcpy(configuration->databasepath, databasepath.c_str()); 47 delete dialog; 48 } else { 49 delete dialog; 50 return Action::failure; 51 } 56 ValueStorage::getInstance().queryCurrentValue(NAME, databasepath); 57 strcpy(configuration->databasepath, databasepath.c_str()); 52 58 53 59 // load table -
src/Actions/CmdAction/ElementDbAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandElementDb(std::string &databasepath); 14 13 15 class CommandLineElementDbAction : public Action { 16 friend void CommandElementDb(std::string &databasepath); 17 14 18 public: 15 19 CommandLineElementDbAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/CmdAction/FastParsingAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/CmdAction/FastParsingAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include "Actions/MapOfActions.hpp" 24 #include "UIElements/ValueStorage.hpp" 25 26 // memento to remember the state when undoing 27 28 class CommandLineFastParsingState : public ActionState { 29 public: 30 CommandLineFastParsingState(bool _bool) : 31 boolean(_bool) 32 {} 33 bool boolean; 34 }; 35 24 36 25 37 const char CommandLineFastParsingAction::NAME[] = "fastparsing"; … … 32 44 {} 33 45 46 void CommandFastParsing(bool fastparsing) { 47 ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing); 48 ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive); 49 }; 50 51 Dialog* CommandLineFastParsingAction::fillDialog(Dialog *dialog) { 52 ASSERT(dialog,"No Dialog given when filling action dialog"); 53 54 dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME)); 55 56 return dialog; 57 } 58 34 59 Action::state_ptr CommandLineFastParsingAction::performCall() { 35 Dialog *dialog = UIFactory::getInstance().makeDialog();36 60 37 61 config *configuration = World::getInstance().getConfig(); 38 dialog->queryBoolean(NAME, &configuration->FastParsing, MapOfActions::getInstance().getDescription(NAME)); 39 40 if(dialog->display()) { 41 if (configuration->FastParsing) 42 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 43 else 44 DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl); 45 delete dialog; 46 return Action::success; 47 } else { 48 delete dialog; 49 return Action::failure; 50 } 62 ValueStorage::getInstance().queryCurrentValue(NAME, configuration->FastParsing); 63 if (configuration->FastParsing) 64 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 65 else 66 DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl); 67 return Action::success; 51 68 } 52 69 53 70 Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) { 54 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());71 CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get()); 55 72 56 return Action::failure; 57 // string newName = state->mol->getName(); 58 // state->mol->setName(state->lastName); 59 // 60 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 73 config *configuration = World::getInstance().getConfig(); 74 configuration->FastParsing = state->boolean; 75 76 return Action::state_ptr(new CommandLineFastParsingState(!state->boolean)); 61 77 } 62 78 63 79 Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){ 64 return Action::failure;80 return performUndo(_state); 65 81 } 66 82 67 83 bool CommandLineFastParsingAction::canUndo() { 68 return false;84 return true; 69 85 } 70 86 71 87 bool CommandLineFastParsingAction::shouldUndo() { 72 return false;88 return true; 73 89 } 74 90 -
src/Actions/CmdAction/FastParsingAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandFastParsing(bool fastparsing); 14 13 15 class CommandLineFastParsingAction : public Action { 16 friend void CommandFastParsing(bool fastparsing); 17 14 18 public: 15 19 CommandLineFastParsingAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/CmdAction/HelpAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/CmdAction/HelpAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "CommandLineParser.hpp" 12 13 … … 29 30 {} 30 31 31 Action::state_ptr CommandLineHelpAction::performCall() { 32 void CommandHelp() { 33 ActionRegistry::getInstance().getActionByName(CommandLineHelpAction::NAME)->call(Action::NonInteractive); 34 }; 35 36 Dialog* CommandLineHelpAction::fillDialog(Dialog *dialog) { 37 ASSERT(dialog,"No Dialog given when filling action dialog"); 38 32 39 ostringstream usage; 33 Dialog *dialog = UIFactory::getInstance().makeDialog();34 35 40 usage << CommandLineParser::getInstance().visible << endl; 36 41 dialog->queryEmpty(NAME, usage.str()); 37 42 38 if(dialog->display()) { 39 delete dialog; 40 return Action::success; 41 } else { 42 delete dialog; 43 return Action::failure; 44 } 43 return dialog; 44 } 45 46 Action::state_ptr CommandLineHelpAction::performCall() { 47 return Action::success; 45 48 } 46 49 47 50 Action::state_ptr CommandLineHelpAction::performUndo(Action::state_ptr _state) { 48 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 49 50 return Action::failure; 51 // string newName = state->mol->getName(); 52 // state->mol->setName(state->lastName); 53 // 54 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 51 return Action::success; 55 52 } 56 53 57 54 Action::state_ptr CommandLineHelpAction::performRedo(Action::state_ptr _state){ 58 return Action:: failure;55 return Action::success; 59 56 } 60 57 61 58 bool CommandLineHelpAction::canUndo() { 62 return false;59 return true; 63 60 } 64 61 65 62 bool CommandLineHelpAction::shouldUndo() { 66 return false;63 return true; 67 64 } 68 65 -
src/Actions/CmdAction/HelpAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandHelp(); 14 13 15 class CommandLineHelpAction : public Action { 16 friend void CommandHelp(); 17 14 18 public: 15 19 CommandLineHelpAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/CmdAction/VerboseAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/CmdAction/VerboseAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "verbose.hpp" … … 19 20 #include "UIElements/UIFactory.hpp" 20 21 #include "UIElements/Dialog.hpp" 21 #include "Actions/MapOfActions.hpp" 22 #include "UIElements/ValueStorage.hpp" 23 24 // memento to remember the state when undoing 25 26 class CommandLineVerboseState : public ActionState { 27 public: 28 CommandLineVerboseState(int _verbosity) : 29 verbosity(_verbosity) 30 {} 31 int verbosity; 32 }; 33 22 34 23 35 const char CommandLineVerboseAction::NAME[] = "verbose"; … … 30 42 {} 31 43 44 void CommandVerbose(int verbosity) { 45 ValueStorage::getInstance().setCurrentValue(CommandLineVerboseAction::NAME, verbosity); 46 ActionRegistry::getInstance().getActionByName(CommandLineVerboseAction::NAME)->call(Action::NonInteractive); 47 }; 48 49 Dialog* CommandLineVerboseAction::fillDialog(Dialog *dialog) { 50 ASSERT(dialog,"No Dialog given when filling action dialog"); 51 52 dialog->queryInt(NAME, ValueStorage::getInstance().getDescription(NAME)); 53 54 return dialog; 55 } 56 32 57 Action::state_ptr CommandLineVerboseAction::performCall() { 33 Dialog *dialog = UIFactory::getInstance().makeDialog();34 58 int verbosity = 2; 35 59 36 dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));60 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 37 61 38 if(dialog->display()) { 39 setVerbosity(verbosity); 40 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 41 delete dialog; 42 return Action::success; 43 } else { 44 delete dialog; 45 return Action::failure; 46 } 62 setVerbosity(verbosity); 63 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 64 return Action::success; 47 65 } 48 66 49 67 Action::state_ptr CommandLineVerboseAction::performUndo(Action::state_ptr _state) { 50 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());68 CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get()); 51 69 52 return Action::failure;53 // string newName = state->mol->getName();54 // state->mol->setName(state->lastName); 55 // 56 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));70 int verbosity = 2; 71 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 72 73 setVerbosity(state->verbosity); 74 return Action::state_ptr(new CommandLineVerboseState(verbosity)); 57 75 } 58 76 59 77 Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){ 60 return Action::failure;78 return performUndo(_state); 61 79 } 62 80 63 81 bool CommandLineVerboseAction::canUndo() { 64 return false;82 return true; 65 83 } 66 84 67 85 bool CommandLineVerboseAction::shouldUndo() { 68 return false;86 return true; 69 87 } 70 88 -
src/Actions/CmdAction/VerboseAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandVerbose(int verbosity); 14 13 15 class CommandLineVerboseAction : public Action { 16 friend void CommandVerbose(int verbosity); 17 14 18 public: 15 19 CommandLineVerboseAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/CmdAction/VersionAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/CmdAction/VersionAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 12 13 #include <iostream> … … 17 18 #include "UIElements/UIFactory.hpp" 18 19 #include "UIElements/Dialog.hpp" 19 #include " Actions/MapOfActions.hpp"20 #include "UIElements/ValueStorage.hpp" 20 21 21 22 const char CommandLineVersionAction::NAME[] = "version"; … … 28 29 {} 29 30 30 Action::state_ptr CommandLineVersionAction::performCall() { 31 Dialog *dialog = UIFactory::getInstance().makeDialog(); 31 void CommandVersion() { 32 ActionRegistry::getInstance().getActionByName(CommandLineVersionAction::NAME)->call(Action::NonInteractive); 33 }; 34 35 Dialog* CommandLineVersionAction::fillDialog(Dialog *dialog) { 36 ASSERT(dialog,"No Dialog given when filling action dialog"); 32 37 33 38 dialog->queryEmpty(NAME, ESPACKVersion); 34 39 35 if(dialog->display()) { 36 delete dialog; 37 return Action::success; 38 } else { 39 delete dialog; 40 return Action::failure; 41 } 40 return dialog; 41 } 42 43 Action::state_ptr CommandLineVersionAction::performCall() { 44 return Action::success; 42 45 } 43 46 44 47 Action::state_ptr CommandLineVersionAction::performUndo(Action::state_ptr _state) { 45 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 46 47 return Action::failure; 48 // string newName = state->mol->getName(); 49 // state->mol->setName(state->lastName); 50 // 51 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 48 return Action::success; 52 49 } 53 50 54 51 Action::state_ptr CommandLineVersionAction::performRedo(Action::state_ptr _state){ 55 return Action:: failure;52 return Action::success; 56 53 } 57 54 58 55 bool CommandLineVersionAction::canUndo() { 59 return false;56 return true; 60 57 } 61 58 62 59 bool CommandLineVersionAction::shouldUndo() { 63 return false;60 return true; 64 61 } 65 62 -
src/Actions/CmdAction/VersionAction.hpp
r06f4ef6 rb6da28 12 12 #include "version.h" 13 13 14 void CommandVersion(); 15 14 16 class CommandLineVersionAction : public Action { 17 friend void CommandVersion(); 18 15 19 public: 16 20 CommandLineVersionAction(); … … 21 25 22 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 23 29 private: 24 30 virtual Action::state_ptr performCall(); -
src/Actions/ErrorAction.cpp
r06f4ef6 rb6da28 27 27 } 28 28 29 Dialog* ErrorAction::createDialog() { 30 return NULL; 31 } 32 29 33 Action::state_ptr ErrorAction::performCall() { 30 34 Log() << Verbose(0) << errorMsg << endl; -
src/Actions/ErrorAction.hpp
r06f4ef6 rb6da28 22 22 23 23 private: 24 24 virtual Dialog * createDialog(); 25 25 virtual Action::state_ptr performCall(); 26 26 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 13 #include "bondgraph.hpp" 12 14 #include "config.hpp" 13 15 #include "log.hpp" … … 26 28 #include "UIElements/UIFactory.hpp" 27 29 #include "UIElements/Dialog.hpp" 28 #include " Actions/MapOfActions.hpp"30 #include "UIElements/ValueStorage.hpp" 29 31 30 32 const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search"; … … 37 39 {} 38 40 41 void FragmentationDepthFirstSearch(double distance) { 42 ValueStorage::getInstance().setCurrentValue(FragmentationDepthFirstSearchAction::NAME, distance); 43 ActionRegistry::getInstance().getActionByName(FragmentationDepthFirstSearchAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog* FragmentationDepthFirstSearchAction::fillDialog(Dialog *dialog) { 47 ASSERT(dialog,"No Dialog given when filling action dialog"); 48 49 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 50 51 return dialog; 52 } 53 39 54 Action::state_ptr FragmentationDepthFirstSearchAction::performCall() { 40 Dialog *dialog = UIFactory::getInstance().makeDialog();41 55 double distance; 42 56 43 dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));57 ValueStorage::getInstance().queryCurrentValue(NAME, distance); 44 58 45 if(dialog->display()) { 46 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 47 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 48 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 49 int *MinimumRingSize = new int[mol->getAtomCount()]; 50 atom ***ListOfLocalAtoms = NULL; 51 class StackClass<bond *> *BackEdgeStack = NULL; 52 class StackClass<bond *> *LocalBackEdgeStack = NULL; 53 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 54 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 55 if (Subgraphs != NULL) { 56 int FragmentCounter = 0; 57 while (Subgraphs->next != NULL) { 58 Subgraphs = Subgraphs->next; 59 Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 60 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount); 61 Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack); 62 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 63 delete(LocalBackEdgeStack); 64 delete(Subgraphs->previous); 65 FragmentCounter++; 66 } 67 delete(Subgraphs); 68 for (int i=0;i<FragmentCounter;i++) 69 delete[](ListOfLocalAtoms[i]); 70 delete[](ListOfLocalAtoms); 59 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 60 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 61 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 62 int *MinimumRingSize = new int[mol->getAtomCount()]; 63 atom **ListOfAtoms = NULL; 64 class StackClass<bond *> *BackEdgeStack = NULL; 65 class StackClass<bond *> *LocalBackEdgeStack = NULL; 66 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 67 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 68 if (Subgraphs != NULL) { 69 int FragmentCounter = 0; 70 while (Subgraphs->next != NULL) { 71 Subgraphs = Subgraphs->next; 72 ListOfAtoms = NULL; 73 Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 74 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount); 75 Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack); 76 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 77 delete(LocalBackEdgeStack); 78 delete(Subgraphs->previous); 79 delete[](ListOfAtoms); // and here we remove it 80 FragmentCounter++; 71 81 } 72 delete(BackEdgeStack); 73 delete[](MinimumRingSize); 74 delete dialog; 75 return Action::success; 76 } else { 77 delete dialog; 78 return Action::failure; 82 delete(Subgraphs); 79 83 } 84 delete(BackEdgeStack); 85 delete[](MinimumRingSize); 86 return Action::success; 80 87 } 81 88 82 89 Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) { 83 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 84 85 return Action::failure; 86 // string newName = state->mol->getName(); 87 // state->mol->setName(state->lastName); 88 // 89 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 90 return Action::success; 90 91 } 91 92 92 93 Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){ 93 return Action:: failure;94 return Action::success; 94 95 } 95 96 96 97 bool FragmentationDepthFirstSearchAction::canUndo() { 97 return false;98 return true; 98 99 } 99 100 100 101 bool FragmentationDepthFirstSearchAction::shouldUndo() { 101 return false;102 return true; 102 103 } 103 104 -
src/Actions/FragmentationAction/DepthFirstSearchAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationDepthFirstSearch(double distance); 14 13 15 class FragmentationDepthFirstSearchAction : public Action { 16 friend void FragmentationDepthFirstSearch(double distance); 17 14 18 public: 15 19 FragmentationDepthFirstSearchAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/FragmentationAction/FragmentationAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/FragmentationAction/FragmentationAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 13 #include "bondgraph.hpp" 12 14 #include "config.hpp" 13 15 #include "log.hpp" … … 24 26 #include "UIElements/UIFactory.hpp" 25 27 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"28 #include "UIElements/ValueStorage.hpp" 27 29 28 30 const char FragmentationFragmentationAction::NAME[] = "fragment-mol"; … … 35 37 {} 36 38 39 void FragmentationFragmentation(std::string &path, double distance, int order) { 40 ValueStorage::getInstance().setCurrentValue(FragmentationFragmentationAction::NAME, path); 41 ValueStorage::getInstance().setCurrentValue("distance", distance); 42 ValueStorage::getInstance().setCurrentValue("order", order); 43 ActionRegistry::getInstance().getActionByName(FragmentationFragmentationAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog* FragmentationFragmentationAction::fillDialog(Dialog *dialog) { 47 ASSERT(dialog,"No Dialog given when filling action dialog"); 48 49 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 50 dialog->queryDouble("distance", ValueStorage::getInstance().getDescription("distance")); 51 dialog->queryInt("order", ValueStorage::getInstance().getDescription("order")); 52 53 return dialog; 54 } 55 37 56 Action::state_ptr FragmentationFragmentationAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 57 clock_t start,end; 40 58 molecule *mol = NULL; 41 59 double distance = -1.; 42 60 int order = 0; 61 std::string path; 43 62 config *configuration = World::getInstance().getConfig(); 44 63 int ExitFlag = 0; 45 64 46 cout << "pre-dialog"<< endl; 47 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 48 dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance")); 49 dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order")); 65 ValueStorage::getInstance().queryCurrentValue(NAME, path); 66 ValueStorage::getInstance().queryCurrentValue("distance", distance); 67 ValueStorage::getInstance().queryCurrentValue("order", order); 50 68 51 if(dialog->display()) {52 cout << "POST-dialog"<< endl;69 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 70 mol = iter->second; 53 71 ASSERT(mol != NULL, "No molecule has been picked for fragmentation."); 54 72 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << distance << " angstroem, order of " << order << "." << endl); … … 58 76 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 59 77 if (mol->hasBondStructure()) { 60 ExitFlag = mol->FragmentMolecule(order, configuration);78 ExitFlag = mol->FragmentMolecule(order, path); 61 79 } 62 80 World::getInstance().setExitFlag(ExitFlag); 63 81 end = clock(); 64 82 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 65 delete dialog;66 return Action::success;67 } else {68 delete dialog;69 return Action::failure;70 83 } 84 return Action::success; 71 85 } 72 86 73 87 Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) { 74 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 75 76 return Action::failure; 77 // string newName = state->mol->getName(); 78 // state->mol->setName(state->lastName); 79 // 80 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 88 return Action::success; 81 89 } 82 90 83 91 Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){ 84 return Action:: failure;92 return Action::success; 85 93 } 86 94 87 95 bool FragmentationFragmentationAction::canUndo() { 88 return false;96 return true; 89 97 } 90 98 91 99 bool FragmentationFragmentationAction::shouldUndo() { 92 return false;100 return true; 93 101 } 94 102 -
src/Actions/FragmentationAction/FragmentationAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationFragmentation(std::string &path, double distance, int order); 14 13 15 class FragmentationFragmentationAction : public Action { 16 friend void FragmentationFragmentation(std::string &path, double distance, int order); 17 14 18 public: 15 19 FragmentationFragmentationAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "config.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect"; … … 35 36 {} 36 37 37 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog(); 38 void FragmentationSubgraphDissection() { 39 ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* FragmentationSubgraphDissectionAction::fillDialog(Dialog *dialog) { 43 ASSERT(dialog,"No Dialog given when filling action dialog"); 39 44 40 45 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 41 46 42 if(dialog->display()) { 43 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 44 // @TODO rather do the dissection afterwards 45 MoleculeListClass *molecules = World::getInstance().getMolecules(); 46 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 47 delete dialog; 48 return Action::success; 49 } else { 50 delete dialog; 51 return Action::failure; 52 } 47 return dialog; 48 } 49 50 51 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() { 52 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 53 // @TODO rather do the dissection afterwards 54 MoleculeListClass *molecules = World::getInstance().getMolecules(); 55 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 56 return Action::success; 53 57 } 54 58 -
src/Actions/FragmentationAction/SubgraphDissectionAction.hpp
r06f4ef6 rb6da28 7 7 8 8 #ifndef SUBGRAPHDISSECTIONACTION_HPP_ 9 #define SUBGRAPHDISSECTIONACTION_HPP_ f9 #define SUBGRAPHDISSECTIONACTION_HPP_ 10 10 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationSubgraphDissection(); 14 13 15 class FragmentationSubgraphDissectionAction : public Action { 16 friend void FragmentationSubgraphDissection(); 17 14 18 public: 15 19 FragmentationSubgraphDissectionAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/Makefile.am
r06f4ef6 rb6da28 17 17 ${MOLECULEACTIONSOURCE} \ 18 18 ${PARSERACTIONSOURCE} \ 19 ${SELECTIONACTIONSOURCE} \ 19 20 ${TESSELATIONACTIONSOURCE} \ 20 21 ${WORLDACTIONSOURCE} \ … … 28 29 ${MOLECULEACTIONHEADER} \ 29 30 ${PARSERACTIONHEADER} \ 31 ${SELECTIONACTIONHEADER} \ 30 32 ${TESSELATIONACTIONHEADER} \ 31 33 ${WORLDACTIONHEADER} \ … … 36 38 AnalysisAction/MolecularVolumeAction.cpp \ 37 39 AnalysisAction/PairCorrelationAction.cpp \ 38 AnalysisAction/PrincipalAxisSystemAction.cpp 40 AnalysisAction/PointCorrelationAction.cpp \ 41 AnalysisAction/PrincipalAxisSystemAction.cpp \ 42 AnalysisAction/SurfaceCorrelationAction.cpp 39 43 ANALYSISACTIONHEADER = \ 40 44 AnalysisAction/MolecularVolumeAction.hpp \ 41 45 AnalysisAction/PairCorrelationAction.hpp \ 42 AnalysisAction/PrincipalAxisSystemAction.hpp 46 AnalysisAction/PointCorrelationAction.hpp \ 47 AnalysisAction/PrincipalAxisSystemAction.hpp \ 48 AnalysisAction/SurfaceCorrelationAction.hpp 43 49 44 50 ATOMACTIONSOURCE = \ … … 107 113 ParserAction/SaveXyzAction.hpp 108 114 115 SELECTIONACTIONSOURCE = \ 116 SelectionAction/AllAtomsAction.cpp \ 117 SelectionAction/AllMoleculesAction.cpp \ 118 SelectionAction/AtomByIdAction.cpp \ 119 SelectionAction/MoleculeByIdAction.cpp \ 120 SelectionAction/NotAllAtomsAction.cpp \ 121 SelectionAction/NotAllMoleculesAction.cpp \ 122 SelectionAction/NotAtomByIdAction.cpp \ 123 SelectionAction/NotMoleculeByIdAction.cpp 124 SELECTIONACTIONHEADER = \ 125 SelectionAction/AllAtomsAction.hpp \ 126 SelectionAction/AllMoleculesAction.hpp \ 127 SelectionAction/AtomByIdAction.hpp \ 128 SelectionAction/MoleculeByIdAction.hpp \ 129 SelectionAction/NotAllAtomsAction.hpp \ 130 SelectionAction/NotAllMoleculesAction.hpp \ 131 SelectionAction/NotAtomByIdAction.hpp \ 132 SelectionAction/NotMoleculeByIdAction.hpp 133 109 134 TESSELATIONACTIONSOURCE = \ 110 135 TesselationAction/ConvexEnvelopeAction.cpp \ … … 120 145 WorldAction/CenterOnEdgeAction.cpp \ 121 146 WorldAction/ChangeBoxAction.cpp \ 147 WorldAction/InputAction.cpp \ 148 WorldAction/OutputAction.cpp \ 122 149 WorldAction/RemoveSphereOfAtomsAction.cpp \ 123 150 WorldAction/RepeatBoxAction.cpp \ 124 151 WorldAction/ScaleBoxAction.cpp \ 125 152 WorldAction/SetDefaultNameAction.cpp \ 126 WorldAction/SetGaussianBasisAction.cpp 153 WorldAction/SetGaussianBasisAction.cpp \ 154 WorldAction/SetOutputFormatsAction.cpp 127 155 WORLDACTIONHEADER = \ 128 156 WorldAction/AddEmptyBoundaryAction.hpp \ … … 131 159 WorldAction/CenterOnEdgeAction.hpp \ 132 160 WorldAction/ChangeBoxAction.hpp \ 161 WorldAction/InputAction.hpp \ 162 WorldAction/OutputAction.hpp \ 133 163 WorldAction/RemoveSphereOfAtomsAction.hpp \ 134 164 WorldAction/RepeatBoxAction.hpp \ 135 165 WorldAction/ScaleBoxAction.hpp \ 136 166 WorldAction/SetDefaultNameAction.hpp \ 137 WorldAction/SetGaussianBasisAction.hpp 167 WorldAction/SetGaussianBasisAction.hpp \ 168 WorldAction/SetOutputFormatsAction.hpp 138 169 170 unity.cpp: 171 echo "" > unity.cpp; \ 172 list='$(ACTIONSSOURCE)'; for file in $$list; do \ 173 echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \ 174 done; 175 176 MOSTLYCLEANFILES = unity.cpp -
src/Actions/MakroAction.cpp
r06f4ef6 rb6da28 44 44 } 45 45 46 Dialog* MakroAction::fillDialog(Dialog *dialog) { 47 return actions->fillAllDialogs(dialog); 48 } 46 49 47 50 Action::state_ptr MakroAction::performCall(){ -
src/Actions/MakroAction.hpp
r06f4ef6 rb6da28 29 29 bool shouldUndo(); 30 30 31 protected: 32 virtual Dialog *fillDialog(Dialog *dialog); 31 33 private: 32 34 virtual Action::state_ptr performCall(); -
src/Actions/ManipulateAtomsProcess.cpp
r06f4ef6 rb6da28 27 27 {} 28 28 29 Dialog* ManipulateAtomsProcess::fillDialog(Dialog *dialog){ 30 ASSERT(dialog,"No Dialog given when filling action dialog"); 31 return dialog; 32 } 33 29 34 Action::state_ptr ManipulateAtomsProcess::performCall(){ 30 35 World::getInstance().doManipulate(this); … … 53 58 setMaxSteps(world->numAtoms()); 54 59 start(); 55 for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){ 60 for(World::internal_AtomIterator 61 iter=world->getAtomIter_internal(descr); 62 iter!=world->atomEnd_internal(); 63 ++iter){ 64 56 65 setCurrStep(iter.getCount()); 57 66 operation(*iter); -
src/Actions/ManipulateAtomsProcess.hpp
r06f4ef6 rb6da28 27 27 28 28 virtual void doManipulate(World *); 29 30 protected: 31 virtual Dialog * fillDialog(Dialog*); 29 32 private: 30 31 33 virtual Action::state_ptr performCall(); 32 34 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MapOfActions.cpp
r06f4ef6 rb6da28 10 10 using namespace std; 11 11 12 #include "Actions/MapOfActions.hpp" 13 #include "Descriptors/AtomIdDescriptor.hpp" 14 #include "Descriptors/MoleculeIdDescriptor.hpp" 15 #include "Helpers/Assert.hpp" 12 16 #include "Patterns/Singleton_impl.hpp" 13 #include "Actions/MapOfActions.hpp"14 #include "Helpers/Assert.hpp"15 17 16 18 #include <boost/lexical_cast.hpp> … … 18 20 #include <boost/program_options.hpp> 19 21 22 #include <iostream> 23 24 #include "atom.hpp" 25 #include "Box.hpp" 20 26 #include "CommandLineParser.hpp" 27 #include "element.hpp" 21 28 #include "log.hpp" 29 #include "Matrix.hpp" 30 #include "molecule.hpp" 31 #include "periodentafel.hpp" 32 #include "vector.hpp" 22 33 #include "verbose.hpp" 23 34 35 #include "Actions/ActionRegistry.hpp" 36 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" 37 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 38 #include "Actions/AnalysisAction/PointCorrelationAction.hpp" 39 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 40 #include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp" 41 #include "Actions/AtomAction/AddAction.hpp" 42 #include "Actions/AtomAction/ChangeElementAction.hpp" 43 #include "Actions/AtomAction/RemoveAction.hpp" 44 #include "Actions/CmdAction/BondLengthTableAction.hpp" 45 #include "Actions/CmdAction/ElementDbAction.hpp" 46 #include "Actions/CmdAction/FastParsingAction.hpp" 47 #include "Actions/CmdAction/HelpAction.hpp" 48 #include "Actions/CmdAction/VerboseAction.hpp" 49 #include "Actions/CmdAction/VersionAction.hpp" 50 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 51 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 52 #include "Actions/FragmentationAction/FragmentationAction.hpp" 53 #include "Actions/MoleculeAction/BondFileAction.hpp" 54 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 55 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp" 56 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp" 57 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp" 58 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp" 59 #include "Actions/MoleculeAction/SaveBondsAction.hpp" 60 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp" 61 #include "Actions/MoleculeAction/SuspendInWaterAction.hpp" 62 #include "Actions/MoleculeAction/TranslateAction.hpp" 63 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp" 64 #include "Actions/ParserAction/LoadXyzAction.hpp" 65 #include "Actions/ParserAction/SaveXyzAction.hpp" 66 #include "Actions/SelectionAction/AllAtomsAction.hpp" 67 #include "Actions/SelectionAction/AllMoleculesAction.hpp" 68 #include "Actions/SelectionAction/AtomByIdAction.hpp" 69 #include "Actions/SelectionAction/MoleculeByIdAction.hpp" 70 #include "Actions/SelectionAction/NotAllAtomsAction.hpp" 71 #include "Actions/SelectionAction/NotAllMoleculesAction.hpp" 72 #include "Actions/SelectionAction/NotAtomByIdAction.hpp" 73 #include "Actions/SelectionAction/NotMoleculeByIdAction.hpp" 74 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp" 75 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp" 76 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp" 77 #include "Actions/WorldAction/BoundInBoxAction.hpp" 78 #include "Actions/WorldAction/CenterInBoxAction.hpp" 79 #include "Actions/WorldAction/CenterOnEdgeAction.hpp" 80 #include "Actions/WorldAction/ChangeBoxAction.hpp" 81 #include "Actions/WorldAction/InputAction.hpp" 82 #include "Actions/WorldAction/OutputAction.hpp" 83 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 84 #include "Actions/WorldAction/RepeatBoxAction.hpp" 85 #include "Actions/WorldAction/ScaleBoxAction.hpp" 86 #include "Actions/WorldAction/SetDefaultNameAction.hpp" 87 #include "Actions/WorldAction/SetGaussianBasisAction.hpp" 88 #include "Actions/WorldAction/SetOutputFormatsAction.hpp" 24 89 #include "Actions/Values.hpp" 25 90 … … 27 92 { 28 93 VectorValue VV; 29 if (values.size() != 3) { 30 cerr << "Specified vector does not have three components but " << values.size() << endl; 94 std::vector<std::string> components; 95 96 // split comma-separated values 97 if (values.size() != 1) { 98 cerr << "Not one vector but " << components.size() << " given " << endl; 99 throw boost::program_options::validation_error("Unequal to one vector given"); 100 } 101 std::string argument(values.at(0)); 102 std::string::iterator Aiter = argument.begin(); 103 std::string::iterator Biter = argument.begin(); 104 for (; Aiter != argument.end(); ++Aiter) { 105 if (*Aiter == ',') { 106 components.push_back(string(Biter,Aiter)); 107 do { 108 Aiter++; 109 } while (*Aiter == ' ' || *Aiter == '\t'); 110 Biter = Aiter; 111 } 112 } 113 components.push_back(string(Biter,argument.end())); 114 115 if (components.size() != 3) { 116 cerr << "Specified vector does not have three components but " << components.size() << endl; 31 117 throw boost::program_options::validation_error("Specified vector does not have three components"); 32 118 } 33 VV.x = boost::lexical_cast<double>( values.at(0));34 VV.y = boost::lexical_cast<double>( values.at(1));35 VV.z = boost::lexical_cast<double>( values.at(2));119 VV.x = boost::lexical_cast<double>(components.at(0)); 120 VV.y = boost::lexical_cast<double>(components.at(1)); 121 VV.z = boost::lexical_cast<double>(components.at(2)); 36 122 v = boost::any(VectorValue(VV)); 37 123 } … … 40 126 { 41 127 BoxValue BV; 42 if (values.size() != 6) { 43 cerr << "Specified vector does not have three components but " << values.size() << endl; 128 std::vector<std::string> components; 129 130 // split comma-separated values 131 if (values.size() != 1) { 132 cerr << "Not one vector but " << components.size() << " given " << endl; 133 throw boost::program_options::validation_error("Unequal to one vector given"); 134 } 135 std::string argument(values.at(0)); 136 std::string::iterator Aiter = argument.begin(); 137 std::string::iterator Biter = argument.begin(); 138 for (; Aiter != argument.end(); ++Aiter) { 139 if (*Aiter == ',') { 140 components.push_back(string(Biter,Aiter)); 141 do { 142 Aiter++; 143 } while (*Aiter == ' ' || *Aiter == '\t'); 144 Biter = Aiter; 145 } 146 } 147 components.push_back(string(Biter,argument.end())); 148 149 if (components.size() != 6) { 150 cerr << "Specified vector does not have three components but " << components.size() << endl; 44 151 throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components"); 45 152 } 46 BV.xx = boost::lexical_cast<double>( values.at(0));47 BV. xy = boost::lexical_cast<double>(values.at(1));48 BV. xz = boost::lexical_cast<double>(values.at(2));49 BV. yy = boost::lexical_cast<double>(values.at(3));50 BV. yz = boost::lexical_cast<double>(values.at(4));51 BV.zz = boost::lexical_cast<double>( values.at(5));153 BV.xx = boost::lexical_cast<double>(components.at(0)); 154 BV.yx = boost::lexical_cast<double>(components.at(1)); 155 BV.yy = boost::lexical_cast<double>(components.at(2)); 156 BV.zx = boost::lexical_cast<double>(components.at(3)); 157 BV.zy = boost::lexical_cast<double>(components.at(4)); 158 BV.zz = boost::lexical_cast<double>(components.at(5)); 52 159 v = boost::any(BoxValue(BV)); 53 160 } … … 83 190 DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order"; 84 191 DescriptionMap["help"] = "Give this help screen"; 192 DescriptionMap["input"] = "specify input files"; 85 193 DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule"; 194 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule"; 86 195 DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule"; 87 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule"; 88 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface"; 196 DescriptionMap["output"] = "write output files"; 197 DescriptionMap["set-output"] = "specify output formats"; 198 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements"; 89 199 DescriptionMap["parse-xyz"] = "parse xyz file into World"; 200 DescriptionMap["point-correlation"] = "pair correlation analysis between element and point"; 90 201 DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule"; 91 202 DescriptionMap["remove-atom"] = "remove a specified atom"; … … 93 204 DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis"; 94 205 DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis"; 95 DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";96 206 DescriptionMap["save-adjacency"] = "name of the adjacency file to write to"; 97 207 DescriptionMap["save-bonds"] = "name of the bonds file to write to"; 98 208 DescriptionMap["save-temperature"] = "name of the temperature file to write to"; 209 DescriptionMap["SaveXyz"] = "save world as xyz file"; 99 210 DescriptionMap["scale-box"] = "scale box and atomic positions inside"; 211 DescriptionMap["select-all-atoms"] = "select all atoms"; 212 DescriptionMap["select-all-molecules"] = "select all molecules"; 213 DescriptionMap["select-atom-by-id"] = "select an atom by index"; 214 DescriptionMap["select-molecule-by-id"] = "select a molecule by index"; 215 DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC"; 216 DescriptionMap["set-output"] = "specify output formats"; 100 217 DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs"; 218 DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface"; 101 219 DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified"; 102 220 DescriptionMap["translate-mol"] = "translate molecule by given vector"; 221 DescriptionMap["unselect-all-atoms"] = "unselect all atoms"; 222 DescriptionMap["unselect-all-molecules"] = "unselect all molecules"; 223 DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index"; 224 DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index"; 103 225 DescriptionMap["verbose"] = "set verbosity level"; 104 226 DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file"; 105 227 DescriptionMap["version"] = "show version"; 106 228 // keys for values 107 DescriptionMap["atom-by-id"] = "index of an atom";108 229 DescriptionMap["bin-output-file"] = "name of the bin output file"; 109 230 DescriptionMap["bin-end"] = "start of the last bin"; … … 123 244 DescriptionMap["MaxDistance"] = "maximum distance in space"; 124 245 DescriptionMap["molecule-by-id"] = "index of a molecule"; 125 DescriptionMap["molecule-by-name"] = "name of a molecule";126 246 DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope"; 127 247 DescriptionMap["order"] = "order of a discretization, dissection, ..."; … … 129 249 DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)"; 130 250 DescriptionMap["position"] = "position in R^3 space"; 131 DescriptionMap["sphere-radius"] = "radius of tesselation sphere";132 251 DescriptionMap["start-step"] = "first or start step"; 133 252 … … 141 260 ShortFormMap["center-in-box"] = "b"; 142 261 ShortFormMap["change-element"] = "E"; 143 ShortFormMap["convex-envelope"] = "o";262 // ShortFormMap["convex-envelope"] = "x"; 144 263 ShortFormMap["default-molname"] = "X"; 145 264 ShortFormMap["depth-first-search"] = "D"; … … 152 271 ShortFormMap["linear-interpolate"] = "L"; 153 272 ShortFormMap["nonconvex-envelope"] = "N"; 154 ShortFormMap["pair-correlation"] = "C"; 273 // ShortFormMap["output"] = "o"; 274 // ShortFormMap["pair-correlation"] = "C"; 155 275 ShortFormMap["parse-xyz"] = "p"; 156 276 ShortFormMap["remove-atom"] = "r"; … … 163 283 ShortFormMap["scale-box"] = "s"; 164 284 ShortFormMap["set-basis"] = "M"; 285 ShortFormMap["set-output"] = "o"; 165 286 ShortFormMap["subgraph-dissect"] = "I"; 166 287 ShortFormMap["suspend-in-water"] = "u"; … … 171 292 172 293 // value types for the actions 173 TypeMap["add-atom"] = Element; 174 TypeMap["bond-file"] = String; 175 TypeMap["bond-table"] = String; 176 TypeMap["boundary"] = Vector; 177 TypeMap["center-in-box"] = Box; 178 TypeMap["change-box"] = Box; 179 TypeMap["change-element"] = Atom; 180 TypeMap["change-molname"] = String; 181 TypeMap["convex-envelope"] = Molecule; 182 TypeMap["default-molname"] = String; 183 TypeMap["depth-first-search"] = Double; 184 TypeMap["element-db"] = String; 185 TypeMap["fastparsing"] = Boolean; 186 TypeMap["fill-molecule"] = String; 187 TypeMap["fragment-mol"] = Molecule; 188 TypeMap["input"] = String; 189 TypeMap["linear-interpolate"] = String; 190 TypeMap["molecular-volume"] = Molecule; 191 TypeMap["nonconvex-envelope"] = Molecule; 192 TypeMap["parse-xyz"] = String; 193 TypeMap["pair-correlation"] = String; 194 TypeMap["principal-axis-system"] = Molecule; 195 TypeMap["remove-atom"] = Atom; 196 TypeMap["remove-sphere"] = Double; 197 TypeMap["repeat-box"] = Vector; 198 TypeMap["rotate-to-pas"] = Molecule; 199 TypeMap["save-adjacency"] = String; 200 TypeMap["save-bonds"] = String; 201 TypeMap["save-temperature"] = String; 202 TypeMap["scale-box"] = Vector; 203 TypeMap["set-basis"] = String; 204 TypeMap["subgraph-dissect"] = None; 205 TypeMap["suspend-in-water"] = Double; 206 TypeMap["translate-mol"] = Vector; 207 TypeMap["verlet-integrate"] = String; 208 TypeMap["verbose"] = Integer; 294 TypeMap["add-atom"] = &typeid(element); 295 TypeMap["bond-file"] = &typeid(std::string); 296 TypeMap["bond-table"] = &typeid(std::string); 297 TypeMap["boundary"] = &typeid(VectorValue); 298 TypeMap["center-in-box"] = &typeid(BoxValue); 299 TypeMap["change-box"] = &typeid(BoxValue); 300 TypeMap["change-element"] = &typeid(element); 301 TypeMap["change-molname"] = &typeid(std::string); 302 TypeMap["convex-envelope"] = &typeid(void); 303 TypeMap["default-molname"] = &typeid(std::string); 304 TypeMap["depth-first-search"] = &typeid(double); 305 TypeMap["element-db"] = &typeid(std::string); 306 TypeMap["fastparsing"] = &typeid(bool); 307 TypeMap["fill-molecule"] = &typeid(std::string); 308 TypeMap["fragment-mol"] = &typeid(std::string); 309 TypeMap["input"] = &typeid(std::string); 310 TypeMap["linear-interpolate"] = &typeid(std::string); 311 TypeMap["molecular-volume"] = &typeid(molecule); 312 TypeMap["nonconvex-envelope"] = &typeid(double); 313 TypeMap["output"] = &typeid(void); 314 TypeMap["parse-xyz"] = &typeid(std::string); 315 TypeMap["pair-correlation"] = &typeid(void); 316 TypeMap["point-correlation"] = &typeid(void); 317 TypeMap["principal-axis-system"] = &typeid(void); 318 TypeMap["remove-atom"] = &typeid(void); 319 TypeMap["remove-sphere"] = &typeid(double); 320 TypeMap["repeat-box"] = &typeid(VectorValue); 321 TypeMap["rotate-to-pas"] = &typeid(molecule); 322 TypeMap["save-adjacency"] = &typeid(std::string); 323 TypeMap["save-bonds"] = &typeid(std::string); 324 TypeMap["save-temperature"] = &typeid(std::string); 325 TypeMap["scale-box"] = &typeid(VectorValue); 326 TypeMap["set-basis"] = &typeid(std::string); 327 TypeMap["set-output"] = &typeid(std::vector<std::string>); 328 TypeMap["subgraph-dissect"] = &typeid(void); 329 TypeMap["surface-correlation"] = &typeid(void); 330 TypeMap["suspend-in-water"] = &typeid(double); 331 TypeMap["translate-mol"] = &typeid(VectorValue); 332 TypeMap["verlet-integrate"] = &typeid(std::string); 333 TypeMap["verbose"] = &typeid(int); 209 334 210 335 // value types for the values 211 TypeMap["atom-by-id"] = Atom; 212 TypeMap["bin-output-file"] = String; 213 TypeMap["bin-end"] = Double; 214 TypeMap["bin-start"] = Double; 215 TypeMap["bin-width"] = Double; 216 TypeMap["convex-file"] = String; 217 TypeMap["distance"] = Double; 218 TypeMap["distances"] = Vector; 219 TypeMap["DoRotate"] = Boolean; 220 TypeMap["element"] = Element; 221 TypeMap["elements"] = ListOfElements; 222 TypeMap["end-step"] = Integer; 223 TypeMap["id-mapping"] = Boolean; 224 TypeMap["length"] = Double; 225 TypeMap["lengths"] = Vector; 226 TypeMap["MaxDistance"] = Double; 227 TypeMap["molecule-by-id"] = Molecule; 228 TypeMap["molecule-by-name"] = Molecule; 229 TypeMap["nonconvex-file"] = String; 230 TypeMap["order"] = Integer; 231 TypeMap["output-file"] = String; 232 TypeMap["periodic"] = Boolean; 233 TypeMap["position"] = Vector; 234 TypeMap["sphere-radius"] = Double; 235 TypeMap["start-step"] = Integer; 336 TypeMap["bin-output-file"] = &typeid(std::string); 337 TypeMap["bin-end"] = &typeid(double); 338 TypeMap["bin-start"] = &typeid(double); 339 TypeMap["bin-width"] = &typeid(double); 340 TypeMap["convex-file"] = &typeid(std::string); 341 TypeMap["distance"] = &typeid(double); 342 TypeMap["distances"] = &typeid(VectorValue); 343 TypeMap["DoRotate"] = &typeid(bool); 344 TypeMap["element"] = &typeid(element); 345 TypeMap["elements"] = &typeid(std::vector<element *>); 346 TypeMap["end-step"] = &typeid(int); 347 TypeMap["id-mapping"] = &typeid(bool); 348 TypeMap["length"] = &typeid(double); 349 TypeMap["lengths"] = &typeid(VectorValue); 350 TypeMap["MaxDistance"] = &typeid(double); 351 TypeMap["molecule-by-id"] = &typeid(molecule); 352 TypeMap["nonconvex-file"] = &typeid(std::string); 353 TypeMap["order"] = &typeid(int); 354 TypeMap["output-file"] = &typeid(std::string); 355 TypeMap["periodic"] = &typeid(bool); 356 TypeMap["position"] = &typeid(VectorValue); 357 TypeMap["select-all-atoms"] = &typeid(void); 358 TypeMap["select-all-molecules"] = &typeid(void); 359 TypeMap["select-atom-by-id"] = &typeid(atom); 360 TypeMap["select-molecule-by-id"] = &typeid(molecule); 361 TypeMap["start-step"] = &typeid(int); 362 TypeMap["unselect-all-atoms"] = &typeid(void); 363 TypeMap["unselect-all-molecules"] = &typeid(void); 364 TypeMap["unselect-atom-by-id"] = &typeid(atom); 365 TypeMap["unselect-molecule-by-id"] = &typeid(molecule); 366 367 TypeEnumMap[&typeid(void)] = None; 368 TypeEnumMap[&typeid(bool)] = Boolean; 369 TypeEnumMap[&typeid(int)] = Integer; 370 TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers; 371 TypeEnumMap[&typeid(double)] = Double; 372 TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles; 373 TypeEnumMap[&typeid(std::string)] = String; 374 TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings; 375 TypeEnumMap[&typeid(VectorValue)] = Vector; 376 TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors; 377 TypeEnumMap[&typeid(BoxValue)] = Box; 378 TypeEnumMap[&typeid(molecule)] = Molecule; 379 TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules; 380 TypeEnumMap[&typeid(atom)] = Atom; 381 TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms; 382 TypeEnumMap[&typeid(element)] = Element; 383 TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements; 236 384 237 385 // default values for any action that needs one (always string!) 238 DefaultValue["bin-width"] = "0.5"; 239 DefaultValue["fastparsing"] = "0"; 240 DefaultValue["atom-by-id"] = "-1"; 241 DefaultValue["molecule-by-id"] = "-1"; 242 DefaultValue["periodic"] = "0"; 243 244 245 // list of generic actions 386 CurrentValue["bin-width"] = "0.5"; 387 CurrentValue["fastparsing"] = "0"; 388 CurrentValue["periodic"] = "0"; 389 390 // put action into each menu category 391 MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis"); 392 MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms"); 393 MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options"); 394 MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation"); 395 MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules"); 396 MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output"); 397 MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection"); 398 MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation"); 399 MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals"); 400 401 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") ); 402 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") ); 403 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") ); 404 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") ); 405 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") ); 406 407 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") ); 408 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") ); 409 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") ); 410 411 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") ); 412 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") ); 413 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") ); 414 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") ); 415 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") ); 416 417 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") ); 418 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") ); 419 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") ); 420 421 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") ); 422 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") ); 423 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") ); 424 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") ); 425 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") ); 426 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") ); 427 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") ); 428 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") ); 429 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") ); 430 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "translate-mol") ); 431 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") ); 432 433 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") ); 434 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") ); 435 436 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") ); 437 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") ); 438 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") ); 439 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") ); 440 441 MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") ); 442 MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") ); 443 444 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") ); 445 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") ); 446 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") ); 447 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") ); 448 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") ); 449 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") ); 450 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") ); 451 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") ); 452 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") ); 453 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") ); 454 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") ); 455 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") ); 456 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") ); 457 458 // put actions into command line category 246 459 generic.insert("add-atom"); 247 460 generic.insert("bond-file"); … … 262 475 generic.insert("fragment-mol"); 263 476 generic.insert("help"); 264 generic.insert("linear-interpolate"); 477 generic.insert("input"); 478 generic.insert("linear-interpolate"); 265 479 // generic.insert("molecular-volume"); 266 480 generic.insert("nonconvex-envelope"); 481 generic.insert("output"); 267 482 generic.insert("pair-correlation"); 268 // generic.insert("parse-xyz"); 483 generic.insert("parse-xyz"); 484 generic.insert("point-correlation"); 269 485 // generic.insert("principal-axis-system"); 270 486 generic.insert("remove-atom"); … … 276 492 generic.insert("save-temperature"); 277 493 generic.insert("scale-box"); 494 generic.insert("select-all-atoms"); 495 generic.insert("select-all-molecules"); 496 generic.insert("select-atom-by-id"); 497 generic.insert("select-molecule-by-id"); 278 498 generic.insert("set-basis"); 499 generic.insert("set-output"); 279 500 generic.insert("subgraph-dissect"); 501 generic.insert("surface-correlation"); 280 502 generic.insert("suspend-in-water"); 281 503 generic.insert("translate-mol"); 504 generic.insert("unselect-all-atoms"); 505 generic.insert("unselect-all-molecules"); 506 generic.insert("unselect-atom-by-id"); 507 generic.insert("unselect-molecule-by-id"); 282 508 generic.insert("verbose"); 283 509 generic.insert("verlet-integrate"); … … 286 512 // positional arguments 287 513 generic.insert("input"); 288 inputfile.insert("input");289 514 290 515 // hidden arguments 291 generic.insert("atom-by-id"); 292 generic.insert("bin-end"); 293 generic.insert("bin-output-file"); 294 generic.insert("bin-start"); 295 generic.insert("bin-width"); 296 generic.insert("convex-file"); 297 generic.insert("distance"); 298 generic.insert("DoRotate"); 299 generic.insert("distances"); 300 generic.insert("element"); 301 generic.insert("elements"); 302 generic.insert("end-step"); 303 generic.insert("id-mapping"); 304 generic.insert("lengths"); 305 generic.insert("MaxDistance"); 306 generic.insert("molecule-by-id"); 307 generic.insert("molecule-by-name"); 308 generic.insert("nonconvex-file"); 309 generic.insert("order"); 310 generic.insert("output-file"); 311 generic.insert("periodic"); 312 generic.insert("position"); 313 generic.insert("sphere-radius"); 314 generic.insert("start-step"); 516 hidden.insert("bin-end"); 517 hidden.insert("bin-output-file"); 518 hidden.insert("bin-start"); 519 hidden.insert("bin-width"); 520 hidden.insert("convex-file"); 521 hidden.insert("distance"); 522 hidden.insert("DoRotate"); 523 hidden.insert("distances"); 524 hidden.insert("element"); 525 hidden.insert("elements"); 526 hidden.insert("end-step"); 527 hidden.insert("id-mapping"); 528 hidden.insert("lengths"); 529 hidden.insert("MaxDistance"); 530 hidden.insert("molecule-by-id"); 531 hidden.insert("nonconvex-file"); 532 hidden.insert("order"); 533 hidden.insert("output-file"); 534 hidden.insert("periodic"); 535 hidden.insert("position"); 536 hidden.insert("start-step"); 315 537 } 316 538 … … 323 545 } 324 546 547 void MapOfActions::queryCurrentValue(const char * name, class atom * &_T) 548 { 549 int atomID = -1; 550 if (typeid( atom ) == *TypeMap[name]) { 551 if (CurrentValue.find(name) == CurrentValue.end()) 552 throw MissingValueException(__FILE__, __LINE__); 553 atomID = lexical_cast<int>(CurrentValue[name].c_str()); 554 CurrentValue.erase(name); 555 } else 556 throw IllegalTypeException(__FILE__,__LINE__); 557 _T = World::getInstance().getAtom(AtomById(atomID)); 558 } 559 560 void MapOfActions::queryCurrentValue(const char * name, class element * &_T) { 561 int Z = -1; 562 if (typeid( element ) == *TypeMap[name]) { 563 if (CurrentValue.find(name) == CurrentValue.end()) 564 throw MissingValueException(__FILE__, __LINE__); 565 Z = lexical_cast<int>(CurrentValue[name].c_str()); 566 CurrentValue.erase(name); 567 } else 568 throw IllegalTypeException(__FILE__,__LINE__); 569 _T = World::getInstance().getPeriode()->FindElement(Z); 570 } 571 572 void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) { 573 int molID = -1; 574 if (typeid( molecule ) == *TypeMap[name]) { 575 if (CurrentValue.find(name) == CurrentValue.end()) 576 throw MissingValueException(__FILE__, __LINE__); 577 molID = lexical_cast<int>(CurrentValue[name].c_str()); 578 CurrentValue.erase(name); 579 } else 580 throw IllegalTypeException(__FILE__,__LINE__); 581 _T = World::getInstance().getMolecule(MoleculeById(molID)); 582 } 583 584 void MapOfActions::queryCurrentValue(const char * name, class Box &_T) { 585 Matrix M; 586 double tmp; 587 if (typeid( BoxValue ) == *TypeMap[name]) { 588 if (CurrentValue.find(name) == CurrentValue.end()) 589 throw MissingValueException(__FILE__, __LINE__); 590 std::istringstream stream(CurrentValue[name]); 591 stream >> tmp; 592 M.set(0,0,tmp); 593 stream >> tmp; 594 M.set(0,1,tmp); 595 M.set(1,0,tmp); 596 stream >> tmp; 597 M.set(0,2,tmp); 598 M.set(2,0,tmp); 599 stream >> tmp; 600 M.set(1,1,tmp); 601 stream >> tmp; 602 M.set(1,2,tmp); 603 M.set(2,1,tmp); 604 stream >> tmp; 605 M.set(2,2,tmp); 606 _T = M; 607 CurrentValue.erase(name); 608 } else 609 throw IllegalTypeException(__FILE__,__LINE__); 610 } 611 612 void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) { 613 if (typeid( VectorValue ) == *TypeMap[name]) { 614 std::istringstream stream(CurrentValue[name]); 615 CurrentValue.erase(name); 616 stream >> _T[0]; 617 stream >> _T[1]; 618 stream >> _T[2]; 619 } else 620 throw IllegalTypeException(__FILE__,__LINE__); 621 } 622 623 void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T) 624 { 625 int atomID = -1; 626 atom *Walker = NULL; 627 if (typeid( std::vector<atom *> ) == *TypeMap[name]) { 628 if (CurrentValue.find(name) == CurrentValue.end()) 629 throw MissingValueException(__FILE__, __LINE__); 630 std::istringstream stream(CurrentValue[name]); 631 CurrentValue.erase(name); 632 while (!stream.fail()) { 633 stream >> atomID >> ws; 634 Walker = World::getInstance().getAtom(AtomById(atomID)); 635 if (Walker != NULL) 636 _T.push_back(Walker); 637 atomID = -1; 638 Walker = NULL; 639 } 640 } else 641 throw IllegalTypeException(__FILE__,__LINE__); 642 } 643 644 void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T) 645 { 646 int Z = -1; 647 element *elemental = NULL; 648 if (typeid( std::vector<element *> ) == *TypeMap[name]) { 649 if (CurrentValue.find(name) == CurrentValue.end()) 650 throw MissingValueException(__FILE__, __LINE__); 651 std::istringstream stream(CurrentValue[name]); 652 CurrentValue.erase(name); 653 while (!stream.fail()) { 654 stream >> Z >> ws; 655 elemental = World::getInstance().getPeriode()->FindElement(Z); 656 if (elemental != NULL) 657 _T.push_back(elemental); 658 Z = -1; 659 } 660 } else 661 throw IllegalTypeException(__FILE__,__LINE__); 662 } 663 664 void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T) 665 { 666 int molID = -1; 667 molecule *mol = NULL; 668 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) { 669 if (CurrentValue.find(name) == CurrentValue.end()) 670 throw MissingValueException(__FILE__, __LINE__); 671 std::istringstream stream(CurrentValue[name]); 672 CurrentValue.erase(name); 673 while (!stream.fail()) { 674 stream >> molID >> ws; 675 mol = World::getInstance().getMolecule(MoleculeById(molID)); 676 if (mol != NULL) 677 _T.push_back(mol); 678 molID = -1; 679 mol = NULL; 680 } 681 } else 682 throw IllegalTypeException(__FILE__,__LINE__); 683 } 684 685 686 void MapOfActions::setCurrentValue(const char * name, class atom * &_T) 687 { 688 if (typeid( atom ) == *TypeMap[name]) { 689 std::ostringstream stream; 690 stream << _T->getId(); 691 CurrentValue[name] = stream.str(); 692 } else 693 throw IllegalTypeException(__FILE__,__LINE__); 694 } 695 696 void MapOfActions::setCurrentValue(const char * name, class element * &_T) 697 { 698 if (typeid( element ) == *TypeMap[name]) { 699 std::ostringstream stream; 700 stream << _T->Z; 701 CurrentValue[name] = stream.str(); 702 } else 703 throw IllegalTypeException(__FILE__,__LINE__); 704 } 705 706 void MapOfActions::setCurrentValue(const char * name, class molecule * &_T) 707 { 708 if (typeid( molecule ) == *TypeMap[name]) { 709 std::ostringstream stream; 710 stream << _T->getId(); 711 CurrentValue[name] = stream.str(); 712 } else 713 throw IllegalTypeException(__FILE__,__LINE__); 714 } 715 716 void MapOfActions::setCurrentValue(const char * name, class Box &_T) 717 { 718 const Matrix &M = _T.getM(); 719 if (typeid( BoxValue ) == *TypeMap[name]) { 720 std::ostringstream stream; 721 stream << M.at(0,0) << " "; 722 stream << M.at(0,1) << " "; 723 stream << M.at(0,2) << " "; 724 stream << M.at(1,1) << " "; 725 stream << M.at(1,2) << " "; 726 stream << M.at(2,2) << " "; 727 CurrentValue[name] = stream.str(); 728 } else 729 throw IllegalTypeException(__FILE__,__LINE__); 730 } 731 732 void MapOfActions::setCurrentValue(const char * name, class Vector &_T) 733 { 734 if (typeid( VectorValue ) == *TypeMap[name]){ 735 std::ostringstream stream; 736 stream << _T[0] << " "; 737 stream << _T[1] << " "; 738 stream << _T[2] << " "; 739 CurrentValue[name] = stream.str(); 740 } else 741 throw IllegalTypeException(__FILE__,__LINE__); 742 } 743 744 void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T) 745 { 746 if (typeid( std::vector<atom *> ) == *TypeMap[name]) { 747 std::ostringstream stream; 748 for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 749 stream << (*iter)->getId() << " "; 750 } 751 CurrentValue[name] = stream.str(); 752 } else 753 throw IllegalTypeException(__FILE__,__LINE__); 754 } 755 756 void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T) 757 { 758 if (typeid( std::vector<element *> ) == *TypeMap[name]) { 759 std::ostringstream stream; 760 for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 761 stream << (*iter)->Z << " "; 762 } 763 CurrentValue[name] = stream.str(); 764 } else 765 throw IllegalTypeException(__FILE__,__LINE__); 766 } 767 768 void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T) 769 { 770 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) { 771 std::ostringstream stream; 772 for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 773 stream << (*iter)->getId() << " "; 774 } 775 CurrentValue[name] = stream.str(); 776 } else 777 throw IllegalTypeException(__FILE__,__LINE__); 778 } 779 780 781 782 void MapOfActions::populateActions() 783 { 784 new AnalysisMolecularVolumeAction(); 785 new AnalysisPairCorrelationAction(); 786 new AnalysisPointCorrelationAction(); 787 new AnalysisPrincipalAxisSystemAction(); 788 new AnalysisSurfaceCorrelationAction(); 789 790 new AtomAddAction(); 791 new AtomChangeElementAction(); 792 new AtomRemoveAction(); 793 794 new CommandLineBondLengthTableAction(); 795 new CommandLineElementDbAction(); 796 new CommandLineFastParsingAction(); 797 new CommandLineHelpAction(); 798 new CommandLineVerboseAction(); 799 new CommandLineVersionAction(); 800 801 new FragmentationDepthFirstSearchAction(); 802 new FragmentationFragmentationAction(); 803 new FragmentationSubgraphDissectionAction(); 804 805 new MoleculeBondFileAction(); 806 new MoleculeChangeNameAction(); 807 new MoleculeFillWithMoleculeAction(); 808 new MoleculeLinearInterpolationofTrajectoriesAction(); 809 new MoleculeRotateToPrincipalAxisSystemAction(); 810 new MoleculeSaveAdjacencyAction(); 811 new MoleculeSaveBondsAction(); 812 new MoleculeSaveTemperatureAction(); 813 new MoleculeSuspendInWaterAction(); 814 new MoleculeTranslateAction(); 815 new MoleculeVerletIntegrationAction(); 816 817 new ParserLoadXyzAction(); 818 new ParserSaveXyzAction(); 819 820 new SelectionAllAtomsAction(); 821 new SelectionAllMoleculesAction(); 822 new SelectionAtomByIdAction(); 823 new SelectionMoleculeByIdAction(); 824 new SelectionNotAllAtomsAction(); 825 new SelectionNotAllMoleculesAction(); 826 new SelectionNotAtomByIdAction(); 827 new SelectionNotMoleculeByIdAction(); 828 829 new TesselationConvexEnvelopeAction(); 830 new TesselationNonConvexEnvelopeAction(); 831 832 new WorldAddEmptyBoundaryAction(); 833 new WorldBoundInBoxAction(); 834 new WorldCenterInBoxAction(); 835 new WorldCenterOnEdgeAction(); 836 new WorldChangeBoxAction(); 837 new WorldInputAction(); 838 new WorldOutputAction(); 839 new WorldRemoveSphereOfAtomsAction(); 840 new WorldRepeatBoxAction(); 841 new WorldScaleBoxAction(); 842 new WorldSetDefaultNameAction(); 843 new WorldSetGaussianBasisAction(); 844 new WorldSetOutputFormatsAction(); 845 } 846 325 847 /** Adds all options to the CommandLineParser. 326 848 * … … 332 854 for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) { 333 855 if (hasValue(*OptionRunner)) { 334 DoLog( 0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]<< " to CommandLineParser." << endl);335 switch( (enum OptionTypes) TypeMap[*OptionRunner]) {856 DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl); 857 switch(TypeEnumMap[TypeMap[*OptionRunner]]) { 336 858 default: 337 859 case None: … … 343 865 ListRunner->second->add_options() 344 866 (getKeyAndShortForm(*OptionRunner).c_str(), 345 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?346 po::value< bool >()->default_value( atoi(DefaultValue[*OptionRunner].c_str())) :867 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 868 po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 347 869 po::value< bool >(), 348 870 getDescription(*OptionRunner).c_str()) … … 352 874 ListRunner->second->add_options() 353 875 (getKeyAndShortForm(*OptionRunner).c_str(), 354 po::value<BoxValue>() ->multitoken(),876 po::value<BoxValue>(), 355 877 getDescription(*OptionRunner).c_str()) 356 878 ; … … 359 881 ListRunner->second->add_options() 360 882 (getKeyAndShortForm(*OptionRunner).c_str(), 361 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?362 po::value< int >()->default_value( atoi(DefaultValue[*OptionRunner].c_str())) :883 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 884 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 363 885 po::value< int >(), 364 886 getDescription(*OptionRunner).c_str()) 365 887 ; 366 888 break; 367 case ListOfInt s:889 case ListOfIntegers: 368 890 ListRunner->second->add_options() 369 891 (getKeyAndShortForm(*OptionRunner).c_str(), … … 375 897 ListRunner->second->add_options() 376 898 (getKeyAndShortForm(*OptionRunner).c_str(), 377 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?378 po::value< double >()->default_value( atof(DefaultValue[*OptionRunner].c_str())) :899 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 900 po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) : 379 901 po::value< double >(), 380 902 getDescription(*OptionRunner).c_str()) … … 391 913 ListRunner->second->add_options() 392 914 (getKeyAndShortForm(*OptionRunner).c_str(), 393 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?394 po::value< std::string >()->default_value( DefaultValue[*OptionRunner]) :915 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 916 po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) : 395 917 po::value< std::string >(), 396 918 getDescription(*OptionRunner).c_str()) 397 919 ; 398 920 break; 399 case Axis: 400 ListRunner->second->add_options() 401 (getKeyAndShortForm(*OptionRunner).c_str(), 402 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 403 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 921 case ListOfStrings: 922 ListRunner->second->add_options() 923 (getKeyAndShortForm(*OptionRunner).c_str(), 924 po::value< vector<std::string> >()->multitoken(), 925 getDescription(*OptionRunner).c_str()) 926 ; 927 break; 928 case Vector: 929 ListRunner->second->add_options() 930 (getKeyAndShortForm(*OptionRunner).c_str(), 931 po::value<VectorValue>(), 932 getDescription(*OptionRunner).c_str()) 933 ; 934 break; 935 case ListOfVectors: 936 ListRunner->second->add_options() 937 (getKeyAndShortForm(*OptionRunner).c_str(), 938 po::value< vector<VectorValue> >()->multitoken(), 939 getDescription(*OptionRunner).c_str()) 940 ; 941 break; 942 case Molecule: 943 ListRunner->second->add_options() 944 (getKeyAndShortForm(*OptionRunner).c_str(), 945 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 946 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 404 947 po::value< int >(), 405 948 getDescription(*OptionRunner).c_str()) 406 949 ; 407 950 break; 408 case Vector:409 ListRunner->second->add_options() 410 (getKeyAndShortForm(*OptionRunner).c_str(), 411 po::value< VectorValue>()->multitoken(),412 getDescription(*OptionRunner).c_str()) 413 ; 414 break; 415 case Molecule:416 ListRunner->second->add_options() 417 (getKeyAndShortForm(*OptionRunner).c_str(), 418 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?419 po::value< int >()->default_value( atoi(DefaultValue[*OptionRunner].c_str())) :951 case ListOfMolecules: 952 ListRunner->second->add_options() 953 (getKeyAndShortForm(*OptionRunner).c_str(), 954 po::value< vector<int> >()->multitoken(), 955 getDescription(*OptionRunner).c_str()) 956 ; 957 break; 958 case Atom: 959 ListRunner->second->add_options() 960 (getKeyAndShortForm(*OptionRunner).c_str(), 961 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 962 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 420 963 po::value< int >(), 421 964 getDescription(*OptionRunner).c_str()) 422 965 ; 423 966 break; 424 case ListOf Molecules:967 case ListOfAtoms: 425 968 ListRunner->second->add_options() 426 969 (getKeyAndShortForm(*OptionRunner).c_str(), … … 429 972 ; 430 973 break; 431 case Atom:432 ListRunner->second->add_options()433 (getKeyAndShortForm(*OptionRunner).c_str(),434 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?435 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :436 po::value< int >(),437 getDescription(*OptionRunner).c_str())438 ;439 break;440 case ListOfAtoms:441 ListRunner->second->add_options()442 (getKeyAndShortForm(*OptionRunner).c_str(),443 po::value< vector<int> >()->multitoken(),444 getDescription(*OptionRunner).c_str())445 ;446 break;447 974 case Element: 448 975 ListRunner->second->add_options() 449 976 (getKeyAndShortForm(*OptionRunner).c_str(), 450 po::value< vector<int>>(),977 po::value< int >(), 451 978 getDescription(*OptionRunner).c_str()) 452 979 ; … … 461 988 } 462 989 } else { 463 DoLog( 0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);990 DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl); 464 991 ListRunner->second->add_options() 465 992 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str()) … … 468 995 } 469 996 } 470 // add positional arguments471 for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) {472 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);473 CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1);474 }475 cout << "Name for position 1: " << CommandLineParser::getInstance().inputfile.name_for_position(1) << endl;476 997 } 477 998 … … 529 1050 * \return type of the action 530 1051 */ 531 enum MapOfActions::OptionTypesMapOfActions::getValueType(string actionname)532 { 533 return TypeMap[actionname] ;1052 std::string MapOfActions::getValueType(string actionname) 1053 { 1054 return TypeMap[actionname]->name(); 534 1055 } 535 1056 -
src/Actions/MapOfActions.hpp
r06f4ef6 rb6da28 9 9 #define MAPOFACTIONS_HPP_ 10 10 11 #include "Helpers/Assert.hpp"12 11 #include <boost/program_options.hpp> 12 #include <boost/lexical_cast.hpp> 13 13 14 #include <map> 14 15 #include <set> 16 #include <vector> 17 #include <typeinfo> 18 19 #include "Exceptions/IllegalTypeException.hpp" 20 #include "Exceptions/MissingValueException.hpp" 21 #include "Helpers/Assert.hpp" 22 #include "Patterns/Singleton.hpp" 15 23 16 24 class MapOfActionsTest; 17 25 18 #include "Patterns/Singleton.hpp" 26 class Box; 27 class atom; 28 class element; 29 class molecule; 30 class Vector; 19 31 20 32 namespace po = boost::program_options; 21 33 34 using boost::lexical_cast; 35 36 /** Central class for adding functionality to the code. 37 * 38 * In Molecuilder everything that can be done - such as adding atoms, 39 * translating molecules, saving bind information - is an Action. 40 * 41 * In order to reference Action's with what the user sees, this class is the 42 * mediator. 43 * 44 * An Action is described to the user by: 45 * -# a name (this is the most important information) 46 * -# a description 47 * -# a shortform (single letter for use on the command line) 48 * -# a text menu it resides in 49 * -# the type of its argument 50 * -# the command line category 51 * 52 * The Action::NAME is the most important information because every Action 53 * registers itself automatically with the ActionRegistry and can be retrieved 54 * therefrom and from this MapOfActions simply by knowing its name alone. 55 * 56 * In the constructor of MapOfActions all this is set. 57 * 58 * Note that Action will require input from the user. This is done via class 59 * Query. 60 * 61 * And note also that MapOfActions actually contains more than just all 62 * Actions: There are a number of names that actually are just arguments to 63 * actions (e.g. "output-file"). 64 * 65 * <h1> Howto add an Action</h1> 66 * 67 * Let us assume your new action (class) is called SuperDuperAction, consisting 68 * of two files SuperDuperAction.cpp and SuperDuperAction.hpp. 69 * 70 * Furthermore, let's say you Action needs two values: a double value as a 71 * upper threshold and a string which is the name of the output file. 72 * 73 * <h2> Command Line preliminaries </h2> 74 * 75 * You have to decide whether (for the command line) it makes sense to have an 76 * extra argument requesting the arguments, or one should be the argument of 77 * your action. I.e. your action name is "super-duper", then the use may 78 * call your action like this: 79 * 80 * ./molecuilder --super-duper 4 --output-file test.dat 81 * 82 * Here, we have picked the threshold as the value for your action and the 83 * name of the output file is given by an additional argument. Of course, 84 * it can be the other way round or by two arguments such as here: 85 * 86 * ./molecuilder --super-duper --threshold 4 --output-file test.dat 87 * 88 * It depends on what possible arguments are already there (don't make up 89 * new ones if present ones actually make sense for your action) and which 90 * argument is more natural or closer to what your action does. 91 * 92 * <h2> Menu preliminaries </h2> 93 * 94 * Whatever you decide, your action will need some Query dialogs to request 95 * the necessary information from the user, either via a command line 96 * argument (--output-file) via a text dialog (referenced by "output-file") 97 * or via a graphical dialog (same reference). And therein, the names 98 * of the arguments have to re-appear. 99 * 100 * Then, the following steps have to be done to incorporate your Action: 101 * -# create a unique name for your action (no capital letters) to reference 102 * it, this name has to appear in the file SuperDuperAction.cpp, e.g. 103 * "super-duper" 104 * -# pick names the other required arguments, best if they are already 105 * present in the MapOfActions. They have to appear in Query's in the 106 * code of your Action. 107 * -# With this name create entries in the following maps for the action 108 * name and for each names of a desired addtional argument if not present: 109 * -# DescriptionMap, a catchy description of what your action does 110 * -# TypeMap, see MapOfActions::OptionTypes for possible types of the single 111 * argument it takes. 112 * -# MenuContainsActionMap, in which menu should your action appear 113 * -# ShortFormMap (optional), single letter for command line call 114 * -# DefaultValueMap (optional), the default value (always a string) 115 * -# add to one of the command line sets by the following categories 116 * -# generic - generic options (i.e. not one of the others) 117 * -# config - action/argument only considers internal bevahior, user 118 * does not have to see it while still having full functionality 119 * -# hidden - this should be hidden from the user 120 * -# visible - this should be visible to the user 121 * -# inputfile - this should only be parsed from an input file, not 122 * from command line 123 * -# add to a menu, i.e. make an entry in MenuContainsActionMap. 124 * -# add header file SuperDuperAction.hpp to MapOfActions.cpp and instantiate 125 * your action in populateMenu() (mind the sorting: 1. menu, 126 * 2. alphabetical) 127 * 128 * And that's. 129 * 130 * Now, your action can be called from the command line, within the text 131 * menu and the graphical user interface. 132 * 133 */ 22 134 class MapOfActions : public Singleton<MapOfActions> { 23 135 friend class Singleton<MapOfActions>; 24 136 friend class MapOfActionsTest; 25 137 public: 26 enum OptionTypes { None, Boolean, Integer, ListOfInt s, Double, ListOfDoubles, String, Axis, Vector, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };138 enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements }; 27 139 28 140 // getter for the action descriptions and short forms 29 std::string getDescription(st ring actionname);30 std::string getKeyAndShortForm(st ring actionname);31 std::string getShortForm(st ring actionname);32 map <std::string, std::string> getShortFormToActionMap();141 std::string getDescription(std::string actionname); 142 std::string getKeyAndShortForm(std::string actionname); 143 std::string getShortForm(std::string actionname); 144 std::map <std::string, std::string> getShortFormToActionMap(); 33 145 34 146 void AddOptionsToParser(); 35 147 36 148 // check presence and getter for action type 37 bool hasValue(string actionname); 38 bool isShortFormPresent(string shortform); 39 enum OptionTypes getValueType(string actionname); 40 41 set<string> generic; 42 set<string> config; 43 set<string> hidden; 44 set<string> visible; 45 set<string> inputfile; 149 bool hasValue(std::string actionname); 150 bool isShortFormPresent(std::string shortform); 151 std::string getValueType(std::string actionname); 152 153 std::set<std::string> generic; 154 std::set<std::string> config; 155 std::set<std::string> hidden; 156 std::set<std::string> visible; 157 std::set<std::string> inputfile; 158 159 std::multimap <std::string, std::string> MenuContainsActionMap; 160 std::map <std::string, std::pair<std::string,std::string> > MenuDescription; 161 162 // instantiates and puts all known actions into the ActionRegistry 163 void populateActions(); 164 165 void queryCurrentValue(const char * name, class atom * &_T); 166 void queryCurrentValue(const char * name, class element * &_T); 167 void queryCurrentValue(const char * name, class molecule * &_T); 168 void queryCurrentValue(const char * name, class Box &_T); 169 void queryCurrentValue(const char * name, class Vector &_T); 170 void queryCurrentValue(const char * name, std::vector<atom *>&_T); 171 void queryCurrentValue(const char * name, std::vector<element *>&_T); 172 void queryCurrentValue(const char * name, std::vector<molecule *>&_T); 173 template<typename T> void queryCurrentValue(const char * name, T &_T) 174 { 175 if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 176 if (CurrentValue.find(name) == CurrentValue.end()) 177 throw MissingValueException(__FILE__, __LINE__); 178 _T = lexical_cast<T>(CurrentValue[name].c_str()); 179 CurrentValue.erase(name); 180 } else 181 throw IllegalTypeException(__FILE__,__LINE__); 182 } 183 template<typename T> void queryCurrentValue(const char * name, std::vector<T> &_T) 184 { 185 T temp; 186 if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 187 if (CurrentValue.find(name) == CurrentValue.end()) 188 throw MissingValueException(__FILE__, __LINE__); 189 std::istringstream stream(CurrentValue[name]); 190 CurrentValue.erase(name); 191 while (!stream.fail()) { 192 stream >> temp >> std::ws; 193 _T.push_back(temp); 194 } 195 } else 196 throw IllegalTypeException(__FILE__,__LINE__); 197 } 198 199 void setCurrentValue(const char * name, class atom * &_T); 200 void setCurrentValue(const char * name, class element * &_T); 201 void setCurrentValue(const char * name, class molecule * &_T); 202 void setCurrentValue(const char * name, class Box &_T); 203 void setCurrentValue(const char * name, class Vector &_T); 204 void setCurrentValue(const char * name, std::vector<atom *>&_T); 205 void setCurrentValue(const char * name, std::vector<element *>&_T); 206 void setCurrentValue(const char * name, std::vector<molecule *>&_T); 207 template<class T> void setCurrentValue(const char * name, T &_T) 208 { 209 std::ostringstream stream; 210 if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 211 stream << _T; 212 CurrentValue[name] = stream.str(); 213 } else 214 throw IllegalTypeException(__FILE__,__LINE__); 215 } 216 template<class T> void setCurrentValue(const char * name, std::vector<T> &_T) 217 { 218 std::ostringstream stream; 219 if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 220 std::ostringstream stream; 221 for (typename std::vector<T>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 222 stream << (*iter) << " "; 223 } 224 CurrentValue[name] = stream.str(); 225 } else 226 throw IllegalTypeException(__FILE__,__LINE__); 227 } 228 46 229 47 230 private: … … 51 234 52 235 // lookup list from our configs to the ones of CommandLineParser 53 map<set<std::string> *, po::options_description *> CmdParserLookup;236 std::map< std::set<std::string> *, po::options_description *> CmdParserLookup; 54 237 55 238 // map of the action names and their description 56 map<std::string, std::string> DefaultValue; 57 map<std::string, std::string> DescriptionMap; 58 map<std::string, std::string> ShortFormMap; 59 map<std::string, enum OptionTypes > TypeMap; 239 std::map<std::string, std::string> CurrentValue; 240 std::map<std::string, std::string> DescriptionMap; 241 std::map<std::string, std::string> ShortFormMap; 242 std::map<std::string, const std::type_info * > TypeMap; 243 std::map<const std::type_info *, enum OptionTypes > TypeEnumMap; 60 244 }; 61 245 -
src/Actions/MethodAction.cpp
r06f4ef6 rb6da28 26 26 {} 27 27 28 Dialog* MethodAction::fillDialog(Dialog *dialog) { 29 ASSERT(dialog,"No Dialog given when filling action dialog"); 30 return dialog; 31 } 32 28 33 29 34 Action::state_ptr MethodAction::performCall() { -
src/Actions/MethodAction.hpp
r06f4ef6 rb6da28 25 25 virtual bool shouldUndo(); 26 26 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 27 29 private: 28 30 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/BondFileAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/BondFileAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 #include "World.hpp" 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 21 26 22 #include "atom.hpp"23 #include "bondgraph.hpp"24 #include "config.hpp"25 #include "defs.hpp"26 #include "log.hpp"27 #include "molecule.hpp"28 #include "vector.hpp"29 #include "World.hpp"30 27 31 28 /****** MoleculeBondFileAction *****/ … … 52 49 {} 53 50 51 void MoleculeBondFile(std::string &bondfile) { 52 ValueStorage::getInstance().setCurrentValue(MoleculeBondFileAction::NAME, bondfile); 53 ActionRegistry::getInstance().getActionByName(MoleculeBondFileAction::NAME)->call(Action::NonInteractive); 54 }; 55 56 Dialog* MoleculeBondFileAction::fillDialog(Dialog *dialog) { 57 ASSERT(dialog,"No Dialog given when filling action dialog"); 58 59 dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME)); 60 61 return dialog; 62 } 63 54 64 Action::state_ptr MoleculeBondFileAction::performCall() { 55 65 string filename; 56 Dialog *dialog = UIFactory::getInstance().makeDialog();57 66 molecule *mol = NULL; 58 67 59 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 60 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 68 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 61 69 62 if(dialog->display()) { 70 if(World::getInstance().countSelectedMolecules() == 1) { 71 mol = World::getInstance().beginMoleculeSelection()->second; 63 72 DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << filename << "." << endl); 64 73 ifstream input(filename.c_str()); 65 74 mol->CreateAdjacencyListFromDbondFile(&input); 66 75 input.close(); 67 delete dialog;68 76 return Action::success; 69 } 70 delete dialog; 71 return Action::failure; 77 } else 78 return Action::failure; 72 79 } 73 80 -
src/Actions/MoleculeAction/BondFileAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeBondFile(std::string &bondfile); 17 16 18 class MoleculeBondFileAction : public Action { 19 friend void MoleculeBondFile(std::string &bondfile); 20 17 21 public: 18 22 MoleculeBondFileAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/ChangeNameAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "atom.hpp" 13 #include "molecule.hpp" 11 14 12 15 #include <iostream> … … 17 20 #include "UIElements/UIFactory.hpp" 18 21 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "molecule.hpp" 22 #include "UIElements/ValueStorage.hpp" 23 23 24 24 /****** MoleculeChangeNameAction *****/ … … 36 36 }; 37 37 38 const char MoleculeChangeNameAction::NAME[] = " Change filename of Molecule";38 const char MoleculeChangeNameAction::NAME[] = "change-molname"; 39 39 40 40 MoleculeChangeNameAction::MoleculeChangeNameAction() : … … 45 45 {} 46 46 47 void MoleculeChangeName(std::string &name) { 48 ValueStorage::getInstance().setCurrentValue(MoleculeChangeNameAction::NAME, name); 49 ActionRegistry::getInstance().getActionByName(MoleculeChangeNameAction::NAME)->call(Action::NonInteractive); 50 }; 51 52 Dialog* MoleculeChangeNameAction::fillDialog(Dialog *dialog) { 53 ASSERT(dialog,"No Dialog given when filling action dialog"); 54 55 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 56 57 return dialog; 58 } 59 47 60 Action::state_ptr MoleculeChangeNameAction::performCall() { 48 61 string filename; 49 62 molecule *mol = NULL; 50 Dialog *dialog = UIFactory::getInstance().makeDialog();51 63 52 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 53 dialog->queryString("Enter name: ",&filename); 64 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 54 65 55 if(dialog->display()) { 66 if (World::getInstance().countSelectedMolecules() == 1) { 67 mol = World::getInstance().beginMoleculeSelection()->second; 56 68 string oldName = mol->getName(); 57 69 mol->setName(filename); 58 delete dialog;59 70 return Action::state_ptr(new MoleculeChangeNameState(mol,oldName)); 60 } 61 delete dialog; 62 return Action::failure; 71 } else 72 return Action::failure; 63 73 } 64 74 -
src/Actions/MoleculeAction/ChangeNameAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeChangeName(std::string &name); 17 16 18 class MoleculeChangeNameAction : public Action { 19 friend void MoleculeChangeName(std::string &name); 20 17 21 public: 18 22 MoleculeChangeNameAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "atom.hpp" 13 #include "bondgraph.hpp" 14 #include "boundary.hpp" 15 #include "config.hpp" 16 #include "molecule.hpp" 17 #include "verbose.hpp" 18 #include "World.hpp" 19 11 20 12 21 #include <iostream> … … 17 26 #include "UIElements/UIFactory.hpp" 18 27 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "bondgraph.hpp" 23 #include "boundary.hpp" 24 #include "config.hpp" 25 #include "defs.hpp" 26 #include "molecule.hpp" 27 #include "periodentafel.hpp" 28 #include "vector.hpp" 29 #include "verbose.hpp" 30 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 31 29 32 30 /****** MoleculeFillWithMoleculeAction *****/ … … 53 51 {} 54 52 53 void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeFillWithMoleculeAction::NAME, fillername); 55 ValueStorage::getInstance().setCurrentValue("distances", distances); 56 ValueStorage::getInstance().setCurrentValue("lengths", lengths); 57 ValueStorage::getInstance().setCurrentValue("DoRotate", MaxDistance); 58 ValueStorage::getInstance().setCurrentValue("MaxDistance", DoRotate); 59 ActionRegistry::getInstance().getActionByName(MoleculeFillWithMoleculeAction::NAME)->call(Action::NonInteractive); 60 }; 61 62 Dialog* MoleculeFillWithMoleculeAction::fillDialog(Dialog *dialog) { 63 ASSERT(dialog,"No Dialog given when filling action dialog"); 64 65 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 66 dialog->queryVector("distances", false, ValueStorage::getInstance().getDescription("distances")); 67 dialog->queryVector("lengths", false, ValueStorage::getInstance().getDescription("lengths")); 68 dialog->queryBoolean("DoRotate", ValueStorage::getInstance().getDescription("DoRotate")); 69 dialog->queryDouble("MaxDistance", ValueStorage::getInstance().getDescription("MaxDistance")); 70 71 return dialog; 72 } 73 55 74 Action::state_ptr MoleculeFillWithMoleculeAction::performCall() { 56 75 string filename; 57 Dialog *dialog = UIFactory::getInstance().makeDialog();58 76 Vector distances; 59 77 Vector lengths; … … 61 79 bool DoRotate = false; 62 80 63 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));64 dialog->queryVector("distances", &distances, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("distances"));65 dialog->queryVector("lengths", &lengths, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("lengths"));66 dialog->queryBoolean("DoRotate", &DoRotate, MapOfActions::getInstance().getDescription("DoRotate"));67 dialog->queryDouble("MaxDistance", &MaxDistance, MapOfActions::getInstance().getDescription("MaxDistance"));81 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 82 ValueStorage::getInstance().queryCurrentValue("distances", distances); 83 ValueStorage::getInstance().queryCurrentValue("lengths", lengths); 84 ValueStorage::getInstance().queryCurrentValue("DoRotate", DoRotate); 85 ValueStorage::getInstance().queryCurrentValue("MaxDistance", MaxDistance); 68 86 69 if(dialog->display()) { 70 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl); 71 // construct water molecule 72 molecule *filler = World::getInstance().createMolecule(); 73 if (!filler->AddXYZFile(filename)) { 74 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl); 75 } 76 filler->SetNameFromFilename(filename.c_str()); 77 molecule *Filling = NULL; 87 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl); 88 // construct water molecule 89 molecule *filler = World::getInstance().createMolecule(); 90 if (!filler->AddXYZFile(filename)) { 91 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl); 92 } 93 filler->SetNameFromFilename(filename.c_str()); 94 molecule *Filling = NULL; 78 95 // atom *first = NULL, *second = NULL, *third = NULL; 79 96 // first = World::getInstance().createAtom(); … … 91 108 // filler->AddBond(first, third, 1); 92 109 // filler->AddBond(second, third, 1); 93 110 World::getInstance().getConfig()->BG->ConstructBondGraph(filler); 94 111 // filler->SetNameFromFilename("water"); 95 // call routine 96 double distance[NDIM]; 97 for (int i=0;i<NDIM;i++) 98 distance[i] = distances[i]; 99 Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate); 100 if (Filling != NULL) { 101 Filling->ActiveFlag = false; 102 World::getInstance().getMolecules()->insert(Filling); 103 } 104 World::getInstance().destroyMolecule(filler); 112 // call routine 113 double distance[NDIM]; 114 for (int i=0;i<NDIM;i++) 115 distance[i] = distances[i]; 116 Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate); 117 if (Filling != NULL) { 118 Filling->ActiveFlag = false; 119 World::getInstance().getMolecules()->insert(Filling); 120 } 121 for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) { 122 atom *Walker = *iter; 123 filler->erase(iter); 124 World::getInstance().destroyAtom(Walker); 125 } 126 World::getInstance().destroyMolecule(filler); 105 127 106 delete dialog; 107 return Action::success; 108 } 109 delete dialog; 110 return Action::failure; 128 return Action::success; 111 129 } 112 130 -
src/Actions/MoleculeAction/FillWithMoleculeAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 #include "Actions/Process.hpp" 13 #include "vector.hpp" 13 14 14 15 class MoleculeListClass; 15 16 17 void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate); 18 16 19 class MoleculeFillWithMoleculeAction : public Action { 20 friend void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate); 21 17 22 public: 18 23 MoleculeFillWithMoleculeAction(); … … 23 28 24 29 virtual const std::string getName(); 30 protected: 31 virtual Dialog * fillDialog(Dialog *dialog); 25 32 private: 26 33 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "atom.hpp" 13 #include "defs.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 11 18 12 19 #include <iostream> … … 18 25 #include "UIElements/UIFactory.hpp" 19 26 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 21 28 22 #include "atom.hpp"23 #include "defs.hpp"24 #include "log.hpp"25 #include "molecule.hpp"26 #include "verbose.hpp"27 #include "World.hpp"28 29 29 30 /****** MoleculeLinearInterpolationofTrajectoriesAction *****/ … … 50 51 {} 51 52 53 void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeLinearInterpolationofTrajectoriesAction::NAME, filename); 55 ValueStorage::getInstance().setCurrentValue("start-step", start); 56 ValueStorage::getInstance().setCurrentValue("end-step", end); 57 ValueStorage::getInstance().setCurrentValue("id-mapping", IdMapping); 58 ActionRegistry::getInstance().getActionByName(MoleculeLinearInterpolationofTrajectoriesAction::NAME)->call(Action::NonInteractive); 59 }; 60 61 Dialog* MoleculeLinearInterpolationofTrajectoriesAction::fillDialog(Dialog *dialog) { 62 ASSERT(dialog,"No Dialog given when filling action dialog"); 63 64 dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME)); 65 dialog->queryInt("start-step", MapOfActions::getInstance().getDescription("start-step")); 66 dialog->queryInt("end-step", MapOfActions::getInstance().getDescription("end-step")); 67 dialog->queryBoolean("id-mapping", MapOfActions::getInstance().getDescription("id-mapping")); 68 69 return dialog; 70 } 71 52 72 Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() { 53 73 string filename; 54 Dialog *dialog = UIFactory::getInstance().makeDialog();55 74 molecule *mol = NULL; 56 75 int start = -1; … … 58 77 bool IdMapping = true; 59 78 79 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 80 ValueStorage::getInstance().queryCurrentValue("start-step", start); 81 ValueStorage::getInstance().queryCurrentValue("end-step", end); 82 ValueStorage::getInstance().queryCurrentValue("id-mapping", IdMapping); 60 83 61 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 62 dialog->queryInt("start-step", &start, MapOfActions::getInstance().getDescription("start-step")); 63 dialog->queryInt("end-step", &end, MapOfActions::getInstance().getDescription("end-step")); 64 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 65 dialog->queryBoolean("id-mapping", &IdMapping, MapOfActions::getInstance().getDescription("id-mapping")); 66 67 if(dialog->display()) { 84 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 85 mol = iter->second; 68 86 DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << start << " and " << end << "." << endl); 69 87 if (IdMapping) 70 88 DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl); 71 char outputname[MAXSTRINGSIZE]; 72 strcpy(outputname, filename.c_str()); 73 // TODO: LinearInterpolationBetweenConfiguration should use stream, not the filename directly! (better for unit test) 74 if (!mol->LinearInterpolationBetweenConfiguration(start, end, outputname, *(World::getInstance().getConfig()), IdMapping)) 75 DoLog(2) && (Log() << Verbose(2) << "Could not store " << outputname << " files." << endl); 89 if (!mol->LinearInterpolationBetweenConfiguration(start, end, filename, *(World::getInstance().getConfig()), IdMapping)) 90 DoLog(2) && (Log() << Verbose(2) << "Could not store " << filename << " files." << endl); 76 91 else 77 92 DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl); 78 delete dialog;79 return Action::success;80 93 } 81 delete dialog; 82 return Action::failure; 94 return Action::success; 83 95 } 84 96 -
src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping); 17 16 18 class MoleculeLinearInterpolationofTrajectoriesAction : public Action { 19 friend void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping); 20 17 21 public: 18 22 MoleculeLinearInterpolationofTrajectoriesAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "log.hpp" 23 #include "molecule.hpp" 24 #include "verbose.hpp" 25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 /****** MoleculeRotateToPrincipalAxisSystemAction *****/ … … 47 48 {} 48 49 50 void MoleculeRotateToPrincipalAxisSystem() { 51 ActionRegistry::getInstance().getActionByName(MoleculeRotateToPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive); 52 }; 53 54 Dialog* MoleculeRotateToPrincipalAxisSystemAction::fillDialog(Dialog *dialog) { 55 ASSERT(dialog,"No Dialog given when filling action dialog"); 56 57 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 58 59 return dialog; 60 } 61 49 62 Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() { 50 Dialog *dialog = UIFactory::getInstance().makeDialog();51 63 molecule *mol = NULL; 52 64 53 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 54 55 if(dialog->display()) { 65 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 66 mol = iter->second; 56 67 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl); 57 68 mol->PrincipalAxisSystem(true); 58 delete dialog;59 return Action::success;60 69 } 61 delete dialog; 62 return Action::failure; 70 return Action::success; 63 71 } 64 72 -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeRotateToPrincipalAxisSystem(); 17 16 18 class MoleculeRotateToPrincipalAxisSystemAction : public Action { 19 friend void MoleculeRotateToPrincipalAxisSystem(); 20 17 21 public: 18 22 MoleculeRotateToPrincipalAxisSystemAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/SaveAdjacencyAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "bondgraph.hpp" 13 #include "config.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 18 11 19 12 20 #include <iostream> … … 18 26 #include "UIElements/UIFactory.hpp" 19 27 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "bondgraph.hpp" 24 #include "config.hpp" 25 #include "defs.hpp" 26 #include "log.hpp" 27 #include "molecule.hpp" 28 #include "vector.hpp" 29 #include "verbose.hpp" 30 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 31 29 32 30 /****** MoleculeSaveAdjacencyAction *****/ … … 53 51 {} 54 52 53 void MoleculeSaveAdjacency(std::string &adjacencyfile) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeSaveAdjacencyAction::NAME, adjacencyfile); 55 ActionRegistry::getInstance().getActionByName(MoleculeSaveAdjacencyAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* MoleculeSaveAdjacencyAction::fillDialog(Dialog *dialog) { 59 ASSERT(dialog,"No Dialog given when filling action dialog"); 60 61 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 63 return dialog; 64 } 65 55 66 Action::state_ptr MoleculeSaveAdjacencyAction::performCall() { 56 67 string filename; 57 Dialog *dialog = UIFactory::getInstance().makeDialog();58 68 molecule *mol = NULL; 59 69 60 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 70 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 62 71 63 if(dialog->display()) { 72 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 73 mol = iter->second; 64 74 DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << filename << "." << endl); 65 75 World::getInstance().getConfig()->BG->ConstructBondGraph(mol); 66 76 // TODO: sollte stream nicht filename benutzen, besser fuer unit test 67 char outputname[MAXSTRINGSIZE]; 68 strcpy(outputname, filename.c_str()); 69 mol->StoreAdjacencyToFile(NULL, outputname); 70 delete dialog; 71 return Action::success; 77 mol->StoreAdjacencyToFile(filename); 72 78 } 73 delete dialog; 74 return Action::failure; 79 return Action::success; 75 80 } 76 81 -
src/Actions/MoleculeAction/SaveAdjacencyAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeSaveAdjacency(std::string &adjacencyfile); 17 16 18 class MoleculeSaveAdjacencyAction : public Action { 19 friend void MoleculeSaveAdjacency(std::string &adjacencyfile); 20 17 21 public: 18 22 MoleculeSaveAdjacencyAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/SaveBondsAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/SaveBondsAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "bondgraph.hpp" 13 #include "config.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 18 11 19 12 20 #include <iostream> … … 18 26 #include "UIElements/UIFactory.hpp" 19 27 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "bondgraph.hpp" 24 #include "config.hpp" 25 #include "defs.hpp" 26 #include "log.hpp" 27 #include "molecule.hpp" 28 #include "vector.hpp" 29 #include "verbose.hpp" 30 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 31 29 32 30 /****** MoleculeSaveBondsAction *****/ … … 53 51 {} 54 52 53 void MoleculeSaveBonds(std::string &bondsfile) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeSaveBondsAction::NAME, bondsfile); 55 ActionRegistry::getInstance().getActionByName(MoleculeSaveBondsAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* MoleculeSaveBondsAction::fillDialog(Dialog *dialog) { 59 ASSERT(dialog,"No Dialog given when filling action dialog"); 60 61 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 63 return dialog; 64 } 65 55 66 Action::state_ptr MoleculeSaveBondsAction::performCall() { 56 67 string filename; 57 Dialog *dialog = UIFactory::getInstance().makeDialog();58 68 molecule *mol = NULL; 59 69 60 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 70 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 62 71 63 if(dialog->display()) { 72 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 73 mol = iter->second; 64 74 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl); 65 75 World::getInstance().getConfig()->BG->ConstructBondGraph(mol); 66 // TODO: sollte stream, nicht filenamen direkt nutzen, beser fuer unit tests 67 char outputname[MAXSTRINGSIZE]; 68 strcpy(outputname, filename.c_str()); 69 mol->StoreBondsToFile(NULL, outputname); 70 delete dialog; 71 return Action::success; 76 // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests 77 mol->StoreBondsToFile(filename); 72 78 } 73 delete dialog; 74 return Action::failure; 79 return Action::success; 75 80 } 76 81 -
src/Actions/MoleculeAction/SaveBondsAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeSaveBonds(std::string &bondsfile); 17 16 18 class MoleculeSaveBondsAction : public Action { 19 friend void MoleculeSaveBonds(std::string &bondsfile); 20 17 21 public: 18 22 MoleculeSaveBondsAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/SaveTemperatureAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 #include "World.hpp" 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "log.hpp" 24 #include "molecule.hpp" 25 #include "verbose.hpp" 26 #include "World.hpp" 25 #include "UIElements/ValueStorage.hpp" 27 26 28 27 /****** MoleculeSaveTemperatureAction *****/ … … 49 48 {} 50 49 50 void MoleculeSaveTemperature(std::string &temperaturefile) { 51 ValueStorage::getInstance().setCurrentValue(MoleculeSaveTemperatureAction::NAME, temperaturefile); 52 ActionRegistry::getInstance().getActionByName(MoleculeSaveTemperatureAction::NAME)->call(Action::NonInteractive); 53 }; 54 55 Dialog* MoleculeSaveTemperatureAction::fillDialog(Dialog *dialog) { 56 ASSERT(dialog,"No Dialog given when filling action dialog"); 57 58 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 59 60 return dialog; 61 } 62 51 63 Action::state_ptr MoleculeSaveTemperatureAction::performCall() { 52 64 string filename; 53 Dialog *dialog = UIFactory::getInstance().makeDialog();54 65 molecule *mol = NULL; 55 66 56 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 57 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 67 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 58 68 59 if(dialog->display()) { 69 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 70 mol = iter->second; 60 71 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl); 61 72 ofstream output; … … 66 77 DoLog(2) && (Log() << Verbose(2) << "File stored." << endl); 67 78 output.close(); 68 delete dialog;69 return Action::success;70 79 } 71 delete dialog; 72 return Action::failure; 80 return Action::success; 73 81 } 74 82 -
src/Actions/MoleculeAction/SaveTemperatureAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeSaveTemperature(std::string &temperaturefile); 17 16 18 class MoleculeSaveTemperatureAction : public Action { 19 friend void MoleculeSaveTemperature(std::string &temperaturefile); 20 17 21 public: 18 22 MoleculeSaveTemperatureAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/SuspendInWaterAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/SuspendInWaterAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "boundary.hpp" 13 #include "config.hpp" 14 #include "log.hpp" 15 #include "verbose.hpp" 16 #include "World.hpp" 11 17 12 18 #include <iostream> … … 17 23 #include "UIElements/UIFactory.hpp" 18 24 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "boundary.hpp" 23 #include "config.hpp" 24 #include "log.hpp" 25 #include "config.hpp" 26 #include "World.hpp" 25 #include "UIElements/ValueStorage.hpp" 27 26 28 27 /****** MoleculeSuspendInWaterAction *****/ … … 49 48 {} 50 49 50 void MoleculeSuspendInWater(double density) { 51 ValueStorage::getInstance().setCurrentValue(MoleculeSuspendInWaterAction::NAME, density); 52 ActionRegistry::getInstance().getActionByName(MoleculeSuspendInWaterAction::NAME)->call(Action::NonInteractive); 53 }; 54 55 Dialog* MoleculeSuspendInWaterAction::fillDialog(Dialog *dialog) { 56 ASSERT(dialog,"No Dialog given when filling action dialog"); 57 58 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 59 60 return dialog; 61 } 62 51 63 Action::state_ptr MoleculeSuspendInWaterAction::performCall() { 52 64 molecule *mol = NULL; 53 Dialog *dialog = UIFactory::getInstance().makeDialog();54 65 double density; 55 66 double volume = 0.; 56 67 57 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 58 dialog->queryDouble("density", &density, MapOfActions::getInstance().getDescription("density")); 68 ValueStorage::getInstance().queryCurrentValue(NAME, density); 59 69 60 if(dialog->display()) { 70 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 71 mol = iter->second; 61 72 DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water."); 62 73 if (density < 1.0) { … … 64 75 } else { 65 76 PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, density); // if volume == 0, will calculate from ConvexEnvelope 66 delete dialog;67 return Action::success;68 77 } 69 78 } 70 delete dialog; 71 return Action::failure; 79 return Action::success; 72 80 } 73 81 -
src/Actions/MoleculeAction/SuspendInWaterAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeSuspendInWater(double density); 17 16 18 class MoleculeSuspendInWaterAction : public Action { 19 friend void MoleculeSuspendInWater(double density); 20 17 21 public: 18 22 MoleculeSuspendInWaterAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/TranslateAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/TranslateAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "vector.hpp" 15 #include "verbose.hpp" 16 #include "World.hpp" 11 17 12 18 #include <iostream> … … 18 24 #include "UIElements/UIFactory.hpp" 19 25 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "log.hpp" 24 #include "molecule.hpp" 25 #include "verbose.hpp" 26 #include "World.hpp" 26 #include "UIElements/ValueStorage.hpp" 27 27 28 28 /****** MoleculeTranslateAction *****/ … … 49 49 {} 50 50 51 void MoleculeTranslate(Vector &x, bool periodic) { 52 ValueStorage::getInstance().setCurrentValue(MoleculeTranslateAction::NAME, x); 53 ValueStorage::getInstance().setCurrentValue("periodic", periodic); 54 ActionRegistry::getInstance().getActionByName(MoleculeTranslateAction::NAME)->call(Action::NonInteractive); 55 }; 56 57 Dialog* MoleculeTranslateAction::fillDialog(Dialog *dialog) { 58 ASSERT(dialog,"No Dialog given when filling action dialog"); 59 60 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 61 dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic")); 62 63 return dialog; 64 } 65 51 66 Action::state_ptr MoleculeTranslateAction::performCall() { 52 Dialog *dialog = UIFactory::getInstance().makeDialog();53 67 molecule *mol = NULL; 54 68 Vector x; 55 69 bool periodic = false; 56 70 57 dialog->queryVector(NAME, &x, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME)); 58 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 59 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic")); 60 cout << "pre-dialog" << endl; 71 ValueStorage::getInstance().queryCurrentValue(NAME, x); 72 ValueStorage::getInstance().queryCurrentValue("periodic", periodic); 61 73 62 if(dialog->display()) {63 cout << "post-dialog" << endl;74 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 75 mol = iter->second; 64 76 DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl); 65 77 if (periodic) … … 67 79 else 68 80 mol->Translate((const Vector *)&x); 69 delete dialog;70 return Action::success;71 81 } 72 delete dialog; 73 return Action::failure; 82 return Action::success; 74 83 } 75 84 -
src/Actions/MoleculeAction/TranslateAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 #include "Actions/Process.hpp" 13 #include "vector.hpp" 13 14 14 15 class MoleculeListClass; 15 16 17 void MoleculeTranslate(Vector &x, bool periodic); 18 16 19 class MoleculeTranslateAction : public Action { 20 friend void MoleculeTranslate(Vector &x, bool periodic); 21 17 22 public: 18 23 MoleculeTranslateAction(); … … 23 28 24 29 virtual const std::string getName(); 30 protected: 31 virtual Dialog * fillDialog(Dialog *dialog); 25 32 private: 26 33 virtual Action::state_ptr performCall(); -
src/Actions/MoleculeAction/VerletIntegrationAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 #include "World.hpp" 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "log.hpp" 24 #include "molecule.hpp" 25 #include "verbose.hpp" 26 #include "World.hpp" 25 #include "UIElements/ValueStorage.hpp" 27 26 28 27 /****** MoleculeVerletIntegrationAction *****/ … … 49 48 {} 50 49 50 void MoleculeVerletIntegration(std::string &forcesfile) { 51 ValueStorage::getInstance().setCurrentValue(MoleculeVerletIntegrationAction::NAME, forcesfile); 52 ActionRegistry::getInstance().getActionByName(MoleculeVerletIntegrationAction::NAME)->call(Action::NonInteractive); 53 }; 54 55 Dialog* MoleculeVerletIntegrationAction::fillDialog(Dialog *dialog) { 56 ASSERT(dialog,"No Dialog given when filling action dialog"); 57 58 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 59 60 return dialog; 61 } 62 51 63 Action::state_ptr MoleculeVerletIntegrationAction::performCall() { 52 64 string filename; 53 Dialog *dialog = UIFactory::getInstance().makeDialog();54 65 molecule *mol = NULL; 55 66 56 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 57 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 67 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 58 68 59 if(dialog->display()) { 69 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 70 mol = iter->second; 60 71 DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl); 61 72 // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test 62 73 char outputname[MAXSTRINGSIZE]; 63 74 strcpy(outputname, filename.c_str()); 64 if (!mol->VerletForceIntegration(outputname, *(World::getInstance().getConfig()) ))75 if (!mol->VerletForceIntegration(outputname, *(World::getInstance().getConfig()), 0)) 65 76 DoLog(2) && (Log() << Verbose(2) << "File not found." << endl); 66 77 else 67 78 DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl); 68 69 delete dialog;70 return Action::success;71 79 } 72 delete dialog; 73 return Action::failure; 80 return Action::success; 74 81 } 75 82 -
src/Actions/MoleculeAction/VerletIntegrationAction.hpp
r06f4ef6 rb6da28 14 14 class MoleculeListClass; 15 15 16 void MoleculeVerletIntegration(std::string &forcesfile); 17 16 18 class MoleculeVerletIntegrationAction : public Action { 19 friend void MoleculeVerletIntegration(std::string &forcesfile); 20 17 21 public: 18 22 MoleculeVerletIntegrationAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/ParserAction/LoadXyzAction.cpp
r06f4ef6 rb6da28 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 using namespace std; 11 10 12 #include "Actions/ParserAction/LoadXyzAction.hpp" 13 #include "Actions/ActionRegistry.hpp" 11 14 #include "Parser/XyzParser.hpp" 15 #include "atom.hpp" 16 #include "log.hpp" 17 #include "molecule.hpp" 18 #include "verbose.hpp" 19 #include "World.hpp" 12 20 13 21 #include <iostream> 22 #include <set> 14 23 #include <string> 15 16 using namespace std; 24 #include <vector> 17 25 18 26 #include "UIElements/UIFactory.hpp" 19 27 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "molecule.hpp" 28 #include "UIElements/ValueStorage.hpp" 24 29 25 30 /****** ParserLoadXyzAction *****/ … … 37 42 //}; 38 43 39 const char ParserLoadXyzAction::NAME[] = " LoadXyz";44 const char ParserLoadXyzAction::NAME[] = "parse-xyz"; 40 45 41 46 ParserLoadXyzAction::ParserLoadXyzAction() : … … 46 51 {} 47 52 53 void ParserLoadXyz(std::string &filename) { 54 ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename); 55 ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* ParserLoadXyzAction::fillDialog(Dialog *dialog) { 59 ASSERT(dialog,"No Dialog given when filling action dialog"); 60 61 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 63 return dialog; 64 } 65 48 66 Action::state_ptr ParserLoadXyzAction::performCall() { 49 67 string filename; 50 XyzParser parser;51 Dialog *dialog = UIFactory::getInstance().makeDialog();52 68 53 dialog->queryString("filename",&filename, "Filename of the xyz file");69 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 54 70 55 if(dialog->display()) { 56 // parse xyz file 57 ifstream input; 58 input.open(filename.c_str()); 59 if (!input.fail()) 60 parser.load(&input); 61 input.close(); 71 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 72 // parse xyz file 73 ifstream input; 74 input.open(filename.c_str()); 75 if (!input.fail()) { 76 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 77 set <atom*> UniqueList; 78 { 79 vector<atom *> ListBefore = World::getInstance().getAllAtoms(); 80 for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner) 81 UniqueList.insert(*runner); 82 } 83 XyzParser parser; // briefly instantiate a parser which is removed at end of focus 84 parser.load(&input); 85 { 86 vector<atom *> ListAfter = World::getInstance().getAllAtoms(); 87 pair< set<atom *>::iterator, bool > Inserter; 88 if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed 89 MoleculeListClass *molecules = World::getInstance().getMolecules(); 90 molecule *mol = World::getInstance().createMolecule(); 91 molecules->insert(mol); 92 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) { 93 Inserter = UniqueList.insert(*runner); 94 if (Inserter.second) { // if not present, then new (just parsed) atom, add ... 95 cout << "Adding new atom " << **runner << " to new mol." << endl; 96 mol->AddAtom(*runner); 97 } 98 } 99 mol->doCountAtoms(); 100 } else { 101 cout << "No atoms parsed?" << endl; 102 } 103 } 104 } else { 105 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl); 62 106 } 63 delete dialog;64 return Action:: failure;107 input.close(); 108 return Action::success; 65 109 } 66 110 -
src/Actions/ParserAction/LoadXyzAction.hpp
r06f4ef6 rb6da28 12 12 #include "Actions/Process.hpp" 13 13 14 void ParserLoadXyz(std::string &filename); 15 14 16 class ParserLoadXyzAction : public Action { 17 friend void ParserLoadXyz(std::string &filename); 18 15 19 public: 16 20 ParserLoadXyzAction(); … … 21 25 22 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 23 29 private: 24 30 virtual Action::state_ptr performCall(); -
src/Actions/ParserAction/SaveXyzAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/ParserAction/SaveXyzAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "Parser/XyzParser.hpp" 13 #include "atom.hpp" 14 #include "molecule.hpp" 12 15 13 16 #include <iostream> … … 18 21 #include "UIElements/UIFactory.hpp" 19 22 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"23 #include "UIElements/ValueStorage.hpp" 21 24 22 #include "atom.hpp"23 #include "molecule.hpp"24 25 25 26 /****** ParserSaveXyzAction *****/ … … 46 47 {} 47 48 49 void ParserSaveXyz(std::string &filename) { 50 ValueStorage::getInstance().setCurrentValue(ParserSaveXyzAction::NAME, filename); 51 ActionRegistry::getInstance().getActionByName(ParserSaveXyzAction::NAME)->call(Action::NonInteractive); 52 }; 53 54 Dialog* ParserSaveXyzAction::fillDialog(Dialog *dialog) { 55 ASSERT(dialog,"No Dialog given when filling action dialog"); 56 57 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 58 59 return dialog; 60 } 61 48 62 Action::state_ptr ParserSaveXyzAction::performCall() { 49 63 string filename; 50 64 XyzParser parser; 51 Dialog *dialog = UIFactory::getInstance().makeDialog();52 65 53 dialog->queryString("filename",&filename, "Filename of the xyz file");66 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 54 67 55 if(dialog->display()) { 56 // store xyz file 57 ofstream output; 58 output.open(filename.c_str()); 59 if (!output.fail()) 60 parser.save(&output); 61 output.close(); 62 } 63 delete dialog; 68 // store xyz file 69 ofstream output; 70 output.open(filename.c_str()); 71 if (!output.fail()) 72 parser.save(&output); 73 output.close(); 64 74 return Action::failure; 65 75 } -
src/Actions/ParserAction/SaveXyzAction.hpp
r06f4ef6 rb6da28 12 12 #include "Actions/Process.hpp" 13 13 14 void ParserSaveXyz(std::string &filename); 15 14 16 class ParserSaveXyzAction : public Action { 17 friend void ParserSaveXyz(std::string &filename); 18 15 19 public: 16 20 ParserSaveXyzAction(); … … 21 25 22 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 23 29 private: 24 30 virtual Action::state_ptr performCall(); -
src/Actions/Process.cpp
r06f4ef6 rb6da28 13 13 14 14 Process::Process(int _maxSteps, std::string _name, bool _doRegister) : 15 Action(_name,_doRegister), 15 16 Observable("Process"), 16 Action(_name,_doRegister),17 17 maxSteps(_maxSteps), 18 18 active(false), … … 41 41 42 42 int Process::getCurrStep(){ 43 OBSERVE;44 43 return currStep; 45 44 } 46 45 47 46 void Process::setCurrStep(int _currStep){ 47 OBSERVE; 48 48 currStep = _currStep; 49 49 } … … 55 55 return 0; 56 56 } 57 58 57 int Process::getMaxSteps(){ 59 58 return maxSteps; -
src/Actions/TesselationAction/ConvexEnvelopeAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "boundary.hpp" 13 #include "config.hpp" 14 #include "linkedcell.hpp" 15 #include "log.hpp" 16 #include "molecule.hpp" 17 #include "verbose.hpp" 18 #include "World.hpp" 11 19 12 20 #include <iostream> … … 17 25 #include "UIElements/UIFactory.hpp" 18 26 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "boundary.hpp" 23 #include "config.hpp" 24 #include "linkedcell.hpp" 25 #include "log.hpp" 26 #include "molecule.hpp" 27 #include "verbose.hpp" 28 #include "World.hpp" 27 #include "UIElements/ValueStorage.hpp" 29 28 30 29 /****** TesselationConvexEnvelopeAction *****/ … … 51 50 {} 52 51 52 void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex) { 53 ValueStorage::getInstance().setCurrentValue("convex-file", filenameConvex); 54 ValueStorage::getInstance().setCurrentValue("nonconvex-file", filenameConvex); 55 ActionRegistry::getInstance().getActionByName(TesselationConvexEnvelopeAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* TesselationConvexEnvelopeAction::fillDialog(Dialog *dialog) { 59 ASSERT(dialog,"No Dialog given when filling action dialog"); 60 61 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 dialog->queryString("convex-file", ValueStorage::getInstance().getDescription("convex-file")); 63 dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file")); 64 65 return dialog; 66 } 67 53 68 Action::state_ptr TesselationConvexEnvelopeAction::performCall() { 54 69 string filenameConvex; 55 70 string filenameNonConvex; 56 Dialog *dialog = UIFactory::getInstance().makeDialog();57 71 molecule * mol = NULL; 58 bool Success = false;72 bool Success = true; 59 73 config *configuration = World::getInstance().getConfig(); 60 74 61 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 62 dialog->queryString("convex-file", &filenameConvex, MapOfActions::getInstance().getDescription("convex-file")); 63 dialog->queryString("nonconvex-file", &filenameNonConvex, MapOfActions::getInstance().getDescription("nonconvex-file")); 75 ValueStorage::getInstance().queryCurrentValue("convex-file", filenameConvex); 76 ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filenameNonConvex); 64 77 65 if(dialog->display()) { 78 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 79 mol = iter->second; 66 80 class Tesselation *TesselStruct = NULL; 67 81 const LinkedCell *LCList = NULL; … … 70 84 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl); 71 85 LCList = new LinkedCell(mol, 100.); 72 //FindConvexBorder(mol, LCList, argv[argptr]); 86 Boundaries *BoundaryPoints = NULL; 87 //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); 73 88 // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests 74 89 FindNonConvexBorder(mol, TesselStruct, LCList, 50., filenameNonConvex.c_str()); … … 80 95 delete(TesselStruct); 81 96 delete(LCList); 82 delete dialog;83 if (Success)84 return Action::success;85 else86 return Action::failure;87 97 } 88 delete dialog; 89 return Action::failure; 98 if (Success) 99 return Action::success; 100 else 101 return Action::failure; 90 102 } 91 103 -
src/Actions/TesselationAction/ConvexEnvelopeAction.hpp
r06f4ef6 rb6da28 14 14 class TesselationListClass; 15 15 16 void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex); 17 16 18 class TesselationConvexEnvelopeAction : public Action { 19 friend void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex); 20 17 21 public: 18 22 TesselationConvexEnvelopeAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); … … 31 37 }; 32 38 33 34 39 #endif // CONVEXENVELOPEACTION_HPP -
src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "boundary.hpp" 13 #include "linkedcell.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 11 18 12 19 #include <iostream> … … 17 24 #include "UIElements/UIFactory.hpp" 18 25 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "boundary.hpp" 23 #include "linkedcell.hpp" 24 #include "log.hpp" 25 #include "molecule.hpp" 26 #include "verbose.hpp" 27 #include "World.hpp" 26 #include "UIElements/ValueStorage.hpp" 28 27 29 28 /****** TesselationNonConvexEnvelopeAction *****/ … … 50 49 {} 51 50 51 void TesselationNonConvexEnvelope(double radius, std::string &filename) { 52 ValueStorage::getInstance().setCurrentValue(TesselationNonConvexEnvelopeAction::NAME, radius); 53 ValueStorage::getInstance().setCurrentValue("nonconvex-file", filename); 54 ActionRegistry::getInstance().getActionByName(TesselationNonConvexEnvelopeAction::NAME)->call(Action::NonInteractive); 55 }; 56 57 Dialog* TesselationNonConvexEnvelopeAction::fillDialog(Dialog *dialog) { 58 ASSERT(dialog,"No Dialog given when filling action dialog"); 59 60 dialog->queryDouble(NAME, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryString("nonconvex-file", MapOfActions::getInstance().getDescription("nonconvex-file")); 62 63 return dialog; 64 } 65 52 66 Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() { 53 67 string filename; 54 Dialog *dialog = UIFactory::getInstance().makeDialog();55 68 molecule * Boundary = NULL; 56 69 double SphereRadius = 0; … … 58 71 clock_t start,end; 59 72 60 dialog->queryMolecule(NAME, &Boundary, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryString("nonconvex-file", &filename, MapOfActions::getInstance().getDescription("nonconvex-file")); 62 dialog->queryDouble("sphere-radius", &SphereRadius, MapOfActions::getInstance().getDescription("sphere-radius")); 73 ValueStorage::getInstance().queryCurrentValue(NAME, SphereRadius); 74 ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filename); 63 75 64 if(dialog->display()) { 76 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 77 Boundary = iter->second; 65 78 class Tesselation *T = NULL; 66 79 const LinkedCell *LCList = NULL; … … 76 89 delete(LCList); 77 90 delete(T); 78 delete dialog;79 if (Success)80 return Action::success;81 else82 return Action::failure;83 91 } 84 delete dialog; 85 return Action::failure; 92 if (Success) 93 return Action::success; 94 else 95 return Action::failure; 86 96 } 87 97 -
src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp
r06f4ef6 rb6da28 14 14 class TesselationListClass; 15 15 16 void TesselationNonConvexEnvelope(double radius, std::string &filename); 17 16 18 class TesselationNonConvexEnvelopeAction : public Action { 19 friend void TesselationNonConvexEnvelope(double radius, std::string &filename); 20 17 21 public: 18 22 TesselationNonConvexEnvelopeAction(); … … 23 27 24 28 virtual const std::string getName(); 29 protected: 30 virtual Dialog * fillDialog(Dialog *dialog); 25 31 private: 26 32 virtual Action::state_ptr performCall(); -
src/Actions/Values.hpp
r06f4ef6 rb6da28 19 19 { 20 20 double xx; 21 double xy; 22 double xz; 21 double yx; 23 22 double yy; 24 double yz; 23 double zx; 24 double zy; 25 25 double zz; 26 26 }; -
src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 #include "Helpers/Assert.hpp" 26 27 … … 34 35 {} 35 36 37 void WorldAddEmptyBoundary(Vector &boundary) { 38 ValueStorage::getInstance().setCurrentValue(WorldAddEmptyBoundaryAction::NAME, boundary); 39 ActionRegistry::getInstance().getActionByName(WorldAddEmptyBoundaryAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* WorldAddEmptyBoundaryAction::fillDialog(Dialog *dialog) { 43 ASSERT(dialog,"No Dialog given when filling action dialog"); 44 45 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 46 47 return dialog; 48 } 49 36 50 Action::state_ptr WorldAddEmptyBoundaryAction::performCall() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 51 Vector boundary; 39 52 Vector Min; … … 41 54 int j=0; 42 55 43 dialog->queryVector(NAME, &boundary, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));56 ValueStorage::getInstance().queryCurrentValue(NAME, boundary); 44 57 45 if(dialog->display()) { 46 // get maximum and minimum 47 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 48 ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary."); 49 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 50 Min = (*AtomRunner)->x; 51 Max = (*AtomRunner)->x; 52 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 53 for (int i=0;i<NDIM;i++) { 54 if ((*AtomRunner)->x[i] > Max[i]) 55 Max[i] = (*AtomRunner)->x[i]; 56 if ((*AtomRunner)->x[i] < Min[i]) 57 Min[i] = (*AtomRunner)->x[i]; 58 } 58 // get maximum and minimum 59 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 60 ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary."); 61 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 62 Min = (*AtomRunner)->x; 63 Max = (*AtomRunner)->x; 64 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 65 for (int i=0;i<NDIM;i++) { 66 if ((*AtomRunner)->x[i] > Max[i]) 67 Max[i] = (*AtomRunner)->x[i]; 68 if ((*AtomRunner)->x[i] < Min[i]) 69 Min[i] = (*AtomRunner)->x[i]; 59 70 } 60 // set new box size61 double * const cell_size = World::getInstance().getDomain();62 for (j=0;j<6;j++)63 cell_size[j] = 0.;64 j=-1;65 for (int i=0;i<NDIM;i++) {66 j += i+1;67 cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);68 }69 // translate all atoms, such that Min is aty (0,0,0)70 AtomRunner = AllAtoms.begin();71 for (; AtomRunner != AllAtoms.end(); ++AtomRunner)72 (*AtomRunner)->x -= Min - boundary;73 delete dialog;74 return Action::success;75 } else {76 delete dialog;77 return Action::failure;78 71 } 72 // set new box size 73 double * const cell_size = new double[6]; 74 for (j=0;j<6;j++) 75 cell_size[j] = 0.; 76 j=-1; 77 for (int i=0;i<NDIM;i++) { 78 j += i+1; 79 cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]); 80 } 81 World::getInstance().setDomain(cell_size); 82 delete[] cell_size; 83 // translate all atoms, such that Min is aty (0,0,0) 84 AtomRunner = AllAtoms.begin(); 85 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) 86 (*AtomRunner)->x -= Min - boundary; 87 return Action::success; 79 88 } 80 89 -
src/Actions/WorldAction/AddEmptyBoundaryAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 void WorldAddEmptyBoundary(Vector &boundary); 12 15 13 16 class WorldAddEmptyBoundaryAction : public Action { 17 friend void WorldAddEmptyBoundary(Vector &boundary); 18 14 19 public: 15 20 WorldAddEmptyBoundaryAction(); … … 20 25 21 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 22 29 private: 23 30 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/BoundInBoxAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/BoundInBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "molecule.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include " Actions/MapOfActions.hpp"24 #include "UIElements/ValueStorage.hpp" 24 25 25 26 const char WorldBoundInBoxAction::NAME[] = "bound-in-box"; … … 32 33 {} 33 34 35 void WorldBoundInBox() { 36 ActionRegistry::getInstance().getActionByName(WorldBoundInBoxAction::NAME)->call(Action::NonInteractive); 37 }; 38 39 Dialog* WorldBoundInBoxAction::fillDialog(Dialog *dialog) { 40 ASSERT(dialog,"No Dialog given when filling action dialog"); 41 42 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 43 44 return dialog; 45 } 46 34 47 Action::state_ptr WorldBoundInBoxAction::performCall() { 35 Dialog *dialog = UIFactory::getInstance().makeDialog();36 48 37 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 38 39 if(dialog->display()) { 40 // center 41 vector<molecule*> AllMolecules = World::getInstance().getAllMolecules(); 42 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 43 (*MolRunner)->BoundInBox(); 44 } 45 delete dialog; 46 return Action::success; 47 } else { 48 delete dialog; 49 return Action::failure; 49 // center 50 vector<molecule*> AllMolecules = World::getInstance().getAllMolecules(); 51 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 52 (*MolRunner)->BoundInBox(); 50 53 } 54 return Action::success; 51 55 } 52 56 -
src/Actions/WorldAction/BoundInBoxAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldBoundInBox(); 14 13 15 class WorldBoundInBoxAction : public Action { 16 friend void WorldBoundInBox(); 17 14 18 public: 15 19 WorldBoundInBoxAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/CenterInBoxAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/CenterInBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "Box.hpp" 11 13 #include "log.hpp" 12 14 #include "molecule.hpp" … … 20 22 #include "UIElements/UIFactory.hpp" 21 23 #include "UIElements/Dialog.hpp" 22 #include " Actions/MapOfActions.hpp"24 #include "UIElements/ValueStorage.hpp" 23 25 24 26 const char WorldCenterInBoxAction::NAME[] = "center-in-box"; … … 31 33 {} 32 34 35 void WorldCenterInBox(Box &_box) { 36 ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box); 37 ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive); 38 }; 39 40 Dialog* WorldCenterInBoxAction::fillDialog(Dialog *dialog) { 41 ASSERT(dialog,"No Dialog given when filling action dialog"); 42 43 dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME)); 44 45 return dialog; 46 } 47 33 48 Action::state_ptr WorldCenterInBoxAction::performCall() { 34 Dialog *dialog = UIFactory::getInstance().makeDialog();35 49 36 double * cell_size = World::getInstance().getDomain(); 37 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 50 Box& cell_size = World::getInstance().getDomain(); 51 ValueStorage::getInstance().queryCurrentValue(NAME, cell_size); 52 World::getInstance().setDomain(cell_size.getM()); 38 53 39 if(dialog->display()) { 40 // center 41 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); 42 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 43 (*MolRunner)->CenterInBox(); 44 } 45 delete dialog; 46 return Action::success; 47 } else { 48 delete dialog; 49 return Action::failure; 54 // center 55 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); 56 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 57 (*MolRunner)->CenterInBox(); 50 58 } 59 return Action::success; 51 60 } 52 61 -
src/Actions/WorldAction/CenterInBoxAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Box.hpp" 13 14 void WorldCenterInBox(Box &_box); 12 15 13 16 class WorldCenterInBoxAction : public Action { 17 friend void WorldCenterInBox(Box &_box); 18 14 19 public: 15 20 WorldCenterInBoxAction(); … … 20 25 21 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 22 29 private: 23 30 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/CenterOnEdgeAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/CenterOnEdgeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" 13 14 #include "vector.hpp" 14 15 #include "World.hpp" 16 #include "Matrix.hpp" 15 17 16 18 #include <iostream> … … 21 23 #include "UIElements/UIFactory.hpp" 22 24 #include "UIElements/Dialog.hpp" 23 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 24 26 #include "Helpers/Assert.hpp" 25 27 … … 33 35 {} 34 36 37 void WorldCenterOnEdge() { 38 ActionRegistry::getInstance().getActionByName(WorldCenterOnEdgeAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* WorldCenterOnEdgeAction::fillDialog(Dialog *dialog) { 42 ASSERT(dialog,"No Dialog given when filling action dialog"); 43 44 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 35 49 Action::state_ptr WorldCenterOnEdgeAction::performCall() { 36 Dialog *dialog = UIFactory::getInstance().makeDialog();37 50 Vector Min; 38 51 Vector Max; 39 int j=0;40 52 41 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 53 // get maximum and minimum 54 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 55 ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); 56 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 57 Min = (*AtomRunner)->x; 58 Max = (*AtomRunner)->x; 59 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 60 for (int i=0;i<NDIM;i++) { 61 if ((*AtomRunner)->x[i] > Max[i]) 62 Max[i] = (*AtomRunner)->x[i]; 63 if ((*AtomRunner)->x[i] < Min[i]) 64 Min[i] = (*AtomRunner)->x[i]; 65 } 66 } 67 // set new box size 68 Matrix domain; 69 for (int i=0;i<NDIM;i++) { 70 double tmp = Max[i]-Min[i]; 71 tmp = fabs(tmp)>=1. ? tmp : 1.0; 72 domain.at(i,i) = tmp; 73 } 74 World::getInstance().setDomain(domain); 75 // translate all atoms, such that Min is aty (0,0,0) 76 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) 77 (*AtomRunner)->x -= Min; 42 78 43 if(dialog->display()) { 44 // get maximum and minimum 45 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 46 ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); 47 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 48 Min = (*AtomRunner)->x; 49 Max = (*AtomRunner)->x; 50 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 51 for (int i=0;i<NDIM;i++) { 52 if ((*AtomRunner)->x[i] > Max[i]) 53 Max[i] = (*AtomRunner)->x[i]; 54 if ((*AtomRunner)->x[i] < Min[i]) 55 Min[i] = (*AtomRunner)->x[i]; 56 } 57 } 58 // set new box size 59 double * const cell_size = World::getInstance().getDomain(); 60 for (j=0;j<6;j++) 61 cell_size[j] = 0.; 62 j=-1; 63 for (int i=0;i<NDIM;i++) { 64 j += i+1; 65 cell_size[j] = (Max[i]-Min[i]); 66 } 67 // translate all atoms, such that Min is aty (0,0,0) 68 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) 69 (*AtomRunner)->x -= Min; 70 delete dialog; 71 return Action::success; 72 } else { 73 delete dialog; 74 return Action::failure; 75 } 79 return Action::success; 76 80 } 77 81 -
src/Actions/WorldAction/CenterOnEdgeAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldCenterOnEdge(); 14 13 15 class WorldCenterOnEdgeAction : public Action { 16 friend void WorldCenterOnEdge(); 17 14 18 public: 15 19 WorldCenterOnEdgeAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/ChangeBoxAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/ChangeBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "verbose.hpp" 13 14 #include "World.hpp" 15 #include "Box.hpp" 16 #include "Matrix.hpp" 14 17 15 18 #include <iostream> … … 20 23 #include "UIElements/UIFactory.hpp" 21 24 #include "UIElements/Dialog.hpp" 22 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 23 26 24 27 const char WorldChangeBoxAction::NAME[] = "change-box"; … … 31 34 {} 32 35 36 void WorldChangeBox(Box &_box) { 37 ValueStorage::getInstance().setCurrentValue(WorldChangeBoxAction::NAME, _box); 38 ActionRegistry::getInstance().getActionByName(WorldChangeBoxAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* WorldChangeBoxAction::fillDialog(Dialog *dialog) { 42 ASSERT(dialog,"No Dialog given when filling action dialog"); 43 44 dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 33 49 Action::state_ptr WorldChangeBoxAction::performCall() { 34 Dialog *dialog = UIFactory::getInstance().makeDialog();35 50 36 double * cell_size = World::getInstance().getDomain(); 37 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 51 Box cell_size; 52 ValueStorage::getInstance().queryCurrentValue(NAME, cell_size); 53 World::getInstance().setDomain(cell_size.getM()); // this is needed as only this function is OBSERVEd. 38 54 39 if(dialog->display()) { 40 DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size[0] << "," << cell_size[1] << "," << cell_size[2] << "," << cell_size[3] << "," << cell_size[4] << "," << cell_size[5] << "," << endl); 41 delete dialog; 42 return Action::success; 43 } else { 44 delete dialog; 45 return Action::failure; 46 } 55 DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << World::getInstance().getDomain().getM() << endl); 56 return Action::success; 47 57 } 48 58 -
src/Actions/WorldAction/ChangeBoxAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Box.hpp" 13 14 void WorldChangeBox(Box &_box); 12 15 13 16 class WorldChangeBoxAction : public Action { 17 friend void WorldChangeBox(Box &_box); 18 14 19 public: 15 20 WorldChangeBoxAction(); … … 20 25 21 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 22 29 private: 23 30 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "Descriptors/AtomDescriptor.hpp" 11 13 #include "atom.hpp" 12 #include "Descriptors/AtomDescriptor.hpp"13 14 #include "log.hpp" 14 15 #include "molecule.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char WorldRemoveSphereOfAtomsAction::NAME[] = "remove-sphere"; … … 35 36 {} 36 37 38 void WorldRemoveSphereOfAtoms(double radius, Vector &point) { 39 ValueStorage::getInstance().setCurrentValue(WorldRemoveSphereOfAtomsAction::NAME, radius); 40 ValueStorage::getInstance().setCurrentValue("position", point); 41 ActionRegistry::getInstance().getActionByName(WorldRemoveSphereOfAtomsAction::NAME)->call(Action::NonInteractive); 42 }; 43 44 Dialog* WorldRemoveSphereOfAtomsAction::fillDialog(Dialog *dialog) { 45 ASSERT(dialog,"No Dialog given when filling action dialog"); 46 47 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 48 dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position")); 49 50 return dialog; 51 } 52 37 53 Action::state_ptr WorldRemoveSphereOfAtomsAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 54 double radius = 0.; 40 55 Vector point; 41 56 42 dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME));43 dialog->queryVector("position", &point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));57 ValueStorage::getInstance().queryCurrentValue(NAME, radius); 58 ValueStorage::getInstance().queryCurrentValue("position", point); 44 59 45 if(dialog->display()) { 46 delete dialog; 47 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl); 48 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 49 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 50 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 51 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 52 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 53 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) 54 (*iter)->erase(*AtomRunner); 55 World::getInstance().destroyAtom(*AtomRunner); 56 } 60 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl); 61 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 62 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 63 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 64 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 65 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 66 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) 67 (*iter)->erase(*AtomRunner); 68 World::getInstance().destroyAtom(*AtomRunner); 57 69 } 58 return Action::success;59 } else {60 delete dialog;61 return Action::failure;62 70 } 63 71 return Action::success; 64 72 } 65 73 -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 15 void WorldRemoveSphereOfAtoms(double radius, Vector &point); 12 16 13 17 class WorldRemoveSphereOfAtomsAction : public Action { 18 friend void WorldRemoveSphereOfAtoms(double radius, Vector &point); 19 14 20 public: 15 21 WorldRemoveSphereOfAtomsAction(); … … 20 26 21 27 virtual const std::string getName(); 28 protected: 29 virtual Dialog * fillDialog(Dialog *dialog); 22 30 private: 23 31 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/RepeatBoxAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/RepeatBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" 13 14 #include "molecule.hpp" 14 15 #include "vector.hpp" 16 #include "Matrix.hpp" 15 17 #include "verbose.hpp" 16 18 #include "World.hpp" 19 #include "Box.hpp" 17 20 18 21 #include <iostream> … … 23 26 #include "UIElements/UIFactory.hpp" 24 27 #include "UIElements/Dialog.hpp" 25 #include " Actions/MapOfActions.hpp"28 #include "UIElements/ValueStorage.hpp" 26 29 #include "Descriptors/MoleculeDescriptor.hpp" 27 30 #include "Descriptors/MoleculePtrDescriptor.hpp" … … 36 39 {} 37 40 41 void WorldRepeatBox(Vector &Repeater) { 42 ValueStorage::getInstance().setCurrentValue(WorldRepeatBoxAction::NAME, Repeater); 43 ActionRegistry::getInstance().getActionByName(WorldRepeatBoxAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog * WorldRepeatBoxAction::fillDialog(Dialog *dialog) { 47 ASSERT(dialog,"No Dialog given when filling action dialog"); 48 49 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 50 51 return dialog; 52 } 53 38 54 Action::state_ptr WorldRepeatBoxAction::performCall() { 39 Dialog *dialog = UIFactory::getInstance().makeDialog();40 55 Vector Repeater; 41 56 int count; … … 46 61 MoleculeListClass *molecules = World::getInstance().getMolecules(); 47 62 48 dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));49 //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id")); 63 ValueStorage::getInstance().queryCurrentValue(NAME, Repeater); 64 50 65 vector<molecule *> AllMolecules; 51 66 if (mol != NULL) { … … 57 72 } 58 73 59 if(dialog->display()) { 60 (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl); 61 double * const cell_size = World::getInstance().getDomain(); 62 double *M = ReturnFullMatrixforSymmetric(cell_size); 63 Vector x,y; 64 int n[NDIM]; 65 for (int axis = 0; axis < NDIM; axis++) { 66 Repeater[axis] = floor(Repeater[axis]); 67 if (Repeater[axis] < 1) { 68 DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl); 69 Repeater[axis] = 1; 70 } 71 cell_size[(abs(axis+1) == 2) ? 2 : ((abs(axis+2) == 3) ? 5 : 0)] *= 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; 72 85 } 86 repMat.at(axis,axis) = Repeater[axis]; 87 } 88 newM *= repMat; 89 World::getInstance().setDomain(newM); 73 90 74 molecule *newmol = NULL; 75 Vector ** vectors = NULL; 76 for (n[0] = 0; n[0] < Repeater[0]; n[0]++) { 77 y[0] = n[0]; 78 for (n[1] = 0; n[1] < Repeater[1]; n[1]++) { 79 y[1] = n[1]; 80 for (n[2] = 0; n[2] < Repeater[2]; n[2]++) { 81 y[2] = n[2]; 82 if (n[0] == n[1] == n[2] == 0) 83 continue; 84 for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 85 mol = *MolRunner; 86 DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl); 87 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 88 if (count != 0) { // if there is more than none 89 Elements = new const element *[count]; 90 vectors = new Vector *[count]; 91 j = 0; 92 for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) { 93 Elements[j] = (*AtomRunner)->type; 94 vectors[j] = &(*AtomRunner)->x; 95 j++; 96 } 97 if (count != j) 98 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 99 x = y; 100 x.MatrixMultiplication(M); 101 newmol = World::getInstance().createMolecule(); 102 molecules->insert(newmol); 103 for (int k=count;k--;) { // go through every atom of the original cell 104 Walker = World::getInstance().createAtom(); // create a new body 105 Walker->x = (*vectors[k]) + x; 106 Walker->type = Elements[k]; // insert original element 107 cout << "new atom is " << *Walker << endl; 108 newmol->AddAtom(Walker); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 109 } 110 // free memory 111 delete[](Elements); 112 delete[](vectors); 113 } else { 114 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++; 115 113 } 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); 116 132 } 117 133 } 118 134 } 119 135 } 120 delete(M);121 delete dialog;122 return Action::success;123 } else {124 delete dialog;125 return Action::failure;126 136 } 137 return Action::success; 127 138 } 128 139 -
src/Actions/WorldAction/RepeatBoxAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 void WorldRepeatBox(Vector &Repeater); 12 15 13 16 class WorldRepeatBoxAction : public Action { 17 friend void WorldRepeatBox(Vector &Repeater); 18 14 19 public: 15 20 WorldRepeatBoxAction(); … … 20 25 21 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 22 29 private: 23 30 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/ScaleBoxAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/ScaleBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" … … 14 15 #include "verbose.hpp" 15 16 #include "World.hpp" 17 #include "Box.hpp" 18 #include "Matrix.hpp" 16 19 17 20 #include <iostream> … … 22 25 #include "UIElements/UIFactory.hpp" 23 26 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 25 28 26 29 const char WorldScaleBoxAction::NAME[] = "scale-box"; … … 33 36 {} 34 37 38 void WorldScaleBox(Vector &Scaler) { 39 ValueStorage::getInstance().setCurrentValue(WorldScaleBoxAction::NAME, Scaler); 40 ActionRegistry::getInstance().getActionByName(WorldScaleBoxAction::NAME)->call(Action::NonInteractive); 41 }; 42 43 Dialog* WorldScaleBoxAction::fillDialog(Dialog *dialog) { 44 ASSERT(dialog,"No Dialog given when filling action dialog"); 45 46 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 47 48 return dialog; 49 } 50 35 51 Action::state_ptr WorldScaleBoxAction::performCall() { 36 Dialog *dialog = UIFactory::getInstance().makeDialog();37 52 Vector Scaler; 38 53 double x[NDIM]; 39 int j=0;40 54 41 dialog->queryVector(NAME, &Scaler, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));55 ValueStorage::getInstance().queryCurrentValue(NAME, Scaler); 42 56 43 if(dialog->display()) { 44 DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl); 45 for (int i=0;i<NDIM;i++) 46 x[i] = Scaler[i]; 47 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 48 for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 49 (*AtomRunner)->x.ScaleAll(x); 50 } 51 j = -1; 52 double * const cell_size = World::getInstance().getDomain(); 53 for (int i=0;i<NDIM;i++) { 54 j += i+1; 55 cell_size[j]*=x[i]; 56 } 57 DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl); 58 for (int i=0;i<NDIM;i++) 59 x[i] = Scaler[i]; 60 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 61 for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 62 (*AtomRunner)->x.ScaleAll(x); 63 } 57 64 58 delete dialog;59 return Action::success;60 } else { 61 delete dialog;62 return Action::failure;65 Matrix M = World::getInstance().getDomain().getM(); 66 Matrix scale; 67 68 for (int i=0;i<NDIM;i++) { 69 scale.at(i,i) = x[i]; 63 70 } 71 M *= scale; 72 World::getInstance().setDomain(M); 73 74 return Action::success; 64 75 } 65 76 -
src/Actions/WorldAction/ScaleBoxAction.hpp
r06f4ef6 rb6da28 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 void WorldScaleBox(Vector &Scaler); 12 15 13 16 class WorldScaleBoxAction : public Action { 17 friend void WorldScaleBox(Vector &Scaler); 18 14 19 public: 15 20 WorldScaleBoxAction(); … … 20 25 21 26 virtual const std::string getName(); 27 protected: 28 virtual Dialog * fillDialog(Dialog *dialog); 22 29 private: 23 30 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/SetDefaultNameAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/SetDefaultNameAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "verbose.hpp" … … 20 21 #include "UIElements/UIFactory.hpp" 21 22 #include "UIElements/Dialog.hpp" 22 #include "Actions/MapOfActions.hpp" 23 #include "UIElements/ValueStorage.hpp" 24 25 26 // memento to remember the state when undoing 27 28 class WorldSetDefaultNameState : public ActionState { 29 public: 30 WorldSetDefaultNameState(std::string _lastName) : 31 lastName(_lastName) 32 {} 33 std::string lastName; 34 }; 23 35 24 36 const char WorldSetDefaultNameAction::NAME[] = "default-molname"; … … 31 43 {} 32 44 45 void WorldSetDefaultName(std::string &defaultname) { 46 ValueStorage::getInstance().setCurrentValue(WorldSetDefaultNameAction::NAME, defaultname); 47 ActionRegistry::getInstance().getActionByName(WorldSetDefaultNameAction::NAME)->call(Action::NonInteractive); 48 }; 49 50 Dialog* WorldSetDefaultNameAction::fillDialog(Dialog *dialog) { 51 ASSERT(dialog,"No Dialog given when filling action dialog"); 52 53 string defaultname = World::getInstance().getDefaultName(); 54 ValueStorage::getInstance().setCurrentValue(NAME, defaultname); 55 dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME)); 56 57 return dialog; 58 } 59 33 60 Action::state_ptr WorldSetDefaultNameAction::performCall() { 34 Dialog *dialog = UIFactory::getInstance().makeDialog();35 61 string defaultname; 36 62 37 63 defaultname = World::getInstance().getDefaultName(); 38 dialog->queryString(NAME, &defaultname, MapOfActions::getInstance().getDescription(NAME));64 ValueStorage::getInstance().queryCurrentValue(NAME, defaultname); 39 65 40 if(dialog->display()) { 41 World::getInstance().setDefaultName(defaultname); 42 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl); 43 delete dialog; 44 return Action::success; 45 } else { 46 delete dialog; 47 return Action::failure; 48 } 66 World::getInstance().setDefaultName(defaultname); 67 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl); 68 return Action::success; 49 69 } 50 70 51 71 Action::state_ptr WorldSetDefaultNameAction::performUndo(Action::state_ptr _state) { 52 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());72 WorldSetDefaultNameState *state = assert_cast<WorldSetDefaultNameState*>(_state.get()); 53 73 54 return Action::failure; 55 // string newName = state->mol->getName(); 56 // state->mol->setName(state->lastName); 57 // 58 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 74 string newName = World::getInstance().getDefaultName(); 75 World::getInstance().setDefaultName(state->lastName); 76 77 return Action::state_ptr(new WorldSetDefaultNameState(newName)); 59 78 } 60 79 61 80 Action::state_ptr WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){ 62 return Action::failure;81 return performUndo(_state); 63 82 } 64 83 65 84 bool WorldSetDefaultNameAction::canUndo() { 66 return false;85 return true; 67 86 } 68 87 69 88 bool WorldSetDefaultNameAction::shouldUndo() { 70 return false;89 return true; 71 90 } 72 91 -
src/Actions/WorldAction/SetDefaultNameAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldSetDefaultName(std::string &defaultname); 14 13 15 class WorldSetDefaultNameAction : public Action { 16 friend void WorldSetDefaultName(std::string &defaultname); 17 14 18 public: 15 19 WorldSetDefaultNameAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/Actions/WorldAction/SetGaussianBasisAction.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "Actions/WorldAction/SetGaussianBasisAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include "Actions/MapOfActions.hpp" 24 #include "UIElements/ValueStorage.hpp" 25 26 27 // memento to remember the state when undoing 28 29 class WorldSetGaussianBasisState : public ActionState { 30 public: 31 WorldSetGaussianBasisState(std::string _lastName) : 32 lastName(_lastName) 33 {} 34 std::string lastName; 35 }; 36 24 37 25 38 const char WorldSetGaussianBasisAction::NAME[] = "set-basis"; … … 32 45 {} 33 46 47 void WorldSetGaussianBasis(std::string &basisname) { 48 ValueStorage::getInstance().setCurrentValue(WorldSetGaussianBasisAction::NAME, basisname); 49 ActionRegistry::getInstance().getActionByName(WorldSetGaussianBasisAction::NAME)->call(Action::NonInteractive); 50 }; 51 52 Dialog* WorldSetGaussianBasisAction::fillDialog(Dialog *dialog) { 53 ASSERT(dialog,"No Dialog given when filling action dialog"); 54 55 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 56 57 return dialog; 58 } 59 34 60 Action::state_ptr WorldSetGaussianBasisAction::performCall() { 35 Dialog *dialog = UIFactory::getInstance().makeDialog();36 61 config *configuration = World::getInstance().getConfig(); 37 dialog->queryString(NAME, &(configuration->basis), MapOfActions::getInstance().getDescription(NAME));38 62 39 if(dialog->display()) { 40 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl); 41 delete dialog; 42 return Action::success; 43 } else { 44 delete dialog; 45 return Action::failure; 46 } 63 string lastname = configuration->basis; 64 ValueStorage::getInstance().queryCurrentValue(NAME, configuration->basis); 65 66 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl); 67 return Action::success; 47 68 } 48 69 49 70 Action::state_ptr WorldSetGaussianBasisAction::performUndo(Action::state_ptr _state) { 50 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());71 WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get()); 51 72 52 return Action::failure;53 // string newName = state->mol->getName();54 // state->mol->setName(state->lastName);55 // 56 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));73 config *configuration = World::getInstance().getConfig(); 74 string newName = configuration->basis; 75 configuration->basis = state->lastName; 76 77 return Action::state_ptr(new WorldSetGaussianBasisState(newName)); 57 78 } 58 79 59 80 Action::state_ptr WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){ 60 return Action::failure;81 return performUndo(_state); 61 82 } 62 83 63 84 bool WorldSetGaussianBasisAction::canUndo() { 64 return false;85 return true; 65 86 } 66 87 67 88 bool WorldSetGaussianBasisAction::shouldUndo() { 68 return false;89 return true; 69 90 } 70 91 -
src/Actions/WorldAction/SetGaussianBasisAction.hpp
r06f4ef6 rb6da28 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldSetGaussianBasis(std::string &basisname); 14 13 15 class WorldSetGaussianBasisAction : public Action { 16 friend void WorldSetGaussianBasis(std::string &basisname); 17 14 18 public: 15 19 WorldSetGaussianBasisAction(); … … 20 24 21 25 virtual const std::string getName(); 26 protected: 27 virtual Dialog * fillDialog(Dialog *dialog); 22 28 private: 23 29 virtual Action::state_ptr performCall(); -
src/CommandLineParser.cpp
r06f4ef6 rb6da28 41 41 void CommandLineParser::Parse() 42 42 { 43 po::store(po::command_line_parser(argc,argv).options(cmdline_options). options(visible).positional(inputfile).run(), vm);43 po::store(po::command_line_parser(argc,argv).options(cmdline_options).run(), vm); 44 44 ifstream input; 45 45 input.open("example.cfg"); -
src/CommandLineParser.hpp
r06f4ef6 rb6da28 17 17 #include <list> 18 18 19 /** This class is a wrapper for boost::program_options. 20 * 21 * <h1> CommandLine Howto </h1> 22 * <h2> Introduction </h2> 23 * 24 * The UIFactory is a base class for the User Interaction. There are three UI specializations: 25 * Text, GUI and CommandLine. Accessing functionality via the CommandLine UI is explained here. 26 * 27 * First, an Action has to be written for the specific functionality. This Action should 28 * be added in Actions/...Action in the respective subdirectory of the following types: 29 * -# Analysis: Analysis actions like evaluating pair correlation, bonds, ... 30 * -# Atom: adding, removing, manipulating atoms 31 * -# Cmd: specifying data bases, verbosity, ... 32 * -# Fragmentation: fragmenting a system, performing graph analysis, ... 33 * -# Molecule: adding, removing, manipulating molecules 34 * -# Parser: Parsing files (loading, saving) 35 * -# Tesselation: obtaining (non)convex surface of a molecule, embedding, ... 36 * -# World: Setting Box dimensions, default name of new molecules, ... 37 * 38 * The CommandLineUIFactory is a specialization of the UIFactory for parsing command 39 * line parameters, generating and executing actions there from. 40 * 41 * The idea of the CommandLineFactory is explained elsewhere, here we would like to give a 42 * receipe for creating new actions. 43 * 44 * <h3>Introducing new actions</h3> 45 * 46 * Let us now introduce what to do if a new action is to be implemented. Here, we use the 47 * CommandLineVersionAction as an example. 48 * This consists if basically three parts: 49 * 1. Create the files, write the classes and make them compilable 50 * - Create new source and header files in one of the above subfolders in the Actions folder, 51 * e.g. create VersionAction.cpp and VersionAction.hpp in Actions/Cmd/ 52 * - Give it a sensible class name, the convention is <type><what it does>Action, 53 * where <type> is basically the naming (written out) of the subdirectory, 54 * e.g. class CommandLineVersionAction. 55 * - Add the source and header file to the respective variables in molecuilder/src/Makefile.am, 56 * e.g. if you add a Cmd action the variables are CMDACTIONSOURCE and CMDACTIONHEADER, 57 * such that they get compiled. 58 * 2. Add an instance to the CommandLineUIFactory, such that they are known to the UI. 59 * - Add the header file as an include to UIElements/CommandLineWindow.cpp, e.g. 60 * #include "Actions/Cmd/VersionAction.hpp" 61 * - Add an instance of your class to the specific populater-function in 62 * UIElements/CommandLineWindow.cpp, e.g. for the above Cmd action, add to populateCmdActions() 63 * add new CommandLineVersionAction(). 64 * This will automatically register in the ActionRegistry. 65 * 3. Give them an option name, short hand an description, such that they can be referenced from 66 * the command line. 67 * - think of a new key name, e.g. "version", which is the long form of the command parameter, 68 * i.e. --version). 69 * - add this key to every map of MapofActions, i.e. to 70 * - MapofActions::DescriptionMap: the description which appears as help and tooltip 71 * - MapofActions::ShortFormMap: the short form of the command parameter (e.g. -v) 72 * - MapofActions::ValueMap: the value the command parameter has (do not create if it does not need one) 73 * - If your action requires additional parameters, these need to be added in the same manner as in 74 * the list item above. 75 * 76 * Don't forget to write the actual code. :) 77 * 78 * <h3>Writing an action</h3> 79 * 80 * As you write a new action you may think in terms of the command line, i.e. you want to use this 81 * new functionality you add by calling molecuilder as: ./molecuilder --super-action foobar.txt, where 82 * the key of your new action would be "super-action". While this is fine, keep in mind, that your action 83 * should be useable for the other UI specializations as well, i.e. from the menu and the GUI. Therefore, 84 * -# Don't use cin to ask the user for input: Use Query...()! 85 * -# Rather don't use cout/cerrs, but either give Log() or eLog() or use QueryEmpty() if you want to give 86 * the user specific information what you ask of him. 87 * 88 */ 19 89 class CommandLineParser : public Singleton<CommandLineParser> { 20 90 friend class Singleton<CommandLineParser>; -
src/Descriptors/AtomDescriptor.cpp
r06f4ef6 rb6da28 12 12 13 13 #include "World.hpp" 14 15 14 #include "atom.hpp" 15 #include "Patterns/ObservedContainer_impl.hpp" 16 16 17 17 #include <boost/bind.hpp> 18 #include <cassert> 18 19 19 #include <iostream> 20 20 21 21 using namespace std; 22 22 23 typedef World::AtomSet::i terator atoms_iter_t;23 typedef World::AtomSet::internal_iterator atoms_iter_t; 24 24 25 25 /************************ Forwarding object **************************************/ … … 74 74 75 75 atom* AtomDescriptor_impl::find() { 76 World::AtomSet atoms = getAtoms();77 atoms_iter_t res = find_if(atoms.begin (),atoms.end(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));78 return (res!=atoms.end ())?((*res).second):0;76 World::AtomSet &atoms = getAtoms(); 77 atoms_iter_t res = find_if(atoms.begin_internal(),atoms.end_internal(),boost::bind(&AtomDescriptor_impl::predicate,this,_1)); 78 return (res!=atoms.end_internal())?((*res).second):0; 79 79 } 80 80 … … 82 82 vector<atom*> res; 83 83 World::AtomSet atoms = getAtoms(); 84 atoms_iter_t iter; 85 for(iter=atoms.begin();iter!=atoms.end();++iter) { 86 if(predicate(*iter)){ 87 res.push_back((*iter).second); 88 } 84 for_each(atoms.begin_internal(), 85 atoms.end_internal(), 86 boost::bind(&AtomDescriptor_impl::checkAndAdd, 87 this,&res,_1)); 88 return res; 89 } 90 91 void AtomDescriptor_impl::checkAndAdd(std::vector<atom*> *v,std::pair<atomId_t,atom*> p){ 92 if(predicate(p)){ 93 v->push_back(p.second); 89 94 } 90 return res;91 95 } 92 96 -
src/Descriptors/AtomDescriptor.hpp
r06f4ef6 rb6da28 35 35 // close coupling to the world to allow access 36 36 friend atom* World::getAtom(AtomDescriptor descriptor); 37 friend std::vector<atom*>World::getAllAtoms(AtomDescriptor descriptor);37 friend World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor); 38 38 template <class,class,class> friend class SelectiveIterator; 39 39 -
src/Descriptors/AtomDescriptor_impl.hpp
r06f4ef6 rb6da28 50 50 */ 51 51 World::AtomSet& getAtoms(); 52 53 void checkAndAdd(std::vector<atom*>*,std::pair<atomId_t,atom*>); 52 54 }; 53 55 -
src/Descriptors/AtomIdDescriptor.cpp
r06f4ef6 rb6da28 12 12 13 13 #include "atom.hpp" 14 #include "Patterns/ObservedContainer_impl.hpp" 14 15 15 16 using namespace std; … … 32 33 33 34 atom *AtomIdDescriptor_impl::find(){ 34 World::AtomSet atoms = getAtoms();35 World::AtomSet &atoms = getAtoms(); 35 36 World::AtomSet::iterator res = atoms.find(id); 36 37 return (res!=atoms.end())?((*res).second):0; -
src/Descriptors/MoleculeDescriptor.cpp
r06f4ef6 rb6da28 12 12 13 13 #include "World.hpp" 14 #include "Patterns/ObservedContainer_impl.hpp" 14 15 15 16 #include "molecule.hpp" 16 17 17 18 #include <boost/bind.hpp> 18 #include <cassert>19 19 #include <iostream> 20 20 21 21 using namespace std; 22 22 23 typedef World::MoleculeSet::i terator molecules_iter_t;23 typedef World::MoleculeSet::internal_iterator molecules_iter_t; 24 24 25 25 /************************ Forwarding object **************************************/ … … 74 74 75 75 molecule* MoleculeDescriptor_impl::find() { 76 World::MoleculeSet molecules = getMolecules();77 molecules_iter_t res = find_if(molecules.begin (),molecules.end(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));78 return (res!=molecules.end ())?((*res).second):0;76 World::MoleculeSet &molecules = getMolecules(); 77 molecules_iter_t res = find_if(molecules.begin_internal(),molecules.end_internal(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1)); 78 return (res!=molecules.end_internal())?((*res).second):0; 79 79 } 80 80 81 81 vector<molecule*> MoleculeDescriptor_impl::findAll() { 82 82 vector<molecule*> res; 83 World::MoleculeSet molecules = getMolecules(); 84 molecules_iter_t iter; 85 for(iter=molecules.begin();iter!=molecules.end();++iter) { 86 if(predicate(*iter)){ 87 res.push_back((*iter).second); 88 } 83 World::MoleculeSet &molecules = getMolecules(); 84 for_each(molecules.begin_internal(), 85 molecules.end_internal(), 86 boost::bind(&MoleculeDescriptor_impl::checkAndAdd, 87 this,&res,_1)); 88 return res; 89 } 90 91 void MoleculeDescriptor_impl::checkAndAdd(std::vector<molecule*> *v,std::pair<moleculeId_t,molecule*> p){ 92 if(predicate(p)){ 93 v->push_back(p.second); 89 94 } 90 return res;91 95 } 92 96 -
src/Descriptors/MoleculeDescriptor_impl.hpp
r06f4ef6 rb6da28 50 50 */ 51 51 World::MoleculeSet& getMolecules(); 52 53 void checkAndAdd(std::vector<molecule*>*,std::pair<moleculeId_t,molecule*>); 52 54 }; 53 55 -
src/Descriptors/MoleculeIdDescriptor.cpp
r06f4ef6 rb6da28 10 10 #include "MoleculeIdDescriptor.hpp" 11 11 #include "MoleculeIdDescriptor_impl.hpp" 12 13 #include "Patterns/ObservedContainer_impl.hpp" 12 14 13 15 #include "molecule.hpp" … … 32 34 33 35 molecule *MoleculeIdDescriptor_impl::find(){ 34 World::MoleculeSet molecules = getMolecules();36 World::MoleculeSet &molecules = getMolecules(); 35 37 World::MoleculeSet::iterator res = molecules.find(id); 36 38 return (res!=molecules.end())?((*res).second):0; -
src/Descriptors/MoleculeNameDescriptor.cpp
r06f4ef6 rb6da28 30 30 31 31 molecule *MoleculeNameDescriptor_impl::find(){ 32 World::MoleculeSet molecules = getMolecules();32 World::MoleculeSet &molecules = getMolecules(); 33 33 World::MoleculeSet::iterator res = molecules.begin(); 34 34 for (; res != molecules.end(); res++) -
src/Descriptors/MoleculePtrDescriptor.cpp
r06f4ef6 rb6da28 10 10 #include "MoleculePtrDescriptor.hpp" 11 11 #include "MoleculePtrDescriptor_impl.hpp" 12 13 #include "Patterns/ObservedContainer_impl.hpp" 12 14 13 15 #include "molecule.hpp" … … 32 34 33 35 molecule *MoleculePtrDescriptor_impl::find(){ 34 World::MoleculeSet molecules = getMolecules();36 World::MoleculeSet &molecules = getMolecules(); 35 37 World::MoleculeSet::iterator res = molecules.find(ptr->getId()); 36 38 return (res!=molecules.end())?((*res).second):0; -
src/Exceptions/CustomException.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "CustomException.hpp" 11 #include <iostream> 11 12 12 13 using namespace std; -
src/Exceptions/CustomException.hpp
r06f4ef6 rb6da28 10 10 11 11 #include <exception> 12 #include <iostream> 12 #include <iosfwd> 13 #include <string> 13 14 14 15 /** -
src/Hbondangle.db
r06f4ef6 rb6da28 1 # atomicnumber angles for single, double and triple bond (-1 no angle) 1 2 1 180 -1 -1 2 3 5 180 131.0 109.2 -
src/Hbonddistance.db
r06f4ef6 rb6da28 1 #atomic number bond distances for single, double and triple bond (-1 no bond) 1 2 1 0.74 -1 -1 2 3 2 0.77429209 -1 -1 -
src/Helpers/Assert.cpp
r06f4ef6 rb6da28 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp"9 7 10 8 #include "Helpers/Assert.hpp" … … 46 44 } 47 45 48 using namespace Assert;49 50 46 #ifndef NDEBUG 51 47 52 Action _my_assert::defaultAction = Ask; 53 std::vector<Assert::hook_t> _my_assert::hooks; 48 #ifdef __GNUC__ 49 #include <cstdlib> 50 #include <execinfo.h> 51 #include <cxxabi.h> 52 #endif 54 53 55 std::map<std::string,bool> _wrapper::ignores; 56 const char* _wrapper::message_ptr = "source pointer did not point to object of desired type"; 57 const char* _wrapper::message_ref = "source reference did not contain object of desired type"; 54 Assert::Action Assert::_my_assert::defaultAction = Ask; 55 std::vector<Assert::hook_t> Assert::_my_assert::hooks; 58 56 57 std::map<std::string,bool> Assert::_wrapper::ignores; 58 const char* Assert::_wrapper::message_ptr = "source pointer did not point to object of desired type"; 59 const char* Assert::_wrapper::message_ref = "source reference did not contain object of desired type"; 59 60 60 bool _my_assert::check(const bool res, 61 const char* condition, 62 const char* message, 63 const char* filename, 64 const int line, 65 bool& ignore) 61 bool Assert::_my_assert::check(const char* condition, 62 const char* message, 63 const char* filename, 64 const int line, 65 bool& ignore) 66 66 { 67 if(!res){ 68 cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl; 69 cout << "Assertion Message: " << message << std::endl; 70 while(true){ 71 char choice; 72 if(defaultAction==Ask) { 73 cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl; 74 cin >> choice; 75 } 76 else{ 77 choice = ActionKeys[defaultAction]; 78 } 79 switch(choice){ 80 case 'a': 81 return true; 82 break; 83 case 't': 84 throw AssertionFailure(condition,filename,line,message); 85 break; 86 case 'w': 87 ignore = true; 88 // fallthrough 89 case 'i': 90 return false; 91 break; 92 } 67 cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl; 68 cout << "Assertion Message: " << message << std::endl; 69 while(true){ 70 char choice; 71 if(defaultAction==Assert::Ask) { 72 #ifdef __GNUC__ 73 cout << "Please choose: (a)bort, (t)hrow execption, show (b)actrace, (i)gnore, al(w)ays ignore" << endl; 74 #else 75 cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl; 76 #endif /* __GNUC__ */ 77 cin >> choice; 78 } 79 else{ 80 choice = ActionKeys[defaultAction]; 81 } 82 switch(choice){ 83 case 'a': 84 return true; 85 break; 86 case 't': 87 throw AssertionFailure(condition,filename,line,message); 88 break; 89 #ifdef __GNUC__ 90 case 'b': 91 Assert::_my_assert::backtrace(filename,line); 92 break; 93 #endif /* __GNUC__ */ 94 case 'w': 95 ignore = true; 96 // fallthrough 97 case 'i': 98 return false; 99 break; 93 100 } 94 101 } … … 96 103 } 97 104 98 void _my_assert::doHooks(){ 105 #ifdef __GNUC__ 106 void Assert::_my_assert::backtrace(const char *file, int line){ 107 const size_t max_depth = 100; 108 void* stack_addrs[max_depth]; 109 size_t stack_depth; 110 char **stack_strings=0; 111 const char *func_name=0; 112 size_t sz = 64; 113 114 // get the backtrace 115 stack_depth = ::backtrace(stack_addrs,max_depth); 116 stack_strings = backtrace_symbols(stack_addrs, stack_depth); 117 // used later for demangling 118 // reserved here, so we can free it unconditionally 119 char *dm_function = static_cast<char*>(malloc(sz)); 120 if(!dm_function){ 121 // malloc failed... we are out of luck 122 cout << "cannot provide stack trace due to exhausted memory" << endl; 123 return; 124 } 125 126 cout << "Backtrace from " << file << "@" << line << ":" << endl; 127 128 // i=2 because we don't want this function, nor the assertion handler 129 for(unsigned int i=2;i<stack_depth-2;++i){ 130 // find the mangled function name 131 char *begin = stack_strings[i]; 132 // function name starts with a ( 133 while(*begin && *begin!='(') ++begin; 134 char *end=begin; 135 while(*end && *end!='+') ++end; 136 137 // see if we found our function name 138 if(*begin && *end){ 139 *begin++ = 0; 140 *end = 0; 141 // use the C++ demangler 142 143 int status; 144 char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status); 145 if(func_ret){ 146 // abi might have realloced... 147 dm_function = func_ret; 148 func_name = dm_function; 149 } 150 else{ 151 // demangling failed... get the function name without demangling 152 func_name = begin; 153 } 154 } 155 else{ 156 // function name not found... get the whole line 157 func_name = stack_strings[i]; 158 } 159 cout << func_name << endl; 160 } 161 free(dm_function); 162 free(stack_strings); // malloc()ed by backtrace_symbols 163 } 164 #endif /* __GNUC__ */ 165 166 void Assert::_my_assert::doHooks(){ 99 167 for(vector<hook_t>::reverse_iterator iter = hooks.rbegin(); iter!=hooks.rend(); ++iter ){ 100 168 (*iter)(); … … 102 170 } 103 171 104 void _my_assert::addHook(hook_t hook){172 void Assert::_my_assert::addHook(hook_t hook){ 105 173 hooks.push_back(hook); 106 174 } 107 175 108 void _my_assert::removeHook(Assert::hook_t hook){176 void Assert::_my_assert::removeHook(Assert::hook_t hook){ 109 177 for(vector<hook_t>::iterator iter = hooks.begin(); iter!=hooks.end();){ 110 178 if((*iter)==hook){ … … 117 185 } 118 186 119 void _my_assert::setDefault(Assert::Action action){187 void Assert::_my_assert::setDefault(Assert::Action action){ 120 188 defaultAction = action; 121 189 } 122 Assert::Action _my_assert::getDefault(){190 Assert::Action Assert::_my_assert::getDefault(){ 123 191 return defaultAction; 124 192 } 125 std::string _my_assert::printDefault(){193 std::string Assert::_my_assert::printDefault(){ 126 194 return ActionNames[defaultAction]; 127 195 } -
src/Helpers/Assert.hpp
r06f4ef6 rb6da28 11 11 #include<sstream> 12 12 #include<string> 13 #include<ios tream>13 #include<iosfwd> 14 14 #include<vector> 15 15 #include<map> … … 234 234 static bool ignore = false;\ 235 235 if(!ignore){\ 236 if( Assert::_my_assert::check((condition),STRINGIFY(condition),(message),\237 __FILE__,__LINE__,ignore)){\236 if(!(condition) && Assert::_my_assert::check(STRINGIFY(condition),(message),\ 237 __FILE__,__LINE__,ignore)){\ 238 238 Assert::_my_assert::doHooks();\ 239 239 DEBUG_BREAK;\ … … 247 247 static bool ignore = false; \ 248 248 if(!ignore){\ 249 if(Assert::_my_assert::check( false,"Exception caught",(message),__FILE__,__LINE__,ignore)){\249 if(Assert::_my_assert::check("Exception caught",(message),__FILE__,__LINE__,ignore)){\ 250 250 Assert::_my_assert::doHooks();\ 251 DEBUG_BREAK;\251 DEBUG_BREAK;\ 252 252 }\ 253 253 }\ … … 299 299 class _my_assert{ 300 300 public: 301 static bool check(const bool res, 302 const char* condition, 301 static bool check(const char* condition, 303 302 const char* message, 304 303 const char* filename, 305 304 const int line, 306 305 bool& ignore); 306 #ifdef __GNUC__ 307 static void backtrace(const char *file, int line); 308 #endif /* __GNUC__ */ 307 309 static void addHook(Assert::hook_t hook); 308 310 static void removeHook(Assert::hook_t hook); … … 332 334 333 335 if(!ignore){ 334 if(_my_assert::check(dynamic_cast<target>(src)==static_cast<target>(src),"type-safe typecast",335 336 bool res = dynamic_cast<target>(src)==static_cast<target>(src); 337 if(!res && _my_assert::check("type-safe typecast",message_ptr,file,line,ignore)){ 336 338 _my_assert::doHooks(); 337 339 DEBUG_BREAK; … … 354 356 catch(...){ 355 357 if(!ignore){ 356 if(_my_assert::check( 0,"type-safe typecast",message_ref,file,line,ignore)){358 if(_my_assert::check("type-safe typecast",message_ref,file,line,ignore)){ 357 359 _my_assert::doHooks(); 358 360 DEBUG_BREAK; -
src/Helpers/MemDebug.cpp
r06f4ef6 rb6da28 6 6 */ 7 7 8 #ifndef NDBEGUG 9 #ifndef NO_MEMDEBUG 8 // NDEBUG implies NO_MEMDEBUG 9 #ifdef NDEBUG 10 # ifndef NO_MEMDEBUG 11 # define NO_MEMDEBUG 12 # endif 13 #endif 14 15 // NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set 16 #ifdef NO_MEMDEBUG 17 # ifdef MEMDEBUG 18 # undef MEMDEBUG 19 # endif 20 #else 21 # ifndef MEMDEBUG 22 # define MEMDEBUG 23 # endif 24 #endif 25 26 #ifdef MEMDEBUG 10 27 11 28 #include <iostream> … … 55 72 // all allocated memory blocks 56 73 struct entry_t { 74 typedef unsigned int checksum_t; 57 75 // we seperate the tracking info from the rest 58 76 // A checksum will be calculated for this part of … … 73 91 } info; 74 92 bool isIgnored; 75 ch archecksum;93 checksum_t checksum; 76 94 entry_t *prev; 77 95 entry_t *next; … … 100 118 // calculates a simple checksum for the info block 101 119 // the checksum is used to find memory corruptions 102 inline charcalcChecksum(entry_t::info_t *info){120 inline entry_t::checksum_t calcChecksum(entry_t::info_t *info){ 103 121 char *buffer = (char*)info; 104 charchecksum =0;122 entry_t::checksum_t checksum =0; 105 123 for(size_t i=0;i<sizeof(entry_t::info_t);i++){ 106 124 checksum+=buffer[i]; … … 137 155 cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl; 138 156 #endif 157 } 158 } 159 160 void dumpMemory(std::ostream &ost){ 161 ost << "Maximum allocated Memory: " << max << " bytes" << endl; 162 ost << "Maximum allocated Memory: " << max << " bytes" << endl; 163 ost << "Currently allocated Memory: " << state <<" bytes" << endl; 164 ost << allocs << " allocated chunks total" << endl; 165 bool corrupted=false; 166 for(entry_t *pos=begin;pos;pos=pos->next){ 167 ost << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl; 168 # ifdef __GNUC__ 169 ost << "Chunk reserved at: " << pos->info.function 170 << " (" << pos->info.file << ":" << pos->info.line << ")" << endl; 171 # else 172 ost << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl; 173 # endif 174 ost << "Chunk address: " << pos->info.location << endl; 175 entry_t::checksum_t checksum = calcChecksum(&pos->info); 176 ost << "Checksum of chunk: " << checksum << endl; 177 ost << "Checksum at allocation time: " << pos->checksum << endl; 178 if(checksum!=pos->checksum){ 179 ost << "!!!Chunk was corrupted!!!" << endl; 180 corrupted=true; 181 } 182 } 183 if(corrupted){ 184 ost << "\n!!!Memory corruption detected!!!" << endl; 139 185 } 140 186 } … … 489 535 } 490 536 #endif 491 #endif -
src/Helpers/MemDebug.hpp
r06f4ef6 rb6da28 21 21 * your sourcefiles. 22 22 */ 23 #ifndef NDEBUG24 #ifndef NO_MEMDEBUG25 23 26 #ifndef MEMDEBUG 27 #define MEMDEBUG 24 // Set all flags in a way that makes sense 25 26 // NDEBUG implies NO_MEMDEBUG 27 #ifdef NDEBUG 28 # ifndef NO_MEMDEBUG 29 # define NO_MEMDEBUG 30 # endif 28 31 #endif 32 33 // NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set 34 #ifdef NO_MEMDEBUG 35 # ifdef MEMDEBUG 36 # undef MEMDEBUG 37 # endif 38 #else 39 # ifndef MEMDEBUG 40 # define MEMDEBUG 41 # endif 42 #endif 43 44 #ifdef MEMDEBUG 29 45 30 46 #include <new> … … 45 61 */ 46 62 void getState(); 63 void dumpMemory(std::ostream&); 47 64 48 65 void _ignore(void*); … … 83 100 #endif 84 101 85 #endif 86 #endif 87 88 89 #ifdef NDEBUG 90 #undef MEMDEBUG 91 #endif 92 93 #ifndef MEMDEBUG 102 #else 94 103 // memory debugging was disabled 95 104 96 105 namespace Memory { 97 106 inline void getState(){} 107 108 inline void dumpMemory(std::ostream&){}; 98 109 99 110 template <typename T> … … 104 115 105 116 #endif 117 118 106 119 #endif /* MEMDEBUG_HPP_ */ -
src/Legacy/oldmenu.cpp
r06f4ef6 rb6da28 10 10 11 11 #include "Legacy/oldmenu.hpp" 12 #include "analysis_bonds.hpp" 12 13 #include "analysis_correlation.hpp" 13 14 #include "World.hpp" … … 509 510 Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl; 510 511 Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl; 512 Log() << Verbose(0) << " h - count the number of hydrogen bonds" << endl; 511 513 Log() << Verbose(0) << "all else - go back" << endl; 512 514 Log() << Verbose(0) << "===============================================" << endl; … … 574 576 const LinkedCell *LCList = NULL; 575 577 LCList = new LinkedCell(mol, 10.); 576 FindConvexBorder(mol, TesselStruct, LCList, NULL); 578 Boundaries *BoundaryPoints = NULL; 579 FindConvexBorder(mol, BoundaryPoints TesselStruct, LCList, NULL); 577 580 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration); 578 581 Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\ … … 599 602 } 600 603 break; 604 case 'h': 605 { 606 int Z1; 607 cout << "Please enter first interface element: "; 608 cin >> Z1; 609 const element * InterfaceElement = World::getInstance().getPeriode()->FindElement(Z1); 610 int Z2; 611 cout << "Please enter second interface element: "; 612 cin >> Z2; 613 const element * InterfaceElement2 = World::getInstance().getPeriode()->FindElement(Z2); 614 cout << endl << "There are " << CountHydrogenBridgeBonds(World::getInstance().getMolecules(), InterfaceElement, InterfaceElement2) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << " and " << (InterfaceElement2 != 0 ? InterfaceElement2->name : "None") << "." << endl; 615 } 616 break; 601 617 } 602 618 }; … … 609 625 { 610 626 int Order1; 627 std::string path; 611 628 clock_t start, end; 612 629 … … 614 631 Log() << Verbose(0) << "What's the desired bond order: "; 615 632 cin >> Order1; 633 DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: "); 634 cin >> path; 616 635 if (mol->hasBondStructure()) { 617 636 start = clock(); 618 mol->FragmentMolecule(Order1, configuration);637 mol->FragmentMolecule(Order1, path); 619 638 end = clock(); 620 639 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl; -
src/Line.cpp
r06f4ef6 rb6da28 215 215 } 216 216 217 std::vector<Vector> Line::getSphereIntersections() const{ 218 std::vector<Vector> res; 219 220 // line is kept in normalized form, so we can skip a lot of calculations 221 double discriminant = 1-origin->NormSquared(); 222 // we might have 2, 1 or 0 solutions, depending on discriminant 223 if(discriminant>=0){ 224 if(discriminant==0){ 225 res.push_back(*origin); 226 } 227 else{ 228 Vector helper = sqrt(discriminant)*(*direction); 229 res.push_back(*origin+helper); 230 res.push_back(*origin-helper); 231 } 232 } 233 return res; 234 } 235 217 236 Line makeLineThrough(const Vector &x1, const Vector &x2){ 218 237 if(x1==x2){ -
src/Line.hpp
r06f4ef6 rb6da28 38 38 Plane getOrthogonalPlane(const Vector &origin) const; 39 39 40 std::vector<Vector> getSphereIntersections() const; 41 40 42 private: 41 43 std::auto_ptr<Vector> origin; -
src/Makefile.am
r06f4ef6 rb6da28 8 8 Helpers/Assert.cpp \ 9 9 Helpers/MemDebug.cpp 10 11 BASESOURCE = \ 12 ${HELPERSOURCE} \ 13 Space.cpp \ 14 vector.cpp 15 16 BASEHEADER = \ 17 ${HELPERHEADER} \ 18 Space.hpp \ 19 vector.hpp 10 20 11 21 ATOMSOURCE = \ … … 31 41 32 42 LINALGSOURCE = \ 33 ${HELPERSOURCE} \34 43 gslmatrix.cpp \ 35 44 gslvector.cpp \ 36 linearsystemofequations.cpp \ 37 Space.cpp \ 38 vector.cpp 45 linearsystemofequations.cpp 39 46 40 LINALGHEADER = gslmatrix.hpp \ 47 LINALGHEADER = \ 48 gslmatrix.hpp \ 41 49 gslvector.hpp \ 42 linearsystemofequations.hpp \ 43 Space.hpp \ 44 vector.hpp 50 linearsystemofequations.hpp 45 51 46 52 ANALYSISSOURCE = \ … … 63 69 64 70 ACTIONSHEADER = \ 65 ${ANALYSISACTIONHEADER} \66 ${ATOMACTIONHEADER} \67 ${CMDACTIONHEADER} \68 ${FRAGMENTATIONACTIONHEADER} \69 ${MOLECULEACTIONHEADER} \70 ${PARSERACTIONHEADER} \71 ${TESSELATIONACTIONHEADER} \72 ${WORLDACTIONHEADER} \73 71 Actions/Action.hpp \ 74 72 Actions/ActionHistory.hpp \ … … 83 81 Actions/MethodAction.hpp \ 84 82 Actions/Process.hpp 85 83 84 EXCEPTIONSOURCE = \ 85 Exceptions/CustomException.cpp \ 86 Exceptions/IllegalTypeException.cpp \ 87 Exceptions/LinearDependenceException.cpp \ 88 Exceptions/MathException.cpp \ 89 Exceptions/MissingValueException.cpp \ 90 Exceptions/NotInvertibleException.cpp \ 91 Exceptions/ParseError.cpp \ 92 Exceptions/SkewException.cpp \ 93 Exceptions/ZeroVectorException.cpp 94 95 EXCEPTIONHEADER = \ 96 Exceptions/CustomException.hpp \ 97 Exceptions/IllegalTypeException.hpp \ 98 Exceptions/LinearDependenceException.hpp \ 99 Exceptions/MathException.hpp \ 100 Exceptions/MissingValueException.hpp \ 101 Exceptions/NotInvertibleException.hpp \ 102 Exceptions/ParseError.hpp \ 103 Exceptions/SkewException.hpp \ 104 Exceptions/ZeroVectorException.hpp 86 105 87 106 PARSERSOURCE = \ 88 107 Parser/ChangeTracker.cpp \ 89 108 Parser/FormatParser.cpp \ 109 Parser/FormatParserStorage.cpp \ 110 Parser/MpqcParser.cpp \ 111 Parser/PcpParser.cpp \ 90 112 Parser/TremoloParser.cpp \ 91 113 Parser/XyzParser.cpp 114 92 115 PARSERHEADER = \ 93 116 Parser/ChangeTracker.hpp \ 94 117 Parser/FormatParser.hpp \ 118 Parser/FormatParserStorage.hpp \ 119 Parser/MpqcParser.hpp \ 120 Parser/PcpParser.hpp \ 95 121 Parser/TremoloParser.hpp \ 96 122 Parser/XyzParser.hpp … … 104 130 105 131 SHAPESOURCE = \ 106 Shapes/Shape.cpp 132 Shapes/BaseShapes.cpp \ 133 Shapes/Shape.cpp \ 134 Shapes/ShapeOps.cpp 107 135 SHAPEHEADER = \ 108 Shapes/Shape.hpp 136 Shapes/BaseShapes.hpp \ 137 Shapes/Shape.hpp \ 138 Shapes/ShapeOps.hpp 139 109 140 110 111 # all these files are only used for legacy reasons while the transition is in progress112 # they are only needed to keep the program usable at any point of the transition and will be113 # deleted once everything is fully refactored114 LEGACYSOURCE = Legacy/oldmenu.cpp115 LEGACYHEADER = Legacy/oldmenu.hpp116 117 141 DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \ 118 142 Descriptors/AtomIdDescriptor.cpp \ 143 Descriptors/AtomSelectionDescriptor.cpp \ 119 144 Descriptors/AtomTypeDescriptor.cpp \ 120 145 Descriptors/MoleculeDescriptor.cpp \ 146 Descriptors/MoleculeFormulaDescriptor.cpp \ 121 147 Descriptors/MoleculeIdDescriptor.cpp \ 122 148 Descriptors/MoleculeNameDescriptor.cpp \ 123 Descriptors/MoleculePtrDescriptor.cpp 149 Descriptors/MoleculePtrDescriptor.cpp \ 150 Descriptors/MoleculeSelectionDescriptor.cpp 124 151 125 152 126 153 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \ 127 154 Descriptors/AtomIdDescriptor.hpp \ 155 Descriptors/AtomSelectionDescriptor.hpp \ 128 156 Descriptors/AtomTypeDescriptor.hpp \ 129 157 Descriptors/MoleculeDescriptor.hpp \ 158 Descriptors/MoleculeFormulaDescriptor.hpp \ 130 159 Descriptors/MoleculeIdDescriptor.hpp \ 131 160 Descriptors/MoleculeNameDescriptor.hpp \ 132 Descriptors/MoleculePtrDescriptor.hpp 133 134 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \ 135 Exceptions/LinearDependenceException.cpp \ 136 Exceptions/MathException.cpp \ 137 Exceptions/SkewException.cpp \ 138 Exceptions/ZeroVectorException.cpp 161 Descriptors/MoleculePtrDescriptor.hpp \ 162 Descriptors/MoleculeSelectionDescriptor.cpp 163 164 165 QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \ 166 UIElements/QT4/QTMainWindow.hpp \ 167 UIElements/Menu/QT4/QTMenu.hpp \ 168 UIElements/Views/QT4/QTWorldView.hpp \ 169 UIElements/Views/QT4/GLMoleculeView.hpp \ 170 UIElements/Views/QT4/QTMoleculeView.hpp \ 171 UIElements/Views/QT4/QTStatusBar.hpp 139 172 140 EXCEPTIONHEADER = Exceptions/CustomException.hpp \ 141 Exceptions/LinearDependenceException.hpp \ 142 Exceptions/MathException.hpp \ 143 Exceptions/SkewException.hpp \ 144 Exceptions/ZeroVectorException.hpp 173 QTUISOURCE = allmocs.moc.cpp \ 174 UIElements/QT4/QTMainWindow.cpp \ 175 UIElements/QT4/QTDialog.cpp \ 176 UIElements/QT4/QTUIFactory.cpp \ 177 UIElements/Menu/QT4/QTMenu.cpp \ 178 UIElements/Views/QT4/QTWorldView.cpp \ 179 UIElements/Views/QT4/GLMoleculeView.cpp \ 180 UIElements/Views/QT4/QTMoleculeView.cpp \ 181 UIElements/Views/QT4/QTStatusBar.cpp 182 183 QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp 184 185 QTUI_DEFS = 145 186 146 187 SOURCE = \ … … 148 189 ${ACTIONSSOURCE} \ 149 190 ${ATOMSOURCE} \ 191 ${EXCEPTIONSOURCE} \ 150 192 ${PATTERNSOURCE} \ 151 193 ${PARSERSOURCE} \ 152 194 ${SHAPESOURCE} \ 153 195 ${DESCRIPTORSOURCE} \ 154 ${HELPERSOURCE} \155 ${LEGACYSOURCE} \156 ${EXCEPTIONSOURCE} \157 196 bond.cpp \ 158 197 bondgraph.cpp \ 159 198 boundary.cpp \ 199 Box.cpp \ 160 200 CommandLineParser.cpp \ 161 201 config.cpp \ 202 ConfigFileBuffer.cpp \ 162 203 element.cpp \ 163 204 elements_db.cpp \ 164 205 ellipsoid.cpp \ 165 206 errorlogger.cpp \ 207 Formula.cpp \ 166 208 graph.cpp \ 167 209 helpers.cpp \ … … 172 214 log.cpp \ 173 215 logger.cpp \ 216 Matrix.cpp \ 174 217 moleculelist.cpp \ 175 218 molecule.cpp \ … … 182 225 periodentafel.cpp \ 183 226 Plane.cpp \ 184 Space.cpp \185 227 tesselation.cpp \ 186 228 tesselationhelpers.cpp \ 229 ThermoStatContainer.cpp \ 187 230 triangleintersectionlist.cpp \ 188 vector.cpp \231 UIElements/UIFactory.cpp \ 189 232 vector_ops.cpp \ 190 233 verbose.cpp \ … … 195 238 ${ACTIONSHEADER} \ 196 239 ${ATOMHEADER} \ 240 ${EXCEPTIONHEADER} \ 197 241 ${PARSERHEADER} \ 198 242 ${PATTERNHEADER} \ 199 243 ${SHAPEHEADER} \ 200 244 ${DESCRIPTORHEADER} \ 201 ${EXCEPTIONHEADER} \202 ${LEGACYHEADER} \203 245 bond.hpp \ 204 246 bondgraph.hpp \ 205 247 boundary.hpp \ 248 Box.hpp \ 206 249 CommandLineParser.hpp \ 207 250 config.hpp \ 251 ConfigFileBuffer.hpp \ 208 252 defs.hpp \ 209 253 element.hpp \ … … 211 255 ellipsoid.hpp \ 212 256 errorlogger.hpp \ 257 Formula.hpp \ 213 258 graph.hpp \ 214 259 helpers.hpp \ … … 220 265 log.hpp \ 221 266 logger.hpp \ 267 Matrix.hpp \ 222 268 molecule.hpp \ 223 269 molecule_template.hpp \ … … 228 274 tesselation.hpp \ 229 275 tesselationhelpers.hpp \ 276 ThermoStatContainer.hpp \ 230 277 triangleintersectionlist.hpp \ 278 UIElements/UIFactory.hpp \ 231 279 verbose.hpp \ 232 280 vector_ops.hpp \ … … 240 288 241 289 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) 290 GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS} 242 291 INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements 243 292 244 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a 245 bin_PROGRAMS = molecuilder joiner analyzer 293 noinst_LIBRARIES = libmolecuilderbase.a libmolecuilder.a libgslwrapper.a libmenu.a libparser.a 294 bin_PROGRAMS = molecuilder molecuildergui joiner analyzer 295 EXTRA_PROGRAMS = unity 296 246 297 molecuilderdir = ${bindir} 298 299 libmolecuilderbase_a_SOURCES = ${BASESOURCE} ${BASEHEADER} 247 300 libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER} 301 libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER} 302 libparser_a_SOURCES = ${PARSERSOURCE} ${PARSERHEADER} 248 303 libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER} 304 249 305 molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db 250 molecuilder_LDFLAGS = $(BOOST_LDFLAGS) 251 molecuilder_SOURCES = builder.cpp 252 molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} 306 307 molecuilder_CXXFLAGS = $(BOOST_CPPFLAGS) 308 #molecuilder_CXXFLAGS += -DNO_CACHING 309 molecuilder_LDFLAGS = $(BOOST_LIB) 310 molecuilder_SOURCES = ${LEGACYSOURCE} builder.cpp 311 molecuilder_SOURCES += $(srcdir)/version.c 312 molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilderbase.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} 313 314 #Stuff for building the GUI using QT 315 molecuildergui_SOURCES = ${QTUISOURCE} ${LEGACYSOURCE} builder.cpp 316 molecuildergui_SOURCES += $(srcdir)/version.c 317 molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT 318 molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS} 319 molecuildergui_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilderbase.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} ${GUI_LIBS} 320 253 321 joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp 254 joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 322 joiner_LDADD = libmolecuilder.a libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 323 255 324 analyzer_SOURCES = analyzer.cpp datacreator.cpp parser.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp 256 analyzer_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 325 analyzer_LDADD = libmolecuilder.a libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 326 327 unity_SOURCES = unity.cpp $(srcdir)/version.c 328 unity_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} 329 330 #Rules needed for QT4 331 # UI-Files are scattered throughout several subdirectories 332 # Therfore `%'-rules do not seem to work 333 #Quick fix to get it done otherwise 334 allmocs.moc.cpp: ${QTUIMOC_HEADER} 335 echo "" > allmocs.moc.cpp;\ 336 list='$(QTUIMOC_HEADER)'; for header in $$list; do \ 337 echo "Making mocfile for $$header"; \ 338 target=`basename $$header | sed "s/\(.*\)\..*/\1.moc.cpp/"`;\ 339 $(MOC) $(srcdir)/$$header -o $$target \ 340 || eval $$failcom; \ 341 echo "#include \"$$target\"" >> allmocs.moc.cpp; \ 342 done; 343 344 unity.cpp: ${LINALGSOURCE} ${LINALGHEADER} ${SOURCE} ${HEADER} 345 echo "" > unity.cpp; \ 346 list='$(BASESOURCE)'; for file in $$list; do \ 347 echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \ 348 done; \ 349 list='$(LINALGSOURCE)'; for file in $$list; do \ 350 echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \ 351 done; \ 352 list='$(SOURCE)'; for file in $$list; do \ 353 echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \ 354 done; \ 355 subdirs='$(SUBDIRS)';for directory in $$subdirs; do\ 356 olddir=$$PWD;\ 357 cd $$directory && make unity.cpp;\ 358 cd $$olddir;\ 359 echo "#include \"$$directory/unity.cpp\"" >> unity.cpp;\ 360 done;\ 361 echo "#include \"$(srcdir)/builder.cpp\"" >> unity.cpp; 362 363 MOSTLYCLEANFILES = allmocs.moc.cpp unity.cpp 364 365 #EXTRA_DIST = ${molecuilder_DATA} 257 366 258 367 FORCE: 259 368 $(srcdir)/.git-version: FORCE 260 @if (test -d $(top_srcdir)/../.git && cd $(srcdir) && git describe HEAD) > .git-version-t 2>/dev/null \ 369 @if (test -d $(top_srcdir)/.git && cd $(srcdir) \ 370 && { git describe --dirty --always || git describe; } ) > .git-version-t 2>/dev/null \ 261 371 && ! diff .git-version-t $(srcdir)/.git-version >/dev/null 2>&1; then \ 262 372 mv -f .git-version-t $(srcdir)/.git-version; \ … … 270 380 echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@ 271 381 272 molecuilder_SOURCES += $(srcdir)/version.c 382 -
src/Parser/ChangeTracker.cpp
r06f4ef6 rb6da28 7 7 8 8 #include "Helpers/MemDebug.hpp" 9 #include "Parser/ChangeTracker.hpp" 10 #include "Patterns/Singleton_impl.hpp" 9 11 10 #include "ChangeTracker.hpp"11 12 ChangeTracker* ChangeTracker::instance = NULL;13 12 14 13 /** … … 27 26 ChangeTracker::~ChangeTracker() { 28 27 World::getInstance().signOff(this); 29 }30 31 /**32 * Returns the change tracker instance.33 *34 * \return this35 */36 ChangeTracker* ChangeTracker::get() {37 if (instance == NULL) {38 instance = new ChangeTracker();39 }40 41 return instance;42 }43 44 /**45 * Destroys the change tracker instance. Be careful, the change tracker is a46 * singleton and destruction might lead to a loss of consistency.47 */48 void ChangeTracker::destroy() {49 delete instance;50 instance = NULL;51 28 } 52 29 … … 76 53 } 77 54 } 55 56 CONSTRUCT_SINGLETON(ChangeTracker) -
src/Parser/ChangeTracker.hpp
r06f4ef6 rb6da28 18 18 * changes to it. 19 19 */ 20 class ChangeTracker : public Observable { 20 class ChangeTracker : public Singleton<ChangeTracker>, public Observable { 21 friend class Singleton<ChangeTracker>; 21 22 public: 22 23 void saveStatus(); … … 31 32 bool isConsistent; 32 33 static ChangeTracker* instance; 34 35 // private constructor and destructor due to singleton 33 36 ChangeTracker(); 34 37 ~ChangeTracker(); -
src/Parser/FormatParser.cpp
r06f4ef6 rb6da28 19 19 Observer("FormatParser") 20 20 { 21 ChangeTracker::get ()->signOn(this);21 ChangeTracker::getInstance().signOn(this); 22 22 saveStream = NULL; 23 23 } … … 27 27 */ 28 28 FormatParser::~FormatParser() { 29 ChangeTracker::get ()->signOff(this);29 ChangeTracker::getInstance().signOff(this); 30 30 } 31 31 -
src/Parser/TremoloParser.cpp
r06f4ef6 rb6da28 21 21 22 22 using namespace std; 23 using namespace boost;24 23 25 24 /** … … 49 48 knownKeys["GrpTypeNo"] = TremoloKey::GrpTypeNo; 50 49 knownKeys["torsion"] = TremoloKey::torsion; 50 51 // default behavior: use all possible keys on output 52 for (std::map<std::string, TremoloKey::atomDataKey>::iterator iter = knownKeys.begin(); iter != knownKeys.end(); ++iter) 53 usedFields.push_back(iter->first); 51 54 } 52 55 … … 193 196 194 197 lineStream << line.substr(offset); 198 usedFields.clear(); 195 199 while (lineStream.good()) { 196 200 lineStream >> keyword; -
src/Parser/TremoloParser.hpp
r06f4ef6 rb6da28 10 10 11 11 #include <string> 12 #include " FormatParser.hpp"12 #include "Parser/FormatParser.hpp" 13 13 14 14 /** -
src/Parser/XyzParser.cpp
r06f4ef6 rb6da28 27 27 */ 28 28 XyzParser::~XyzParser() { 29 delete(&comment);30 29 } 31 30 … … 58 57 */ 59 58 void XyzParser::save(ostream* file) { 60 *file << World::getInstance().numAtoms() << endl << comment << endl; 59 if (comment == "") { 60 time_t now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 61 comment = "Created by molecuilder on "; 62 // ctime ends in \n\0, we have to cut away the newline 63 std::string time(ctime(&now)); 64 size_t pos = time.find('\n'); 65 if (pos != 0) 66 comment += time.substr(0,pos); 67 else 68 comment += time; 69 } 70 *file << World::getInstance().numAtoms() << endl << "\t" << comment << endl; 61 71 62 72 vector<atom*> atoms = World::getInstance().getAllAtoms(); 63 73 for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) { 64 *file << fixed<< (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;74 *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl; 65 75 } 66 76 } -
src/Parser/XyzParser.hpp
r06f4ef6 rb6da28 10 10 11 11 #include <string> 12 #include " FormatParser.hpp"12 #include "Parser/FormatParser.hpp" 13 13 14 14 /** -
src/Patterns/Cacheable.hpp
r06f4ef6 rb6da28 12 12 #include <boost/function.hpp> 13 13 #include <boost/shared_ptr.hpp> 14 #include <iostream>15 14 16 15 #include "Helpers/Assert.hpp" -
src/Patterns/ObservedIterator.hpp
r06f4ef6 rb6da28 84 84 { 85 85 --iter; 86 return *this; 86 87 } 87 88 … … 105 106 acquireLock(); 106 107 return (*iter); 108 } 109 110 value_type *operator->(){ 111 acquireLock(); 112 return &(*iter); 107 113 } 108 114 -
src/Patterns/Observer.hpp
r06f4ef6 rb6da28 170 170 //! @cond 171 171 // Structure for RAII-Style notification 172 p rotected:172 public: 173 173 /** 174 174 * This structure implements the Observer-mechanism RAII-Idiom. … … 241 241 #define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this) 242 242 #define NOTIFY(notification) do{Observable::enque_notification_internal(this,notification);}while(0) 243 #define LOCK_OBSERVABLE(observable) Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(&(observable)) 243 244 244 245 #endif /* OBSERVER_HPP_ */ -
src/Patterns/Singleton.hpp
r06f4ef6 rb6da28 9 9 #define SINGLETON_HPP_ 10 10 11 #include <cassert>12 11 #include <boost/thread.hpp> 13 12 13 #include "Helpers/Assert.hpp" 14 14 #include "defs.hpp" 15 15 … … 181 181 182 182 inline static void set(creator_T*&,creator_T*){ 183 assert(0 &&"Cannot set the Instance for a singleton of this type");183 ASSERT(0, "Cannot set the Instance for a singleton of this type"); 184 184 } 185 185 }; … … 191 191 struct creator_t<creator_T,false>{ 192 192 inline static creator_T* make(){ 193 assert(0 && "Cannot create a singleton of this type directly"); 193 ASSERT(0, "Cannot create a singleton of this type directly"); 194 return 0; 194 195 } 195 196 inline static void set(ptr_t& dest,creator_T* src){ -
src/Patterns/Singleton_impl.hpp
r06f4ef6 rb6da28 72 72 template <class T,bool _may_create> 73 73 void Singleton<T,_may_create>::setInstance(T* newInstance){ 74 assert(!theInstance.get() &&"Trying to set the instance of an already created singleton");74 ASSERT(!theInstance.get(), "Trying to set the instance of an already created singleton"); 75 75 boost::recursive_mutex::scoped_lock guard(instanceLock); 76 76 theInstance.reset(newInstance); … … 83 83 template <class T, bool _may_create> 84 84 Singleton<T,_may_create>::Singleton(const Singleton<T,_may_create>&){ 85 assert(0 &&"Copy constructor of singleton template called");85 ASSERT(0, "Copy constructor of singleton template called"); 86 86 } 87 87 -
src/Plane.hpp
r06f4ef6 rb6da28 11 11 #include <memory> 12 12 #include <vector> 13 #include <ios tream>13 #include <iosfwd> 14 14 #include "Space.hpp" 15 15 #include "Exceptions/LinearDependenceException.hpp" -
src/Shapes/Shape.cpp
r06f4ef6 rb6da28 15 15 Shape::~Shape(){} 16 16 17 bool Shape::isInside(const Vector &point) {17 bool Shape::isInside(const Vector &point) const{ 18 18 return impl->isInside(point); 19 19 } … … 32 32 Shape::impl_ptr Shape::getImpl() const{ 33 33 return impl; 34 } 35 36 // allows arbitrary friendship, but only if implementation is known 37 Shape::impl_ptr getShapeImpl(const Shape &shape){ 38 return shape.getImpl(); 34 39 } 35 40 … … 61 66 62 67 Shape operator&&(const Shape &lhs,const Shape &rhs){ 63 Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl( lhs.getImpl(),rhs.getImpl()));68 Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs))); 64 69 return Shape(newImpl); 65 70 } … … 78 83 79 84 Shape operator||(const Shape &lhs,const Shape &rhs){ 80 Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl( lhs.getImpl(),rhs.getImpl()));85 Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs))); 81 86 return Shape(newImpl); 82 87 } … … 95 100 96 101 Shape operator!(const Shape &arg){ 97 Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl( arg.getImpl()));102 Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg))); 98 103 return Shape(newImpl); 99 104 } -
src/Shapes/Shape.hpp
r06f4ef6 rb6da28 16 16 class Shape 17 17 { 18 friend Shape operator&&(const Shape&,const Shape&);19 friend Shape operator||(const Shape&,const Shape&);20 friend Shape operator!(const Shape&);21 18 public: 22 19 typedef boost::shared_ptr<Shape_impl> impl_ptr; 20 friend impl_ptr getShapeImpl(const Shape&); 23 21 24 22 Shape(impl_ptr); … … 26 24 virtual ~Shape(); 27 25 28 bool isInside(const Vector &point) ;26 bool isInside(const Vector &point) const; 29 27 30 28 Shape &operator=(const Shape& rhs); -
src/Shapes/Shape_impl.hpp
r06f4ef6 rb6da28 13 13 class Shape_impl { 14 14 public: 15 Shape_impl(){}; 16 virtual ~Shape_impl(){}; 15 17 virtual bool isInside(const Vector &point)=0; 16 18 }; … … 58 60 }; 59 61 62 Shape::impl_ptr getShapeImpl(const Shape&); 63 60 64 #endif /* SHAPE_IMPL_HPP_ */ -
src/UIElements/CommandLineUI/CommandLineDialog.cpp
r06f4ef6 rb6da28 24 24 #include "defs.hpp" 25 25 #include "log.hpp" 26 #include "Matrix.hpp" 26 27 #include "periodentafel.hpp" 27 28 #include "verbose.hpp" 28 29 #include "World.hpp" 30 #include "Box.hpp" 29 31 30 32 #include "atom.hpp" … … 49 51 } 50 52 51 void CommandLineDialog::queryInt(const char* title, int* target, string _description){ 52 registerQuery(new IntCommandLineQuery(title,target, _description)); 53 } 54 55 void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){ 56 registerQuery(new BooleanCommandLineQuery(title,target, _description)); 57 } 58 59 void CommandLineDialog::queryDouble(const char* title, double* target, string _description){ 60 registerQuery(new DoubleCommandLineQuery(title,target, _description)); 61 } 62 63 void CommandLineDialog::queryString(const char* title, string* target, string _description){ 64 registerQuery(new StringCommandLineQuery(title,target, _description)); 65 } 66 67 void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) { 68 registerQuery(new AtomCommandLineQuery(title,target, _description)); 69 } 70 71 void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) { 72 registerQuery(new MoleculeCommandLineQuery(title,target, _description)); 73 } 74 75 void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) { 76 registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description)); 77 } 78 79 void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) { 80 registerQuery(new BoxCommandLineQuery(title,cellSize,_description)); 81 } 82 83 void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){ 84 registerQuery(new ElementCommandLineQuery(title,target, _description)); 53 void CommandLineDialog::queryInt(const char* title, string _description){ 54 registerQuery(new IntCommandLineQuery(title, _description)); 55 } 56 57 void CommandLineDialog::queryInts(const char* title, string _description){ 58 registerQuery(new IntsCommandLineQuery(title, _description)); 59 } 60 61 void CommandLineDialog::queryBoolean(const char* title, string _description){ 62 registerQuery(new BooleanCommandLineQuery(title, _description)); 63 } 64 65 void CommandLineDialog::queryDouble(const char* title, string _description){ 66 registerQuery(new DoubleCommandLineQuery(title, _description)); 67 } 68 69 void CommandLineDialog::queryDoubles(const char* title, string _description){ 70 registerQuery(new DoublesCommandLineQuery(title, _description)); 71 } 72 73 void CommandLineDialog::queryString(const char* title, string _description){ 74 registerQuery(new StringCommandLineQuery(title, _description)); 75 } 76 77 void CommandLineDialog::queryStrings(const char* title, string _description){ 78 registerQuery(new StringsCommandLineQuery(title, _description)); 79 } 80 81 void CommandLineDialog::queryAtom(const char* title, string _description) { 82 registerQuery(new AtomCommandLineQuery(title, _description)); 83 } 84 85 void CommandLineDialog::queryAtoms(const char* title, string _description) { 86 registerQuery(new AtomsCommandLineQuery(title, _description)); 87 } 88 89 void CommandLineDialog::queryMolecule(const char* title, string _description) { 90 registerQuery(new MoleculeCommandLineQuery(title, _description)); 91 } 92 93 void CommandLineDialog::queryMolecules(const char* title, string _description) { 94 registerQuery(new MoleculesCommandLineQuery(title, _description)); 95 } 96 97 void CommandLineDialog::queryVector(const char* title, bool check, string _description) { 98 registerQuery(new VectorCommandLineQuery(title,check, _description)); 99 } 100 101 void CommandLineDialog::queryVectors(const char* title, bool check, string _description) { 102 registerQuery(new VectorsCommandLineQuery(title,check, _description)); 103 } 104 105 void CommandLineDialog::queryBox(const char* title, string _description) { 106 registerQuery(new BoxCommandLineQuery(title,_description)); 107 } 108 109 void CommandLineDialog::queryElement(const char* title, string _description){ 110 registerQuery(new ElementCommandLineQuery(title, _description)); 111 } 112 113 void CommandLineDialog::queryElements(const char* title, string _description){ 114 registerQuery(new ElementsCommandLineQuery(title, _description)); 85 115 } 86 116 … … 98 128 } 99 129 100 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, int *_target,string _description) :101 Dialog::IntQuery(title, _target,_description)130 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) : 131 Dialog::IntQuery(title, _description) 102 132 {} 103 133 … … 114 144 } 115 145 116 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) : 117 Dialog::BooleanQuery(title,_target, _description) 146 CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) : 147 Dialog::IntsQuery(title, _description) 148 {} 149 150 CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {} 151 152 bool CommandLineDialog::IntsCommandLineQuery::handle() { 153 if (CommandLineParser::getInstance().vm.count(getTitle())) { 154 tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 155 return true; 156 } else { 157 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl); 158 return false; 159 } 160 } 161 162 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) : 163 Dialog::BooleanQuery(title, _description) 118 164 {} 119 165 … … 130 176 } 131 177 132 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string *_target,string _description) :133 Dialog::StringQuery(title, _target,_description)178 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) : 179 Dialog::StringQuery(title, _description) 134 180 {} 135 181 … … 146 192 } 147 193 148 CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) : 149 Dialog::DoubleQuery(title,_target, _description) 194 CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) : 195 Dialog::StringsQuery(title, _description) 196 {} 197 198 CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {} 199 200 bool CommandLineDialog::StringsCommandLineQuery::handle() { 201 if (CommandLineParser::getInstance().vm.count(getTitle())) { 202 tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >(); 203 return true; 204 } else { 205 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl); 206 return false; 207 } 208 } 209 210 CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) : 211 Dialog::DoubleQuery(title, _description) 150 212 {} 151 213 … … 162 224 } 163 225 164 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) : 165 Dialog::AtomQuery(title,_target, _description) 226 CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) : 227 Dialog::DoublesQuery(title, _description) 228 {} 229 230 CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {} 231 232 bool CommandLineDialog::DoublesCommandLineQuery::handle() { 233 if (CommandLineParser::getInstance().vm.count(getTitle())) { 234 tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >(); 235 return true; 236 } else { 237 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl); 238 return false; 239 } 240 } 241 242 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) : 243 Dialog::AtomQuery(title, _description) 166 244 {} 167 245 … … 180 258 } 181 259 182 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) : 183 Dialog::MoleculeQuery(title,_target, _description) 260 CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) : 261 Dialog::AtomsQuery(title, _description) 262 {} 263 264 CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {} 265 266 bool CommandLineDialog::AtomsCommandLineQuery::handle() { 267 std::vector<int> IdxOfAtom; 268 if (CommandLineParser::getInstance().vm.count(getTitle())) { 269 IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 270 for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) { 271 temp = World::getInstance().getAtom(AtomById(*iter)); 272 if (temp) 273 tmp.push_back(temp); 274 } 275 return true; 276 } else { 277 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl); 278 return false; 279 } 280 } 281 282 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) : 283 Dialog::MoleculeQuery(title, _description) 184 284 {} 185 285 … … 190 290 if (CommandLineParser::getInstance().vm.count(getTitle())) { 191 291 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>(); 192 cout << "IdxOfMol " << IdxOfMol << endl; 193 if (IdxOfMol >= 0) 194 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 195 else 196 tmp = NULL; 292 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 197 293 return true; 198 294 } else { … … 202 298 } 203 299 204 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) : 205 Dialog::VectorQuery(title,_target,_cellSize,_check, _description) 300 CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) : 301 Dialog::MoleculesQuery(title, _description) 302 {} 303 304 CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {} 305 306 bool CommandLineDialog::MoleculesCommandLineQuery::handle() { 307 std::vector<int> IdxOfMol; 308 if (CommandLineParser::getInstance().vm.count(getTitle())) { 309 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 310 for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) { 311 temp = World::getInstance().getMolecule(MoleculeById(*iter)); 312 if (temp) 313 tmp.push_back(temp); 314 } 315 return true; 316 } else { 317 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl); 318 return false; 319 } 320 } 321 322 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) : 323 Dialog::VectorQuery(title,_check, _description) 206 324 {} 207 325 … … 213 331 if (CommandLineParser::getInstance().vm.count(getTitle())) { 214 332 temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >(); 215 tmp->at(0) = temp.x; 216 tmp->at(1) = temp.y; 217 tmp->at(2) = temp.z; 333 tmp[0] = temp.x; 334 tmp[1] = temp.y; 335 tmp[2] = temp.z; 336 if ((check) && (!World::getInstance().getDomain().isInside(tmp))) { 337 DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl); 338 return false; 339 } 218 340 return true; 219 341 } else { … … 223 345 } 224 346 225 226 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) : 227 Dialog::BoxQuery(title,_cellSize, _description) 347 CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) : 348 Dialog::VectorsQuery(title,_check, _description) 349 {} 350 351 CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery() 352 {} 353 354 bool CommandLineDialog::VectorsCommandLineQuery::handle() { 355 std::vector<VectorValue> temporary; 356 if (CommandLineParser::getInstance().vm.count(getTitle())) { 357 temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >(); 358 for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) { 359 temp[0] = (*iter).x; 360 temp[1] = (*iter).y; 361 temp[2] = (*iter).z; 362 if ((!check) || (World::getInstance().getDomain().isInside(temp))) 363 tmp.push_back(temp); 364 else 365 DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl); 366 } 367 return true; 368 } else { 369 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl); 370 return false; 371 } 372 } 373 374 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) : 375 Dialog::BoxQuery(title, _description) 228 376 {} 229 377 … … 235 383 if (CommandLineParser::getInstance().vm.count(getTitle())) { 236 384 temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >(); 237 tmp[0] = temp.xx; 238 tmp[1] = temp.xy; 239 tmp[2] = temp.xz; 240 tmp[3] = temp.yy; 241 tmp[4] = temp.yz; 242 tmp[5] = temp.zz; 385 Matrix M; 386 M.set(0,0, temp.xx); 387 M.set(0,1, temp.yx); 388 M.set(0,2, temp.zx); 389 M.set(1,0, temp.yx); 390 M.set(1,1, temp.yy); 391 M.set(1,2, temp.zy); 392 M.set(2,0, temp.zx); 393 M.set(2,1, temp.zy); 394 M.set(2,2, temp.zz); 395 tmp.setM(M); 243 396 return true; 244 397 } else { … … 248 401 } 249 402 250 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, st d::vector<element *> *target, string _description) :251 Dialog::ElementQuery(title, target,_description)403 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) : 404 Dialog::ElementQuery(title, _description) 252 405 {} 253 406 … … 258 411 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 259 412 periodentafel *periode = World::getInstance().getPeriode(); 260 element *elemental = NULL; 413 if (CommandLineParser::getInstance().vm.count(getTitle())) { 414 int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >(); 415 tmp = periode->FindElement(Z); 416 ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery"); 417 return true; 418 } else { 419 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl); 420 return false; 421 } 422 } 423 424 CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) : 425 Dialog::ElementsQuery(title, _description) 426 {} 427 428 CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery() 429 {} 430 431 bool CommandLineDialog::ElementsCommandLineQuery::handle() { 432 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 433 periodentafel *periode = World::getInstance().getPeriode(); 261 434 if (CommandLineParser::getInstance().vm.count(getTitle())) { 262 435 vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >(); 263 436 for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) { 264 elemental= periode->FindElement(*ZRunner);265 ASSERT( elemental!= NULL, "Invalid element specified in ElementCommandLineQuery");266 elements.push_back(elemental);437 temp = periode->FindElement(*ZRunner); 438 ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery"); 439 tmp.push_back(temp); 267 440 } 268 441 return true; 269 442 } else { 270 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);271 return false; 272 } 273 } 443 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl); 444 return false; 445 } 446 } -
src/UIElements/CommandLineUI/CommandLineDialog.hpp
r06f4ef6 rb6da28 28 28 29 29 virtual void queryEmpty(const char *, std::string = ""); 30 virtual void queryInt(const char *, int *, std::string = ""); 31 virtual void queryBoolean(const char *, bool *, std::string = ""); 32 virtual void queryString(const char*, std::string *, std::string = ""); 33 virtual void queryDouble(const char*, double*, std::string = ""); 34 virtual void queryAtom(const char*,atom**, std::string = ""); 35 virtual void queryMolecule(const char*,molecule**,std::string = ""); 36 virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = ""); 37 virtual void queryBox(const char*,double ** const, std::string = ""); 38 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 30 virtual void queryInt(const char *, std::string = ""); 31 virtual void queryInts(const char *, std::string = ""); 32 virtual void queryBoolean(const char *, std::string = ""); 33 virtual void queryString(const char*, std::string = ""); 34 virtual void queryStrings(const char*, std::string = ""); 35 virtual void queryDouble(const char*, std::string = ""); 36 virtual void queryDoubles(const char*, std::string = ""); 37 virtual void queryAtom(const char*, std::string = ""); 38 virtual void queryAtoms(const char*, std::string = ""); 39 virtual void queryMolecule(const char*, std::string = ""); 40 virtual void queryMolecules(const char*, std::string = ""); 41 virtual void queryVector(const char*, bool, std::string = ""); 42 virtual void queryVectors(const char*, bool, std::string = ""); 43 virtual void queryBox(const char*, std::string = ""); 44 virtual void queryElement(const char*, std::string = ""); 45 virtual void queryElements(const char*, std::string = ""); 39 46 40 47 protected: … … 49 56 class IntCommandLineQuery : public Dialog::IntQuery { 50 57 public: 51 IntCommandLineQuery(std::string title, int *_target,std::string _description = "");58 IntCommandLineQuery(std::string title, std::string _description = ""); 52 59 virtual ~IntCommandLineQuery(); 60 virtual bool handle(); 61 }; 62 63 class IntsCommandLineQuery : public Dialog::IntsQuery { 64 public: 65 IntsCommandLineQuery(std::string title, std::string _description = ""); 66 virtual ~IntsCommandLineQuery(); 53 67 virtual bool handle(); 54 68 }; … … 56 70 class BooleanCommandLineQuery : public Dialog::BooleanQuery { 57 71 public: 58 BooleanCommandLineQuery(std::string title, bool *_target,std::string _description = "");72 BooleanCommandLineQuery(std::string title, std::string _description = ""); 59 73 virtual ~BooleanCommandLineQuery(); 60 74 virtual bool handle(); … … 63 77 class DoubleCommandLineQuery : public Dialog::DoubleQuery { 64 78 public: 65 DoubleCommandLineQuery(std::string title, double *_target,std::string _description = "");79 DoubleCommandLineQuery(std::string title, std::string _description = ""); 66 80 virtual ~DoubleCommandLineQuery(); 81 virtual bool handle(); 82 }; 83 84 class DoublesCommandLineQuery : public Dialog::DoublesQuery { 85 public: 86 DoublesCommandLineQuery(std::string title, std::string _description = ""); 87 virtual ~DoublesCommandLineQuery(); 67 88 virtual bool handle(); 68 89 }; … … 70 91 class StringCommandLineQuery : public Dialog::StringQuery { 71 92 public: 72 StringCommandLineQuery(std::string title, std::string *_target, std::string_description = "");93 StringCommandLineQuery(std::string title, std::string _description = ""); 73 94 virtual ~StringCommandLineQuery(); 95 virtual bool handle(); 96 }; 97 98 class StringsCommandLineQuery : public Dialog::StringsQuery { 99 public: 100 StringsCommandLineQuery(std::string title, std::string _description = ""); 101 virtual ~StringsCommandLineQuery(); 74 102 virtual bool handle(); 75 103 }; … … 77 105 class AtomCommandLineQuery : public Dialog::AtomQuery { 78 106 public: 79 AtomCommandLineQuery(std::string title, atom **_target,std::string _description = "");107 AtomCommandLineQuery(std::string title, std::string _description = ""); 80 108 virtual ~AtomCommandLineQuery(); 109 virtual bool handle(); 110 }; 111 112 class AtomsCommandLineQuery : public Dialog::AtomsQuery { 113 public: 114 AtomsCommandLineQuery(std::string title, std::string _description = ""); 115 virtual ~AtomsCommandLineQuery(); 81 116 virtual bool handle(); 82 117 }; … … 84 119 class MoleculeCommandLineQuery : public Dialog::MoleculeQuery { 85 120 public: 86 MoleculeCommandLineQuery(std::string title, molecule **_target,std::string _description = "");121 MoleculeCommandLineQuery(std::string title, std::string _description = ""); 87 122 virtual ~MoleculeCommandLineQuery(); 123 virtual bool handle(); 124 }; 125 126 class MoleculesCommandLineQuery : public Dialog::MoleculesQuery { 127 public: 128 MoleculesCommandLineQuery(std::string title, std::string _description = ""); 129 virtual ~MoleculesCommandLineQuery(); 88 130 virtual bool handle(); 89 131 }; … … 91 133 class VectorCommandLineQuery : public Dialog::VectorQuery { 92 134 public: 93 VectorCommandLineQuery(std::string title, Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");135 VectorCommandLineQuery(std::string title,bool _check, std::string _description = ""); 94 136 virtual ~VectorCommandLineQuery(); 137 virtual bool handle(); 138 }; 139 140 class VectorsCommandLineQuery : public Dialog::VectorsQuery { 141 public: 142 VectorsCommandLineQuery(std::string title,bool _check, std::string _description = ""); 143 virtual ~VectorsCommandLineQuery(); 95 144 virtual bool handle(); 96 145 }; … … 98 147 class BoxCommandLineQuery : public Dialog::BoxQuery { 99 148 public: 100 BoxCommandLineQuery(std::string title, double ** const _cellSize,std::string _description = "");149 BoxCommandLineQuery(std::string title, std::string _description = ""); 101 150 virtual ~BoxCommandLineQuery(); 102 151 virtual bool handle(); … … 105 154 class ElementCommandLineQuery : public Dialog::ElementQuery { 106 155 public: 107 ElementCommandLineQuery(std::string title, std:: vector<element *> *_target, std::string _description = "");156 ElementCommandLineQuery(std::string title, std::string _description = ""); 108 157 virtual ~ElementCommandLineQuery(); 158 virtual bool handle(); 159 }; 160 161 class ElementsCommandLineQuery : public Dialog::ElementsQuery { 162 public: 163 ElementsCommandLineQuery(std::string title, std::string _description = ""); 164 virtual ~ElementsCommandLineQuery(); 109 165 virtual bool handle(); 110 166 }; -
src/UIElements/CommandLineUI/CommandLineUIFactory.hpp
r06f4ef6 rb6da28 11 11 #include "UIFactory.hpp" 12 12 13 /** This class is a specialization of the UIFactory. 14 * 15 * <h2> Introduction </h2> 16 * 17 * The UIFactory is a base class for the User Interaction. There are three UI specializations: 18 * Text, GUI and CommandLine. 19 * 20 * The idea of the command line part is as follows: 21 * 22 * All actions that can be called from the command line are instantiated via populater-functions. 23 * In the constructor of an action it is automatically registered with the ActionRegistry and can 24 * henceforth be looked up there. 25 * 26 * There is a CommandLineParser which parses the command line parameters and puts all found values 27 * into a map. Then, MainWindow::Display of the CommandLineUIFactory is called, which goes through 28 * every action (by the ActionRegistry) and looks through the parsed commands whether the action is 29 * desired. 30 * 31 * In the action itself, Query's ask for user input. In the CommandLine case, we don't want direct 32 * user interaction, but the user has to have those values already delivered along with the desired 33 * action. Hence, the Query implementations just look up the desired values in the CommandLineParser 34 * vaults. When they are not found, an exception is thrown. When all are found, the action is performed. 35 * 36 */ 13 37 class CommandLineUIFactory : public UIFactory 14 38 { -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
r06f4ef6 rb6da28 13 13 #include "CommandLineUI/CommandLineStatusIndicator.hpp" 14 14 15 #include "Actions/Action.hpp" 16 #include "Actions/MapOfActions.hpp" 15 17 #include "Actions/ActionRegistry.hpp" 16 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" 17 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 18 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 19 #include "Actions/AtomAction/AddAction.hpp" 20 #include "Actions/AtomAction/ChangeElementAction.hpp" 21 #include "Actions/AtomAction/RemoveAction.hpp" 22 #include "Actions/CmdAction/BondLengthTableAction.hpp" 23 #include "Actions/CmdAction/ElementDbAction.hpp" 24 #include "Actions/CmdAction/FastParsingAction.hpp" 25 #include "Actions/CmdAction/HelpAction.hpp" 26 #include "Actions/CmdAction/VerboseAction.hpp" 27 #include "Actions/CmdAction/VersionAction.hpp" 28 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 29 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 30 #include "Actions/FragmentationAction/FragmentationAction.hpp" 31 #include "Actions/MoleculeAction/BondFileAction.hpp" 32 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 33 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp" 34 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp" 35 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp" 36 #include "Actions/MoleculeAction/SaveBondsAction.hpp" 37 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp" 38 #include "Actions/MoleculeAction/TranslateAction.hpp" 39 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp" 40 #include "Actions/ParserAction/LoadXyzAction.hpp" 41 #include "Actions/ParserAction/SaveXyzAction.hpp" 42 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp" 43 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp" 44 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp" 45 #include "Actions/WorldAction/BoundInBoxAction.hpp" 46 #include "Actions/WorldAction/CenterInBoxAction.hpp" 47 #include "Actions/WorldAction/CenterOnEdgeAction.hpp" 48 #include "Actions/WorldAction/ChangeBoxAction.hpp" 49 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 50 #include "Actions/WorldAction/RepeatBoxAction.hpp" 51 #include "Actions/WorldAction/ScaleBoxAction.hpp" 52 #include "Actions/WorldAction/SetDefaultNameAction.hpp" 53 #include "Actions/WorldAction/SetGaussianBasisAction.hpp" 18 54 19 #include "CommandLineParser.hpp" 55 20 … … 62 27 { 63 28 // create and register all command line callable actions 64 populateAnalysisActions(); 65 populateAtomActions(); 66 populateCmdActions(); 67 populateFragmentationActions(); 68 populateMoleculeActions(); 69 populateParserActions(); 70 populateTesselationActions(); 71 populateWorldActions(); 29 MapOfActions::getInstance().populateActions(); 72 30 73 31 // Add status indicators etc... … … 81 39 82 40 void CommandLineWindow::display() { 41 //cout << ActionRegistry::getInstance(); 42 83 43 // go through all possible actions 84 44 for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) { 85 cout << "Checking presence of " << *CommandRunner << endl; 86 if (ActionRegistry::getInstance().isActionByNamePresent(*CommandRunner)) 45 cout << "Checking presence of " << *CommandRunner << ": "; 46 if (ActionRegistry::getInstance().isActionPresentByName(*CommandRunner)) { 47 cout << "calling " << *CommandRunner << endl; 87 48 ActionRegistry::getInstance().getActionByName(*CommandRunner)->call(); 49 } else { 50 cout << "absent." << endl; 51 } 88 52 } 89 53 } 90 54 91 void CommandLineWindow::populateAnalysisActions()92 {93 new AnalysisMolecularVolumeAction();94 new AnalysisPairCorrelationAction();95 new AnalysisPrincipalAxisSystemAction();96 }97 98 void CommandLineWindow::populateAtomActions()99 {100 new AtomAddAction();101 new AtomChangeElementAction();102 new AtomRemoveAction();103 }104 105 void CommandLineWindow::populateCmdActions()106 {107 new CommandLineBondLengthTableAction();108 new CommandLineElementDbAction();109 new CommandLineFastParsingAction();110 new CommandLineHelpAction();111 new CommandLineVerboseAction();112 new CommandLineVersionAction();113 }114 115 void CommandLineWindow::populateFragmentationActions()116 {117 new FragmentationDepthFirstSearchAction();118 new FragmentationFragmentationAction();119 new FragmentationSubgraphDissectionAction();120 }121 122 void CommandLineWindow::populateMoleculeActions()123 {124 new MoleculeBondFileAction();125 new MoleculeChangeNameAction();126 new MoleculeFillWithMoleculeAction();127 new MoleculeLinearInterpolationofTrajectoriesAction();128 new MoleculeSaveAdjacencyAction();129 new MoleculeSaveBondsAction();130 new MoleculeSaveTemperatureAction();131 new MoleculeTranslateAction();132 new MoleculeVerletIntegrationAction();133 }134 135 void CommandLineWindow::populateParserActions()136 {137 new ParserLoadXyzAction();138 new ParserSaveXyzAction();139 }140 141 void CommandLineWindow::populateTesselationActions()142 {143 new TesselationConvexEnvelopeAction();144 new TesselationNonConvexEnvelopeAction();145 }146 147 void CommandLineWindow::populateWorldActions()148 {149 new WorldAddEmptyBoundaryAction();150 new WorldBoundInBoxAction();151 new WorldCenterInBoxAction();152 new WorldCenterOnEdgeAction();153 new WorldChangeBoxAction();154 new WorldRemoveSphereOfAtomsAction();155 new WorldRepeatBoxAction();156 new WorldScaleBoxAction();157 new WorldSetDefaultNameAction();158 new WorldSetGaussianBasisAction();159 } -
src/UIElements/Dialog.cpp
r06f4ef6 rb6da28 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 #include <cassert>11 12 10 #include "Dialog.hpp" 13 11 #include "ValueStorage.hpp" 12 13 #include "verbose.hpp" 14 14 #include "atom.hpp" 15 15 #include "element.hpp" 16 16 #include "molecule.hpp" 17 17 #include "vector.hpp" 18 #include "Matrix.hpp" 19 #include "Box.hpp" 18 20 19 21 using namespace std; … … 36 38 37 39 bool Dialog::display(){ 40 if(checkAll()){ 41 setAll(); 42 return true; 43 } 44 else{ 45 return false; 46 } 47 } 48 49 bool Dialog::checkAll(){ 38 50 list<Query*>::iterator iter; 39 51 bool retval = true; … … 46 58 } 47 59 } 48 if (retval){49 // if all queries succeeded we can set the targets to appropriate values50 for(iter=queries.begin(); iter!=queries.end(); iter++) {51 (*iter)->setResult();52 }53 }54 60 return retval; 61 } 62 63 void Dialog::setAll(){ 64 list<Query*>::iterator iter; 65 for(iter=queries.begin(); iter!=queries.end(); iter++) { 66 (*iter)->setResult(); 67 } 68 } 69 70 bool Dialog::hasQueries(){ 71 return queries.size(); 55 72 } 56 73 … … 85 102 // Int Queries 86 103 87 Dialog::IntQuery::IntQuery(string title, int *_target,std::string description) :88 Query(title, description) , target(_target)104 Dialog::IntQuery::IntQuery(string title, std::string description) : 105 Query(title, description) 89 106 {} 90 107 … … 92 109 93 110 void Dialog::IntQuery::setResult() { 94 *target = tmp; 95 } 96 97 // Int Queries 98 99 Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) : 100 Query(title, description), target(_target) 111 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 112 } 113 114 // Ints Queries 115 116 Dialog::IntsQuery::IntsQuery(string title, std::string description) : 117 Query(title, description) 118 {} 119 120 Dialog::IntsQuery::~IntsQuery() {} 121 122 void Dialog::IntsQuery::setResult() { 123 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 124 } 125 126 // Bool Queries 127 128 Dialog::BooleanQuery::BooleanQuery(string title,std::string description) : 129 Query(title, description) 101 130 {} 102 131 … … 104 133 105 134 void Dialog::BooleanQuery::setResult() { 106 *target = tmp;135 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 107 136 } 108 137 109 138 // String Queries 110 139 111 Dialog::StringQuery::StringQuery(string title,st ring *_target, std::string _description) :112 Query(title, _description) , target(_target)140 Dialog::StringQuery::StringQuery(string title,std::string _description) : 141 Query(title, _description) 113 142 {} 114 143 … … 116 145 117 146 void Dialog::StringQuery::setResult() { 118 *target = tmp; 147 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 148 } 149 150 // Strings Queries 151 152 Dialog::StringsQuery::StringsQuery(string title,std::string _description) : 153 Query(title, _description) 154 {} 155 156 Dialog::StringsQuery::~StringsQuery() {}; 157 158 void Dialog::StringsQuery::setResult() { 159 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 119 160 } 120 161 121 162 // Double Queries 122 163 123 Dialog::DoubleQuery::DoubleQuery(string title, double *_target,std::string _description) :124 Query(title, _description) , target(_target)164 Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) : 165 Query(title, _description) 125 166 {} 126 167 … … 128 169 129 170 void Dialog::DoubleQuery::setResult() { 130 *target = tmp; 171 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 172 } 173 174 // Doubles Queries 175 176 Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) : 177 Query(title, _description) 178 {} 179 180 Dialog::DoublesQuery::~DoublesQuery() {}; 181 182 void Dialog::DoublesQuery::setResult() { 183 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 131 184 } 132 185 … … 134 187 // Atom Queries 135 188 136 Dialog::AtomQuery::AtomQuery(string title, atom **_target,std::string _description) :189 Dialog::AtomQuery::AtomQuery(string title, std::string _description) : 137 190 Query(title, _description), 138 tmp(0), 139 target(_target) 140 191 tmp(0) 141 192 {} 142 193 … … 144 195 145 196 void Dialog::AtomQuery::setResult() { 146 *target = tmp; 197 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 198 } 199 200 // Atoms Queries 201 202 Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) : 203 Query(title, _description), 204 tmp(0) 205 {} 206 207 Dialog::AtomsQuery::~AtomsQuery() {} 208 209 void Dialog::AtomsQuery::setResult() { 210 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 147 211 } 148 212 149 213 // Molecule Queries 150 214 151 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target,std::string _description) :215 Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) : 152 216 Query(title, _description), 153 tmp(0), 154 target(_target) 155 217 tmp(0) 156 218 {} 157 219 … … 159 221 160 222 void Dialog::MoleculeQuery::setResult() { 161 *target = tmp; 223 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 224 } 225 226 // Molecules Queries 227 228 Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) : 229 Query(title, _description), 230 tmp(0) 231 {} 232 233 Dialog::MoleculesQuery::~MoleculesQuery() {} 234 235 void Dialog::MoleculesQuery::setResult() { 236 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 162 237 } 163 238 164 239 // Vector Queries 165 240 166 Dialog::VectorQuery::VectorQuery(std::string title, Vector *_target,const double *const _cellSize,bool _check, std::string _description) :241 Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) : 167 242 Query(title, _description), 168 cellSize(_cellSize), 169 check(_check), 170 target(_target) 171 { 172 tmp = new Vector(); 173 } 243 check(_check) 244 {} 174 245 175 246 Dialog::VectorQuery::~VectorQuery() 176 { 177 delete tmp; 178 } 247 {} 179 248 180 249 void Dialog::VectorQuery::setResult() { 181 *target = *tmp; 250 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 251 } 252 253 // Vectors Queries 254 255 Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) : 256 Query(title, _description), 257 check(_check) 258 {} 259 260 Dialog::VectorsQuery::~VectorsQuery() 261 {} 262 263 void Dialog::VectorsQuery::setResult() { 264 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 182 265 } 183 266 184 267 // Box Queries 185 268 186 Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) : 187 Query(title, _description), 188 target(_cellSize) 189 { 190 tmp = new double[6]; 191 } 269 Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) : 270 Query(title, _description) 271 {} 192 272 193 273 Dialog::BoxQuery::~BoxQuery() 194 { 195 delete[] tmp; 196 } 274 {} 197 275 198 276 void Dialog::BoxQuery::setResult() { 199 for (int i=0;i<6;i++) { 200 (*target)[i] = tmp[i]; 201 } 277 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 202 278 } 203 279 204 280 // Element Queries 205 Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) : 206 Query(title, _description), 207 target(_target) 281 Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) : 282 Query(title, _description) 208 283 {} 209 284 … … 211 286 212 287 void Dialog::ElementQuery::setResult(){ 213 *target=elements; 214 } 288 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 289 } 290 291 // Elements Queries 292 Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) : 293 Query(title, _description) 294 {} 295 296 Dialog::ElementsQuery::~ElementsQuery(){} 297 298 void Dialog::ElementsQuery::setResult(){ 299 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 300 } -
src/UIElements/Dialog.hpp
r06f4ef6 rb6da28 13 13 #include<vector> 14 14 15 #include "Box.hpp" 16 #include "vector.hpp" 17 15 18 class atom; 19 class Box; 16 20 class element; 17 21 class molecule; 18 class Vector; 19 22 23 24 /** Dialog is one of the two main classes of the UIFactory base class. 25 * 26 * The Dialog is meant for asking the user for information needed to perform actions he 27 * desires, such as asking for a position in space or a length. 28 * 29 * For this purpose there is the base class Query and numerous specializations for each 30 * of the types to be asked. There are primitives integer, doubles and string, but also 31 * advanced types such as element, molecule or Vector. There is also an empty query for 32 * displaying text. 33 */ 20 34 class Dialog 21 35 { … … 25 39 26 40 virtual void queryEmpty(const char *, std::string = "")=0; 27 virtual void queryBoolean(const char *, bool *, std::string = "")=0; 28 virtual void queryInt(const char *, int *, std::string = "")=0; 29 virtual void queryDouble(const char*,double *, std::string = "")=0; 30 virtual void queryString(const char*, std::string *, std::string = "")=0; 31 virtual void queryAtom(const char*,atom**,std::string = "")=0; 32 virtual void queryMolecule(const char*,molecule**, std::string = "")=0; 33 virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0; 34 virtual void queryBox(const char*,double ** const, std::string = "")=0; 35 virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0; 41 virtual void queryBoolean(const char *, std::string = "")=0; 42 virtual void queryInt(const char *, std::string = "")=0; 43 virtual void queryInts(const char *, std::string = "")=0; 44 virtual void queryDouble(const char*, std::string = "")=0; 45 virtual void queryDoubles(const char*, std::string = "")=0; 46 virtual void queryString(const char*, std::string = "")=0; 47 virtual void queryStrings(const char*, std::string = "")=0; 48 virtual void queryAtom(const char*,std::string = "")=0; 49 virtual void queryAtoms(const char*,std::string = "")=0; 50 virtual void queryMolecule(const char*, std::string = "")=0; 51 virtual void queryMolecules(const char*, std::string = "")=0; 52 virtual void queryVector(const char*,bool, std::string = "")=0; 53 virtual void queryVectors(const char*,bool, std::string = "")=0; 54 virtual void queryBox(const char*, std::string = "")=0; 55 virtual void queryElement(const char*, std::string = "")=0; 56 virtual void queryElements(const char*, std::string = "")=0; 36 57 37 58 virtual bool display(); 59 60 virtual bool checkAll(); 61 virtual void setAll(); 62 63 virtual bool hasQueries(); 38 64 39 65 protected: … … 76 102 class BooleanQuery : public Query { 77 103 public: 78 BooleanQuery(std::string title, bool *_target,std::string _description = "");104 BooleanQuery(std::string title, std::string _description = ""); 79 105 virtual ~BooleanQuery(); 80 106 virtual bool handle()=0; … … 82 108 protected: 83 109 bool tmp; 84 private:85 bool *target;86 110 }; 87 111 88 112 class IntQuery : public Query { 89 113 public: 90 IntQuery(std::string title, int *_target,std::string _description = "");114 IntQuery(std::string title, std::string _description = ""); 91 115 virtual ~IntQuery(); 92 116 virtual bool handle()=0; … … 94 118 protected: 95 119 int tmp; 96 private: 97 int *target; 120 }; 121 122 class IntsQuery : public Query { 123 public: 124 IntsQuery(std::string title, std::string _description = ""); 125 virtual ~IntsQuery(); 126 virtual bool handle()=0; 127 virtual void setResult(); 128 protected: 129 int temp; 130 std::vector<int> tmp; 98 131 }; 99 132 100 133 class DoubleQuery : public Query { 101 134 public: 102 DoubleQuery(std::string title, double *_target,std::string _description = "");135 DoubleQuery(std::string title, std::string _description = ""); 103 136 virtual ~DoubleQuery(); 104 137 virtual bool handle()=0; … … 106 139 protected: 107 140 double tmp; 108 private: 109 double *target; 141 }; 142 143 class DoublesQuery : public Query { 144 public: 145 DoublesQuery(std::string title, std::string _description = ""); 146 virtual ~DoublesQuery(); 147 virtual bool handle()=0; 148 virtual void setResult(); 149 protected: 150 double temp; 151 std::vector<double> tmp; 110 152 }; 111 153 112 154 class StringQuery : public Query { 113 155 public: 114 StringQuery(std::string title, std::string *_target,std::string _description = "");156 StringQuery(std::string title, std::string _description = ""); 115 157 virtual ~StringQuery(); 116 158 virtual bool handle()=0; … … 118 160 protected: 119 161 std::string tmp; 120 private: 121 std::string *target; 162 }; 163 164 class StringsQuery : public Query { 165 public: 166 StringsQuery(std::string title, std::string _description = ""); 167 virtual ~StringsQuery(); 168 virtual bool handle()=0; 169 virtual void setResult(); 170 protected: 171 std::string temp; 172 std::vector<std::string> tmp; 122 173 }; 123 174 124 175 class MoleculeQuery : public Query { 125 176 public: 126 MoleculeQuery(std::string title, molecule **_target,std::string _description = "");177 MoleculeQuery(std::string title, std::string _description = ""); 127 178 virtual ~MoleculeQuery(); 128 179 virtual bool handle()=0; … … 130 181 protected: 131 182 molecule *tmp; 132 private: 133 molecule **target; 183 }; 184 185 class MoleculesQuery : public Query { 186 public: 187 MoleculesQuery(std::string title, std::string _description = ""); 188 virtual ~MoleculesQuery(); 189 virtual bool handle()=0; 190 virtual void setResult(); 191 protected: 192 molecule * temp; 193 std::vector<molecule *> tmp; 134 194 }; 135 195 136 196 class AtomQuery : public Query { 137 197 public: 138 AtomQuery(std::string title, atom **_target,std::string _description = "");198 AtomQuery(std::string title, std::string _description = ""); 139 199 virtual ~AtomQuery(); 140 200 virtual bool handle()=0; … … 142 202 protected: 143 203 atom *tmp; 144 private: 145 atom **target; 204 }; 205 206 class AtomsQuery : public Query { 207 public: 208 AtomsQuery(std::string title, std::string _description = ""); 209 virtual ~AtomsQuery(); 210 virtual bool handle()=0; 211 virtual void setResult(); 212 protected: 213 atom *temp; 214 std::vector<atom *> tmp; 146 215 }; 147 216 148 217 class VectorQuery : public Query { 149 218 public: 150 VectorQuery(std::string title, Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");219 VectorQuery(std::string title,bool _check, std::string _description = ""); 151 220 virtual ~VectorQuery(); 152 221 virtual bool handle()=0; 153 222 virtual void setResult(); 154 223 protected: 155 Vector *tmp; 156 const double *const cellSize; 224 Vector tmp; 157 225 bool check; 158 private: 159 Vector *target; 226 }; 227 228 class VectorsQuery : public Query { 229 public: 230 VectorsQuery(std::string title,bool _check, std::string _description = ""); 231 virtual ~VectorsQuery(); 232 virtual bool handle()=0; 233 virtual void setResult(); 234 protected: 235 Vector temp; 236 std::vector<Vector> tmp; 237 bool check; 160 238 }; 161 239 162 240 class BoxQuery : public Query { 163 241 public: 164 BoxQuery(std::string title, double ** const _cellSize,std::string _description = "");242 BoxQuery(std::string title, std::string _description = ""); 165 243 virtual ~BoxQuery(); 166 244 virtual bool handle()=0; 167 245 virtual void setResult(); 168 246 protected: 169 double *tmp; 170 private: 171 double **target; 247 Box tmp; 172 248 }; 173 249 174 250 class ElementQuery : public Query { 175 251 public: 176 ElementQuery(std::string title, std:: vector<element *> *_target, std::string _description = "");252 ElementQuery(std::string title, std::string _description = ""); 177 253 virtual ~ElementQuery(); 178 254 virtual bool handle()=0; 179 255 virtual void setResult(); 180 256 protected: 181 std::vector<element *> elements; 182 private: 183 std::vector<element *> * const target; 257 element * tmp; 258 }; 259 260 class ElementsQuery : public Query { 261 public: 262 ElementsQuery(std::string title, std::string _description = ""); 263 virtual ~ElementsQuery(); 264 virtual bool handle()=0; 265 virtual void setResult(); 266 protected: 267 element *temp; 268 std::vector<element *> tmp; 184 269 }; 185 270 -
src/UIElements/MainWindow.cpp
r06f4ef6 rb6da28 11 11 12 12 MainWindow::MainWindow() 13 { 14 // TODO Auto-generated constructor stub 15 16 } 13 {} 17 14 18 15 MainWindow::~MainWindow() 19 { 20 // TODO Auto-generated destructor stub 21 } 16 {} -
src/UIElements/Makefile.am
r06f4ef6 rb6da28 46 46 Dialog.cpp \ 47 47 MainWindow.cpp \ 48 UIFactory.cpp48 ValueStorage.cpp 49 49 50 50 UIHEADER = \ … … 56 56 Dialog.hpp \ 57 57 MainWindow.hpp \ 58 UIFactory.hpp58 ValueStorage.hpp 59 59 60 60 TEXTUISOURCE = \ … … 80 80 CommandLineUI/CommandLineWindow.hpp 81 81 82 82 unity.cpp: 83 echo "" > unity.cpp; \ 84 list='$(UISOURCE)'; for file in $$list; do \ 85 echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \ 86 done; 87 88 MOSTLYCLEANFILES = unity.cpp -
src/UIElements/Menu/TextMenu.cpp
r06f4ef6 rb6da28 127 127 } 128 128 129 Dialog* TextMenu::LeaveAction::fillDialog(Dialog *dialog){ 130 ASSERT(dialog,"No Dialog given when filling action dialog"); 131 return dialog; 132 } 133 134 129 135 Action::state_ptr TextMenu::LeaveAction::performCall(){ 130 136 menu->doQuit(); -
src/UIElements/Menu/TextMenu.hpp
r06f4ef6 rb6da28 35 35 bool shouldUndo(); 36 36 37 protected: 38 virtual Dialog* fillDialog(Dialog *dialog); 37 39 private: 38 40 virtual Action::state_ptr performCall(); -
src/UIElements/TextUI/TextDialog.cpp
r06f4ef6 rb6da28 14 14 #include <Descriptors/MoleculeDescriptor.hpp> 15 15 #include <Descriptors/MoleculeIdDescriptor.hpp> 16 #include <boost/lexical_cast.hpp> 16 17 #include "TextUI/TextDialog.hpp" 17 18 … … 25 26 #include "molecule.hpp" 26 27 #include "vector.hpp" 28 #include "Matrix.hpp" 29 #include "Box.hpp" 30 31 #include <boost/lexical_cast.hpp> 27 32 28 33 using namespace std; 34 35 using boost::lexical_cast; 36 using boost::bad_lexical_cast; 29 37 30 38 … … 42 50 } 43 51 44 void TextDialog::queryBoolean(const char* title, bool* target, string description){ 45 registerQuery(new BooleanTextQuery(title,target,description)); 46 } 47 48 void TextDialog::queryInt(const char* title, int* target, string description){ 49 registerQuery(new IntTextQuery(title,target,description)); 50 } 51 52 void TextDialog::queryDouble(const char* title, double* target, string description){ 53 registerQuery(new DoubleTextQuery(title,target,description)); 54 } 55 56 void TextDialog::queryString(const char* title, string* target, string description){ 57 registerQuery(new StringTextQuery(title,target,description)); 58 } 59 60 void TextDialog::queryAtom(const char* title, atom **target, string description) { 61 registerQuery(new AtomTextQuery(title,target,description)); 62 } 63 64 void TextDialog::queryMolecule(const char* title, molecule **target, string description) { 65 registerQuery(new MoleculeTextQuery(title,target,description)); 66 } 67 68 void TextDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string description) { 69 registerQuery(new VectorTextQuery(title,target,cellSize,check,description)); 70 } 71 72 void TextDialog::queryBox(const char* title,double ** const cellSize, string description) { 73 registerQuery(new BoxTextQuery(title,cellSize,description)); 74 } 75 76 void TextDialog::queryElement(const char* title, std::vector<element *> *target, string description){ 77 registerQuery(new ElementTextQuery(title,target,description)); 52 void TextDialog::queryBoolean(const char* title, string description){ 53 registerQuery(new BooleanTextQuery(title,description)); 54 } 55 56 void TextDialog::queryInt(const char* title, string description){ 57 registerQuery(new IntTextQuery(title,description)); 58 } 59 60 void TextDialog::queryInts(const char* title, string description){ 61 registerQuery(new IntsTextQuery(title,description)); 62 } 63 64 void TextDialog::queryDouble(const char* title, string description){ 65 registerQuery(new DoubleTextQuery(title,description)); 66 } 67 68 void TextDialog::queryDoubles(const char* title, string description){ 69 registerQuery(new DoublesTextQuery(title,description)); 70 } 71 72 void TextDialog::queryString(const char* title, string description){ 73 registerQuery(new StringTextQuery(title,description)); 74 } 75 76 void TextDialog::queryStrings(const char* title, string description){ 77 registerQuery(new StringsTextQuery(title,description)); 78 } 79 80 void TextDialog::queryAtom(const char* title, string description) { 81 registerQuery(new AtomTextQuery(title,description)); 82 } 83 84 void TextDialog::queryAtoms(const char* title, string description) { 85 registerQuery(new AtomsTextQuery(title,description)); 86 } 87 88 void TextDialog::queryMolecule(const char* title, string description) { 89 registerQuery(new MoleculeTextQuery(title,description)); 90 } 91 92 void TextDialog::queryMolecules(const char* title, string description) { 93 registerQuery(new MoleculesTextQuery(title,description)); 94 } 95 96 void TextDialog::queryVector(const char* title, bool check, string description) { 97 registerQuery(new VectorTextQuery(title,check,description)); 98 } 99 100 void TextDialog::queryVectors(const char* title, bool check, string description) { 101 registerQuery(new VectorsTextQuery(title,check,description)); 102 } 103 104 void TextDialog::queryBox(const char* title, string description) { 105 registerQuery(new BoxTextQuery(title,description)); 106 } 107 108 void TextDialog::queryElement(const char* title, string description){ 109 registerQuery(new ElementTextQuery(title,description)); 110 } 111 112 void TextDialog::queryElements(const char* title, string description){ 113 registerQuery(new ElementsTextQuery(title,description)); 78 114 } 79 115 … … 91 127 } 92 128 93 TextDialog::IntTextQuery::IntTextQuery(string title, int * _target,std::string _description) :94 Dialog::IntQuery(title,_ target,_description)129 TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) : 130 Dialog::IntQuery(title,_description) 95 131 {} 96 132 … … 115 151 } 116 152 117 TextDialog::BooleanTextQuery::BooleanTextQuery(string title, bool * _target, std::string _description) : 118 Dialog::BooleanQuery(title,_target,_description) 153 TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) : 154 Dialog::IntsQuery(title,_description) 155 {} 156 157 TextDialog::IntsTextQuery::~IntsTextQuery() {} 158 159 bool TextDialog::IntsTextQuery::handle() { 160 Log() << Verbose(0) << getTitle(); 161 std::string line; 162 getline(cin,line); 163 // dissect by " " 164 string::iterator olditer = line.begin(); 165 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 166 if (*iter == ' ') { 167 std::istringstream stream(string(iter, olditer)); 168 stream >> temp; 169 tmp.push_back(temp); 170 olditer = iter; 171 } 172 } 173 if (olditer != line.begin()) { // insert last part also 174 std::istringstream stream(string(olditer, line.end())); 175 stream >> temp; 176 tmp.push_back(temp); 177 } 178 179 return true; 180 } 181 182 TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) : 183 Dialog::BooleanQuery(title,_description) 119 184 {} 120 185 … … 144 209 } 145 210 146 TextDialog::StringTextQuery::StringTextQuery(string title, string *_target,std::string _description) :147 Dialog::StringQuery(title,_ target,_description)211 TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) : 212 Dialog::StringQuery(title,_description) 148 213 {} 149 214 … … 156 221 } 157 222 158 TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target, std::string _description) : 159 Dialog::DoubleQuery(title,_target,_description) 223 TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) : 224 Dialog::StringsQuery(title,_description) 225 {} 226 227 TextDialog::StringsTextQuery::~StringsTextQuery() {} 228 229 bool TextDialog::StringsTextQuery::handle() { 230 Log() << Verbose(0) << getTitle(); 231 getline(cin,temp); 232 // dissect by " " 233 string::iterator olditer = temp.begin(); 234 for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) { 235 if (*iter == ' ') { 236 tmp.push_back(string(iter, olditer)); 237 olditer = iter; 238 } 239 } 240 if (olditer != temp.begin()) // insert last part also 241 tmp.push_back(string(olditer, temp.end())); 242 243 return true; 244 } 245 246 TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) : 247 Dialog::DoubleQuery(title,_description) 160 248 {} 161 249 … … 179 267 } 180 268 181 TextDialog::AtomTextQuery::AtomTextQuery(string title, atom **_target, std::string _description) : 182 Dialog::AtomQuery(title,_target,_description) 269 270 TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) : 271 Dialog::DoublesQuery(title,_description) 272 {} 273 274 TextDialog::DoublesTextQuery::~DoublesTextQuery() {} 275 276 bool TextDialog::DoublesTextQuery::handle() { 277 Log() << Verbose(0) << getTitle(); 278 std::string line; 279 getline(cin,line); 280 // dissect by " " 281 string::iterator olditer = line.begin(); 282 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 283 if (*iter == ' ') { 284 std::istringstream stream(string(iter, olditer)); 285 stream >> temp; 286 tmp.push_back(temp); 287 olditer = iter; 288 } 289 } 290 if (olditer != line.begin()) { // insert last part also 291 std::istringstream stream(string(olditer, line.end())); 292 stream >> temp; 293 tmp.push_back(temp); 294 } 295 296 return true; 297 } 298 299 TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) : 300 Dialog::AtomQuery(title,_description) 183 301 {} 184 302 … … 186 304 187 305 bool TextDialog::AtomTextQuery::handle() { 188 int idxOfAtom= 0;306 int idxOfAtom=-1; 189 307 bool badInput = false; 190 308 do{ … … 202 320 tmp = World::getInstance().getAtom(AtomById(idxOfAtom)); 203 321 if(!tmp && idxOfAtom!=-1){ 204 Log() << Verbose(0) << "Invalid Atom Index" << endl;322 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl; 205 323 badInput = true; 206 324 } … … 211 329 } 212 330 213 TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, std::string _description) : 214 Dialog::MoleculeQuery(title,_target,_description) 331 332 TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) : 333 Dialog::AtomsQuery(title,_description) 334 {} 335 336 TextDialog::AtomsTextQuery::~AtomsTextQuery() {} 337 338 bool TextDialog::AtomsTextQuery::handle() { 339 int idxOfAtom=-1; 340 Log() << Verbose(0) << getTitle(); 341 std::string line; 342 getline(cin,line); 343 // dissect by " " 344 string::iterator olditer = line.begin(); 345 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 346 if (*iter == ' ') { 347 std::istringstream stream(string(iter, olditer)); 348 stream >> idxOfAtom; 349 temp = World::getInstance().getAtom(AtomById(idxOfAtom)); 350 if(!temp && idxOfAtom!=-1){ 351 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl; 352 break; 353 } 354 tmp.push_back(temp); 355 olditer = iter; 356 } 357 } 358 if (olditer != line.begin()) { // insert last part also 359 std::istringstream stream(string(olditer, line.end())); 360 stream >> idxOfAtom; 361 temp = World::getInstance().getAtom(AtomById(idxOfAtom)); 362 if(!temp && idxOfAtom!=-1) { 363 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl; 364 tmp.push_back(temp); 365 } 366 } 367 368 return (idxOfAtom!=-1); 369 } 370 371 TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) : 372 Dialog::MoleculeQuery(title,_description) 215 373 {} 216 374 … … 243 401 } 244 402 245 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check, std::string _description) : 246 Dialog::VectorQuery(title,_target,_cellSize,_check,_description) 403 404 TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) : 405 Dialog::MoleculesQuery(title,_description) 406 {} 407 408 TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {} 409 410 bool TextDialog::MoleculesTextQuery::handle() { 411 int idxOfMol=-1; 412 Log() << Verbose(0) << getTitle(); 413 std::string line; 414 getline(cin,line); 415 // dissect by " " 416 string::iterator olditer = line.begin(); 417 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 418 if (*iter == ' ') { 419 std::istringstream stream(string(iter, olditer)); 420 stream >> idxOfMol; 421 temp = World::getInstance().getMolecule(MoleculeById(idxOfMol)); 422 if(!temp && idxOfMol!=-1){ 423 Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl; 424 break; 425 } 426 tmp.push_back(temp); 427 olditer = iter; 428 } 429 } 430 if (olditer != line.begin()) { // insert last part also 431 std::istringstream stream(string(olditer, line.end())); 432 stream >> idxOfMol; 433 temp = World::getInstance().getMolecule(MoleculeById(idxOfMol)); 434 if(!temp && idxOfMol!=-1){ 435 Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl; 436 tmp.push_back(temp); 437 } 438 } 439 440 return (idxOfMol!=-1); 441 } 442 443 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) : 444 Dialog::VectorQuery(title,_check,_description) 247 445 {} 248 446 … … 251 449 252 450 bool TextDialog::VectorTextQuery::handle() { 253 Log() << Verbose(0) << getTitle(); 254 255 char coords[3] = {'x','y','z'}; 256 int j = -1; 257 for (int i=0;i<3;i++) { 258 j += i+1; 259 do { 260 Log() << Verbose(0) << coords[i] << "[0.." << cellSize[j] << "]: "; 261 cin >> (*tmp)[i]; 262 } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= cellSize[j])) && (check)); 263 } 264 return true; 265 } 266 267 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, double ** const _cellSize, std::string _description) : 268 Dialog::BoxQuery(title,_cellSize,_description) 451 std::cout << getTitle(); 452 const Matrix &M = World::getInstance().getDomain().getM(); 453 char coords[3] = {'x', 'y', 'z'}; 454 for (int i=0;i<3;i++) 455 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: "); 456 457 std::string line; 458 getline(cin,line); 459 460 // dissect by "," 461 double coord = 0.; 462 int counter = 0; 463 string::iterator olditer = line.begin(); 464 for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) { 465 if (*iter == ',') { 466 std::istringstream stream(string(iter, olditer)); 467 stream >> coord; 468 tmp[counter++] = coord; 469 olditer = iter; 470 } 471 } 472 if ((olditer != line.begin()) && (counter != 3)) { // insert last part also 473 std::istringstream stream(string(olditer, line.end())); 474 stream >> coord; 475 tmp[counter++] = coord; 476 } 477 478 // check vector 479 return World::getInstance().getDomain().isInside(tmp); 480 } 481 482 TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) : 483 Dialog::VectorsQuery(title,_check,_description) 484 {} 485 486 TextDialog::VectorsTextQuery::~VectorsTextQuery() 487 {} 488 489 bool TextDialog::VectorsTextQuery::handle() { 490 std::cout << getTitle(); 491 char coords[3] = {'x', 'y', 'z'}; 492 const Matrix &M = World::getInstance().getDomain().getM(); 493 for (int i=0;i<3;i++) 494 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: "); 495 496 std::string line; 497 getline(cin,line); 498 499 // dissect by "," 500 double coord = 0.; 501 string::iterator olditerspace = line.begin(); 502 string::iterator olditercomma = line.begin(); 503 int counter = 0; 504 for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) { 505 if (*vectoriter == ',') 506 counter++; 507 if ((*vectoriter == ' ') && (counter == 2)) { 508 counter = 0; 509 for(string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) { 510 if (*componentiter == ',') { 511 std::istringstream stream(string(componentiter, olditercomma)); 512 stream >> coord; 513 temp[counter++] = coord; 514 olditercomma = componentiter; 515 } 516 } 517 if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also 518 std::istringstream stream(string(olditercomma, vectoriter)); 519 stream >> coord; 520 temp[counter++] = coord; 521 } 522 if (World::getInstance().getDomain().isInside(temp)) 523 tmp.push_back(temp); 524 olditerspace = vectoriter; 525 } 526 } 527 return true; 528 } 529 530 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) : 531 Dialog::BoxQuery(title,_description) 269 532 {} 270 533 … … 275 538 Log() << Verbose(0) << getTitle(); 276 539 277 std::string coords[6] = {"xx","xy","xz", "yy", "yz", "zz"}; 540 double temp[6]; 541 std::string coords[6] = {"xx","yx","yy", "zx", "zy", "zz"}; 278 542 for (int i=0;i<6;i++) { 279 543 Log() << Verbose(0) << coords[i] << ": "; 280 cin >> tmp[i]; 281 } 282 return true; 283 } 284 285 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description) : 286 Dialog::ElementQuery(title,_target,_description) 544 cin >> temp[i]; 545 } 546 Matrix M; 547 M.set(0,0, temp[0]); 548 M.set(0,1, temp[1]); 549 M.set(0,2, temp[2]); 550 M.set(1,0, temp[1]); 551 M.set(1,1, temp[3]); 552 M.set(1,2, temp[4]); 553 M.set(2,0, temp[2]); 554 M.set(2,1, temp[4]); 555 M.set(2,2, temp[5]); 556 tmp.setM(M); 557 return true; 558 } 559 560 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) : 561 Dialog::ElementQuery(title,_description) 287 562 {} 288 563 … … 293 568 bool badInput=false; 294 569 bool aborted = false; 295 element * t mp = NULL;570 element * temp = NULL; 296 571 do{ 297 572 badInput = false; … … 306 581 } 307 582 else{ 308 t mp = World::getInstance().getPeriode()->FindElement(Z);309 if(!t mp){583 temp = World::getInstance().getPeriode()->FindElement(Z); 584 if(!temp){ 310 585 Log() << Verbose(0) << "No element with this atomic number!" << endl; 311 586 badInput = true; 312 } else {313 elements.push_back(tmp);314 587 } 315 588 } … … 330 603 } 331 604 else{ 332 t mp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());333 if(!t mp){605 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str()); 606 if(!temp){ 334 607 Log() << Verbose(0) << "No element with this shorthand!" << endl; 335 608 badInput = true; 336 } else {337 elements.push_back(tmp);338 609 } 339 610 } … … 350 621 return !aborted; 351 622 } 623 624 TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) : 625 Dialog::ElementsQuery(title,_description) 626 {} 627 628 TextDialog::ElementsTextQuery::~ElementsTextQuery() 629 {} 630 631 bool TextDialog::ElementsTextQuery::handle() { 632 std::string shorthand; 633 int Z=-1; 634 Log() << Verbose(0) << getTitle(); 635 std::string line; 636 getline(cin,line); 637 // dissect by " " 638 string::iterator olditer = line.begin(); 639 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 640 if (*iter == ' ') { 641 std::istringstream stream(string(iter, olditer)); 642 stream >> shorthand; 643 try { 644 Z = lexical_cast<int>(shorthand); 645 temp = World::getInstance().getPeriode()->FindElement(Z); 646 } catch (bad_lexical_cast) { 647 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str()); 648 }; 649 if(!temp && Z!=-1){ 650 Log() << Verbose(0) << "Invalid Element" << shorthand << endl; 651 break; 652 } 653 tmp.push_back(temp); 654 olditer = iter; 655 } 656 } 657 if (olditer != line.begin()) { // insert last part also 658 std::istringstream stream(string(olditer, line.end())); 659 stream >> shorthand; 660 try { 661 Z = lexical_cast<int>(shorthand); 662 temp = World::getInstance().getPeriode()->FindElement(Z); 663 } catch (bad_lexical_cast) { 664 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str()); 665 }; 666 if(!temp && Z!=-1) { 667 Log() << Verbose(0) << "Invalid Element" << shorthand << endl; 668 tmp.push_back(temp); 669 } 670 } 671 672 return (Z!=-1); 673 } -
src/UIElements/TextUI/TextDialog.hpp
r06f4ef6 rb6da28 25 25 26 26 virtual void queryEmpty(const char *, std::string = ""); 27 virtual void queryBoolean(const char *, bool *, std::string = ""); 28 virtual void queryInt(const char *, int *, std::string = ""); 29 virtual void queryString(const char*, std::string *, std::string = ""); 30 virtual void queryDouble(const char*, double*, std::string = ""); 31 virtual void queryAtom(const char*,atom**,std::string = ""); 32 virtual void queryMolecule(const char*,molecule**,std::string = ""); 33 virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = ""); 34 virtual void queryBox(const char*,double ** const, std::string = ""); 35 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 27 virtual void queryBoolean(const char *, std::string = ""); 28 virtual void queryInt(const char *, std::string = ""); 29 virtual void queryInts(const char *, std::string = ""); 30 virtual void queryString(const char*, std::string = ""); 31 virtual void queryStrings(const char*, std::string = ""); 32 virtual void queryDouble(const char*, std::string = ""); 33 virtual void queryDoubles(const char*, std::string = ""); 34 virtual void queryAtom(const char*,std::string = ""); 35 virtual void queryAtoms(const char*,std::string = ""); 36 virtual void queryMolecule(const char*,std::string = ""); 37 virtual void queryMolecules(const char*,std::string = ""); 38 virtual void queryVector(const char*,bool, std::string = ""); 39 virtual void queryVectors(const char*,bool, std::string = ""); 40 virtual void queryBox(const char*, std::string = ""); 41 virtual void queryElement(const char*, std::string = ""); 42 virtual void queryElements(const char*, std::string = ""); 36 43 37 44 protected: … … 46 53 class BooleanTextQuery : public Dialog::BooleanQuery { 47 54 public: 48 BooleanTextQuery(std::string title, bool *_target,std::string _description = NULL);55 BooleanTextQuery(std::string title, std::string _description = NULL); 49 56 virtual ~BooleanTextQuery(); 50 57 virtual bool handle(); … … 53 60 class IntTextQuery : public Dialog::IntQuery { 54 61 public: 55 IntTextQuery(std::string title, int *_target,std::string _description = NULL);62 IntTextQuery(std::string title, std::string _description = NULL); 56 63 virtual ~IntTextQuery(); 64 virtual bool handle(); 65 }; 66 67 class IntsTextQuery : public Dialog::IntsQuery { 68 public: 69 IntsTextQuery(std::string title, std::string _description = NULL); 70 virtual ~IntsTextQuery(); 57 71 virtual bool handle(); 58 72 }; … … 60 74 class DoubleTextQuery : public Dialog::DoubleQuery { 61 75 public: 62 DoubleTextQuery(std::string title, double *_target,std::string _description = NULL);76 DoubleTextQuery(std::string title, std::string _description = NULL); 63 77 virtual ~DoubleTextQuery(); 78 virtual bool handle(); 79 }; 80 81 class DoublesTextQuery : public Dialog::DoublesQuery { 82 public: 83 DoublesTextQuery(std::string title, std::string _description = NULL); 84 virtual ~DoublesTextQuery(); 64 85 virtual bool handle(); 65 86 }; … … 67 88 class StringTextQuery : public Dialog::StringQuery { 68 89 public: 69 StringTextQuery(std::string title, std::string *_target, std::string_description = NULL);90 StringTextQuery(std::string title, std::string _description = NULL); 70 91 virtual ~StringTextQuery(); 92 virtual bool handle(); 93 }; 94 95 class StringsTextQuery : public Dialog::StringsQuery { 96 public: 97 StringsTextQuery(std::string title, std::string _description = NULL); 98 virtual ~StringsTextQuery(); 71 99 virtual bool handle(); 72 100 }; … … 74 102 class AtomTextQuery : public Dialog::AtomQuery { 75 103 public: 76 AtomTextQuery(std::string title, atom **_target,std::string _description = NULL);104 AtomTextQuery(std::string title, std::string _description = NULL); 77 105 virtual ~AtomTextQuery(); 106 virtual bool handle(); 107 }; 108 109 class AtomsTextQuery : public Dialog::AtomsQuery { 110 public: 111 AtomsTextQuery(std::string title, std::string _description = NULL); 112 virtual ~AtomsTextQuery(); 78 113 virtual bool handle(); 79 114 }; … … 81 116 class MoleculeTextQuery : public Dialog::MoleculeQuery { 82 117 public: 83 MoleculeTextQuery(std::string title, molecule **_target,std::string _description = NULL);118 MoleculeTextQuery(std::string title, std::string _description = NULL); 84 119 virtual ~MoleculeTextQuery(); 120 virtual bool handle(); 121 }; 122 123 class MoleculesTextQuery : public Dialog::MoleculesQuery { 124 public: 125 MoleculesTextQuery(std::string title, std::string _description = NULL); 126 virtual ~MoleculesTextQuery(); 85 127 virtual bool handle(); 86 128 }; … … 88 130 class VectorTextQuery : public Dialog::VectorQuery { 89 131 public: 90 VectorTextQuery(std::string title, Vector *_target,const double *const _cellSize,bool _check, std::string _description = NULL);132 VectorTextQuery(std::string title,bool _check, std::string _description = NULL); 91 133 virtual ~VectorTextQuery(); 134 virtual bool handle(); 135 }; 136 137 class VectorsTextQuery : public Dialog::VectorsQuery { 138 public: 139 VectorsTextQuery(std::string title,bool _check, std::string _description = NULL); 140 virtual ~VectorsTextQuery(); 92 141 virtual bool handle(); 93 142 }; … … 95 144 class BoxTextQuery : public Dialog::BoxQuery { 96 145 public: 97 BoxTextQuery(std::string title, double ** const _cellSize,std::string _description = NULL);146 BoxTextQuery(std::string title, std::string _description = NULL); 98 147 virtual ~BoxTextQuery(); 99 148 virtual bool handle(); … … 102 151 class ElementTextQuery : public Dialog::ElementQuery { 103 152 public: 104 ElementTextQuery(std::string title, std:: vector<element *> *_target, std::string _description = NULL);153 ElementTextQuery(std::string title, std::string _description = NULL); 105 154 virtual ~ElementTextQuery(); 155 virtual bool handle(); 156 }; 157 158 class ElementsTextQuery : public Dialog::ElementsQuery { 159 public: 160 ElementsTextQuery(std::string title, std::string _description = NULL); 161 virtual ~ElementsTextQuery(); 106 162 virtual bool handle(); 107 163 }; -
src/UIElements/TextUI/TextUIFactory.cpp
r06f4ef6 rb6da28 9 9 #include "UIElements/TextUI/TextWindow.hpp" 10 10 #include "UIElements/TextUI/TextDialog.hpp" 11 12 11 13 12 TextUIFactory::TextUIFactory() -
src/UIElements/TextUI/TextUIFactory.hpp
r06f4ef6 rb6da28 13 13 class TextUIFactory : public UIFactory 14 14 { 15 friend class UIFactory;15 friend class UIFactory; 16 16 17 17 public: -
src/UIElements/TextUI/TextWindow.cpp
r06f4ef6 rb6da28 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 #include "TextUI/TextWindow.hpp"11 12 10 #include <boost/bind.hpp> 13 14 15 // TODO: When done with refactoring most of these wont be needed anymore16 #include "analysis_correlation.hpp"17 #include "atom.hpp"18 #include "bond.hpp"19 #include "bondgraph.hpp"20 #include "boundary.hpp"21 #include "config.hpp"22 #include "element.hpp"23 #include "ellipsoid.hpp"24 #include "helpers.hpp"25 #include "leastsquaremin.hpp"26 #include "linkedcell.hpp"27 #include "log.hpp"28 #include "memoryusageobserver.hpp"29 #include "molecule.hpp"30 #include "periodentafel.hpp"31 #include "World.hpp"32 33 #include "Legacy/oldmenu.hpp"34 11 35 12 #include "Menu/Menu.hpp" … … 40 17 #include "Menu/SubMenuItem.hpp" 41 18 #include "TextUI/TextStatusIndicator.hpp" 19 #include "TextUI/TextWindow.hpp" 20 #include "Actions/MapOfActions.hpp" 42 21 #include "Actions/MethodAction.hpp" 43 #include "Actions/MoleculeAction/ChangeNameAction.hpp"44 22 #include "Actions/ErrorAction.hpp" 45 23 #include "Actions/ActionRegistry.hpp" 24 #include "Parser/ChangeTracker.hpp" 46 25 #include "Views/StreamStringView.hpp" 47 26 #include "Views/MethodStringView.hpp" 48 27 28 #include "defs.hpp" 29 #include "log.hpp" 30 #include "verbose.hpp" 31 32 // all needed due to config::SaveAll() 33 #include "config.hpp" 34 #include "periodentafel.hpp" 35 36 // config::SaveAll() and enumerate() 37 #include "molecule.hpp" 38 49 39 #include <iostream> 50 51 using namespace std; 40 #include <map> 52 41 53 42 // TODO: see what code can be moved to a base class for Graphic and Text Windows 54 43 TextWindow::TextWindow() 55 44 { 56 MoleculeListClass *molecules = World::getInstance().getMolecules(); 57 config *configuration = World::getInstance().getConfig(); 58 periodentafel *periode = World::getInstance().getPeriode(); 59 char *ConfigFileName = NULL; 60 old_menu = new oldmenu; 45 map <std::string, TextMenu *> NametoTextMenuMap; 46 47 // populate all actions 48 MapOfActions::getInstance().populateActions(); 61 49 62 50 // build the main menu 63 51 main_menu = new TextMenu(Log() << Verbose(0), "Main Menu"); 64 52 65 moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate, molecules,_1));53 moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,World::getInstance().getMolecules(),_1)); 66 54 new DisplayMenuItem(main_menu,moleculeView,"Molecule List"); 67 55 … … 76 64 new SeperatorItem(main_menu); 77 65 78 Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen, molecules));66 Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,World::getInstance().getMolecules())); 79 67 new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction); 80 68 81 TextMenu *editMoleculesMenu = new TextMenu(Log() << Verbose(0), "Edit Molecules"); 82 new SubMenuItem('e',"edit molecules (load, parse, save)",main_menu,editMoleculesMenu); 83 84 Action *manipulateMoleculeAction = new MethodAction("manipulateMoleculeAction",boost::bind(&oldmenu::ManipulateMolecules,old_menu,periode, molecules, configuration)); 85 new ActionMenuItem('g',"globally manipulate atoms in molecule",main_menu,manipulateMoleculeAction); 86 87 Action *mergeMoleculeAction = new MethodAction("mergeMoleculeAction",boost::bind(&oldmenu::MergeMolecules,old_menu,periode, molecules)); 88 new ActionMenuItem('M',"Merge molecules",main_menu,mergeMoleculeAction); 89 90 Action *manipulateAtomsAction = new MethodAction("manipulateAtomsAction",boost::bind(&oldmenu::ManipulateAtoms,old_menu,periode, molecules, configuration)); 91 new ActionMenuItem('m',"manipulate atoms",main_menu,manipulateAtomsAction); 69 TextMenu *Menu = NULL; 70 std::set <char> ShortcutList; 71 for(map<std::string, pair<std::string,std::string> >::iterator iter = MapOfActions::getInstance().MenuDescription.begin(); iter != MapOfActions::getInstance().MenuDescription.end(); ++iter) { 72 Menu = new TextMenu(Log() << Verbose(0), iter->second.second); 73 NametoTextMenuMap.insert( pair <std::string, TextMenu *> (iter->first, Menu) ); 74 new SubMenuItem(getSuitableShortForm(ShortcutList,iter->first),iter->second.first.c_str(),main_menu,Menu); 75 } 92 76 93 77 new SeperatorItem(main_menu); 94 78 95 Action *editConfigAction = new MethodAction("editConfigAction",boost::bind(&config::Edit,configuration)); 96 new ActionMenuItem('c',"edit the current configuration",main_menu,editConfigAction); 97 98 new SeperatorItem(main_menu); 99 100 Action *saveConfigAction = new MethodAction("saveConfigAction",boost::bind(&config::SaveAll,configuration, ConfigFileName, periode, molecules)); 101 new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction); 102 103 Action *doTestAction = new MethodAction("doTestAction",boost::bind(&oldmenu::testroutine,old_menu,molecules)); 104 new ActionMenuItem('T',"call the current test routine",main_menu,doTestAction); 79 Action *saveConfigAction = ActionRegistry::getInstance().getActionByName("output"); 80 new ActionMenuItem('s',"save current setup to config files",main_menu,saveConfigAction); 105 81 106 82 quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false); 107 83 new ActionMenuItem('q',"quit",main_menu,quitAction); 108 84 109 // call all functions used to build the submenus 110 111 populateEditMoleculesMenu(editMoleculesMenu); 112 113 Action *returnFromEditMoleculeAction = new TextMenu::LeaveAction(editMoleculesMenu); 114 MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",editMoleculesMenu,returnFromEditMoleculeAction); 115 116 editMoleculesMenu->addDefault(returnItem); 85 // go through all menus and create them 86 for (map <std::string, TextMenu *>::iterator MenuRunner = NametoTextMenuMap.begin(); MenuRunner != NametoTextMenuMap.end(); ++MenuRunner) { 87 cout << "Creating Menu " << MenuRunner->first << "." << endl; 88 populateMenu(MenuRunner->second, MenuRunner->first); 89 } 117 90 118 91 // Add status indicators etc... … … 123 96 TextWindow::~TextWindow() 124 97 { 125 delete old_menu;126 98 delete quitAction; 127 99 delete moleculeView; … … 134 106 } 135 107 136 void TextWindow::populateEditMoleculesMenu(Menu* editMoleculesMenu) 108 char TextWindow::getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const 137 109 { 138 MoleculeListClass *molecules = World::getInstance().getMolecules(); 139 periodentafel *periode = World::getInstance().getPeriode(); 110 for (std::string::const_iterator CharRunner = name.begin(); CharRunner != name.end(); ++CharRunner) { 111 if (ShortcutList.find(*CharRunner) == ShortcutList.end()) 112 return *CharRunner; 113 } 114 DoeLog(1) && (eLog() << Verbose(1) << "Could not find a suitable shortform for TextWindow::getSuitableShortForm()." << endl); 115 return ((char)(ShortcutList.size() % 10) + '0'); 116 } 140 117 141 // build the EditMoleculesMenu 142 Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode)); 143 new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction); 144 145 Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode)); 146 new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction); 147 148 Action *changeFilenameAction = new MoleculeChangeNameAction(); 149 new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction); 150 151 Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules)); 152 new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction); 153 154 Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules)); 155 new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction); 156 157 Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules)); 158 new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction); 159 118 void TextWindow::populateMenu(TextMenu* Menu, const std::string &MenuName) 119 { 120 Action *ActionItem = NULL; 121 set <char> ShortcutList; 122 // through all actions for this menu 123 pair < multimap <std::string, std::string>::iterator, multimap <std::string, std::string>::iterator > MenuActions = MapOfActions::getInstance().MenuContainsActionMap.equal_range(MenuName); 124 for (multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) { 125 cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl; 126 ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second); 127 new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),MapOfActions::getInstance().getDescription(MenuRunner->second).c_str(),Menu,ActionItem); 128 } 129 // finally add default quit item 130 Action *returnFromAction = new TextMenu::LeaveAction(Menu); 131 MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction); 132 Menu->addDefault(returnFromItem); 160 133 } -
src/UIElements/TextUI/TextWindow.hpp
r06f4ef6 rb6da28 11 11 #include "MainWindow.hpp" 12 12 13 #include <string> 14 #include <set> 15 13 16 class TextMenu; 14 17 class Action; 15 class oldmenu;16 18 class StringView; 17 19 class TextStatusIndicator; … … 25 27 26 28 virtual void display(); 29 27 30 private: 28 31 // populaters 29 void populateEditMoleculesMenu(Menu* editMoleculesMenu); 32 char getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const; 33 void populateMenu(TextMenu* Menu, const std::string &name); 30 34 31 35 TextMenu *main_menu; … … 36 40 StringView *moleculeView; 37 41 TextStatusIndicator *statusIndicator; 38 39 // This class still contains a lot of scattered functionality40 oldmenu *old_menu;41 42 }; 42 43 -
src/UIElements/UIFactory.cpp
r06f4ef6 rb6da28 12 12 #include "UIElements/UIFactory.hpp" 13 13 #include "Helpers/Assert.hpp" 14 #include "Helpers/MemDebug.hpp" 14 15 15 16 using namespace std; -
src/UIElements/UIFactory.hpp
r06f4ef6 rb6da28 25 25 * only create UIelements of that certain type, so that all UIElements match. This way different 26 26 * UIs can be handled in a concise abstract way. 27 * 28 * The main functionality is the MainWindow and the Dialog. 29 * 30 * MainWindow basically is the framework if the UI. The MainWindow has a run function which is 31 * called MainWindow::Display(), which will listen for user input and react to it via actions for 32 * as long as the user desires or tells the MainWindow to quit. 33 * 34 * Within the MainWindow Dialog classes may be instantiated which ask the user for input to 35 * certain actions he wants to perform. 36 * 27 37 */ 28 38 class UIFactory : public Singleton<UIFactory,false> … … 30 40 friend class Singleton<UIFactory,false>; 31 41 public: 42 32 43 /** 33 44 * Produce some kind of main window, of whichever type was chosen when the factory was created -
src/UIElements/Views/StreamStringView.hpp
r06f4ef6 rb6da28 10 10 11 11 #include <boost/function.hpp> 12 #include <ios tream>12 #include <iosfwd> 13 13 14 14 #include "Views/StringView.hpp" -
src/VectorSet.hpp
r06f4ef6 rb6da28 12 12 #include <functional> 13 13 #include <algorithm> 14 #include <limits> 14 15 15 16 /** … … 19 20 */ 20 21 21 class Vector; 22 #include "vector.hpp" 23 #include <list> 22 24 23 25 // this tests, whether we actually have a Vector … … 48 50 void translate(const Vector &translater){ 49 51 // this is needed to allow template lookup 50 transform(this->begin(),this->end(),this->begin(),bind1st(plus<Vector>(),translater)); 52 transform(this->begin(),this->end(),this->begin(),std::bind1st(std::plus<Vector>(),translater)); 53 } 54 55 double minDistSquared(const Vector &point){ 56 if(!this->size()) 57 return std::numeric_limits<double>::infinity(); 58 std::list<double> helper; 59 helper.resize(this->size()); 60 transform(this->begin(),this->end(), 61 helper.begin(), 62 std::bind2nd(std::mem_fun_ref(&Vector::DistanceSquared),point)); 63 return *min_element(helper.begin(),helper.end()); 51 64 } 52 65 }; 53 66 67 // allows simpler definition of VectorSets 68 #define VECTORSET(container_type) VectorSet<container_type<Vector> > 69 54 70 #endif /* VECTORSET_HPP_ */ -
src/World.cpp
r06f4ef6 rb6da28 10 10 #include "World.hpp" 11 11 12 #include <functional> 13 12 14 #include "atom.hpp" 13 15 #include "config.hpp" 14 16 #include "molecule.hpp" 15 17 #include "periodentafel.hpp" 18 #include "ThermoStatContainer.hpp" 16 19 #include "Descriptors/AtomDescriptor.hpp" 17 20 #include "Descriptors/AtomDescriptor_impl.hpp" … … 20 23 #include "Descriptors/SelectiveIterator_impl.hpp" 21 24 #include "Actions/ManipulateAtomsProcess.hpp" 25 #include "Helpers/Assert.hpp" 26 #include "Box.hpp" 27 #include "Matrix.hpp" 28 #include "defs.hpp" 22 29 23 30 #include "Patterns/Singleton_impl.hpp" 31 #include "Patterns/ObservedContainer_impl.hpp" 24 32 25 33 using namespace std; 34 35 const unsigned int MAX_POOL_FRAGMENTATION=20; 36 const unsigned int MAX_FRAGMENTATION_SKIPS=100; 26 37 27 38 /******************************* getter and setter ************************/ … … 40 51 } 41 52 42 vector<atom*>World::getAllAtoms(AtomDescriptor descriptor){53 World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor){ 43 54 return descriptor.findAll(); 44 55 } 45 56 46 vector<atom*>World::getAllAtoms(){57 World::AtomComposite World::getAllAtoms(){ 47 58 return getAllAtoms(AllAtoms()); 48 59 } … … 72 83 // system 73 84 74 double * World::getDomain() { 75 return cell_size; 85 Box& World::getDomain() { 86 return *cell_size; 87 } 88 89 void World::setDomain(const Matrix &mat){ 90 OBSERVE; 91 *cell_size = mat; 76 92 } 77 93 78 94 void World::setDomain(double * matrix) 79 95 { 80 96 OBSERVE; 97 Matrix M = ReturnFullMatrixforSymmetric(matrix); 98 cell_size->setM(M); 81 99 } 82 100 … … 87 105 void World::setDefaultName(std::string name) 88 106 { 107 OBSERVE; 89 108 defaultName = name; 90 109 }; 110 111 class ThermoStatContainer * World::getThermostats() 112 { 113 return Thermostats; 114 } 115 91 116 92 117 int World::getExitFlag() { … … 105 130 molecule *mol = NULL; 106 131 mol = NewMolecule(); 107 assert(!molecules.count(currMoleculeId)); 108 mol->setId(currMoleculeId++); 132 moleculeId_t id = getNextMoleculeId(); 133 ASSERT(!molecules.count(id),"proposed id did not specify an unused ID"); 134 mol->setId(id); 109 135 // store the molecule by ID 110 136 molecules[mol->getId()] = mol; … … 121 147 OBSERVE; 122 148 molecule *mol = molecules[id]; 123 assert(mol);149 ASSERT(mol,"Molecule id that was meant to be destroyed did not exist"); 124 150 DeleteMolecule(mol); 125 151 molecules.erase(id); 126 } 127 128 double *World::cell_size = NULL; 152 releaseMoleculeId(id); 153 } 129 154 130 155 atom *World::createAtom(){ 131 156 OBSERVE; 132 157 atomId_t id = getNextAtomId(); 158 ASSERT(!atoms.count(id),"proposed id did not specify an unused ID"); 133 159 atom *res = NewAtom(id); 134 160 res->setWorld(this); … … 157 183 OBSERVE; 158 184 atom *atom = atoms[id]; 159 assert(atom);185 ASSERT(atom,"Atom ID that was meant to be destroyed did not exist"); 160 186 DeleteAtom(atom); 161 187 atoms.erase(id); … … 169 195 if(!target){ 170 196 target = atoms[oldId]; 171 assert(target &&"Atom with that ID not found");197 ASSERT(target,"Atom with that ID not found"); 172 198 return target->changeId(newId); 173 199 } … … 207 233 208 234 atomId_t World::getNextAtomId(){ 209 // see if we can reuse some Id 210 if(atomIdPool.empty()){ 211 return currAtomId++; 212 } 213 else{ 214 // we give out the first ID from the pool 215 atomId_t id = *(atomIdPool.begin()); 216 atomIdPool.erase(id); 235 // try to find an Id in the pool; 236 if(!atomIdPool.empty()){ 237 atomIdPool_t::iterator iter=atomIdPool.begin(); 238 atomId_t id = iter->first; 239 range<atomId_t> newRange = makeRange(id+1,iter->last); 240 // we wont use this iterator anymore, so we don't care about invalidating 241 atomIdPool.erase(iter); 242 if(newRange.first<newRange.last){ 243 atomIdPool.insert(newRange); 244 } 217 245 return id; 218 246 } 247 // Nothing in the pool... we are out of luck 248 return currAtomId++; 219 249 } 220 250 221 251 void World::releaseAtomId(atomId_t id){ 222 atomIdPool.insert(id); 223 // defragmentation of the pool 224 set<atomId_t>::reverse_iterator iter; 225 // go through all Ids in the pool that lie immediately below the border 226 while(!atomIdPool.empty() && *(atomIdPool.rbegin())==(currAtomId-1)){ 227 atomIdPool.erase(--currAtomId); 228 } 252 atomIdPool.insert(makeRange(id,id+1)); 253 defragAtomIdPool(); 229 254 } 230 255 231 256 bool World::reserveAtomId(atomId_t id){ 232 257 if(id>=currAtomId ){ 233 // add all ids between the new one and current border as available234 for(atomId_t pos=currAtomId; pos<id; ++pos){235 atomIdPool.insert( pos);258 range<atomId_t> newRange = makeRange(currAtomId,id); 259 if(newRange.first<newRange.last){ 260 atomIdPool.insert(newRange); 236 261 } 237 262 currAtomId=id+1; 263 defragAtomIdPool(); 238 264 return true; 239 265 } 240 else if(atomIdPool.count(id)){ 241 atomIdPool.erase(id); 266 // look for a range that matches the request 267 for(atomIdPool_t::iterator iter=atomIdPool.begin();iter!=atomIdPool.end();++iter){ 268 if(iter->isBefore(id)){ 269 // we have covered all available ranges... nothing to be found here 270 break; 271 } 272 // no need to check first, since it has to be <=id, since otherwise we would have broken out 273 if(!iter->isBeyond(id)){ 274 // we found a matching range... get the id from this range 275 276 // split up this range at the point of id 277 range<atomId_t> bottomRange = makeRange(iter->first,id); 278 range<atomId_t> topRange = makeRange(id+1,iter->last); 279 // remove this range 280 atomIdPool.erase(iter); 281 if(bottomRange.first<bottomRange.last){ 282 atomIdPool.insert(bottomRange); 283 } 284 if(topRange.first<topRange.last){ 285 atomIdPool.insert(topRange); 286 } 287 defragAtomIdPool(); 288 return true; 289 } 290 } 291 // this ID could not be reserved 292 return false; 293 } 294 295 void World::defragAtomIdPool(){ 296 // check if the situation is bad enough to make defragging neccessary 297 if((numAtomDefragSkips<MAX_FRAGMENTATION_SKIPS) && 298 (atomIdPool.size()<lastAtomPoolSize+MAX_POOL_FRAGMENTATION)){ 299 ++numAtomDefragSkips; 300 return; 301 } 302 for(atomIdPool_t::iterator iter = atomIdPool.begin();iter!=atomIdPool.end();){ 303 // see if this range is adjacent to the next one 304 atomIdPool_t::iterator next = iter; 305 next++; 306 if(next!=atomIdPool.end() && (next->first==iter->last)){ 307 // merge the two ranges 308 range<atomId_t> newRange = makeRange(iter->first,next->last); 309 atomIdPool.erase(iter); 310 atomIdPool.erase(next); 311 pair<atomIdPool_t::iterator,bool> res = atomIdPool.insert(newRange); 312 ASSERT(res.second,"Id-Pool was confused"); 313 iter=res.first; 314 continue; 315 } 316 ++iter; 317 } 318 if(!atomIdPool.empty()){ 319 // check if the last range is at the border 320 atomIdPool_t::iterator iter = atomIdPool.end(); 321 iter--; 322 if(iter->last==currAtomId){ 323 currAtomId=iter->first; 324 atomIdPool.erase(iter); 325 } 326 } 327 lastAtomPoolSize=atomIdPool.size(); 328 numAtomDefragSkips=0; 329 } 330 331 // Molecules 332 333 moleculeId_t World::getNextMoleculeId(){ 334 // try to find an Id in the pool; 335 if(!moleculeIdPool.empty()){ 336 moleculeIdPool_t::iterator iter=moleculeIdPool.begin(); 337 moleculeId_t id = iter->first; 338 range<moleculeId_t> newRange = makeRange(id+1,iter->last); 339 // we wont use this iterator anymore, so we don't care about invalidating 340 moleculeIdPool.erase(iter); 341 if(newRange.first<newRange.last){ 342 moleculeIdPool.insert(newRange); 343 } 344 return id; 345 } 346 // Nothing in the pool... we are out of luck 347 return currMoleculeId++; 348 } 349 350 void World::releaseMoleculeId(moleculeId_t id){ 351 moleculeIdPool.insert(makeRange(id,id+1)); 352 defragMoleculeIdPool(); 353 } 354 355 bool World::reserveMoleculeId(moleculeId_t id){ 356 if(id>=currMoleculeId ){ 357 range<moleculeId_t> newRange = makeRange(currMoleculeId,id); 358 if(newRange.first<newRange.last){ 359 moleculeIdPool.insert(newRange); 360 } 361 currMoleculeId=id+1; 362 defragMoleculeIdPool(); 242 363 return true; 243 364 } 244 else{ 245 // this ID could not be reserved 246 return false; 247 } 248 } 365 // look for a range that matches the request 366 for(moleculeIdPool_t::iterator iter=moleculeIdPool.begin();iter!=moleculeIdPool.end();++iter){ 367 if(iter->isBefore(id)){ 368 // we have coverd all available ranges... nothing to be found here 369 break; 370 } 371 // no need to check first, since it has to be <=id, since otherwise we would have broken out 372 if(!iter->isBeyond(id)){ 373 // we found a matching range... get the id from this range 374 375 // split up this range at the point of id 376 range<moleculeId_t> bottomRange = makeRange(iter->first,id); 377 range<moleculeId_t> topRange = makeRange(id+1,iter->last); 378 // remove this range 379 moleculeIdPool.erase(iter); 380 if(bottomRange.first<bottomRange.last){ 381 moleculeIdPool.insert(bottomRange); 382 } 383 if(topRange.first<topRange.last){ 384 moleculeIdPool.insert(topRange); 385 } 386 defragMoleculeIdPool(); 387 return true; 388 } 389 } 390 // this ID could not be reserved 391 return false; 392 } 393 394 void World::defragMoleculeIdPool(){ 395 // check if the situation is bad enough to make defragging neccessary 396 if((numMoleculeDefragSkips<MAX_FRAGMENTATION_SKIPS) && 397 (moleculeIdPool.size()<lastMoleculePoolSize+MAX_POOL_FRAGMENTATION)){ 398 ++numMoleculeDefragSkips; 399 return; 400 } 401 for(moleculeIdPool_t::iterator iter = moleculeIdPool.begin();iter!=moleculeIdPool.end();){ 402 // see if this range is adjacent to the next one 403 moleculeIdPool_t::iterator next = iter; 404 next++; 405 if(next!=moleculeIdPool.end() && (next->first==iter->last)){ 406 // merge the two ranges 407 range<moleculeId_t> newRange = makeRange(iter->first,next->last); 408 moleculeIdPool.erase(iter); 409 moleculeIdPool.erase(next); 410 pair<moleculeIdPool_t::iterator,bool> res = moleculeIdPool.insert(newRange); 411 ASSERT(res.second,"Id-Pool was confused"); 412 iter=res.first; 413 continue; 414 } 415 ++iter; 416 } 417 if(!moleculeIdPool.empty()){ 418 // check if the last range is at the border 419 moleculeIdPool_t::iterator iter = moleculeIdPool.end(); 420 iter--; 421 if(iter->last==currMoleculeId){ 422 currMoleculeId=iter->first; 423 moleculeIdPool.erase(iter); 424 } 425 } 426 lastMoleculePoolSize=moleculeIdPool.size(); 427 numMoleculeDefragSkips=0; 428 } 429 430 /******************************* Iterators ********************************/ 431 432 // external parts with observers 433 434 CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor); 435 436 World::AtomIterator 437 World::getAtomIter(AtomDescriptor descr){ 438 return AtomIterator(descr,atoms); 439 } 440 441 World::AtomIterator 442 World::getAtomIter(){ 443 return AtomIterator(AllAtoms(),atoms); 444 } 445 446 World::AtomIterator 447 World::atomEnd(){ 448 return AtomIterator(AllAtoms(),atoms,atoms.end()); 449 } 450 451 CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor); 452 453 World::MoleculeIterator 454 World::getMoleculeIter(MoleculeDescriptor descr){ 455 return MoleculeIterator(descr,molecules); 456 } 457 458 World::MoleculeIterator 459 World::getMoleculeIter(){ 460 return MoleculeIterator(AllMolecules(),molecules); 461 } 462 463 World::MoleculeIterator 464 World::moleculeEnd(){ 465 return MoleculeIterator(AllMolecules(),molecules,molecules.end()); 466 } 467 468 // Internal parts, without observers 469 470 // Build the AtomIterator from template 471 CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet::set_t,AtomDescriptor); 472 473 474 World::internal_AtomIterator 475 World::getAtomIter_internal(AtomDescriptor descr){ 476 return internal_AtomIterator(descr,atoms.getContent()); 477 } 478 479 World::internal_AtomIterator 480 World::atomEnd_internal(){ 481 return internal_AtomIterator(AllAtoms(),atoms.getContent(),atoms.end_internal()); 482 } 483 484 // build the MoleculeIterator from template 485 CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet::set_t,MoleculeDescriptor); 486 487 World::internal_MoleculeIterator World::getMoleculeIter_internal(MoleculeDescriptor descr){ 488 return internal_MoleculeIterator(descr,molecules.getContent()); 489 } 490 491 World::internal_MoleculeIterator World::moleculeEnd_internal(){ 492 return internal_MoleculeIterator(AllMolecules(),molecules.getContent(),molecules.end_internal()); 493 } 494 495 /************************** Selection of Atoms and molecules ******************/ 496 497 // Atoms 498 499 void World::clearAtomSelection(){ 500 selectedAtoms.clear(); 501 } 502 503 void World::selectAtom(atom *atom){ 504 ASSERT(atom,"Invalid pointer in selection of atom"); 505 selectedAtoms[atom->getId()]=atom; 506 } 507 508 void World::selectAtom(atomId_t id){ 509 ASSERT(atoms.count(id),"Atom Id selected that was not in the world"); 510 selectedAtoms[id]=atoms[id]; 511 } 512 513 void World::selectAllAtoms(AtomDescriptor descr){ 514 internal_AtomIterator begin = getAtomIter_internal(descr); 515 internal_AtomIterator end = atomEnd_internal(); 516 void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function 517 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above 518 } 519 520 void World::selectAtomsOfMolecule(molecule *_mol){ 521 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule"); 522 // need to make it const to get the fast iterators 523 const molecule *mol = _mol; 524 void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function 525 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above 526 } 527 528 void World::selectAtomsOfMolecule(moleculeId_t id){ 529 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule"); 530 selectAtomsOfMolecule(molecules[id]); 531 } 532 533 void World::unselectAtom(atom *atom){ 534 ASSERT(atom,"Invalid pointer in unselection of atom"); 535 unselectAtom(atom->getId()); 536 } 537 538 void World::unselectAtom(atomId_t id){ 539 ASSERT(atoms.count(id),"Atom Id unselected that was not in the world"); 540 selectedAtoms.erase(id); 541 } 542 543 void World::unselectAllAtoms(AtomDescriptor descr){ 544 internal_AtomIterator begin = getAtomIter_internal(descr); 545 internal_AtomIterator end = atomEnd_internal(); 546 void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function 547 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above 548 } 549 550 void World::unselectAtomsOfMolecule(molecule *_mol){ 551 ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule"); 552 // need to make it const to get the fast iterators 553 const molecule *mol = _mol; 554 void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function 555 for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above 556 } 557 558 void World::unselectAtomsOfMolecule(moleculeId_t id){ 559 ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule"); 560 unselectAtomsOfMolecule(molecules[id]); 561 } 562 563 size_t World::countSelectedAtoms() const { 564 size_t count = 0; 565 for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) 566 count++; 567 return count; 568 } 569 570 bool World::isSelected(atom *atom) const { 571 return selectedAtoms.find(atom->getId()) != selectedAtoms.end(); 572 } 573 574 const std::vector<atom *> World::getSelectedAtoms() const { 575 std::vector<atom *> returnAtoms; 576 returnAtoms.resize(countSelectedAtoms()); 577 int count = 0; 578 for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) 579 returnAtoms[count++] = iter->second; 580 return returnAtoms; 581 } 582 249 583 250 584 // Molecules 251 585 252 /******************************* Iterators ********************************/ 253 254 // Build the AtomIterator from template 255 CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor); 256 257 258 World::AtomIterator World::getAtomIter(AtomDescriptor descr){ 259 return AtomIterator(descr,atoms); 260 } 261 262 World::AtomIterator World::atomEnd(){ 263 return AtomIterator(AllAtoms(),atoms,atoms.end()); 264 } 265 266 // build the MoleculeIterator from template 267 CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor); 268 269 World::MoleculeIterator World::getMoleculeIter(MoleculeDescriptor descr){ 270 return MoleculeIterator(descr,molecules); 271 } 272 273 World::MoleculeIterator World::moleculeEnd(){ 274 return MoleculeIterator(AllMolecules(),molecules,molecules.end()); 586 void World::clearMoleculeSelection(){ 587 selectedMolecules.clear(); 588 } 589 590 void World::selectMolecule(molecule *mol){ 591 ASSERT(mol,"Invalid pointer to molecule in selection"); 592 selectedMolecules[mol->getId()]=mol; 593 } 594 595 void World::selectMolecule(moleculeId_t id){ 596 ASSERT(molecules.count(id),"Molecule Id selected that was not in the world"); 597 selectedMolecules[id]=molecules[id]; 598 } 599 600 void World::selectAllMolecules(MoleculeDescriptor descr){ 601 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 602 internal_MoleculeIterator end = moleculeEnd_internal(); 603 void (World::*func)(molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function 604 for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above 605 } 606 607 void World::selectMoleculeOfAtom(atom *atom){ 608 ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom"); 609 molecule *mol=atom->getMolecule(); 610 // the atom might not be part of a molecule 611 if(mol){ 612 selectMolecule(mol); 613 } 614 } 615 616 void World::selectMoleculeOfAtom(atomId_t id){ 617 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\ 618 selectMoleculeOfAtom(atoms[id]); 619 } 620 621 void World::unselectMolecule(molecule *mol){ 622 ASSERT(mol,"invalid pointer in unselection of molecule"); 623 unselectMolecule(mol->getId()); 624 } 625 626 void World::unselectMolecule(moleculeId_t id){ 627 ASSERT(molecules.count(id),"No such molecule with ID in unselection"); 628 selectedMolecules.erase(id); 629 } 630 631 void World::unselectAllMolecules(MoleculeDescriptor descr){ 632 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 633 internal_MoleculeIterator end = moleculeEnd_internal(); 634 void (World::*func)(molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function 635 for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above 636 } 637 638 void World::unselectMoleculeOfAtom(atom *atom){ 639 ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom"); 640 molecule *mol=atom->getMolecule(); 641 // the atom might not be part of a molecule 642 if(mol){ 643 unselectMolecule(mol); 644 } 645 } 646 647 void World::unselectMoleculeOfAtom(atomId_t id){ 648 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\ 649 unselectMoleculeOfAtom(atoms[id]); 650 } 651 652 size_t World::countSelectedMolecules() const { 653 size_t count = 0; 654 for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter) 655 count++; 656 return count; 657 } 658 659 bool World::isSelected(molecule *mol) const { 660 return selectedMolecules.find(mol->getId()) != selectedMolecules.end(); 661 } 662 663 const std::vector<molecule *> World::getSelectedMolecules() const { 664 std::vector<molecule *> returnMolecules; 665 returnMolecules.resize(countSelectedMolecules()); 666 int count = 0; 667 for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter) 668 returnMolecules[count++] = iter->second; 669 return returnMolecules; 670 } 671 672 /******************* Iterators over Selection *****************************/ 673 World::AtomSelectionIterator World::beginAtomSelection(){ 674 return selectedAtoms.begin(); 675 } 676 677 World::AtomSelectionIterator World::endAtomSelection(){ 678 return selectedAtoms.end(); 679 } 680 681 682 World::MoleculeSelectionIterator World::beginMoleculeSelection(){ 683 return selectedMolecules.begin(); 684 } 685 686 World::MoleculeSelectionIterator World::endMoleculeSelection(){ 687 return selectedMolecules.end(); 275 688 } 276 689 … … 281 694 periode(new periodentafel), 282 695 configuration(new config), 696 Thermostats(new ThermoStatContainer), 283 697 ExitFlag(0), 284 atoms(), 698 atoms(this), 699 selectedAtoms(this), 285 700 currAtomId(0), 286 molecules(), 701 lastAtomPoolSize(0), 702 numAtomDefragSkips(0), 703 molecules(this), 704 selectedMolecules(this), 287 705 currMoleculeId(0), 288 706 molecules_deprecated(new MoleculeListClass(this)) 289 707 { 290 cell_size = new double[6]; 291 cell_size[0] = 20.; 292 cell_size[1] = 0.; 293 cell_size[2] = 20.; 294 cell_size[3] = 0.; 295 cell_size[4] = 0.; 296 cell_size[5] = 20.; 708 cell_size = new Box; 709 Matrix domain; 710 domain.at(0,0) = 20; 711 domain.at(1,1) = 20; 712 domain.at(2,2) = 20; 713 cell_size->setM(domain); 297 714 defaultName = "none"; 298 715 molecules_deprecated->signOn(this); … … 302 719 { 303 720 molecules_deprecated->signOff(this); 304 delete []cell_size;721 delete cell_size; 305 722 delete molecules_deprecated; 306 delete periode;307 delete configuration;308 723 MoleculeSet::iterator molIter; 309 724 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ … … 316 731 } 317 732 atoms.clear(); 733 delete periode; 734 delete configuration; 735 delete Thermostats; 318 736 } 319 737 -
src/World.hpp
r06f4ef6 rb6da28 23 23 #include "Patterns/Cacheable.hpp" 24 24 #include "Patterns/Singleton.hpp" 25 #include "Patterns/ObservedContainer.hpp" 26 #include "Helpers/Range.hpp" 27 #include "AtomSet.hpp" 25 28 26 29 // include config.h … … 30 33 31 34 // forward declarations 32 class config;33 class periodentafel;34 class MoleculeListClass;35 35 class atom; 36 class molecule;37 36 class AtomDescriptor; 38 37 class AtomDescriptor_impl; 38 template<typename T> class AtomsCalculation; 39 class Box; 40 class config; 41 class ManipulateAtomsProcess; 42 class Matrix; 43 class molecule; 39 44 class MoleculeDescriptor; 40 45 class MoleculeDescriptor_impl; 41 class ManipulateAtomsProcess; 42 template<typename T> 43 class AtomsCalculation; 46 class MoleculeListClass; 47 class periodentafel; 48 class ThermoStatContainer; 49 44 50 45 51 /****************************************** forward declarations *****************************/ … … 58 64 friend class MoleculeDescriptor_impl; 59 65 friend class MoleculeDescriptor; 66 // coupling with descriptors over selection 67 friend class AtomSelectionDescriptor_impl; 68 friend class MoleculeSelectionDescriptor_impl; 60 69 61 70 // Actions, calculations etc associated with the World … … 65 74 66 75 // Types for Atom and Molecule structures 67 typedef std::map<atomId_t,atom*> AtomSet; 68 typedef std::map<moleculeId_t,molecule*> MoleculeSet; 76 typedef ObservedContainer<std::map<atomId_t,atom*> > AtomSet; 77 typedef ObservedContainer<std::map<moleculeId_t,molecule*> > MoleculeSet; 78 79 typedef ATOMSET(std::vector) AtomComposite; 69 80 70 81 /***** getter and setter *****/ … … 89 100 * returns a vector containing all atoms that match a given descriptor 90 101 */ 91 std::vector<atom*>getAllAtoms(AtomDescriptor descriptor);92 std::vector<atom*>getAllAtoms();102 AtomComposite getAllAtoms(AtomDescriptor descriptor); 103 AtomComposite getAllAtoms(); 93 104 94 105 /** … … 125 136 * get the domain size as a symmetric matrix (6 components) 126 137 */ 127 double * getDomain(); 138 Box& getDomain(); 139 140 /** 141 * Set the domain size from a matrix object 142 * 143 * Matrix needs to be symmetric 144 */ 145 void setDomain(const Matrix &mat); 128 146 129 147 /** … … 141 159 */ 142 160 void setDefaultName(std::string name); 161 162 /** 163 * get pointer to World's ThermoStatContainer 164 */ 165 ThermoStatContainer * getThermostats(); 143 166 144 167 /* … … 202 225 ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string); 203 226 227 /**** 228 * Iterators to use internal data structures 229 * All these iterators are observed to track changes. 230 * There is a corresponding protected section with unobserved iterators, 231 * which can be used internally when the extra speed is needed 232 */ 233 234 typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator; 235 236 /** 237 * returns an iterator over all Atoms matching a given descriptor. 238 * This iterator is observed, so don't keep it around unnecessary to 239 * avoid unintended blocking. 240 */ 241 AtomIterator getAtomIter(AtomDescriptor descr); 242 AtomIterator getAtomIter(); 243 244 AtomIterator atomEnd(); 245 246 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator; 247 248 /** 249 * returns an iterator over all Molecules matching a given descriptor. 250 * This iterator is observed, so don't keep it around unnecessary to 251 * avoid unintended blocking. 252 */ 253 MoleculeIterator getMoleculeIter(MoleculeDescriptor descr); 254 MoleculeIterator getMoleculeIter(); 255 256 MoleculeIterator moleculeEnd(); 257 258 /******** Selections of molecules and Atoms *************/ 259 void clearAtomSelection(); 260 void selectAtom(atom*); 261 void selectAtom(atomId_t); 262 void selectAllAtoms(AtomDescriptor); 263 void selectAtomsOfMolecule(molecule*); 264 void selectAtomsOfMolecule(moleculeId_t); 265 void unselectAtom(atom*); 266 void unselectAtom(atomId_t); 267 void unselectAllAtoms(AtomDescriptor); 268 void unselectAtomsOfMolecule(molecule*); 269 void unselectAtomsOfMolecule(moleculeId_t); 270 size_t countSelectedAtoms() const; 271 bool isSelected(atom *_atom) const; 272 const std::vector<atom *> getSelectedAtoms() const; 273 274 void clearMoleculeSelection(); 275 void selectMolecule(molecule*); 276 void selectMolecule(moleculeId_t); 277 void selectAllMolecules(MoleculeDescriptor); 278 void selectMoleculeOfAtom(atom*); 279 void selectMoleculeOfAtom(atomId_t); 280 void unselectMolecule(molecule*); 281 void unselectMolecule(moleculeId_t); 282 void unselectAllMolecules(MoleculeDescriptor); 283 void unselectMoleculeOfAtom(atom*); 284 void unselectMoleculeOfAtom(atomId_t); 285 size_t countSelectedMolecules() const; 286 bool isSelected(molecule *_mol) const; 287 const std::vector<molecule *> getSelectedMolecules() const; 288 289 /******************** Iterators to selections *****************/ 290 typedef AtomSet::iterator AtomSelectionIterator; 291 AtomSelectionIterator beginAtomSelection(); 292 AtomSelectionIterator endAtomSelection(); 293 294 typedef MoleculeSet::iterator MoleculeSelectionIterator; 295 MoleculeSelectionIterator beginMoleculeSelection(); 296 MoleculeSelectionIterator endMoleculeSelection(); 297 204 298 protected: 205 /**** Iterators to use internal data structures */ 299 /**** 300 * Iterators to use internal data structures 301 * All these iterators are unobserved for speed reasons. 302 * There is a corresponding public section to these methods, 303 * which produce observed iterators.*/ 206 304 207 305 // Atoms 208 typedef SelectiveIterator<atom*,AtomSet ,AtomDescriptor>AtomIterator;306 typedef SelectiveIterator<atom*,AtomSet::set_t,AtomDescriptor> internal_AtomIterator; 209 307 210 308 /** … … 212 310 * used for internal purposes, like AtomProcesses and AtomCalculations. 213 311 */ 214 AtomIterator getAtomIter(AtomDescriptor descr);312 internal_AtomIterator getAtomIter_internal(AtomDescriptor descr); 215 313 216 314 /** … … 220 318 * used for internal purposes, like AtomProcesses and AtomCalculations. 221 319 */ 222 AtomIterator atomEnd();320 internal_AtomIterator atomEnd_internal(); 223 321 224 322 // Molecules 225 226 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator; 323 typedef SelectiveIterator<molecule*,MoleculeSet::set_t,MoleculeDescriptor> internal_MoleculeIterator; 324 227 325 228 326 /** … … 230 328 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. 231 329 */ 232 MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);330 internal_MoleculeIterator getMoleculeIter_internal(MoleculeDescriptor descr); 233 331 234 332 /** … … 238 336 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. 239 337 */ 240 MoleculeIterator moleculeEnd();338 internal_MoleculeIterator moleculeEnd_internal(); 241 339 242 340 … … 249 347 void releaseAtomId(atomId_t); 250 348 bool reserveAtomId(atomId_t); 349 void defragAtomIdPool(); 350 351 moleculeId_t getNextMoleculeId(); 352 void releaseMoleculeId(moleculeId_t); 353 bool reserveMoleculeId(moleculeId_t); 354 void defragMoleculeIdPool(); 251 355 252 356 periodentafel *periode; 253 357 config *configuration; 254 static double*cell_size;358 Box *cell_size; 255 359 std::string defaultName; 360 class ThermoStatContainer *Thermostats; 256 361 int ExitFlag; 257 public: 362 private: 363 258 364 AtomSet atoms; 259 private: 260 std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId 365 AtomSet selectedAtoms; 366 typedef std::set<range<atomId_t> > atomIdPool_t; 367 /** 368 * stores the pool for all available AtomIds below currAtomId 369 * 370 * The pool contains ranges of free ids in the form [bottom,top). 371 */ 372 atomIdPool_t atomIdPool; 261 373 atomId_t currAtomId; //!< stores the next available Id for atoms 374 size_t lastAtomPoolSize; //!< size of the pool after last defrag, to skip some defrags 375 unsigned int numAtomDefragSkips; 376 262 377 MoleculeSet molecules; 378 MoleculeSet selectedMolecules; 379 typedef std::set<range<atomId_t> > moleculeIdPool_t; 380 /** 381 * stores the pool for all available AtomIds below currAtomId 382 * 383 * The pool contains ranges of free ids in the form [bottom,top). 384 */ 385 moleculeIdPool_t moleculeIdPool; 263 386 moleculeId_t currMoleculeId; 387 size_t lastMoleculePoolSize; //!< size of the pool after last defrag, to skip some defrags 388 unsigned int numMoleculeDefragSkips; 264 389 private: 265 390 /** -
src/analysis_bonds.cpp
r06f4ef6 rb6da28 13 13 #include "element.hpp" 14 14 #include "info.hpp" 15 #include "verbose.hpp" 15 16 #include "log.hpp" 16 17 #include "molecule.hpp" … … 121 122 * \param *molecules molecules to count bonds 122 123 * \param *InterfaceElement or NULL 123 */ 124 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL) 124 * \param *Interface2Element or NULL 125 */ 126 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL, const element * Interface2Element = NULL) 125 127 { 126 128 int count = 0; … … 128 130 double Otherangle = 0.; 129 131 bool InterfaceFlag = false; 132 bool Interface2Flag = false; 130 133 bool OtherHydrogenFlag = true; 131 134 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) { … … 145 148 OtherHydrogens = 0; 146 149 InterfaceFlag = (InterfaceElement == NULL); 150 Interface2Flag = (Interface2Element == NULL); 147 151 for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) { 148 152 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner); … … 155 159 } 156 160 InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement); 161 Interface2Flag = Interface2Flag || (OtherAtom->type == Interface2Element); 157 162 } 158 163 DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl); … … 168 173 break; 169 174 } 170 if (InterfaceFlag && OtherHydrogenFlag) {175 if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) { 171 176 // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule 172 177 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) { -
src/analysis_bonds.hpp
r06f4ef6 rb6da28 33 33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max); 34 34 35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement );35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement, const element * Interface2Element); 36 36 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second); 37 37 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third); -
src/analysis_correlation.cpp
r06f4ef6 rb6da28 9 9 10 10 #include <iostream> 11 #include <iomanip> 11 12 12 13 #include "analysis_correlation.hpp" … … 19 20 #include "triangleintersectionlist.hpp" 20 21 #include "vector.hpp" 22 #include "Matrix.hpp" 21 23 #include "verbose.hpp" 22 24 #include "World.hpp" 25 #include "Box.hpp" 23 26 24 27 25 28 /** Calculates the pair correlation between given elements. 26 29 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) 27 * \param *molecules list of molecules structure30 * \param *molecules vector of molecules 28 31 * \param &elements vector of elements to correlate 29 32 * \return Map of doubles with values the pair of the two atoms. 30 33 */ 31 PairCorrelationMap *PairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements)34 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements) 32 35 { 33 36 Info FunctionInfo(__func__); 34 37 PairCorrelationMap *outmap = NULL; 35 38 double distance = 0.; 36 double *domain = World::getInstance().getDomain();37 38 if (molecules ->ListOfMolecules.empty()) {39 Box &domain = World::getInstance().getDomain(); 40 41 if (molecules.empty()) { 39 42 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 40 43 return outmap; 41 44 } 42 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)45 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 43 46 (*MolWalker)->doCountAtoms(); 44 47 … … 61 64 62 65 outmap = new PairCorrelationMap; 63 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 64 if ((*MolWalker)->ActiveFlag) { 65 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 66 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 67 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 68 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 69 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 70 if ((*MolOtherWalker)->ActiveFlag) { 71 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 72 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 73 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 74 if ((*iter)->getId() < (*runner)->getId()){ 75 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 77 distance = (*iter)->node->PeriodicDistance(*(*runner)->node, domain); 78 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 79 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 80 } 66 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){ 67 DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 68 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 69 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 70 for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){ 71 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 72 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 73 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 74 if ((*iter)->getId() < (*runner)->getId()){ 75 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 77 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node); 78 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 79 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 81 80 } 82 }83 81 } 84 82 } … … 96 94 * \return Map of doubles with values the pair of the two atoms. 97 95 */ 98 PairCorrelationMap *PeriodicPairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const int ranges[NDIM] )96 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ) 99 97 { 100 98 Info FunctionInfo(__func__); … … 108 106 Vector periodicOtherX; 109 107 110 if (molecules ->ListOfMolecules.empty()) {108 if (molecules.empty()) { 111 109 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 112 110 return outmap; 113 111 } 114 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)112 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 115 113 (*MolWalker)->doCountAtoms(); 116 114 … … 133 131 134 132 outmap = new PairCorrelationMap; 135 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 136 if ((*MolWalker)->ActiveFlag) { 137 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 138 double * FullInverseMatrix = InverseMatrix(FullMatrix); 139 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 140 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 141 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 142 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 143 periodicX = *(*iter)->node; 144 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 145 // go through every range in xyz and get distance 146 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 147 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 148 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 149 checkX = Vector(n[0], n[1], n[2]) + periodicX; 150 checkX.MatrixMultiplication(FullMatrix); 151 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 152 if ((*MolOtherWalker)->ActiveFlag) { 153 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 154 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 155 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 156 if ((*iter)->getId() < (*runner)->getId()){ 157 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 158 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 159 periodicOtherX = *(*runner)->node; 160 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 161 // go through every range in xyz and get distance 162 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) 163 for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++) 164 for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) { 165 checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX; 166 checkOtherX.MatrixMultiplication(FullMatrix); 167 distance = checkX.distance(checkOtherX); 168 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 169 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 170 } 171 } 133 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){ 134 Matrix FullMatrix = World::getInstance().getDomain().getM(); 135 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 136 DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 137 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 138 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 139 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 140 // go through every range in xyz and get distance 141 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 142 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 143 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 144 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 145 for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){ 146 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 147 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 148 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 149 if ((*iter)->getId() < (*runner)->getId()){ 150 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 151 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 152 periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3 153 // go through every range in xyz and get distance 154 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) 155 for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++) 156 for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) { 157 checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX); 158 distance = checkX.distance(checkOtherX); 159 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 160 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 161 } 162 } 172 163 } 173 164 } 174 165 } 175 }176 }177 166 } 178 delete[](FullMatrix);179 delete[](FullInverseMatrix);180 167 } 181 168 } … … 190 177 * \return Map of dobules with values as pairs of atom and the vector 191 178 */ 192 CorrelationToPointMap *CorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point )179 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point ) 193 180 { 194 181 Info FunctionInfo(__func__); 195 182 CorrelationToPointMap *outmap = NULL; 196 183 double distance = 0.; 197 double *cell_size= World::getInstance().getDomain();198 199 if (molecules ->ListOfMolecules.empty()) {184 Box &domain = World::getInstance().getDomain(); 185 186 if (molecules.empty()) { 200 187 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl); 201 188 return outmap; 202 189 } 203 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)190 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 204 191 (*MolWalker)->doCountAtoms(); 205 192 outmap = new CorrelationToPointMap; 206 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 207 if ((*MolWalker)->ActiveFlag) { 208 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 209 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 210 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 211 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 212 if ((*type == NULL) || ((*iter)->type == *type)) { 213 distance = (*iter)->node->PeriodicDistance(*point, cell_size); 214 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 215 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 216 } 217 } 218 } 193 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 194 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 195 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 196 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 197 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 198 if ((*type == NULL) || ((*iter)->type == *type)) { 199 distance = domain.periodicDistance(*(*iter)->node,*point); 200 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 201 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 202 } 203 } 204 } 219 205 220 206 return outmap; … … 228 214 * \return Map of dobules with values as pairs of atom and the vector 229 215 */ 230 CorrelationToPointMap *PeriodicCorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )216 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ) 231 217 { 232 218 Info FunctionInfo(__func__); … … 237 223 Vector checkX; 238 224 239 if (molecules ->ListOfMolecules.empty()) {225 if (molecules.empty()) { 240 226 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl); 241 227 return outmap; 242 228 } 243 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)229 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 244 230 (*MolWalker)->doCountAtoms(); 245 231 outmap = new CorrelationToPointMap; 246 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 247 if ((*MolWalker)->ActiveFlag) { 248 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 249 double * FullInverseMatrix = InverseMatrix(FullMatrix); 250 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 251 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 252 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 253 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 254 if ((*type == NULL) || ((*iter)->type == *type)) { 255 periodicX = *(*iter)->node; 256 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 257 // go through every range in xyz and get distance 258 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 259 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 260 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 261 checkX = Vector(n[0], n[1], n[2]) + periodicX; 262 checkX.MatrixMultiplication(FullMatrix); 263 distance = checkX.distance(*point); 264 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 265 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 266 } 267 } 268 } 269 delete[](FullMatrix); 270 delete[](FullInverseMatrix); 271 } 232 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 233 Matrix FullMatrix = World::getInstance().getDomain().getM(); 234 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 235 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 236 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 237 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 238 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 239 if ((*type == NULL) || ((*iter)->type == *type)) { 240 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 241 // go through every range in xyz and get distance 242 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 243 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 244 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 245 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 246 distance = checkX.distance(*point); 247 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 248 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 249 } 250 } 251 } 252 } 272 253 273 254 return outmap; … … 281 262 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 282 263 */ 283 CorrelationToSurfaceMap *CorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )264 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ) 284 265 { 285 266 Info FunctionInfo(__func__); … … 289 270 Vector centroid; 290 271 291 if ((Surface == NULL) || (LC == NULL) || (molecules ->ListOfMolecules.empty())) {272 if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) { 292 273 DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 293 274 return outmap; 294 275 } 295 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)276 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 296 277 (*MolWalker)->doCountAtoms(); 297 278 outmap = new CorrelationToSurfaceMap; 298 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 299 if ((*MolWalker)->ActiveFlag) { 300 DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl); 301 if ((*MolWalker)->empty()) 302 DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl); 303 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 304 DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl); 305 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 306 if ((*type == NULL) || ((*iter)->type == *type)) { 307 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 308 distance = Intersections.GetSmallestDistance(); 309 triangle = Intersections.GetClosestTriangle(); 310 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 311 } 312 } 313 } else { 314 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl); 315 } 279 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 280 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << (*MolWalker)->name << "." << endl); 281 if ((*MolWalker)->empty()) 282 DoLog(2) && (2) && (Log() << Verbose(2) << "\t is empty." << endl); 283 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 284 DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl); 285 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 286 if ((*type == NULL) || ((*iter)->type == *type)) { 287 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 288 distance = Intersections.GetSmallestDistance(); 289 triangle = Intersections.GetClosestTriangle(); 290 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 291 } 292 } 293 } 316 294 317 295 return outmap; … … 330 308 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 331 309 */ 332 CorrelationToSurfaceMap *PeriodicCorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )310 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 333 311 { 334 312 Info FunctionInfo(__func__); … … 341 319 Vector checkX; 342 320 343 if ((Surface == NULL) || (LC == NULL) || (molecules ->ListOfMolecules.empty())) {321 if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) { 344 322 DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 345 323 return outmap; 346 324 } 347 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)325 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 348 326 (*MolWalker)->doCountAtoms(); 349 327 outmap = new CorrelationToSurfaceMap; 350 328 double ShortestDistance = 0.; 351 329 BoundaryTriangleSet *ShortestTriangle = NULL; 352 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 353 if ((*MolWalker)->ActiveFlag) { 354 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 355 double * FullInverseMatrix = InverseMatrix(FullMatrix); 356 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 357 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 358 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 359 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 360 if ((*type == NULL) || ((*iter)->type == *type)) { 361 periodicX = *(*iter)->node; 362 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 363 // go through every range in xyz and get distance 364 ShortestDistance = -1.; 365 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 366 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 367 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 368 checkX = Vector(n[0], n[1], n[2]) + periodicX; 369 checkX.MatrixMultiplication(FullMatrix); 370 TriangleIntersectionList Intersections(&checkX,Surface,LC); 371 distance = Intersections.GetSmallestDistance(); 372 triangle = Intersections.GetClosestTriangle(); 373 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 374 ShortestDistance = distance; 375 ShortestTriangle = triangle; 376 } 330 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 331 Matrix FullMatrix = World::getInstance().getDomain().getM(); 332 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 333 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 334 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 335 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 336 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 337 if ((*type == NULL) || ((*iter)->type == *type)) { 338 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 339 // go through every range in xyz and get distance 340 ShortestDistance = -1.; 341 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 342 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 343 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 344 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 345 TriangleIntersectionList Intersections(&checkX,Surface,LC); 346 distance = Intersections.GetSmallestDistance(); 347 triangle = Intersections.GetClosestTriangle(); 348 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 349 ShortestDistance = distance; 350 ShortestTriangle = triangle; 377 351 } 378 // insert 379 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 380 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 381 } 382 } 383 delete[](FullMatrix); 384 delete[](FullInverseMatrix); 385 } 352 } 353 // insert 354 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 355 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 356 } 357 } 358 } 386 359 387 360 return outmap; -
src/analysis_correlation.hpp
r06f4ef6 rb6da28 22 22 // STL headers 23 23 #include <map> 24 #include <vector> 24 25 25 26 #include "defs.hpp" 26 27 27 28 #include "atom.hpp" 29 #include "verbose.hpp" 28 30 29 31 /****************************************** forward declarations *****************************/ … … 32 34 class element; 33 35 class LinkedCell; 34 class MoleculeListClass;35 36 class Tesselation; 36 37 class Vector; … … 45 46 /********************************************** declarations *******************************/ 46 47 47 PairCorrelationMap *PairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements);48 CorrelationToPointMap *CorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point );49 CorrelationToSurfaceMap *CorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );50 PairCorrelationMap *PeriodicPairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const int ranges[NDIM] );51 CorrelationToPointMap *PeriodicCorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );48 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements); 49 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point ); 50 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ); 51 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ); 52 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ); 53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 53 54 int GetBin ( const double value, const double BinWidth, const double BinStart ); 54 55 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); -
src/analyzer.cpp
r06f4ef6 rb6da28 14 14 #include "datacreator.hpp" 15 15 #include "helpers.hpp" 16 #include "memoryallocator.hpp"17 16 #include "parser.hpp" 18 17 #include "periodentafel.hpp" 18 #include "verbose.hpp" 19 19 20 20 // include config.h -
src/atom.cpp
r06f4ef6 rb6da28 12 12 #include "element.hpp" 13 13 #include "lists.hpp" 14 #include "memoryallocator.hpp"15 14 #include "parser.hpp" 16 15 #include "vector.hpp" 17 16 #include "World.hpp" 18 17 #include "molecule.hpp" 18 #include "Shapes/Shape.hpp" 19 20 #include <iomanip> 21 #include <iostream> 19 22 20 23 /************************************* Functions for class atom *************************************/ … … 107 110 }; 108 111 112 bool atom::isFather(const atom *ptr){ 113 return ptr==father; 114 } 115 109 116 /** Checks whether atom is within the given box. 110 117 * \param offset offset to box origin … … 112 119 * \return true - is inside, false - is not 113 120 */ 114 bool atom::IsIn Parallelepiped(const Vector offset, const double *parallelepiped) const115 { 116 return (node->IsInParallelepiped(offset, parallelepiped));121 bool atom::IsInShape(const Shape& shape) const 122 { 123 return shape.isInside(*node); 117 124 }; 118 125 … … 159 166 * \return true - \a *out present, false - \a *out is NULL 160 167 */ 161 bool atom::OutputArrayIndexed(o fstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const168 bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const 162 169 { 163 170 AtomNo[type->Z]++; // increment number 164 171 if (out != NULL) { 165 *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint; 172 cout << "Looking for atom with element " << *type << endl; 173 ASSERT(elementLookup.there.find(type)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 174 *out << "Ion_Type" << elementLookup.there.find(type)->second << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint; 166 175 *out << x[0] << "\t" << x[1] << "\t" << x[2]; 167 176 *out << "\t" << FixedIon; … … 236 245 * \param *AtomNo pointer to atom counter that is increased by one 237 246 */ 238 void atom::OutputMPQCLine(o fstream * const out, const Vector *center, int *AtomNo = NULL) const247 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 239 248 { 240 249 *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; … … 315 324 } 316 325 317 atomId_t atom::getId() {326 atomId_t atom::getId() const { 318 327 return id; 319 328 } … … 328 337 } 329 338 339 molecule* atom::getMolecule(){ 340 return mol; 341 } 342 330 343 void atom::removeFromMolecule(){ 331 344 if(mol){ -
src/atom.hpp
r06f4ef6 rb6da28 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 #include <list> 22 22 #include <vector> … … 35 35 class World; 36 36 class molecule; 37 class Shape; 37 38 38 39 /********************************************** declarations *******************************/ … … 51 52 52 53 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const; 53 bool OutputArrayIndexed(o fstream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;54 bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const; 54 55 bool OutputXYZLine(ofstream *out) const; 55 56 bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const; 56 57 bool OutputTrajectoryXYZ(ofstream * const out, const int step) const; 57 void OutputMPQCLine(o fstream * const out, const Vector *center, int *AtomNo) const;58 void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const; 58 59 59 60 void InitComponentNr(); 60 61 61 62 void EqualsFather ( const atom *ptr, const atom **res ) const; 63 bool isFather(const atom *ptr); 62 64 void CorrectFather(); 63 65 atom *GetTrueFather(); … … 66 68 double DistanceToVector(const Vector &origin) const; 67 69 double DistanceSquaredToVector(const Vector &origin) const; 68 bool IsIn Parallelepiped(const Vector offset, const double *parallelepiped) const;70 bool IsInShape(const Shape&) const; 69 71 70 72 // getter and setter … … 79 81 void setWorld(World*); 80 82 81 virtual atomId_t getId() ;83 virtual atomId_t getId() const; 82 84 virtual bool changeId(atomId_t newId); 83 85 … … 89 91 90 92 void setMolecule(molecule*); 93 molecule* getMolecule(); 91 94 void removeFromMolecule(); 92 95 -
src/atom_graphnodeinfo.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "atom_graphnodeinfo.hpp" 11 #include "memoryallocator.hpp"12 11 13 12 /** Constructor of class GraphNodeInfo. 14 13 */ 15 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr( NULL), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(NULL) {};14 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(0), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(0) {}; 16 15 17 16 /** Destructor of class GraphNodeInfo. -
src/atom_particleinfo.cpp
r06f4ef6 rb6da28 9 9 10 10 #include "atom_particleinfo.hpp" 11 #include "memoryallocator.hpp" 11 12 #include <iostream> 12 13 13 14 /** Constructor of ParticleInfo. -
src/atom_particleinfo.hpp
r06f4ef6 rb6da28 18 18 #endif 19 19 20 #include <iostream> 20 #include <iosfwd> 21 #include <string> 21 22 22 23 /****************************************** forward declarations *****************************/ -
src/atom_trajectoryparticle.cpp
r06f4ef6 rb6da28 15 15 #include "log.hpp" 16 16 #include "parser.hpp" 17 #include "ThermoStatContainer.hpp" 17 18 #include "verbose.hpp" 18 19 … … 105 106 * \param *Force matrix with forces 106 107 */ 107 void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force )108 void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force, const size_t offset) 108 109 { 109 110 //a = configuration.Deltat*0.5/walker->type->mass; // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a 110 111 for (int d=0; d<NDIM; d++) { 111 Trajectory.F.at(NextStep)[d] = -Force->Matrix[0][nr][d+ 5]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);112 Trajectory.F.at(NextStep)[d] = -Force->Matrix[0][nr][d+offset]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.); 112 113 Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d]; 113 114 Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]); // s(t) = s(0) + v * deltat + 1/2 a * deltat^2 … … 197 198 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 198 199 { 199 double sigma = sqrt(configuration->T argetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)200 double sigma = sqrt(configuration->Thermostats->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) 200 201 Vector &U = Trajectory.U.at(Step); 201 202 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 202 203 // throw a dice to determine whether it gets hit by a heat bath particle 203 if (((((rand()/(double)RAND_MAX))*configuration->T empFrequency) < 1.)) {204 if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) { 204 205 DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> "); 205 206 // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis … … 225 226 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 226 227 for (int d=0; d<NDIM; d++) { 227 U[d] *= sqrt(1+(configuration->Deltat/configuration->T empFrequency)*(ScaleTempFactor-1));228 U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1)); 228 229 *ekin += 0.5*type->mass * U[d]*U[d]; 229 230 } … … 255 256 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 256 257 for (int d=0; d<NDIM; d++) { 257 U[d] += configuration->Deltat/type->mass * (configuration-> alpha * (U[d] * type->mass));258 U[d] += configuration->Deltat/type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass)); 258 259 *ekin += (0.5*type->mass) * U[d]*U[d]; 259 260 } -
src/atom_trajectoryparticle.hpp
r06f4ef6 rb6da28 20 20 #include <fstream> 21 21 22 #include <gsl/gsl_inline.h> 22 23 #include <gsl/gsl_randist.h> 23 24 … … 50 51 void ResizeTrajectory(int MaxSteps); 51 52 void CopyStepOnStep(int dest, int src); 52 void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force );53 void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force, const size_t offset); 53 54 void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const; 54 55 -
src/bond.cpp
r06f4ef6 rb6da28 7 7 #include "Helpers/MemDebug.hpp" 8 8 9 #include "verbose.hpp" 9 10 #include "atom.hpp" 10 11 #include "bond.hpp" -
src/bondgraph.cpp
r06f4ef6 rb6da28 15 15 #include "element.hpp" 16 16 #include "info.hpp" 17 #include "verbose.hpp" 17 18 #include "log.hpp" 18 19 #include "molecule.hpp" -
src/bondgraph.hpp
r06f4ef6 rb6da28 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 22 22 /*********************************************** defines ***********************************/ -
src/boundary.cpp
r06f4ef6 rb6da28 15 15 #include "info.hpp" 16 16 #include "linkedcell.hpp" 17 #include "verbose.hpp" 17 18 #include "log.hpp" 18 #include "memoryallocator.hpp"19 19 #include "molecule.hpp" 20 20 #include "tesselation.hpp" … … 22 22 #include "World.hpp" 23 23 #include "Plane.hpp" 24 #include "Matrix.hpp" 25 #include "Box.hpp" 26 27 #include <iostream> 28 #include <iomanip> 24 29 25 30 #include<gsl/gsl_poly.h> … … 296 301 * \param *out output stream for debugging 297 302 * \param *mol molecule structure with Atom's and Bond's. 303 * \param *BoundaryPts set of boundary points to use or NULL 298 304 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return 299 305 * \param *LCList atoms in LinkedCell list … … 301 307 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename. 302 308 */ 303 void FindConvexBorder(const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)309 void FindConvexBorder(const molecule* mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename) 304 310 { 305 311 Info FunctionInfo(__func__); … … 312 318 313 319 // 1. Find all points on the boundary 314 if (BoundaryP oints == NULL) {315 316 320 if (BoundaryPts == NULL) { 321 BoundaryFreeFlag = true; 322 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 317 323 } else { 318 DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl); 324 BoundaryPoints = BoundaryPts; 325 DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl); 319 326 } 320 327 321 328 // printing all inserted for debugging 322 for (int axis=0; axis < NDIM; axis++) 323 { 324 DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl); 325 int i=0; 326 for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 327 if (runner != BoundaryPoints[axis].begin()) 328 DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second); 329 else 330 DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second); 331 i++; 332 } 333 DoLog(0) && (Log() << Verbose(0) << endl); 334 } 329 for (int axis=0; axis < NDIM; axis++) { 330 DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl); 331 int i=0; 332 for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 333 if (runner != BoundaryPoints[axis].begin()) 334 DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second); 335 else 336 DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second); 337 i++; 338 } 339 DoLog(0) && (Log() << Verbose(0) << endl); 340 } 335 341 336 342 // 2. fill the boundary point list … … 338 344 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) 339 345 if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0)) 340 Do eLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl);346 DoLog(2) && (Log()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present." << endl); 341 347 342 348 DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl); … … 672 678 673 679 IsAngstroem = configuration->GetIsAngstroem(); 680 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 674 681 GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem); 675 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);676 682 LinkedCell *LCList = new LinkedCell(mol, 10.); 677 FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL);683 FindConvexBorder(mol, BoundaryPoints, TesselStruct, (const LinkedCell *&)LCList, NULL); 678 684 delete (LCList); 685 delete[] BoundaryPoints; 679 686 680 687 … … 684 691 else 685 692 clustervolume = ClusterVolume; 693 694 delete TesselStruct; 686 695 687 696 for (int i = 0; i < NDIM; i++) … … 736 745 mol->CenterInBox(); 737 746 } 747 delete GreatestDiameter; 738 748 // update Box of atoms by boundary 739 749 mol->SetBoxDimension(&BoxLengths); … … 764 774 int N[NDIM]; 765 775 int n[NDIM]; 766 double *M = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());767 double Rotations[NDIM*NDIM];768 double *MInverse = InverseMatrix(M);776 const Matrix &M = World::getInstance().getDomain().getM(); 777 Matrix Rotations; 778 const Matrix &MInverse = World::getInstance().getDomain().getMinv(); 769 779 Vector AtomTranslations; 770 780 Vector FillerTranslations; … … 799 809 800 810 // calculate filler grid in [0,1]^3 801 FillerDistance = Vector(distance[0], distance[1], distance[2]); 802 FillerDistance.InverseMatrixMultiplication(M); 811 FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]); 803 812 for(int i=0;i<NDIM;i++) 804 813 N[i] = (int) ceil(1./FillerDistance[i]); … … 813 822 for (n[2] = 0; n[2] < N[2]; n[2]++) { 814 823 // calculate position of current grid vector in untransformed box 815 CurrentPosition = Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 816 CurrentPosition.MatrixMultiplication(M); 824 CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 817 825 // create molecule random translation vector ... 818 826 for (int i=0;i<NDIM;i++) … … 835 843 } 836 844 837 Rotations [0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));838 Rotations [3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));839 Rotations [6] = cos(phi[1])*sin(phi[2]);840 Rotations [1] = - sin(phi[0])*cos(phi[1]);841 Rotations [4] = cos(phi[0])*cos(phi[1]);842 Rotations [7] = sin(phi[1]);843 Rotations [3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));844 Rotations [5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));845 Rotations [8] = cos(phi[1])*cos(phi[2]);845 Rotations.set(0,0, cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]))); 846 Rotations.set(0,1, sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]))); 847 Rotations.set(0,2, cos(phi[1])*sin(phi[2]) ); 848 Rotations.set(1,0, -sin(phi[0])*cos(phi[1]) ); 849 Rotations.set(1,1, cos(phi[0])*cos(phi[1]) ); 850 Rotations.set(1,2, sin(phi[1]) ); 851 Rotations.set(2,0, -cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]))); 852 Rotations.set(2,1, -sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]))); 853 Rotations.set(2,2, cos(phi[1])*cos(phi[2]) ); 846 854 } 847 855 … … 849 857 Inserter = (*iter)->x; 850 858 if (DoRandomRotation) 851 Inserter .MatrixMultiplication(Rotations);859 Inserter *= Rotations; 852 860 Inserter += AtomTranslations + FillerTranslations + CurrentPosition; 853 861 854 862 // check whether inserter is inside box 855 Inserter .MatrixMultiplication(MInverse);863 Inserter *= MInverse; 856 864 FillIt = true; 857 865 for (int i=0;i<NDIM;i++) 858 866 FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON); 859 Inserter .MatrixMultiplication(M);867 Inserter *= M; 860 868 861 869 // Check whether point is in- or outside … … 892 900 } 893 901 } 894 delete[](M); 895 delete[](MInverse); 902 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 903 delete LCList[*ListRunner]; 904 delete TesselStruct[(*ListRunner)]; 905 } 896 906 897 907 return Filling; … … 1004 1014 // // Purges surplus triangles. 1005 1015 // TesselStruct->RemoveDegeneratedTriangles(); 1006 1007 // check envelope for consistency1008 status = CheckListOfBaselines(TesselStruct);1016 // 1017 // // check envelope for consistency 1018 // status = CheckListOfBaselines(TesselStruct); 1009 1019 1010 1020 cout << "before correction" << endl; -
src/boundary.hpp
r06f4ef6 rb6da28 12 12 13 13 #include <fstream> 14 #include <ios tream>14 #include <iosfwd> 15 15 16 16 // STL headers … … 50 50 double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 51 51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation); 52 void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);52 void FindConvexBorder(const molecule* const mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename); 53 53 Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol); 54 54 void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC); -
src/builder.cpp
r06f4ef6 rb6da28 1 1 /** \file builder.cpp 2 2 * 3 * By stating absolute positions or binding angles and distances atomic positions of a molecule can be constructed. 4 * The output is the complete configuration file for PCP for direct use. 5 * Features: 6 * -# Atomic data is retrieved from a file, if not found requested and stored there for later re-use 7 * -# step-by-step construction of the molecule beginning either at a centre of with a certain atom 3 * date: Jan 1, 2007 4 * author: heber 8 5 * 9 6 */ 10 7 11 /*! \mainpage Mole cuilder - a molecular set builder8 /*! \mainpage MoleCuilder - a molecular set builder 12 9 * 13 * This introductory shall briefly make a quainted with the program, helping in installing and a first run.10 * This introductory shall briefly make acquainted with the program, helping in installing and a first run. 14 11 * 15 12 * \section about About the Program 16 13 * 17 * Molecuilder is a short program, written in C++, that enables the construction of a coordinate set for the 18 * atoms making up an molecule by the successive statement of binding angles and distances and referencing to 19 * already constructed atoms. 14 * MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the 15 * atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond 16 * angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and 17 * ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated 18 * and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules. 19 * In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or 20 * amorphic in nature. 20 21 * 21 * A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello22 * molecular dynamics implementation.23 22 * 24 23 * \section install Installation … … 32 31 * -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n 33 32 * -# make doxygen-doc: Creates these html pages out of the documented source 33 * -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of 34 * functions. 34 35 * 35 36 * \section run Running … … 37 38 * The program can be executed by running: ./molecuilder 38 39 * 39 * Note, that it uses a database, called "elements.db", in the executable's directory. If the file is not found, 40 * it is created and any given data on elements of the periodic table will be stored therein and re-used on 41 * later re-execution. 40 * MoleCuilder has three interfaces at your disposal: 41 * -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms 42 * as you like 43 * -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed 44 * with any user interaction. 45 * -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other 46 * informations to ease the construction of bigger geometries. 42 47 * 43 * \section ref References 44 * 45 * For the special configuration file format, see the documentation of pcp. 48 * The supported output formats right now are: 49 * -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs) 50 * -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation) 51 * -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation) 52 * -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates. 46 53 * 47 54 */ … … 49 56 #include "Helpers/MemDebug.hpp" 50 57 51 #include <boost/bind.hpp>52 53 using namespace std;54 55 #include <cstring>56 #include <cstdlib>57 58 #include "analysis_bonds.hpp"59 #include "analysis_correlation.hpp"60 #include "atom.hpp"61 #include "bond.hpp"62 58 #include "bondgraph.hpp" 63 #include "boundary.hpp"64 59 #include "CommandLineParser.hpp" 65 60 #include "config.hpp" 66 #include "element.hpp"67 #include "ellipsoid.hpp"68 #include "helpers.hpp"69 #include "leastsquaremin.hpp"70 #include "linkedcell.hpp"71 61 #include "log.hpp" 72 #include "memoryusageobserver.hpp"73 62 #include "molecule.hpp" 74 63 #include "periodentafel.hpp" 64 #include "tesselationhelpers.hpp" 65 #include "UIElements/UIFactory.hpp" 66 #include "UIElements/TextUI/TextUIFactory.hpp" 67 #include "UIElements/CommandLineUI/CommandLineUIFactory.hpp" 68 #ifdef USE_GUI_QT 69 #include "UIElements/QT4/QTUIFactory.hpp" 70 #endif 71 #include "UIElements/MainWindow.hpp" 72 #include "UIElements/Dialog.hpp" 73 #include "Menu/ActionMenuItem.hpp" 74 #include "verbose.hpp" 75 #include "World.hpp" 76 77 #include "Actions/ActionRegistry.hpp" 78 #include "Actions/ActionHistory.hpp" 79 #include "Actions/MapOfActions.hpp" 80 81 #include "Parser/ChangeTracker.hpp" 82 #include "Parser/FormatParserStorage.hpp" 83 75 84 #include "UIElements/UIFactory.hpp" 76 85 #include "UIElements/TextUI/TextUIFactory.hpp" … … 78 87 #include "UIElements/MainWindow.hpp" 79 88 #include "UIElements/Dialog.hpp" 80 #include "Menu/ActionMenuItem.hpp" 81 #include "Actions/ActionRegistry.hpp" 82 #include "Actions/ActionHistory.hpp" 83 #include "Actions/MapOfActions.hpp" 84 #include "Actions/MethodAction.hpp" 85 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 86 #include "World.hpp" 89 87 90 #include "version.h" 88 #include "World.hpp"89 91 90 91 /********************************************* Subsubmenu routine ************************************/92 #if 093 /** Submenu for adding atoms to the molecule.94 * \param *periode periodentafel95 * \param *molecule molecules with atoms96 */97 static void AddAtoms(periodentafel *periode, molecule *mol)98 {99 atom *first, *second, *third, *fourth;100 Vector **atoms;101 Vector x,y,z,n; // coordinates for absolute point in cell volume102 double a,b,c;103 char choice; // menu choice char104 bool valid;105 106 cout << Verbose(0) << "===========ADD ATOM============================" << endl;107 cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;108 cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;109 cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;110 cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;111 cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;112 cout << Verbose(0) << "all else - go back" << endl;113 cout << Verbose(0) << "===============================================" << endl;114 cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;115 cout << Verbose(0) << "INPUT: ";116 cin >> choice;117 118 switch (choice) {119 default:120 DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl);121 break;122 case 'a': // absolute coordinates of atom123 cout << Verbose(0) << "Enter absolute coordinates." << endl;124 first = new atom;125 first->x.AskPosition(World::getInstance().getDomain(), false);126 first->type = periode->AskElement(); // give type127 mol->AddAtom(first); // add to molecule128 break;129 130 case 'b': // relative coordinates of atom wrt to reference point131 first = new atom;132 valid = true;133 do {134 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);135 cout << Verbose(0) << "Enter reference coordinates." << endl;136 x.AskPosition(World::getInstance().getDomain(), true);137 cout << Verbose(0) << "Enter relative coordinates." << endl;138 first->x.AskPosition(World::getInstance().getDomain(), false);139 first->x.AddVector((const Vector *)&x);140 cout << Verbose(0) << "\n";141 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));142 first->type = periode->AskElement(); // give type143 mol->AddAtom(first); // add to molecule144 break;145 146 case 'c': // relative coordinates of atom wrt to already placed atom147 first = new atom;148 valid = true;149 do {150 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);151 second = mol->AskAtom("Enter atom number: ");152 DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl);153 first->x.AskPosition(World::getInstance().getDomain(), false);154 for (int i=NDIM;i--;) {155 first->x.x[i] += second->x.x[i];156 }157 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));158 first->type = periode->AskElement(); // give type159 mol->AddAtom(first); // add to molecule160 break;161 162 case 'd': // two atoms, two angles and a distance163 first = new atom;164 valid = true;165 do {166 if (!valid) {167 DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl);168 }169 cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;170 second = mol->AskAtom("Enter central atom: ");171 third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");172 fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");173 a = ask_value("Enter distance between central (first) and new atom: ");174 b = ask_value("Enter angle between new, first and second atom (degrees): ");175 b *= M_PI/180.;176 bound(&b, 0., 2.*M_PI);177 c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");178 c *= M_PI/180.;179 bound(&c, -M_PI, M_PI);180 cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;181 /*182 second->Output(1,1,(ofstream *)&cout);183 third->Output(1,2,(ofstream *)&cout);184 fourth->Output(1,3,(ofstream *)&cout);185 n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);186 x.Copyvector(&second->x);187 x.SubtractVector(&third->x);188 x.Copyvector(&fourth->x);189 x.SubtractVector(&third->x);190 191 if (!z.SolveSystem(&x,&y,&n, b, c, a)) {192 coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;193 continue;194 }195 DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: ");196 z.Output();197 DoLog(0) && (Log() << Verbose(0) << endl);198 */199 // calc axis vector200 x.CopyVector(&second->x);201 x.SubtractVector(&third->x);202 x.Normalize();203 Log() << Verbose(0) << "x: ",204 x.Output();205 DoLog(0) && (Log() << Verbose(0) << endl);206 z.MakeNormalVector(&second->x,&third->x,&fourth->x);207 Log() << Verbose(0) << "z: ",208 z.Output();209 DoLog(0) && (Log() << Verbose(0) << endl);210 y.MakeNormalVector(&x,&z);211 Log() << Verbose(0) << "y: ",212 y.Output();213 DoLog(0) && (Log() << Verbose(0) << endl);214 215 // rotate vector around first angle216 first->x.CopyVector(&x);217 first->x.RotateVector(&z,b - M_PI);218 Log() << Verbose(0) << "Rotated vector: ",219 first->x.Output();220 DoLog(0) && (Log() << Verbose(0) << endl);221 // remove the projection onto the rotation plane of the second angle222 n.CopyVector(&y);223 n.Scale(first->x.ScalarProduct(&y));224 Log() << Verbose(0) << "N1: ",225 n.Output();226 DoLog(0) && (Log() << Verbose(0) << endl);227 first->x.SubtractVector(&n);228 Log() << Verbose(0) << "Subtracted vector: ",229 first->x.Output();230 DoLog(0) && (Log() << Verbose(0) << endl);231 n.CopyVector(&z);232 n.Scale(first->x.ScalarProduct(&z));233 Log() << Verbose(0) << "N2: ",234 n.Output();235 DoLog(0) && (Log() << Verbose(0) << endl);236 first->x.SubtractVector(&n);237 Log() << Verbose(0) << "2nd subtracted vector: ",238 first->x.Output();239 DoLog(0) && (Log() << Verbose(0) << endl);240 241 // rotate another vector around second angle242 n.CopyVector(&y);243 n.RotateVector(&x,c - M_PI);244 Log() << Verbose(0) << "2nd Rotated vector: ",245 n.Output();246 DoLog(0) && (Log() << Verbose(0) << endl);247 248 // add the two linear independent vectors249 first->x.AddVector(&n);250 first->x.Normalize();251 first->x.Scale(a);252 first->x.AddVector(&second->x);253 254 DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: ");255 first->x.Output();256 DoLog(0) && (Log() << Verbose(0) << endl);257 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));258 first->type = periode->AskElement(); // give type259 mol->AddAtom(first); // add to molecule260 break;261 262 case 'e': // least square distance position to a set of atoms263 first = new atom;264 atoms = new (Vector*[128]);265 valid = true;266 for(int i=128;i--;)267 atoms[i] = NULL;268 int i=0, j=0;269 cout << Verbose(0) << "Now we need at least three molecules.\n";270 do {271 cout << Verbose(0) << "Enter " << i+1 << "th atom: ";272 cin >> j;273 if (j != -1) {274 second = mol->FindAtom(j);275 atoms[i++] = &(second->x);276 }277 } while ((j != -1) && (i<128));278 if (i >= 2) {279 first->x.LSQdistance((const Vector **)atoms, i);280 first->x.Output();281 first->type = periode->AskElement(); // give type282 mol->AddAtom(first); // add to molecule283 } else {284 delete first;285 cout << Verbose(0) << "Please enter at least two vectors!\n";286 }287 break;288 };289 };290 291 /** Submenu for centering the atoms in the molecule.292 * \param *mol molecule with all the atoms293 */294 static void CenterAtoms(molecule *mol)295 {296 Vector x, y, helper;297 char choice; // menu choice char298 299 cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;300 cout << Verbose(0) << " a - on origin" << endl;301 cout << Verbose(0) << " b - on center of gravity" << endl;302 cout << Verbose(0) << " c - within box with additional boundary" << endl;303 cout << Verbose(0) << " d - within given simulation box" << endl;304 cout << Verbose(0) << "all else - go back" << endl;305 cout << Verbose(0) << "===============================================" << endl;306 cout << Verbose(0) << "INPUT: ";307 cin >> choice;308 309 switch (choice) {310 default:311 cout << Verbose(0) << "Not a valid choice." << endl;312 break;313 case 'a':314 cout << Verbose(0) << "Centering atoms in config file on origin." << endl;315 mol->CenterOrigin();316 break;317 case 'b':318 cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;319 mol->CenterPeriodic();320 break;321 case 'c':322 cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;323 for (int i=0;i<NDIM;i++) {324 cout << Verbose(0) << "Enter axis " << i << " boundary: ";325 cin >> y.x[i];326 }327 mol->CenterEdge(&x); // make every coordinate positive328 mol->Center.AddVector(&y); // translate by boundary329 helper.CopyVector(&y);330 helper.Scale(2.);331 helper.AddVector(&x);332 mol->SetBoxDimension(&helper); // update Box of atoms by boundary333 break;334 case 'd':335 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;336 for (int i=0;i<NDIM;i++) {337 cout << Verbose(0) << "Enter axis " << i << " boundary: ";338 cin >> x.x[i];339 }340 // update Box of atoms by boundary341 mol->SetBoxDimension(&x);342 // center343 mol->CenterInBox();344 break;345 }346 };347 348 /** Submenu for aligning the atoms in the molecule.349 * \param *periode periodentafel350 * \param *mol molecule with all the atoms351 */352 static void AlignAtoms(periodentafel *periode, molecule *mol)353 {354 atom *first, *second, *third;355 Vector x,n;356 char choice; // menu choice char357 358 cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;359 cout << Verbose(0) << " a - state three atoms defining align plane" << endl;360 cout << Verbose(0) << " b - state alignment vector" << endl;361 cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;362 cout << Verbose(0) << " d - align automatically by least square fit" << endl;363 cout << Verbose(0) << "all else - go back" << endl;364 cout << Verbose(0) << "===============================================" << endl;365 cout << Verbose(0) << "INPUT: ";366 cin >> choice;367 368 switch (choice) {369 default:370 case 'a': // three atoms defining mirror plane371 first = mol->AskAtom("Enter first atom: ");372 second = mol->AskAtom("Enter second atom: ");373 third = mol->AskAtom("Enter third atom: ");374 375 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);376 break;377 case 'b': // normal vector of mirror plane378 cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;379 n.AskPosition(World::getInstance().getDomain(),0);380 n.Normalize();381 break;382 case 'c': // three atoms defining mirror plane383 first = mol->AskAtom("Enter first atom: ");384 second = mol->AskAtom("Enter second atom: ");385 386 n.CopyVector((const Vector *)&first->x);387 n.SubtractVector((const Vector *)&second->x);388 n.Normalize();389 break;390 case 'd':391 char shorthand[4];392 Vector a;393 struct lsq_params param;394 do {395 fprintf(stdout, "Enter the element of atoms to be chosen: ");396 fscanf(stdin, "%3s", shorthand);397 } while ((param.type = periode->FindElement(shorthand)) == NULL);398 cout << Verbose(0) << "Element is " << param.type->name << endl;399 mol->GetAlignvector(¶m);400 for (int i=NDIM;i--;) {401 x.x[i] = gsl_vector_get(param.x,i);402 n.x[i] = gsl_vector_get(param.x,i+NDIM);403 }404 gsl_vector_free(param.x);405 cout << Verbose(0) << "Offset vector: ";406 x.Output();407 DoLog(0) && (Log() << Verbose(0) << endl);408 n.Normalize();409 break;410 };411 DoLog(0) && (Log() << Verbose(0) << "Alignment vector: ");412 n.Output();413 DoLog(0) && (Log() << Verbose(0) << endl);414 mol->Align(&n);415 };416 417 /** Submenu for mirroring the atoms in the molecule.418 * \param *mol molecule with all the atoms419 */420 static void MirrorAtoms(molecule *mol)421 {422 atom *first, *second, *third;423 Vector n;424 char choice; // menu choice char425 426 DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl);427 DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl);428 DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl);429 DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl);430 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);431 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);432 DoLog(0) && (Log() << Verbose(0) << "INPUT: ");433 cin >> choice;434 435 switch (choice) {436 default:437 case 'a': // three atoms defining mirror plane438 first = mol->AskAtom("Enter first atom: ");439 second = mol->AskAtom("Enter second atom: ");440 third = mol->AskAtom("Enter third atom: ");441 442 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);443 break;444 case 'b': // normal vector of mirror plane445 DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl);446 n.AskPosition(World::getInstance().getDomain(),0);447 n.Normalize();448 break;449 case 'c': // three atoms defining mirror plane450 first = mol->AskAtom("Enter first atom: ");451 second = mol->AskAtom("Enter second atom: ");452 453 n.CopyVector((const Vector *)&first->x);454 n.SubtractVector((const Vector *)&second->x);455 n.Normalize();456 break;457 };458 DoLog(0) && (Log() << Verbose(0) << "Normal vector: ");459 n.Output();460 DoLog(0) && (Log() << Verbose(0) << endl);461 mol->Mirror((const Vector *)&n);462 };463 464 /** Submenu for removing the atoms from the molecule.465 * \param *mol molecule with all the atoms466 */467 static void RemoveAtoms(molecule *mol)468 {469 atom *first, *second;470 int axis;471 double tmp1, tmp2;472 char choice; // menu choice char473 474 DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl);475 DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl);476 DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl);477 DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl);478 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);479 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);480 DoLog(0) && (Log() << Verbose(0) << "INPUT: ");481 cin >> choice;482 483 switch (choice) {484 default:485 case 'a':486 if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))487 DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl);488 else489 DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl);490 break;491 case 'b':492 second = mol->AskAtom("Enter number of atom as reference point: ");493 DoLog(0) && (Log() << Verbose(0) << "Enter radius: ");494 cin >> tmp1;495 first = mol->start;496 second = first->next;497 while(second != mol->end) {498 first = second;499 second = first->next;500 if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...501 mol->RemoveAtom(first);502 }503 break;504 case 'c':505 DoLog(0) && (Log() << Verbose(0) << "Which axis is it: ");506 cin >> axis;507 DoLog(0) && (Log() << Verbose(0) << "Lower boundary: ");508 cin >> tmp1;509 DoLog(0) && (Log() << Verbose(0) << "Upper boundary: ");510 cin >> tmp2;511 first = mol->start;512 second = first->next;513 while(second != mol->end) {514 first = second;515 second = first->next;516 if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...517 //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;518 mol->RemoveAtom(first);519 }520 }521 break;522 };523 //mol->Output();524 choice = 'r';525 };526 527 /** Submenu for measuring out the atoms in the molecule.528 * \param *periode periodentafel529 * \param *mol molecule with all the atoms530 */531 static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)532 {533 atom *first, *second, *third;534 Vector x,y;535 double min[256], tmp1, tmp2, tmp3;536 int Z;537 char choice; // menu choice char538 539 DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl);540 DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl);541 DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl);542 DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl);543 DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl);544 DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl);545 DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl);546 DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl);547 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);548 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);549 DoLog(0) && (Log() << Verbose(0) << "INPUT: ");550 cin >> choice;551 552 switch(choice) {553 default:554 DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl);555 break;556 case 'a':557 first = mol->AskAtom("Enter first atom: ");558 for (int i=MAX_ELEMENTS;i--;)559 min[i] = 0.;560 561 second = mol->start;562 while ((second->next != mol->end)) {563 second = second->next; // advance564 Z = second->type->Z;565 tmp1 = 0.;566 if (first != second) {567 x.CopyVector((const Vector *)&first->x);568 x.SubtractVector((const Vector *)&second->x);569 tmp1 = x.Norm();570 }571 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;572 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;573 }574 for (int i=MAX_ELEMENTS;i--;)575 if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;576 break;577 578 case 'b':579 first = mol->AskAtom("Enter first atom: ");580 second = mol->AskAtom("Enter second atom: ");581 for (int i=NDIM;i--;)582 min[i] = 0.;583 x.CopyVector((const Vector *)&first->x);584 x.SubtractVector((const Vector *)&second->x);585 tmp1 = x.Norm();586 DoLog(1) && (Log() << Verbose(1) << "Distance vector is ");587 x.Output();588 DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl);589 break;590 591 case 'c':592 DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl);593 first = mol->AskAtom("Enter first atom: ");594 second = mol->AskAtom("Enter central atom: ");595 third = mol->AskAtom("Enter last atom: ");596 tmp1 = tmp2 = tmp3 = 0.;597 x.CopyVector((const Vector *)&first->x);598 x.SubtractVector((const Vector *)&second->x);599 y.CopyVector((const Vector *)&third->x);600 y.SubtractVector((const Vector *)&second->x);601 DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ");602 DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl);603 break;604 case 'd':605 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);606 DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: ");607 cin >> Z;608 if ((Z >=0) && (Z <=1))609 mol->PrincipalAxisSystem((bool)Z);610 else611 mol->PrincipalAxisSystem(false);612 break;613 case 'e':614 {615 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");616 class Tesselation *TesselStruct = NULL;617 const LinkedCell *LCList = NULL;618 LCList = new LinkedCell(mol, 10.);619 FindConvexBorder(mol, TesselStruct, LCList, NULL);620 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);621 DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\622 delete(LCList);623 delete(TesselStruct);624 }625 break;626 case 'f':627 mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);628 break;629 case 'g':630 {631 char filename[255];632 DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl);633 cin >> filename;634 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);635 ofstream *output = new ofstream(filename, ios::trunc);636 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))637 DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);638 else639 DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);640 output->close();641 delete(output);642 }643 break;644 }645 };646 647 /** Submenu for measuring out the atoms in the molecule.648 * \param *mol molecule with all the atoms649 * \param *configuration configuration structure for the to be written config files of all fragments650 */651 static void FragmentAtoms(molecule *mol, config *configuration)652 {653 int Order1;654 clock_t start, end;655 656 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);657 DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");658 cin >> Order1;659 if (mol->first->next != mol->last) { // there are bonds660 start = clock();661 mol->FragmentMolecule(Order1, configuration);662 end = clock();663 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);664 } else665 DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl);666 };667 668 /********************************************** Submenu routine **************************************/669 670 /** Submenu for manipulating atoms.671 * \param *periode periodentafel672 * \param *molecules list of molecules whose atoms are to be manipulated673 */674 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)675 {676 atom *first, *second, *third;677 molecule *mol = NULL;678 Vector x,y,z,n; // coordinates for absolute point in cell volume679 double *factor; // unit factor if desired680 double bond, minBond;681 char choice; // menu choice char682 bool valid;683 684 DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl);685 DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl);686 DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl);687 DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl);688 DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl);689 DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl);690 DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl);691 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);692 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);693 if (molecules->NumberOfActiveMolecules() > 1)694 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);695 DoLog(0) && (Log() << Verbose(0) << "INPUT: ");696 cin >> choice;697 698 switch (choice) {699 default:700 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);701 break;702 703 case 'a': // add atom704 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)705 if ((*ListRunner)->ActiveFlag) {706 mol = *ListRunner;707 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);708 AddAtoms(periode, mol);709 }710 break;711 712 case 'b': // scale a bond713 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)714 if ((*ListRunner)->ActiveFlag) {715 mol = *ListRunner;716 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);717 DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl);718 first = mol->AskAtom("Enter first (fixed) atom: ");719 second = mol->AskAtom("Enter second (shifting) atom: ");720 minBond = 0.;721 for (int i=NDIM;i--;)722 minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);723 minBond = sqrt(minBond);724 DoLog(0) && (Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl);725 DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: ");726 cin >> bond;727 for (int i=NDIM;i--;) {728 second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);729 }730 //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";731 //second->Output(second->type->No, 1);732 }733 break;734 735 case 'c': // unit scaling of the metric736 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)737 if ((*ListRunner)->ActiveFlag) {738 mol = *ListRunner;739 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);740 DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl);741 DoLog(0) && (Log() << Verbose(0) << "Enter three factors: ");742 factor = new double[NDIM];743 cin >> factor[0];744 cin >> factor[1];745 cin >> factor[2];746 valid = true;747 mol->Scale((const double ** const)&factor);748 delete[](factor);749 }750 break;751 752 case 'l': // measure distances or angles753 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)754 if ((*ListRunner)->ActiveFlag) {755 mol = *ListRunner;756 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);757 MeasureAtoms(periode, mol, configuration);758 }759 break;760 761 case 'r': // remove atom762 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)763 if ((*ListRunner)->ActiveFlag) {764 mol = *ListRunner;765 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);766 RemoveAtoms(mol);767 }768 break;769 770 case 't': // turn/rotate atom771 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)772 if ((*ListRunner)->ActiveFlag) {773 mol = *ListRunner;774 DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl);775 first = mol->AskAtom("Enter turning atom: ");776 second = mol->AskAtom("Enter central atom: ");777 third = mol->AskAtom("Enter bond atom: ");778 cout << Verbose(0) << "Enter new angle in degrees: ";779 double tmp = 0.;780 cin >> tmp;781 // calculate old angle782 x.CopyVector((const Vector *)&first->x);783 x.SubtractVector((const Vector *)&second->x);784 y.CopyVector((const Vector *)&third->x);785 y.SubtractVector((const Vector *)&second->x);786 double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);787 cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";788 cout << Verbose(0) << alpha << " degrees" << endl;789 // rotate790 z.MakeNormalVector(&x,&y);791 x.RotateVector(&z,(alpha-tmp)*M_PI/180.);792 x.AddVector(&second->x);793 first->x.CopyVector(&x);794 // check new angle795 x.CopyVector((const Vector *)&first->x);796 x.SubtractVector((const Vector *)&second->x);797 alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);798 cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";799 cout << Verbose(0) << alpha << " degrees" << endl;800 }801 break;802 803 case 'u': // change an atom's element804 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)805 if ((*ListRunner)->ActiveFlag) {806 int Z;807 mol = *ListRunner;808 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);809 first = NULL;810 do {811 DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: ");812 cin >> Z;813 } while ((first = mol->FindAtom(Z)) == NULL);814 DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: ");815 cin >> Z;816 first->type = periode->FindElement(Z);817 DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl);818 }819 break;820 }821 };822 823 /** Submenu for manipulating molecules.824 * \param *periode periodentafel825 * \param *molecules list of molecule to manipulate826 */827 static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)828 {829 atom *first = NULL;830 Vector x,y,z,n; // coordinates for absolute point in cell volume831 int j, axis, count, faktor;832 char choice; // menu choice char833 molecule *mol = NULL;834 element **Elements;835 Vector **vectors;836 MoleculeLeafClass *Subgraphs = NULL;837 838 DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl);839 DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl);840 DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl);841 DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl);842 DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl);843 DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl);844 DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl);845 DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl);846 DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl);847 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);848 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);849 if (molecules->NumberOfActiveMolecules() > 1)850 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);851 DoLog(0) && (Log() << Verbose(0) << "INPUT: ");852 cin >> choice;853 854 switch (choice) {855 default:856 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);857 break;858 859 case 'd': // duplicate the periodic cell along a given axis, given times860 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)861 if ((*ListRunner)->ActiveFlag) {862 mol = *ListRunner;863 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);864 DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: ");865 cin >> axis;866 DoLog(0) && (Log() << Verbose(0) << "State the factor: ");867 cin >> faktor;868 869 mol->CountAtoms(); // recount atoms870 if (mol->getAtomCount() != 0) { // if there is more than none871 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand872 Elements = new element *[count];873 vectors = new Vector *[count];874 j = 0;875 first = mol->start;876 while (first->next != mol->end) { // make a list of all atoms with coordinates and element877 first = first->next;878 Elements[j] = first->type;879 vectors[j] = &first->x;880 j++;881 }882 if (count != j)883 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);884 x.Zero();885 y.Zero();886 y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude887 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times888 x.AddVector(&y); // per factor one cell width further889 for (int k=count;k--;) { // go through every atom of the original cell890 first = new atom(); // create a new body891 first->x.CopyVector(vectors[k]); // use coordinate of original atom892 first->x.AddVector(&x); // translate the coordinates893 first->type = Elements[k]; // insert original element894 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)895 }896 }897 if (mol->first->next != mol->last) // if connect matrix is present already, redo it898 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);899 // free memory900 delete[](Elements);901 delete[](vectors);902 // correct cell size903 if (axis < 0) { // if sign was negative, we have to translate everything904 x.Zero();905 x.AddVector(&y);906 x.Scale(-(faktor-1));907 mol->Translate(&x);908 }909 World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;910 }911 }912 break;913 914 case 'f':915 FragmentAtoms(mol, configuration);916 break;917 918 case 'g': // center the atoms919 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)920 if ((*ListRunner)->ActiveFlag) {921 mol = *ListRunner;922 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);923 CenterAtoms(mol);924 }925 break;926 927 case 'i': // align all atoms928 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)929 if ((*ListRunner)->ActiveFlag) {930 mol = *ListRunner;931 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);932 AlignAtoms(periode, mol);933 }934 break;935 936 case 'm': // mirror atoms along a given axis937 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)938 if ((*ListRunner)->ActiveFlag) {939 mol = *ListRunner;940 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);941 MirrorAtoms(mol);942 }943 break;944 945 case 'o': // create the connection matrix946 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)947 if ((*ListRunner)->ActiveFlag) {948 mol = *ListRunner;949 double bonddistance;950 clock_t start,end;951 DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: ");952 cin >> bonddistance;953 start = clock();954 mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);955 end = clock();956 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);957 }958 break;959 960 case 't': // translate all atoms961 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)962 if ((*ListRunner)->ActiveFlag) {963 mol = *ListRunner;964 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);965 DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl);966 x.AskPosition(World::getInstance().getDomain(),0);967 mol->Center.AddVector((const Vector *)&x);968 }969 break;970 }971 // Free all972 if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed973 while (Subgraphs->next != NULL) {974 Subgraphs = Subgraphs->next;975 delete(Subgraphs->previous);976 }977 delete(Subgraphs);978 }979 };980 981 982 /** Submenu for creating new molecules.983 * \param *periode periodentafel984 * \param *molecules list of molecules to add to985 */986 static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules)987 {988 char choice; // menu choice char989 Vector center;990 int nr, count;991 molecule *mol = NULL;992 993 DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl);994 DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl);995 DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl);996 DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl);997 DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl);998 DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl);999 DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl);1000 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);1001 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);1002 DoLog(0) && (Log() << Verbose(0) << "INPUT: ");1003 cin >> choice;1004 1005 switch (choice) {1006 default:1007 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);1008 break;1009 case 'c':1010 mol = World::getInstance().createMolecule();1011 molecules->insert(mol);1012 break;1013 1014 case 'l': // load from XYZ file1015 {1016 char filename[MAXSTRINGSIZE];1017 DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);1018 mol = World::getInstance().createMolecule();1019 do {1020 DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");1021 cin >> filename;1022 } while (!mol->AddXYZFile(filename));1023 mol->SetNameFromFilename(filename);1024 // center at set box dimensions1025 mol->CenterEdge(¢er);1026 double * const cell_size = World::getInstance().getDomain();1027 cell_size[0] = center.x[0];1028 cell_size[1] = 0;1029 cell_size[2] = center.x[1];1030 cell_size[3] = 0;1031 cell_size[4] = 0;1032 cell_size[5] = center.x[2];1033 molecules->insert(mol);1034 }1035 break;1036 1037 case 'n':1038 {1039 char filename[MAXSTRINGSIZE];1040 do {1041 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");1042 cin >> nr;1043 mol = molecules->ReturnIndex(nr);1044 } while (mol == NULL);1045 DoLog(0) && (Log() << Verbose(0) << "Enter name: ");1046 cin >> filename;1047 strcpy(mol->name, filename);1048 }1049 break;1050 1051 case 'N':1052 {1053 char filename[MAXSTRINGSIZE];1054 do {1055 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");1056 cin >> nr;1057 mol = molecules->ReturnIndex(nr);1058 } while (mol == NULL);1059 DoLog(0) && (Log() << Verbose(0) << "Enter name: ");1060 cin >> filename;1061 mol->SetNameFromFilename(filename);1062 }1063 break;1064 1065 case 'p': // parse XYZ file1066 {1067 char filename[MAXSTRINGSIZE];1068 mol = NULL;1069 do {1070 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");1071 cin >> nr;1072 mol = molecules->ReturnIndex(nr);1073 } while (mol == NULL);1074 DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);1075 do {1076 DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");1077 cin >> filename;1078 } while (!mol->AddXYZFile(filename));1079 mol->SetNameFromFilename(filename);1080 }1081 break;1082 1083 case 'r':1084 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");1085 cin >> nr;1086 count = 1;1087 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)1088 if (nr == (*ListRunner)->IndexNr) {1089 mol = *ListRunner;1090 molecules->ListOfMolecules.erase(ListRunner);1091 delete(mol);1092 break;1093 }1094 break;1095 }1096 };1097 1098 1099 /** Submenu for merging molecules.1100 * \param *periode periodentafel1101 * \param *molecules list of molecules to add to1102 */1103 static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)1104 {1105 char choice; // menu choice char1106 1107 DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl);1108 DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl);1109 DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl);1110 DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl);1111 DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl);1112 DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl);1113 DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl);1114 DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl);1115 DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl);1116 DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl);1117 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);1118 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);1119 DoLog(0) && (Log() << Verbose(0) << "INPUT: ");1120 cin >> choice;1121 1122 switch (choice) {1123 default:1124 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);1125 break;1126 1127 case 'a':1128 {1129 int src, dest;1130 molecule *srcmol = NULL, *destmol = NULL;1131 {1132 do {1133 DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");1134 cin >> dest;1135 destmol = molecules->ReturnIndex(dest);1136 } while ((destmol == NULL) && (dest != -1));1137 do {1138 DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: ");1139 cin >> src;1140 srcmol = molecules->ReturnIndex(src);1141 } while ((srcmol == NULL) && (src != -1));1142 if ((src != -1) && (dest != -1))1143 molecules->SimpleAdd(srcmol, destmol);1144 }1145 }1146 break;1147 1148 case 'b':1149 {1150 const int nr = 2;1151 char *names[nr] = {"first", "second"};1152 int Z[nr];1153 element *elements[nr];1154 for (int i=0;i<nr;i++) {1155 Z[i] = 0;1156 do {1157 cout << "Enter " << names[i] << " element: ";1158 cin >> Z[i];1159 } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));1160 elements[i] = periode->FindElement(Z[i]);1161 }1162 const int count = CountBondsOfTwo(molecules, elements[0], elements[1]);1163 cout << endl << "There are " << count << " ";1164 for (int i=0;i<nr;i++) {1165 if (i==0)1166 cout << elements[i]->symbol;1167 else1168 cout << "-" << elements[i]->symbol;1169 }1170 cout << " bonds." << endl;1171 }1172 break;1173 1174 case 'B':1175 {1176 const int nr = 3;1177 char *names[nr] = {"first", "second", "third"};1178 int Z[nr];1179 element *elements[nr];1180 for (int i=0;i<nr;i++) {1181 Z[i] = 0;1182 do {1183 cout << "Enter " << names[i] << " element: ";1184 cin >> Z[i];1185 } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));1186 elements[i] = periode->FindElement(Z[i]);1187 }1188 const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]);1189 cout << endl << "There are " << count << " ";1190 for (int i=0;i<nr;i++) {1191 if (i==0)1192 cout << elements[i]->symbol;1193 else1194 cout << "-" << elements[i]->symbol;1195 }1196 cout << " bonds." << endl;1197 }1198 break;1199 1200 case 'e':1201 {1202 int src, dest;1203 molecule *srcmol = NULL, *destmol = NULL;1204 do {1205 DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ");1206 cin >> src;1207 srcmol = molecules->ReturnIndex(src);1208 } while ((srcmol == NULL) && (src != -1));1209 do {1210 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ");1211 cin >> dest;1212 destmol = molecules->ReturnIndex(dest);1213 } while ((destmol == NULL) && (dest != -1));1214 if ((src != -1) && (dest != -1))1215 molecules->EmbedMerge(destmol, srcmol);1216 }1217 break;1218 1219 case 'h':1220 {1221 int Z;1222 cout << "Please enter interface element: ";1223 cin >> Z;1224 element * const InterfaceElement = periode->FindElement(Z);1225 cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;1226 }1227 break;1228 1229 case 'm':1230 {1231 int nr;1232 molecule *mol = NULL;1233 do {1234 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: ");1235 cin >> nr;1236 mol = molecules->ReturnIndex(nr);1237 } while ((mol == NULL) && (nr != -1));1238 if (nr != -1) {1239 int N = molecules->ListOfMolecules.size()-1;1240 int *src = new int(N);1241 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)1242 if ((*ListRunner)->IndexNr != nr)1243 src[N++] = (*ListRunner)->IndexNr;1244 molecules->SimpleMultiMerge(mol, src, N);1245 delete[](src);1246 }1247 }1248 break;1249 1250 case 's':1251 DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl);1252 break;1253 1254 case 't':1255 {1256 int src, dest;1257 molecule *srcmol = NULL, *destmol = NULL;1258 {1259 do {1260 DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");1261 cin >> dest;1262 destmol = molecules->ReturnIndex(dest);1263 } while ((destmol == NULL) && (dest != -1));1264 do {1265 DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: ");1266 cin >> src;1267 srcmol = molecules->ReturnIndex(src);1268 } while ((srcmol == NULL) && (src != -1));1269 if ((src != -1) && (dest != -1))1270 molecules->SimpleMerge(srcmol, destmol);1271 }1272 }1273 break;1274 }1275 };1276 1277 /********************************************** Test routine **************************************/1278 1279 /** Is called always as option 'T' in the menu.1280 * \param *molecules list of molecules1281 */1282 static void testroutine(MoleculeListClass *molecules)1283 {1284 // the current test routine checks the functionality of the KeySet&Graph concept:1285 // We want to have a multiindex (the KeySet) describing a unique subgraph1286 int i, comp, counter=0;1287 1288 // create a clone1289 molecule *mol = NULL;1290 if (molecules->ListOfMolecules.size() != 0) // clone1291 mol = (molecules->ListOfMolecules.front())->CopyMolecule();1292 else {1293 DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... ");1294 performCriticalExit();1295 return;1296 }1297 atom *Walker = mol->start;1298 1299 // generate some KeySets1300 DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);1301 KeySet TestSets[mol->getAtomCount()+1];1302 i=1;1303 while (Walker->next != mol->end) {1304 Walker = Walker->next;1305 for (int j=0;j<i;j++) {1306 TestSets[j].insert(Walker->nr);1307 }1308 i++;1309 }1310 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);1311 KeySetTestPair test;1312 test = TestSets[mol->getAtomCount()-1].insert(Walker->nr);1313 if (test.second) {1314 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);1315 } else {1316 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);1317 }1318 TestSets[mol->getAtomCount()].insert(mol->end->previous->nr);1319 TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr);1320 1321 // constructing Graph structure1322 DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl);1323 Graph Subgraphs;1324 1325 // insert KeySets into Subgraphs1326 DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);1327 for (int j=0;j<mol->getAtomCount();j++) {1328 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));1329 }1330 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);1331 GraphTestPair test2;1332 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));1333 if (test2.second) {1334 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);1335 } else {1336 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl);1337 }1338 1339 // show graphs1340 DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl);1341 Graph::iterator A = Subgraphs.begin();1342 while (A != Subgraphs.end()) {1343 DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": ");1344 KeySet::iterator key = (*A).first.begin();1345 comp = -1;1346 while (key != (*A).first.end()) {1347 if ((*key) > comp)1348 DoLog(0) && (Log() << Verbose(0) << (*key) << " ");1349 else1350 DoLog(0) && (Log() << Verbose(0) << (*key) << "! ");1351 comp = (*key);1352 key++;1353 }1354 DoLog(0) && (Log() << Verbose(0) << endl);1355 A++;1356 }1357 delete(mol);1358 };1359 1360 #endif1361 1362 /** Tries given filename or standard on saving the config file.1363 * \param *ConfigFileName name of file1364 * \param *configuration pointer to configuration structure with all the values1365 * \param *periode pointer to periodentafel structure with all the elements1366 * \param *molecules list of molecules structure with all the atoms and coordinates1367 */1368 static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)1369 {1370 char filename[MAXSTRINGSIZE];1371 ofstream output;1372 molecule *mol = World::getInstance().createMolecule();1373 mol->SetNameFromFilename(ConfigFileName);1374 1375 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {1376 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);1377 }1378 1379 1380 // first save as PDB data1381 if (ConfigFileName != NULL)1382 strcpy(filename, ConfigFileName);1383 if (output == NULL)1384 strcpy(filename,"main_pcp_linux");1385 DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input ");1386 if (configuration->SavePDB(filename, molecules))1387 DoLog(0) && (Log() << Verbose(0) << "done." << endl);1388 else1389 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1390 1391 // then save as tremolo data file1392 if (ConfigFileName != NULL)1393 strcpy(filename, ConfigFileName);1394 if (output == NULL)1395 strcpy(filename,"main_pcp_linux");1396 DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input ");1397 if (configuration->SaveTREMOLO(filename, molecules))1398 DoLog(0) && (Log() << Verbose(0) << "done." << endl);1399 else1400 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1401 1402 // translate each to its center and merge all molecules in MoleculeListClass into this molecule1403 int N = molecules->ListOfMolecules.size();1404 int *src = new int[N];1405 N=0;1406 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {1407 src[N++] = (*ListRunner)->IndexNr;1408 (*ListRunner)->Translate(&(*ListRunner)->Center);1409 }1410 molecules->SimpleMultiAdd(mol, src, N);1411 delete[](src);1412 1413 // ... and translate back1414 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {1415 (*ListRunner)->Center.Scale(-1.);1416 (*ListRunner)->Translate(&(*ListRunner)->Center);1417 (*ListRunner)->Center.Scale(-1.);1418 }1419 1420 DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl);1421 // get correct valence orbitals1422 mol->CalculateOrbitals(*configuration);1423 configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;1424 if (ConfigFileName != NULL) { // test the file name1425 strcpy(filename, ConfigFileName);1426 output.open(filename, ios::trunc);1427 } else if (strlen(configuration->configname) != 0) {1428 strcpy(filename, configuration->configname);1429 output.open(configuration->configname, ios::trunc);1430 } else {1431 strcpy(filename, DEFAULTCONFIG);1432 output.open(DEFAULTCONFIG, ios::trunc);1433 }1434 output.close();1435 output.clear();1436 DoLog(0) && (Log() << Verbose(0) << "Saving of config file ");1437 if (configuration->Save(filename, periode, mol))1438 DoLog(0) && (Log() << Verbose(0) << "successful." << endl);1439 else1440 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1441 1442 // and save to xyz file1443 if (ConfigFileName != NULL) {1444 strcpy(filename, ConfigFileName);1445 strcat(filename, ".xyz");1446 output.open(filename, ios::trunc);1447 }1448 if (output == NULL) {1449 strcpy(filename,"main_pcp_linux");1450 strcat(filename, ".xyz");1451 output.open(filename, ios::trunc);1452 }1453 DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file ");1454 if (mol->MDSteps <= 1) {1455 if (mol->OutputXYZ(&output))1456 DoLog(0) && (Log() << Verbose(0) << "successful." << endl);1457 else1458 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1459 } else {1460 if (mol->OutputTrajectoriesXYZ(&output))1461 DoLog(0) && (Log() << Verbose(0) << "successful." << endl);1462 else1463 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1464 }1465 output.close();1466 output.clear();1467 1468 // and save as MPQC configuration1469 if (ConfigFileName != NULL)1470 strcpy(filename, ConfigFileName);1471 if (output == NULL)1472 strcpy(filename,"main_pcp_linux");1473 DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input ");1474 if (configuration->SaveMPQC(filename, mol))1475 DoLog(0) && (Log() << Verbose(0) << "done." << endl);1476 else1477 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1478 1479 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {1480 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);1481 }1482 1483 World::getInstance().destroyMolecule(mol);1484 };1485 1486 /** Parses the command line options.1487 * Note that this function is from now on transitional. All commands that are not passed1488 * here are handled by CommandLineParser and the actions of CommandLineUIFactory.1489 * \param argc argument count1490 * \param **argv arguments array1491 * \param *molecules list of molecules structure1492 * \param *periode elements structure1493 * \param configuration config file structure1494 * \param *ConfigFileName pointer to config file name in **argv1495 * \param *PathToDatabases pointer to db's path in **argv1496 * \param &ArgcList list of arguments that we do not parse here1497 * \return exit code (0 - successful, all else - something's wrong)1498 */1499 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,1500 config& configuration, char **ConfigFileName, set<int> &ArgcList)1501 {1502 Vector x,y,z,n; // coordinates for absolute point in cell volume1503 double *factor; // unit factor if desired1504 ifstream test;1505 ofstream output;1506 string line;1507 atom *first;1508 bool SaveFlag = false;1509 int ExitFlag = 0;1510 int j;1511 double volume = 0.;1512 enum ConfigStatus configPresent = absent;1513 clock_t start,end;1514 double MaxDistance = -1;1515 int argptr;1516 molecule *mol = NULL;1517 string BondGraphFileName("\n");1518 bool DatabasePathGiven = false;1519 1520 if (argc > 1) { // config file specified as option1521 // 1. : Parse options that just set variables or print help1522 argptr = 1;1523 do {1524 if (argv[argptr][0] == '-') {1525 DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n");1526 argptr++;1527 switch(argv[argptr-1][1]) {1528 case 'h':1529 case 'H':1530 case '?':1531 ArgcList.insert(argptr-1);1532 return(1);1533 break;1534 case 'v':1535 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1536 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying verbosity: -v <level>" << endl);1537 performCriticalExit();1538 } else {1539 setVerbosity(atoi(argv[argptr]));1540 ArgcList.insert(argptr-1);1541 ArgcList.insert(argptr);1542 argptr++;1543 }1544 break;1545 case 'V':1546 ArgcList.insert(argptr-1);1547 return(1);1548 break;1549 case 'B':1550 if (ExitFlag == 0) ExitFlag = 1;1551 if ((argptr+5 >= argc)) {1552 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for setting Box: -B <xx> <<xy> <<xz> <yy> <yz> <zz>" << endl);1553 performCriticalExit();1554 } else {1555 ArgcList.insert(argptr-1);1556 ArgcList.insert(argptr);1557 ArgcList.insert(argptr+1);1558 ArgcList.insert(argptr+2);1559 ArgcList.insert(argptr+3);1560 ArgcList.insert(argptr+4);1561 ArgcList.insert(argptr+5);1562 argptr+=6;1563 }1564 break;1565 case 'e':1566 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1567 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl);1568 performCriticalExit();1569 } else {1570 ArgcList.insert(argptr-1);1571 ArgcList.insert(argptr);1572 argptr+=1;1573 }1574 break;1575 case 'g':1576 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1577 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl);1578 performCriticalExit();1579 } else {1580 ArgcList.insert(argptr-1);1581 ArgcList.insert(argptr);1582 argptr+=1;1583 }1584 break;1585 case 'M':1586 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1587 ExitFlag = 255;1588 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -M <basis name>" << endl);1589 performCriticalExit();1590 } else {1591 ArgcList.insert(argptr-1);1592 ArgcList.insert(argptr);1593 argptr+=1;1594 }1595 break;1596 case 'n':1597 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1598 ExitFlag = 255;1599 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting fast-parsing: -n <0/1>" << endl);1600 performCriticalExit();1601 } else {1602 ArgcList.insert(argptr-1);1603 ArgcList.insert(argptr);1604 argptr+=1;1605 }1606 break;1607 case 'X':1608 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1609 ExitFlag = 255;1610 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting default molecule name: -X <name>" << endl);1611 performCriticalExit();1612 } else {1613 ArgcList.insert(argptr-1);1614 ArgcList.insert(argptr);1615 argptr+=1;1616 }1617 break;1618 default: // no match? Step on1619 argptr++;1620 break;1621 }1622 } else1623 argptr++;1624 } while (argptr < argc);1625 1626 // 3b. Find config file name and parse if possible, also BondGraphFileName1627 if (argv[1][0] != '-') {1628 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place1629 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);1630 test.open(argv[1], ios::in);1631 if (test == NULL) {1632 //return (1);1633 output.open(argv[1], ios::out);1634 if (output == NULL) {1635 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);1636 configPresent = absent;1637 } else {1638 DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);1639 strcpy(*ConfigFileName, argv[1]);1640 configPresent = empty;1641 output.close();1642 }1643 } else {1644 test.close();1645 strcpy(*ConfigFileName, argv[1]);1646 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");1647 switch (configuration.TestSyntax(*ConfigFileName, periode)) {1648 case 1:1649 DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);1650 configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules);1651 configPresent = present;1652 break;1653 case 0:1654 DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);1655 configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules);1656 configPresent = present;1657 break;1658 default:1659 DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);1660 configPresent = empty;1661 }1662 }1663 } else1664 configPresent = absent;1665 // set mol to first active molecule1666 if (molecules->ListOfMolecules.size() != 0) {1667 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)1668 if ((*ListRunner)->ActiveFlag) {1669 mol = *ListRunner;1670 break;1671 }1672 }1673 if (mol == NULL) {1674 mol = World::getInstance().createMolecule();1675 mol->ActiveFlag = true;1676 if (*ConfigFileName != NULL)1677 mol->SetNameFromFilename(*ConfigFileName);1678 molecules->insert(mol);1679 }1680 1681 // 4. parse again through options, now for those depending on elements db and config presence1682 argptr = 1;1683 do {1684 DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl);1685 if (argv[argptr][0] == '-') {1686 argptr++;1687 if ((configPresent == present) || (configPresent == empty)) {1688 switch(argv[argptr-1][1]) {1689 case 'p':1690 if (ExitFlag == 0) ExitFlag = 1;1691 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1692 ExitFlag = 255;1693 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl);1694 performCriticalExit();1695 } else {1696 SaveFlag = true;1697 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);1698 if (!mol->AddXYZFile(argv[argptr]))1699 DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);1700 else {1701 DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);1702 configPresent = present;1703 }1704 }1705 break;1706 case 'a':1707 if (ExitFlag == 0) ExitFlag = 1;1708 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) {1709 ExitFlag = 255;1710 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for adding atom: -a <Z> --position <x> <y> <z>" << endl);1711 performCriticalExit();1712 } else {1713 ArgcList.insert(argptr-1);1714 ArgcList.insert(argptr);1715 ArgcList.insert(argptr+1);1716 ArgcList.insert(argptr+2);1717 ArgcList.insert(argptr+3);1718 ArgcList.insert(argptr+4);1719 argptr+=5;1720 }1721 break;1722 default: // no match? Don't step on (this is done in next switch's default)1723 break;1724 }1725 }1726 if (configPresent == present) {1727 switch(argv[argptr-1][1]) {1728 case 'D':1729 if (ExitFlag == 0) ExitFlag = 1;1730 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1731 ExitFlag = 255;1732 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for depth-first-search analysis: -D <max. bond distance>" << endl);1733 performCriticalExit();1734 } else {1735 ArgcList.insert(argptr-1);1736 ArgcList.insert(argptr);1737 argptr+=1;1738 }1739 break;1740 case 'I':1741 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);1742 ArgcList.insert(argptr-1);1743 argptr+=0;1744 break;1745 case 'C':1746 {1747 if (ExitFlag == 0) ExitFlag = 1;1748 if ((argptr+11 >= argc)) {1749 ExitFlag = 255;1750 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl);1751 performCriticalExit();1752 } else {1753 switch(argv[argptr][0]) {1754 case 'E':1755 ArgcList.insert(argptr-1);1756 ArgcList.insert(argptr);1757 ArgcList.insert(argptr+1);1758 ArgcList.insert(argptr+2);1759 ArgcList.insert(argptr+3);1760 ArgcList.insert(argptr+4);1761 ArgcList.insert(argptr+5);1762 ArgcList.insert(argptr+6);1763 ArgcList.insert(argptr+7);1764 ArgcList.insert(argptr+8);1765 ArgcList.insert(argptr+9);1766 ArgcList.insert(argptr+10);1767 ArgcList.insert(argptr+11);1768 argptr+=12;1769 break;1770 1771 case 'P':1772 ArgcList.insert(argptr-1);1773 ArgcList.insert(argptr);1774 ArgcList.insert(argptr+1);1775 ArgcList.insert(argptr+2);1776 ArgcList.insert(argptr+3);1777 ArgcList.insert(argptr+4);1778 ArgcList.insert(argptr+5);1779 ArgcList.insert(argptr+6);1780 ArgcList.insert(argptr+7);1781 ArgcList.insert(argptr+8);1782 ArgcList.insert(argptr+9);1783 ArgcList.insert(argptr+10);1784 ArgcList.insert(argptr+11);1785 ArgcList.insert(argptr+12);1786 ArgcList.insert(argptr+13);1787 ArgcList.insert(argptr+14);1788 argptr+=15;1789 break;1790 1791 case 'S':1792 ArgcList.insert(argptr-1);1793 ArgcList.insert(argptr);1794 ArgcList.insert(argptr+1);1795 ArgcList.insert(argptr+2);1796 ArgcList.insert(argptr+3);1797 ArgcList.insert(argptr+4);1798 ArgcList.insert(argptr+5);1799 ArgcList.insert(argptr+6);1800 ArgcList.insert(argptr+7);1801 ArgcList.insert(argptr+8);1802 ArgcList.insert(argptr+9);1803 ArgcList.insert(argptr+10);1804 ArgcList.insert(argptr+11);1805 ArgcList.insert(argptr+12);1806 ArgcList.insert(argptr+13);1807 ArgcList.insert(argptr+14);1808 argptr+=15;1809 break;1810 1811 default:1812 ExitFlag = 255;1813 DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl);1814 performCriticalExit();1815 break;1816 }1817 }1818 break;1819 }1820 case 'E':1821 if (ExitFlag == 0) ExitFlag = 1;1822 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr]))) {1823 ExitFlag = 255;1824 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> --element <Z>" << endl);1825 performCriticalExit();1826 } else {1827 ArgcList.insert(argptr-1);1828 ArgcList.insert(argptr);1829 ArgcList.insert(argptr+1);1830 ArgcList.insert(argptr+2);1831 argptr+=3;1832 }1833 break;1834 case 'F':1835 if (ExitFlag == 0) ExitFlag = 1;1836 if ((argptr+12 >= argc) || (argv[argptr][0] == '-')) {1837 ExitFlag = 255;1838 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling with molecule: -F <filler xyz file> --MaxDistance <distance or -1> --distances <x> <y> <z> --lengths <surface> <randatm> <randmol> --DoRotate <0/1>" << endl);1839 performCriticalExit();1840 } else {1841 ArgcList.insert(argptr-1);1842 ArgcList.insert(argptr);1843 ArgcList.insert(argptr+1);1844 ArgcList.insert(argptr+2);1845 ArgcList.insert(argptr+3);1846 ArgcList.insert(argptr+4);1847 ArgcList.insert(argptr+5);1848 ArgcList.insert(argptr+6);1849 ArgcList.insert(argptr+7);1850 ArgcList.insert(argptr+8);1851 ArgcList.insert(argptr+9);1852 ArgcList.insert(argptr+10);1853 ArgcList.insert(argptr+11);1854 ArgcList.insert(argptr+12);1855 argptr+=13;1856 }1857 break;1858 case 'A':1859 if (ExitFlag == 0) ExitFlag = 1;1860 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {1861 ExitFlag =255;1862 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile> --molecule-by-id <molecule_id>" << endl);1863 performCriticalExit();1864 } else {1865 ArgcList.insert(argptr-1);1866 ArgcList.insert(argptr);1867 ArgcList.insert(argptr+1);1868 ArgcList.insert(argptr+2);1869 argptr+=3;1870 }1871 break;1872 1873 case 'J':1874 if (ExitFlag == 0) ExitFlag = 1;1875 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {1876 ExitFlag =255;1877 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -J <path> --molecule-by-id <molecule_id>" << endl);1878 performCriticalExit();1879 } else {1880 ArgcList.insert(argptr-1);1881 ArgcList.insert(argptr);1882 ArgcList.insert(argptr+1);1883 ArgcList.insert(argptr+2);1884 argptr+=3;1885 }1886 break;1887 1888 case 'j':1889 if (ExitFlag == 0) ExitFlag = 1;1890 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1891 ExitFlag =255;1892 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path> --molecule-by-id <molecule_id>" << endl);1893 performCriticalExit();1894 } else {1895 ArgcList.insert(argptr-1);1896 ArgcList.insert(argptr);1897 ArgcList.insert(argptr+1);1898 ArgcList.insert(argptr+2);1899 argptr+=3;1900 }1901 break;1902 1903 case 'N':1904 if (ExitFlag == 0) ExitFlag = 1;1905 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){1906 ExitFlag = 255;1907 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -N <molecule_id> --sphere-radius <radius> --nonconvex-file <output prefix>" << endl);1908 performCriticalExit();1909 } else {1910 ArgcList.insert(argptr-1);1911 ArgcList.insert(argptr);1912 ArgcList.insert(argptr+1);1913 ArgcList.insert(argptr+2);1914 ArgcList.insert(argptr+3);1915 ArgcList.insert(argptr+4);1916 argptr+=5;1917 }1918 break;1919 case 'S':1920 if (ExitFlag == 0) ExitFlag = 1;1921 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {1922 ExitFlag = 255;1923 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file> --molecule-by-id 0" << endl);1924 performCriticalExit();1925 } else {1926 ArgcList.insert(argptr-1);1927 ArgcList.insert(argptr);1928 ArgcList.insert(argptr+1);1929 ArgcList.insert(argptr+2);1930 argptr+=3;1931 }1932 break;1933 case 'L':1934 if (ExitFlag == 0) ExitFlag = 1;1935 if ((argptr+8 >= argc) || (argv[argptr][0] == '-')) {1936 ExitFlag = 255;1937 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for linear interpolation: -L <prefix> --start-step <step0> --end-step <step1> --molecule-by-id 0 --id-mapping <0/1>" << endl);1938 performCriticalExit();1939 } else {1940 ArgcList.insert(argptr-1);1941 ArgcList.insert(argptr);1942 ArgcList.insert(argptr+1);1943 ArgcList.insert(argptr+2);1944 ArgcList.insert(argptr+3);1945 ArgcList.insert(argptr+4);1946 ArgcList.insert(argptr+5);1947 ArgcList.insert(argptr+6);1948 ArgcList.insert(argptr+7);1949 ArgcList.insert(argptr+8);1950 argptr+=9;1951 }1952 break;1953 case 'P':1954 if (ExitFlag == 0) ExitFlag = 1;1955 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {1956 ExitFlag = 255;1957 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file> --molecule-by-id <molecule_id>" << endl);1958 performCriticalExit();1959 } else {1960 ArgcList.insert(argptr-1);1961 ArgcList.insert(argptr);1962 ArgcList.insert(argptr+1);1963 ArgcList.insert(argptr+2);1964 argptr+=3;1965 }1966 break;1967 case 'R':1968 if (ExitFlag == 0) ExitFlag = 1;1969 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) {1970 ExitFlag = 255;1971 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <distance> --position <x> <y> <z>" << endl);1972 performCriticalExit();1973 } else {1974 ArgcList.insert(argptr-1);1975 ArgcList.insert(argptr);1976 ArgcList.insert(argptr+1);1977 ArgcList.insert(argptr+2);1978 ArgcList.insert(argptr+3);1979 ArgcList.insert(argptr+4);1980 argptr+=5;1981 }1982 break;1983 case 't':1984 if (ExitFlag == 0) ExitFlag = 1;1985 if ((argptr+4 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {1986 ExitFlag = 255;1987 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z> --molecule-by-id <molecule_id> --periodic <0/1>" << endl);1988 performCriticalExit();1989 } else {1990 ArgcList.insert(argptr-1);1991 ArgcList.insert(argptr);1992 ArgcList.insert(argptr+1);1993 ArgcList.insert(argptr+2);1994 ArgcList.insert(argptr+3);1995 ArgcList.insert(argptr+4);1996 ArgcList.insert(argptr+5);1997 ArgcList.insert(argptr+6);1998 argptr+=7;1999 }2000 break;2001 case 's':2002 if (ExitFlag == 0) ExitFlag = 1;2003 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {2004 ExitFlag = 255;2005 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);2006 performCriticalExit();2007 } else {2008 ArgcList.insert(argptr-1);2009 ArgcList.insert(argptr);2010 ArgcList.insert(argptr+1);2011 ArgcList.insert(argptr+2);2012 argptr+=3;2013 }2014 break;2015 case 'b':2016 if (ExitFlag == 0) ExitFlag = 1;2017 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {2018 ExitFlag = 255;2019 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl);2020 performCriticalExit();2021 } else {2022 ArgcList.insert(argptr-1);2023 ArgcList.insert(argptr);2024 ArgcList.insert(argptr+1);2025 ArgcList.insert(argptr+2);2026 ArgcList.insert(argptr+3);2027 ArgcList.insert(argptr+4);2028 ArgcList.insert(argptr+5);2029 argptr+=6;2030 }2031 break;2032 case 'B':2033 if (ExitFlag == 0) ExitFlag = 1;2034 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {2035 ExitFlag = 255;2036 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);2037 performCriticalExit();2038 } else {2039 ArgcList.insert(argptr-1);2040 ArgcList.insert(argptr);2041 ArgcList.insert(argptr+1);2042 ArgcList.insert(argptr+2);2043 ArgcList.insert(argptr+3);2044 ArgcList.insert(argptr+4);2045 ArgcList.insert(argptr+5);2046 argptr+=6;2047 }2048 break;2049 case 'c':2050 if (ExitFlag == 0) ExitFlag = 1;2051 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {2052 ExitFlag = 255;2053 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl);2054 performCriticalExit();2055 } else {2056 ArgcList.insert(argptr-1);2057 ArgcList.insert(argptr);2058 ArgcList.insert(argptr+1);2059 ArgcList.insert(argptr+2);2060 argptr+=3;2061 }2062 break;2063 case 'O':2064 if (ExitFlag == 0) ExitFlag = 1;2065 ArgcList.insert(argptr-1);2066 argptr+=0;2067 break;2068 case 'r':2069 if (ExitFlag == 0) ExitFlag = 1;2070 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr]))) {2071 ExitFlag = 255;2072 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl);2073 performCriticalExit();2074 } else {2075 ArgcList.insert(argptr-1);2076 ArgcList.insert(argptr);2077 argptr+=1;2078 }2079 break;2080 case 'f':2081 if (ExitFlag == 0) ExitFlag = 1;2082 if ((argptr+1 >= argc) || (argv[argptr][0] == '-')) {2083 ExitFlag = 255;2084 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);2085 performCriticalExit();2086 } else {2087 ArgcList.insert(argptr-1);2088 ArgcList.insert(argptr);2089 ArgcList.insert(argptr+1);2090 ArgcList.insert(argptr+2);2091 ArgcList.insert(argptr+3);2092 ArgcList.insert(argptr+4);2093 argptr+=5;2094 }2095 break;2096 case 'm':2097 if (ExitFlag == 0) ExitFlag = 1;2098 j = atoi(argv[argptr++]);2099 if ((j<0) || (j>1)) {2100 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);2101 j = 0;2102 }2103 if (j) {2104 SaveFlag = true;2105 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);2106 mol->PrincipalAxisSystem((bool)j);2107 } else2108 ArgcList.insert(argptr-1);2109 argptr+=0;2110 break;2111 case 'o':2112 if (ExitFlag == 0) ExitFlag = 1;2113 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){2114 ExitFlag = 255;2115 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl);2116 performCriticalExit();2117 } else {2118 ArgcList.insert(argptr-1);2119 ArgcList.insert(argptr);2120 ArgcList.insert(argptr+1);2121 ArgcList.insert(argptr+2);2122 ArgcList.insert(argptr+3);2123 ArgcList.insert(argptr+4);2124 argptr+=5;2125 }2126 break;2127 case 'U':2128 if (ExitFlag == 0) ExitFlag = 1;2129 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {2130 ExitFlag = 255;2131 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl);2132 performCriticalExit();2133 } else {2134 volume = atof(argv[argptr++]);2135 DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl);2136 }2137 case 'u':2138 if (ExitFlag == 0) ExitFlag = 1;2139 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) {2140 if (volume != -1)2141 ExitFlag = 255;2142 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl);2143 performCriticalExit();2144 } else {2145 ArgcList.insert(argptr-1);2146 ArgcList.insert(argptr);2147 argptr+=1;2148 }2149 break;2150 case 'd':2151 if (ExitFlag == 0) ExitFlag = 1;2152 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {2153 ExitFlag = 255;2154 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl);2155 performCriticalExit();2156 } else {2157 ArgcList.insert(argptr-1);2158 ArgcList.insert(argptr);2159 ArgcList.insert(argptr+1);2160 ArgcList.insert(argptr+2);2161 argptr+=3;2162 }2163 break;2164 default: // no match? Step on2165 if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!2166 argptr++;2167 break;2168 }2169 }2170 } else argptr++;2171 } while (argptr < argc);2172 if (SaveFlag)2173 configuration.SaveAll(*ConfigFileName, periode, molecules);2174 } else { // no arguments, hence scan the elements db2175 if (periode->LoadPeriodentafel(configuration.databasepath))2176 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);2177 else2178 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);2179 configuration.RetrieveConfigPathAndName("main_pcp_linux");2180 }2181 return(ExitFlag);2182 };2183 92 2184 93 /********************************************** Main routine **************************************/ 2185 94 2186 95 void cleanUp(){ 96 FormatParserStorage::purgeInstance(); 97 ChangeTracker::purgeInstance(); 2187 98 World::purgeInstance(); 2188 99 logger::purgeInstance(); … … 2199 110 } 2200 111 112 void dumpMemory(){ 113 ofstream ost("molecuilder.memdump"); 114 Memory::dumpMemory(ost); 115 } 116 2201 117 int main(int argc, char **argv) 2202 118 { 2203 config *configuration = World::getInstance().getConfig(); 2204 // while we are non interactive, we want to abort from asserts 2205 //ASSERT_DO(Assert::Abort); 2206 molecule *mol = NULL; 2207 Vector x, y, z, n; 2208 ifstream test; 2209 ofstream output; 2210 string line; 2211 char **Arguments = NULL; 2212 int ArgcSize = 0; 2213 int ExitFlag = 0; 2214 bool ArgumentsCopied = false; 2215 char *ConfigFileName = new char[MAXSTRINGSIZE]; 119 // while we are non interactive, we want to abort from asserts 120 ASSERT_DO(Assert::Abort); 121 ASSERT_HOOK(dumpMemory); 122 string line; 123 char **Arguments = NULL; 124 int ArgcSize = 0; 125 int ExitFlag = 0; 126 bool ArgumentsCopied = false; 127 std::string BondGraphFileName("\n"); 2216 128 2217 // print version check whether arguments are present at all 2218 cout << ESPACKVersion << endl; 2219 if (argc < 2) { 2220 cout << "Obtain help with " << argv[0] << " -h." << endl; 2221 cleanUp(); 2222 Memory::getState(); 2223 return(1); 129 // print version check whether arguments are present at all 130 cout << ESPACKVersion << endl; 131 132 setVerbosity(0); 133 // need to init the history before any action is created 134 ActionHistory::init(); 135 136 // from this moment on, we need to be sure to deeinitialize in the correct order 137 // this is handled by the cleanup function 138 atexit(cleanUp); 139 140 // Parse command line options and if present create respective UI 141 { 142 // construct bond graph 143 if (World::getInstance().getConfig()->BG == NULL) { 144 World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem()); 145 if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) { 146 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl); 147 } else { 148 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl); 149 } 2224 150 } 2225 2226 2227 setVerbosity(0); 2228 // need to init the history before any action is created 2229 ActionHistory::init(); 2230 2231 // In the interactive mode, we can leave the user the choice in case of error 2232 ASSERT_DO(Assert::Ask); 2233 2234 // from this moment on, we need to be sure to deeinitialize in the correct order 2235 // this is handled by the cleanup function 2236 atexit(cleanUp); 2237 2238 // Parse command line options and if present create respective UI 2239 { 2240 set<int> ArgcList; 2241 ArgcList.insert(0); // push back program! 2242 ArgcList.insert(1); // push back config file name 2243 // handle arguments by ParseCommandLineOptions() 2244 ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList); 2245 World::getInstance().setExitFlag(ExitFlag); 2246 // copy all remaining arguments to a new argv 2247 Arguments = new char *[ArgcList.size()]; 2248 cout << "The following arguments are handled by CommandLineParser: "; 2249 for (set<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) { 2250 Arguments[ArgcSize] = new char[strlen(argv[*ArgcRunner])+2]; 2251 strcpy(Arguments[ArgcSize], argv[*ArgcRunner]); 2252 cout << " " << argv[*ArgcRunner]; 2253 ArgcSize++; 2254 } 2255 cout << endl; 2256 ArgumentsCopied = true; 2257 // handle remaining arguments by CommandLineParser 151 // handle remaining arguments by CommandLineParser 152 if (argc>1) { 2258 153 MapOfActions::getInstance().AddOptionsToParser(); 2259 154 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap(); 2260 CommandLineParser::getInstance().Run(ArgcSize,Arguments, ShortFormToActionMap); 2261 if (!CommandLineParser::getInstance().isEmpty()) { 2262 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl); 2263 UIFactory::registerFactory(new CommandLineUIFactory::description()); 2264 UIFactory::makeUserInterface("CommandLine"); 2265 } else { 155 CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap); 156 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl); 157 UIFactory::registerFactory(new CommandLineUIFactory::description()); 158 UIFactory::makeUserInterface("CommandLine"); 159 } else { 160 // In the interactive mode, we can leave the user the choice in case of error 161 ASSERT_DO(Assert::Ask); 162 #ifdef USE_GUI_QT 163 DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl); 164 UIFactory::registerFactory(new QTUIFactory::description()); 165 UIFactory::makeUserInterface("QT4"); 166 #else 2266 167 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl); 168 cout << ESPACKVersion << endl; 2267 169 UIFactory::registerFactory(new TextUIFactory::description()); 2268 170 UIFactory::makeUserInterface("Text"); 2269 }171 #endif 2270 172 } 173 } 2271 174 2272 2273 2274 2275 2276 175 { 176 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(); 177 mainWindow->display(); 178 delete mainWindow; 179 } 2277 180 2278 Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl;2279 World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules());181 FormatParserStorage::getInstance().SaveAll(); 182 ChangeTracker::getInstance().saveStatus(); 2280 183 2281 184 // free the new argv … … 2285 188 delete[](Arguments); 2286 189 } 2287 delete[](ConfigFileName);190 //delete[](ConfigFileName); 2288 191 2289 192 ExitFlag = World::getInstance().getExitFlag(); -
src/config.cpp
r06f4ef6 rb6da28 10 10 #include <cstring> 11 11 12 #include "World.hpp"13 12 #include "atom.hpp" 14 13 #include "bond.hpp" 14 #include "bondgraph.hpp" 15 15 #include "config.hpp" 16 #include "ConfigFileBuffer.hpp" 16 17 #include "element.hpp" 17 18 #include "helpers.hpp" 18 19 #include "info.hpp" 19 20 #include "lists.hpp" 21 #include "verbose.hpp" 20 22 #include "log.hpp" 21 23 #include "molecule.hpp" 22 #include "memoryallocator.hpp"23 24 #include "molecule.hpp" 24 25 #include "periodentafel.hpp" 26 #include "ThermoStatContainer.hpp" 25 27 #include "World.hpp" 26 27 /******************************** Functions for class ConfigFileBuffer **********************/ 28 29 /** Structure containing compare function for Ion_Type sorting. 30 */ 31 struct IonTypeCompare { 32 bool operator()(const char* s1, const char *s2) const { 33 char number1[8]; 34 char number2[8]; 35 const char *dummy1, *dummy2; 36 //Log() << Verbose(0) << s1 << " " << s2 << endl; 37 dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type" 38 dummy2 = strchr(dummy1, '_'); 39 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 40 number1[dummy2-dummy1]='\0'; 41 dummy1 = strchr(s2, '_')+sizeof(char)*5; // go just after "Ion_Type" 42 dummy2 = strchr(dummy1, '_'); 43 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 44 number2[dummy2-dummy1]='\0'; 45 if (atoi(number1) != atoi(number2)) 46 return (atoi(number1) < atoi(number2)); 47 else { 48 dummy1 = strchr(s1, '_')+sizeof(char); 49 dummy1 = strchr(dummy1, '_')+sizeof(char); 50 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 51 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 52 number1[dummy2-dummy1]='\0'; 53 dummy1 = strchr(s2, '_')+sizeof(char); 54 dummy1 = strchr(dummy1, '_')+sizeof(char); 55 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 56 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 57 number2[dummy2-dummy1]='\0'; 58 return (atoi(number1) < atoi(number2)); 59 } 60 } 61 }; 62 63 /** Constructor for ConfigFileBuffer class. 64 */ 65 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 66 { 67 }; 68 69 /** Constructor for ConfigFileBuffer class with filename to be parsed. 70 * \param *filename file name 71 */ 72 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 73 { 74 ifstream *file = NULL; 75 char line[MAXSTRINGSIZE]; 76 77 // prescan number of lines 78 file= new ifstream(filename); 79 if (file == NULL) { 80 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 81 return; 82 } 83 NoLines = 0; // we're overcounting by one 84 long file_position = file->tellg(); // mark current position 85 do { 86 file->getline(line, 256); 87 NoLines++; 88 } while (!file->eof()); 89 file->clear(); 90 file->seekg(file_position, ios::beg); 91 DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl); 92 93 // allocate buffer's 1st dimension 94 if (buffer != NULL) { 95 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl); 96 return; 97 } else 98 buffer = new char *[NoLines]; 99 100 // scan each line and put into buffer 101 int lines=0; 102 int i; 103 do { 104 buffer[lines] = new char[MAXSTRINGSIZE]; 105 file->getline(buffer[lines], MAXSTRINGSIZE-1); 106 i = strlen(buffer[lines]); 107 buffer[lines][i] = '\n'; 108 buffer[lines][i+1] = '\0'; 109 lines++; 110 } while((!file->eof()) && (lines < NoLines)); 111 DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl); 112 113 // close and exit 114 file->close(); 115 file->clear(); 116 delete(file); 117 } 118 119 /** Destructor for ConfigFileBuffer class. 120 */ 121 ConfigFileBuffer::~ConfigFileBuffer() 122 { 123 for(int i=0;i<NoLines;++i) 124 delete[](buffer[i]); 125 delete[](buffer); 126 delete[](LineMapping); 127 } 128 129 130 /** Create trivial mapping. 131 */ 132 void ConfigFileBuffer::InitMapping() 133 { 134 LineMapping = new int[NoLines]; 135 for (int i=0;i<NoLines;i++) 136 LineMapping[i] = i; 137 } 138 139 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted. 140 * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the 141 * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine 142 * points to first Ion_Type entry. 143 * \param *FileBuffer pointer to buffer structure 144 * \param NoAtoms of subsequent lines to look at 145 */ 146 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms) 147 { 148 map<const char *, int, IonTypeCompare> IonTypeLineMap; 149 if (LineMapping == NULL) { 150 DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl); 151 performCriticalExit(); 152 return; 153 } 154 155 // put all into hashed map 156 for (int i=0; i<NoAtoms; ++i) { 157 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i)); 158 } 159 160 // fill map 161 int nr=0; 162 for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) { 163 if (CurrentLine+nr < NoLines) 164 LineMapping[CurrentLine+(nr++)] = runner->second; 165 else { 166 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl); 167 performCriticalExit(); 168 } 169 } 170 } 28 #include "Matrix.hpp" 29 #include "Box.hpp" 171 30 172 31 /************************************* Functions for class config ***************************/ … … 174 33 /** Constructor for config file class. 175 34 */ 176 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 177 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL), 178 ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 35 config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), 36 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 179 37 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 180 38 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), … … 186 44 pseudopotpath = new char[MAXSTRINGSIZE]; 187 45 databasepath = new char[MAXSTRINGSIZE]; 188 configpath = new char[MAXSTRINGSIZE];189 46 configname = new char[MAXSTRINGSIZE]; 47 Thermostats = new ThermoStatContainer(); 190 48 strcpy(mainname,"pcp"); 191 49 strcpy(defaultpath,"not specified"); 192 50 strcpy(pseudopotpath,"not specified"); 193 configpath[0]='\0';194 51 configname[0]='\0'; 195 52 basis = "3-21G"; 196 197 InitThermostats();198 53 }; 199 54 … … 206 61 delete[](pseudopotpath); 207 62 delete[](databasepath); 208 delete[](configpath);209 63 delete[](configname); 210 delete[](ThermostatImplemented); 211 for (int j=0;j<MaxThermostats;j++) 212 delete[](ThermostatNames[j]); 213 delete[](ThermostatNames); 64 if (Thermostats != NULL) 65 delete(Thermostats); 214 66 215 67 if (BG != NULL) 216 68 delete(BG); 217 69 }; 218 219 /** Initialises variables in class config for Thermostats.220 */221 void config::InitThermostats()222 {223 ThermostatImplemented = new int[MaxThermostats];224 ThermostatNames = new char *[MaxThermostats];225 for (int j=0;j<MaxThermostats;j++)226 ThermostatNames[j] = new char[12];227 228 strcpy(ThermostatNames[0],"None");229 ThermostatImplemented[0] = 1;230 strcpy(ThermostatNames[1],"Woodcock");231 ThermostatImplemented[1] = 1;232 strcpy(ThermostatNames[2],"Gaussian");233 ThermostatImplemented[2] = 1;234 strcpy(ThermostatNames[3],"Langevin");235 ThermostatImplemented[3] = 1;236 strcpy(ThermostatNames[4],"Berendsen");237 ThermostatImplemented[4] = 1;238 strcpy(ThermostatNames[5],"NoseHoover");239 ThermostatImplemented[5] = 1;240 };241 242 /** Readin of Thermostat related values from parameter file.243 * \param *fb file buffer containing the config file244 */245 void config::ParseThermostats(class ConfigFileBuffer * const fb)246 {247 char * const thermo = new char[12];248 const int verbose = 0;249 250 // read desired Thermostat from file along with needed additional parameters251 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {252 if (strcmp(thermo, ThermostatNames[0]) == 0) { // None253 if (ThermostatImplemented[0] == 1) {254 Thermostat = None;255 } else {256 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);257 Thermostat = None;258 }259 } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock260 if (ThermostatImplemented[1] == 1) {261 Thermostat = Woodcock;262 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency263 } else {264 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);265 Thermostat = None;266 }267 } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian268 if (ThermostatImplemented[2] == 1) {269 Thermostat = Gaussian;270 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate271 } else {272 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);273 Thermostat = None;274 }275 } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin276 if (ThermostatImplemented[3] == 1) {277 Thermostat = Langevin;278 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma279 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {280 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);281 } else {282 alpha = 1.;283 }284 } else {285 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);286 Thermostat = None;287 }288 } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen289 if (ThermostatImplemented[4] == 1) {290 Thermostat = Berendsen;291 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T292 } else {293 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);294 Thermostat = None;295 }296 } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover297 if (ThermostatImplemented[5] == 1) {298 Thermostat = NoseHoover;299 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass300 alpha = 0.;301 } else {302 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);303 Thermostat = None;304 }305 } else {306 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);307 Thermostat = None;308 }309 } else {310 if ((MaxOuterStep > 0) && (TargetTemp != 0))311 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl);312 Thermostat = None;313 }314 delete[](thermo);315 };316 317 70 318 71 /** Displays menu for editing each entry of the config file. … … 629 382 }; 630 383 631 /** Retrieves the path in the given config file name.632 * \param filename config file string633 */634 void config::RetrieveConfigPathAndName(const string filename)635 {636 char *ptr = NULL;637 char *buffer = new char[MAXSTRINGSIZE];638 strncpy(buffer, filename.c_str(), MAXSTRINGSIZE);639 int last = -1;640 for(last=MAXSTRINGSIZE;last--;) {641 if (buffer[last] == '/')642 break;643 }644 if (last == -1) { // no path in front, set to local directory.645 strcpy(configpath, "./");646 ptr = buffer;647 } else {648 strncpy(configpath, buffer, last+1);649 ptr = &buffer[last+1];650 if (last < 254)651 configpath[last+1]='\0';652 }653 strcpy(configname, ptr);654 DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);655 delete[](buffer);656 };657 658 /** Initializes ConfigFileBuffer from a file.659 * \param *file input file stream being the opened config file660 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL661 */662 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)663 {664 if (FileBuffer != NULL) {665 DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);666 delete(FileBuffer);667 }668 FileBuffer = new ConfigFileBuffer(filename);669 670 FileBuffer->InitMapping();671 };672 673 384 /** Loads a molecule from a ConfigFileBuffer. 674 385 * \param *mol molecule to load … … 864 575 file->close(); 865 576 delete(file); 866 RetrieveConfigPathAndName(filename);867 577 868 578 // ParseParameterFile 869 struct ConfigFileBuffer *FileBuffer = NULL; 870 PrepareFileBuffer(filename,FileBuffer); 579 class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 871 580 872 581 /* Oeffne Hauptparameterdatei */ … … 877 586 int verbose = 0; 878 587 588 //TODO: This is actually sensible?: if (MaxOuterStep > 0) 879 589 ParseThermostats(FileBuffer); 880 590 … … 941 651 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 942 652 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 943 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &( config::TargetTemp), 1, optional);653 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional); 944 654 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 945 655 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) … … 971 681 // Unit cell and magnetic field 972 682 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 973 double * c onst cell_size = World::getInstance().getDomain();683 double * cell_size = new double[6]; 974 684 cell_size[0] = BoxLength[0]; 975 685 cell_size[1] = BoxLength[3]; … … 978 688 cell_size[4] = BoxLength[7]; 979 689 cell_size[5] = BoxLength[8]; 690 World::getInstance().setDomain(cell_size); 691 delete cell_size; 980 692 //if (1) fprintf(stderr,"\n"); 981 693 … … 1101 813 return; 1102 814 } 1103 RetrieveConfigPathAndName(filename);1104 815 // ParseParameters 1105 816 … … 1150 861 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 1151 862 ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 1152 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &( config::TargetTemp), 1, optional);1153 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &( config::ScaleTempStep), 1, optional);863 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional); 864 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(Thermostats->ScaleTempStep), 1, optional); 1154 865 config::EpsWannier = 1e-8; 1155 866 … … 1176 887 1177 888 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 1178 double * c onst cell_size = World::getInstance().getDomain();889 double * cell_size = new double[6]; 1179 890 cell_size[0] = BoxLength[0]; 1180 891 cell_size[1] = BoxLength[3]; … … 1183 894 cell_size[4] = BoxLength[7]; 1184 895 cell_size[5] = BoxLength[8]; 896 World::getInstance().setDomain(cell_size); 897 delete[] cell_size; 1185 898 if (1) fprintf(stderr,"\n"); 1186 899 config::DoPerturbation = 0; … … 1318 1031 { 1319 1032 bool result = true; 1320 // bring MaxTypes up to date 1321 mol->CountElements(); 1322 const double * const cell_size = World::getInstance().getDomain(); 1033 const Matrix &domain = World::getInstance().getDomain().getM(); 1323 1034 ofstream * const output = new ofstream(filename, ios::out); 1324 1035 if (output != NULL) { … … 1339 1050 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1340 1051 *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl; 1341 *output << "Thermostat\t" << Thermostat Names[Thermostat] << "\t";1342 switch(Thermostat ) {1052 *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t"; 1053 switch(Thermostats->Thermostat) { 1343 1054 default: 1344 1055 case None: 1345 1056 break; 1346 1057 case Woodcock: 1347 *output << ScaleTempStep;1058 *output << Thermostats->ScaleTempStep; 1348 1059 break; 1349 1060 case Gaussian: 1350 *output << ScaleTempStep;1061 *output << Thermostats->ScaleTempStep; 1351 1062 break; 1352 1063 case Langevin: 1353 *output << T empFrequency << "\t" <<alpha;1064 *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha; 1354 1065 break; 1355 1066 case Berendsen: 1356 *output << T empFrequency;1067 *output << Thermostats->TempFrequency; 1357 1068 break; 1358 1069 case NoseHoover: 1359 *output << HooverMass;1070 *output << Thermostats->HooverMass; 1360 1071 break; 1361 1072 }; … … 1372 1083 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1373 1084 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; 1374 *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl;1085 *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl; 1375 1086 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1376 1087 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; … … 1391 1102 *output << endl; 1392 1103 *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl; 1393 *output << cell_size[0]<< "\t" << endl;1394 *output << cell_size[1] << "\t" << cell_size[2]<< "\t" << endl;1395 *output << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5]<< "\t" << endl;1104 *output << domain.at(0,0) << "\t" << endl; 1105 *output << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl; 1106 *output << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl; 1396 1107 // FIXME 1397 1108 *output << endl; … … 1425 1136 *output << "IsAngstroem\t" << config::IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl; 1426 1137 *output << "RelativeCoord\t" << config::RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl; 1427 *output << "MaxTypes\t" << mol-> ElementCount<< "\t# maximum number of different ion types" << endl;1138 *output << "MaxTypes\t" << mol->getElementCount() << "\t# maximum number of different ion types" << endl; 1428 1139 *output << endl; 1429 1140 result = result && mol->Checkout(output); … … 1483 1194 // output of atoms 1484 1195 AtomNo = 0; 1485 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1196 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1486 1197 delete(center); 1487 1198 *output << "\t}" << endl; … … 1525 1236 // output of atoms 1526 1237 AtomNo = 0; 1527 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1238 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1528 1239 delete(center); 1529 1240 *output << "\t}" << endl; … … 1784 1495 char filename[MAXSTRINGSIZE]; 1785 1496 ofstream output; 1786 molecule *mol = World::getInstance().createMolecule(); 1787 mol->SetNameFromFilename(ConfigFileName); 1788 1789 if (!strcmp(configpath, GetDefaultPath())) { 1790 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1791 } 1792 1497 molecule *mol = NULL; 1793 1498 1794 1499 // first save as PDB data … … 1816 1521 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1817 1522 int N = molecules->ListOfMolecules.size(); 1818 int *src = new int[N]; 1819 N=0; 1820 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1821 src[N++] = (*ListRunner)->IndexNr; 1822 (*ListRunner)->Translate(&(*ListRunner)->Center); 1823 } 1824 molecules->SimpleMultiAdd(mol, src, N); 1825 delete[](src); 1826 1827 // ... and translate back 1828 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1829 (*ListRunner)->Center.Scale(-1.); 1830 (*ListRunner)->Translate(&(*ListRunner)->Center); 1831 (*ListRunner)->Center.Scale(-1.); 1523 if (N != 1) { // don't do anything in case of only one molecule (shifts mol ids otherwise) 1524 int *src = new int[N]; 1525 N=0; 1526 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1527 src[N++] = (*ListRunner)->IndexNr; 1528 (*ListRunner)->Translate(&(*ListRunner)->Center); 1529 } 1530 mol = World::getInstance().createMolecule(); 1531 mol->SetNameFromFilename(ConfigFileName); 1532 molecules->SimpleMultiMerge(mol, src, N); 1533 //mol->CalculateOrbitals(*this); 1534 delete[](src); 1535 } else { 1536 if (!molecules->ListOfMolecules.empty()) { 1537 mol = *(molecules->ListOfMolecules.begin()); 1538 mol->doCountAtoms(); 1539 //mol->CalculateOrbitals(*this); 1540 } else { 1541 DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl); 1542 } 1832 1543 } 1833 1544 1834 1545 Log() << Verbose(0) << "Storing configuration ... " << endl; 1835 1546 // get correct valence orbitals 1836 mol->CalculateOrbitals(*this);1837 InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;1838 1547 if (ConfigFileName != NULL) { // test the file name 1839 1548 strcpy(filename, ConfigFileName); … … 1891 1600 Log() << Verbose(0) << "\t... failed." << endl; 1892 1601 1893 if (!strcmp(configpath, GetDefaultPath())) { 1894 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1895 } 1896 1897 World::getInstance().destroyMolecule(mol); 1602 // don't destroy molecule as it contains all our atoms 1603 //World::getInstance().destroyMolecule(mol); 1898 1604 }; 1899 1605 … … 2340 2046 return (found); // true if found, false if not 2341 2047 } 2048 2049 /** Reading of Thermostat related values from parameter file. 2050 * \param *fb file buffer containing the config file 2051 */ 2052 void config::ParseThermostats(class ConfigFileBuffer * const fb) 2053 { 2054 char * const thermo = new char[12]; 2055 const int verbose = 0; 2056 2057 // read desired Thermostat from file along with needed additional parameters 2058 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) { 2059 if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None 2060 if (Thermostats->ThermostatImplemented[0] == 1) { 2061 Thermostats->Thermostat = None; 2062 } else { 2063 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2064 Thermostats->Thermostat = None; 2065 } 2066 } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock 2067 if (Thermostats->ThermostatImplemented[1] == 1) { 2068 Thermostats->Thermostat = Woodcock; 2069 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency 2070 } else { 2071 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2072 Thermostats->Thermostat = None; 2073 } 2074 } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian 2075 if (Thermostats->ThermostatImplemented[2] == 1) { 2076 Thermostats->Thermostat = Gaussian; 2077 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate 2078 } else { 2079 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2080 Thermostats->Thermostat = None; 2081 } 2082 } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin 2083 if (Thermostats->ThermostatImplemented[3] == 1) { 2084 Thermostats->Thermostat = Langevin; 2085 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma 2086 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) { 2087 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl); 2088 } else { 2089 Thermostats->alpha = 1.; 2090 } 2091 } else { 2092 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2093 Thermostats->Thermostat = None; 2094 } 2095 } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen 2096 if (Thermostats->ThermostatImplemented[4] == 1) { 2097 Thermostats->Thermostat = Berendsen; 2098 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T 2099 } else { 2100 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2101 Thermostats->Thermostat = None; 2102 } 2103 } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover 2104 if (Thermostats->ThermostatImplemented[5] == 1) { 2105 Thermostats->Thermostat = NoseHoover; 2106 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass 2107 Thermostats->alpha = 0.; 2108 } else { 2109 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2110 Thermostats->Thermostat = None; 2111 } 2112 } else { 2113 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl); 2114 Thermostats->Thermostat = None; 2115 } 2116 } else { 2117 if ((Thermostats->TargetTemp != 0)) 2118 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl); 2119 Thermostats->Thermostat = None; 2120 } 2121 delete[](thermo); 2122 }; 2123 -
src/config.hpp
r06f4ef6 rb6da28 20 20 #include <string> 21 21 22 #include "bondgraph.hpp"23 24 22 /****************************************** forward declarations *****************************/ 25 23 24 class BondGraph; 25 class ConfigFileBuffer; 26 26 class molecule; 27 27 class MoleculeListClass; 28 28 class periodentafel; 29 class ThermoStatContainer; 29 30 30 31 /********************************************** declarations *******************************/ 31 32 class ConfigFileBuffer {33 public:34 char **buffer;35 int *LineMapping;36 int CurrentLine;37 int NoLines;38 39 ConfigFileBuffer();40 ConfigFileBuffer(const char * const filename);41 ~ConfigFileBuffer();42 43 void InitMapping();44 void MapIonTypesInBuffer(const int NoAtoms);45 };46 32 47 33 /** The config file. … … 51 37 public: 52 38 class BondGraph *BG; 39 class ThermoStatContainer *Thermostats; 53 40 54 41 int PsiType; … … 60 47 int ProcPEGamma; 61 48 int ProcPEPsi; 62 char *configpath;63 49 char *configname; 64 50 bool FastParsing; … … 70 56 int DoConstrainedMD; 71 57 int MaxOuterStep; 72 int Thermostat;73 int *ThermostatImplemented;74 char **ThermostatNames;75 double TempFrequency;76 double alpha;77 double HooverMass;78 double TargetTemp;79 int ScaleTempStep;80 58 81 59 private: … … 138 116 void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList); 139 117 void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList); 140 void RetrieveConfigPathAndName(const string filename);141 118 bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const; 142 119 bool SaveMPQC(const char * const filename, const molecule * const mol) const; … … 152 129 char *GetDefaultPath() const; 153 130 void SetDefaultPath(const char * const path); 154 void InitThermostats();155 131 void ParseThermostats(class ConfigFileBuffer * const fb); 156 132 }; -
src/datacreator.cpp
r06f4ef6 rb6da28 12 12 #include "helpers.hpp" 13 13 #include "parser.hpp" 14 #include "verbose.hpp" 15 16 #include <iomanip> 14 17 15 18 //=========================== FUNCTIONS============================ -
src/datacreator.hpp
r06f4ef6 rb6da28 10 10 using namespace std; 11 11 12 #include <ios tream>12 #include <iosfwd> 13 13 14 14 /****************************************** forward declarations *****************************/ -
src/defs.hpp
r06f4ef6 rb6da28 82 82 #define STD_SEPERATOR_SPACER '-' 83 83 84 #define MOLECUILDER_NAME "Molecuilder" 85 86 const extern unsigned int MAX_POOL_FRAGMENTATION; 87 const extern unsigned int MAX_FRAGMENTATION_SKIPS; 88 84 89 #endif /*DEFS_HPP_*/ -
src/element.cpp
r06f4ef6 rb6da28 26 26 next(NULL), 27 27 sort(NULL), 28 No(-1),29 28 Valence(0), 30 29 NoValenceOrbitals(0) … … 70 69 return string(symbol); 71 70 } 71 72 std::string element::getName() const{ 73 return string(name); 74 } 75 76 std::ostream &operator<<(std::ostream &ost,const element &elem){ 77 ost << elem.getName() << "(" << elem.getNumber() << ")"; 78 return ost; 79 } -
src/element.hpp
r06f4ef6 rb6da28 16 16 #endif 17 17 18 #include <ios tream>18 #include <iosfwd> 19 19 #include <string> 20 20 … … 41 41 element *next; //!< next element in list 42 42 int *sort; //!< sorc criteria 43 int No; //!< number of element set on periodentafel::Output()44 43 double Valence; //!< number of valence electrons for this element 45 44 int NoValenceOrbitals; //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix() … … 53 52 atomicNumber_t getNumber() const; 54 53 std::string getSymbol() const; 54 std::string getName() const; 55 55 56 56 //> print element entries to screen … … 61 61 }; 62 62 63 std::ostream &operator<<(std::ostream&,const element&); 63 64 64 65 #endif /* ELEMENT_HPP_ */ -
src/ellipsoid.cpp
r06f4ef6 rb6da28 21 21 #include "tesselation.hpp" 22 22 #include "vector.hpp" 23 #include "Matrix.hpp" 23 24 #include "verbose.hpp" 24 25 … … 34 35 Vector helper, RefPoint; 35 36 double distance = -1.; 36 double Matrix[NDIM*NDIM];37 Matrix Matrix; 37 38 double InverseLength[3]; 38 39 double psi,theta,phi; // euler angles in ZX'Z'' convention … … 51 52 theta = EllipsoidAngle[1]; 52 53 phi = EllipsoidAngle[2]; 53 Matrix [0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);54 Matrix [1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);55 Matrix [2] = sin(psi)*sin(theta);56 Matrix [3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);57 Matrix [4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);58 Matrix [5] = -cos(psi)*sin(theta);59 Matrix [6] = sin(theta)*sin(phi);60 Matrix [7] = sin(theta)*cos(phi);61 Matrix [8] = cos(theta);62 helper .MatrixMultiplication(Matrix);54 Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi)); 55 Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi)); 56 Matrix.set(2,0, sin(psi)*sin(theta)); 57 Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi)); 58 Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi)); 59 Matrix.set(2,1, -cos(psi)*sin(theta)); 60 Matrix.set(0,2, sin(theta)*sin(phi)); 61 Matrix.set(1,2, sin(theta)*cos(phi)); 62 Matrix.set(2,2, cos(theta)); 63 helper *= Matrix; 63 64 helper.ScaleAll(InverseLength); 64 65 //Log() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl; … … 73 74 phi = -EllipsoidAngle[2]; 74 75 helper.ScaleAll(EllipsoidLength); 75 Matrix [0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);76 Matrix [1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);77 Matrix [2] = sin(psi)*sin(theta);78 Matrix [3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);79 Matrix [4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);80 Matrix [5] = -cos(psi)*sin(theta);81 Matrix [6] = sin(theta)*sin(phi);82 Matrix [7] = sin(theta)*cos(phi);83 Matrix [8] = cos(theta);84 helper .MatrixMultiplication(Matrix);76 Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi)); 77 Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi)); 78 Matrix.set(2,0, sin(psi)*sin(theta)); 79 Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi)); 80 Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi)); 81 Matrix.set(2,1, -cos(psi)*sin(theta)); 82 Matrix.set(0,2, sin(theta)*sin(phi)); 83 Matrix.set(1,2, sin(theta)*cos(phi)); 84 Matrix.set(2,2, cos(theta)); 85 helper *= Matrix; 85 86 //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl; 86 87 -
src/errorlogger.cpp
r06f4ef6 rb6da28 9 9 10 10 #include <fstream> 11 #include <iostream> 11 12 #include "errorlogger.hpp" 12 13 #include "verbose.hpp" -
src/errorlogger.hpp
r06f4ef6 rb6da28 9 9 #define ERRORLOGGER_HPP_ 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 13 13 #include "Patterns/Singleton.hpp" -
src/graph.cpp
r06f4ef6 rb6da28 13 13 #include "config.hpp" 14 14 #include "graph.hpp" 15 #include "verbose.hpp" 15 16 #include "log.hpp" 16 17 #include "molecule.hpp" -
src/graph.hpp
r06f4ef6 rb6da28 27 27 class molecule; 28 28 29 class Graph;30 29 class SubGraph; 31 30 class Node; … … 34 33 /********************************************** definitions *********************************/ 35 34 36 #define NodeMap pair < int, class Node* > 37 #define EdgeMap multimap < class Node*, class Edge* > 35 typedef std::pair < int, class Node* > NodeMap; 36 typedef std::multimap < class Node*, class Edge* > EdgeMap; 38 37 39 #define KeyStack deque<int> 40 #define KeySet set<int> 41 #define NumberValuePair pair<int, double> 42 #define Graph map <KeySet, NumberValuePair, KeyCompare > 43 #define GraphPair pair <KeySet, NumberValuePair > 44 #define KeySetTestPair pair<KeySet::iterator, bool> 45 #define GraphTestPair pair<Graph::iterator, bool> 38 typedef std::deque<int> KeyStack; 39 typedef std::set<int> KeySet; 40 typedef std::pair<int, double> NumberValuePair; 46 41 47 48 /******************************** Some small functions and/or structures **********************************/ 49 42 // needed for definition of Graph and GraphTestPair 50 43 struct KeyCompare 51 44 { 52 45 bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const; 53 46 }; 47 48 typedef std::map <KeySet, NumberValuePair, KeyCompare > Graph; 49 typedef std::pair <KeySet, NumberValuePair > GraphPair; 50 typedef std::pair<KeySet::iterator, bool> KeySetTestPair; 51 typedef std::pair<Graph::iterator, bool> GraphTestPair; 52 53 54 /******************************** Some small functions and/or structures **********************************/ 54 55 55 56 //bool operator < (KeySet SubgraphA, KeySet SubgraphB); //note: this declaration is important, otherwise normal < is used (producing wrong order) -
src/gslvector.cpp
r06f4ef6 rb6da28 10 10 #include <cassert> 11 11 #include <cmath> 12 #include <iostream> 12 13 13 14 #include "gslvector.hpp" 14 15 #include "defs.hpp" 15 16 #include "vector.hpp" 17 #include "VectorContent.hpp" 16 18 17 19 /** Constructor of class GSLVector. … … 69 71 */ 70 72 void GSLVector::SetFromVector(Vector &v){ 71 gsl_vector_memcpy (vector, v.get() );73 gsl_vector_memcpy (vector, v.get()->content); 72 74 } 73 75 -
src/gslvector.hpp
r06f4ef6 rb6da28 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 #include <gsl/gsl_vector.h> 22 22 -
src/helpers.cpp
r06f4ef6 rb6da28 8 8 #include "helpers.hpp" 9 9 #include "Helpers/fast_functions.hpp" 10 #include "verbose.hpp" 10 11 #include "log.hpp" 11 #include "memoryusageobserver.hpp" 12 13 #include <iostream> 12 14 13 15 /********************************************** helpful functions *********************************/ … … 117 119 }; 118 120 119 /** Blows the 6-dimensional \a cell_size array up to a full NDIM by NDIM matrix.120 * \param *symm 6-dim array of unique symmetric matrix components121 * \return allocated NDIM*NDIM array with the symmetric matrix122 */123 double * ReturnFullMatrixforSymmetric(const double * const symm)124 {125 double *matrix = new double[NDIM * NDIM];126 matrix[0] = symm[0];127 matrix[1] = symm[1];128 matrix[2] = symm[3];129 matrix[3] = symm[1];130 matrix[4] = symm[2];131 matrix[5] = symm[4];132 matrix[6] = symm[3];133 matrix[7] = symm[4];134 matrix[8] = symm[5];135 return matrix;136 };137 138 /** Calculate the inverse of a 3x3 matrix.139 * \param *matrix NDIM_NDIM array140 */141 double * InverseMatrix( const double * const A)142 {143 double *B = new double[NDIM * NDIM];144 double detA = RDET3(A);145 double detAReci;146 147 for (int i=0;i<NDIM*NDIM;++i)148 B[i] = 0.;149 // calculate the inverse B150 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular151 detAReci = 1./detA;152 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11153 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12154 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13155 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21156 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22157 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23158 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31159 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32160 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33161 }162 return B;163 };164 165 166 167 121 /** Comparison function for GSL heapsort on distances in two molecules. 168 122 * \param *a -
src/helpers.hpp
r06f4ef6 rb6da28 20 20 #include "defs.hpp" 21 21 #include "log.hpp" 22 #include "memoryallocator.hpp"23 22 24 23 /********************************************** definitions *********************************/ … … 52 51 bool IsValidNumber( const char *string); 53 52 int CompareDoubles (const void * a, const void * b); 54 double * ReturnFullMatrixforSymmetric(const double * const cell_size);55 double * InverseMatrix(const double * const A);56 53 void performCriticalExit(); 57 54 … … 197 194 }; 198 195 196 /************ struct to contain simple enumerations ***************/ 197 template <class C> 198 struct enumeration{ 199 enumeration() : max(0) {} 200 enumeration(unsigned int i) : max(i) {} 201 enumeration(const enumeration &src) : 202 there(src.there), 203 back(src.back), 204 max(src.max) 205 {} 206 enumeration &operator=(const enumeration &src){ 207 /* no self-assignment check needed */ 208 there = src.there; 209 back = src.back; 210 max = src.max; 211 return *this; 212 } 213 void add(const C &value){ 214 if(!there.count(value)){ 215 there[value]=max; 216 back[max++]=value; 217 } 218 } 219 unsigned int getMax() const{ 220 return max; 221 } 222 223 map<C,unsigned int> there; 224 map<unsigned int,C> back; 225 private: 226 unsigned int max; 227 }; 228 229 /***** A counter to generate sequential numbers *******************/ 230 struct counter{ 231 inline counter() : count(0){}; 232 inline counter(int i) : count(i){}; 233 inline unsigned int operator()(){ 234 return count++; 235 } 236 private: 237 unsigned int count; 238 }; 239 240 template <class C,class ForwardIterator> 241 enumeration<C> enumerate(ForwardIterator first,ForwardIterator last){ 242 enumeration<C> res; 243 for_each(first,last,bind1st(mem_fun(&enumeration<C>::add),&res)); 244 return res; 245 } 246 199 247 #endif /*HELPERS_HPP_*/ -
src/joiner.cpp
r06f4ef6 rb6da28 14 14 #include "datacreator.hpp" 15 15 #include "helpers.hpp" 16 #include "memoryallocator.hpp"17 16 #include "parser.hpp" 18 17 #include "periodentafel.hpp" 18 #include "verbose.hpp" 19 19 20 20 //============================== MAIN ============================= -
src/linearsystemofequations.hpp
r06f4ef6 rb6da28 6 6 */ 7 7 8 using namespace std; 8 #ifndef LINEARSYSTEMSOFEQUATIONS_HPP 9 #define LINEARSYSTEMSOFEQUATIONS_HPP 9 10 10 11 /*********************************************** includes ***********************************/ … … 55 56 bool IsSymmetric; 56 57 }; 58 59 #endif /* LINEARSYSTEMSOFEQUATIONS_HPP */ -
src/linkedcell.cpp
r06f4ef6 rb6da28 10 10 #include "helpers.hpp" 11 11 #include "linkedcell.hpp" 12 #include "verbose.hpp" 12 13 #include "log.hpp" 13 14 #include "molecule.hpp" … … 187 188 N[i] = 0; 188 189 index = -1; 189 max.Zero();190 min.Zero();191 190 }; 192 191 … … 199 198 for(int i=0;i<NDIM;i++) 200 199 status = status && ((n[i] >=0) && (n[i] < N[i])); 201 if (!status)202 DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl);200 // if (!status) 201 // DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl); 203 202 return status; 204 203 }; … … 279 278 280 279 /** Calculates the interval bounds of the linked cell grid. 281 * \param *lower lower bounds282 * \param *upper upper bounds280 * \param lower lower bounds 281 * \param upper upper bounds 283 282 * \param step how deep to check the neighbouring cells (i.e. number of layers to check) 284 283 */ … … 286 285 { 287 286 for (int i=0;i<NDIM;i++) { 288 lower[i] = n[i]; 289 for (int s=step; s>0;--s) 290 if ((n[i]-s) >= 0) { 291 lower[i] = n[i]-s; 292 break; 293 } 294 upper[i] = n[i]; 295 for (int s=step; s>0;--s) 296 if ((n[i]+s) < N[i]) { 297 upper[i] = n[i]+s; 298 break; 299 } 287 lower[i] = n[i]-step; 288 if (lower[i] < 0) 289 lower[i] = 0; 290 if (lower[i] >= N[i]) 291 lower[i] = N[i]-1; 292 upper[i] = n[i]+step; 293 if (upper[i] >= N[i]) 294 upper[i] = N[i]-1; 295 if (upper[i] < 0) 296 upper[i] = 0; 300 297 //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl; 301 298 } -
src/log.hpp
r06f4ef6 rb6da28 12 12 #include "logger.hpp" 13 13 14 class logger *Log();15 class errorLogger *eLog();14 class logger & Log(); 15 class errorLogger & eLog(); 16 16 void setVerbosity(int verbosityLevel); 17 17 bool DoLog(int verbose); -
src/logger.cpp
r06f4ef6 rb6da28 9 9 10 10 #include <fstream> 11 #include <iostream> 11 12 #include "logger.hpp" 12 13 #include "verbose.hpp" -
src/logger.hpp
r06f4ef6 rb6da28 9 9 #define LOGGER_HPP_ 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 13 13 #include "Patterns/Singleton.hpp" -
src/molecule.cpp
r06f4ef6 rb6da28 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H 8 #include <config.h> 9 #endif 10 7 11 #include "Helpers/MemDebug.hpp" 8 12 9 13 #include <cstring> 10 14 #include <boost/bind.hpp> 15 #include <boost/foreach.hpp> 16 17 #include <gsl/gsl_inline.h> 18 #include <gsl/gsl_heapsort.h> 11 19 12 20 #include "World.hpp" … … 22 30 #include "log.hpp" 23 31 #include "molecule.hpp" 24 #include "memoryallocator.hpp" 32 25 33 #include "periodentafel.hpp" 26 34 #include "stackclass.hpp" 27 35 #include "tesselation.hpp" 28 36 #include "vector.hpp" 37 #include "Matrix.hpp" 29 38 #include "World.hpp" 39 #include "Box.hpp" 30 40 #include "Plane.hpp" 31 41 #include "Exceptions/LinearDependenceException.hpp" … … 39 49 molecule::molecule(const periodentafel * const teil) : 40 50 Observable("molecule"), 41 elemente(teil), MDSteps(0), BondCount(0), ElementCount(0),NoNonHydrogen(0), NoNonBonds(0),51 elemente(teil), MDSteps(0), BondCount(0), NoNonHydrogen(0), NoNonBonds(0), 42 52 NoCyclicBonds(0), BondDistance(0.), ActiveFlag(false), IndexNr(-1), 43 formula(this,boost::bind(&molecule::calcFormula,this),"formula"), 44 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer(begin()) 45 { 46 47 // other stuff 48 for(int i=MAX_ELEMENTS;i--;) 49 ElementsInMolecule[i] = 0; 53 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer(atoms.begin()) 54 { 55 50 56 strcpy(name,World::getInstance().getDefaultName().c_str()); 51 57 }; … … 79 85 void molecule::setName(const std::string _name){ 80 86 OBSERVE; 87 cout << "Set name of molecule " << getId() << " to " << _name << endl; 81 88 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 82 89 } … … 90 97 } 91 98 92 const std::string molecule::getFormula(){ 93 return *formula; 94 } 95 96 std::string molecule::calcFormula(){ 97 std::map<atomicNumber_t,unsigned int> counts; 98 stringstream sstr; 99 periodentafel *periode = World::getInstance().getPeriode(); 100 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 101 counts[(*iter)->type->getNumber()]++; 102 } 103 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; 104 for(iter = counts.rbegin(); iter != counts.rend(); ++iter) { 105 atomicNumber_t Z = (*iter).first; 106 sstr << periode->FindElement(Z)->symbol << (*iter).second; 107 } 108 return sstr.str(); 99 const Formula &molecule::getFormula(){ 100 return formula; 101 } 102 103 unsigned int molecule::getElementCount(){ 104 return formula.getElementCount(); 105 } 106 107 bool molecule::hasElement(const element *element) const{ 108 return formula.hasElement(element); 109 } 110 111 bool molecule::hasElement(atomicNumber_t Z) const{ 112 return formula.hasElement(Z); 113 } 114 115 bool molecule::hasElement(const string &shorthand) const{ 116 return formula.hasElement(shorthand); 109 117 } 110 118 … … 143 151 molecule::const_iterator molecule::erase( const_iterator loc ) 144 152 { 153 OBSERVE; 145 154 molecule::const_iterator iter = loc; 146 155 iter--; 147 156 atom* atom = *loc; 148 atoms.erase( loc ); 157 atomIds.erase( atom->getId() ); 158 atoms.remove( atom ); 159 formula-=atom->type; 149 160 atom->removeFromMolecule(); 150 161 return iter; … … 153 164 molecule::const_iterator molecule::erase( atom * key ) 154 165 { 155 cout << "trying to erase atom" << endl;166 OBSERVE; 156 167 molecule::const_iterator iter = find(key); 157 168 if (iter != end()){ 158 atoms.erase( iter++ ); 169 atomIds.erase( key->getId() ); 170 atoms.remove( key ); 171 formula-=key->type; 159 172 key->removeFromMolecule(); 160 173 } … … 164 177 molecule::const_iterator molecule::find ( atom * key ) const 165 178 { 166 return atoms.find( key ); 179 molecule::const_iterator iter; 180 for (molecule::const_iterator Runner = begin(); Runner != end(); ++Runner) { 181 if (*Runner == key) 182 return molecule::const_iterator(Runner); 183 } 184 return molecule::const_iterator(atoms.end()); 167 185 } 168 186 169 187 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 170 188 { 171 pair<atomSet::iterator,bool> res = atoms.insert(key); 172 return pair<iterator,bool>(iterator(res.first,this),res.second); 189 OBSERVE; 190 pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId()); 191 if (res.second) { // push atom if went well 192 atoms.push_back(key); 193 formula+=key->type; 194 return pair<iterator,bool>(molecule::iterator(--end()),res.second); 195 } else { 196 return pair<iterator,bool>(molecule::iterator(end()),res.second); 197 } 173 198 } 174 199 175 200 bool molecule::containsAtom(atom* key){ 176 return atoms.count(key);201 return (find(key) != end()); 177 202 } 178 203 … … 188 213 pointer->sort = &pointer->nr; 189 214 if (pointer->type != NULL) { 190 if (ElementsInMolecule[pointer->type->Z] == 0) 191 ElementCount++; 192 ElementsInMolecule[pointer->type->Z]++; // increase number of elements 215 formula += pointer->type; 193 216 if (pointer->type->Z != 1) 194 217 NoNonHydrogen++; … … 216 239 if (pointer != NULL) { 217 240 atom *walker = pointer->clone(); 241 formula += walker->type; 218 242 walker->setName(pointer->getName()); 219 243 walker->nr = last_atom++; // increase number within molecule … … 272 296 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 273 297 Vector InBondvector; // vector in direction of *Bond 274 double *matrix = NULL;298 const Matrix &matrix = World::getInstance().getDomain().getM(); 275 299 bond *Binder = NULL; 276 double * const cell_size = World::getInstance().getDomain();277 300 278 301 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 295 318 } // (signs are correct, was tested!) 296 319 } 297 matrix = ReturnFullMatrixforSymmetric(cell_size); 298 Orthovector1.MatrixMultiplication(matrix); 320 Orthovector1 *= matrix; 299 321 InBondvector -= Orthovector1; // subtract just the additional translation 300 delete[](matrix);301 322 bondlength = InBondvector.Norm(); 302 323 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 529 550 break; 530 551 } 531 delete[](matrix);532 552 533 553 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 606 626 { 607 627 molecule *copy = World::getInstance().createMolecule(); 608 atom *LeftAtom = NULL, *RightAtom = NULL;609 628 610 629 // copy all atoms 611 ActOnCopyWithEachAtom ( &molecule::AddCopyAtom, copy);630 for_each(atoms.begin(),atoms.end(),bind1st(mem_fun(&molecule::AddCopyAtom),copy)); 612 631 613 632 // copy all bonds 614 bond *Binder = NULL;615 bond *NewBond = NULL;616 633 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 617 634 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 618 635 if ((*BondRunner)->leftatom == *AtomRunner) { 619 Binder = (*BondRunner);636 bond *Binder = (*BondRunner); 620 637 621 638 // get the pendant atoms of current bond in the copy molecule 622 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom ); 623 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom ); 624 625 NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree); 639 atomSet::iterator leftiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->leftatom)); 640 atomSet::iterator rightiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->rightatom)); 641 ASSERT(leftiter!=atoms.end(),"No original left atom for bondcopy found"); 642 ASSERT(leftiter!=atoms.end(),"No original right atom for bondcopy found"); 643 atom *LeftAtom = *leftiter; 644 atom *RightAtom = *rightiter; 645 646 bond *NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree); 626 647 NewBond->Cyclic = Binder->Cyclic; 627 648 if (Binder->Cyclic) … … 630 651 } 631 652 // correct fathers 632 ActOnAllAtoms( &atom::CorrectFather);653 for_each(atoms.begin(),atoms.end(),mem_fun(&atom::CorrectFather)); 633 654 634 655 // copy values 635 copy->CountElements();636 656 if (hasBondStructure()) { // if adjaceny list is present 637 657 copy->BondDistance = BondDistance; … … 648 668 * @param three vectors forming the matrix that defines the shape of the parallelpiped 649 669 */ 650 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {670 molecule* molecule::CopyMoleculeFromSubRegion(const Shape ®ion) const { 651 671 molecule *copy = World::getInstance().createMolecule(); 652 672 653 ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped ); 673 BOOST_FOREACH(atom *iter,atoms){ 674 if(iter->IsInShape(region)){ 675 copy->AddCopyAtom(iter); 676 } 677 } 654 678 655 679 //TODO: copy->BuildInducedSubgraph(this); … … 728 752 else 729 753 length = strlen(molname) - strlen(endname); 754 cout << "Set name of molecule " << getId() << " to " << molname << endl; 730 755 strncpy(name, molname, length); 731 756 name[length]='\0'; … … 737 762 void molecule::SetBoxDimension(Vector *dim) 738 763 { 739 double * const cell_size = World::getInstance().getDomain(); 740 cell_size[0] = dim->at(0); 741 cell_size[1] = 0.; 742 cell_size[2] = dim->at(1); 743 cell_size[3] = 0.; 744 cell_size[4] = 0.; 745 cell_size[5] = dim->at(2); 764 Matrix domain; 765 for(int i =0; i<NDIM;++i) 766 domain.at(i,i) = dim->at(i); 767 World::getInstance().setDomain(domain); 746 768 }; 747 769 … … 754 776 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 755 777 OBSERVE; 756 if (ElementsInMolecule[pointer->type->Z] != 0) { // this would indicate an error 757 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 758 } else 759 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 760 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 761 ElementCount--; 778 formula-=pointer->type; 762 779 RemoveBonds(pointer); 763 780 erase(pointer); … … 773 790 if (pointer == NULL) 774 791 return false; 775 if (ElementsInMolecule[pointer->type->Z] != 0) // this would indicate an error 776 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 777 else 778 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 779 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 780 ElementCount--; 792 formula-=pointer->type; 781 793 erase(pointer); 782 794 return true; … … 790 802 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 791 803 erase(iter); 804 return empty(); 792 805 }; 793 806 … … 835 848 bool molecule::CheckBounds(const Vector *x) const 836 849 { 837 double * const cell_size = World::getInstance().getDomain();850 const Matrix &domain = World::getInstance().getDomain().getM(); 838 851 bool result = true; 839 int j =-1;840 852 for (int i=0;i<NDIM;i++) { 841 j += i+1; 842 result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j])); 853 result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i))); 843 854 } 844 855 //return result; … … 849 860 * \param *out output stream 850 861 */ 851 bool molecule::Output(ofstream * const output) 852 { 853 int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS]; 854 CountElements(); 855 856 for (int i=0;i<MAX_ELEMENTS;++i) { 857 AtomNo[i] = 0; 858 ElementNo[i] = 0; 859 } 862 bool molecule::Output(ostream * const output) 863 { 860 864 if (output == NULL) { 861 865 return false; 862 866 } else { 867 int AtomNo[MAX_ELEMENTS]; 868 memset(AtomNo,0,(MAX_ELEMENTS-1)*sizeof(*AtomNo)); 869 enumeration<const element*> elementLookup = formula.enumerateElements(); 870 for(map<const element*,unsigned int>::iterator iter=elementLookup.there.begin(); 871 iter!=elementLookup.there.end();++iter){ 872 cout << "Enumerated element " << *iter->first << " with number " << iter->second << endl; 873 } 863 874 *output << "#Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon)" << endl; 864 SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1); 865 int current=1; 866 for (int i=0;i<MAX_ELEMENTS;++i) { 867 if (ElementNo[i] == 1) 868 ElementNo[i] = current++; 869 } 870 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 875 for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputArrayIndexed,_1,output,elementLookup,AtomNo,(const char*)0)); 871 876 return true; 872 877 } … … 879 884 { 880 885 int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS]; 881 CountElements();882 886 883 887 if (output == NULL) { … … 912 916 { 913 917 DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl); 914 ActOnAllAtoms (&atom::OutputBondOfAtom);918 for_each(atoms.begin(),atoms.end(),mem_fun(&atom::OutputBondOfAtom)); 915 919 DoLog(0) && (Log() << Verbose(0) << endl); 916 920 }; … … 921 925 bool molecule::Checkout(ofstream * const output) const 922 926 { 923 return elemente->Checkout(output, ElementsInMolecule);927 return formula.checkOut(output); 924 928 }; 925 929 … … 935 939 for (int step=0;step<MDSteps;step++) { 936 940 *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now); 937 ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step);941 for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputTrajectoryXYZ,_1,output,step)); 938 942 } 939 943 return true; … … 952 956 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 953 957 *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now); 954 ActOnAllAtoms( &atom::OutputXYZLine, output);958 for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::OutputXYZLine),output)); 955 959 return true; 956 960 } else … … 979 983 }; 980 984 981 /** Brings molecule::ElementCount and molecule::ElementsInMolecule up-to-date.982 */983 void molecule::CountElements()984 {985 for(int i=MAX_ELEMENTS;i--;)986 ElementsInMolecule[i] = 0;987 ElementCount = 0;988 989 SetIndexedArrayForEachAtomTo ( ElementsInMolecule, &element::Z, &Increment, 1);990 991 for(int i=MAX_ELEMENTS;i--;)992 ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);993 };994 995 996 /** Counts necessary number of valence electrons and returns number and SpinType.997 * \param configuration containing everything998 */999 void molecule::CalculateOrbitals(class config &configuration)1000 {1001 configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0;1002 for(int i=MAX_ELEMENTS;i--;) {1003 if (ElementsInMolecule[i] != 0) {1004 //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;1005 configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);1006 }1007 }1008 configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2);1009 configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2;1010 configuration.MaxPsiDouble /= 2;1011 configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;1012 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2)) {1013 configuration.ProcPEGamma /= 2;1014 configuration.ProcPEPsi *= 2;1015 } else {1016 configuration.ProcPEGamma *= configuration.ProcPEPsi;1017 configuration.ProcPEPsi = 1;1018 }1019 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.MaxPsiDouble;1020 };1021 1022 985 /** Determines whether two molecules actually contain the same atoms and coordination. 1023 986 * \param *out output stream for debugging … … 1038 1001 /// first count both their atoms and elements and update lists thereby ... 1039 1002 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; 1040 CountElements();1041 OtherMolecule->CountElements();1042 1003 1043 1004 /// ... and compare: … … 1049 1010 } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl; 1050 1011 } 1051 /// -# ElementCount1012 /// -# Formula 1052 1013 if (result) { 1053 if ( ElementCount != OtherMolecule->ElementCount) {1054 DoLog(4) && (Log() << Verbose(4) << " ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount<< endl);1014 if (formula != OtherMolecule->formula) { 1015 DoLog(4) && (Log() << Verbose(4) << "Formulas don't match: " << formula << " == " << OtherMolecule->formula << endl); 1055 1016 result = false; 1056 } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl; 1057 } 1058 /// -# ElementsInMolecule 1059 if (result) { 1060 for (flag=MAX_ELEMENTS;flag--;) { 1061 //Log() << Verbose(5) << "Element " << flag << ": " << ElementsInMolecule[flag] << " <-> " << OtherMolecule->ElementsInMolecule[flag] << "." << endl; 1062 if (ElementsInMolecule[flag] != OtherMolecule->ElementsInMolecule[flag]) 1063 break; 1064 } 1065 if (flag < MAX_ELEMENTS) { 1066 DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl); 1067 result = false; 1068 } else Log() << Verbose(4) << "ElementsInMolecule match." << endl; 1017 } else Log() << Verbose(4) << "Formulas match: " << formula << " == " << OtherMolecule->formula << endl; 1069 1018 } 1070 1019 /// then determine and compare center of gravity for each molecule ... -
src/molecule.hpp
r06f4ef6 rb6da28 7 7 #define MOLECULES_HPP_ 8 8 9 using namespace std;10 11 9 /*********************************************** includes ***********************************/ 12 10 13 // GSL headers 14 #include <gsl/gsl_eigen.h> 15 #include <gsl/gsl_heapsort.h> 16 #include <gsl/gsl_linalg.h> 17 #include <gsl/gsl_matrix.h> 18 #include <gsl/gsl_multimin.h> 19 #include <gsl/gsl_vector.h> 20 #include <gsl/gsl_randist.h> 11 #ifdef HAVE_CONFIG_H 12 #include <config.h> 13 #endif 21 14 22 15 //// STL headers … … 29 22 #include <string> 30 23 31 #include " defs.hpp"24 #include "types.hpp" 32 25 #include "graph.hpp" 33 #include "stackclass.hpp"34 26 #include "tesselation.hpp" 35 27 #include "Patterns/Observer.hpp" 36 28 #include "Patterns/ObservedIterator.hpp" 37 29 #include "Patterns/Cacheable.hpp" 30 #include "Formula.hpp" 31 #include "AtomSet.hpp" 38 32 39 33 #include "Descriptors/MoleculeDescriptor_impl.hpp" … … 53 47 class periodentafel; 54 48 class Vector; 49 class Shape; 50 template <class> class StackClass; 55 51 56 52 /******************************** Some definitions for easier reading **********************************/ … … 81 77 }; 82 78 83 #define MaxThermostats 6 //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented84 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover }; //!< Thermostat names for output85 86 87 79 /** The complete molecule. 88 80 * Class incorporates number of types … … 93 85 94 86 public: 95 typedef std::set<atom*> atomSet; 87 typedef ATOMSET(std::list) atomSet; 88 typedef std::set<atomId_t> atomIdSet; 96 89 typedef ObservedIterator<atomSet> iterator; 97 90 typedef atomSet::const_iterator const_iterator; … … 106 99 //int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms() 107 100 int BondCount; //!< number of atoms, brought up-to-date by CountBonds() 108 int ElementCount; //!< how many unique elements are therein109 int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not110 101 mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule 111 102 mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule … … 118 109 119 110 private: 120 Cacheable<string>formula;111 Formula formula; 121 112 Cacheable<int> AtomCount; 122 113 moleculeId_t id; 123 atomSet atoms; //<!set of atoms 114 atomSet atoms; //<!list of atoms 115 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms 124 116 protected: 125 117 //void CountAtoms(); … … 143 135 void setId(moleculeId_t); 144 136 void setName(const std::string); 145 const std::string getFormula(); 146 std::string calcFormula(); 137 const Formula &getFormula(); 138 unsigned int getElementCount(); 139 bool hasElement(const element*) const; 140 bool hasElement(atomicNumber_t) const; 141 bool hasElement(const std::string&) const; 142 147 143 148 144 iterator begin(); … … 262 258 263 259 /// Count and change present atoms' coordination. 264 void CountElements();265 void CalculateOrbitals(class config &configuration);266 260 bool CenterInBox(); 267 261 bool BoundInBox(); … … 282 276 void SetBoxDimension(Vector *dim); 283 277 void ScanForPeriodicCorrection(); 284 bool VerletForceIntegration(char *file, config &configuration );278 bool VerletForceIntegration(char *file, config &configuration, const size_t offset); 285 279 void Thermostats(config &configuration, double ActualTemp, int Thermostat); 286 280 void PrincipalAxisSystem(bool DoRotate); … … 290 284 double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem); 291 285 void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force); 292 bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity);286 bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity); 293 287 294 288 bool CheckBounds(const Vector *x) const; … … 319 313 320 314 molecule *CopyMolecule(); 321 molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const;315 molecule* CopyMoleculeFromSubRegion(const Shape&) const; 322 316 323 317 /// Fragment molecule by two different approaches: 324 int FragmentMolecule(int Order, config *configuration);325 bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL);326 bool StoreBondsToFile( char *path, char *filename);327 bool StoreAdjacencyToFile( char *path, char *filename);328 bool CheckAdjacencyFileAgainstMolecule( char *path, atom **ListOfAtoms);329 bool ParseOrderAtSiteFromFile( char *path);330 bool StoreOrderAtSiteFile( char *path);331 bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);318 int FragmentMolecule(int Order, std::string &prefix); 319 bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path = ""); 320 bool StoreBondsToFile(std::string &filename, std::string path = ""); 321 bool StoreAdjacencyToFile(std::string &filename, std::string path = ""); 322 bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms); 323 bool ParseOrderAtSiteFromFile(std::string &path); 324 bool StoreOrderAtSiteFile(std::string &path); 325 bool StoreForcesFile(MoleculeListClass *BondFragments, std::string &path, int *SortIndex); 332 326 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 333 327 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); … … 347 341 348 342 // Output routines. 349 bool Output( ofstream * const output);343 bool Output(std::ostream * const output); 350 344 bool OutputTrajectories(ofstream * const output); 351 345 void OutputListOfBonds() const; … … 378 372 ~MoleculeListClass(); 379 373 380 bool AddHydrogenCorrection( char *path);381 bool StoreForcesFile( char *path, int *SortIndex);374 bool AddHydrogenCorrection(std::string &path); 375 bool StoreForcesFile(std::string &path, int *SortIndex); 382 376 void insert(molecule *mol); 383 377 void erase(molecule *mol); 384 378 molecule * ReturnIndex(int index); 385 bool OutputConfigForListOfFragments( config *configuration, int *SortIndex);379 bool OutputConfigForListOfFragments(std::string &prefix, int *SortIndex); 386 380 int NumberOfActiveMolecules(); 387 381 void Enumerate(ostream *out); … … 429 423 430 424 bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous); 431 bool FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList = false);425 bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false); 432 426 bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter); 433 427 bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false); 434 bool FillListOfLocalAtoms(atom ** *&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList);428 bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList); 435 429 void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph); 436 430 int Count() const; -
src/molecule_dynamics.cpp
r06f4ef6 rb6da28 13 13 #include "element.hpp" 14 14 #include "info.hpp" 15 #include "verbose.hpp" 15 16 #include "log.hpp" 16 #include "memoryallocator.hpp"17 17 #include "molecule.hpp" 18 18 #include "parser.hpp" 19 19 #include "Plane.hpp" 20 #include "ThermoStatContainer.hpp" 21 22 #include <gsl/gsl_matrix.h> 23 #include <gsl/gsl_vector.h> 24 #include <gsl/gsl_linalg.h> 20 25 21 26 /************************************* Functions for class molecule *********************************/ … … 472 477 * \param startstep stating initial configuration in molecule::Trajectories 473 478 * \param endstep stating final configuration in molecule::Trajectories 479 * \param &prefix path and prefix 474 480 * \param &config configuration structure 475 481 * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential() 476 482 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories 477 483 */ 478 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)484 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity) 479 485 { 480 486 molecule *mol = NULL; … … 524 530 for (int i=getAtomCount(); i--; ) 525 531 SortIndex[i] = i; 526 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 532 533 status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex); 527 534 delete[](SortIndex); 528 535 … … 537 544 * have to transform them). 538 545 * This adds a new MD step to the config file. 539 * \param *out output stream for debugging540 546 * \param *file filename 541 547 * \param config structure with config::Deltat, config::IsAngstroem, config::DoConstrained 542 * \param delta_t time step width in atomic units 543 * \param IsAngstroem whether coordinates are in angstroem (true) or bohrradius (false) 544 * \param DoConstrained whether we perform a constrained (>0, target step in molecule::trajectories) or unconstrained (0) molecular dynamics, \sa molecule::MinimiseConstrainedPotential() 548 * \param offset offset in matrix file to the first force component 545 549 * \return true - file found and parsed, false - file not found or imparsable 546 550 * \todo This is not yet checked if it is correctly working with DoConstrained set to true. 547 551 */ 548 bool molecule::VerletForceIntegration(char *file, config &configuration )552 bool molecule::VerletForceIntegration(char *file, config &configuration, const size_t offset) 549 553 { 550 554 Info FunctionInfo(__func__); … … 556 560 ForceMatrix Force; 557 561 558 CountElements(); // make sure ElementsInMolecule is up to date 559 562 const int AtomCount = getAtomCount(); 560 563 // check file 561 564 if (input == NULL) { … … 568 571 return false; 569 572 } 570 if (Force.RowCounter[0] != getAtomCount()) {573 if (Force.RowCounter[0] != AtomCount) { 571 574 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl); 572 575 performCriticalExit(); … … 575 578 // correct Forces 576 579 Velocity.Zero(); 577 for(int i=0;i< getAtomCount();i++)580 for(int i=0;i<AtomCount;i++) 578 581 for(int d=0;d<NDIM;d++) { 579 Velocity[d] += Force.Matrix[0][i][d+ 5];582 Velocity[d] += Force.Matrix[0][i][d+offset]; 580 583 } 581 for(int i=0;i< getAtomCount();i++)584 for(int i=0;i<AtomCount;i++) 582 585 for(int d=0;d<NDIM;d++) { 583 Force.Matrix[0][i][d+ 5] -= Velocity[d]/static_cast<double>(getAtomCount());586 Force.Matrix[0][i][d+offset] -= Velocity[d]/static_cast<double>(AtomCount); 584 587 } 585 588 // solve a constrained potential if we are meant to … … 596 599 //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 ); 597 600 598 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force );601 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force, (const size_t) 0); 599 602 } 600 603 // correct velocities (rather momenta) so that center of mass remains motionless … … 643 646 644 647 // calculate scale configuration 645 ScaleTempFactor = configuration.T argetTemp/ActualTemp;648 ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp; 646 649 647 650 // differentating between the various thermostats … … 651 654 break; 652 655 case Woodcock: 653 if ((configuration. ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {656 if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) { 654 657 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl); 655 658 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); … … 684 687 delta_alpha = 0.; 685 688 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 686 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.T argetTemp)/(configuration.HooverMass*Units2Electronmass);687 configuration. alpha += delta_alpha*configuration.Deltat;688 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration. alpha << "." << endl);689 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.Thermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass); 690 configuration.Thermostats->alpha += delta_alpha*configuration.Deltat; 691 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.Thermostats->alpha << "." << endl); 689 692 // apply updated alpha as additional force 690 693 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration ); -
src/molecule_fragmentation.cpp
r06f4ef6 rb6da28 17 17 #include "helpers.hpp" 18 18 #include "lists.hpp" 19 #include "verbose.hpp" 19 20 #include "log.hpp" 20 #include "memoryallocator.hpp"21 21 #include "molecule.hpp" 22 22 #include "periodentafel.hpp" 23 23 #include "World.hpp" 24 #include "Matrix.hpp" 25 #include "Box.hpp" 26 #include "stackclass.hpp" 24 27 25 28 /************************************* Functions for class molecule *********************************/ … … 82 85 * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly 83 86 * Finally, the temporary graph is inserted into the given \a FragmentList for return. 84 * \param *out output stream for debugging 85 * \param *path path to file 87 * \param &path path to file 86 88 * \param *FragmentList empty, filled on return 87 89 * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL) 88 90 */ 89 bool ParseKeySetFile( char *path, Graph *&FragmentList)91 bool ParseKeySetFile(std::string &path, Graph *&FragmentList) 90 92 { 91 93 bool status = true; … … 94 96 GraphTestPair testGraphInsert; 95 97 int NumberOfFragments = 0; 96 char filename[MAXSTRINGSIZE];98 string filename; 97 99 98 100 if (FragmentList == NULL) { // check list pointer … … 102 104 // 1st pass: open file and read 103 105 DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl); 104 sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE);105 InputFile.open(filename );106 if (InputFile != NULL) {106 filename = path + KEYSETFILE; 107 InputFile.open(filename.c_str()); 108 if (InputFile.good()) { 107 109 // each line represents a new fragment 108 110 char buffer[MAXSTRINGSIZE]; … … 181 183 182 184 /** Stores key sets to file. 183 * \param *out output stream for debugging184 185 * \param KeySetList Graph with Keysets 185 * \param *path path to file186 * \param &path path to file 186 187 * \return true - file written successfully, false - writing failed 187 188 */ 188 bool StoreKeySetFile(Graph &KeySetList, char *path) 189 { 190 ofstream output; 189 bool StoreKeySetFile(Graph &KeySetList, std::string &path) 190 { 191 191 bool status = true; 192 string line; 192 string line = path + KEYSETFILE; 193 ofstream output(line.c_str()); 193 194 194 195 // open KeySet file 195 line = path;196 line.append("/");197 line += FRAGMENTPREFIX;198 line += KEYSETFILE;199 output.open(line.c_str(), ios::out);200 196 DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... "); 201 if(output != NULL) {197 if(output.good()) { 202 198 for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) { 203 199 for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) { … … 302 298 303 299 /** Scans the adaptive order file and insert (index, value) into map. 304 * \param *out output stream for debugging 305 * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative) 300 * \param &path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative) 306 301 * \param &IndexedKeySetList list to find key set for a given index \a No 307 302 * \return adaptive criteria list from file 308 303 */ 309 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap( char *path, map<int,KeySet> &IndexKeySetList)304 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(std::string &path, map<int,KeySet> &IndexKeySetList) 310 305 { 311 306 map<int, pair<double,int> > *AdaptiveCriteriaList = new map<int, pair<double,int> >; … … 313 308 double Value = 0.; 314 309 char buffer[MAXSTRINGSIZE]; 315 sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT); 316 ifstream InputFile(buffer, ios::in); 310 string filename = path + ENERGYPERFRAGMENT; 311 ifstream InputFile(filename.c_str()); 312 313 if (InputFile.fail()) { 314 DoeLog(1) && (eLog() << Verbose(1) << "Cannot find file " << filename << "." << endl); 315 return AdaptiveCriteriaList; 316 } 317 317 318 318 if (CountLinesinFile(InputFile) > 0) { … … 419 419 420 420 /** Checks whether the OrderAtSite is still below \a Order at some site. 421 * \param *out output stream for debugging422 421 * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively 423 422 * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase 424 423 * \param Order desired Order if positive, desired exponent in threshold criteria if negative (0 is single-step) 425 424 * \param *MinimumRingSize array of max. possible order to avoid loops 426 * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)425 * \param path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative) 427 426 * \return true - needs further fragmentation, false - does not need fragmentation 428 427 */ 429 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)428 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path) 430 429 { 431 430 bool status = false; … … 585 584 * of vertex indices: Global always means the index in "this" molecule, whereas local refers to the molecule or 586 585 * subgraph in the MoleculeListClass. 587 * \param *out output stream for debugging588 586 * \param Order up to how many neighbouring bonds a fragment contains in BondOrderScheme::BottumUp scheme 589 * \param *configuration configuration for writing config files for each fragment587 * \param &prefix path and prefix of the bond order configs to be written 590 588 * \return 1 - continue, 2 - stop (no fragmentation occured) 591 589 */ 592 int molecule::FragmentMolecule(int Order, config *configuration)590 int molecule::FragmentMolecule(int Order, std::string &prefix) 593 591 { 594 592 MoleculeListClass *BondFragments = NULL; … … 624 622 625 623 // === compare it with adjacency file === 626 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule( configuration->configpath, ListOfAtoms);624 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(prefix, ListOfAtoms); 627 625 delete[](ListOfAtoms); 628 626 … … 634 632 MinimumRingSize[i] = getAtomCount(); 635 633 MolecularWalker = Subgraphs; 634 const int LeafCount = Subgraphs->next->Count(); 636 635 FragmentCounter = 0; 637 636 while (MolecularWalker->next != NULL) { 638 637 MolecularWalker = MolecularWalker->next; 639 638 // fill the bond structure of the individually stored subgraphs 640 MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 639 ListOfAtoms = NULL; 640 MolecularWalker->FillBondStructureFromReference(this, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 641 641 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 642 642 LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount); … … 649 649 // Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name; 650 650 DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 651 MolecularWalker->Leaf->PickLocalBackEdges(ListOf LocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);651 MolecularWalker->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack); 652 652 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 653 653 MolecularWalker->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 654 654 DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 655 655 delete(LocalBackEdgeStack); 656 delete(ListOfAtoms); 657 FragmentCounter++; 656 658 } 657 659 delete(BackEdgeStack); 658 660 659 661 // ===== 3. if structure still valid, parse key set file and others ===== 660 FragmentationToDo = FragmentationToDo && ParseKeySetFile( configuration->configpath, ParsedFragmentList);662 FragmentationToDo = FragmentationToDo && ParseKeySetFile(prefix, ParsedFragmentList); 661 663 662 664 // ===== 4. check globally whether there's something to do actually (first adaptivity check) 663 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile( configuration->configpath);665 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(prefix); 664 666 665 667 // =================================== Begin of FRAGMENTATION =============================== 666 668 // ===== 6a. assign each keyset to its respective subgraph ===== 667 Subgraphs->next->AssignKeySetsToFragment(this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, (FragmentCounter = 0), true); 669 ListOfLocalAtoms = new atom **[LeafCount]; 670 for (int i=0;i<LeafCount;i++) 671 ListOfLocalAtoms[i] = NULL; 672 FragmentCounter = 0; 673 Subgraphs->next->AssignKeySetsToFragment(this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, FragmentCounter, true); 674 delete[](ListOfLocalAtoms); 668 675 669 676 // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle … … 672 679 AtomMask[getAtomCount()] = false; 673 680 FragmentationToDo = false; // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards 674 while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {681 while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, prefix))) { 675 682 FragmentationToDo = FragmentationToDo || CheckOrder; 676 683 AtomMask[getAtomCount()] = true; // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite() … … 701 708 delete[](MinimumRingSize); 702 709 703 704 710 // ==================================== End of FRAGMENTATION ============================================ 705 711 … … 727 733 KeySet test = (*runner).first; 728 734 DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl); 729 BondFragments->insert(StoreFragmentFromKeySet(test, configuration));735 BondFragments->insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig())); 730 736 k++; 731 737 } … … 739 745 740 746 DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl); 741 if (BondFragments->OutputConfigForListOfFragments( configuration, SortIndex))747 if (BondFragments->OutputConfigForListOfFragments(prefix, SortIndex)) 742 748 DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl); 743 749 else … … 745 751 746 752 // store force index reference file 747 BondFragments->StoreForcesFile( configuration->configpath, SortIndex);753 BondFragments->StoreForcesFile(prefix, SortIndex); 748 754 749 755 // store keysets file 750 StoreKeySetFile(TotalGraph, configuration->configpath);756 StoreKeySetFile(TotalGraph, prefix); 751 757 752 758 { 753 759 // store Adjacency file 754 char filename[MAXSTRINGSIZE]; 755 strcpy(filename, FRAGMENTPREFIX); 756 strcat(filename, ADJACENCYFILE); 757 StoreAdjacencyToFile(configuration->configpath, filename); 760 std::string filename = prefix + ADJACENCYFILE; 761 StoreAdjacencyToFile(filename); 758 762 } 759 763 760 764 // store Hydrogen saturation correction file 761 BondFragments->AddHydrogenCorrection( configuration->configpath);765 BondFragments->AddHydrogenCorrection(prefix); 762 766 763 767 // store adaptive orders into file 764 StoreOrderAtSiteFile( configuration->configpath);768 StoreOrderAtSiteFile(prefix); 765 769 766 770 // restore orbital and Stop values 767 CalculateOrbitals(*configuration);771 //CalculateOrbitals(*configuration); 768 772 769 773 // free memory for bond part … … 782 786 /** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file. 783 787 * Atoms not present in the file get "-1". 784 * \param *out output stream for debugging 785 * \param *path path to file ORDERATSITEFILE 788 * \param &path path to file ORDERATSITEFILE 786 789 * \return true - file writable, false - not writable 787 790 */ 788 bool molecule::StoreOrderAtSiteFile( char *path)789 { 790 string streamline;791 bool molecule::StoreOrderAtSiteFile(std::string &path) 792 { 793 string line; 791 794 ofstream file; 792 795 793 line << path << "/" << FRAGMENTPREFIX <<ORDERATSITEFILE;794 file.open(line. str().c_str());796 line = path + ORDERATSITEFILE; 797 file.open(line.c_str()); 795 798 DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl); 796 if (file != NULL) {799 if (file.good()) { 797 800 ActOnAllAtoms( &atom::OutputOrder, &file ); 798 801 file.close(); … … 800 803 return true; 801 804 } else { 802 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line .str()<< "." << endl);805 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line << "." << endl); 803 806 return false; 804 807 } … … 807 810 /** Parses pairs(Atom::nr, Atom::AdaptiveOrder) from file and stores in molecule's Atom's. 808 811 * Atoms not present in the file get "0". 809 * \param *out output stream for debugging 810 * \param *path path to file ORDERATSITEFILEe 812 * \param &path path to file ORDERATSITEFILEe 811 813 * \return true - file found and scanned, false - file not found 812 814 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two 813 815 */ 814 bool molecule::ParseOrderAtSiteFromFile( char *path)816 bool molecule::ParseOrderAtSiteFromFile(std::string &path) 815 817 { 816 818 unsigned char *OrderArray = new unsigned char[getAtomCount()]; … … 818 820 bool status; 819 821 int AtomNr, value; 820 string streamline;822 string line; 821 823 ifstream file; 822 824 … … 827 829 828 830 DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl); 829 line << path << "/" << FRAGMENTPREFIX <<ORDERATSITEFILE;830 file.open(line. str().c_str());831 if (file != NULL) {831 line = path + ORDERATSITEFILE; 832 file.open(line.c_str()); 833 if (file.good()) { 832 834 while (!file.eof()) { // parse from file 833 835 AtomNr = -1; … … 850 852 status = true; 851 853 } else { 852 DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line .str()<< "." << endl);854 DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line << "." << endl); 853 855 status = false; 854 856 } … … 1717 1719 atom *Walker = NULL; 1718 1720 atom *OtherWalker = NULL; 1719 double * const cell_size = World::getInstance().getDomain(); 1720 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1721 Matrix matrix = World::getInstance().getDomain().getM(); 1721 1722 enum Shading *ColorList = NULL; 1722 1723 double tmp; … … 1758 1759 Translationvector[i] = (tmp < 0) ? +1. : -1.; 1759 1760 } 1760 Translationvector .MatrixMultiplication(matrix);1761 Translationvector *= matrix; 1761 1762 //Log() << Verbose(3) << "Translation vector is "; 1762 1763 Log() << Verbose(0) << Translationvector << endl; … … 1789 1790 delete(AtomStack); 1790 1791 delete[](ColorList); 1791 delete[](matrix);1792 1792 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1793 1793 }; -
src/molecule_geometry.cpp
r06f4ef6 rb6da28 5 5 * Author: heber 6 6 */ 7 8 #ifdef HAVE_CONFIG_H 9 #include <config.h> 10 #endif 7 11 8 12 #include "Helpers/MemDebug.hpp" … … 14 18 #include "helpers.hpp" 15 19 #include "leastsquaremin.hpp" 20 #include "verbose.hpp" 16 21 #include "log.hpp" 17 #include "memoryallocator.hpp"18 22 #include "molecule.hpp" 19 23 #include "World.hpp" 20 24 #include "Plane.hpp" 25 #include "Matrix.hpp" 26 #include "Box.hpp" 21 27 #include <boost/foreach.hpp> 28 29 #include <gsl/gsl_eigen.h> 30 #include <gsl/gsl_multimin.h> 22 31 23 32 … … 33 42 const Vector *Center = DetermineCenterOfAll(); 34 43 const Vector *CenterBox = DetermineCenterOfBox(); 35 double * const cell_size = World::getInstance().getDomain(); 36 double *M = ReturnFullMatrixforSymmetric(cell_size); 37 double *Minv = InverseMatrix(M); 44 Box &domain = World::getInstance().getDomain(); 38 45 39 46 // go through all atoms 40 47 ActOnAllVectors( &Vector::SubtractVector, *Center); 41 48 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 42 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 43 44 delete[](M); 45 delete[](Minv); 49 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 50 46 51 delete(Center); 52 delete(CenterBox); 47 53 return status; 48 54 }; … … 55 61 { 56 62 bool status = true; 57 double * const cell_size = World::getInstance().getDomain(); 58 double *M = ReturnFullMatrixforSymmetric(cell_size); 59 double *Minv = InverseMatrix(M); 60 61 // go through all atoms 62 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 63 64 delete[](M); 65 delete[](Minv); 63 Box &domain = World::getInstance().getDomain(); 64 65 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 66 66 67 return status; 67 68 }; … … 119 120 Center += (*iter)->x; 120 121 } 121 Center.Scale(-1./ Num); // divide through total number (and sign for direction)122 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) 122 123 Translate(&Center); 123 124 Center.Zero(); … … 141 142 (*a) += (*iter)->x; 142 143 } 143 a->Scale(1./ Num); // divide through total mass (and sign for direction)144 a->Scale(1./(double)Num); // divide through total mass (and sign for direction) 144 145 } 145 146 return a; … … 152 153 { 153 154 Vector *a = new Vector(0.5,0.5,0.5); 154 155 const double *cell_size = World::getInstance().getDomain(); 156 double *M = ReturnFullMatrixforSymmetric(cell_size); 157 a->MatrixMultiplication(M); 158 delete[](M); 159 155 const Matrix &M = World::getInstance().getDomain().getM(); 156 (*a) *= M; 160 157 return a; 161 158 }; … … 180 177 (*a) += tmp; 181 178 } 182 a->Scale(1./Num); // divide through total mass (and sign for direction)179 a->Scale(1./Num); // divide through total mass 183 180 } 184 181 // Log() << Verbose(1) << "Resulting center of gravity: "; … … 243 240 void molecule::TranslatePeriodically(const Vector *trans) 244 241 { 245 double * const cell_size = World::getInstance().getDomain(); 246 double *M = ReturnFullMatrixforSymmetric(cell_size); 247 double *Minv = InverseMatrix(M); 242 Box &domain = World::getInstance().getDomain(); 248 243 249 244 // go through all atoms 250 245 ActOnAllVectors( &Vector::AddVector, *trans); 251 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 252 253 delete[](M); 254 delete[](Minv); 246 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 247 255 248 }; 256 249 … … 263 256 OBSERVE; 264 257 Plane p(*n,0); 265 BOOST_FOREACH( atom* iter, atoms ){ 266 (*iter->node) = p.mirrorVector(*iter->node); 267 } 258 atoms.transformNodes(boost::bind(&Plane::mirrorVector,p,_1)); 268 259 }; 269 260 … … 273 264 void molecule::DeterminePeriodicCenter(Vector ¢er) 274 265 { 275 double * const cell_size = World::getInstance().getDomain(); 276 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 277 double *inversematrix = InverseMatrix(matrix); 266 const Matrix &matrix = World::getInstance().getDomain().getM(); 267 const Matrix &inversematrix = World::getInstance().getDomain().getM(); 278 268 double tmp; 279 269 bool flag; … … 287 277 if ((*iter)->type->Z != 1) { 288 278 #endif 289 Testvector = (*iter)->x; 290 Testvector.MatrixMultiplication(inversematrix); 279 Testvector = inversematrix * (*iter)->x; 291 280 Translationvector.Zero(); 292 281 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { … … 305 294 } 306 295 Testvector += Translationvector; 307 Testvector .MatrixMultiplication(matrix);296 Testvector *= matrix; 308 297 Center += Testvector; 309 298 Log() << Verbose(1) << "vector is: " << Testvector << endl; … … 312 301 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 313 302 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 314 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 315 Testvector.MatrixMultiplication(inversematrix); 303 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x; 316 304 Testvector += Translationvector; 317 Testvector .MatrixMultiplication(matrix);305 Testvector *= matrix; 318 306 Center += Testvector; 319 307 Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl; … … 324 312 } 325 313 } while (!flag); 326 delete[](matrix);327 delete[](inversematrix);328 314 329 315 Center.Scale(1./static_cast<double>(getAtomCount())); … … 387 373 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 388 374 // the eigenvectors specify the transformation matrix 389 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 375 Matrix M = Matrix(evec->data); 376 377 BOOST_FOREACH(atom* iter, atoms){ 378 (*iter->node) *= M; 379 } 390 380 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 391 381 -
src/molecule_graph.cpp
r06f4ef6 rb6da28 6 6 */ 7 7 8 #ifdef HAVE_CONFIG_H 9 #include <config.h> 10 #endif 11 8 12 #include "Helpers/MemDebug.hpp" 9 13 … … 12 16 #include "bondgraph.hpp" 13 17 #include "config.hpp" 18 #include "defs.hpp" 14 19 #include "element.hpp" 15 20 #include "helpers.hpp" … … 17 22 #include "linkedcell.hpp" 18 23 #include "lists.hpp" 24 #include "verbose.hpp" 19 25 #include "log.hpp" 20 #include "memoryallocator.hpp"21 26 #include "molecule.hpp" 22 27 #include "World.hpp" 23 28 #include "Helpers/fast_functions.hpp" 24 29 #include "Helpers/Assert.hpp" 25 30 #include "Matrix.hpp" 31 #include "Box.hpp" 32 #include "stackclass.hpp" 26 33 27 34 struct BFSAccounting … … 120 127 LinkedCell *LC = NULL; 121 128 bool free_BG = false; 122 double * const cell_size= World::getInstance().getDomain();129 Box &domain = World::getInstance().getDomain(); 123 130 124 131 if (BG == NULL) { … … 177 184 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 178 185 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 179 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);186 const double distance = domain.periodicDistanceSquared(OtherWalker->x,Walker->x); 180 187 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 181 188 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 578 585 // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph 579 586 DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl); 580 LeafWalker->Leaf->Output((ofstream *)& cout);587 LeafWalker->Leaf->Output((ofstream *)&(Log() << Verbose(0))); 581 588 DoLog(0) && (Log() << Verbose(0) << endl); 582 589 … … 663 670 BFS.ColorList = new enum Shading[AtomCount]; 664 671 BFS.BFSStack = new StackClass<atom *> (AtomCount); 672 BFS.TouchedStack = new StackClass<atom *> (AtomCount); 665 673 666 674 for (int i = AtomCount; i--;) { 667 675 BFS.ShortestPathList[i] = -1; 668 676 BFS.PredecessorList[i] = 0; 677 BFS.ColorList[i] = white; 669 678 } 670 679 }; … … 680 689 delete[](BFS.ColorList); 681 690 delete (BFS.BFSStack); 691 delete (BFS.TouchedStack); 682 692 BFS.AtomCount = 0; 683 693 }; … … 824 834 MinRingSize = RingSize; 825 835 } else { 826 DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[ Walker->GetTrueFather()->nr] << " found." << endl);836 DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[BFS.Root->GetTrueFather()->nr] << " found." << endl); 827 837 } 828 838 }; … … 1024 1034 /** Storing the bond structure of a molecule to file. 1025 1035 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line. 1026 * \param *path path tofile1027 * \param *filename name of file1036 * \param &filename name of file 1037 * \param path path to file, defaults to empty 1028 1038 * \return true - file written successfully, false - writing failed 1029 1039 */ 1030 bool molecule::StoreAdjacencyToFile( char *path, char *filename)1040 bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path) 1031 1041 { 1032 1042 ofstream AdjacencyFile; 1033 string streamline;1043 string line; 1034 1044 bool status = true; 1035 1045 1036 if (path != NULL)1037 line << path << "/" <<filename;1046 if (path != "") 1047 line = path + "/" + filename; 1038 1048 else 1039 line <<filename;1040 AdjacencyFile.open(line. str().c_str(), ios::out);1049 line = filename; 1050 AdjacencyFile.open(line.c_str(), ios::out); 1041 1051 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1042 if (AdjacencyFile != NULL) {1052 if (AdjacencyFile.good()) { 1043 1053 AdjacencyFile << "m\tn" << endl; 1044 1054 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); … … 1046 1056 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1047 1057 } else { 1048 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line .str()<< "." << endl);1058 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl); 1049 1059 status = false; 1050 1060 } … … 1056 1066 /** Storing the bond structure of a molecule to file. 1057 1067 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line. 1058 * \param *path path tofile1059 * \param *filename name of file1068 * \param &filename name of file 1069 * \param path path to file, defaults to empty 1060 1070 * \return true - file written successfully, false - writing failed 1061 1071 */ 1062 bool molecule::StoreBondsToFile( char *path, char *filename)1072 bool molecule::StoreBondsToFile(std::string &filename, std::string path) 1063 1073 { 1064 1074 ofstream BondFile; 1065 string streamline;1075 string line; 1066 1076 bool status = true; 1067 1077 1068 if (path != NULL)1069 line << path << "/" <<filename;1078 if (path != "") 1079 line = path + "/" + filename; 1070 1080 else 1071 line <<filename;1072 BondFile.open(line. str().c_str(), ios::out);1081 line = filename; 1082 BondFile.open(line.c_str(), ios::out); 1073 1083 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1074 if (BondFile != NULL) {1084 if (BondFile.good()) { 1075 1085 BondFile << "m\tn" << endl; 1076 1086 ActOnAllAtoms(&atom::OutputBonds, &BondFile); … … 1078 1088 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1079 1089 } else { 1080 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line .str()<< "." << endl);1090 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl); 1081 1091 status = false; 1082 1092 } … … 1086 1096 ; 1087 1097 1088 bool CheckAdjacencyFileAgainstMolecule_Init( char *path, ifstream &File, int *&CurrentBonds)1089 { 1090 string streamfilename;1091 filename << path << "/" << FRAGMENTPREFIX <<ADJACENCYFILE;1092 File.open(filename. str().c_str(), ios::out);1098 bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds) 1099 { 1100 string filename; 1101 filename = path + ADJACENCYFILE; 1102 File.open(filename.c_str(), ios::out); 1093 1103 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl); 1094 if (File == NULL)1104 if (File.fail()) 1095 1105 return false; 1096 1106 … … 1146 1156 * \return true - structure is equal, false - not equivalence 1147 1157 */ 1148 bool molecule::CheckAdjacencyFileAgainstMolecule( char *path, atom **ListOfAtoms)1158 bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms) 1149 1159 { 1150 1160 ifstream File; -
src/molecule_pointcloud.cpp
r06f4ef6 rb6da28 11 11 #include "config.hpp" 12 12 #include "info.hpp" 13 #include "memoryallocator.hpp"14 13 #include "molecule.hpp" 15 14 … … 57 56 void molecule::GoToFirst() const 58 57 { 59 InternalPointer = atoms.begin(); 58 // evil hack necessary because 59 // -# although InternalPointer is mutable 60 // -# only const_iterator begin() is called due to const in the function declaration above 61 // -# and there is no cast from const_iterator to const iterator 62 atomSet::const_iterator test = begin(); 63 InternalPointer = *(reinterpret_cast<atomSet::iterator *>(&test)); 60 64 }; 61 65 -
src/moleculelist.cpp
r06f4ef6 rb6da28 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H 8 #include <config.h> 9 #endif 10 7 11 #include "Helpers/MemDebug.hpp" 8 12 9 13 #include <cstring> 14 15 #include <gsl/gsl_inline.h> 16 #include <gsl/gsl_heapsort.h> 10 17 11 18 #include "World.hpp" 12 19 #include "atom.hpp" 13 20 #include "bond.hpp" 21 #include "bondgraph.hpp" 14 22 #include "boundary.hpp" 15 23 #include "config.hpp" … … 18 26 #include "linkedcell.hpp" 19 27 #include "lists.hpp" 28 #include "verbose.hpp" 20 29 #include "log.hpp" 21 30 #include "molecule.hpp" 22 #include "memoryallocator.hpp"23 31 #include "periodentafel.hpp" 24 32 #include "Helpers/Assert.hpp" 33 #include "Matrix.hpp" 34 #include "Box.hpp" 35 #include "stackclass.hpp" 25 36 26 37 #include "Helpers/Assert.hpp" … … 212 223 213 224 // put all molecules of src into mol 214 molecule::iterator runner; 215 for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 216 runner = iter++; 217 srcmol->UnlinkAtom((*runner)); 218 mol->AddAtom((*runner)); 225 for (molecule::iterator iter = srcmol->begin(); !srcmol->empty(); iter=srcmol->begin()) { 226 atom * const Walker = *iter; 227 srcmol->UnlinkAtom(Walker); 228 mol->AddAtom(Walker); 219 229 } 220 230 … … 259 269 status = status && SimpleMerge(mol, srcmol); 260 270 } 271 insert(mol); 261 272 return status; 262 273 }; … … 379 390 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse 380 391 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance. 381 * \param *out output stream for debugging 382 * \param *path path to file 383 */ 384 bool MoleculeListClass::AddHydrogenCorrection(char *path) 392 * \param &path path to file 393 */ 394 bool MoleculeListClass::AddHydrogenCorrection(std::string &path) 385 395 { 386 396 bond *Binder = NULL; … … 400 410 // 0a. find dimension of matrices with constants 401 411 line = path; 402 line.append("/");403 line += FRAGMENTPREFIX;404 412 line += "1"; 405 413 line += FITCONSTANTSUFFIX; 406 414 input.open(line.c_str()); 407 if (input == NULL) {415 if (input.fail()) { 408 416 DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl); 409 417 return false; … … 569 577 570 578 /** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config. 571 * \param *out output stream for debugging 572 * \param *path path to file 579 * \param &path path to file 573 580 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config 574 581 * \return true - file written successfully, false - writing failed 575 582 */ 576 bool MoleculeListClass::StoreForcesFile(char *path, 577 int *SortIndex) 583 bool MoleculeListClass::StoreForcesFile(std::string &path, int *SortIndex) 578 584 { 579 585 bool status = true; 580 ofstream ForcesFile; 581 stringstream line; 586 string filename(path); 587 filename += FORCESFILE; 588 ofstream ForcesFile(filename.c_str()); 582 589 periodentafel *periode=World::getInstance().getPeriode(); 583 590 584 591 // open file for the force factors 585 592 DoLog(1) && (Log() << Verbose(1) << "Saving force factors ... "); 586 line << path << "/" << FRAGMENTPREFIX << FORCESFILE; 587 ForcesFile.open(line.str().c_str(), ios::out); 588 if (ForcesFile != NULL) { 593 if (!ForcesFile.fail()) { 589 594 //Log() << Verbose(1) << "Final AtomicForcesList: "; 590 595 //output << prefix << "Forces" << endl; … … 592 597 periodentafel::const_iterator elemIter; 593 598 for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){ 594 if ((*ListRunner)-> ElementsInMolecule[(*elemIter).first]) { // if this element got atoms599 if ((*ListRunner)->hasElement((*elemIter).first)) { // if this element got atoms 595 600 for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){ 596 601 if ((*atomIter)->type->getNumber() == (*elemIter).first) { … … 611 616 } else { 612 617 status = false; 613 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str()<< "." << endl);618 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << filename << "." << endl); 614 619 } 615 620 ForcesFile.close(); … … 620 625 /** Writes a config file for each molecule in the given \a **FragmentList. 621 626 * \param *out output stream for debugging 622 * \param *configuration standard configuration to attach atoms in fragment molecule to.627 * \param &prefix path and prefix to the fragment config files 623 628 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config 624 629 * \return true - success (each file was written), false - something went wrong. 625 630 */ 626 bool MoleculeListClass::OutputConfigForListOfFragments( config *configuration, int *SortIndex)631 bool MoleculeListClass::OutputConfigForListOfFragments(std::string &prefix, int *SortIndex) 627 632 { 628 633 ofstream outputFragment; 629 char FragmentName[MAXSTRINGSIZE];634 std::string FragmentName; 630 635 char PathBackup[MAXSTRINGSIZE]; 631 636 bool result = true; … … 636 641 int FragmentCounter = 0; 637 642 ofstream output; 638 double cell_size_backup[6]; 639 double * const cell_size = World::getInstance().getDomain(); 640 641 // backup cell_size 642 for (int i=0;i<6;i++) 643 cell_size_backup[i] = cell_size[i]; 643 Matrix cell_size = World::getInstance().getDomain().getM(); 644 Matrix cell_size_backup = cell_size; 645 644 646 // store the fragments as config and as xyz 645 647 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { 646 648 // save default path as it is changed for each fragment 647 path = configuration->GetDefaultPath();649 path = World::getInstance().getConfig()->GetDefaultPath(); 648 650 if (path != NULL) 649 651 strcpy(PathBackup, path); … … 658 660 // output xyz file 659 661 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++); 660 sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);661 outputFragment.open(FragmentName , ios::out);662 FragmentName = prefix + FragmentNumber + ".conf.xyz"; 663 outputFragment.open(FragmentName.c_str(), ios::out); 662 664 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ..."); 663 665 if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment))) … … 679 681 (*ListRunner)->CenterEdge(&BoxDimension); 680 682 (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary 681 int j = -1;682 683 for (int k = 0; k < NDIM; k++) { 683 j += k + 1;684 BoxDimension[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);685 cell_size[j] = BoxDimension[k] * 2.;686 }684 BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem); 685 cell_size.at(k,k) = BoxDimension[k] * 2.; 686 } 687 World::getInstance().setDomain(cell_size); 687 688 (*ListRunner)->Translate(&BoxDimension); 688 689 689 690 // also calculate necessary orbitals 690 (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment 691 (*ListRunner)->CalculateOrbitals(*configuration); 691 //(*ListRunner)->CalculateOrbitals(*World::getInstance().getConfig); 692 692 693 693 // change path in config 694 //strcpy(PathBackup, configuration->configpath); 695 sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber); 696 configuration->SetDefaultPath(FragmentName); 694 FragmentName = PathBackup; 695 FragmentName += "/"; 696 FragmentName += FRAGMENTPREFIX; 697 FragmentName += FragmentNumber; 698 FragmentName += "/"; 699 World::getInstance().getConfig()->SetDefaultPath(FragmentName.c_str()); 697 700 698 701 // and save as config 699 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);702 FragmentName = prefix + FragmentNumber + ".conf"; 700 703 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ..."); 701 if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))704 if ((intermediateResult = World::getInstance().getConfig()->Save(FragmentName.c_str(), (*ListRunner)->elemente, (*ListRunner)))) 702 705 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 703 706 else … … 706 709 707 710 // restore old config 708 configuration->SetDefaultPath(PathBackup);711 World::getInstance().getConfig()->SetDefaultPath(PathBackup); 709 712 710 713 // and save as mpqc input file 711 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);714 FragmentName = prefix + FragmentNumber + ".conf"; 712 715 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ..."); 713 if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))716 if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner)))) 714 717 DoLog(2) && (Log() << Verbose(2) << " done." << endl); 715 718 else … … 727 730 728 731 // restore cell_size 729 for (int i=0;i<6;i++) 730 cell_size[i] = cell_size_backup[i]; 732 World::getInstance().setDomain(cell_size_backup); 731 733 732 734 return result; … … 767 769 768 770 // 1. dissect the molecule into connected subgraphs 769 if (!configuration->BG->ConstructBondGraph(mol)) { 770 World::getInstance().destroyMolecule(mol); 771 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 771 if (configuration->BG != NULL) { 772 if (!configuration->BG->ConstructBondGraph(mol)) { 773 World::getInstance().destroyMolecule(mol); 774 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 775 return; 776 } 777 } else { 778 DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl); 772 779 return; 773 780 } … … 884 891 // center at set box dimensions 885 892 mol->CenterEdge(¢er); 886 World::getInstance().getDomain()[0] = center[0]; 887 World::getInstance().getDomain()[1] = 0; 888 World::getInstance().getDomain()[2] = center[1]; 889 World::getInstance().getDomain()[3] = 0; 890 World::getInstance().getDomain()[4] = 0; 891 World::getInstance().getDomain()[5] = center[2]; 893 Matrix domain; 894 for(int i =0;i<NDIM;++i) 895 domain.at(i,i) = center[i]; 896 World::getInstance().setDomain(domain); 892 897 insert(mol); 893 898 } … … 1014 1019 * \param *out output stream for debugging 1015 1020 * \param *reference reference molecule with the bond structure to be copied 1016 * \param &FragmentCounter Counter needed to address \a **ListOfLocalAtoms 1017 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled 1021 * \param **&ListOfLocalAtoms Lookup table for this subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled 1018 1022 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not 1019 1023 * \return true - success, false - faoilure 1020 1024 */ 1021 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)1025 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList) 1022 1026 { 1023 1027 atom *OtherWalker = NULL; … … 1028 1032 DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl); 1029 1033 // fill ListOfLocalAtoms if NULL was given 1030 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter,reference->getAtomCount(), FreeList)) {1034 if (!FillListOfLocalAtoms(ListOfLocalAtoms, reference->getAtomCount(), FreeList)) { 1031 1035 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1032 1036 return false; … … 1045 1049 AtomNo = Father->nr; // global id of the current walker 1046 1050 for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) { 1047 OtherWalker = ListOfLocalAtoms[ FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker1051 OtherWalker = ListOfLocalAtoms[(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker 1048 1052 if (OtherWalker != NULL) { 1049 1053 if (OtherWalker->nr > (*iter)->nr) 1050 1054 Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree); 1051 1055 } else { 1052 DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" <<(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);1056 DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl); 1053 1057 status = false; 1054 1058 } … … 1059 1063 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1060 1064 // free the index lookup list 1061 delete[](ListOfLocalAtoms[FragmentCounter]); 1062 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 1063 delete[](ListOfLocalAtoms); 1065 delete[](ListOfLocalAtoms); 1064 1066 } 1065 1067 DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl); … … 1107 1109 /** Fills a lookup list of father's Atom::nr -> atom for each subgraph. 1108 1110 * \param *out output stream from debugging 1109 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled 1110 * \param FragmentCounter counts the fragments as we move along the list 1111 * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled 1111 1112 * \param GlobalAtomCount number of atoms in the complete molecule 1112 1113 * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not 1113 * \return true - success, false - failure 1114 */ 1115 bool MoleculeLeafClass::FillListOfLocalAtoms(atom ** *&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList)1114 * \return true - success, false - failure (ListOfLocalAtoms != NULL) 1115 */ 1116 bool MoleculeLeafClass::FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList) 1116 1117 { 1117 1118 bool status = true; 1118 1119 1119 if (ListOfLocalAtoms == NULL) { // allocated initial pointer 1120 // allocate and set each field to NULL 1121 const int Counter = Count(); 1122 ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments."); 1123 ListOfLocalAtoms = new atom**[Counter]; 1124 if (ListOfLocalAtoms == NULL) { 1125 FreeList = FreeList && false; 1126 status = false; 1127 } 1128 for (int i=0;i<Counter;i++) 1129 ListOfLocalAtoms[i] = NULL; 1130 } 1131 1132 if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph 1133 status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount); 1120 if (ListOfLocalAtoms == NULL) { // allocate and fill list of this fragment/subgraph 1121 status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms, GlobalAtomCount); 1134 1122 FreeList = FreeList && true; 1135 } 1123 } else 1124 return false; 1136 1125 1137 1126 return status; … … 1155 1144 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl); 1156 1145 // fill ListOfLocalAtoms if NULL was given 1157 if (!FillListOfLocalAtoms(ListOfLocalAtoms , FragmentCounter, reference->getAtomCount(), FreeList)) {1146 if (!FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount(), FreeList)) { 1158 1147 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1159 1148 return false; … … 1200 1189 // free the index lookup list 1201 1190 delete[](ListOfLocalAtoms[FragmentCounter]); 1202 if (FragmentCounter == 0) // first fragments frees the initial pointer to list1203 delete[](ListOfLocalAtoms);1204 1191 } 1205 1192 DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl); -
src/orbitals.db
r06f4ef6 rb6da28 1 # atomicnumber numberoforbitals 1 2 1 1 2 3 2 0 -
src/parser.cpp
r06f4ef6 rb6da28 12 12 13 13 #include "helpers.hpp" 14 #include "memoryallocator.hpp"15 14 #include "parser.hpp" 15 #include "verbose.hpp" 16 16 17 17 // include config.h … … 76 76 MatrixContainer::~MatrixContainer() { 77 77 if (Matrix != NULL) { 78 // free Matrix[MatrixCounter] 79 if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL)) 80 for(int j=RowCounter[MatrixCounter]+1;j--;) 81 delete[](Matrix[MatrixCounter][j]); 82 //if (MatrixCounter != 0) 83 delete[](Matrix[MatrixCounter]); 84 // free all matrices but ultimate one 78 85 for(int i=MatrixCounter;i--;) { 79 86 if ((ColumnCounter != NULL) && (RowCounter != NULL)) { … … 83 90 } 84 91 } 85 if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))86 for(int j=RowCounter[MatrixCounter]+1;j--;)87 delete[](Matrix[MatrixCounter][j]);88 if (MatrixCounter != 0)89 delete[](Matrix[MatrixCounter]);90 92 delete[](Matrix); 91 93 } 94 // free indices 92 95 if (Indices != NULL) 93 96 for(int i=MatrixCounter+1;i--;) { … … 96 99 delete[](Indices); 97 100 101 // free header and counters 98 102 if (Header != NULL) 99 103 for(int i=MatrixCounter+1;i--;) … … 168 172 169 173 // parse header 174 if (Header[MatrixNr] != NULL) 175 delete[] Header[MatrixNr]; 170 176 Header[MatrixNr] = new char[1024]; 171 177 for (int m=skiplines+1;m--;) … … 207 213 // allocate matrix if it's not zero dimension in one direction 208 214 if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) { 215 if (Matrix[MatrixNr] != NULL) 216 delete[] Matrix[MatrixNr]; 209 217 Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1]; 210 218 for(int j=0;j<RowCounter[MatrixNr]+1;j++) 219 Matrix[MatrixNr][j] = 0; 220 211 221 // parse in each entry for this matrix 212 222 input.clear(); … … 219 229 strncpy(Header[MatrixNr], line.str().c_str(), 1023); 220 230 for(int j=0;j<RowCounter[MatrixNr];j++) { 231 if (Matrix[MatrixNr][j] != NULL) 232 delete[] Matrix[MatrixNr][j]; 221 233 Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]]; 234 for(int k=0;k<ColumnCounter[MatrixNr];k++) 235 Matrix[MatrixNr][j][k] = 0; 236 222 237 input.getline(filename, 1023); 223 238 stringstream lines(filename); … … 229 244 //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl; 230 245 } 246 if (Matrix[MatrixNr][ RowCounter[MatrixNr] ] != NULL) 247 delete[] Matrix[MatrixNr][ RowCounter[MatrixNr] ]; 231 248 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]]; 232 249 for(int j=ColumnCounter[MatrixNr];j--;) -
src/periodentafel.cpp
r06f4ef6 rb6da28 32 32 periodentafel::periodentafel() 33 33 { 34 bool status = true; 35 status = LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)); 36 ASSERT(status, "General element initialization failed"); 37 status = LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)); 38 ASSERT(status, "Valence entry of element initialization failed"); 39 status = LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)); 40 ASSERT(status, "Orbitals entry of element initialization failed"); 41 status = LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in)); 42 ASSERT(status, "HBond angle entry of element initialization failed"); 43 status = LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in)); 44 ASSERT(status, "HBond distance entry of element initialization failed"); 34 { 35 stringstream input(elementsDB,ios_base::in); 36 bool status = LoadElementsDatabase(&input); 37 ASSERT(status, "General element initialization failed"); 38 } 39 { 40 stringstream input(valenceDB,ios_base::in); 41 bool status = LoadValenceDatabase(&input); 42 ASSERT(status, "Valence entry of element initialization failed"); 43 } 44 { 45 stringstream input(orbitalsDB,ios_base::in); 46 bool status = LoadOrbitalsDatabase(&input); 47 ASSERT(status, "Orbitals entry of element initialization failed"); 48 } 49 { 50 stringstream input(HbondangleDB,ios_base::in); 51 bool status = LoadHBondAngleDatabase(&input); 52 ASSERT(status, "HBond angle entry of element initialization failed"); 53 } 54 { 55 stringstream input(HbonddistanceDB,ios_base::in); 56 bool status = LoadHBondLengthsDatabase(&input); 57 ASSERT(status, "HBond distance entry of element initialization failed"); 58 } 45 59 }; 46 60 … … 111 125 * \return pointer to element 112 126 */ 113 element * const periodentafel::FindElement(const char * constshorthand) const127 element * const periodentafel::FindElement(const string &shorthand) const 114 128 { 115 129 element *res = 0; … … 197 211 }; 198 212 199 /** Prints period table to given stream.200 * \param *output output stream201 * \param *checkliste elements table for this molecule202 */203 bool periodentafel::Checkout(ostream * const output, const int * const checkliste) const204 {205 bool result = true;206 int No = 1;207 208 if (output != NULL) {209 *output << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;210 *output << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;211 for(const_iterator iter=elements.begin(); iter!=elements.end();++iter){212 if (((*iter).first < MAX_ELEMENTS) && (checkliste[(*iter).first])) {213 (*iter).second->No = No;214 result = result && (*iter).second->Checkout(output, No++, checkliste[(*iter).first]);215 }216 }217 return result;218 } else219 return false;220 };221 222 213 /** Loads element list from file. 223 214 * \param *path to to standard file names … … 333 324 ASSERT(Elemental != NULL, "element should be present but is not??"); 334 325 *Elemental = *neues; 326 delete(neues); 327 neues = Elemental; 335 328 } else { 336 329 InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues)); … … 373 366 (*input) >> elements[Z]->Valence; 374 367 (*input) >> ws; 375 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;368 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl; 376 369 } 377 370 return true; … … 396 389 (*input) >> elements[Z]->NoValenceOrbitals; 397 390 (*input) >> ws; 398 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;391 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl; 399 392 } 400 393 return true; -
src/periodentafel.hpp
r06f4ef6 rb6da28 9 9 #endif 10 10 11 #include <ios tream>11 #include <iosfwd> 12 12 #include <map> 13 #include < iterator>13 #include <string> 14 14 15 15 #include "unittests/periodentafelTest.hpp" … … 48 48 void CleanupPeriodtable(); 49 49 element * const FindElement(atomicNumber_t) const; 50 element * const FindElement(const char * constshorthand) const;50 element * const FindElement(const std::string &shorthand) const; 51 51 element * const AskElement() const; 52 52 element * const EnterElement(); … … 57 57 reverse_iterator rend(); 58 58 bool Output(std::ostream * const output) const; 59 bool Checkout(std::ostream * const output, const int * const checkliste) const;60 59 bool LoadPeriodentafel(const char * const path); 61 60 bool StorePeriodentafel(const char * const path) const; -
src/stackclass.hpp
r06f4ef6 rb6da28 12 12 13 13 #include "verbose.hpp" 14 #include " memoryallocator.hpp"14 #include "log.hpp" 15 15 16 16 /****************************************** forward declarations *****************************/ -
src/tesselation.cpp
r06f4ef6 rb6da28 9 9 10 10 #include <fstream> 11 #include < assert.h>11 #include <iomanip> 12 12 13 13 #include "helpers.hpp" … … 24 24 #include "Plane.hpp" 25 25 #include "Exceptions/LinearDependenceException.hpp" 26 #include "Helpers/Assert.hpp"27 28 26 #include "Helpers/Assert.hpp" 29 27 … … 234 232 { 235 233 Info FunctionInfo(__func__); 234 double angle = CalculateConvexity(); 235 if (angle > -MYEPSILON) { 236 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 237 return true; 238 } else { 239 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 240 return false; 241 } 242 } 243 244 245 /** Calculates the angle between two triangles with respect to their normal vector. 246 * We sum the two angles of each height vector with respect to the center of the baseline. 247 * \return angle > 0 then convex, if < 0 then concave 248 */ 249 double BoundaryLineSet::CalculateConvexity() const 250 { 251 Info FunctionInfo(__func__); 236 252 Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck; 237 253 // get the two triangles … … 282 298 BaseLineNormal.Scale(-1.); 283 299 double angle = GetAngle(helper[0], helper[1], BaseLineNormal); 284 if ((angle - M_PI) > -MYEPSILON) { 285 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 286 return true; 287 } else { 288 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 289 return false; 290 } 300 return (angle - M_PI); 291 301 } 292 302 … … 307 317 /** Returns other endpoint of the line. 308 318 * \param *point other endpoint 309 * \return NULL - if endpoint not contained in BoundaryLineSet , or pointer to BoundaryPointSet otherwise319 * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise 310 320 */ 311 321 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const … … 318 328 else 319 329 return NULL; 330 } 331 ; 332 333 /** Returns other triangle of the line. 334 * \param *point other endpoint 335 * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise 336 */ 337 class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const 338 { 339 Info FunctionInfo(__func__); 340 if (triangles.size() == 2) { 341 for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner) 342 if (TriangleRunner->second != triangle) 343 return TriangleRunner->second; 344 } 345 return NULL; 320 346 } 321 347 ; … … 664 690 ; 665 691 692 /** Returns the baseline which does not contain the given boundary point \a *point. 693 * \param *point endpoint which is neither endpoint of the desired line 694 * \return pointer to desired third baseline 695 */ 696 class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const 697 { 698 Info FunctionInfo(__func__); 699 // sanity check 700 if (!ContainsBoundaryPoint(point)) 701 return NULL; 702 for (int i = 0; i < 3; i++) 703 if (!lines[i]->ContainsBoundaryPoint(point)) 704 return lines[i]; 705 // actually, that' impossible :) 706 return NULL; 707 } 708 ; 709 666 710 /** Calculates the center point of the triangle. 667 711 * Is third of the sum of all endpoints. … … 1113 1157 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner)); 1114 1158 1115 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << OtherOptCenter<< ":" << endl);1159 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl); 1116 1160 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1117 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance( OtherOptCenter) << "." << endl);1161 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl); 1118 1162 1119 1163 // remove baseline's endpoints and candidates … … 1131 1175 DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl); 1132 1176 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1133 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << endl); 1177 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl); 1178 1179 // check with animate_sphere.tcl VMD script 1180 if (ThirdPoint != NULL) { 1181 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl); 1182 } else { 1183 DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl); 1184 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl); 1185 } 1134 1186 } 1135 1187 delete (ListofPoints); 1136 1188 1137 // check with animate_sphere.tcl VMD script1138 if (ThirdPoint != NULL) {1139 DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);1140 } else {1141 DoLog(1) && (Log() << Verbose(1) << "Check by: ... missing third point ..." << endl);1142 DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);1143 }1144 1189 } 1145 1190 return flag; … … 1604 1649 bool AddFlag = false; 1605 1650 LinkedCell *BoundaryPoints = NULL; 1651 bool SuccessFlag = true; 1606 1652 1607 1653 cloud->GoToFirst(); … … 1617 1663 // get the next triangle 1618 1664 triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints); 1619 BTS = triangles->front(); 1620 if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) { 1665 if (triangles != NULL) 1666 BTS = triangles->front(); 1667 else 1668 BTS = NULL; 1669 delete triangles; 1670 if ((BTS == NULL) || (BTS->ContainsBoundaryPoint(Walker))) { 1621 1671 DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl); 1622 1672 cloud->GoToNext(); … … 1688 1738 } else { // something is wrong with FindClosestTriangleToPoint! 1689 1739 DoeLog(1) && (eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl); 1690 return false; 1740 SuccessFlag = false; 1741 break; 1691 1742 } 1692 1743 cloud->GoToNext(); … … 1695 1746 // exit 1696 1747 delete (Center); 1697 return true; 1748 delete (BoundaryPoints); 1749 return SuccessFlag; 1698 1750 } 1699 1751 ; … … 2198 2250 for (int i = 0; i < NDIM; i++) { // each axis 2199 2251 LC->n[i] = LC->N[i] - 1; // current axis is topmost cell 2200 for (LC->n[(i + 1) % NDIM] = 0; LC->n[(i + 1) % NDIM] < LC->N[(i + 1) % NDIM]; LC->n[(i + 1) % NDIM]++) 2201 for (LC->n[(i + 2) % NDIM] = 0; LC->n[(i + 2) % NDIM] < LC->N[(i + 2) % NDIM]; LC->n[(i + 2) % NDIM]++) { 2252 const int map[NDIM] = {i, (i + 1) % NDIM, (i + 2) % NDIM}; 2253 for (LC->n[map[1]] = 0; LC->n[map[1]] < LC->N[map[1]]; LC->n[map[1]]++) 2254 for (LC->n[map[2]] = 0; LC->n[map[2]] < LC->N[map[2]]; LC->n[map[2]]++) { 2202 2255 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 2203 2256 //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2204 2257 if (List != NULL) { 2205 2258 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2206 if ((*Runner)->node->at( i) > maxCoordinate[i]) {2207 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << i<< " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl);2208 maxCoordinate[ i] = (*Runner)->node->at(i);2209 MaxPoint[ i] = (*Runner);2259 if ((*Runner)->node->at(map[0]) > maxCoordinate[map[0]]) { 2260 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl); 2261 maxCoordinate[map[0]] = (*Runner)->node->at(map[0]); 2262 MaxPoint[map[0]] = (*Runner); 2210 2263 } 2211 2264 } … … 2527 2580 baseline = Runner->second; 2528 2581 if (baseline->pointlist.empty()) { 2529 assert((baseline->BaseLine->triangles.size() == 1) && ("Open line without exactly one attached triangle"));2582 ASSERT((baseline->BaseLine->triangles.size() == 1),"Open line without exactly one attached triangle"); 2530 2583 T = (((baseline->BaseLine->triangles.begin()))->second); 2531 2584 DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl); … … 3293 3346 } 3294 3347 } else { 3295 Do Log(1) && (Log() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);3348 DoeLog(0) && (eLog() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl); 3296 3349 } 3297 3350 } else { … … 4593 4646 4594 4647 DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl); 4595 IndexToIndex::iterator it; 4596 for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 4648 for (IndexToIndex::iterator it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 4597 4649 DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl); 4598 4650 … … 4612 4664 int count = 0; 4613 4665 4614 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) { 4666 // iterate over all degenerated triangles 4667 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); !DegeneratedTriangles->empty(); TriangleKeyRunner = DegeneratedTriangles->begin()) { 4668 DoLog(0) && (Log() << Verbose(0) << "Checking presence of triangles " << TriangleKeyRunner->first << " and " << TriangleKeyRunner->second << "." << endl); 4669 // both ways are stored in the map, only use one 4670 if (TriangleKeyRunner->first > TriangleKeyRunner->second) 4671 continue; 4672 4673 // determine from the keys in the map the two _present_ triangles 4615 4674 finder = TrianglesOnBoundary.find(TriangleKeyRunner->first); 4616 4675 if (finder != TrianglesOnBoundary.end()) 4617 4676 triangle = finder->second; 4618 4677 else 4619 break;4678 continue; 4620 4679 finder = TrianglesOnBoundary.find(TriangleKeyRunner->second); 4621 4680 if (finder != TrianglesOnBoundary.end()) 4622 4681 partnerTriangle = finder->second; 4623 4682 else 4624 break; 4625 4683 continue; 4684 4685 // determine which lines are shared by the two triangles 4626 4686 bool trianglesShareLine = false; 4627 4687 for (int i = 0; i < 3; ++i) -
src/tesselation.hpp
r06f4ef6 rb6da28 138 138 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const; 139 139 bool CheckConvexityCriterion() const; 140 double CalculateConvexity() const; 140 141 class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const; 142 class BoundaryTriangleSet *GetOtherTriangle(const BoundaryTriangleSet * const triangle) const; 141 143 142 144 class BoundaryPointSet *endpoints[2]; … … 164 166 bool ContainsBoundaryPoint(const TesselPoint * const point) const; 165 167 class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const; 168 class BoundaryLineSet *GetThirdLine(const BoundaryPointSet * const point) const; 166 169 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const; 167 170 bool IsPresentTupel(const BoundaryTriangleSet * const T) const; -
src/tesselationhelpers.cpp
r06f4ef6 rb6da28 12 12 #include "info.hpp" 13 13 #include "linkedcell.hpp" 14 #include "linearsystemofequations.hpp" 14 15 #include "log.hpp" 15 16 #include "tesselation.hpp" … … 20 21 #include "verbose.hpp" 21 22 #include "Plane.hpp" 22 23 double DetGet(gsl_matrix * const A, const int inPlace) 24 { 25 Info FunctionInfo(__func__); 26 /* 27 inPlace = 1 => A is replaced with the LU decomposed copy. 28 inPlace = 0 => A is retained, and a copy is used for LU. 29 */ 30 31 double det; 32 int signum; 33 gsl_permutation *p = gsl_permutation_alloc(A->size1); 34 gsl_matrix *tmpA=0; 35 36 if (inPlace) 37 tmpA = A; 38 else { 39 gsl_matrix *tmpA = gsl_matrix_alloc(A->size1, A->size2); 40 gsl_matrix_memcpy(tmpA , A); 41 } 42 43 44 gsl_linalg_LU_decomp(tmpA , p , &signum); 45 det = gsl_linalg_LU_det(tmpA , signum); 46 gsl_permutation_free(p); 47 if (! inPlace) 48 gsl_matrix_free(tmpA); 49 50 return det; 51 }; 23 #include "Matrix.hpp" 52 24 53 25 void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS) 54 26 { 55 27 Info FunctionInfo(__func__); 56 gsl_matrix *A = gsl_matrix_calloc(3,3);28 Matrix mat; 57 29 double m11, m12, m13, m14; 58 30 59 31 for(int i=0;i<3;i++) { 60 gsl_matrix_set(A,i, 0, a[i]);61 gsl_matrix_set(A,i, 1, b[i]);62 gsl_matrix_set(A,i, 2, c[i]);63 } 64 m11 = DetGet(A, 1);32 mat.set(i, 0, a[i]); 33 mat.set(i, 1, b[i]); 34 mat.set(i, 2, c[i]); 35 } 36 m11 = mat.determinant(); 65 37 66 38 for(int i=0;i<3;i++) { 67 gsl_matrix_set(A,i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);68 gsl_matrix_set(A,i, 1, b[i]);69 gsl_matrix_set(A,i, 2, c[i]);70 } 71 m12 = DetGet(A, 1);39 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]); 40 mat.set(i, 1, b[i]); 41 mat.set(i, 2, c[i]); 42 } 43 m12 = mat.determinant(); 72 44 73 45 for(int i=0;i<3;i++) { 74 gsl_matrix_set(A,i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);75 gsl_matrix_set(A,i, 1, a[i]);76 gsl_matrix_set(A,i, 2, c[i]);77 } 78 m13 = DetGet(A, 1);46 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]); 47 mat.set(i, 1, a[i]); 48 mat.set(i, 2, c[i]); 49 } 50 m13 = mat.determinant(); 79 51 80 52 for(int i=0;i<3;i++) { 81 gsl_matrix_set(A,i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);82 gsl_matrix_set(A,i, 1, a[i]);83 gsl_matrix_set(A,i, 2, b[i]);84 } 85 m14 = DetGet(A, 1);53 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]); 54 mat.set(i, 1, a[i]); 55 mat.set(i, 2, b[i]); 56 } 57 m14 = mat.determinant(); 86 58 87 59 if (fabs(m11) < MYEPSILON) … … 94 66 if (fabs(a.distance(*center) - RADIUS) > MYEPSILON) 95 67 DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.distance(*center) - RADIUS) << " from a than RADIUS." << endl); 96 97 gsl_matrix_free(A);98 68 }; 99 69 … … 178 148 Info FunctionInfo(__func__); 179 149 Vector helper; 180 double alpha, beta, gamma;181 150 Vector SideA = b - c; 182 151 Vector SideB = c - a; 183 152 Vector SideC = a - b; 184 alpha = M_PI - SideB.Angle(SideC); 185 beta = M_PI - SideC.Angle(SideA); 186 gamma = M_PI - SideA.Angle(SideB); 187 //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl; 188 if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) { 189 DoeLog(2) && (eLog()<< Verbose(2) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl); 190 } 153 154 helper[0] = SideA.NormSquared()*(SideB.NormSquared()+SideC.NormSquared() - SideA.NormSquared()); 155 helper[1] = SideB.NormSquared()*(SideC.NormSquared()+SideA.NormSquared() - SideB.NormSquared()); 156 helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared()); 191 157 192 158 Center->Zero(); 193 helper = sin(2.*alpha) * a; 194 (*Center) += helper; 195 helper = sin(2.*beta) * b; 196 (*Center) += helper; 197 helper = sin(2.*gamma) * c; 198 (*Center) += helper; 199 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma))); 159 *Center += helper[0] * a; 160 *Center += helper[1] * b; 161 *Center += helper[2] * c; 162 Center->Scale(1./(helper[0]+helper[1]+helper[2])); 163 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl; 200 164 }; 201 165 … … 255 219 }; 256 220 257 /**258 * Intersection calculation function.259 *260 * @param x to find the result for261 * @param function parameter262 */263 double MinIntersectDistance(const gsl_vector * x, void *params)264 {265 Info FunctionInfo(__func__);266 double retval = 0;267 struct Intersection *I = (struct Intersection *)params;268 Vector intersection;269 for (int i=0;i<NDIM;i++)270 intersection[i] = gsl_vector_get(x, i);271 272 Vector SideA = I->x1 -I->x2 ;273 Vector HeightA = intersection - I->x1;274 HeightA.ProjectOntoPlane(SideA);275 276 Vector SideB = I->x3 - I->x4;277 Vector HeightB = intersection - I->x3;278 HeightB.ProjectOntoPlane(SideB);279 280 retval = HeightA.ScalarProduct(HeightA) + HeightB.ScalarProduct(HeightB);281 //Log() << Verbose(1) << "MinIntersectDistance called, result: " << retval << endl;282 283 return retval;284 };285 286 287 /**288 * Calculates whether there is an intersection between two lines. The first line289 * always goes through point 1 and point 2 and the second line is given by the290 * connection between point 4 and point 5.291 *292 * @param point 1 of line 1293 * @param point 2 of line 1294 * @param point 1 of line 2295 * @param point 2 of line 2296 *297 * @return true if there is an intersection between the given lines, false otherwise298 */299 bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4)300 {301 Info FunctionInfo(__func__);302 bool result;303 304 struct Intersection par;305 par.x1 = point1;306 par.x2 = point2;307 par.x3 = point3;308 par.x4 = point4;309 310 const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;311 gsl_multimin_fminimizer *s = NULL;312 gsl_vector *ss, *x;313 gsl_multimin_function minexFunction;314 315 size_t iter = 0;316 int status;317 double size;318 319 /* Starting point */320 x = gsl_vector_alloc(NDIM);321 gsl_vector_set(x, 0, point1[0]);322 gsl_vector_set(x, 1, point1[1]);323 gsl_vector_set(x, 2, point1[2]);324 325 /* Set initial step sizes to 1 */326 ss = gsl_vector_alloc(NDIM);327 gsl_vector_set_all(ss, 1.0);328 329 /* Initialize method and iterate */330 minexFunction.n = NDIM;331 minexFunction.f = &MinIntersectDistance;332 minexFunction.params = (void *)∥333 334 s = gsl_multimin_fminimizer_alloc(T, NDIM);335 gsl_multimin_fminimizer_set(s, &minexFunction, x, ss);336 337 do {338 iter++;339 status = gsl_multimin_fminimizer_iterate(s);340 341 if (status) {342 break;343 }344 345 size = gsl_multimin_fminimizer_size(s);346 status = gsl_multimin_test_size(size, 1e-2);347 348 if (status == GSL_SUCCESS) {349 DoLog(1) && (Log() << Verbose(1) << "converged to minimum" << endl);350 }351 } while (status == GSL_CONTINUE && iter < 100);352 353 // check whether intersection is in between or not354 Vector intersection;355 double t1, t2;356 for (int i = 0; i < NDIM; i++) {357 intersection[i] = gsl_vector_get(s->x, i);358 }359 360 Vector SideA = par.x2 - par.x1;361 Vector HeightA = intersection - par.x1;362 363 t1 = HeightA.ScalarProduct(SideA)/SideA.ScalarProduct(SideA);364 365 Vector SideB = par.x4 - par.x3;366 Vector HeightB = intersection - par.x3;367 368 t2 = HeightB.ScalarProduct(SideB)/SideB.ScalarProduct(SideB);369 370 Log() << Verbose(1) << "Intersection " << intersection << " is at "371 << t1 << " for (" << point1 << "," << point2 << ") and at "372 << t2 << " for (" << point3 << "," << point4 << "): ";373 374 if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) {375 DoLog(1) && (Log() << Verbose(1) << "true intersection." << endl);376 result = true;377 } else {378 DoLog(1) && (Log() << Verbose(1) << "intersection out of region of interest." << endl);379 result = false;380 }381 382 // free minimizer stuff383 gsl_vector_free(x);384 gsl_vector_free(ss);385 gsl_multimin_fminimizer_free(s);386 387 return result;388 };389 390 221 /** Gets the angle between a point and a reference relative to the provided center. 391 222 * We have two shanks point and reference between which the angle is calculated … … 419 250 /** Calculates the volume of a general tetraeder. 420 251 * \param *a first vector 421 * \param * a firstvector422 * \param * a firstvector423 * \param * a firstvector252 * \param *b second vector 253 * \param *c third vector 254 * \param *d fourth vector 424 255 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$ 425 256 */ … … 439 270 volume = 1./6. * fabs(Point.ScalarProduct(TetraederVector[2])); 440 271 return volume; 272 }; 273 274 /** Calculates the area of a general triangle. 275 * We use the Heron's formula of area, [Bronstein, S. 138] 276 * \param &A first vector 277 * \param &B second vector 278 * \param &C third vector 279 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$ 280 */ 281 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C) 282 { 283 Info FunctionInfo(__func__); 284 285 const double sidea = B.distance(C); 286 const double sideb = A.distance(C); 287 const double sidec = A.distance(B); 288 const double s = (sidea+sideb+sidec)/2.; 289 290 const double area = sqrt(s*(s-sidea)*(s-sideb)*(s-sidec)); 291 return area; 441 292 }; 442 293 … … 574 425 } 575 426 } else { 576 eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," 577 << LC->n[2] << " is invalid!" << endl; 427 DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl); 578 428 } 579 429 } … … 630 480 } 631 481 } else { 632 eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," 633 << LC->n[2] << " is invalid!" << endl; 482 DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl); 634 483 } 635 484 } … … 882 731 class BoundaryPointSet *point = NULL; 883 732 class BoundaryLineSet *line = NULL; 884 885 // calculate remaining concavity 733 class BoundaryTriangleSet *triangle = NULL; 734 double ConcavityPerLine = 0.; 735 double ConcavityPerTriangle = 0.; 736 double area = 0.; 737 double totalarea = 0.; 738 886 739 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 887 740 point = PointRunner->second; 888 741 DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl); 889 point->value = 0; 742 743 // calculate mean concavity over all connected line 744 ConcavityPerLine = 0.; 890 745 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 891 746 line = LineRunner->second; 892 747 //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl; 893 if (!line->CheckConvexityCriterion()) 894 point->value += 1; 895 } 896 } 897 }; 898 748 ConcavityPerLine -= line->CalculateConvexity(); 749 } 750 ConcavityPerLine /= point->lines.size(); 751 752 // weigh with total area of the surrounding triangles 753 totalarea = 0.; 754 TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second); 755 for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 756 totalarea += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node); 757 } 758 ConcavityPerLine *= totalarea; 759 760 // calculate mean concavity over all attached triangles 761 ConcavityPerTriangle = 0.; 762 for (TriangleSet::const_iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 763 line = (*TriangleRunner)->GetThirdLine(PointRunner->second); 764 triangle = line->GetOtherTriangle(*TriangleRunner); 765 area = CalculateAreaofGeneralTriangle(*triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node); 766 area += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node); 767 area *= -line->CalculateConvexity(); 768 if (area > 0) 769 ConcavityPerTriangle += area; 770 // else 771 // ConcavityPerTriangle -= area; 772 } 773 ConcavityPerTriangle /= triangles->size()/totalarea; 774 delete(triangles); 775 776 // add up 777 point->value = ConcavityPerLine + ConcavityPerTriangle; 778 } 779 }; 780 781 782 783 /** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation. 784 * Sets BoundaryPointSet::value equal to the nearest distance to convex envelope. 785 * \param *out output stream for debugging 786 * \param *TesselStruct pointer to Tesselation structure 787 * \param *Convex pointer to convex Tesselation structure as reference 788 */ 789 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex) 790 { 791 Info FunctionInfo(__func__); 792 double distance = 0.; 793 794 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 795 DoeLog(1) && (eLog() << Verbose(1) << "INFO: Current point is " << * PointRunner->second << "." << endl); 796 797 distance = 0.; 798 for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) { 799 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(*PointRunner->second->node->node, TriangleRunner->second); 800 if (CurrentDistance < distance) 801 distance = CurrentDistance; 802 } 803 804 PointRunner->second->value = distance; 805 } 806 }; 899 807 900 808 /** Checks whether each BoundaryLineSet in the Tesselation has two triangles. -
src/tesselationhelpers.hpp
r06f4ef6 rb6da28 20 20 #endif 21 21 22 #include <gsl/gsl_linalg.h> 23 #include <gsl/gsl_matrix.h> 24 #include <gsl/gsl_multimin.h> 25 #include <gsl/gsl_permutation.h> 26 #include <gsl/gsl_vector.h> 27 28 #include <iostream> 22 #include <iosfwd> 29 23 30 24 #include "defs.hpp" … … 43 37 /********************************************** definitions *********************************/ 44 38 45 #define HULLEPSILON 1e- 1039 #define HULLEPSILON 1e-9 //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities 46 40 47 41 /********************************************** declarations *******************************/ 48 42 49 double DetGet(gsl_matrix * const A, const int inPlace);50 43 void GetSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS); 51 44 void GetCenterOfSphere(Vector* const Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* const Direction, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius); 52 45 void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c); 53 46 double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection); 54 double MinIntersectDistance(const gsl_vector * x, void *params);55 bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4);56 47 double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d); 48 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C); 57 49 double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector); 58 50 … … 68 60 void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud); 69 61 void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct); 62 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex); 70 63 double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle); 71 64 -
src/triangleintersectionlist.cpp
r06f4ef6 rb6da28 11 11 #include "Helpers/MemDebug.hpp" 12 12 13 #include <boost/scoped_ptr.hpp> 14 13 15 #include "triangleintersectionlist.hpp" 14 16 … … 16 18 #include "tesselation.hpp" 17 19 #include "vector.hpp" 20 #include "verbose.hpp" 18 21 19 22 /** Constructor for class TriangleIntersectionList. … … 118 121 119 122 // get closest points 120 DistanceToPointMap * points = Tess->FindClosestBoundaryPointsToVector(Point,Vicinity);123 boost::scoped_ptr< DistanceToPointMap > points(Tess->FindClosestBoundaryPointsToVector(Point,Vicinity)); 121 124 if (points == NULL) { 122 125 DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl); -
src/unittests/ActOnAllUnitTest.cpp
r06f4ef6 rb6da28 14 14 #include "../test/ActOnAlltest.hpp" 15 15 #include "ActOnAllUnitTest.hpp" 16 #include "memoryallocator.hpp"17 16 #include "vector.hpp" 18 17 -
src/unittests/ActionSequenceTest.cpp
r06f4ef6 rb6da28 17 17 #include "Actions/ActionRegistry.hpp" 18 18 19 #include "DummyUI.hpp" 20 19 21 #ifdef HAVE_TESTRUNNER 20 22 #include "UnitTestMain.hpp" … … 33 35 virtual ~canUndoActionStub(){} 34 36 37 virtual Dialog* fillDialog(Dialog *dialog){ 38 ASSERT(dialog,"No Dialog given when filling action dialog"); 39 return dialog; 40 } 41 35 42 virtual Action::state_ptr performCall(){ 36 43 return Action::success; … … 55 62 cannotUndoActionStub() : Action("cannotUndoActionStub",false){} 56 63 virtual ~cannotUndoActionStub(){} 64 65 virtual Dialog* fillDialog(Dialog *dialog){ 66 ASSERT(dialog,"No Dialog given when filling action dialog"); 67 return dialog; 68 } 57 69 58 70 virtual Action::state_ptr performCall(){ … … 82 94 virtual ~wasCalledActionStub(){} 83 95 96 virtual Dialog* fillDialog(Dialog *dialog){ 97 return dialog; 98 } 84 99 virtual Action::state_ptr performCall(){ 85 100 called = true; … … 108 123 109 124 void ActionSequenceTest::setUp(){ 125 static bool hasDescriptor = false; 110 126 ActionHistory::init(); 127 // TODO: find a way to really reset the factory to a clean state in tear-down 128 if(!hasDescriptor){ 129 UIFactory::registerFactory(new DummyUIFactory::description()); 130 hasDescriptor = true; 131 } 132 UIFactory::makeUserInterface("Dummy"); 111 133 // create some necessary stubs used in this test 112 134 positive1 = new canUndoActionStub(); … … 135 157 ActionHistory::purgeInstance(); 136 158 ActionRegistry::purgeInstance(); 159 UIFactory::purgeInstance(); 137 160 } 138 161 … … 220 243 221 244 CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled()); 222 CPPUNIT_ASSERT_EQUAL(true,wasCalled 1->wasCalled());245 CPPUNIT_ASSERT_EQUAL(true,wasCalled2->wasCalled()); 223 246 224 247 ActionHistory::getInstance().undoLast(); 225 248 226 249 CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled()); 227 CPPUNIT_ASSERT_EQUAL(false,wasCalled 1->wasCalled());228 229 } 230 231 250 CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled()); 251 252 } 253 254 -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r06f4ef6 rb6da28 16 16 #include "analysis_correlation.hpp" 17 17 #include "AnalysisCorrelationToPointUnitTest.hpp" 18 19 #include "Descriptors/MoleculeDescriptor.hpp" 18 20 19 21 #include "atom.hpp" … … 38 40 39 41 // init private all pointers to zero 40 TestList = NULL;41 42 TestMolecule = NULL; 42 43 pointmap = NULL; … … 71 72 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 72 73 73 TestList = World::getInstance().getMolecules();74 TestList->insert(TestMolecule);75 74 TestMolecule->ActiveFlag = true; 76 75 … … 79 78 80 79 // init maps 81 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point ); 80 World::getInstance().selectAllMolecules(AllMolecules()); 81 allMolecules = World::getInstance().getSelectedMolecules(); 82 CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size()); 83 pointmap = CorrelationToPoint( allMolecules, elements, (const Vector *)point ); 82 84 binmap = NULL; 83 85 -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
r06f4ef6 rb6da28 35 35 private: 36 36 37 MoleculeListClass *TestList;37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 39 element *hydrogen; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r06f4ef6 rb6da28 16 16 #include "analysis_correlation.hpp" 17 17 #include "AnalysisCorrelationToSurfaceUnitTest.hpp" 18 19 #include "Descriptors/MoleculeDescriptor.hpp" 18 20 19 21 #include "atom.hpp" … … 45 47 46 48 // init private all pointers to zero 47 TestList = NULL;48 49 TestSurfaceMolecule = NULL; 49 50 surfacemap = NULL; … … 83 84 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 ); 84 85 85 TestList = World::getInstance().getMolecules();86 86 TestSurfaceMolecule->ActiveFlag = true; 87 TestList->insert(TestSurfaceMolecule);88 87 89 88 // init tesselation and linked cell … … 116 115 TestSurfaceMolecule->AddAtom(Walker); 117 116 118 TestSurfaceMolecule->ActiveFlag = true; 119 TestList->insert(TestSurfaceMolecule); 117 World::getInstance().selectAllMolecules(AllMolecules()); 118 allMolecules = World::getInstance().getSelectedMolecules(); 119 CPPUNIT_ASSERT_EQUAL( (size_t) 2, allMolecules.size()); 120 120 121 121 // init maps … … 146 146 { 147 147 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() ); 148 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );148 CPPUNIT_ASSERT_EQUAL( (size_t)2, allMolecules.size() ); 149 149 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); 150 150 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() ); … … 156 156 // do the pair correlation 157 157 elements.push_back(hydrogen); 158 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );158 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 159 159 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 160 160 CPPUNIT_ASSERT( surfacemap != NULL ); … … 166 166 BinPairMap::iterator tester; 167 167 elements.push_back(hydrogen); 168 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );168 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 169 169 // put pair correlation into bins and check with no range 170 170 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); … … 182 182 BinPairMap::iterator tester; 183 183 elements.push_back(hydrogen); 184 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );184 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 185 185 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 186 186 // ... and check with [0., 2.] range … … 201 201 BinPairMap::iterator tester; 202 202 elements.push_back(carbon); 203 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );203 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 204 204 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 205 205 // put pair correlation into bins and check with no range … … 221 221 BinPairMap::iterator tester; 222 222 elements.push_back(carbon); 223 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );223 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 224 224 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 225 225 // ... and check with [0., 2.] range -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r06f4ef6 rb6da28 43 43 private: 44 44 45 MoleculeListClass *TestList;45 std::vector<molecule *> allMolecules; 46 46 molecule *TestSurfaceMolecule; 47 47 element *hydrogen; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r06f4ef6 rb6da28 16 16 #include "analysis_correlation.hpp" 17 17 #include "AnalysisPairCorrelationUnitTest.hpp" 18 19 #include "Descriptors/MoleculeDescriptor.hpp" 18 20 19 21 #include "World.hpp" … … 42 44 43 45 // init private all pointers to zero 44 TestList = NULL;45 46 TestMolecule = NULL; 46 47 correlationmap = NULL; … … 76 77 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 77 78 78 TestList = World::getInstance().getMolecules();79 TestMolecule->ActiveFlag = true;80 TestList->insert(TestMolecule);81 82 79 // init maps 83 correlationmap = PairCorrelation( TestList, elements); 80 World::getInstance().selectAllMolecules(AllMolecules()); 81 allMolecules = World::getInstance().getSelectedMolecules(); 82 CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size()); 83 correlationmap = PairCorrelation( allMolecules, elements); 84 84 binmap = NULL; 85 85 -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
r06f4ef6 rb6da28 35 35 private: 36 36 37 MoleculeListClass *TestList;37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 39 element *hydrogen; -
src/unittests/CountBondsUnitTest.cpp
r06f4ef6 rb6da28 154 154 Translator = Vector(3,0,0); 155 155 TestMolecule2->Translate(&Translator); 156 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );157 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen ) );156 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 157 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) ); 158 158 //OutputTestMolecule(TestMolecule2, "testmolecule2-1.xyz"); 159 159 Translator = Vector(-3,0,0); … … 163 163 Translator = Vector(0,3,0); 164 164 TestMolecule2->Translate(&Translator); 165 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );165 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 166 166 //OutputTestMolecule(TestMolecule2, "testmolecule2-2.xyz"); 167 167 Translator = Vector(0,-3,0); … … 172 172 TestMolecule2->Scale((const double ** const)&mirror); 173 173 TestMolecule2->Translate(&Translator); 174 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );174 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 175 175 //OutputTestMolecule(TestMolecule2, "testmolecule2-3.xyz"); 176 176 Translator = Vector(0,3,0); … … 181 181 Translator = Vector(2,1,0); 182 182 TestMolecule2->Translate(&Translator); 183 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );183 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 184 184 //OutputTestMolecule(TestMolecule2, "testmolecule2-4.xyz"); 185 185 Translator = Vector(-2,-1,0); … … 189 189 Translator = Vector(0,0,3); 190 190 TestMolecule2->Translate(&Translator); 191 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );191 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 192 192 //OutputTestMolecule(TestMolecule2, "testmolecule2-5.xyz"); 193 193 Translator = Vector(0,0,-3); … … 198 198 TestMolecule2->Scale((const double ** const)&mirror); 199 199 TestMolecule2->Translate(&Translator); 200 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );200 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 201 201 //OutputTestMolecule(TestMolecule2, "testmolecule2-6.xyz"); 202 202 Translator = Vector(3,0,0); … … 208 208 TestMolecule2->Scale((const double ** const)&mirror); 209 209 TestMolecule2->Translate(&Translator); 210 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );210 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 211 211 //OutputTestMolecule(TestMolecule2, "testmolecule2-7.xyz"); 212 212 Translator = Vector(-3,0,0); … … 219 219 TestMolecule2->Translate(&Translator); 220 220 //OutputTestMolecule(TestMolecule2, "testmolecule2-8.xyz"); 221 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );221 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 222 222 Translator = Vector(0,-3,0); 223 223 TestMolecule2->Translate(&Translator); -
src/unittests/LineUnittest.cpp
r06f4ef6 rb6da28 17 17 18 18 #include <iostream> 19 #include <cmath> 19 20 20 21 using namespace std; … … 352 353 CPPUNIT_ASSERT_EQUAL(fixture,zeroVec); 353 354 } 355 356 void LineUnittest::sphereIntersectionTest(){ 357 { 358 std::vector<Vector> res = la1->getSphereIntersections(); 359 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 360 CPPUNIT_ASSERT(testDirection(res[0],e1)); 361 CPPUNIT_ASSERT(testDirection(res[1],e1)); 362 CPPUNIT_ASSERT(res[0]!=res[1]); 363 } 364 365 { 366 std::vector<Vector> res = la2->getSphereIntersections(); 367 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 368 CPPUNIT_ASSERT(testDirection(res[0],e2)); 369 CPPUNIT_ASSERT(testDirection(res[1],e2)); 370 CPPUNIT_ASSERT(res[0]!=res[1]); 371 } 372 373 { 374 std::vector<Vector> res = la3->getSphereIntersections(); 375 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 376 CPPUNIT_ASSERT(testDirection(res[0],e3)); 377 CPPUNIT_ASSERT(testDirection(res[1],e3)); 378 CPPUNIT_ASSERT(res[0]!=res[1]); 379 } 380 381 { 382 std::vector<Vector> res = lp1->getSphereIntersections(); 383 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 384 CPPUNIT_ASSERT((res[0]==e1) || (res[0]==e2)); 385 CPPUNIT_ASSERT((res[1]==e1) || (res[1]==e2)); 386 CPPUNIT_ASSERT(res[0]!=res[1]); 387 } 388 389 { 390 std::vector<Vector> res = lp2->getSphereIntersections(); 391 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 392 CPPUNIT_ASSERT((res[0]==e2) || (res[0]==e3)); 393 CPPUNIT_ASSERT((res[1]==e2) || (res[1]==e3)); 394 CPPUNIT_ASSERT(res[0]!=res[1]); 395 } 396 397 { 398 std::vector<Vector> res = lp3->getSphereIntersections(); 399 CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2); 400 CPPUNIT_ASSERT((res[0]==e3) || (res[0]==e1)); 401 CPPUNIT_ASSERT((res[1]==e3) || (res[1]==e1)); 402 CPPUNIT_ASSERT(res[0]!=res[1]); 403 } 404 } -
src/unittests/LineUnittest.hpp
r06f4ef6 rb6da28 22 22 CPPUNIT_TEST ( intersectionTest ); 23 23 CPPUNIT_TEST ( rotationTest ); 24 CPPUNIT_TEST ( sphereIntersectionTest ); 24 25 CPPUNIT_TEST_SUITE_END(); 25 26 … … 33 34 void intersectionTest(); 34 35 void rotationTest(); 36 void sphereIntersectionTest(); 35 37 36 38 private: -
src/unittests/LinkedCellUnitTest.cpp
r06f4ef6 rb6da28 264 264 Vector tester; 265 265 LinkedCell::LinkedNodes *ListOfPoints = NULL; 266 atom *Walker = NULL;267 266 size_t size = 0; 268 267 … … 326 325 Vector tester; 327 326 LinkedCell::LinkedNodes *ListOfPoints = NULL; 328 atom *Walker = NULL;329 327 size_t size = 0; 330 328 -
src/unittests/Makefile.am
r06f4ef6 rb6da28 7 7 AM_CXXFLAGS = $(CPPUNIT_CFLAGS) 8 8 9 MENUTESTS = \10 ActionSequenceTest11 12 9 TESTS = \ 10 ActionSequenceTest \ 13 11 ActOnAllUnitTest \ 14 12 AnalysisBondsUnitTests \ … … 19 17 AtomDescriptorTest \ 20 18 BondGraphUnitTest \ 19 BoxUnittest \ 21 20 CacheableTest \ 22 21 CountBondsUnitTest \ 22 FormulaUnittest \ 23 23 GSLMatrixSymmetricUnitTest \ 24 24 GSLMatrixUnitTest \ … … 31 31 LogUnitTest \ 32 32 manipulateAtomsTest \ 33 MemoryUsageObserverUnitTest \ 34 MemoryAllocatorUnitTest \ 33 MatrixUnittest \ 35 34 MoleculeDescriptorTest \ 36 35 ObserverTest \ … … 44 43 Tesselation_BoundaryTriangleUnitTest \ 45 44 Tesselation_InOutsideUnitTest \ 46 VectorUnitTest \ 47 ${MENUTESTS} 45 VectorUnitTest 48 46 49 47 … … 51 49 noinst_PROGRAMS = $(TESTS) TestRunner 52 50 53 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}51 GSLLIBS = ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 54 52 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 53 PARSERLIBS = ../libparser.a ${ALLLIBS} 54 UILIBS = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ${ALLLIBS} ${BOOST_PROGRAM_OPTIONS_LIB} 55 55 56 56 TESTSOURCES = \ … … 64 64 atomsCalculationTest.cpp \ 65 65 bondgraphunittest.cpp \ 66 BoxUnittest.cpp \ 66 67 CacheableTest.cpp \ 67 68 CountBondsUnitTest.cpp \ 69 FormulaUnittest.cpp \ 68 70 gslmatrixsymmetricunittest.cpp \ 69 71 gslmatrixunittest.cpp \ … … 75 77 listofbondsunittest.cpp \ 76 78 logunittest.cpp \ 79 MatrixUnittest.cpp \ 77 80 manipulateAtomsTest.cpp \ 78 memoryallocatorunittest.cpp \79 memoryusageobserverunittest.cpp \80 81 MoleculeDescriptorTest.cpp \ 81 82 ObserverTest.cpp \ … … 101 102 atomsCalculationTest.hpp \ 102 103 bondgraphunittest.hpp \ 104 BoxUnittest.hpp \ 103 105 CacheableTest.hpp \ 104 106 CountBondsUnitTest.hpp \ 107 FormulaUnittest.hpp \ 105 108 gslmatrixsymmetricunittest.hpp \ 106 109 gslmatrixunittest.hpp \ … … 113 116 logunittest.hpp \ 114 117 manipulateAtomsTest.hpp \ 115 memoryallocatorunittest.hpp \ 116 memoryusageobserverunittest.hpp \ 118 MatrixUnittest.hpp \ 117 119 MoleculeDescriptorTest.hpp \ 118 120 periodentafelTest.hpp \ … … 127 129 128 130 129 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp130 ActionSequenceTest_LDADD = ${ ALLLIBS}131 ActionSequenceTest_SOURCES = UnitTestMain.cpp ActionSequenceTest.cpp ActionSequenceTest.hpp $(srcdir)/../version.c 132 ActionSequenceTest_LDADD = ${UILIBS} 131 133 132 134 ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp … … 154 156 BondGraphUnitTest_LDADD = ${ALLLIBS} 155 157 158 BoxUnittest_SOURCES = UnitTestMain.cpp BoxUnittest.cpp BoxUnittest.hpp 159 BoxUnittest_LDADD = ${ALLLIBS} 160 156 161 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp 157 162 CacheableTest_LDADD = ${ALLLIBS} … … 160 165 CountBondsUnitTest_LDADD = ${ALLLIBS} 161 166 167 FormulaUnittest_SOURCES = UnitTestMain.cpp FormulaUnittest.cpp FormulaUnittest.hpp 168 FormulaUnittest_LDADD = ${ALLLIBS} 169 162 170 GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp 163 171 GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS} … … 187 195 LogUnitTest_LDADD = ${ALLLIBS} 188 196 189 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp 190 manipulateAtomsTest_LDADD = ${ALLLIBS} 191 192 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 193 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS} 194 195 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 196 MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS} 197 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp $(srcdir)/../version.c 198 manipulateAtomsTest_LDADD = ${UILIBS} 199 200 MatrixUnittest_SOURCES = UnitTestMain.cpp MatrixUnittest.cpp MatrixUnittest.hpp 201 MatrixUnittest_LDADD = ${ALLLIBS} 197 202 198 203 MoleculeDescriptorTest_SOURCES = UnitTestMain.cpp MoleculeDescriptorTest.cpp MoleculeDescriptorTest.hpp … … 203 208 204 209 ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp 205 ParserUnitTest_LDADD = ${ ALLLIBS}210 ParserUnitTest_LDADD = ${PARSERLIBS} 206 211 207 212 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp … … 215 220 216 221 SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp 217 SingletonTest_LDADD = $ (BOOST_LIB) ${BOOST_THREAD_LIB}222 SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB} 218 223 219 224 StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp … … 229 234 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 230 235 231 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp$(TESTSOURCES) $(TESTHEADERS)232 TestRunner_LDADD = ${ALLLIBS}236 TestRunner_SOURCES = TestRunnerMain.cpp $(srcdir)/../version.c $(TESTSOURCES) $(TESTHEADERS) 237 TestRunner_LDADD = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ../libmolecuilder.a ../libparser.a ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} 233 238 234 239 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp -
src/unittests/ObserverTest.cpp
r06f4ef6 rb6da28 182 182 }; 183 183 184 class Observable Collection: public Observable {184 class ObservableSet : public Observable { 185 185 public: 186 186 typedef std::set<SimpleObservable*> set; … … 188 188 typedef set::const_iterator const_iterator; 189 189 190 Observable Collection(int _num) :190 ObservableSet(int _num) : 191 191 Observable("ObservableCollection"), 192 192 num(_num) … … 199 199 } 200 200 201 ~Observable Collection(){201 ~ObservableSet(){ 202 202 set::iterator iter; 203 203 for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){ 204 204 delete (*iter); 205 } 206 } 207 208 iterator begin(){ 209 return iterator(theSet.begin(),this); 210 } 211 212 iterator end(){ 213 return iterator(theSet.end(),this); 214 } 215 216 const int num; 217 218 private: 219 set theSet; 220 }; 221 222 class ObservableMap : public Observable { 223 public: 224 typedef std::map<int,SimpleObservable*> set; 225 typedef ObservedIterator<set> iterator; 226 typedef set::const_iterator const_iterator; 227 228 ObservableMap(int _num) : 229 Observable("ObservableCollection"), 230 num(_num) 231 { 232 for(int i=0; i<num; ++i){ 233 SimpleObservable *content = new SimpleObservable(); 234 content->signOn(this); 235 theSet.insert(make_pair(i,content)); 236 } 237 } 238 239 ~ObservableMap(){ 240 set::iterator iter; 241 for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){ 242 delete iter->second; 205 243 } 206 244 } … … 231 269 blockObservable = new BlockObservable(); 232 270 notificationObservable = new NotificationObservable(); 233 collection = new ObservableCollection(5); 271 obsset = new ObservableSet(5); 272 obsmap = new ObservableMap(5); 234 273 235 274 observer1 = new UpdateCountObserver(); … … 249 288 delete blockObservable; 250 289 delete notificationObservable; 251 delete collection; 290 delete obsset; 291 delete obsmap; 252 292 253 293 delete observer1; … … 268 308 simpleObservable2->signOn(observer4); 269 309 310 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 311 CPPUNIT_ASSERT_EQUAL( 0, observer2->updates ); 312 CPPUNIT_ASSERT_EQUAL( 0, observer3->updates ); 313 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 314 315 270 316 simpleObservable1->changeMethod(); 271 317 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates ); … … 292 338 void ObserverTest::doesBlockUpdateTest() { 293 339 callObservable->signOn(observer1); 340 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 294 341 295 342 callObservable->changeMethod1(); … … 311 358 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 312 359 CPPUNIT_ASSERT_EQUAL( 2, observer2->updates ); 360 } 361 362 void ObserverTest::outsideLockTest(){ 363 callObservable->signOn(observer1); 364 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 365 366 { 367 LOCK_OBSERVABLE(*callObservable); 368 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates ); 369 } 370 // lock is gone now, observer should have notified 371 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates ); 313 372 } 314 373 … … 341 400 int i = 0; 342 401 // test the general iterator methods 343 for(Observable Collection::iterator iter=collection->begin(); iter!=collection->end();++iter){344 CPPUNIT_ASSERT(i< collection->num);402 for(ObservableSet::iterator iter=obsset->begin(); iter!=obsset->end();++iter){ 403 CPPUNIT_ASSERT(i< obsset->num); 345 404 i++; 346 405 } 347 406 348 407 i=0; 349 for(Observable Collection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){350 CPPUNIT_ASSERT(i< collection->num);351 i++; 352 } 353 354 collection->signOn(observer1);408 for(ObservableSet::const_iterator iter=obsset->begin(); iter!=obsset->end();++iter){ 409 CPPUNIT_ASSERT(i<obsset->num); 410 i++; 411 } 412 413 obsset->signOn(observer1); 355 414 { 356 415 // we construct this out of the loop, so the iterator dies at the end of 357 416 // the scope and not the end of the loop (allows more testing) 358 Observable Collection::iterator iter;359 for(iter= collection->begin(); iter!=collection->end(); ++iter){417 ObservableSet::iterator iter; 418 for(iter=obsset->begin(); iter!=obsset->end(); ++iter){ 360 419 (*iter)->changeMethod(); 361 420 } … … 367 426 368 427 // when using a const_iterator no changes should be propagated 369 for(Observable Collection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);428 for(ObservableSet::const_iterator iter = obsset->begin(); iter!=obsset->end();++iter); 370 429 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates); 371 collection->signOff(observer1); 430 431 // we need to test the operator-> as well 432 obsmap->signOn(observer2); 433 { 434 // we construct this out of the loop, so the iterator dies at the end of 435 // the scope and not the end of the loop (allows more testing) 436 ObservableMap::iterator iter; 437 for(iter=obsmap->begin(); iter!=obsmap->end(); ++iter){ 438 iter->second->changeMethod(); 439 } 440 // At this point no change should have been propagated 441 CPPUNIT_ASSERT_EQUAL( 0, observer2->updates); 442 } 443 // After the Iterator has died the propagation should take place 444 CPPUNIT_ASSERT_EQUAL( 1, observer2->updates); 445 446 447 obsset->signOff(observer1); 448 obsmap->signOff(observer2); 372 449 } 373 450 … … 382 459 // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE 383 460 simpleObservable1->signOn(simpleObservable1); 461 #ifndef NDEBUG 384 462 CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure); 463 #else 464 simpleObservable1->changeMethod(); 465 #endif 385 466 386 467 // more complex test … … 388 469 simpleObservable1->signOn(simpleObservable2); 389 470 simpleObservable2->signOn(simpleObservable1); 471 #ifndef NDEBUG 390 472 CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure); 473 #else 474 simpleObservable1->changeMethod(); 475 #endif 476 477 391 478 simpleObservable1->signOff(simpleObservable2); 392 479 simpleObservable2->signOff(simpleObservable1); -
src/unittests/ObserverTest.hpp
r06f4ef6 rb6da28 17 17 class CallObservable; 18 18 class SuperObservable; 19 class ObservableCollection; 19 class ObservableSet; 20 class ObservableMap; 20 21 class BlockObservable; 21 22 class NotificationObservable; … … 27 28 CPPUNIT_TEST ( doesBlockUpdateTest ); 28 29 CPPUNIT_TEST ( doesSubObservableTest ); 30 CPPUNIT_TEST ( outsideLockTest ); 29 31 CPPUNIT_TEST ( doesNotifyTest ); 30 32 CPPUNIT_TEST ( doesReportTest ); … … 40 42 void doesBlockUpdateTest(); 41 43 void doesSubObservableTest(); 44 void outsideLockTest(); 42 45 void doesNotifyTest(); 43 46 void doesReportTest(); … … 60 63 SuperObservable *superObservable; 61 64 NotificationObservable *notificationObservable; 62 ObservableCollection *collection; 65 ObservableSet *obsset; 66 ObservableMap *obsmap; 63 67 64 68 }; -
src/unittests/ParserUnitTest.cpp
r06f4ef6 rb6da28 12 12 #include <cppunit/ui/text/TestRunner.h> 13 13 14 #include "Parser/MpqcParser.hpp" 15 #include "Parser/PcpParser.hpp" 16 #include "Parser/TremoloParser.hpp" 14 17 #include "Parser/XyzParser.hpp" 15 #include "Parser/TremoloParser.hpp"16 18 #include "World.hpp" 17 19 #include "atom.hpp" … … 29 31 CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest ); 30 32 33 static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\ 34 \n\ 35 mainname\tpcp\t# programm name (for runtime files)\n\ 36 defaultpath\not specified\t# where to put files during runtime\n\ 37 pseudopotpath\not specified\t# where to find pseudopotentials\n\ 38 \n\ 39 ProcPEGamma\t8\t# for parallel computing: share constants\n\ 40 ProcPEPsi\t1\t# for parallel computing: share wave functions\n\ 41 DoOutVis\t0\t# Output data for OpenDX\n\ 42 DoOutMes\t1\t# Output data for measurements\n\ 43 DoOutOrbitals\t0\t# Output all Orbitals\n\ 44 DoOutCurr\t0\t# Ouput current density for OpenDx\n\ 45 DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\ 46 DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\ 47 DoFullCurrent\t0\t# Do full perturbation\n\ 48 DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\ 49 Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\ 50 CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\ 51 SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\ 52 VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\ 53 VectorCut\t0\t# Cut plane axis value\n\ 54 AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\ 55 Seed\t1\t# initial value for random seed for Psi coefficients\n\ 56 \n\ 57 MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\ 58 Deltat\t0.01\t# time per MD step\n\ 59 OutVisStep\t10\t# Output visual data every ...th step\n\ 60 OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\ 61 TargetTemp\t0.000950045\t# Target temperature\n\ 62 MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\ 63 EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\ 64 # Values specifying when to stop\n\ 65 MaxMinStep\t100\t# Maximum number of steps\n\ 66 RelEpsTotalE\t1e-07\t# relative change in total energy\n\ 67 RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\ 68 MaxMinStopStep\t2\t# check every ..th steps\n\ 69 MaxMinGapStopStep\t1\t# check every ..th steps\n\ 70 \n\ 71 # Values specifying when to stop for INIT, otherwise same as above\n\ 72 MaxInitMinStep\t100\t# Maximum number of steps\n\ 73 InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\ 74 InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\ 75 InitMaxMinStopStep\t2\t# check every ..th steps\n\ 76 InitMaxMinGapStopStep\t1\t# check every ..th steps\n\ 77 \n\ 78 BoxLength\t# (Length of a unit cell)\n\ 79 20\n\ 80 0\t20\n\ 81 0\t0\t20\n\ 82 \n\ 83 ECut\t128\t# energy cutoff for discretization in Hartrees\n\ 84 MaxLevel\t5\t# number of different levels in the code, >=2\n\ 85 Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\ 86 RiemannTensor\t0\t# (Use metric)\n\ 87 PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\ 88 MaxPsiDouble\t2\t# here: specifying both maximum number of SpinUp- and -Down-states\n\ 89 PsiMaxNoUp\t2\t# here: specifying maximum number of SpinUp-states\n\ 90 PsiMaxNoDown\t2\t# here: specifying maximum number of SpinDown-states\n\ 91 AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\ 92 \n\ 93 RCut\t20\t# R-cut for the ewald summation\n\ 94 StructOpt\t0\t# Do structure optimization beforehand\n\ 95 IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\ 96 RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\ 97 MaxTypes\t2\t# maximum number of different ion types\n\ 98 \n\ 99 # Ion type data (PP = PseudoPotential, Z = atomic number)\n\ 100 #Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\ 101 Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\ 102 Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\ 103 #Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\ 104 Ion_Type2_1\t0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\ 105 Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\ 106 Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n"; 107 static string waterMpqc ="% Created by MoleCuilder\n\ 108 mpqc: (\n\ 109 \tsavestate = no\n\ 110 \tdo_gradient = yes\n\ 111 \tmole<MBPT2>: (\n\ 112 \t\tmaxiter = 200\n\ 113 \t\tbasis = $:basis\n\ 114 \t\tmolecule = $:molecule\n\ 115 \t\treference<CLHF>: (\n\ 116 \t\t\tbasis = $:basis\n\ 117 \t\t\tmolecule = $:molecule\n\ 118 \t\t)\n\ 119 \t)\n\ 120 )\n\ 121 molecule<Molecule>: (\n\ 122 \tunit = angstrom\n\ 123 \t{ atoms geometry } = {\n\ 124 \t\tO [ -0.505735\t0\t0 ]\n\ 125 \t\tH [ 0.252867\t0\t0.504284 ]\n\ 126 \t\tH [ 0.252867\t0\t-0.504284 ]\n\ 127 \t}\n\ 128 )\n\ 129 basis<GaussianBasisSet>: (\n\ 130 \tname = \"3-21G\"\n\ 131 \tmolecule = $:molecule\n\ 132 )\n"; 133 static string waterXyz = "3\n\tH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n"; 134 static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n"; 135 static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 136 static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n"; 137 static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 138 static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; 139 static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 140 static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 141 static string Tremolo_full = "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n"; 31 142 32 143 void ParserUnitTest::setUp() { 33 144 World::getInstance(); 145 146 // we need hydrogens and oxygens in the following tests 147 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL); 148 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL); 34 149 } 35 150 36 151 void ParserUnitTest::tearDown() { 152 ChangeTracker::purgeInstance(); 37 153 World::purgeInstance(); 38 154 } … … 43 159 cout << "Testing the XYZ parser." << endl; 44 160 XyzParser* testParser = new XyzParser(); 45 string waterXyz = "3\nH2O: water molecule\nO\t0.000000\t0.000000\t0.000000\nH\t0.758602\t0.000000\t0.504284\nH\t0.758602\t0.000000\t-0.504284\n";46 161 stringstream input; 47 162 input << waterXyz; … … 62 177 TremoloParser* testParser = new TremoloParser(); 63 178 stringstream input, output; 64 string waterTremolo;65 179 66 180 // Atomdata beginning with "# ATOMDATA" 67 waterTremolo = "# ATOMDATA\tId\tname\tType\tx=3\n"; 68 input << waterTremolo; 69 testParser->load(&input); 70 testParser->save(&output); 71 CPPUNIT_ASSERT(waterTremolo == output.str()); 181 input << Tremolo_Atomdata1; 182 testParser->load(&input); 183 testParser->save(&output); 184 CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str()); 72 185 input.clear(); 73 186 output.clear(); 74 187 75 188 // Atomdata beginning with "#ATOMDATA" 76 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 77 input << waterTremolo; 189 input << Tremolo_Atomdata2; 78 190 testParser->load(&input); 79 191 testParser->save(&output); … … 83 195 84 196 // Invalid key in Atomdata line 85 waterTremolo = "#\n#ATOMDATA Id name foo Type x=3\n\n\n"; 86 input << waterTremolo; 197 input << Tremolo_invalidkey; 87 198 testParser->load(&input); 88 199 //TODO: proove invalidity … … 93 204 TremoloParser* testParser = new TremoloParser(); 94 205 stringstream input; 95 string waterTremolo;96 206 97 207 // One simple data line 98 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 99 input << waterTremolo; 208 input << Tremolo_Atomdata2; 100 209 testParser->load(&input); 101 210 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0); … … 106 215 TremoloParser* testParser = new TremoloParser(); 107 216 stringstream input; 108 string waterTremolo;109 217 110 218 // One simple data line 111 waterTremolo = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 112 input << waterTremolo; 219 input << Tremolo_velocity; 113 220 testParser->load(&input); 114 221 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0); … … 119 226 TremoloParser* testParser = new TremoloParser(); 120 227 stringstream input; 121 string waterTremolo;122 228 123 229 // Neighbor data 124 waterTremolo = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; 125 input << waterTremolo; 230 input << Tremolo_neighbours; 126 231 testParser->load(&input); 127 232 … … 135 240 TremoloParser* testParser = new TremoloParser(); 136 241 stringstream input, output; 137 string waterTremolo;138 242 139 243 // Neighbor data 140 waterTremolo = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 141 input << waterTremolo; 244 input << Tremolo_improper; 142 245 testParser->load(&input); 143 246 testParser->save(&output); … … 151 254 TremoloParser* testParser = new TremoloParser(); 152 255 stringstream input, output; 153 string waterTremolo;154 256 155 257 // Neighbor data 156 waterTremolo = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 157 input << waterTremolo; 258 input << Tremolo_torsion; 158 259 testParser->load(&input); 159 260 testParser->save(&output); … … 173 274 testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion"); 174 275 testParser->save(&output); 175 CPPUNIT_ASSERT(output.str() == "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n");276 CPPUNIT_ASSERT(output.str() == Tremolo_full); 176 277 177 278 cout << "testing the tremolo parser is done" << endl; 178 279 } 280 281 void ParserUnitTest::readwritePcpTest() { 282 stringstream input(waterPcp); 283 PcpParser* testParser = new PcpParser(); 284 testParser->load(&input); 285 input.clear(); 286 287 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 288 289 string newWaterPcp = ""; 290 stringstream output; 291 testParser->save(&output); 292 293 input << output; 294 PcpParser* testParser2 = new PcpParser(); 295 testParser2->load(&input); 296 297 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms()); 298 299 CPPUNIT_ASSERT(*testParser == *testParser2); 300 } 301 302 void ParserUnitTest::writeMpqcTest() { 303 // build up water molecule 304 atom *Walker = NULL; 305 Walker = World::getInstance().createAtom(); 306 Walker->type = World::getInstance().getPeriode()->FindElement(8); 307 Walker->x = Vector(0,0,0); 308 Walker = World::getInstance().createAtom(); 309 Walker->type = World::getInstance().getPeriode()->FindElement(1); 310 Walker->x = Vector(0.758602,0,0.504284); 311 Walker = World::getInstance().createAtom(); 312 Walker->type = World::getInstance().getPeriode()->FindElement(1); 313 Walker->x = Vector(0.758602,0,-0.504284); 314 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 315 316 // create two stringstreams, one stored, one created 317 stringstream input(waterMpqc); 318 MpqcParser* testParser = new MpqcParser(); 319 stringstream output; 320 testParser->save(&output); 321 322 // compare both configs 323 string first = input.str(); 324 string second = output.str(); 325 CPPUNIT_ASSERT(first == second); 326 } -
src/unittests/ParserUnitTest.hpp
r06f4ef6 rb6da28 22 22 CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest ); 23 23 CPPUNIT_TEST ( writeTremoloTest ); 24 CPPUNIT_TEST ( readwritePcpTest ); 25 CPPUNIT_TEST ( writeMpqcTest ); 24 26 CPPUNIT_TEST_SUITE_END(); 25 27 … … 36 38 void readAndWriteTremoloTorsionInformationTest(); 37 39 void writeTremoloTest(); 40 void readwritePcpTest(); 41 void writeMpqcTest(); 38 42 }; 39 43 -
src/unittests/PlaneUnittest.cpp
r06f4ef6 rb6da28 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <cmath> 13 15 14 16 #ifdef HAVE_TESTRUNNER -
src/unittests/TestRunnerMain.cpp
r06f4ef6 rb6da28 17 17 #include "../../../TestRunnerClient.h" 18 18 #include "../../../TestRunnerClient.cpp" 19 19 20 #else 20 #include "UnitTestMain.cpp"21 #endif22 21 22 #include "unittests/UnitTestMain.cpp" 23 24 #endif /* HAVE_ECUT */ -
src/unittests/UnitTestMain.cpp
r06f4ef6 rb6da28 6 6 */ 7 7 8 #include <cppunit/CompilerOutputter.h>9 #include <cppunit/extensions/TestFactoryRegistry.h>10 #include <cppunit/ui/text/TestRunner.h>11 12 8 // include config.h 13 9 #ifdef HAVE_CONFIG_H 14 10 #include <config.h> 15 11 #endif 12 13 #include <cppunit/CompilerOutputter.h> 14 #include <cppunit/extensions/TestFactoryRegistry.h> 15 #include <cppunit/ui/text/TestRunner.h> 16 16 17 17 /********************************************** Main routine **************************************/ … … 35 35 return wasSucessful ? 0 : 1; 36 36 }; 37 -
src/unittests/linearsystemofequationsunittest.cpp
r06f4ef6 rb6da28 12 12 #include <cppunit/extensions/TestFactoryRegistry.h> 13 13 #include <cppunit/ui/text/TestRunner.h> 14 #include <cmath> 14 15 15 16 #include "linearsystemofequationsunittest.hpp" -
src/unittests/manipulateAtomsTest.cpp
r06f4ef6 rb6da28 22 22 #include "World.hpp" 23 23 #include "atom.hpp" 24 25 #include "DummyUI.hpp" 24 26 25 27 #ifdef HAVE_TESTRUNNER … … 72 74 // set up and tear down 73 75 void manipulateAtomsTest::setUp(){ 76 static bool hasDescriptor = false; 74 77 ActionHistory::init(); 75 78 World::getInstance(); 79 // TODO: find a way to really reset the factory to a clean state in tear-down 80 if(!hasDescriptor){ 81 UIFactory::registerFactory(new DummyUIFactory::description()); 82 hasDescriptor = true; 83 } 84 UIFactory::makeUserInterface("Dummy"); 76 85 for(int i=0;i<ATOM_COUNT;++i){ 77 86 atoms[i]= new AtomStub(i); … … 83 92 ActionRegistry::purgeInstance(); 84 93 ActionHistory::purgeInstance(); 94 UIFactory::purgeInstance(); 85 95 } 86 96 87 97 static void operation(atom* _atom){ 88 98 AtomStub *atom = dynamic_cast<AtomStub*>(_atom); 89 assert(atom);99 CPPUNIT_ASSERT(atom); 90 100 atom->doSomething(); 91 101 } … … 100 110 AtomStub *atom; 101 111 atom = dynamic_cast<AtomStub*>(*iter); 102 assert(atom);112 CPPUNIT_ASSERT(atom); 103 113 CPPUNIT_ASSERT(atom->manipulated); 104 114 } … … 114 124 AtomStub *atom; 115 125 atom = dynamic_cast<AtomStub*>(*iter); 116 assert(atom);126 CPPUNIT_ASSERT(atom); 117 127 if(atom->getId()!=(int)ATOM_COUNT/2) 118 128 CPPUNIT_ASSERT(atom->manipulated); -
src/unittests/tesselation_insideoutsideunittest.cpp
r06f4ef6 rb6da28 17 17 #include "tesselation.hpp" 18 18 #include "tesselation_insideoutsideunittest.hpp" 19 #include "verbose.hpp" 19 20 20 21 #ifdef HAVE_TESTRUNNER -
src/unittests/vectorunittest.cpp
r06f4ef6 rb6da28 15 15 #include "defs.hpp" 16 16 #include "log.hpp" 17 #include "memoryusageobserver.hpp"18 17 #include "vector.hpp" 19 18 #include "vector_ops.hpp" … … 21 20 #include "Plane.hpp" 22 21 #include "Exceptions/LinearDependenceException.hpp" 22 #include "Matrix.hpp" 23 23 24 24 #ifdef HAVE_TESTRUNNER … … 214 214 CPPUNIT_ASSERT(testVector.ScalarProduct(three) < MYEPSILON); 215 215 } 216 217 218 /**219 * UnitTest for Vector::IsInParallelepiped().220 */221 void VectorTest::IsInParallelepipedTest()222 {223 double parallelepiped[NDIM*NDIM];224 parallelepiped[0] = 1;225 parallelepiped[1] = 0;226 parallelepiped[2] = 0;227 parallelepiped[3] = 0;228 parallelepiped[4] = 1;229 parallelepiped[5] = 0;230 parallelepiped[6] = 0;231 parallelepiped[7] = 0;232 parallelepiped[8] = 1;233 234 fixture = zero;235 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );236 fixture = Vector(2.5,2.5,2.5);237 CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );238 fixture = Vector(1.,1.,1.);239 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );240 fixture = Vector(3.5,3.5,3.5);241 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );242 fixture = Vector(2.,2.,2.);243 CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );244 fixture = Vector(2.,3.,2.);245 CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );246 fixture = Vector(-2.,2.,-1.);247 CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );248 }249 -
src/unittests/vectorunittest.hpp
r06f4ef6 rb6da28 27 27 CPPUNIT_TEST ( ProjectionTest ); 28 28 CPPUNIT_TEST ( NormalsTest ); 29 CPPUNIT_TEST ( IsInParallelepipedTest );30 29 CPPUNIT_TEST_SUITE_END(); 31 30 … … 45 44 void LineIntersectionTest(); 46 45 void VectorRotationTest(); 47 void IsInParallelepipedTest();48 46 49 47 private: -
src/valence.db
r06f4ef6 rb6da28 1 #atomicnumber numberofvalenceorbitals 1 2 1 0.10000000000000E+01 2 3 2 0.20000000000000E+01 -
src/vector.cpp
r06f4ef6 rb6da28 8 8 9 9 #include "vector.hpp" 10 #include "VectorContent.hpp" 10 11 #include "verbose.hpp" 11 12 #include "World.hpp" 12 13 #include "Helpers/Assert.hpp" 13 14 #include "Helpers/fast_functions.hpp" 15 #include "Exceptions/MathException.hpp" 14 16 15 17 #include <iostream> 18 #include <gsl/gsl_blas.h> 19 16 20 17 21 using namespace std; … … 24 28 Vector::Vector() 25 29 { 26 content = gsl_vector_calloc (NDIM);30 content = new VectorContent(); 27 31 }; 28 32 … … 33 37 Vector::Vector(const Vector& src) 34 38 { 35 content = gsl_vector_alloc(NDIM); 36 gsl_vector_set(content,0,src[0]); 37 gsl_vector_set(content,1,src[1]); 38 gsl_vector_set(content,2,src[2]); 39 content = new VectorContent(); 40 gsl_vector_memcpy(content->content, src.content->content); 39 41 } 40 42 … … 43 45 Vector::Vector(const double x1, const double x2, const double x3) 44 46 { 45 content = gsl_vector_alloc(NDIM); 46 gsl_vector_set(content,0,x1); 47 gsl_vector_set(content,1,x2); 48 gsl_vector_set(content,2,x3); 49 }; 47 content = new VectorContent(); 48 gsl_vector_set(content->content,0,x1); 49 gsl_vector_set(content->content,1,x2); 50 gsl_vector_set(content->content,2,x3); 51 }; 52 53 Vector::Vector(VectorContent *_content) : 54 content(_content) 55 {} 50 56 51 57 /** … … 55 61 // check for self assignment 56 62 if(&src!=this){ 57 gsl_vector_set(content,0,src[0]); 58 gsl_vector_set(content,1,src[1]); 59 gsl_vector_set(content,2,src[2]); 63 gsl_vector_memcpy(content->content, src.content->content); 60 64 } 61 65 return *this; … … 65 69 */ 66 70 Vector::~Vector() { 67 gsl_vector_free(content);71 delete content; 68 72 }; 69 73 … … 94 98 } 95 99 96 /** Calculates distance between this and another vector in a periodic cell.97 * \param *y array to second vector98 * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell99 * \return \f$| x - y |\f$100 */101 double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const102 {103 double res = distance(y), tmp, matrix[NDIM*NDIM];104 Vector Shiftedy, TranslationVector;105 int N[NDIM];106 matrix[0] = cell_size[0];107 matrix[1] = cell_size[1];108 matrix[2] = cell_size[3];109 matrix[3] = cell_size[1];110 matrix[4] = cell_size[2];111 matrix[5] = cell_size[4];112 matrix[6] = cell_size[3];113 matrix[7] = cell_size[4];114 matrix[8] = cell_size[5];115 // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells116 for (N[0]=-1;N[0]<=1;N[0]++)117 for (N[1]=-1;N[1]<=1;N[1]++)118 for (N[2]=-1;N[2]<=1;N[2]++) {119 // create the translation vector120 TranslationVector.Zero();121 for (int i=NDIM;i--;)122 TranslationVector[i] = (double)N[i];123 TranslationVector.MatrixMultiplication(matrix);124 // add onto the original vector to compare with125 Shiftedy = y + TranslationVector;126 // get distance and compare with minimum so far127 tmp = distance(Shiftedy);128 if (tmp < res) res = tmp;129 }130 return (res);131 };132 133 /** Calculates distance between this and another vector in a periodic cell.134 * \param *y array to second vector135 * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell136 * \return \f$| x - y |^2\f$137 */138 double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const139 {140 double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];141 Vector Shiftedy, TranslationVector;142 int N[NDIM];143 matrix[0] = cell_size[0];144 matrix[1] = cell_size[1];145 matrix[2] = cell_size[3];146 matrix[3] = cell_size[1];147 matrix[4] = cell_size[2];148 matrix[5] = cell_size[4];149 matrix[6] = cell_size[3];150 matrix[7] = cell_size[4];151 matrix[8] = cell_size[5];152 // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells153 for (N[0]=-1;N[0]<=1;N[0]++)154 for (N[1]=-1;N[1]<=1;N[1]++)155 for (N[2]=-1;N[2]<=1;N[2]++) {156 // create the translation vector157 TranslationVector.Zero();158 for (int i=NDIM;i--;)159 TranslationVector[i] = (double)N[i];160 TranslationVector.MatrixMultiplication(matrix);161 // add onto the original vector to compare with162 Shiftedy = y + TranslationVector;163 // get distance and compare with minimum so far164 tmp = DistanceSquared(Shiftedy);165 if (tmp < res) res = tmp;166 }167 return (res);168 };169 170 /** Keeps the vector in a periodic cell, defined by the symmetric \a *matrix.171 * \param *out ofstream for debugging messages172 * Tries to translate a vector into each adjacent neighbouring cell.173 */174 void Vector::KeepPeriodic(const double * const matrix)175 {176 // int N[NDIM];177 // bool flag = false;178 //vector Shifted, TranslationVector;179 // Log() << Verbose(1) << "Begin of KeepPeriodic." << endl;180 // Log() << Verbose(2) << "Vector is: ";181 // Output(out);182 // Log() << Verbose(0) << endl;183 InverseMatrixMultiplication(matrix);184 for(int i=NDIM;i--;) { // correct periodically185 if (at(i) < 0) { // get every coefficient into the interval [0,1)186 at(i) += ceil(at(i));187 } else {188 at(i) -= floor(at(i));189 }190 }191 MatrixMultiplication(matrix);192 // Log() << Verbose(2) << "New corrected vector is: ";193 // Output(out);194 // Log() << Verbose(0) << endl;195 // Log() << Verbose(1) << "End of KeepPeriodic." << endl;196 };197 198 100 /** Calculates scalar product between this and another vector. 199 101 * \param *y array to second vector … … 203 105 { 204 106 double res = 0.; 205 for (int i=NDIM;i--;) 206 res += at(i)*y[i]; 107 gsl_blas_ddot(content->content, y.content->content, &res); 207 108 return (res); 208 109 }; … … 369 270 double& Vector::operator[](size_t i){ 370 271 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 371 return *gsl_vector_ptr (content , i);272 return *gsl_vector_ptr (content->content, i); 372 273 } 373 274 374 275 const double& Vector::operator[](size_t i) const{ 375 276 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 376 return *gsl_vector_ptr (content , i);277 return *gsl_vector_ptr (content->content, i); 377 278 } 378 279 … … 385 286 } 386 287 387 gsl_vector* Vector::get(){288 VectorContent* Vector::get(){ 388 289 return content; 389 290 } … … 504 405 }; 505 406 407 void Vector::ScaleAll(const Vector &factor){ 408 gsl_vector_mul(content->content, factor.content->content); 409 } 506 410 507 411 508 412 void Vector::Scale(const double factor) 509 413 { 510 for (int i=NDIM;i--;) 511 at(i) *= factor; 512 }; 513 514 /** Given a box by its matrix \a *M and its inverse *Minv the vector is made to point within that box. 515 * \param *M matrix of box 516 * \param *Minv inverse matrix 517 */ 518 void Vector::WrapPeriodically(const double * const M, const double * const Minv) 519 { 520 MatrixMultiplication(Minv); 521 // truncate to [0,1] for each axis 522 for (int i=0;i<NDIM;i++) { 523 //at(i) += 0.5; // set to center of box 524 while (at(i) >= 1.) 525 at(i) -= 1.; 526 while (at(i) < 0.) 527 at(i) += 1.; 528 } 529 MatrixMultiplication(M); 414 gsl_vector_scale(content->content,factor); 530 415 }; 531 416 … … 546 431 return make_pair(res,helper); 547 432 } 548 549 /** Do a matrix multiplication.550 * \param *matrix NDIM_NDIM array551 */552 void Vector::MatrixMultiplication(const double * const M)553 {554 Vector tmp;555 // do the matrix multiplication556 for(int i=NDIM;i--;)557 tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2);558 559 (*this) = tmp;560 };561 562 /** Do a matrix multiplication with the \a *A' inverse.563 * \param *matrix NDIM_NDIM array564 */565 bool Vector::InverseMatrixMultiplication(const double * const A)566 {567 double B[NDIM*NDIM];568 double detA = RDET3(A);569 double detAReci;570 571 // calculate the inverse B572 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular573 detAReci = 1./detA;574 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11575 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12576 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13577 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21578 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22579 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23580 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31581 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32582 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33583 584 MatrixMultiplication(B);585 586 return true;587 } else {588 return false;589 }590 };591 592 433 593 434 /** Creates this vector as the b y *factors' components scaled linear combination of the given three. … … 679 520 void Vector::AddVector(const Vector &y) 680 521 { 681 for(int i=NDIM;i--;) 682 at(i) += y[i]; 522 gsl_vector_add(content->content, y.content->content); 683 523 } 684 524 … … 688 528 void Vector::SubtractVector(const Vector &y) 689 529 { 690 for(int i=NDIM;i--;) 691 at(i) -= y[i]; 692 } 693 694 /** 695 * Checks whether this vector is within the parallelepiped defined by the given three vectors and 696 * their offset. 697 * 698 * @param offest for the origin of the parallelepiped 699 * @param three vectors forming the matrix that defines the shape of the parallelpiped 700 */ 701 bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const 702 { 703 Vector a = (*this)-offset; 704 a.InverseMatrixMultiplication(parallelepiped); 705 bool isInside = true; 706 707 for (int i=NDIM;i--;) 708 isInside = isInside && ((a[i] <= 1) && (a[i] >= 0)); 709 710 return isInside; 530 gsl_vector_sub(content->content, y.content->content); 711 531 } 712 532 -
src/vector.hpp
r06f4ef6 rb6da28 11 11 #endif 12 12 13 #include <iostream> 14 #include <gsl/gsl_vector.h> 15 #include <gsl/gsl_multimin.h> 13 #include <iosfwd> 16 14 17 15 #include <memory> … … 24 22 25 23 class Vector; 24 class Matrix; 25 struct VectorContent; 26 26 27 27 typedef std::vector<Vector> pointset; … … 31 31 */ 32 32 class Vector : public Space{ 33 friend Vector operator*(const Matrix&,const Vector&); 34 friend class Matrix; 33 35 public: 34 35 36 Vector(); 36 37 Vector(const double x1, const double x2, const double x3); … … 42 43 double DistanceSquared(const Vector &y) const; 43 44 double DistanceToSpace(const Space& space) const; 44 double PeriodicDistance(const Vector &y, const double * const cell_size) const;45 double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const;46 45 double ScalarProduct(const Vector &y) const; 47 46 double Angle(const Vector &y) const; … … 58 57 Vector Projection(const Vector &y) const; 59 58 void ScaleAll(const double *factor); 59 void ScaleAll(const Vector &factor); 60 60 void Scale(const double factor); 61 void MatrixMultiplication(const double * const M);62 bool InverseMatrixMultiplication(const double * const M);63 void KeepPeriodic(const double * const matrix);64 61 bool GetOneNormalVector(const Vector &x1); 65 62 bool MakeNormalTo(const Vector &y1); 66 bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const;67 void WrapPeriodically(const double * const M, const double * const Minv);68 63 std::pair<Vector,Vector> partition(const Vector&) const; 69 64 std::pair<pointset,Vector> partition(const pointset&) const; … … 79 74 80 75 // Access to internal structure 81 gsl_vector* get();76 VectorContent* get(); 82 77 83 78 // Methods that are derived directly from other methods … … 104 99 105 100 private: 106 gsl_vector *content; 101 Vector(VectorContent *); 102 VectorContent *content; 107 103 108 104 }; -
src/vector_ops.cpp
r06f4ef6 rb6da28 23 23 #include <gsl/gsl_permutation.h> 24 24 #include <gsl/gsl_vector.h> 25 #include <gsl/gsl_multimin.h> 25 26 26 27 /** -
src/verbose.cpp
r06f4ef6 rb6da28 5 5 #include "info.hpp" 6 6 #include "verbose.hpp" 7 #include <iostream> 7 8 8 9 /** Prints the tabs according to verbosity stored in the temporary constructed class. -
src/verbose.hpp
r06f4ef6 rb6da28 18 18 #endif 19 19 20 #include <ios tream>20 #include <iosfwd> 21 21 22 22 /************************************* Class Verbose & Binary *******************************/ -
tests/Tesselations/Makefile.am
r06f4ef6 rb6da28 1 TESTS = 1_2-dimethoxyethane.test \ 2 1_2-dimethylbenzene.test \ 3 2-methylcyclohexanone.test \ 4 benzene.test \ 5 cholesterol.test \ 6 cycloheptane.test \ 7 dimethyl_bromomalonate.test \ 8 glucose.test \ 9 heptan.test \ 10 isoleucine.test \ 11 neohexane.test \ 12 N_N-dimethylacetamide.test \ 13 proline.test \ 14 putrescine.test \ 15 tartaric_acid.test 1 TESTS = \ 2 1_2-dimethoxyethane.test \ 3 1_2-dimethylbenzene.test \ 4 2-methylcyclohexanone.test \ 5 benzene.test \ 6 cholesterol.test \ 7 cycloheptane.test \ 8 dimethyl_bromomalonate.test \ 9 glucose.test \ 10 isoleucine.test \ 11 neohexane.test \ 12 N_N-dimethylacetamide.test \ 13 proline.test \ 14 putrescine.test \ 15 tartaric_acid.test 16 17 # heptan.test -
tests/Tesselations/defs.in
r06f4ef6 rb6da28 54 54 #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME." 55 55 if [ -e $mol.dbond ]; then 56 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond - N 0 --sphere-radius$RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?56 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 57 57 else 58 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz - N 0 --sphere-radius$RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?58 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 59 59 fi 60 60 #echo "Molecuilder done with exitcode $exitcode." 61 cd ../.. 61 62 #cat stderr 62 63 #cat stdout 63 grep -E "^[0-9]* [0-9]* [0-9]*$" ../../../../../molecuilder/tests/Tesselations/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat64 grep -E "^[0-9]* [0-9]* [0-9]*$" $ {FILENAME}.dat | sort -n >new-triangles.dat65 diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$?64 grep -E "^[0-9]* [0-9]* [0-9]*$" @srcdir@/$mol/$2/${FILENAME}-$mol.dat | sort -n >$testdir/$RADIUS/reference-triangles.dat 65 grep -E "^[0-9]* [0-9]* [0-9]*$" $testdir/$RADIUS/${FILENAME}.dat | sort -n >$testdir/$RADIUS/new-triangles.dat 66 diff $testdir/$RADIUS/reference-triangles.dat $testdir/$RADIUS/new-triangles.dat 2>$testdir/$RADIUS/diffstderr >$testdir/$RADIUS/diffstdout || exitcode=$? 66 67 #echo "Diff done with exitcode $exitcode." 67 68 #cat diffstderr 68 69 #cat diffstdout 69 cd ../..70 70 test $exitcode = $expected_exitcode || exit 1 71 71 } -
tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat
r06f4ef6 rb6da28 1 1 TITLE = "3D CONVEX SHELL" 2 2 VARIABLES = "X" "Y" "Z" "U" 3 ZONE T=" heptan", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE4 -7.27e-07 -1.22006 0.930455 35 -7.27e-07 -1.22006 -0.849545 36 -1.2492 0.921941 0.930455 37 -1.2492 0.921941 -0.849545 38 1.2492 0.921941 -0.849545 39 1.2492 0.921941 0.930455 310 -2.4985 -1.22006 -0.849545 411 -2.4985 -1.22006 0.930455 412 2.4985 -1.22006 0.930455 413 2.4985 -1.22006 -0.849545 414 -4.6377 -0.336759 0.0404545 615 -3.7477 0.921941 0.930455 516 -3.7477 0.921941 -0.849545 517 4.6377 -0.336759 0.0404545 418 3.7477 0.921941 -0.849545 419 3.7477 0.921941 0.930455 420 -7.27e-07 -0.590759 0.0404545 621 -1.2492 0.292641 0.0404545 622 1.2492 0.292641 0.0404545 623 -2.4985 -0.590759 0.0404545 624 2.4985 -0.590759 0.0404545 625 -3.7477 0.292641 0.0404545 1226 3.7477 0.292641 0.0404545 123 ZONE T="none", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 18.7229 5 -7.27e-07 -1.22006 -0.849545 18.7229 6 -1.2492 0.921941 0.930455 18.7227 7 -1.2492 0.921941 -0.849545 18.7227 8 1.2492 0.921941 -0.849545 18.7222 9 1.2492 0.921941 0.930455 18.7222 10 -2.4985 -1.22006 -0.849545 19.9769 11 -2.4985 -1.22006 0.930455 19.9769 12 2.4985 -1.22006 0.930455 27.4727 13 2.4985 -1.22006 -0.849545 27.4727 14 -4.6377 -0.336759 0.0404545 21.541 15 -3.7477 0.921941 0.930455 18.8853 16 -3.7477 0.921941 -0.849545 18.8853 17 4.6377 -0.336759 0.0404545 10.6618 18 3.7477 0.921941 -0.849545 18.5406 19 3.7477 0.921941 0.930455 18.5406 20 -7.27e-07 -0.590759 0.0404545 23.0174 21 -1.2492 0.292641 0.0404545 23.0167 22 1.2492 0.292641 0.0404545 23.0172 23 -2.4985 -0.590759 0.0404545 21.8516 24 2.4985 -0.590759 0.0404545 16.0669 25 -3.7477 0.292641 0.0404545 39.5267 26 3.7477 0.292641 0.0404545 20.5497 27 27 28 28 14 15 23 … … 34 34 15 19 23 35 35 5 15 19 36 16 19 23 37 6 16 19 36 38 5 6 19 37 39 5 6 19 38 40 5 18 19 39 41 4 5 18 42 6 18 19 43 3 6 18 40 44 3 4 18 41 45 3 4 18 42 3 18 1943 3 6 1946 3 18 22 47 3 12 22 44 48 4 18 22 45 49 4 13 22 46 3 18 2247 3 12 2248 50 12 13 22 49 51 12 13 22 50 16 19 23 51 6 16 19 52 11 12 22 53 11 12 22 54 8 11 22 55 8 12 22 56 11 13 22 57 11 13 22 58 7 11 22 59 7 13 22 52 60 14 16 23 53 61 14 16 23 54 62 9 14 23 55 63 9 16 23 56 11 13 22 57 11 13 22 58 7 11 22 59 7 13 22 60 11 12 22 61 11 12 22 62 8 11 22 63 8 12 22 64 3 8 12 65 1 3 8 66 1 3 6 67 1 6 9 68 6 9 16 64 69 4 7 13 65 70 2 4 7 … … 67 72 2 5 10 68 73 5 10 15 69 3 8 1270 1 3 871 1 3 672 1 6 973 6 9 1674 74 10 14 21 75 75 9 10 21 76 76 9 10 21 77 77 9 14 21 78 9 17 21 79 1 9 17 80 1 2 17 81 1 2 17 78 82 10 17 21 79 83 2 10 17 80 1 2 1781 1 2 1782 1 17 2183 1 9 2184 2 17 2085 2 7 2086 84 1 17 20 87 85 1 8 20 88 86 7 8 20 89 87 7 8 20 88 8 11 20 90 89 7 11 20 91 8 11 20 90 2 17 20 91 2 7 20 -
tests/Tesselations/heptan/2.5/NonConvexEnvelope-heptan.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -7.27e-07 -1.22006 0.930455 -17.4952 5 -7.27e-07 -1.22006 -0.849545 -17.4952 6 -1.2492 0.921941 0.930455 -19.6818 7 -1.2492 0.921941 -0.849545 -15.323 8 1.2492 0.921941 -0.849545 -17.495 9 1.2492 0.921941 0.930455 -17.4951 10 -2.4985 -1.22006 -0.849545 -13.1263 11 -2.4985 -1.22006 0.930455 -10.8961 12 2.4985 -1.22006 0.930455 -13.1263 13 2.4985 -1.22006 -0.849545 -10.8961 14 -4.6377 -0.336759 0.0404545 -9.35471 15 -3.7477 0.921941 0.930455 -9.24444 16 -3.7477 0.921941 -0.849545 -11.4805 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 12 13 29 8 11 12 30 3 8 12 31 1 3 8 32 1 3 6 33 1 6 9 34 6 9 16 35 9 14 16 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 8 11 42 10 14 15 43 5 10 15 44 2 5 10 45 2 4 5 46 2 4 7 47 4 7 13 48 7 11 13 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/2/NonConvexEnvelope-heptan.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -7.27e-07 -1.22006 0.930455 -17.4952 5 -7.27e-07 -1.22006 -0.849545 -17.4952 6 -1.2492 0.921941 0.930455 -19.6818 7 -1.2492 0.921941 -0.849545 -15.323 8 1.2492 0.921941 -0.849545 -17.495 9 1.2492 0.921941 0.930455 -17.4951 10 -2.4985 -1.22006 -0.849545 -13.1263 11 -2.4985 -1.22006 0.930455 -10.8961 12 2.4985 -1.22006 0.930455 -13.1263 13 2.4985 -1.22006 -0.849545 -10.8961 14 -4.6377 -0.336759 0.0404545 -9.35471 15 -3.7477 0.921941 0.930455 -9.24444 16 -3.7477 0.921941 -0.849545 -11.4805 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 12 13 29 8 11 12 30 3 8 12 31 1 3 8 32 1 3 6 33 1 6 9 34 6 9 16 35 9 14 16 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 8 11 42 10 14 15 43 5 10 15 44 2 5 10 45 2 4 5 46 2 4 7 47 4 7 13 48 7 11 13 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/25/NonConvexEnvelope-heptan.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -7.27e-07 -1.22006 0.930455 -17.4952 5 -7.27e-07 -1.22006 -0.849545 -17.4952 6 -1.2492 0.921941 0.930455 -19.6818 7 -1.2492 0.921941 -0.849545 -15.323 8 1.2492 0.921941 -0.849545 -17.495 9 1.2492 0.921941 0.930455 -17.4951 10 -2.4985 -1.22006 -0.849545 -13.1263 11 -2.4985 -1.22006 0.930455 -10.8961 12 2.4985 -1.22006 0.930455 -13.1263 13 2.4985 -1.22006 -0.849545 -10.8961 14 -4.6377 -0.336759 0.0404545 -9.35471 15 -3.7477 0.921941 0.930455 -9.24444 16 -3.7477 0.921941 -0.849545 -11.4805 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 12 13 29 8 11 12 30 3 8 12 31 1 3 8 32 1 3 6 33 1 6 9 34 6 9 16 35 9 14 16 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 8 11 42 10 14 15 43 5 10 15 44 2 5 10 45 2 4 5 46 2 4 7 47 4 7 13 48 7 11 13 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/3.5/NonConvexEnvelope-heptan.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -7.27e-07 -1.22006 0.930455 -17.4952 5 -7.27e-07 -1.22006 -0.849545 -17.4952 6 -1.2492 0.921941 0.930455 -19.6818 7 -1.2492 0.921941 -0.849545 -15.323 8 1.2492 0.921941 -0.849545 -17.495 9 1.2492 0.921941 0.930455 -17.4951 10 -2.4985 -1.22006 -0.849545 -13.1263 11 -2.4985 -1.22006 0.930455 -10.8961 12 2.4985 -1.22006 0.930455 -13.1263 13 2.4985 -1.22006 -0.849545 -10.8961 14 -4.6377 -0.336759 0.0404545 -9.35471 15 -3.7477 0.921941 0.930455 -9.24444 16 -3.7477 0.921941 -0.849545 -11.4805 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 12 13 29 8 11 12 30 3 8 12 31 1 3 8 32 1 3 6 33 1 6 9 34 6 9 16 35 9 14 16 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 8 11 42 10 14 15 43 5 10 15 44 2 5 10 45 2 4 5 46 2 4 7 47 4 7 13 48 7 11 13 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/3/NonConvexEnvelope-heptan.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -7.27e-07 -1.22006 0.930455 -17.4952 5 -7.27e-07 -1.22006 -0.849545 -17.4952 6 -1.2492 0.921941 0.930455 -19.6818 7 -1.2492 0.921941 -0.849545 -15.323 8 1.2492 0.921941 -0.849545 -17.495 9 1.2492 0.921941 0.930455 -17.4951 10 -2.4985 -1.22006 -0.849545 -13.1263 11 -2.4985 -1.22006 0.930455 -10.8961 12 2.4985 -1.22006 0.930455 -13.1263 13 2.4985 -1.22006 -0.849545 -10.8961 14 -4.6377 -0.336759 0.0404545 -9.35471 15 -3.7477 0.921941 0.930455 -9.24444 16 -3.7477 0.921941 -0.849545 -11.4805 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 12 13 29 8 11 12 30 3 8 12 31 1 3 8 32 1 3 6 33 1 6 9 34 6 9 16 35 9 14 16 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 8 11 42 10 14 15 43 5 10 15 44 2 5 10 45 2 4 5 46 2 4 7 47 4 7 13 48 7 11 13 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/4/NonConvexEnvelope-heptan.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -7.27e-07 -1.22006 0.930455 -17.4952 5 -7.27e-07 -1.22006 -0.849545 -17.4952 6 -1.2492 0.921941 0.930455 -19.6818 7 -1.2492 0.921941 -0.849545 -15.323 8 1.2492 0.921941 -0.849545 -17.495 9 1.2492 0.921941 0.930455 -17.4951 10 -2.4985 -1.22006 -0.849545 -13.1263 11 -2.4985 -1.22006 0.930455 -10.8961 12 2.4985 -1.22006 0.930455 -13.1263 13 2.4985 -1.22006 -0.849545 -10.8961 14 -4.6377 -0.336759 0.0404545 -9.35471 15 -3.7477 0.921941 0.930455 -9.24444 16 -3.7477 0.921941 -0.849545 -11.4805 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 12 13 29 8 11 12 30 3 8 12 31 1 3 8 32 1 3 6 33 1 6 9 34 6 9 16 35 9 14 16 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 8 11 42 10 14 15 43 5 10 15 44 2 5 10 45 2 4 5 46 2 4 7 47 4 7 13 48 7 11 13 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/regression/Domain/2/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0# here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0# here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states57 MaxPsiDouble 1 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 1 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Domain/3/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0# here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0# here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states57 MaxPsiDouble 1 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 1 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Domain/4/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 47 47 BoxLength # (Length of a unit cell) 48 48 1 49 0 049 0 1 50 50 0 0 2 51 51 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0# here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0# here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states57 MaxPsiDouble 1 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 1 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Domain/5/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0 # check every ..th steps37 MaxMinStopStep 10 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0 # check every ..th steps44 InitMaxMinStopStep 10 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0 # here: specifying maximum number of SpinDown-states57 MaxPsiDouble 10 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 10 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 10 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Filling/1/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0 # check every ..th steps37 MaxMinStopStep 680 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0 # check every ..th steps44 InitMaxMinStopStep 680 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0 # here: specifying maximum number of SpinDown-states57 MaxPsiDouble 680 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 680 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 680 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Filling/1/pre/test.conf
r06f4ef6 rb6da28 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 72 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 73 Ion_Type 2_1 9.782085945 3.275186040 3.5358860370 # molecule nr 074 Ion_Type 2_2 8.532785963 4.158586027 3.5358860370 # molecule nr 175 Ion_Type 2_3 7.283585982 3.2751860403.535886037 0 # molecule nr 276 Ion_Type1_ 1 9.782085945 2.6458860502.645886050 0 # molecule nr 377 Ion_Type1_ 2 9.782085945 2.6458860504.425886024 0 # molecule nr 478 Ion_Type1_ 3 10.672039608 3.9045368783.535886037 0 # molecule nr 579 Ion_Type1_ 4 8.532785963 4.7878860182.645886050 0 # molecule nr 680 Ion_Type1_ 5 8.532785963 4.7878860184.425886024 0 # molecule nr 781 Ion_Type 1_6 6.393632318 3.9045368773.535886037 0 # molecule nr 882 Ion_Type 1_7 7.283585982 2.645886050 2.6458860500 # molecule nr 983 Ion_Type 1_8 7.283585982 2.645886050 4.4258860240 # molecule nr 1073 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 74 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 75 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 76 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 77 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 78 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 79 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 80 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 81 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 82 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 83 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 -
tests/regression/Molecules/6/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0 # check every ..th steps37 MaxMinStopStep 10 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0 # check every ..th steps44 InitMaxMinStopStep 10 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0 # here: specifying maximum number of SpinDown-states57 MaxPsiDouble 10 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 10 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 10 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Molecules/6/pre/test.conf
r06f4ef6 rb6da28 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 72 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 73 Ion_Type 2_1 9.782085945 3.275186040 3.5358860370 # molecule nr 074 Ion_Type 2_2 8.532785963 4.158586027 3.5358860370 # molecule nr 175 Ion_Type 2_3 7.283585982 3.2751860403.535886037 0 # molecule nr 276 Ion_Type1_ 1 9.782085945 2.6458860502.645886050 0 # molecule nr 377 Ion_Type1_ 2 9.782085945 2.6458860504.425886024 0 # molecule nr 478 Ion_Type1_ 3 10.672039608 3.9045368783.535886037 0 # molecule nr 579 Ion_Type1_ 4 8.532785963 4.7878860182.645886050 0 # molecule nr 680 Ion_Type1_ 5 8.532785963 4.7878860184.425886024 0 # molecule nr 781 Ion_Type 1_6 6.393632318 3.9045368773.535886037 0 # molecule nr 882 Ion_Type 1_7 7.283585982 2.645886050 2.6458860500 # molecule nr 983 Ion_Type 1_8 7.283585982 2.645886050 4.4258860240 # molecule nr 1073 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 74 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 75 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 76 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 77 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 78 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 79 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 80 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 81 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 82 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 83 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 -
tests/regression/Molecules/7/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0 # check every ..th steps37 MaxMinStopStep 10 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0 # check every ..th steps44 InitMaxMinStopStep 10 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0 # here: specifying maximum number of SpinDown-states57 MaxPsiDouble 10 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 10 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 10 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Molecules/7/pre/test.conf
r06f4ef6 rb6da28 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 72 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 73 Ion_Type 2_1 9.782085945 3.275186040 3.5358860370 # molecule nr 074 Ion_Type 2_2 8.532785963 4.158586027 3.5358860370 # molecule nr 175 Ion_Type 2_3 7.283585982 3.2751860403.535886037 0 # molecule nr 276 Ion_Type1_ 1 9.782085945 2.6458860502.645886050 0 # molecule nr 377 Ion_Type1_ 2 9.782085945 2.6458860504.425886024 0 # molecule nr 478 Ion_Type1_ 3 10.672039608 3.9045368783.535886037 0 # molecule nr 579 Ion_Type1_ 4 8.532785963 4.7878860182.645886050 0 # molecule nr 680 Ion_Type1_ 5 8.532785963 4.7878860184.425886024 0 # molecule nr 781 Ion_Type 1_6 6.393632318 3.9045368773.535886037 0 # molecule nr 882 Ion_Type 1_7 7.283585982 2.645886050 2.6458860500 # molecule nr 983 Ion_Type 1_8 7.283585982 2.645886050 4.4258860240 # molecule nr 1073 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 74 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 75 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 76 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 77 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 78 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 79 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 80 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 81 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 82 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 83 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 -
tests/regression/Simple_configuration/2/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 0 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 0 # check every ..th steps 46 46 … … 54 54 Level0Factor 2 # factor by which node number increases from S to 0 level 55 55 RiemannTensor 0 # (Use metric) 56 PsiType 0# 0 - doubly occupied, 1 - SpinUp,SpinDown56 PsiType 1 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states 58 58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Simple_configuration/3/post/test.conf
r06f4ef6 rb6da28 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 0 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 0 # check every ..th steps 46 46 … … 54 54 Level0Factor 2 # factor by which node number increases from S to 0 level 55 55 RiemannTensor 0 # (Use metric) 56 PsiType 0# 0 - doubly occupied, 1 - SpinUp,SpinDown56 PsiType 1 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states 58 58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Tesselation/1/post/NonConvexEnvelope.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 9.78209 2.64589 2.64589 05 9.78209 2.64589 4.42589 06 10.672 3.90454 3.53589 07 8.53279 4.78789 2.64589 08 8.53279 4.78789 4.42589 09 6.39363 3.90454 3.53589 010 7.28359 2.64589 2.64589 011 7.28359 2.64589 4.42589 04 9.78209 2.64589 2.64589 -9.24443 5 9.78209 2.64589 4.42589 -11.4804 6 10.672 3.90454 3.53589 -9.35464 7 8.53279 4.78789 2.64589 -9.11459 8 8.53279 4.78789 4.42589 -9.11459 9 6.39363 3.90454 3.53589 -9.35431 10 7.28359 2.64589 2.64589 -11.4803 11 7.28359 2.64589 4.42589 -9.24433 12 12 13 13 1 3 4 -
tests/regression/Tesselation/2/post/ConvexEnvelope.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 9.78209 2.64589 2.64589 05 9.78209 2.64589 4.42589 06 10.672 3.90454 3.53589 07 8.53279 4.78789 2.64589 08 8.53279 4.78789 4.42589 09 6.39363 3.90454 3.53589 010 7.28359 2.64589 2.64589 011 7.28359 2.64589 4.42589 04 9.78209 2.64589 2.64589 -9.24443 5 9.78209 2.64589 4.42589 -11.4804 6 10.672 3.90454 3.53589 -9.35464 7 8.53279 4.78789 2.64589 -9.11459 8 8.53279 4.78789 4.42589 -9.11459 9 6.39363 3.90454 3.53589 -9.35431 10 7.28359 2.64589 2.64589 -11.4803 11 7.28359 2.64589 4.42589 -9.24433 12 12 13 13 1 3 4 -
tests/regression/Tesselation/2/post/NonConvexEnvelope.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 9.78209 2.64589 2.64589 05 9.78209 2.64589 4.42589 06 10.672 3.90454 3.53589 07 8.53279 4.78789 2.64589 08 8.53279 4.78789 4.42589 09 6.39363 3.90454 3.53589 010 7.28359 2.64589 2.64589 011 7.28359 2.64589 4.42589 04 9.78209 2.64589 2.64589 -9.24443 5 9.78209 2.64589 4.42589 -11.4804 6 10.672 3.90454 3.53589 -9.35464 7 8.53279 4.78789 2.64589 -9.11459 8 8.53279 4.78789 4.42589 -9.11459 9 6.39363 3.90454 3.53589 -9.35431 10 7.28359 2.64589 2.64589 -11.4803 11 7.28359 2.64589 4.42589 -9.24433 12 12 13 13 1 3 4 -
tests/regression/Tesselation/3/post/NonConvexEnvelope.dat
r06f4ef6 rb6da28 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 0.3612 -3.628 1.323 1 5 0. 4884 -3.5983 -0.4521 36 1.4985 -2.5112 0.5308 4 7 -1.9534 -3.5752 0.5362 2 8 -1. 1883 -0.199 1.5176 39 - 0.7165 -1.6046 2.5129 110 1.7627 -1.4479 -0.8349411 -1.003 -1.3584 -2.8848 2 12 0.0217 -2.6629 -2.2008 1 13 -2.8885 -1.5706 1.7543 2 14 -2. 0579 -3.6765 -1.7622 015 -2. 9259 -2.1146 -1.7672 116 1.0353 0.1785 2.542317 1. 6325 -1.3323 1.8306 218 0.7271 1.177 0.3594 3 19 1.3374 -0.2942 -2.961220 0.6036 1.0859 -2.1126 3 21 -3.2034 -0.5041 -1.0881 3 22 - 5.1809 -1.8679 0.9687 123 - 4.6025 -2.4721 -0.6025 224 -4. 3385 -3.4329 0.8725 025 3.191 1.3217 -2.8354 1 26 -4.0905 0.6312 1.6028 3 27 2.8131 1.4776 2.5103 0 28 3.9137 2.2936 1.3739 0 29 2.159 2.5738 1.2698 5 30 3.6606 -0.4593 2.1396 2 31 3. 2007 -1.4419 0.7311432 -3.3002 2.3589 0.0094 8 33 - 4.377 1.6962 -1.2433 334 5.2593 1.4547 -1.7445 0 35 4.6863 2.7674 -0.6775 0 36 5.746 -0.9031 1.204 0 37 5. 1212 -0.8867 -0.4582438 -5.2641 2.8314 1.4476 0 39 5.2727 1.6068 1.2828 2 40 -6.2394 4.6427 0.0632 0 41 - 4.4738 4.5591 -0.1458 342 - 5.5506 3.8964 -1.3985 043 - 6.7081 0.9923 0.6224 244 - 7.5442 2.5597 0.5118 045 - 6.8554 1.8134 -0.9499 146 7.1391 2.0447 0.0264 0 47 6.9077 1.1106 0.1214 1 4 6.9077 1.1106 0.1214 -6.99715 5 0.3612 -3.628 1.323 6.00416 6 0.4884 -3.5983 -0.4521 11.8428 7 1.4985 -2.5112 0.5308 6.07951 8 -1.9534 -3.5752 0.5362 -4.26914 9 -1.1883 -0.199 1.5176 14.2992 10 -0.7165 -1.6046 2.5129 6.2134 11 1.7627 -1.4479 -0.8349 7.15053 12 -1.003 -1.3584 -2.8848 32.043 13 0.0217 -2.6629 -2.2008 16.8009 14 -2.8885 -1.5706 1.7543 -1.77076 15 -2.0579 -3.6765 -1.7622 -7.05319 16 -2.9259 -2.1146 -1.7672 33.6663 17 1.0353 0.1785 2.542 48.8869 18 1.6325 -1.3323 1.8306 1.44108 19 0.7271 1.177 0.3594 27.9872 20 1.3374 -0.2942 -2.961 13.6459 21 0.6036 1.0859 -2.1126 98.521 22 -3.2034 -0.5041 -1.0881 8.44805 23 -5.1809 -1.8679 0.9687 -6.07448 24 -4.6025 -2.4721 -0.6025 -6.52057 25 -4.3385 -3.4329 0.8725 -4.12716 26 3.191 1.3217 -2.8354 -10.5968 27 -4.0905 0.6312 1.6028 21.8745 28 2.8131 1.4776 2.5103 -0.774194 29 3.9137 2.2936 1.3739 -2.51806 30 2.159 2.5738 1.2698 151.494 31 3.6606 -0.4593 2.1396 2.60004 32 3.2007 -1.4419 0.7311 2.29272 33 -3.3002 2.3589 0.0094 461.065 34 -4.377 1.6962 -1.2433 43.4649 35 5.2593 1.4547 -1.7445 -6.26082 36 4.6863 2.7674 -0.6775 -8.55931 37 5.746 -0.9031 1.204 -1.29544 38 5.1212 -0.8867 -0.4582 31.5177 39 -5.2641 2.8314 1.4476 21.5516 40 5.2727 1.6068 1.2828 -2.57271 41 -6.2394 4.6427 0.0632 -9.24392 42 -4.4738 4.5591 -0.1458 62.5211 43 -5.5506 3.8964 -1.3985 -10.3613 44 -6.7081 0.9923 0.6224 -7.08885 45 -7.5442 2.5597 0.5118 -11.4252 46 -6.8554 1.8134 -0.9499 3.80444 47 7.1391 2.0447 0.0264 -7.88713 48 48 49 31 434450 31 34 44 51 33 34 44 52 2 2 31 3453 1 6 22 3454 7 16 34 55 7 9 16 56 2 7 9 57 2 7 34 58 2 3 34 59 3 28 34 60 2 8 33 3461 1 2 3 62 1 3 28 63 1 14 28 64 1 4 27 2865 2 7 28 3366 1 6 14 67 6 13 14 68 1 3 14 2769 1 3 24 2770 2 4 27 3671 2 7 33 3672 33 36 44 73 36 434474 2 4 25 3675 2 4 25 2676 2 5 26 3277 2 5 32 4378 2 5 36 4379 1 3 24 2680 1 3 26 2981 5 13 29 82 5 23 29 83 2 3 29 3584 29 35 38 85 2 6 29 3886 2 6 29 3887 1 5 26 2988 1 5 17 2989 1 5 17 2690 1 7 26 3291 1 7 22 3292 5 6 23 93 5 6 13 94 6 10 23 95 1 0 19 2396 19 23 40 97 2 3 35 4098 3 5 40 4199 1 0 19 21100 4 10 21 101 4 6 10 102 1 4 6 103 3 5 37 38104 3 5 37 41105 1 7 29 30106 29 30 38 107 3 0 38 39108 8 17 30 109 8 16 17 110 1 6 17 22111 8 18 30 112 8 12 18 113 1 2 18 30114 1 2 20 30115 2 0 30 42116 3 0 39 42117 8 11 12 118 8 9 11 119 8 9 16 120 1 1 12 20121 1 1 20 21122 4 11 21 123 2 4 11 124 1 2 4 125 2 9 11 126 19 20 21 127 19 20 40 128 2 0 40 42129 4 0 41 42130 2 2 31 32131 3 1 32 43132 39 41 42 133 3 7 39 41134 3 7 38 3949 1 32 44 50 1 32 35 51 1 34 35 52 23 32 35 53 17 23 35 54 8 17 35 55 8 10 17 56 3 8 10 57 3 8 35 58 3 4 35 59 4 29 35 60 29 34 35 61 2 3 4 62 2 4 29 63 2 15 29 64 15 28 29 65 28 29 34 66 2 7 15 67 7 14 15 68 14 15 28 69 14 25 28 70 25 28 37 71 28 34 37 72 1 34 37 73 1 37 44 74 25 26 37 75 25 26 27 76 26 27 33 77 26 33 44 78 26 37 44 79 14 25 27 80 14 27 30 81 6 14 30 82 6 24 30 83 24 30 36 84 30 36 39 85 27 30 39 86 27 30 39 87 16 27 30 88 16 18 30 89 16 18 27 90 18 27 33 91 18 23 33 92 6 7 24 93 6 7 14 94 7 11 24 95 11 20 24 96 20 24 41 97 24 36 41 98 36 41 42 99 11 20 22 100 5 11 22 101 5 7 11 102 2 5 7 103 36 38 39 104 36 38 42 105 18 30 31 106 30 31 39 107 31 39 40 108 9 18 31 109 9 17 18 110 17 18 23 111 9 19 31 112 9 13 19 113 13 19 31 114 13 21 31 115 21 31 43 116 31 40 43 117 9 12 13 118 9 10 12 119 9 10 17 120 12 13 21 121 12 21 22 122 5 12 22 123 3 5 12 124 2 3 5 125 3 10 12 126 20 21 22 127 20 21 41 128 21 41 43 129 41 42 43 130 23 32 33 131 32 33 44 132 40 42 43 133 38 40 42 134 38 39 40 -
tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d
r06f4ef6 rb6da28 3 3 # All atoms as spheres 4 4 2 5 0.939662 -3.01666 0.414493 0.1 1. 1. 1. 6 2 7 -0.152738 -1.94716 0.354093 0.1 1. 1. 1. 8 2 9 0.0659622 -1.03376 -0.880907 0.1 1. 1. 1. 10 2 11 -1.50434 -2.59696 0.0723932 0.1 1. 1. 1. 12 2 13 -0.0717378 -1.05346 1.57779 0.1 1. 1. 1. 14 2 15 1.52186 -0.603155 -0.873807 0.1 1. 1. 1. 16 2 17 -0.346038 -1.95996 -2.03011 0.1 1. 1. 1. 18 2 19 -2.63434 -1.74086 0.647893 0.1 1. 1. 1. 20 2 21 -1.61364 -2.66266 -1.47131 0.1 1. 1. 1. 22 2 23 1.36626 -0.519255 1.65039 0.1 1. 1. 1. 24 2 25 1.74646 0.246745 0.389693 0.1 1. 1. 1. 26 2 27 1.78606 0.287745 -2.09451 0.1 1. 1. 1. 28 2 29 -2.65324 -0.381955 -0.0548068 0.1 1. 1. 1. 30 2 31 -3.97304 -2.44796 0.426993 0.1 1. 1. 1. 32 2 33 3.21726 0.635145 0.478793 0.1 1. 1. 1. 34 2 35 3.13516 0.931145 -1.97401 0.1 1. 1. 1. 36 2 37 -3.80794 0.459345 0.492693 0.1 1. 1. 1. 38 2 39 3.34736 1.81094 1.44919 0.1 1. 1. 1. 40 2 41 3.76986 1.05884 -0.855107 0.1 1. 1. 1. 42 2 43 4.05806 -0.522555 1.01199 0.1 1. 1. 1. 44 2 45 -3.82684 1.81824 -0.210007 0.1 1. 1. 1. 46 2 47 5.16496 1.66244 -0.848507 0.1 1. 1. 1. 48 2 49 5.48576 -0.422855 0.476393 0.1 1. 1. 1. 50 2 51 -4.98154 2.65954 0.337493 0.1 1. 1. 1. 52 2 53 5.91796 1.03174 0.331693 0.1 1. 1. 1. 54 2 55 -5.00044 4.01854 -0.365207 0.1 1. 1. 1. 56 2 57 -6.30524 1.93554 0.0833932 0.1 1. 1. 1. 58 2 59 7.32406 1.08574 0.0829932 0.1 1. 1. 1. 60 2 5 61 0.777562 -3.65286 1.28459 0.1 1. 1. 1. 6 62 2 … … 94 150 2 95 151 7.55546 2.01984 -0.0120068 0.1 1. 1. 1. 96 297 0.939662 -3.01666 0.414493 0.1 1. 1. 1.98 299 -0.152738 -1.94716 0.354093 0.1 1. 1. 1.100 2101 0.0659622 -1.03376 -0.880907 0.1 1. 1. 1.102 2103 -1.50434 -2.59696 0.0723932 0.1 1. 1. 1.104 2105 -0.0717378 -1.05346 1.57779 0.1 1. 1. 1.106 2107 1.52186 -0.603155 -0.873807 0.1 1. 1. 1.108 2109 -0.346038 -1.95996 -2.03011 0.1 1. 1. 1.110 2111 -2.63434 -1.74086 0.647893 0.1 1. 1. 1.112 2113 -1.61364 -2.66266 -1.47131 0.1 1. 1. 1.114 2115 1.36626 -0.519255 1.65039 0.1 1. 1. 1.116 2117 1.74646 0.246745 0.389693 0.1 1. 1. 1.118 2119 1.78606 0.287745 -2.09451 0.1 1. 1. 1.120 2121 -2.65324 -0.381955 -0.0548068 0.1 1. 1. 1.122 2123 -3.97304 -2.44796 0.426993 0.1 1. 1. 1.124 2125 3.21726 0.635145 0.478793 0.1 1. 1. 1.126 2127 3.13516 0.931145 -1.97401 0.1 1. 1. 1.128 2129 -3.80794 0.459345 0.492693 0.1 1. 1. 1.130 2131 3.34736 1.81094 1.44919 0.1 1. 1. 1.132 2133 3.76986 1.05884 -0.855107 0.1 1. 1. 1.134 2135 4.05806 -0.522555 1.01199 0.1 1. 1. 1.136 2137 -3.82684 1.81824 -0.210007 0.1 1. 1. 1.138 2139 5.16496 1.66244 -0.848507 0.1 1. 1. 1.140 2141 5.48576 -0.422855 0.476393 0.1 1. 1. 1.142 2143 -4.98154 2.65954 0.337493 0.1 1. 1. 1.144 2145 5.91796 1.03174 0.331693 0.1 1. 1. 1.146 2147 -5.00044 4.01854 -0.365207 0.1 1. 1. 1.148 2149 -6.30524 1.93554 0.0833932 0.1 1. 1. 1.150 2151 7.32406 1.08574 0.0829932 0.1 1. 1. 1.152 152 # All tesselation triangles 153 153 8 … … 156 156 BACKFACE 0.3 0.3 1.0 0 0 157 157 1 158 5.67566 1.42984 -1.78291 7.55546 2.01984 -0.0120068 7.32406 1.08574 0.08299321. 0. 0.159 1 160 5.67566 1.42984 -1.78291 5.53756 -0.911555 -0.496607 7.32406 1.08574 0.08299321. 0. 0.161 1 162 6.16236 -0.927955 1.16559 5.53756 -0.911555 -0.496607 7.32406 1.08574 0.08299321. 0. 0.158 7.32406 1.08574 0.0829932 5.67566 1.42984 -1.78291 7.55546 2.01984 -0.0120068 1. 0. 0. 159 1 160 7.32406 1.08574 0.0829932 5.67566 1.42984 -1.78291 5.53756 -0.911555 -0.496607 1. 0. 0. 161 1 162 7.32406 1.08574 0.0829932 6.16236 -0.927955 1.16559 5.53756 -0.911555 -0.496607 1. 0. 0. 163 163 1 164 164 3.60736 1.29684 -2.87381 5.67566 1.42984 -1.78291 5.53756 -0.911555 -0.496607 1. 0. 0. … … 202 202 4.07696 -0.484155 2.10119 6.16236 -0.927955 1.16559 5.68906 1.58194 1.24439 1. 0. 0. 203 203 1 204 6.16236 -0.927955 1.16559 5.68906 1.58194 1.24439 7.32406 1.08574 0.08299321. 0. 0.205 1 206 5.68906 1.58194 1.24439 7.55546 2.01984 -0.0120068 7.32406 1.08574 0.08299321. 0. 0.204 7.32406 1.08574 0.0829932 6.16236 -0.927955 1.16559 5.68906 1.58194 1.24439 1. 0. 0. 205 1 206 7.32406 1.08574 0.0829932 5.68906 1.58194 1.24439 7.55546 2.01984 -0.0120068 1. 0. 0. 207 207 1 208 208 3.22946 1.45274 2.47189 4.33006 2.26874 1.33549 5.68906 1.58194 1.24439 1. 0. 0. -
tests/regression/testsuite-analysis.at
r06f4ef6 rb6da28 4 4 AT_KEYWORDS([analysis]) 5 5 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/pre/test.conf .], 0) 6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E--elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr]) 7 7 AT_CHECK([fgrep "Begin of PairCorrelation" stdout], 0, [ignore], [ignore]) 8 8 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/post/$file], 0, [ignore], [ignore]) … … 14 14 AT_KEYWORDS([analysis]) 15 15 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/pre/test.conf .], 0) 16 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E--elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr]) 17 17 #AT_CHECK([file=output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 18 18 AT_CHECK([file=bin_output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 19 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E--elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])19 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr]) 20 20 #AT_CHECK([file=output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 21 21 AT_CHECK([file=bin_output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 22 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E--elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])22 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr]) 23 23 #AT_CHECK([file=output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 24 24 AT_CHECK([file=bin_output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) … … 29 29 AT_KEYWORDS([analysis]) 30 30 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/pre/test.conf .], 0) 31 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 7 -C P --elements 1 --position 10. 10. 10.--output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])31 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 --select-all-molecules --point-correlation --elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr]) 32 32 AT_CHECK([fgrep "Begin of CorrelationToPoint" stdout], 0, [ignore], [ignore]) 33 33 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/post/$file], 0, [ignore], [ignore]) … … 39 39 AT_KEYWORDS([analysis]) 40 40 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/pre/test.conf .], 0) 41 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -I -C S --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 208], 0, [stdout], [stderr])41 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I --select-all-molecules --unselect-molecule-by-id 207 --surface-correlation --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 207], 0, [stdout], [stderr]) 42 42 AT_CHECK([fgrep "Begin of CorrelationToSurface" stdout], 0, [ignore], [ignore]) 43 43 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/post/$file], 0, [ignore], [ignore]) … … 49 49 #AT_KEYWORDS([analysis]) 50 50 #AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/5/pre/test.conf .], 0) 51 #AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -m 0], 0, [stdout], [stderr])51 #AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -m 0], 0, [stdout], [stderr]) 52 52 #AT_CHECK([fgrep "eigenvalue = 4382.53," stdout], 0, [ignore], [ignore]) 53 53 #AT_CHECK([fgrep "eigenvalue = 4369.24," stdout], 0, [ignore], [ignore]) -
tests/regression/testsuite-domain.at
r06f4ef6 rb6da28 3 3 AT_SETUP([Domain - defining simulation domain]) 4 4 AT_KEYWORDS([domain]) 5 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -B 10 0 10 0 0 10], 0, [stdout], [stderr])5 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o pcp -B "10, 0, 10, 0, 0, 10"], 0, [stdout], [stderr]) 6 6 AT_CHECK([fgrep "BoxLength" test.conf], 0, [stdout], [stderr]) 7 7 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/1/post/test.conf], 0, [stdout], [stderr]) … … 12 12 AT_KEYWORDS([domain]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/2/pre/test.conf .], 0) 14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b 15 0 15 0 0 15], 0, [stdout], [stderr])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b "15, 0, 15, 0, 0, 15"], 0, [stdout], [stderr]) 15 15 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/2/post/test.conf], 0, [stdout], [stderr]) 16 16 AT_CLEANUP … … 20 20 AT_KEYWORDS([domain]) 21 21 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/3/pre/test.conf .], 0) 22 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c 5 10 15], 0, [stdout], [stderr])22 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -c "5, 10, 15"], 0, [stdout], [stderr]) 23 23 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/3/post/test.conf], 0, [stdout], [stderr]) 24 24 AT_CLEANUP … … 28 28 AT_KEYWORDS([domain]) 29 29 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/4/pre/test.conf .], 0) 30 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -O], 0, [stdout], [stderr])30 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -O], 0, [stdout], [stderr]) 31 31 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/4/post/test.conf], 0, [stdout], [stderr]) 32 32 AT_CLEANUP … … 36 36 AT_KEYWORDS([domain]) 37 37 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/5/pre/test.conf .], 0) 38 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s 0.5 1. 0.9], 0, [stdout], [stderr])38 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -s "0.5, 1., 0.9"], 0, [stdout], [stderr]) 39 39 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/5/post/test.conf], 0, [stdout], [stderr]) 40 40 AT_CLEANUP … … 44 44 AT_KEYWORDS([domain]) 45 45 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0) 46 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -d 1 1 1], 0, [stdout], [stderr])47 AT_CHECK([file=test. conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])48 AT_CHECK([file=test. conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])49 AT_CHECK([file=test. conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])46 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 1, 1"], 0, [stdout], [stderr]) 47 AT_CHECK([file=test.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 48 AT_CHECK([file=test.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore]) 49 AT_CHECK([file=test.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 50 50 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-x.conf], 0) 51 AT_CHECK([../../molecuilder test-x.conf -e ${abs_top_srcdir}/src/ -d 2 1 1], 0, [stdout], [stderr])52 AT_CHECK([file=test-x. conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])53 AT_CHECK([file=test-x. conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])54 AT_CHECK([file=test-x. conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])51 AT_CHECK([../../molecuilder -i test-x.conf -e ${abs_top_srcdir}/src/ -o xyz -d "2, 1, 1"], 0, [stdout], [stderr]) 52 AT_CHECK([file=test-x.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 53 AT_CHECK([file=test-x.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore]) 54 AT_CHECK([file=test-x.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 55 55 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-y.conf], 0) 56 AT_CHECK([../../molecuilder test-y.conf -e ${abs_top_srcdir}/src/ -d 1 2 1], 0, [stdout], [stderr])57 AT_CHECK([file=test-y. conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])58 AT_CHECK([file=test-y. conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])59 AT_CHECK([file=test-y. conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])56 AT_CHECK([../../molecuilder -i test-y.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 2, 1"], 0, [stdout], [stderr]) 57 AT_CHECK([file=test-y.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 58 AT_CHECK([file=test-y.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore]) 59 AT_CHECK([file=test-y.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 60 60 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-z.conf], 0) 61 AT_CHECK([../../molecuilder test-z.conf -e ${abs_top_srcdir}/src/ -d 1 1 2], 0, [stdout], [stderr])62 AT_CHECK([file=test-z. conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])63 AT_CHECK([file=test-z. conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])64 AT_CHECK([file=test-z. conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])61 AT_CHECK([../../molecuilder -i test-z.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 1, 2"], 0, [stdout], [stderr]) 62 AT_CHECK([file=test-z.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 63 AT_CHECK([file=test-z.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore]) 64 AT_CHECK([file=test-z.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 65 65 #AT_CHECK([/bin/false], 12, [ignore], [ignore]) 66 66 AT_CLEANUP -
tests/regression/testsuite-filling.at
r06f4ef6 rb6da28 10 10 H 0.758602 0. -0.504284 11 11 ]]) 12 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -F water.xyz --MaxDistance -1 --distances 3.1 3.1 3.1 --lengths 2.1 0. 0.--DoRotate 0], 0, [stdout], [stderr])12 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -F water.xyz --MaxDistance -1 --distances "3.1, 3.1, 3.1" --lengths "2.1, 0., 0." --DoRotate 0], 0, [stdout], [stderr]) 13 13 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/1/post/$file], 0, [ignore], [ignore]) 14 14 AT_CLEANUP … … 18 18 AT_KEYWORDS([filling]) 19 19 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/pre/test.conf .], 0) 20 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3-u 1.3], 0, [stdout], [stderr])20 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-molecule-by-id 0 -u 1.3], 0, [stdout], [stderr]) 21 21 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/post/$file], 0, [ignore], [ignore]) 22 22 AT_CLEANUP -
tests/regression/testsuite-fragmentation.at
r06f4ef6 rb6da28 12 12 AT_SETUP([Fragmentation - Fragmentation]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/2/pre/test.conf .], 0) 14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0--distance 1.55 --order 2], 0, [ignore], [ignore])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore]) 15 15 AT_CHECK([ls -l BondFragment*.conf | wc -l], 0, [5 16 16 ], [ignore]) … … 21 21 AT_SETUP([Fragmentation - BROKEN: Fragmentation is at MaxOrder]) 22 22 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/3/pre/test.conf .], 0) 23 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0--distance 1.55 --order 2], 0, [ignore], [ignore])24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0--distance 1.55 --order 2], [ignore], [ignore], [ignore])23 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore]) 24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], [ignore], [ignore], [ignore]) 25 25 AT_CLEANUP -
tests/regression/testsuite-graph.at
r06f4ef6 rb6da28 4 4 AT_KEYWORDS([graph]) 5 5 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/1/pre/test.conf .], 0) 6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -D 2.], 0, [stdout], [stderr])6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -D 2.], 0, [stdout], [stderr]) 7 7 AT_CHECK([fgrep -c "No rings were detected in the molecular structure." stdout], 0, [1 8 8 ], [ignore]) … … 12 12 AT_KEYWORDS([graph]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/2/pre/test.conf .], 0) 14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -I], 0, [stdout], [stderr])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I], 0, [stdout], [stderr]) 15 15 AT_CHECK([fgrep "I scanned 31 molecules." stdout], 0, [ignore], [ignore]) 16 16 AT_CLEANUP -
tests/regression/testsuite-molecules.at
r06f4ef6 rb6da28 4 4 AT_KEYWORDS([Molecules]) 5 5 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/1/pre/test.* .], 0) 6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 4 -A test.dbond --molecule-by-id 0], 0, [stdout], [stderr])6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 --select-molecule-by-id 0 -A test.dbond], 0, [stdout], [stderr]) 7 7 AT_CHECK([fgrep "Looking for atoms 2 and 9." stdout], 0, [ignore], [ignore]) 8 8 AT_CLEANUP … … 12 12 AT_KEYWORDS([Molecules]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/pre/test.conf .], 0) 14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -j test.dbond --molecule-by-id 0], 0, [stdout], [stderr])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -j test.dbond], 0, [stdout], [stderr]) 15 15 AT_CHECK([file=test.dbond; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore]) 16 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -J test.adj --molecule-by-id 0], 0, [stdout], [stderr])16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -J test.adj], 0, [stdout], [stderr]) 17 17 AT_CHECK([file=test.adj; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore]) 18 18 AT_CLEANUP … … 22 22 AT_KEYWORDS([Molecules]) 23 23 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/pre/test.conf .], 0) 24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -S test.ekin --molecule-by-id 0], 0, [stdout], [stderr])24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -S test.ekin], 0, [stdout], [stderr]) 25 25 AT_CHECK([file=test.ekin; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/post/$file], 0, [ignore], [ignore]) 26 26 AT_CLEANUP … … 30 30 AT_KEYWORDS([Molecules]) 31 31 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/4/pre/test.conf .], 0) 32 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -L teststep --start-step 0 --end-step 1 --molecule-by-id 0--id-mapping 1], 0, [stdout], [stderr])32 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -L teststep --start-step 0 --end-step 1 --id-mapping 1], 0, [stdout], [stderr]) 33 33 AT_CLEANUP 34 34 … … 37 37 AT_KEYWORDS([Molecules]) 38 38 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/pre/test.* .], 0) 39 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -P test.forces --molecule-by-id 0], 134, [stdout], [stderr])39 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -P test.forces], 0, [stdout], [stderr]) 40 40 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/post/$file], 0, [ignore], [ignore]) 41 41 AT_CLEANUP … … 45 45 AT_KEYWORDS([Molecules]) 46 46 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test.* .], 0) 47 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t 1. 1. 1. --molecule-by-id 0--periodic 0], 0, [stdout], [stderr])47 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "1., 1., 1." --periodic 0], 0, [stdout], [stderr]) 48 48 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore]) 49 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test2.* .], 0) 50 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "-1., -1., -1." --periodic 0], 0, [stdout], [stderr]) 51 AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore]) 49 52 AT_CLEANUP 50 53 … … 53 56 AT_KEYWORDS([Molecules]) 54 57 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/pre/test.* .], 0) 55 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t 12. 12. 12. --molecule-by-id 0--periodic 1], 0, [stdout], [stderr])58 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "12., 12., 12." --periodic 1], 0, [stdout], [stderr]) 56 59 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/post/$file], 0, [ignore], [ignore]) 57 60 AT_CLEANUP … … 61 64 AT_KEYWORDS([Molecules]) 62 65 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test.* .], 0) 63 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -m 1], 0, [stdout], [stderr])66 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m 0], 0, [stdout], [stderr]) 64 67 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 65 68 AT_CLEANUP -
tests/regression/testsuite-simple_configuration.at
r06f4ef6 rb6da28 14 14 AT_KEYWORDS([configuration]) 15 15 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/pre/test.xyz .], 0) 16 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/-p test.xyz], 0, [ignore], [ignore])16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -p test.xyz], 0, [ignore], [ignore]) 17 17 AT_CHECK([fgrep "Ion_Type1_1" test.conf], 0, [Ion_Type1_1 10.000000000 10.000000000 10.000000000 0 # molecule nr 0 18 18 ], [ignore]) 19 19 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore]) 20 AT_CHECK([file=test. conf.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])21 AT_CHECK([file=test. conf.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])20 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore]) 21 AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore]) 22 22 AT_CLEANUP 23 23 24 # 3 . add atom24 # 3a. add atom 25 25 AT_SETUP([Simple configuration - adding atom]) 26 26 AT_KEYWORDS([configuration]) 27 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a 1 --position 10. 10. 10.], 0, [ignore], [ignore])27 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "10., 10., 10."], 0, [ignore], [ignore]) 28 28 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 29 AT_CHECK([file=test.conf.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 30 AT_CHECK([file=test.conf.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 29 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 30 AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 31 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 134, [ignore], [ignore]) 31 32 AT_CLEANUP 32 33 … … 34 35 AT_SETUP([Simple configuration - Changing element]) 35 36 AT_KEYWORDS([configuration]) 36 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test. conf test.conf], 0)37 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E 0 --element 6], 0, [ignore], [ignore])38 AT_CHECK([file=test. conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore])37 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.xyz test.xyz], 0) 38 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-atom-by-id 0 -E 6 ], 0, [ignore], [ignore]) 39 AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore]) 39 40 AT_CLEANUP 40 41 … … 43 44 AT_KEYWORDS([configuration]) 44 45 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/test.conf .], 0) 45 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -r 0], 0, [ignore], [ignore])46 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz --select-atom-by-id 0 -r], 0, [ignore], [ignore]) 46 47 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore]) 47 AT_CHECK([file=test. conf.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])48 AT_CHECK([file=test. conf.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])48 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore]) 49 AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore]) 49 50 AT_CLEANUP 50 51 … … 52 53 AT_SETUP([Simple configuration - invalid commands on empty configs]) 53 54 AT_KEYWORDS([configuration]) 54 AT_CHECK([../../molecuilder empty.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 55 AT_CHECK([fgrep -c "Not enough" stderr], 0, [1 56 ], [ignore]) 55 AT_CHECK([../../molecuilder -i empty.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 57 56 AT_CLEANUP 58 57 … … 61 60 AT_KEYWORDS([configuration]) 62 61 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/7/pre/test.conf .], 0) 63 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t], 255, [ignore], [stderr]) 64 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 65 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 66 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 67 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 68 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 69 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 70 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 71 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 255, [ignore], [stderr]) 72 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 73 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 255, [ignore], [stderr]) 74 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 75 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 255, [ignore], [stderr]) 76 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 77 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 255, [ignore], [stderr]) 78 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 79 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -T -u], 255, [ignore], [stderr]) 80 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 81 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -u], 255, [ignore], [stderr]) 82 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 62 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -t], 134, [ignore], [stderr]) 63 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 64 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 65 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 66 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 134, [ignore], [stderr]) 67 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 134, [ignore], [stderr]) 68 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 134, [ignore], [stderr]) 69 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 134, [ignore], [stderr]) 70 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -T -u], 134, [ignore], [stderr]) 71 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -u], 134, [ignore], [stderr]) 83 72 AT_CLEANUP 84 73 … … 87 76 AT_KEYWORDS([configuration]) 88 77 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.* .], 0) 89 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -R 7. --position 7.283585982 3.275186040 3.535886037], 0, [stdout], [stderr])90 AT_CHECK([sort -n test. conf.xyz | grep -v "Created by" >test.conf.xyz-sorted], 0, [ignore], [ignore])91 AT_CHECK([sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test. conf.xyz | grep -v "Created by" >${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.conf.xyz-sorted], 0, [ignore], [ignore])92 AT_CHECK([file=test. conf.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])78 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o xyz -R 7. --position "7.283585982, 3.275186040, 3.535886037"], 0, [stdout], [stderr]) 79 AT_CHECK([sort -n test.xyz | grep -v "Created by" >test.xyz-sorted], 0, [ignore], [ignore]) 80 AT_CHECK([sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.xyz | grep -v "Created by" >${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.xyz-sorted], 0, [ignore], [ignore]) 81 AT_CHECK([file=test.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore]) 93 82 AT_CLEANUP -
tests/regression/testsuite-specifics.at
r06f4ef6 rb6da28 4 4 AT_KEYWORDS([options]) 5 5 AT_CHECK([pwd],[ignore],[ignore]) 6 AT_CHECK([../../molecuilder test.conf -v 1 -M test], 0, [stdout], [ignore])6 AT_CHECK([../../molecuilder -i test.conf -v 1 -M test], 0, [stdout], [ignore]) 7 7 AT_CHECK([fgrep "Setting MPQC basis to test." stdout], 0, [ignore], [ignore]) 8 8 AT_CLEANUP -
tests/regression/testsuite-standard_options.at
r06f4ef6 rb6da28 18 18 AT_SETUP([Standard Options - no element database]) 19 19 AT_KEYWORDS([options]) 20 AT_CHECK([../../molecuilder -e], 255, [ignore], [stderr]) 21 AT_CHECK([fgrep "Not enough or invalid arguments" stderr], 0, [ignore], [ignore]) 20 AT_CHECK([../../molecuilder -e], 134, [ignore], [stderr]) 22 21 AT_CLEANUP 23 22 … … 30 29 Helium He 1 18 p 2 4.003 1.5 1.4 31 30 ]]) 32 AT_CHECK([../../molecuilder test.conf -e ./], 0, [stdout], [stderr])31 AT_CHECK([../../molecuilder -i test.conf -e ./], 0, [stdout], [stderr]) 33 32 AT_CHECK([grep -E "Using.*as elements database." stdout], 0, [ignore], [ignore]) 34 33 AT_CHECK([fgrep "Element list loaded successfully." stdout], 0, [ignore], [ignore]) … … 44 43 2 0. 0. 45 44 ]]) 46 AT_CHECK([../../molecuilder test.conf -g bondlength.db], 0, [stdout], [stderr])45 AT_CHECK([../../molecuilder -i test.conf -g bondlength.db], 0, [stdout], [stderr]) 47 46 AT_CHECK([grep -E "Using.*as bond length table." stdout], 0, [ignore], [ignore]) 48 47 AT_CLEANUP … … 51 50 AT_SETUP([Standard Options - fast trajectories]) 52 51 AT_KEYWORDS([options]) 53 AT_CHECK([../../molecuilder test.conf -n 1], 0, [stdout], [stderr])52 AT_CHECK([../../molecuilder -i test.conf -n 1], 0, [stdout], [stderr]) 54 53 AT_CHECK([fgrep "I won't parse trajectories" stdout], 0, [ignore], [ignore]) 55 54 AT_CLEANUP … … 58 57 AT_SETUP([Standard Options - molecule default name]) 59 58 AT_KEYWORDS([options]) 60 AT_CHECK([../../molecuilder test.conf -X test], 0, [stdout], [stderr])59 AT_CHECK([../../molecuilder -i test.conf -X test], 0, [stdout], [stderr]) 61 60 AT_CHECK([fgrep "Default name of new molecules set to test." stdout], 0, [ignore], [ignore]) 62 61 AT_CLEANUP -
tests/regression/testsuite-tesselation.at
r06f4ef6 rb6da28 4 4 AT_KEYWORDS([Tesselation]) 5 5 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/pre/* .], 0) 6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr]) 7 7 AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore]) 8 AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])8 #AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore]) 9 9 AT_CLEANUP 10 10 … … 12 12 AT_SETUP([Tesselation - Convex Envelope]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/pre/* .], 0) 14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -o 0--convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr]) 15 15 AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore]) 16 AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])16 #AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore]) 17 17 AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore]) 18 18 AT_CHECK([diff ConvexEnvelope.dat NonConvexEnvelope.dat], 0, [ignore], [ignore]) … … 22 22 AT_SETUP([Tesselation - Big non-Convex Envelope]) 23 23 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/pre/* .], 0) 24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr]) 25 25 AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore]) 26 AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])26 #AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore]) 27 27 AT_CLEANUP 28 28 … … 30 30 #AT_SETUP([Tesselation - big convex Envelope]) 31 31 #AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/pre/* .], 0) 32 #AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -oConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])32 #AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr]) 33 33 #AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore]) 34 34 #AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
Note:
See TracChangeset
for help on using the changeset viewer.