source: src/molecule_template.hpp@ 986ed3

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 986ed3 was a7b761b, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Merge branch 'MoleculeStartEndSwitch' into StructureRefactoring

Conflicts:

molecuilder/src/Helpers/Assert.cpp
molecuilder/src/Helpers/Assert.hpp
molecuilder/src/Legacy/oldmenu.cpp
molecuilder/src/Makefile.am
molecuilder/src/Patterns/Cacheable.hpp
molecuilder/src/Patterns/Observer.cpp
molecuilder/src/Patterns/Observer.hpp
molecuilder/src/analysis_correlation.cpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/helpers.hpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule.hpp
molecuilder/src/molecule_dynamics.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/ObserverTest.cpp
molecuilder/src/unittests/ObserverTest.hpp

  • Property mode set to 100644
File size: 16.3 KB
Line 
1/*
2 * molecule_template.hpp
3 *
4 * Created on: Oct 6, 2009
5 * Author: heber
6 */
7
8#ifndef MOLECULE_TEMPLATE_HPP_
9#define MOLECULE_TEMPLATE_HPP_
10
11/*********************************************** includes ***********************************/
12
13// include config.h
14#ifdef HAVE_CONFIG_H
15#include <config.h>
16#endif
17
18#include "atom.hpp"
19/********************************************** declarations *******************************/
20
21// ================== Acting on all Vectors ========================== //
22
23// zero arguments
24template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
25 {
26 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
27 (((*iter)->node)->*f)();
28 }
29};
30template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
31 {
32 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
33 (((*iter)->node)->*f)();
34 }
35};
36// one argument
37template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
38{
39 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
40 (((*iter)->node)->*f)(t);
41 }
42};
43template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
44{
45 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
46 (((*iter)->node)->*f)(t);
47 }
48};
49template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
50{
51 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
52 (((*iter)->node)->*f)(t);
53 }
54};
55template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
56{
57 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
58 (((*iter)->node)->*f)(t);
59 }
60};
61// two arguments
62template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
63{
64 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
65 (((*iter)->node)->*f)(t, u);
66 }
67};
68template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
69{
70 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
71 (((*iter)->node)->*f)(t, u);
72 }
73};
74// three arguments
75template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
76{
77 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
78 (((*iter)->node)->*f)(t, u, v);
79 }
80};
81template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
82{
83 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
84 (((*iter)->node)->*f)(t, u, v);
85 }
86};
87
88// ========================= Summing over each Atoms =================================== //
89
90// zero arguments
91template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
92{
93 res result = 0;
94 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
95 result += ((*iter)->*f)();
96 }
97 return result;
98};
99template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
100{
101 res result = 0;
102 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
103 result += ((*iter)->*f)();
104 }
105 return result;
106};
107// one argument
108template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
109{
110 res result = 0;
111 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
112 result += ((*iter)->*f)(t);
113 }
114 return result;
115};
116template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
117{
118 res result = 0;
119 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
120 result += ((*iter)->*f)(t);
121 }
122 return result;
123};
124
125
126// ================== Acting with each Atoms on same molecule ========================== //
127
128// zero arguments
129template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
130{
131 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
132 (*f)((*iter));
133 }
134};
135template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
136{
137 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
138 (*f)((*iter));
139 }
140};
141
142// ================== Acting with each Atoms on copy molecule ========================== //
143
144// zero arguments
145template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
146{
147 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
148 (copy->*f)((*iter));
149 }
150};
151template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
152{
153 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
154 (copy->*f)((*iter));
155 }
156};
157
158// ================== Acting with each Atoms on copy molecule if true ========================== //
159
160// zero arguments
161template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
162{
163 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
164 if (((*iter)->*condition)())
165 (copy->*f)((*iter));
166 }
167};
168template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
169{
170 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
171 if (((*iter)->*condition)())
172 (copy->*f)((*iter));
173 }
174};
175template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
176{
177 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
178 if (((*iter)->*condition)())
179 (copy->*f)((*iter));
180 }
181};
182template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
183{
184 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
185 if (((*iter)->*condition)())
186 (copy->*f)((*iter));
187 }
188};
189// one argument
190template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
191{
192 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
193 if (((*iter)->*condition)(t))
194 (copy->*f)((*iter));
195 }
196};
197template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
198{
199 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
200 if (((*iter)->*condition)(t))
201 (copy->*f)((*iter));
202 }
203};
204template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
205{
206 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
207 if (((*iter)->*condition)(t))
208 (copy->*f)((*iter));
209 }
210};
211template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
212{
213 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
214 if (((*iter)->*condition)(t))
215 (copy->*f)((*iter));
216 }
217};
218// two arguments
219template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
220{
221 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
222 if (((*iter)->*condition)(t,u))
223 (copy->*f)((*iter));
224 }
225};
226template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
227{
228 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
229 if (((*iter)->*condition)(t,u))
230 (copy->*f)((*iter));
231 }
232};
233template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
234{
235 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
236 if (((*iter)->*condition)(t,u))
237 (copy->*f)((*iter));
238 }
239};
240template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
241{
242 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
243 if (((*iter)->*condition)(t,u))
244 (copy->*f)((*iter));
245 }
246};
247// three arguments
248template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
249{
250 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
251 if (((*iter)->*condition)(t,u,v))
252 (copy->*f)((*iter));
253 }
254};
255template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
256{
257 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
258 if (((*iter)->*condition)(t,u,v))
259 (copy->*f)((*iter));
260 }
261};
262template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
263{
264 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
265 if (((*iter)->*condition)(t,u,v))
266 (copy->*f)((*iter));
267 }
268};
269template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
270{
271 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
272 if (((*iter)->*condition)(t,u,v))
273 (copy->*f)((*iter));
274 }
275};
276
277// ================== Acting on all Atoms ========================== //
278
279// zero arguments
280template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
281{
282 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
283 ((*iter)->*f)();
284 }
285};
286template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
287{
288 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
289 ((*iter)->*f)();
290 }
291};
292// one argument
293template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
294{
295 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
296 ((*iter)->*f)(t);
297 }
298};
299template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
300{
301 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
302 ((*iter)->*f)(t);
303 }
304};
305// two argument
306template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
307{
308 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
309 ((*iter)->*f)(t, u);
310 }
311};
312template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
313{
314 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
315 ((*iter)->*f)(t, u);
316 }
317};
318// three argument
319template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
320{
321 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
322 ((*iter)->*f)(t, u, v);
323 }
324};
325template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
326{
327 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
328 ((*iter)->*f)(t, u, v);
329 }
330};
331// four arguments
332template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
333{
334 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
335 ((*iter)->*f)(t, u, v, w);
336 }
337};
338template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
339{
340 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
341 ((*iter)->*f)(t, u, v, w);
342 }
343};
344
345// ===================== Accessing arrays indexed by some integer for each atom ======================
346
347// for atom ints
348template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
349{
350 int inc = 1;
351 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
352 (*Setor) (&array[((*iter)->*index)], &inc);
353 }
354};
355template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
356{
357 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
358 (*Setor) (&array[((*iter)->*index)], &value);
359 }
360};
361template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
362{
363 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
364 (*Setor) (&array[((*iter)->*index)], value);
365 }
366};
367// for element ints
368template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
369{
370 int inc = 1;
371 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
372 (*Setor) (&array[((*iter)->type->*index)], &inc);
373 }
374};
375template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
376{
377 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
378 (*Setor) (&array[((*iter)->type->*index)], &value);
379 }
380};
381template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
382{
383 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
384 (*Setor) (&array[((*iter)->type->*index)], value);
385 }
386};
387
388template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
389{
390 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
391 array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
392 }
393};
394template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
395{
396 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
397 array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
398 }
399};
400template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
401{
402 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
403 array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
404 }
405};
406template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
407{
408 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
409 array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
410 }
411};
412template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
413{
414 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
415 (*iter)->*value = array[((*iter)->*index)];
416 //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*value); << endl;
417 }
418};
419
420template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
421{
422 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
423 (*iter)->*ptr = value;
424 //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*ptr) << endl;
425 }
426};
427
428
429#endif /* MOLECULE_TEMPLATE_HPP_ */
Note: See TracBrowser for help on using the repository browser.