| [bcf653] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
| [0aa122] | 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| [94d5ac6] | 5 | * | 
|---|
|  | 6 | * | 
|---|
|  | 7 | *   This file is part of MoleCuilder. | 
|---|
|  | 8 | * | 
|---|
|  | 9 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
|  | 10 | *    it under the terms of the GNU General Public License as published by | 
|---|
|  | 11 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
|  | 12 | *    (at your option) any later version. | 
|---|
|  | 13 | * | 
|---|
|  | 14 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
|  | 15 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 16 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 17 | *    GNU General Public License for more details. | 
|---|
|  | 18 | * | 
|---|
|  | 19 | *    You should have received a copy of the GNU General Public License | 
|---|
|  | 20 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| [bcf653] | 21 | */ | 
|---|
|  | 22 |  | 
|---|
| [dcea0f] | 23 | /* | 
|---|
|  | 24 | * LinkedCellUnitTest.cpp | 
|---|
|  | 25 | * | 
|---|
|  | 26 | *  Created on: Apr 9, 2010 | 
|---|
|  | 27 | *      Author: heber | 
|---|
|  | 28 | */ | 
|---|
|  | 29 |  | 
|---|
| [bf3817] | 30 | // include config.h | 
|---|
|  | 31 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 32 | #include <config.h> | 
|---|
|  | 33 | #endif | 
|---|
|  | 34 |  | 
|---|
| [dcea0f] | 35 | using namespace std; | 
|---|
|  | 36 |  | 
|---|
|  | 37 | #include <cppunit/CompilerOutputter.h> | 
|---|
|  | 38 | #include <cppunit/extensions/TestFactoryRegistry.h> | 
|---|
|  | 39 | #include <cppunit/ui/text/TestRunner.h> | 
|---|
|  | 40 |  | 
|---|
|  | 41 | #include <iostream> | 
|---|
|  | 42 | #include <stdio.h> | 
|---|
|  | 43 | #include <cstring> | 
|---|
|  | 44 |  | 
|---|
| [6f0841] | 45 | #include "Atom/atom.hpp" | 
|---|
| [b136f6] | 46 | #include "CodePatterns/Assert.hpp" | 
|---|
| [34c43a] | 47 | #include "Descriptors/MoleculeDescriptor.hpp" | 
|---|
| [3bdb6d] | 48 | #include "Element/element.hpp" | 
|---|
|  | 49 | #include "Element/periodentafel.hpp" | 
|---|
| [53c7fc] | 50 | #include "LinkedCell/linkedcell.hpp" | 
|---|
|  | 51 | #include "LinkedCell/PointCloudAdaptor.hpp" | 
|---|
|  | 52 | #include "molecule.hpp" | 
|---|
| [5f612ee] | 53 | #include "World.hpp" | 
|---|
|  | 54 |  | 
|---|
| [91f592] | 55 | #include "linkedcellUnitTest.hpp" | 
|---|
| [f844ef] | 56 |  | 
|---|
| [5f612ee] | 57 | #ifdef HAVE_TESTRUNNER | 
|---|
|  | 58 | #include "UnitTestMain.hpp" | 
|---|
|  | 59 | #endif /*HAVE_TESTRUNNER*/ | 
|---|
| [dcea0f] | 60 |  | 
|---|
|  | 61 | /********************************************** Test classes **************************************/ | 
|---|
|  | 62 |  | 
|---|
|  | 63 | // Registers the fixture into the 'registry' | 
|---|
| [91f592] | 64 | CPPUNIT_TEST_SUITE_REGISTRATION( linkedcelltest ); | 
|---|
| [dcea0f] | 65 |  | 
|---|
|  | 66 |  | 
|---|
| [91f592] | 67 | void linkedcelltest::setUp() | 
|---|
| [dcea0f] | 68 | { | 
|---|
| [b136f6] | 69 | // failing asserts should be thrown | 
|---|
|  | 70 | ASSERT_DO(Assert::Throw); | 
|---|
|  | 71 |  | 
|---|
| [dcea0f] | 72 | atom *Walker = NULL; | 
|---|
|  | 73 |  | 
|---|
|  | 74 | // construct element | 
|---|
| [4eb4fe] | 75 | hydrogen = World::getInstance().getPeriode()->FindElement(1); | 
|---|
|  | 76 | CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); | 
|---|
| [dcea0f] | 77 |  | 
|---|
|  | 78 | // construct molecule (water molecule) | 
|---|
| [5f612ee] | 79 | TestMolecule = World::getInstance().createMolecule(); | 
|---|
| [4eb4fe] | 80 | CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); | 
|---|
| [4f9e47] | 81 | for (double x=0.5;x<3;x+=1.) | 
|---|
|  | 82 | for (double y=0.5;y<3;y+=1.) | 
|---|
|  | 83 | for (double z=0.5;z<3;z+=1.) { | 
|---|
| [5f612ee] | 84 | Walker = World::getInstance().createAtom(); | 
|---|
| [4eb4fe] | 85 | CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); | 
|---|
| [d74077] | 86 | Walker->setType(hydrogen); | 
|---|
|  | 87 | Walker->setPosition(Vector(x, y, z )); | 
|---|
| [4f9e47] | 88 | TestMolecule->AddAtom(Walker); | 
|---|
|  | 89 | } | 
|---|
|  | 90 |  | 
|---|
|  | 91 | // construct linked cell | 
|---|
| [caa06ef] | 92 | PointCloudAdaptor<molecule> cloud(TestMolecule, TestMolecule->name); | 
|---|
| [6bd7e0] | 93 | LC = new LinkedCell_deprecated (cloud, 1.); | 
|---|
| [4eb4fe] | 94 | CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell"); | 
|---|
| [dcea0f] | 95 |  | 
|---|
|  | 96 | // check that TestMolecule was correctly constructed | 
|---|
| [a7b761b] | 97 | CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 ); | 
|---|
| [dcea0f] | 98 | }; | 
|---|
|  | 99 |  | 
|---|
|  | 100 |  | 
|---|
| [91f592] | 101 | void linkedcelltest::tearDown() | 
|---|
| [dcea0f] | 102 | { | 
|---|
|  | 103 | delete(LC); | 
|---|
| [5f612ee] | 104 | World::purgeInstance(); | 
|---|
| [dcea0f] | 105 | }; | 
|---|
|  | 106 |  | 
|---|
|  | 107 |  | 
|---|
| [6bd7e0] | 108 | /** UnitTest for LinkedCell_deprecated::CheckBounds(). | 
|---|
| [4f9e47] | 109 | */ | 
|---|
| [91f592] | 110 | void linkedcelltest::CheckBoundsTest() | 
|---|
| [4f9e47] | 111 | { | 
|---|
|  | 112 | // check for within bounds | 
|---|
|  | 113 | LC->n[0] = LC->n[1] = LC->n[2] = 0; | 
|---|
|  | 114 | CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() ); | 
|---|
|  | 115 | LC->n[0] = LC->n[1] = LC->n[2] = 1; | 
|---|
|  | 116 | CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() ); | 
|---|
|  | 117 | LC->n[0] = LC->n[1] = LC->n[2] = 2; | 
|---|
|  | 118 | CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() ); | 
|---|
|  | 119 |  | 
|---|
|  | 120 | // check for out of bounds | 
|---|
|  | 121 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
|  | 122 | LC->n[0] = 404040; | 
|---|
|  | 123 | CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() ); | 
|---|
|  | 124 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
|  | 125 | LC->n[0] = 0; | 
|---|
|  | 126 | LC->n[1] = 5000; | 
|---|
|  | 127 | CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() ); | 
|---|
|  | 128 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
|  | 129 | LC->n[1] = 0; | 
|---|
|  | 130 | LC->n[2] = -70; | 
|---|
|  | 131 | CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() ); | 
|---|
|  | 132 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
|  | 133 | LC->n[0] = LC->n[1] = LC->n[2] = 3; | 
|---|
|  | 134 | CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() ); | 
|---|
|  | 135 | }; | 
|---|
|  | 136 |  | 
|---|
|  | 137 |  | 
|---|
| [6bd7e0] | 138 | /** UnitTest for LinkedCell_deprecated::GetCurrentCell(). | 
|---|
| [4f9e47] | 139 | * Note that CheckBounds() is used and has to be tested already. | 
|---|
| [dcea0f] | 140 | */ | 
|---|
| [91f592] | 141 | void linkedcelltest::GetCurrentCellTest() | 
|---|
| [dcea0f] | 142 | { | 
|---|
| [4f9e47] | 143 | // within bounds | 
|---|
|  | 144 | LC->n[0] = LC->n[1] = LC->n[2] = 0; | 
|---|
| [34c43a] | 145 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0 * 3*3 + 0 * 3 + 0], LC->GetCurrentCell() ); | 
|---|
| [4f9e47] | 146 | LC->n[0] = LC->n[1] = LC->n[2] = 1; | 
|---|
| [34c43a] | 147 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[1 * 3*3 + 1 * 3 + 1], LC->GetCurrentCell() ); | 
|---|
| [4f9e47] | 148 | LC->n[0] = LC->n[1] = LC->n[2] = 2; | 
|---|
| [34c43a] | 149 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetCurrentCell() ); | 
|---|
| [4f9e47] | 150 |  | 
|---|
|  | 151 | // out of bounds | 
|---|
|  | 152 | LC->n[0] = LC->n[1] = LC->n[2] = 3; | 
|---|
|  | 153 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 154 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetCurrentCell() ); | 
|---|
| [4f9e47] | 155 | LC->n[0] = LC->n[1] = LC->n[2] = -1; | 
|---|
|  | 156 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 157 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetCurrentCell() ); | 
|---|
| [dcea0f] | 158 | }; | 
|---|
|  | 159 |  | 
|---|
| [6bd7e0] | 160 | /** UnitTest for LinkedCell_deprecated::GetRelativeToCurrentCell(). | 
|---|
| [dcea0f] | 161 | */ | 
|---|
| [91f592] | 162 | void linkedcelltest::GetRelativeToCurrentCellTest() | 
|---|
| [dcea0f] | 163 | { | 
|---|
| [4f9e47] | 164 | int offset[3]; | 
|---|
|  | 165 |  | 
|---|
|  | 166 | // offset to (0,0,0) always | 
|---|
|  | 167 | offset[0] = offset[1] = offset[2] = 0; | 
|---|
|  | 168 | LC->n[0] = LC->n[1] = LC->n[2] = 0; | 
|---|
| [34c43a] | 169 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 170 | offset[0] = offset[1] = offset[2] = -1; | 
|---|
|  | 171 | LC->n[0] = LC->n[1] = LC->n[2] = 1; | 
|---|
| [34c43a] | 172 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 173 | offset[0] = offset[1] = offset[2] = -2; | 
|---|
|  | 174 | LC->n[0] = LC->n[1] = LC->n[2] = 2; | 
|---|
| [34c43a] | 175 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 176 |  | 
|---|
|  | 177 | // offset to (0,0,0) - 1.*(x/y/z) out of bounds | 
|---|
|  | 178 | offset[0] = offset[1] = offset[2] = 0; | 
|---|
|  | 179 | offset[0] = -1; | 
|---|
|  | 180 | LC->n[0] = LC->n[1] = LC->n[2] = 0; | 
|---|
|  | 181 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 182 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 183 | offset[0] = offset[1] = offset[2] = 0; | 
|---|
|  | 184 | offset[1] = -1; | 
|---|
|  | 185 | LC->n[0] = LC->n[1] = LC->n[2] = 0; | 
|---|
|  | 186 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 187 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 188 | offset[0] = offset[1] = offset[2] = 0; | 
|---|
|  | 189 | offset[2] = -1; | 
|---|
|  | 190 | LC->n[0] = LC->n[1] = LC->n[2] = 0; | 
|---|
|  | 191 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 192 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 193 |  | 
|---|
|  | 194 | // out of bounds | 
|---|
|  | 195 | offset[0] = offset[1] = offset[2] = -5054932; | 
|---|
|  | 196 | LC->n[0] = LC->n[1] = LC->n[2] = 1; | 
|---|
|  | 197 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 198 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 199 | offset[0] = offset[1] = offset[2] = 192345; | 
|---|
|  | 200 | LC->n[0] = LC->n[1] = LC->n[2] = 1; | 
|---|
|  | 201 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 202 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 203 |  | 
|---|
|  | 204 | // index is out of bounds, offset points within | 
|---|
|  | 205 | offset[0] = offset[1] = offset[2] = -2; | 
|---|
|  | 206 | LC->n[0] = LC->n[1] = LC->n[2] = 4; | 
|---|
| [34c43a] | 207 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [4f9e47] | 208 |  | 
|---|
|  | 209 | // index is within bounds, offset points out | 
|---|
|  | 210 | offset[0] = offset[1] = offset[2] = 2; | 
|---|
|  | 211 | LC->n[0] = LC->n[1] = LC->n[2] = 2; | 
|---|
|  | 212 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [34c43a] | 213 | CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) ); | 
|---|
| [dcea0f] | 214 | }; | 
|---|
|  | 215 |  | 
|---|
|  | 216 |  | 
|---|
| [6bd7e0] | 217 | /** UnitTest for LinkedCell_deprecated::SetIndexToNode(). | 
|---|
| [dcea0f] | 218 | */ | 
|---|
| [91f592] | 219 | void linkedcelltest::SetIndexToNodeTest() | 
|---|
| [dcea0f] | 220 | { | 
|---|
| [4f9e47] | 221 | // check all atoms | 
|---|
| [a7b761b] | 222 | for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end();++iter){ | 
|---|
|  | 223 | CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(*iter) ); | 
|---|
| [4f9e47] | 224 | } | 
|---|
|  | 225 |  | 
|---|
|  | 226 | // check internal vectors, returns false, because this atom is not in LC-list! | 
|---|
| [a7b761b] | 227 | atom *newAtom = World::getInstance().createAtom(); | 
|---|
|  | 228 | newAtom->setName("test"); | 
|---|
| [d74077] | 229 | newAtom->setPosition(Vector(1,1,1)); | 
|---|
| [a7b761b] | 230 | CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); | 
|---|
|  | 231 | World::getInstance().destroyAtom(newAtom); | 
|---|
| [4f9e47] | 232 |  | 
|---|
|  | 233 | // check out of bounds vectors | 
|---|
| [a7b761b] | 234 | newAtom = World::getInstance().createAtom(); | 
|---|
|  | 235 | newAtom->setName("test"); | 
|---|
| [d74077] | 236 | newAtom->setPosition(Vector(0,-1,0)); | 
|---|
| [a7b761b] | 237 | CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); | 
|---|
|  | 238 | World::getInstance().destroyAtom(newAtom); | 
|---|
| [dcea0f] | 239 | }; | 
|---|
|  | 240 |  | 
|---|
|  | 241 |  | 
|---|
| [6bd7e0] | 242 | /** UnitTest for LinkedCell_deprecated::SetIndexToVector(). | 
|---|
| [dcea0f] | 243 | */ | 
|---|
| [91f592] | 244 | void linkedcelltest::SetIndexToVectorTest() | 
|---|
| [dcea0f] | 245 | { | 
|---|
| [4f9e47] | 246 | Vector tester; | 
|---|
|  | 247 |  | 
|---|
|  | 248 | // check center of each cell | 
|---|
|  | 249 | for (double x=0.5;x<3;x+=1.) | 
|---|
|  | 250 | for (double y=0.5;y<3;y+=1.) | 
|---|
|  | 251 | for (double z=0.5;z<3;z+=1.) { | 
|---|
| [8cbb97] | 252 | tester = Vector(x,y,z); | 
|---|
| [d74077] | 253 | CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 254 | } | 
|---|
|  | 255 | // check corners of each cell | 
|---|
|  | 256 | for (double x=1.;x<4;x+=1.) | 
|---|
|  | 257 | for (double y=1.;y<4;y+=1.) | 
|---|
|  | 258 | for (double z=1.;z<4;z+=1.) { | 
|---|
| [8cbb97] | 259 | tester= Vector(x,y,z); | 
|---|
| [4f9e47] | 260 | cout << "Tester is at " << tester << "." << endl; | 
|---|
| [d74077] | 261 | CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 262 | } | 
|---|
|  | 263 | // check out of bounds | 
|---|
|  | 264 | for (double x=0.5-1e-10;x<5;x+=3.1) | 
|---|
|  | 265 | for (double y=0.5-1e-10;y<5;y+=3.1) | 
|---|
|  | 266 | for (double z=0.5-1e-10;z<5;z+=3.1) { | 
|---|
| [8cbb97] | 267 | tester = Vector(x,y,z); | 
|---|
| [4f9e47] | 268 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [d74077] | 269 | CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 270 | } | 
|---|
|  | 271 | // check nonsense vectors | 
|---|
| [8cbb97] | 272 | tester= Vector(-423598,3245978,29349); | 
|---|
| [4f9e47] | 273 | cout << "The following test is supposed to fail and produce an ERROR." << endl; | 
|---|
| [d74077] | 274 | CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); | 
|---|
| [dcea0f] | 275 | }; | 
|---|
|  | 276 |  | 
|---|
|  | 277 |  | 
|---|
| [6bd7e0] | 278 | /** UnitTest for LinkedCell_deprecated::GetNeighbourBounds(). | 
|---|
| [dcea0f] | 279 | */ | 
|---|
| [91f592] | 280 | void linkedcelltest::GetNeighbourBoundsTest() | 
|---|
| [dcea0f] | 281 | { | 
|---|
| [4f9e47] | 282 | Vector tester; | 
|---|
|  | 283 | int lower[NDIM], upper[NDIM]; | 
|---|
|  | 284 |  | 
|---|
| [8cbb97] | 285 | tester= Vector(0.5,0.5,0.5); | 
|---|
| [d74077] | 286 | LC->SetIndexToVector(tester); | 
|---|
| [4f9e47] | 287 | LC->GetNeighbourBounds(lower, upper); | 
|---|
|  | 288 | for (int i=0;i<NDIM;i++) | 
|---|
|  | 289 | CPPUNIT_ASSERT_EQUAL( 0, lower[i]); | 
|---|
|  | 290 | for (int i=0;i<NDIM;i++) | 
|---|
|  | 291 | CPPUNIT_ASSERT_EQUAL( 1, upper[i]); | 
|---|
| [dcea0f] | 292 | }; | 
|---|
|  | 293 |  | 
|---|
|  | 294 |  | 
|---|
| [6bd7e0] | 295 | /** UnitTest for LinkedCell_deprecated::GetallNeighbours(). | 
|---|
| [dcea0f] | 296 | */ | 
|---|
| [91f592] | 297 | void linkedcelltest::GetallNeighboursTest() | 
|---|
| [dcea0f] | 298 | { | 
|---|
| [4f9e47] | 299 | Vector tester; | 
|---|
| [34c43a] | 300 | TesselPointSTLList *ListOfPoints = NULL; | 
|---|
| [4f9e47] | 301 | size_t size = 0; | 
|---|
|  | 302 |  | 
|---|
|  | 303 | // get all atoms | 
|---|
| [8cbb97] | 304 | tester= Vector(1.5,1.5,1.5); | 
|---|
| [d74077] | 305 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 306 | ListOfPoints = LC->GetallNeighbours(); | 
|---|
|  | 307 | size = ListOfPoints->size(); | 
|---|
|  | 308 | CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); | 
|---|
| [a7b761b] | 309 |  | 
|---|
|  | 310 | for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ | 
|---|
|  | 311 | ListOfPoints->remove((*iter)); | 
|---|
| [4f9e47] | 312 | size--; | 
|---|
|  | 313 | CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); | 
|---|
|  | 314 | } | 
|---|
|  | 315 | CPPUNIT_ASSERT_EQUAL( (size_t)0, size ); | 
|---|
|  | 316 | CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() ); | 
|---|
|  | 317 | CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() ); | 
|---|
|  | 318 | delete(ListOfPoints); | 
|---|
|  | 319 |  | 
|---|
|  | 320 | // get all atoms in one corner | 
|---|
| [8cbb97] | 321 | tester= Vector(0.5, 0.5, 0.5); | 
|---|
| [d74077] | 322 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 323 | ListOfPoints = LC->GetallNeighbours(); | 
|---|
|  | 324 | size=ListOfPoints->size(); | 
|---|
|  | 325 | CPPUNIT_ASSERT_EQUAL( (size_t)8, size ); | 
|---|
| [a7b761b] | 326 | for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ | 
|---|
| [d74077] | 327 | if (((*iter)->at(0) <2) && ((*iter)->at(1) <2) && ((*iter)->at(2) <2)) { | 
|---|
| [a7b761b] | 328 | ListOfPoints->remove(*iter); | 
|---|
| [4f9e47] | 329 | size--; | 
|---|
|  | 330 | CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); | 
|---|
|  | 331 | } | 
|---|
|  | 332 | } | 
|---|
|  | 333 | CPPUNIT_ASSERT_EQUAL( (size_t)0, size ); | 
|---|
|  | 334 | CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() ); | 
|---|
|  | 335 | CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() ); | 
|---|
|  | 336 | delete(ListOfPoints); | 
|---|
|  | 337 |  | 
|---|
|  | 338 | // get all atoms from one corner | 
|---|
| [8cbb97] | 339 | tester = Vector(0.5, 0.5, 0.5); | 
|---|
| [d74077] | 340 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 341 | ListOfPoints = LC->GetallNeighbours(3); | 
|---|
|  | 342 | size=ListOfPoints->size(); | 
|---|
|  | 343 | CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); | 
|---|
| [a7b761b] | 344 | for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ | 
|---|
|  | 345 | ListOfPoints->remove(*iter); | 
|---|
| [4f9e47] | 346 | size--; | 
|---|
|  | 347 | CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); | 
|---|
|  | 348 | } | 
|---|
|  | 349 | CPPUNIT_ASSERT_EQUAL( (size_t)0, size ); | 
|---|
|  | 350 | CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() ); | 
|---|
|  | 351 | CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() ); | 
|---|
|  | 352 | delete(ListOfPoints); | 
|---|
| [dcea0f] | 353 | }; | 
|---|
|  | 354 |  | 
|---|
|  | 355 |  | 
|---|
| [6bd7e0] | 356 | /** UnitTest for LinkedCell_deprecated::GetPointsInsideSphere(). | 
|---|
| [dcea0f] | 357 | */ | 
|---|
| [91f592] | 358 | void linkedcelltest::GetPointsInsideSphereTest() | 
|---|
| [dcea0f] | 359 | { | 
|---|
| [4f9e47] | 360 | Vector tester; | 
|---|
| [34c43a] | 361 | TesselPointSTLList *ListOfPoints = NULL; | 
|---|
| [4f9e47] | 362 | size_t size = 0; | 
|---|
|  | 363 |  | 
|---|
|  | 364 | // get all points around central arom with radius 1. | 
|---|
| [8cbb97] | 365 | tester= Vector(1.5,1.5,1.5); | 
|---|
| [d74077] | 366 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 367 | ListOfPoints = LC->GetPointsInsideSphere(1., &tester); | 
|---|
|  | 368 | size = ListOfPoints->size(); | 
|---|
|  | 369 | CPPUNIT_ASSERT_EQUAL( (size_t)7, size ); | 
|---|
| [a7b761b] | 370 | for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ | 
|---|
| [d74077] | 371 | if (((*iter)->DistanceSquared(tester) - 1.) < MYEPSILON ) { | 
|---|
| [a7b761b] | 372 | ListOfPoints->remove(*iter); | 
|---|
| [4f9e47] | 373 | size--; | 
|---|
|  | 374 | CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); | 
|---|
|  | 375 | } | 
|---|
|  | 376 | } | 
|---|
|  | 377 | CPPUNIT_ASSERT_EQUAL( (size_t)0, size ); | 
|---|
|  | 378 | CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() ); | 
|---|
|  | 379 | CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() ); | 
|---|
| [052c10] | 380 | delete ListOfPoints; | 
|---|
| [dcea0f] | 381 | }; | 
|---|