source: molecuilder/src/moleculelist.cpp@ 4dca8e

Last change on this file since 4dca8e was e78824, checked in by Frederik Heber <heber@…>, 16 years ago

class config definitions moved to their own header file.

NOTE: Tesselation of heptan was working correctly! (The config file just grew bigger and bigger that's why more and more triangles were added)

  • Property mode set to 100755
File size: 38.8 KB
RevLine 
[a0bcf1]1/** \file MoleculeListClass.cpp
[c830e8e]2 *
[a0bcf1]3 * Function implementations for the class MoleculeListClass.
[c830e8e]4 *
[a0bcf1]5 */
6
[e78824]7#include "config.hpp"
[a0bcf1]8#include "molecules.hpp"
9
10/*********************************** Functions for class MoleculeListClass *************************/
11
12/** Constructor for MoleculeListClass.
13 */
14MoleculeListClass::MoleculeListClass()
15{
[c830e8e]16 // empty lists
17 ListOfMolecules.clear();
18 MaxIndex = 1;
[a0bcf1]19};
20
21/** Destructor for MoleculeListClass.
22 */
23MoleculeListClass::~MoleculeListClass()
24{
[c75363]25 cout << Verbose(3) << this << ": Freeing ListOfMolcules." << endl;
[c830e8e]26 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
27 cout << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl;
28 delete (*ListRunner);
[a0bcf1]29 }
30 cout << Verbose(4) << "Freeing ListOfMolecules." << endl;
[c830e8e]31 ListOfMolecules.clear(); // empty list
[a0bcf1]32};
33
[c830e8e]34/** Insert a new molecule into the list and set its number.
35 * \param *mol molecule to add to list.
36 * \return true - add successful
[a0bcf1]37 */
[a41b50]38void MoleculeListClass::insert(molecule *mol)
[a0bcf1]39{
[c830e8e]40 mol->IndexNr = MaxIndex++;
41 ListOfMolecules.push_back(mol);
[a0bcf1]42};
43
[c75363]44/** Compare whether two molecules are equal.
45 * \param *a molecule one
46 * \param *n molecule two
47 * \return lexical value (-1, 0, +1)
48 */
[a0bcf1]49int MolCompare(const void *a, const void *b)
50{
51 int *aList = NULL, *bList = NULL;
52 int Count, Counter, aCounter, bCounter;
53 int flag;
54 atom *aWalker = NULL;
55 atom *bWalker = NULL;
[c830e8e]56
[a0bcf1]57 // sort each atom list and put the numbers into a list, then go through
58 //cout << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl;
[c830e8e]59 if ((**(molecule **) a).AtomCount < (**(molecule **) b).AtomCount) {
[a0bcf1]60 return -1;
[c830e8e]61 } else {
62 if ((**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)
63 return +1;
[a0bcf1]64 else {
[c830e8e]65 Count = (**(molecule **) a).AtomCount;
[f75030]66 aList = new int[Count];
67 bList = new int[Count];
[c830e8e]68
[a0bcf1]69 // fill the lists
[c830e8e]70 aWalker = (**(molecule **) a).start;
71 bWalker = (**(molecule **) b).start;
[a0bcf1]72 Counter = 0;
73 aCounter = 0;
74 bCounter = 0;
[c830e8e]75 while ((aWalker->next != (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
[a0bcf1]76 aWalker = aWalker->next;
77 bWalker = bWalker->next;
78 if (aWalker->GetTrueFather() == NULL)
79 aList[Counter] = Count + (aCounter++);
80 else
81 aList[Counter] = aWalker->GetTrueFather()->nr;
82 if (bWalker->GetTrueFather() == NULL)
83 bList[Counter] = Count + (bCounter++);
84 else
85 bList[Counter] = bWalker->GetTrueFather()->nr;
86 Counter++;
87 }
88 // check if AtomCount was for real
89 flag = 0;
[c830e8e]90 if ((aWalker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
[a0bcf1]91 flag = -1;
92 } else {
[c830e8e]93 if ((aWalker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))
[a0bcf1]94 flag = 1;
95 }
96 if (flag == 0) {
97 // sort the lists
[c830e8e]98 gsl_heapsort(aList, Count, sizeof(int), CompareDoubles);
99 gsl_heapsort(bList, Count, sizeof(int), CompareDoubles);
100 // compare the lists
101
[a0bcf1]102 flag = 0;
[c830e8e]103 for (int i = 0; i < Count; i++) {
[a0bcf1]104 if (aList[i] < bList[i]) {
105 flag = -1;
106 } else {
107 if (aList[i] > bList[i])
108 flag = 1;
109 }
110 if (flag != 0)
111 break;
112 }
113 }
[c830e8e]114 delete[] (aList);
115 delete[] (bList);
[a0bcf1]116 return flag;
117 }
118 }
[c830e8e]119 return -1;
120};
121
122/** Output of a list of all molecules.
123 * \param *out output stream
124 */
125void MoleculeListClass::Enumerate(ofstream *out)
126{
127 element* Elemental = NULL;
128 atom *Walker = NULL;
129 int Counts[MAX_ELEMENTS];
[8b05c6]130 double size=0;
131 Vector Origin;
[c830e8e]132
133 // header
[8b05c6]134 *out << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl;
[c830e8e]135 cout << Verbose(0) << "-----------------------------------------------" << endl;
136 if (ListOfMolecules.size() == 0)
137 *out << "\tNone" << endl;
138 else {
[8b05c6]139 Origin.Zero();
[c830e8e]140 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
141 // reset element counts
142 for (int j = 0; j<MAX_ELEMENTS;j++)
143 Counts[j] = 0;
[8b05c6]144 // count atoms per element and determine size of bounding sphere
145 size=0.;
[c830e8e]146 Walker = (*ListRunner)->start;
147 while (Walker->next != (*ListRunner)->end) {
148 Walker = Walker->next;
149 Counts[Walker->type->Z]++;
[8b05c6]150 if (Walker->x.DistanceSquared(&Origin) > size)
151 size = Walker->x.DistanceSquared(&Origin);
[c830e8e]152 }
153 // output Index, Name, number of atoms, chemical formula
154 *out << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";
155 Elemental = (*ListRunner)->elemente->end;
[8b05c6]156 while(Elemental->previous != (*ListRunner)->elemente->start) {
[c830e8e]157 Elemental = Elemental->previous;
158 if (Counts[Elemental->Z] != 0)
159 *out << Elemental->symbol << Counts[Elemental->Z];
160 }
[8b05c6]161 // Center and size
162 *out << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;
[c830e8e]163 }
164 }
165};
166
167/** Returns the molecule with the given index \a index.
168 * \param index index of the desired molecule
169 * \return pointer to molecule structure, NULL if not found
170 */
171molecule * MoleculeListClass::ReturnIndex(int index)
172{
[8b05c6]173 for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
174 if ((*ListRunner)->IndexNr == index)
175 return (*ListRunner);
176 return NULL;
[c830e8e]177};
178
179/** Simple merge of two molecules into one.
180 * \param *mol destination molecule
181 * \param *srcmol source molecule
182 * \return true - merge successful, false - merge failed (probably due to non-existant indices
183 */
184bool MoleculeListClass::SimpleMerge(molecule *mol, molecule *srcmol)
185{
186 if (srcmol == NULL)
187 return false;
188
189 // put all molecules of src into mol
190 atom *Walker = srcmol->start;
191 atom *NextAtom = Walker->next;
192 while (NextAtom != srcmol->end) {
193 Walker = NextAtom;
194 NextAtom = Walker->next;
195 srcmol->UnlinkAtom(Walker);
196 mol->AddAtom(Walker);
197 }
198
199 // remove src
200 ListOfMolecules.remove(srcmol);
201 delete(srcmol);
202 return true;
203};
204
205/** Simple add of one molecules into another.
206 * \param *mol destination molecule
207 * \param *srcmol source molecule
208 * \return true - merge successful, false - merge failed (probably due to non-existant indices
209 */
210bool MoleculeListClass::SimpleAdd(molecule *mol, molecule *srcmol)
211{
212 if (srcmol == NULL)
213 return false;
214
215 // put all molecules of src into mol
216 atom *Walker = srcmol->start;
217 atom *NextAtom = Walker->next;
218 while (NextAtom != srcmol->end) {
219 Walker = NextAtom;
220 NextAtom = Walker->next;
221 Walker = mol->AddCopyAtom(Walker);
222 Walker->father = Walker;
223 }
224
225 return true;
226};
227
228/** Simple merge of a given set of molecules into one.
229 * \param *mol destination molecule
230 * \param *src index of set of source molecule
231 * \param N number of source molecules
232 * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
233 */
234bool MoleculeListClass::SimpleMultiMerge(molecule *mol, int *src, int N)
235{
236 bool status = true;
237 // check presence of all source molecules
238 for (int i=0;i<N;i++) {
239 molecule *srcmol = ReturnIndex(src[i]);
240 status = status && SimpleMerge(mol, srcmol);
241 }
242 return status;
243};
244
245/** Simple add of a given set of molecules into one.
246 * \param *mol destination molecule
247 * \param *src index of set of source molecule
248 * \param N number of source molecules
249 * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
250 */
251bool MoleculeListClass::SimpleMultiAdd(molecule *mol, int *src, int N)
252{
253 bool status = true;
254 // check presence of all source molecules
255 for (int i=0;i<N;i++) {
256 molecule *srcmol = ReturnIndex(src[i]);
257 status = status && SimpleAdd(mol, srcmol);
258 }
259 return status;
260};
261
262/** Scatter merge of a given set of molecules into one.
263 * Scatter merge distributes the molecules in such a manner that they don't overlap.
264 * \param *mol destination molecule
265 * \param *src index of set of source molecule
266 * \param N number of source molecules
267 * \return true - merge successful, false - merge failed (probably due to non-existant indices
268 * \TODO find scatter center for each src molecule
269 */
270bool MoleculeListClass::ScatterMerge(molecule *mol, int *src, int N)
271{
272 // check presence of all source molecules
273 for (int i=0;i<N;i++) {
274 // get pointer to src molecule
275 molecule *srcmol = ReturnIndex(src[i]);
276 if (srcmol == NULL)
277 return false;
278 }
279 // adapt each Center
280 for (int i=0;i<N;i++) {
281 // get pointer to src molecule
282 molecule *srcmol = ReturnIndex(src[i]);
283 //srcmol->Center.Zero();
284 srcmol->Translate(&srcmol->Center);
285 }
286 // perform a simple multi merge
287 SimpleMultiMerge(mol, src, N);
288 return true;
289};
290
291/** Embedding merge of a given set of molecules into one.
292 * Embedding merge inserts one molecule into the other.
293 * \param *mol destination molecule
294 * \param *srcmol source molecule
295 * \return true - merge successful, false - merge failed (probably due to non-existant indices
296 * \TODO find embedding center
297 */
298bool MoleculeListClass::EmbedMerge(molecule *mol, molecule *srcmol)
299{
300 if (srcmol == NULL)
301 return false;
302
303 // calculate center for merge
[899029f]304 srcmol->Center.CopyVector(mol->FindEmbeddingHole((ofstream *)&cout, srcmol));
305 srcmol->Center.Zero();
[c830e8e]306
307 // perform simple merge
308 SimpleMerge(mol, srcmol);
309 return true;
[a0bcf1]310};
311
312/** Simple output of the pointers in ListOfMolecules.
313 * \param *out output stream
314 */
315void MoleculeListClass::Output(ofstream *out)
316{
[c830e8e]317 *out << Verbose(1) << "MoleculeList: ";
318 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
319 *out << *ListRunner << "\t";
[a0bcf1]320 *out << endl;
321};
322
[db3ea3]323/** Calculates necessary hydrogen correction due to unwanted interaction between saturated ones.
324 * If for a pair of two hydrogen atoms a and b, at least is a saturated one, and a and b are not
325 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse
326 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance.
327 * \param *out output stream for debugging
328 * \param *path path to file
329 */
330bool MoleculeListClass::AddHydrogenCorrection(ofstream *out, char *path)
331{
332 atom *Walker = NULL;
333 atom *Runner = NULL;
334 double ***FitConstant = NULL, **correction = NULL;
[c830e8e]335 int a, b;
[db3ea3]336 ofstream output;
337 ifstream input;
338 string line;
339 stringstream zeile;
340 double distance;
341 char ParsedLine[1023];
342 double tmp;
343 char *FragmentNumber = NULL;
344
345 cout << Verbose(1) << "Saving hydrogen saturation correction ... ";
346 // 0. parse in fit constant files that should have the same dimension as the final energy files
347 // 0a. find dimension of matrices with constants
348 line = path;
349 line.append("/");
350 line += FRAGMENTPREFIX;
351 line += "1";
352 line += FITCONSTANTSUFFIX;
353 input.open(line.c_str());
354 if (input == NULL) {
[c830e8e]355 cerr << endl << "Unable to open " << line << ", is the directory correct?"
356 << endl;
[db3ea3]357 return false;
358 }
[c830e8e]359 a = 0;
360 b = -1; // we overcount by one
[db3ea3]361 while (!input.eof()) {
362 input.getline(ParsedLine, 1023);
363 zeile.str(ParsedLine);
[c830e8e]364 int i = 0;
[db3ea3]365 while (!zeile.eof()) {
366 zeile >> distance;
367 i++;
368 }
[c830e8e]369 if (i > a)
370 a = i;
[db3ea3]371 b++;
372 }
373 cout << "I recognized " << a << " columns and " << b << " rows, ";
374 input.close();
[c830e8e]375
[db3ea3]376 // 0b. allocate memory for constants
[c830e8e]377 FitConstant = (double ***) Malloc(sizeof(double **) * 3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
378 for (int k = 0; k < 3; k++) {
379 FitConstant[k] = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
380 for (int i = a; i--;) {
381 FitConstant[k][i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
[db3ea3]382 }
383 }
384 // 0c. parse in constants
[c830e8e]385 for (int i = 0; i < 3; i++) {
[db3ea3]386 line = path;
387 line.append("/");
388 line += FRAGMENTPREFIX;
[c830e8e]389 sprintf(ParsedLine, "%d", i + 1);
[db3ea3]390 line += ParsedLine;
391 line += FITCONSTANTSUFFIX;
392 input.open(line.c_str());
393 if (input == NULL) {
394 cerr << endl << "Unable to open " << line << ", is the directory correct?" << endl;
395 return false;
396 }
[c830e8e]397 int k = 0, l;
[db3ea3]398 while ((!input.eof()) && (k < b)) {
399 input.getline(ParsedLine, 1023);
400 //cout << "Current Line: " << ParsedLine << endl;
401 zeile.str(ParsedLine);
402 zeile.clear();
403 l = 0;
404 while ((!zeile.eof()) && (l < a)) {
405 zeile >> FitConstant[i][l][k];
406 //cout << FitConstant[i][l][k] << "\t";
407 l++;
408 }
409 //cout << endl;
410 k++;
411 }
412 input.close();
413 }
[c830e8e]414 for (int k = 0; k < 3; k++) {
[db3ea3]415 cout << "Constants " << k << ":" << endl;
[c830e8e]416 for (int j = 0; j < b; j++) {
417 for (int i = 0; i < a; i++) {
[db3ea3]418 cout << FitConstant[k][i][j] << "\t";
419 }
420 cout << endl;
421 }
422 cout << endl;
423 }
[c830e8e]424
[db3ea3]425 // 0d. allocate final correction matrix
[c830e8e]426 correction = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **correction");
427 for (int i = a; i--;)
428 correction[i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");
429
[db3ea3]430 // 1a. go through every molecule in the list
[c830e8e]431 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
[db3ea3]432 // 1b. zero final correction matrix
[c830e8e]433 for (int k = a; k--;)
434 for (int j = b; j--;)
[db3ea3]435 correction[k][j] = 0.;
436 // 2. take every hydrogen that is a saturated one
[c830e8e]437 Walker = (*ListRunner)->start;
438 while (Walker->next != (*ListRunner)->end) {
[db3ea3]439 Walker = Walker->next;
[c830e8e]440 //cout << Verbose(1) << "Walker: " << *Walker << " with first bond " << *(*Runner)->ListOfBondsPerAtom[Walker->nr][0] << "." << endl;
441 if ((Walker->type->Z == 1) && ((Walker->father == NULL)
442 || (Walker->father->type->Z != 1))) { // if it's a hydrogen
443 Runner = (*ListRunner)->start;
444 while (Runner->next != (*ListRunner)->end) {
[db3ea3]445 Runner = Runner->next;
[c830e8e]446 //cout << Verbose(2) << "Runner: " << *Runner << " with first bond " << *(*Runner)->ListOfBondsPerAtom[Runner->nr][0] << "." << endl;
[db3ea3]447 // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
[c830e8e]448 if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && ((*ListRunner)->ListOfBondsPerAtom[Runner->nr][0]->GetOtherAtom(Runner) != (*ListRunner)->ListOfBondsPerAtom[Walker->nr][0]->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)
[db3ea3]449 // 4. evaluate the morse potential for each matrix component and add up
[c830e8e]450 distance = Runner->x.Distance(&Walker->x);
451 //cout << "Fragment " << (*ListRunner)->name << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl;
452 for (int k = 0; k < a; k++) {
453 for (int j = 0; j < b; j++) {
454 switch (k) {
455 case 1:
456 case 7:
457 case 11:
458 tmp = pow(FitConstant[0][k][j] * (1. - exp(-FitConstant[1][k][j] * (distance - FitConstant[2][k][j]))), 2);
459 break;
460 default:
461 tmp = FitConstant[0][k][j] * pow(distance, FitConstant[1][k][j]) + FitConstant[2][k][j];
[db3ea3]462 };
[c830e8e]463 correction[k][j] -= tmp; // ground state is actually lower (disturbed by additional interaction)
[db3ea3]464 //cout << tmp << "\t";
465 }
466 //cout << endl;
467 }
468 //cout << endl;
469 }
470 }
471 }
472 }
473 // 5. write final matrix to file
474 line = path;
475 line.append("/");
476 line += FRAGMENTPREFIX;
[c830e8e]477 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr);
[db3ea3]478 line += FragmentNumber;
[c830e8e]479 delete (FragmentNumber);
[db3ea3]480 line += HCORRECTIONSUFFIX;
481 output.open(line.c_str());
482 output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl;
[c830e8e]483 for (int j = 0; j < b; j++) {
484 for (int i = 0; i < a; i++)
[db3ea3]485 output << correction[i][j] << "\t";
486 output << endl;
487 }
488 output.close();
489 }
490 line = path;
491 line.append("/");
492 line += HCORRECTIONSUFFIX;
493 output.open(line.c_str());
494 output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl;
[c830e8e]495 for (int j = 0; j < b; j++) {
496 for (int i = 0; i < a; i++)
[db3ea3]497 output << 0 << "\t";
498 output << endl;
499 }
500 output.close();
501 // 6. free memory of parsed matrices
[c830e8e]502 FitConstant = (double ***) Malloc(sizeof(double **) * a, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
503 for (int k = 0; k < 3; k++) {
504 FitConstant[k] = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
505 for (int i = a; i--;) {
506 FitConstant[k][i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
[db3ea3]507 }
508 }
509 cout << "done." << endl;
510 return true;
511};
[115bf4]512
513/** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config.
514 * \param *out output stream for debugging
515 * \param *path path to file
516 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
517 * \return true - file written successfully, false - writing failed
518 */
[c830e8e]519bool MoleculeListClass::StoreForcesFile(ofstream *out, char *path,
520 int *SortIndex)
[115bf4]521{
522 bool status = true;
523 ofstream ForcesFile;
524 stringstream line;
525 atom *Walker = NULL;
526 element *runner = NULL;
527
528 // open file for the force factors
529 *out << Verbose(1) << "Saving force factors ... ";
530 line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
531 ForcesFile.open(line.str().c_str(), ios::out);
532 if (ForcesFile != NULL) {
533 //cout << Verbose(1) << "Final AtomicForcesList: ";
534 //output << prefix << "Forces" << endl;
[c830e8e]535 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
536 runner = (*ListRunner)->elemente->start;
537 while (runner->next != (*ListRunner)->elemente->end) { // go through every element
[115bf4]538 runner = runner->next;
[c830e8e]539 if ((*ListRunner)->ElementsInMolecule[runner->Z]) { // if this element got atoms
540 Walker = (*ListRunner)->start;
541 while (Walker->next != (*ListRunner)->end) { // go through every atom of this element
[115bf4]542 Walker = Walker->next;
543 if (Walker->type->Z == runner->Z) {
544 if ((Walker->GetTrueFather() != NULL) && (Walker->GetTrueFather() != Walker)) {// if there is a rea
545 //cout << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
[c830e8e]546 ForcesFile << SortIndex[Walker->GetTrueFather()->nr] << "\t";
547 } else
548 // otherwise a -1 to indicate an added saturation hydrogen
549 ForcesFile << "-1\t";
[115bf4]550 }
551 }
[c830e8e]552 }
[115bf4]553 }
554 ForcesFile << endl;
555 }
556 ForcesFile.close();
557 *out << Verbose(1) << "done." << endl;
558 } else {
559 status = false;
560 *out << Verbose(1) << "failed to open file " << line.str() << "." << endl;
561 }
562 ForcesFile.close();
[c830e8e]563
[115bf4]564 return status;
565};
566
[a0bcf1]567/** Writes a config file for each molecule in the given \a **FragmentList.
[c75363]568 * \param *out output stream for debugging
[a0bcf1]569 * \param *configuration standard configuration to attach atoms in fragment molecule to.
570 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
[63b5c31]571 * \param DoPeriodic true - call ScanForPeriodicCorrection, false - don't
572 * \param DoCentering true - call molecule::CenterEdge(), false - don't
[a0bcf1]573 * \return true - success (each file was written), false - something went wrong.
574 */
[f39735]575bool MoleculeListClass::OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex)
[a0bcf1]576{
577 ofstream outputFragment;
[c510a7]578 char FragmentName[MAXSTRINGSIZE];
579 char PathBackup[MAXSTRINGSIZE];
[a0bcf1]580 bool result = true;
581 bool intermediateResult = true;
582 atom *Walker = NULL;
[8f8621]583 Vector BoxDimension;
[5063f1]584 char *FragmentNumber = NULL;
[eefb8e]585 char *path = NULL;
[a0bcf1]586 int FragmentCounter = 0;
[23409a]587 ofstream output;
[c830e8e]588
[a0bcf1]589 // store the fragments as config and as xyz
[c830e8e]590 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
[c75363]591 // save default path as it is changed for each fragment
[eefb8e]592 path = configuration->GetDefaultPath();
593 if (path != NULL)
594 strcpy(PathBackup, path);
595 else
596 cerr << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl;
[c75363]597
598 // correct periodic
[c830e8e]599 (*ListRunner)->ScanForPeriodicCorrection(out);
[c75363]600
601 // output xyz file
[c830e8e]602 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++);
603 sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
[c75363]604 outputFragment.open(FragmentName, ios::out);
[c830e8e]605 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...";
606 if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
[c75363]607 *out << " done." << endl;
608 else
609 *out << " failed." << endl;
610 result = result && intermediateResult;
611 outputFragment.close();
612 outputFragment.clear();
613
[ff74f7]614 // list atoms in fragment for debugging
[c75363]615 *out << Verbose(2) << "Contained atoms: ";
[c830e8e]616 Walker = (*ListRunner)->start;
617 while (Walker->next != (*ListRunner)->end) {
[c75363]618 Walker = Walker->next;
619 *out << Walker->Name << " ";
[a0bcf1]620 }
[c75363]621 *out << endl;
[c830e8e]622
[c75363]623 // center on edge
[c830e8e]624 (*ListRunner)->CenterEdge(out, &BoxDimension);
625 (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary
626 int j = -1;
627 for (int k = 0; k < NDIM; k++) {
628 j += k + 1;
629 BoxDimension.x[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
630 (*ListRunner)->cell_size[j] += BoxDimension.x[k] * 2.;
[a0bcf1]631 }
[c830e8e]632 (*ListRunner)->Translate(&BoxDimension);
[c75363]633
634 // also calculate necessary orbitals
[c830e8e]635 (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment
636 (*ListRunner)->CalculateOrbitals(*configuration);
637
[c75363]638 // change path in config
[ff74f7]639 //strcpy(PathBackup, configuration->configpath);
[c830e8e]640 sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber);
[c75363]641 configuration->SetDefaultPath(FragmentName);
[c830e8e]642
[ff74f7]643 // and save as config
[c830e8e]644 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
645 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...";
646 if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))
[c75363]647 *out << " done." << endl;
648 else
649 *out << " failed." << endl;
[f89a9e]650 result = result && intermediateResult;
[ff74f7]651
[c75363]652 // restore old config
653 configuration->SetDefaultPath(PathBackup);
[ff74f7]654
655 // and save as mpqc input file
[c830e8e]656 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
657 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...";
658 if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))
[ff74f7]659 *out << " done." << endl;
660 else
661 *out << " failed." << endl;
[c830e8e]662
[c75363]663 result = result && intermediateResult;
[f89a9e]664 //outputFragment.close();
665 //outputFragment.clear();
[c830e8e]666 delete (FragmentNumber);
[f75030]667 //Free((void **)&FragmentNumber, "MoleculeListClass::OutputConfigForListOfFragments: *FragmentNumber");
[a0bcf1]668 }
[115bf4]669 cout << " done." << endl;
[c830e8e]670
[a0bcf1]671 // printing final number
[c75363]672 *out << "Final number of fragments: " << FragmentCounter << "." << endl;
[c830e8e]673
[a0bcf1]674 return result;
675};
676
[c830e8e]677/** Counts the number of molecules with the molecule::ActiveFlag set.
678 * \return number of molecules with ActiveFlag set to true.
679 */
680int MoleculeListClass::NumberOfActiveMolecules()
681{
682 int count = 0;
683 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
684 count += ((*ListRunner)->ActiveFlag ? 1 : 0);
685 return count;
686};
687
688
[a0bcf1]689/******************************************* Class MoleculeLeafClass ************************************************/
690
691/** Constructor for MoleculeLeafClass root leaf.
692 * \param *Up Leaf on upper level
693 * \param *PreviousLeaf NULL - We are the first leaf on this level, otherwise points to previous in list
694 */
695//MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL)
696MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL)
697{
[1b2aa1]698 // if (Up != NULL)
699 // if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?
700 // Up->DownLeaf = this;
701 // UpLeaf = Up;
702 // DownLeaf = NULL;
[a0bcf1]703 Leaf = NULL;
704 previous = PreviousLeaf;
705 if (previous != NULL) {
706 MoleculeLeafClass *Walker = previous->next;
707 previous->next = this;
708 next = Walker;
709 } else {
710 next = NULL;
711 }
712};
713
714/** Destructor for MoleculeLeafClass.
715 */
716MoleculeLeafClass::~MoleculeLeafClass()
717{
[1b2aa1]718 // if (DownLeaf != NULL) {// drop leaves further down
719 // MoleculeLeafClass *Walker = DownLeaf;
720 // MoleculeLeafClass *Next;
721 // do {
722 // Next = Walker->NextLeaf;
723 // delete(Walker);
724 // Walker = Next;
725 // } while (Walker != NULL);
726 // // Last Walker sets DownLeaf automatically to NULL
727 // }
[a0bcf1]728 // remove the leaf itself
729 if (Leaf != NULL) {
[c830e8e]730 delete (Leaf);
[a0bcf1]731 Leaf = NULL;
732 }
733 // remove this Leaf from level list
[c830e8e]734 if (previous != NULL)
[a0bcf1]735 previous->next = next;
[1b2aa1]736 // } else { // we are first in list (connects to UpLeaf->DownLeaf)
737 // if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))
738 // NextLeaf->UpLeaf = UpLeaf; // either null as we are top level or the upleaf of the first node
739 // if (UpLeaf != NULL)
740 // UpLeaf->DownLeaf = NextLeaf; // either null as we are only leaf or NextLeaf if we are just the first
741 // }
742 // UpLeaf = NULL;
[a0bcf1]743 if (next != NULL) // are we last in list
744 next->previous = previous;
745 next = NULL;
746 previous = NULL;
747};
748
749/** Adds \a molecule leaf to the tree.
750 * \param *ptr ptr to molecule to be added
751 * \param *Previous previous MoleculeLeafClass referencing level and which on the level
752 * \return true - success, false - something went wrong
753 */
754bool MoleculeLeafClass::AddLeaf(molecule *ptr, MoleculeLeafClass *Previous)
755{
756 return false;
757};
[b8eb3a]758
759/** Fills the bond structure of this chain list subgraphs that are derived from a complete \a *reference molecule.
760 * Calls this routine in each MoleculeLeafClass::next subgraph if it's not NULL.
761 * \param *out output stream for debugging
762 * \param *reference reference molecule with the bond structure to be copied
763 * \param &FragmentCounter Counter needed to address \a **ListOfLocalAtoms
764 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
765 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
766 * \return true - success, false - faoilure
767 */
768bool MoleculeLeafClass::FillBondStructureFromReference(ofstream *out, molecule *reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
769{
770 atom *Walker = NULL, *OtherWalker = NULL;
771 bond *Binder = NULL;
772 bool status = true;
773 int AtomNo;
774
[372c4cd]775 *out << Verbose(1) << "Begin of FillBondStructureFromReference." << endl;
[84e88a]776 // fill ListOfLocalAtoms if NULL was given
777 if (!FillListOfLocalAtoms(out, ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
778 *out << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
779 return false;
[b8eb3a]780 }
[c830e8e]781
[b8eb3a]782 if (status) {
[c830e8e]783 *out << Verbose(1) << "Creating adjacency list for subgraph " << this
784 << "." << endl;
[b8eb3a]785 Walker = Leaf->start;
786 while (Walker->next != Leaf->end) {
787 Walker = Walker->next;
[c830e8e]788 AtomNo = Walker->GetTrueFather()->nr; // global id of the current walker
789 for (int i = 0; i < reference->NumberOfBondsPerAtom[AtomNo]; i++) { // go through father's bonds and copy them all
[b8eb3a]790 Binder = reference->ListOfBondsPerAtom[AtomNo][i];
[c830e8e]791 OtherWalker = ListOfLocalAtoms[FragmentCounter][Binder->GetOtherAtom(Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker
[b8eb3a]792 if (OtherWalker != NULL) {
793 if (OtherWalker->nr > Walker->nr)
[c830e8e]794 Leaf->AddBond(Walker, OtherWalker, Binder->BondDegree);
[b8eb3a]795 } else {
[5a78f5]796 *out << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << Binder->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl;
[b8eb3a]797 status = false;
798 }
799 }
800 }
801 Leaf->CreateListOfBondsPerAtom(out);
802 FragmentCounter++;
803 if (next != NULL)
804 status = next->FillBondStructureFromReference(out, reference, FragmentCounter, ListOfLocalAtoms);
[372c4cd]805 FragmentCounter--;
[b8eb3a]806 }
[c830e8e]807
[372c4cd]808 if ((FreeList) && (ListOfLocalAtoms != NULL)) {
[b8eb3a]809 // free the index lookup list
[c830e8e]810 Free((void **) &ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::FillBondStructureFromReference - **ListOfLocalAtoms[]");
[5a78f5]811 if (FragmentCounter == 0) // first fragments frees the initial pointer to list
[c830e8e]812 Free((void **) &ListOfLocalAtoms, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms");
[b8eb3a]813 }
[255d13]814 FragmentCounter--;
[372c4cd]815 *out << Verbose(1) << "End of FillBondStructureFromReference." << endl;
[b8eb3a]816 return status;
817};
818
[255d13]819/** Fills the root stack for sites to be used as root in fragmentation depending on order or adaptivity criteria
820 * Again, as in \sa FillBondStructureFromReference steps recursively through each Leaf in this chain list of molecule's.
821 * \param *out output stream for debugging
822 * \param *&RootStack stack to be filled
[a3ff7b2]823 * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site
[255d13]824 * \param &FragmentCounter counts through the fragments in this MoleculeLeafClass
825 * \return true - stack is non-empty, fragmentation necessary, false - stack is empty, no more sites to update
826 */
[c830e8e]827bool MoleculeLeafClass::FillRootStackForSubgraphs(ofstream *out,
828 KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
[255d13]829{
[a3ff7b2]830 atom *Walker = NULL, *Father = NULL;
[255d13]831
832 if (RootStack != NULL) {
[c830e8e]833 // find first root candidates
[2700f5e]834 if (&(RootStack[FragmentCounter]) != NULL) {
[c830e8e]835 RootStack[FragmentCounter].clear();
[2700f5e]836 Walker = Leaf->start;
837 while (Walker->next != Leaf->end) { // go through all (non-hydrogen) atoms
838 Walker = Walker->next;
839 Father = Walker->GetTrueFather();
840 if (AtomMask[Father->nr]) // apply mask
[c830e8e]841#ifdef ADDHYDROGEN
[2700f5e]842 if (Walker->type->Z != 1) // skip hydrogen
[c830e8e]843#endif
844 RootStack[FragmentCounter].push_front(Walker->nr);
[84e88a]845 }
[2700f5e]846 if (next != NULL)
847 next->FillRootStackForSubgraphs(out, RootStack, AtomMask, ++FragmentCounter);
[c830e8e]848 } else {
849 *out << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl;
[2700f5e]850 return false;
[255d13]851 }
[84e88a]852 FragmentCounter--;
[255d13]853 return true;
[84e88a]854 } else {
855 *out << Verbose(1) << "Rootstack is NULL." << endl;
[255d13]856 return false;
[84e88a]857 }
858};
859
860/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
861 * \param *out output stream fro debugging
862 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
[5a78f5]863 * \param FragmentCounter counts the fragments as we move along the list
[84e88a]864 * \param GlobalAtomCount number of atoms in the complete molecule
865 * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
866 * \return true - succes, false - failure
867 */
[5a78f5]868bool MoleculeLeafClass::FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList)
[84e88a]869{
870 bool status = true;
[c830e8e]871
[84e88a]872 int Counter = Count();
873 if (ListOfLocalAtoms == NULL) { // allocated initial pointer
874 // allocate and set each field to NULL
[c830e8e]875 ListOfLocalAtoms = (atom ***) Malloc(sizeof(atom **) * Counter, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms");
[84e88a]876 if (ListOfLocalAtoms != NULL) {
[c830e8e]877 for (int i = Counter; i--;)
[84e88a]878 ListOfLocalAtoms[i] = NULL;
879 FreeList = FreeList && true;
880 } else
881 status = false;
882 }
[c830e8e]883
[84e88a]884 if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
885 status = status && CreateFatherLookupTable(out, Leaf->start, Leaf->end, ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
886 FreeList = FreeList && true;
887 }
[c830e8e]888
[84e88a]889 return status;
890};
891
892/** The indices per keyset are compared to the respective father's Atom::nr in each subgraph and thus put into \a **&FragmentList.
893 * \param *out output stream fro debugging
894 * \param *reference reference molecule with the bond structure to be copied
895 * \param *KeySetList list with all keysets
896 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
897 * \param **&FragmentList list to be allocated and returned
898 * \param &FragmentCounter counts the fragments as we move along the list
899 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
900 * \retuen true - success, false - failure
901 */
[c830e8e]902bool MoleculeLeafClass::AssignKeySetsToFragment(ofstream *out,
903 molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms,
904 Graph **&FragmentList, int &FragmentCounter, bool FreeList)
[84e88a]905{
906 bool status = true;
907 int KeySetCounter = 0;
[c830e8e]908
[372c4cd]909 *out << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl;
[84e88a]910 // fill ListOfLocalAtoms if NULL was given
911 if (!FillListOfLocalAtoms(out, ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
912 *out << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
913 return false;
914 }
915
916 // allocate fragment list
917 if (FragmentList == NULL) {
918 KeySetCounter = Count();
[c830e8e]919 FragmentList = (Graph **) Malloc(sizeof(Graph *) * KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList");
920 for (int i = KeySetCounter; i--;)
[84e88a]921 FragmentList[i] = NULL;
922 KeySetCounter = 0;
923 }
[c830e8e]924
[84e88a]925 if ((KeySetList != NULL) && (KeySetList->size() != 0)) { // if there are some scanned keysets at all
926 // assign scanned keysets
927 if (FragmentList[FragmentCounter] == NULL)
928 FragmentList[FragmentCounter] = new Graph;
929 KeySet *TempSet = new KeySet;
[c830e8e]930 for (Graph::iterator runner = KeySetList->begin(); runner != KeySetList->end(); runner++) { // key sets contain global numbers!
931 if (ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->nr] != NULL) {// as we may assume that that bond structure is unchanged, we only test the first key in each set
[84e88a]932 // translate keyset to local numbers
[c830e8e]933 for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
[84e88a]934 TempSet->insert(ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*sprinter)->nr]->nr);
935 // insert into FragmentList
[c830e8e]936 FragmentList[FragmentCounter]->insert(GraphPair(*TempSet, pair<int, double> (KeySetCounter++, (*runner).second.second)));
[84e88a]937 }
938 TempSet->clear();
939 }
[c830e8e]940 delete (TempSet);
[84e88a]941 if (KeySetCounter == 0) {// if there are no keysets, delete the list
942 *out << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl;
[c830e8e]943 delete (FragmentList[FragmentCounter]);
[84e88a]944 } else
945 *out << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl;
946 FragmentCounter++;
947 if (next != NULL)
948 next->AssignKeySetsToFragment(out, reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList);
[372c4cd]949 FragmentCounter--;
[84e88a]950 } else
951 *out << Verbose(1) << "KeySetList is NULL or empty." << endl;
[c830e8e]952
[372c4cd]953 if ((FreeList) && (ListOfLocalAtoms != NULL)) {
[5a78f5]954 // free the index lookup list
[c830e8e]955 Free((void **) &ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::AssignKeySetsToFragment - **ListOfLocalAtoms[]");
[5a78f5]956 if (FragmentCounter == 0) // first fragments frees the initial pointer to list
[c830e8e]957 Free((void **) &ListOfLocalAtoms, "MoleculeLeafClass::AssignKeySetsToFragment - ***ListOfLocalAtoms");
[5a78f5]958 }
[372c4cd]959 *out << Verbose(1) << "End of AssignKeySetsToFragment." << endl;
[84e88a]960 return status;
[255d13]961};
[b8eb3a]962
[2b79c3]963/** Translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)
964 * \param *out output stream for debugging
965 * \param **FragmentList Graph with local numbers per fragment
966 * \param &FragmentCounter counts the fragments as we move along the list
967 * \param &TotalNumberOfKeySets global key set counter
968 * \param &TotalGraph Graph to be filled with global numbers
[c830e8e]969 */
970void MoleculeLeafClass::TranslateIndicesToGlobalIDs(ofstream *out,
971 Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets,
972 Graph &TotalGraph)
[2b79c3]973{
[644ba1]974 *out << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl;
[2b79c3]975 KeySet *TempSet = new KeySet;
[2700f5e]976 if (FragmentList[FragmentCounter] != NULL) {
[c830e8e]977 for (Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {
978 for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
[2700f5e]979 TempSet->insert((Leaf->FindAtom(*sprinter))->GetTrueFather()->nr);
[c830e8e]980 TotalGraph.insert(GraphPair(*TempSet, pair<int, double> (TotalNumberOfKeySets++, (*runner).second.second)));
[2700f5e]981 TempSet->clear();
982 }
[c830e8e]983 delete (TempSet);
[2700f5e]984 } else {
985 *out << Verbose(1) << "FragmentList is NULL." << endl;
[2b79c3]986 }
987 if (next != NULL)
988 next->TranslateIndicesToGlobalIDs(out, FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
989 FragmentCounter--;
[644ba1]990 *out << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl;
[2b79c3]991};
992
[255d13]993/** Simply counts the number of items in the list, from given MoleculeLeafClass.
994 * \return number of items
995 */
[84e88a]996int MoleculeLeafClass::Count() const
[255d13]997{
998 if (next != NULL)
[c830e8e]999 return next->Count() + 1;
[255d13]1000 else
[c830e8e]1001 return 1;
[255d13]1002};
[c830e8e]1003
Note: See TracBrowser for help on using the repository browser.