source: src/molecule_template.hpp@ 6056f1

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

Huge change from ofstream * (const) out --> Log().

  • first shift was done via regular expressions
  • then via error messages from the code
  • note that class atom, class element and class molecule kept in parts their output stream, was they print to file.
  • make check runs fine
  • MISSING: Verbosity is not fixed for everything (i.e. if no endl; is present and next has Verbose(0) ...)

Signed-off-by: Frederik Heber <heber@…>

  • 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/********************************************** declarations *******************************/
19
20// ================== Acting on all Vectors ========================== //
21
22// zero arguments
23template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
24 {
25 atom *Walker = start;
26 while (Walker->next != end) {
27 Walker = Walker->next;
28 ((Walker->node)->*f)();
29 }
30};
31template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
32 {
33 atom *Walker = start;
34 while (Walker->next != end) {
35 Walker = Walker->next;
36 ((Walker->node)->*f)();
37 }
38};
39// one argument
40template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
41{
42 atom *Walker = start;
43 while (Walker->next != end) {
44 Walker = Walker->next;
45 ((Walker->node)->*f)(t);
46 }
47};
48template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
49{
50 atom *Walker = start;
51 while (Walker->next != end) {
52 Walker = Walker->next;
53 ((Walker->node)->*f)(t);
54 }
55};
56// two arguments
57template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
58{
59 atom *Walker = start;
60 while (Walker->next != end) {
61 Walker = Walker->next;
62 ((Walker->node)->*f)(t, u);
63 }
64};
65template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
66{
67 atom *Walker = start;
68 while (Walker->next != end) {
69 Walker = Walker->next;
70 ((Walker->node)->*f)(t, u);
71 }
72};
73// three arguments
74template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
75{
76 atom *Walker = start;
77 while (Walker->next != end) {
78 Walker = Walker->next;
79 ((Walker->node)->*f)(t, u, v);
80 }
81};
82template <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
83{
84 atom *Walker = start;
85 while (Walker->next != end) {
86 Walker = Walker->next;
87 ((Walker->node)->*f)(t, u, v);
88 }
89};
90
91// ========================= Summing over each Atoms =================================== //
92
93// zero arguments
94template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
95{
96 res result = 0;
97 atom *Walker = start;
98 while (Walker->next != end) {
99 Walker = Walker->next;
100 result += (Walker->*f)();
101 }
102 return result;
103};
104template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
105{
106 res result = 0;
107 atom *Walker = start;
108 while (Walker->next != end) {
109 Walker = Walker->next;
110 result += (Walker->*f)();
111 }
112 return result;
113};
114// one argument
115template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
116{
117 res result = 0;
118 atom *Walker = start;
119 while (Walker->next != end) {
120 Walker = Walker->next;
121 result += (Walker->*f)(t);
122 }
123 return result;
124};
125template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
126{
127 res result = 0;
128 atom *Walker = start;
129 while (Walker->next != end) {
130 Walker = Walker->next;
131 result += (Walker->*f)(t);
132 }
133 return result;
134};
135
136
137// ================== Acting with each Atoms on same molecule ========================== //
138
139// zero arguments
140template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
141{
142 atom *Walker = start;
143 while (Walker->next != end) {
144 Walker = Walker->next;
145 (*f)(Walker);
146 }
147};
148template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
149{
150 atom *Walker = start;
151 while (Walker->next != end) {
152 Walker = Walker->next;
153 (*f)(Walker);
154 }
155};
156
157// ================== Acting with each Atoms on copy molecule ========================== //
158
159// zero arguments
160template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
161{
162 atom *Walker = start;
163 while (Walker->next != end) {
164 Walker = Walker->next;
165 (copy->*f)(Walker);
166 }
167};
168template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
169{
170 atom *Walker = start;
171 while (Walker->next != end) {
172 Walker = Walker->next;
173 (copy->*f)(Walker);
174 }
175};
176
177// ================== Acting with each Atoms on copy molecule if true ========================== //
178
179// zero arguments
180template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
181{
182 atom *Walker = start;
183 while (Walker->next != end) {
184 Walker = Walker->next;
185 if ((Walker->*condition)())
186 (copy->*f)(Walker);
187 }
188};
189template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
190{
191 atom *Walker = start;
192 while (Walker->next != end) {
193 Walker = Walker->next;
194 if ((Walker->*condition)())
195 (copy->*f)(Walker);
196 }
197};
198template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
199{
200 atom *Walker = start;
201 while (Walker->next != end) {
202 Walker = Walker->next;
203 if ((Walker->*condition)())
204 (copy->*f)(Walker);
205 }
206};
207template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
208{
209 atom *Walker = start;
210 while (Walker->next != end) {
211 Walker = Walker->next;
212 if ((Walker->*condition)())
213 (copy->*f)(Walker);
214 }
215};
216// one argument
217template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
218{
219 atom *Walker = start;
220 while (Walker->next != end) {
221 Walker = Walker->next;
222 if ((Walker->*condition)(t))
223 (copy->*f)(Walker);
224 }
225};
226template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
227{
228 atom *Walker = start;
229 while (Walker->next != end) {
230 Walker = Walker->next;
231 if ((Walker->*condition)(t))
232 (copy->*f)(Walker);
233 }
234};
235template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
236{
237 atom *Walker = start;
238 while (Walker->next != end) {
239 Walker = Walker->next;
240 if ((Walker->*condition)(t))
241 (copy->*f)(Walker);
242 }
243};
244template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
245{
246 atom *Walker = start;
247 while (Walker->next != end) {
248 Walker = Walker->next;
249 if ((Walker->*condition)(t))
250 (copy->*f)(Walker);
251 }
252};
253// two arguments
254template <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
255{
256 atom *Walker = start;
257 while (Walker->next != end) {
258 Walker = Walker->next;
259 if ((Walker->*condition)(t,u))
260 (copy->*f)(Walker);
261 }
262};
263template <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
264{
265 atom *Walker = start;
266 while (Walker->next != end) {
267 Walker = Walker->next;
268 if ((Walker->*condition)(t,u))
269 (copy->*f)(Walker);
270 }
271};
272template <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
273{
274 atom *Walker = start;
275 while (Walker->next != end) {
276 Walker = Walker->next;
277 if ((Walker->*condition)(t,u))
278 (copy->*f)(Walker);
279 }
280};
281template <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
282{
283 atom *Walker = start;
284 while (Walker->next != end) {
285 Walker = Walker->next;
286 if ((Walker->*condition)(t,u))
287 (copy->*f)(Walker);
288 }
289};
290// three arguments
291template <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
292{
293 atom *Walker = start;
294 while (Walker->next != end) {
295 Walker = Walker->next;
296 if ((Walker->*condition)(t,u,v))
297 (copy->*f)(Walker);
298 }
299};
300template <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
301{
302 atom *Walker = start;
303 while (Walker->next != end) {
304 Walker = Walker->next;
305 if ((Walker->*condition)(t,u,v))
306 (copy->*f)(Walker);
307 }
308};
309template <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
310{
311 atom *Walker = start;
312 while (Walker->next != end) {
313 Walker = Walker->next;
314 if ((Walker->*condition)(t,u,v))
315 (copy->*f)(Walker);
316 }
317};
318template <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
319{
320 atom *Walker = start;
321 while (Walker->next != end) {
322 Walker = Walker->next;
323 if ((Walker->*condition)(t,u,v))
324 (copy->*f)(Walker);
325 }
326};
327
328// ================== Acting on all Atoms ========================== //
329
330// zero arguments
331template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
332{
333 atom *Walker = start;
334 while (Walker->next != end) {
335 Walker = Walker->next;
336 (Walker->*f)();
337 }
338};
339template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
340{
341 atom *Walker = start;
342 while (Walker->next != end) {
343 Walker = Walker->next;
344 (Walker->*f)();
345 }
346};
347// one argument
348template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
349{
350 atom *Walker = start;
351 while (Walker->next != end) {
352 Walker = Walker->next;
353 (Walker->*f)(t);
354 }
355};
356template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
357{
358 atom *Walker = start;
359 while (Walker->next != end) {
360 Walker = Walker->next;
361 (Walker->*f)(t);
362 }
363};
364// two argument
365template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
366{
367 atom *Walker = start;
368 while (Walker->next != end) {
369 Walker = Walker->next;
370 (Walker->*f)(t, u);
371 }
372};
373template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
374{
375 atom *Walker = start;
376 while (Walker->next != end) {
377 Walker = Walker->next;
378 (Walker->*f)(t, u);
379 }
380};
381// three argument
382template <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
383{
384 atom *Walker = start;
385 while (Walker->next != end) {
386 Walker = Walker->next;
387 (Walker->*f)(t, u, v);
388 }
389};
390template <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
391{
392 atom *Walker = start;
393 while (Walker->next != end) {
394 Walker = Walker->next;
395 (Walker->*f)(t, u, v);
396 }
397};
398// four arguments
399template <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
400{
401 atom *Walker = start;
402 while (Walker->next != end) {
403 Walker = Walker->next;
404 (Walker->*f)(t, u, v, w);
405 }
406};
407template <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
408{
409 atom *Walker = start;
410 while (Walker->next != end) {
411 Walker = Walker->next;
412 (Walker->*f)(t, u, v, w);
413 }
414};
415
416// ===================== Accessing arrays indexed by some integer for each atom ======================
417
418// for atom ints
419template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
420{
421 atom *Walker = start;
422 int inc = 1;
423 while (Walker->next != end) {
424 Walker = Walker->next;
425 (*Setor) (&array[(Walker->*index)], &inc);
426 }
427};
428template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
429{
430 atom *Walker = start;
431 while (Walker->next != end) {
432 Walker = Walker->next;
433 (*Setor) (&array[(Walker->*index)], &value);
434 }
435};
436template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
437{
438 atom *Walker = start;
439 while (Walker->next != end) {
440 Walker = Walker->next;
441 (*Setor) (&array[(Walker->*index)], value);
442 }
443};
444// for element ints
445template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
446{
447 atom *Walker = start;
448 int inc = 1;
449 while (Walker->next != end) {
450 Walker = Walker->next;
451 (*Setor) (&array[(Walker->type->*index)], &inc);
452 }
453};
454template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
455{
456 atom *Walker = start;
457 while (Walker->next != end) {
458 Walker = Walker->next;
459 (*Setor) (&array[(Walker->type->*index)], &value);
460 }
461};
462template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
463{
464 atom *Walker = start;
465 while (Walker->next != end) {
466 Walker = Walker->next;
467 (*Setor) (&array[(Walker->type->*index)], value);
468 }
469};
470
471template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
472{
473 atom *Walker = start;
474 while (Walker->next != end) {
475 Walker = Walker->next;
476 array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
477 }
478};
479template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
480{
481 atom *Walker = start;
482 while (Walker->next != end) {
483 Walker = Walker->next;
484 array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
485 }
486};
487template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
488{
489 atom *Walker = start;
490 while (Walker->next != end) {
491 Walker = Walker->next;
492 array[(Walker->*index)] = (Walker->*Setor) (vect);
493 }
494};
495template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
496{
497 atom *Walker = start;
498 while (Walker->next != end) {
499 Walker = Walker->next;
500 array[(Walker->*index)] = (Walker->*Setor) (vect);
501 }
502};
503template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
504{
505 atom *Walker = start;
506 while (Walker->next != end) {
507 Walker = Walker->next;
508 Walker->*value = array[(Walker->*index)];
509 //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
510 }
511};
512
513template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
514{
515 atom *Walker = start;
516 while (Walker->next != end) {
517 Walker = Walker->next;
518 Walker->*ptr = value;
519 //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
520 }
521};
522
523
524#endif /* MOLECULE_TEMPLATE_HPP_ */
Note: See TracBrowser for help on using the repository browser.