source: src/unittests/BoxUnitTest.cpp@ 712886

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 712886 was 712886, checked in by Frederik Heber <heber@…>, 13 years ago

Renamed Box::WrapPeriodically -> ::enforceBoundaryConditions.

  • Property mode set to 100644
File size: 78.9 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * BoxUnitTest.cpp
10 *
11 * Created on: Jul 30, 2010
12 * Author: crueger
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <cppunit/CompilerOutputter.h>
21#include <cppunit/extensions/TestFactoryRegistry.h>
22#include <cppunit/ui/text/TestRunner.h>
23
24#include "LinearAlgebra/Vector.hpp"
25#include "LinearAlgebra/RealSpaceMatrix.hpp"
26#include "Box.hpp"
27#include "CodePatterns/Assert.hpp"
28
29#include "BoxUnitTest.hpp"
30
31#include "stubs/ObserverStub.hpp"
32
33#ifdef HAVE_TESTRUNNER
34#include "UnitTestMain.hpp"
35#endif /*HAVE_TESTRUNNER*/
36
37/********************************************** Test classes **************************************/
38
39// Registers the fixture into the 'registry'
40CPPUNIT_TEST_SUITE_REGISTRATION( BoxUnittest );
41
42void BoxUnittest::setUp(){
43 // failing asserts should be thrown
44 ASSERT_DO(Assert::Throw);
45
46 unit = new RealSpaceMatrix;
47 unit->setIdentity();
48 zero = new RealSpaceMatrix;
49 invertible = new RealSpaceMatrix;
50 invertible->diagonal() = Vector(1,2,3);
51 uninvertible = new RealSpaceMatrix;
52 uninvertible->column(0) = Vector(1,0,1);
53 uninvertible->column(2) = Vector(1,0,1);
54
55 RealSpaceMatrix boxMat;
56 unitBox = new Box;
57 stretchedBox1 = new Box;
58 boxMat.setIdentity();
59 boxMat.diagonal() = Vector(1,2,3);
60 stretchedBox1->setM(boxMat);
61
62 stretchedBox2 = new Box;
63 boxMat.setIdentity();
64 boxMat.diagonal() = Vector(2,3,1);
65 stretchedBox2->setM(boxMat);
66
67 stretchedBox3 = new Box;
68 boxMat.setIdentity();
69 boxMat.diagonal() = Vector(3,1,2);
70 stretchedBox3->setM(boxMat);
71
72 stretchedBox4 = new Box;
73 boxMat.setIdentity();
74 boxMat.diagonal() = Vector(2,2,2);
75 stretchedBox4->setM(boxMat);
76
77 tiltedBox1 = new Box;
78 boxMat.setIdentity();
79 boxMat.column(0) = Vector(1,0,1);
80 tiltedBox1->setM(boxMat);
81
82 tiltedBox2 = new Box;
83 boxMat.setIdentity();
84 boxMat.column(0) = Vector(1,1,1);
85 tiltedBox2->setM(boxMat);
86
87 tiltedBox3 = new Box;
88 boxMat.setIdentity();
89 boxMat.column(1) = Vector(0,1,1);
90 tiltedBox3->setM(boxMat);
91
92 tiltedBox4 = new Box;
93 boxMat.setIdentity();
94 boxMat.column(0) = Vector(1,1,1);
95 boxMat.column(1) = Vector(0,1,1);
96 tiltedBox4->setM(boxMat);
97
98}
99
100void BoxUnittest::tearDown(){
101 delete unit;
102 delete zero;
103 delete invertible;
104 delete uninvertible;
105
106 delete unitBox;
107 delete stretchedBox1;
108 delete stretchedBox2;
109 delete stretchedBox3;
110 delete stretchedBox4;
111 delete tiltedBox1;
112 delete tiltedBox2;
113 delete tiltedBox3;
114 delete tiltedBox4;
115
116}
117
118void BoxUnittest::setBoxTest(){
119 Box testBox;
120 CPPUNIT_ASSERT_NO_THROW(testBox.setM(*unit));
121 CPPUNIT_ASSERT_NO_THROW(testBox = *unit);
122 CPPUNIT_ASSERT_NO_THROW(testBox.setM(*invertible));
123 CPPUNIT_ASSERT_NO_THROW(testBox = *invertible);
124#ifndef NDEBUG
125 CPPUNIT_ASSERT_THROW(testBox.setM(*zero),Assert::AssertionFailure);
126 CPPUNIT_ASSERT_THROW(testBox = *zero,Assert::AssertionFailure);
127 CPPUNIT_ASSERT_THROW(testBox.setM(*uninvertible),Assert::AssertionFailure);
128 CPPUNIT_ASSERT_THROW(testBox = *uninvertible,Assert::AssertionFailure);
129#endif
130}
131
132void BoxUnittest::translateInOutTest(){
133 Vector testVector;
134 {
135 testVector=Vector(0,0,0);
136 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
137 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
138 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
139 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
140 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
141 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
142 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
143 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
144 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
145 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
146 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
147 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
148 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
149 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
150 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
151 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
152 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
153 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
154 }
155
156 {
157 testVector=Vector(0.5,0.5,0.5);
158 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
159 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
160 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
161 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
162 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
163 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
164 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
165 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
166 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
167 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
168 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
169 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
170 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
171 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
172 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
173 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
174 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
175 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
176 }
177
178 {
179 testVector=Vector(1,1,1);
180 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
181 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
182 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
183 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
184 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
185 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
186 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
187 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
188 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
189 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
190 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
191 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
192 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
193 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
194 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
195 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
196 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
197 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
198 }
199
200 {
201 testVector=Vector(2,1,1);
202 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
203 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
204 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
205 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
206 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
207 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
208 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
209 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
210 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
211 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
212 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
213 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
214 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
215 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
216 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
217 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
218 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
219 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
220 }
221
222 {
223 testVector=Vector(1,2,1);
224 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
225 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
226 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
227 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
228 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
229 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
230 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
231 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
232 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
233 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
234 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
235 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
236 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
237 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
238 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
239 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
240 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
241 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
242 }
243
244 {
245 testVector=Vector(1,1,2);
246 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
247 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
248 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
249 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
250 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
251 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
252 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
253 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
254 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
255 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
256 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
257 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
258 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
259 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
260 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
261 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
262 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
263 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
264 }
265
266 {
267 testVector=Vector(3,1,1);
268 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
269 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
270 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
271 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
272 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
273 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
274 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
275 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
276 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
277 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
278 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
279 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
280 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
281 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
282 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
283 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
284 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
285 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
286 }
287
288 {
289 testVector=Vector(1,3,1);
290 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
291 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
292 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
293 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
294 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
295 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
296 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
297 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
298 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
299 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
300 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
301 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
302 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
303 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
304 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
305 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
306 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
307 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
308 }
309
310 {
311 testVector=Vector(1,1,3);
312 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
313 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
314 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
315 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
316 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
317 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
318 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
319 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
320 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
321 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
322 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
323 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
324 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
325 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
326 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
327 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
328 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
329 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
330 }
331
332 {
333 testVector=Vector(2,2,2);
334 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
335 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
336 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
337 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
338 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
339 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
340 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
341 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
342 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
343 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
344 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
345 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
346 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
347 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
348 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
349 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
350 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
351 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
352 }
353
354}
355
356void BoxUnittest::isInsideTest(){
357 Vector testVector(0,0,0);
358 CPPUNIT_ASSERT( unitBox->isInside(testVector));
359 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
360 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
361 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
362 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
363 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
364 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
365 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
366 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
367
368
369 testVector = Vector(0.5,0.5,0.5);
370 CPPUNIT_ASSERT( unitBox->isInside(testVector));
371 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
372 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
373 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
374 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
375 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
376 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
377 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
378 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
379
380 testVector = Vector(1,1,1);
381 CPPUNIT_ASSERT( unitBox->isInside(testVector));
382 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
383 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
384 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
385 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
386 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
387 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
388 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
389 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
390
391 testVector = Vector(2,1,1);
392 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
393 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
394 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
395 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
396 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
397 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
398 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
399 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
400 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
401
402 testVector = Vector(1,2,1);
403 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
404 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
405 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
406 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
407 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
408 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
409 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
410 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
411 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
412
413 testVector = Vector(1,1,2);
414 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
415 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
416 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
417 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
418 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
419 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
420 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
421 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
422 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
423
424 testVector = Vector(3,1,1);
425 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
426 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
427 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
428 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
429 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
430 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
431 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
432 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
433 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
434
435 testVector = Vector(1,3,1);
436 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
437 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
438 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
439 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
440 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
441 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
442 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
443 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
444 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
445
446 testVector = Vector(1,1,3);
447 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
448 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
449 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
450 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
451 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
452 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
453 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
454 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
455 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
456
457 testVector = Vector(2,2,2);
458 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
459 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
460 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
461 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
462 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
463 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
464 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
465 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
466 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
467
468 testVector = Vector(3,3,3);
469 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
470 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
471 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
472 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
473 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
474 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
475 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
476 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
477 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
478}
479
480bool testWrapExplode(VECTORSET(std::vector) &set,Vector &point, Box* box){
481 bool res = true;
482 Vector wrappedPoint = box->enforceBoundaryConditions(point);
483 for(std::vector<Vector>::iterator iter = set.begin(); iter!=set.end();++iter){
484 Vector wrapped = box->enforceBoundaryConditions(*iter);
485 bool equals = (wrapped == wrappedPoint);
486 res = res && equals;
487 if(!equals){
488 cout << "Wrapped vector " << wrapped << " produced from vector " << (*iter) << " does not match target " << wrappedPoint << endl;
489 }
490 }
491 return res;
492}
493
494void BoxUnittest::WrapExplodeTest(){
495 Vector testVector(0,0,0);
496 VECTORSET(std::vector) res;
497
498 // we only can explode those vectors that are actually inside the box
499 {
500 testVector = Vector(0,0,0);
501 res = unitBox->explode(testVector,1);
502 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
503 res = stretchedBox1->explode(testVector,1);
504 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
505 res = stretchedBox2->explode(testVector,1);
506 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
507 res = stretchedBox3->explode(testVector,1);
508 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
509 res = stretchedBox4->explode(testVector,1);
510 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
511 res = tiltedBox1->explode(testVector,1);
512 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
513 res = tiltedBox2->explode(testVector,1);
514 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
515 res = tiltedBox3->explode(testVector,1);
516 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
517 res = tiltedBox4->explode(testVector,1);
518 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
519 }
520
521 {
522 testVector = Vector(0.5,0.5,0.5);
523 res = unitBox->explode(testVector,1);
524 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
525 res = stretchedBox1->explode(testVector,1);
526 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
527 res = stretchedBox2->explode(testVector,1);
528 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
529 res = stretchedBox3->explode(testVector,1);
530 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
531 res = stretchedBox4->explode(testVector,1);
532 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
533 res = tiltedBox1->explode(testVector,1);
534 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
535 res = tiltedBox2->explode(testVector,1);
536 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
537 res = tiltedBox3->explode(testVector,1);
538 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
539 res = tiltedBox4->explode(testVector,1);
540 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
541 }
542
543 {
544 testVector = Vector(1,1,1);
545 res = unitBox->explode(testVector,1);
546 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
547 res = stretchedBox1->explode(testVector,1);
548 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
549 res = stretchedBox2->explode(testVector,1);
550 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
551 res = stretchedBox3->explode(testVector,1);
552 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
553 res = stretchedBox4->explode(testVector,1);
554 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
555 res = tiltedBox1->explode(testVector,1);
556 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
557 res = tiltedBox2->explode(testVector,1);
558 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
559 res = tiltedBox3->explode(testVector,1);
560 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
561 res = tiltedBox4->explode(testVector,1);
562 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
563 }
564
565 {
566 testVector = Vector(2,1,1);
567 res = stretchedBox2->explode(testVector,1);
568 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
569 res = stretchedBox3->explode(testVector,1);
570 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
571 res = stretchedBox4->explode(testVector,1);
572 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
573 }
574
575 {
576 testVector = Vector(1,2,1);
577 res = stretchedBox1->explode(testVector,1);
578 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
579 res = stretchedBox2->explode(testVector,1);
580 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
581 res = stretchedBox4->explode(testVector,1);
582 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
583 res = tiltedBox2->explode(testVector,1);
584 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
585 }
586
587 {
588 testVector = Vector(1,1,2);
589 res = stretchedBox1->explode(testVector,1);
590 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
591 res = stretchedBox3->explode(testVector,1);
592 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
593 res = stretchedBox4->explode(testVector,1);
594 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
595 res = tiltedBox1->explode(testVector,1);
596 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
597 res = tiltedBox2->explode(testVector,1);
598 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
599 res = tiltedBox3->explode(testVector,1);
600 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
601 res = tiltedBox4->explode(testVector,1);
602 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
603 }
604
605 {
606 testVector = Vector(3,1,1);
607 res = stretchedBox3->explode(testVector,1);
608 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
609 }
610
611 {
612 testVector = Vector(1,3,1);
613 res = stretchedBox2->explode(testVector,1);
614 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
615 }
616
617 {
618 testVector = Vector(1,1,3);
619 res = stretchedBox1->explode(testVector,1);
620 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
621 }
622
623 {
624 testVector = Vector(2,2,2);
625 res = stretchedBox4->explode(testVector,1);
626 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
627 }
628
629 // Higher level explosions
630
631 {
632 testVector = Vector(0,0,0);
633 res = unitBox->explode(testVector,2);
634 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
635 res = stretchedBox1->explode(testVector,2);
636 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
637 res = stretchedBox2->explode(testVector,2);
638 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
639 res = stretchedBox3->explode(testVector,2);
640 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
641 res = stretchedBox4->explode(testVector,2);
642 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
643 res = tiltedBox1->explode(testVector,2);
644 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
645 res = tiltedBox2->explode(testVector,2);
646 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
647 res = tiltedBox3->explode(testVector,2);
648 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
649 res = tiltedBox4->explode(testVector,2);
650 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
651 }
652
653 {
654 testVector = Vector(0.5,0.5,0.5);
655 res = unitBox->explode(testVector,2);
656 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
657 res = stretchedBox1->explode(testVector,2);
658 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
659 res = stretchedBox2->explode(testVector,2);
660 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
661 res = stretchedBox3->explode(testVector,2);
662 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
663 res = stretchedBox4->explode(testVector,2);
664 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
665 res = tiltedBox1->explode(testVector,2);
666 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
667 res = tiltedBox2->explode(testVector,2);
668 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
669 res = tiltedBox3->explode(testVector,2);
670 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
671 res = tiltedBox4->explode(testVector,2);
672 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
673 }
674
675 {
676 testVector = Vector(1,1,1);
677 res = unitBox->explode(testVector,2);
678 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
679 res = stretchedBox1->explode(testVector,2);
680 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
681 res = stretchedBox2->explode(testVector,2);
682 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
683 res = stretchedBox3->explode(testVector,2);
684 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
685 res = stretchedBox4->explode(testVector,2);
686 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
687 res = tiltedBox1->explode(testVector,2);
688 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
689 res = tiltedBox2->explode(testVector,2);
690 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
691 res = tiltedBox3->explode(testVector,2);
692 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
693 res = tiltedBox4->explode(testVector,2);
694 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
695 }
696
697 {
698 testVector = Vector(2,1,1);
699 res = stretchedBox2->explode(testVector,2);
700 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
701 res = stretchedBox3->explode(testVector,2);
702 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
703 res = stretchedBox4->explode(testVector,2);
704 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
705 }
706
707 {
708 testVector = Vector(1,2,1);
709 res = stretchedBox1->explode(testVector,2);
710 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
711 res = stretchedBox2->explode(testVector,2);
712 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
713 res = stretchedBox4->explode(testVector,2);
714 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
715 res = tiltedBox2->explode(testVector,2);
716 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
717 }
718
719 {
720 testVector = Vector(1,1,2);
721 res = stretchedBox1->explode(testVector,2);
722 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
723 res = stretchedBox3->explode(testVector,2);
724 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
725 res = stretchedBox4->explode(testVector,2);
726 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
727 res = tiltedBox1->explode(testVector,2);
728 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
729 res = tiltedBox2->explode(testVector,2);
730 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
731 res = tiltedBox3->explode(testVector,2);
732 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
733 res = tiltedBox4->explode(testVector,2);
734 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
735 }
736
737 {
738 testVector = Vector(3,1,1);
739 res = stretchedBox3->explode(testVector,2);
740 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
741 }
742
743 {
744 testVector = Vector(1,3,1);
745 res = stretchedBox2->explode(testVector,2);
746 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
747 }
748
749 {
750 testVector = Vector(1,1,3);
751 res = stretchedBox1->explode(testVector,2);
752 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
753 }
754
755 {
756 testVector = Vector(2,2,2);
757 res = stretchedBox4->explode(testVector,2);
758 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
759 }
760
761 // one more set of higher level explosions
762
763 {
764 testVector = Vector(0,0,0);
765 res = unitBox->explode(testVector,3);
766 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
767 res = stretchedBox1->explode(testVector,3);
768 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
769 res = stretchedBox2->explode(testVector,3);
770 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
771 res = stretchedBox3->explode(testVector,3);
772 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
773 res = stretchedBox4->explode(testVector,3);
774 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
775 res = tiltedBox1->explode(testVector,3);
776 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
777 res = tiltedBox2->explode(testVector,3);
778 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
779 res = tiltedBox3->explode(testVector,3);
780 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
781 res = tiltedBox4->explode(testVector,3);
782 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
783 }
784
785 {
786 testVector = Vector(0.5,0.5,0.5);
787 res = unitBox->explode(testVector,3);
788 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
789 res = stretchedBox1->explode(testVector,3);
790 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
791 res = stretchedBox2->explode(testVector,3);
792 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
793 res = stretchedBox3->explode(testVector,3);
794 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
795 res = stretchedBox4->explode(testVector,3);
796 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
797 res = tiltedBox1->explode(testVector,3);
798 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
799 res = tiltedBox2->explode(testVector,3);
800 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
801 res = tiltedBox3->explode(testVector,3);
802 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
803 res = tiltedBox4->explode(testVector,3);
804 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
805 }
806
807 {
808 testVector = Vector(1,1,1);
809 res = unitBox->explode(testVector,3);
810 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
811 res = stretchedBox1->explode(testVector,3);
812 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
813 res = stretchedBox2->explode(testVector,3);
814 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
815 res = stretchedBox3->explode(testVector,3);
816 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
817 res = stretchedBox4->explode(testVector,3);
818 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
819 res = tiltedBox1->explode(testVector,3);
820 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
821 res = tiltedBox2->explode(testVector,3);
822 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
823 res = tiltedBox3->explode(testVector,3);
824 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
825 res = tiltedBox4->explode(testVector,3);
826 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
827 }
828
829 {
830 testVector = Vector(2,1,1);
831 res = stretchedBox2->explode(testVector,3);
832 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
833 res = stretchedBox3->explode(testVector,3);
834 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
835 res = stretchedBox4->explode(testVector,3);
836 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
837 }
838
839 {
840 testVector = Vector(1,2,1);
841 res = stretchedBox1->explode(testVector,3);
842 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
843 res = stretchedBox2->explode(testVector,3);
844 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
845 res = stretchedBox4->explode(testVector,3);
846 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
847 res = tiltedBox2->explode(testVector,3);
848 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
849 }
850
851 {
852 testVector = Vector(1,1,2);
853 res = stretchedBox1->explode(testVector,3);
854 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
855 res = stretchedBox3->explode(testVector,3);
856 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
857 res = stretchedBox4->explode(testVector,3);
858 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
859 res = tiltedBox1->explode(testVector,3);
860 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
861 res = tiltedBox2->explode(testVector,3);
862 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
863 res = tiltedBox3->explode(testVector,3);
864 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
865 res = tiltedBox4->explode(testVector,3);
866 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
867 }
868
869 {
870 testVector = Vector(3,1,1);
871 res = stretchedBox3->explode(testVector,3);
872 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
873 }
874
875 {
876 testVector = Vector(1,3,1);
877 res = stretchedBox2->explode(testVector,3);
878 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
879 }
880
881 {
882 testVector = Vector(1,1,3);
883 res = stretchedBox1->explode(testVector,3);
884 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
885 }
886
887 {
888 testVector = Vector(2,2,2);
889 res = stretchedBox4->explode(testVector,3);
890 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
891 }
892}
893
894void BoxUnittest::BoundaryBounceTest(){
895 Vector testVector(0,0,0);
896 VECTORSET(std::vector) res;
897
898 unitBox->setCondition(0,BoundaryConditions::Bounce);
899 stretchedBox1->setCondition(0,BoundaryConditions::Bounce);
900 stretchedBox2->setCondition(0,BoundaryConditions::Bounce);
901 stretchedBox3->setCondition(0,BoundaryConditions::Bounce);
902 stretchedBox4->setCondition(0,BoundaryConditions::Bounce);
903 tiltedBox1->setCondition(0,BoundaryConditions::Bounce);
904 tiltedBox2->setCondition(0,BoundaryConditions::Bounce);
905 tiltedBox3->setCondition(0,BoundaryConditions::Bounce);
906 tiltedBox4->setCondition(0,BoundaryConditions::Bounce);
907
908 {
909 testVector = Vector(0,0,0);
910 res = unitBox->explode(testVector,1);
911 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
912 res = stretchedBox1->explode(testVector,1);
913 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
914 res = stretchedBox2->explode(testVector,1);
915 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
916 res = stretchedBox3->explode(testVector,1);
917 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
918 res = stretchedBox4->explode(testVector,1);
919 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
920 res = tiltedBox1->explode(testVector,1);
921 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
922 res = tiltedBox2->explode(testVector,1);
923 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
924 res = tiltedBox3->explode(testVector,1);
925 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
926 res = tiltedBox4->explode(testVector,1);
927 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
928 }
929
930 {
931 testVector = Vector(0.5,0.5,0.5);
932 res = unitBox->explode(testVector,1);
933 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
934 res = stretchedBox1->explode(testVector,1);
935 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
936 res = stretchedBox2->explode(testVector,1);
937 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
938 res = stretchedBox3->explode(testVector,1);
939 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
940 res = stretchedBox4->explode(testVector,1);
941 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
942 res = tiltedBox1->explode(testVector,1);
943 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
944 res = tiltedBox2->explode(testVector,1);
945 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
946 res = tiltedBox3->explode(testVector,1);
947 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
948 res = tiltedBox4->explode(testVector,1);
949 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
950 }
951
952 {
953 testVector = Vector(0,0,0);
954 res = unitBox->explode(testVector,2);
955 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
956 res = stretchedBox1->explode(testVector,2);
957 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
958 res = stretchedBox2->explode(testVector,2);
959 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
960 res = stretchedBox3->explode(testVector,2);
961 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
962 res = stretchedBox4->explode(testVector,2);
963 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
964 res = tiltedBox1->explode(testVector,2);
965 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
966 res = tiltedBox2->explode(testVector,2);
967 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
968 res = tiltedBox3->explode(testVector,2);
969 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
970 res = tiltedBox4->explode(testVector,2);
971 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
972 }
973
974 {
975 testVector = Vector(0.5,0.5,0.5);
976 res = unitBox->explode(testVector,2);
977 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
978 res = stretchedBox1->explode(testVector,2);
979 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
980 res = stretchedBox2->explode(testVector,2);
981 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
982 res = stretchedBox3->explode(testVector,2);
983 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
984 res = stretchedBox4->explode(testVector,2);
985 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
986 res = tiltedBox1->explode(testVector,2);
987 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
988 res = tiltedBox2->explode(testVector,2);
989 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
990 res = tiltedBox3->explode(testVector,2);
991 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
992 res = tiltedBox4->explode(testVector,2);
993 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
994 }
995
996 unitBox->setCondition(1,BoundaryConditions::Bounce);
997 stretchedBox1->setCondition(1,BoundaryConditions::Bounce);
998 stretchedBox2->setCondition(1,BoundaryConditions::Bounce);
999 stretchedBox3->setCondition(1,BoundaryConditions::Bounce);
1000 stretchedBox4->setCondition(1,BoundaryConditions::Bounce);
1001 tiltedBox1->setCondition(1,BoundaryConditions::Bounce);
1002 tiltedBox2->setCondition(1,BoundaryConditions::Bounce);
1003 tiltedBox3->setCondition(1,BoundaryConditions::Bounce);
1004 tiltedBox4->setCondition(1,BoundaryConditions::Bounce);
1005
1006 {
1007 testVector = Vector(0,0,0);
1008 res = unitBox->explode(testVector,1);
1009 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1010 res = stretchedBox1->explode(testVector,1);
1011 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1012 res = stretchedBox2->explode(testVector,1);
1013 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1014 res = stretchedBox3->explode(testVector,1);
1015 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1016 res = stretchedBox4->explode(testVector,1);
1017 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1018 res = tiltedBox1->explode(testVector,1);
1019 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1020 res = tiltedBox2->explode(testVector,1);
1021 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1022 res = tiltedBox3->explode(testVector,1);
1023 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1024 res = tiltedBox4->explode(testVector,1);
1025 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1026 }
1027
1028 {
1029 testVector = Vector(0.5,0.5,0.5);
1030 res = unitBox->explode(testVector,1);
1031 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1032 res = stretchedBox1->explode(testVector,1);
1033 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1034 res = stretchedBox2->explode(testVector,1);
1035 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1036 res = stretchedBox3->explode(testVector,1);
1037 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1038 res = stretchedBox4->explode(testVector,1);
1039 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1040 res = tiltedBox1->explode(testVector,1);
1041 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1042 res = tiltedBox2->explode(testVector,1);
1043 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1044 res = tiltedBox3->explode(testVector,1);
1045 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1046 res = tiltedBox4->explode(testVector,1);
1047 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1048 }
1049
1050 {
1051 testVector = Vector(0,0,0);
1052 res = unitBox->explode(testVector,2);
1053 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1054 res = stretchedBox1->explode(testVector,2);
1055 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1056 res = stretchedBox2->explode(testVector,2);
1057 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1058 res = stretchedBox3->explode(testVector,2);
1059 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1060 res = stretchedBox4->explode(testVector,2);
1061 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1062 res = tiltedBox1->explode(testVector,2);
1063 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1064 res = tiltedBox2->explode(testVector,2);
1065 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1066 res = tiltedBox3->explode(testVector,2);
1067 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1068 res = tiltedBox4->explode(testVector,2);
1069 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1070 }
1071
1072 {
1073 testVector = Vector(0.5,0.5,0.5);
1074 res = unitBox->explode(testVector,2);
1075 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1076 res = stretchedBox1->explode(testVector,2);
1077 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1078 res = stretchedBox2->explode(testVector,2);
1079 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1080 res = stretchedBox3->explode(testVector,2);
1081 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1082 res = stretchedBox4->explode(testVector,2);
1083 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1084 res = tiltedBox1->explode(testVector,2);
1085 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1086 res = tiltedBox2->explode(testVector,2);
1087 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1088 res = tiltedBox3->explode(testVector,2);
1089 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1090 res = tiltedBox4->explode(testVector,2);
1091 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1092 }
1093
1094 unitBox->setCondition(2,BoundaryConditions::Bounce);
1095 stretchedBox1->setCondition(2,BoundaryConditions::Bounce);
1096 stretchedBox2->setCondition(2,BoundaryConditions::Bounce);
1097 stretchedBox3->setCondition(2,BoundaryConditions::Bounce);
1098 stretchedBox4->setCondition(2,BoundaryConditions::Bounce);
1099 tiltedBox1->setCondition(2,BoundaryConditions::Bounce);
1100 tiltedBox2->setCondition(2,BoundaryConditions::Bounce);
1101 tiltedBox3->setCondition(2,BoundaryConditions::Bounce);
1102 tiltedBox4->setCondition(2,BoundaryConditions::Bounce);
1103
1104 {
1105 testVector = Vector(0,0,0);
1106 res = unitBox->explode(testVector,1);
1107 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1108 res = stretchedBox1->explode(testVector,1);
1109 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1110 res = stretchedBox2->explode(testVector,1);
1111 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1112 res = stretchedBox3->explode(testVector,1);
1113 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1114 res = stretchedBox4->explode(testVector,1);
1115 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1116 res = tiltedBox1->explode(testVector,1);
1117 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1118 res = tiltedBox2->explode(testVector,1);
1119 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1120 res = tiltedBox3->explode(testVector,1);
1121 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1122 res = tiltedBox4->explode(testVector,1);
1123 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1124 }
1125
1126 {
1127 testVector = Vector(0.5,0.5,0.5);
1128 res = unitBox->explode(testVector,1);
1129 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1130 res = stretchedBox1->explode(testVector,1);
1131 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1132 res = stretchedBox2->explode(testVector,1);
1133 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1134 res = stretchedBox3->explode(testVector,1);
1135 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1136 res = stretchedBox4->explode(testVector,1);
1137 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1138 res = tiltedBox1->explode(testVector,1);
1139 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1140 res = tiltedBox2->explode(testVector,1);
1141 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1142 res = tiltedBox3->explode(testVector,1);
1143 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1144 res = tiltedBox4->explode(testVector,1);
1145 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1146 }
1147
1148 {
1149 testVector = Vector(0,0,0);
1150 res = unitBox->explode(testVector,2);
1151 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1152 res = stretchedBox1->explode(testVector,2);
1153 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1154 res = stretchedBox2->explode(testVector,2);
1155 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1156 res = stretchedBox3->explode(testVector,2);
1157 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1158 res = stretchedBox4->explode(testVector,2);
1159 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1160 res = tiltedBox1->explode(testVector,2);
1161 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1162 res = tiltedBox2->explode(testVector,2);
1163 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1164 res = tiltedBox3->explode(testVector,2);
1165 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1166 res = tiltedBox4->explode(testVector,2);
1167 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1168 }
1169
1170 {
1171 testVector = Vector(0.5,0.5,0.5);
1172 res = unitBox->explode(testVector,2);
1173 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1174 res = stretchedBox1->explode(testVector,2);
1175 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1176 res = stretchedBox2->explode(testVector,2);
1177 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1178 res = stretchedBox3->explode(testVector,2);
1179 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1180 res = stretchedBox4->explode(testVector,2);
1181 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1182 res = tiltedBox1->explode(testVector,2);
1183 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1184 res = tiltedBox2->explode(testVector,2);
1185 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1186 res = tiltedBox3->explode(testVector,2);
1187 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1188 res = tiltedBox4->explode(testVector,2);
1189 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1190 }
1191}
1192
1193void BoxUnittest::BoundaryIgnoreTest(){
1194 Vector testVector(0,0,0);
1195 VECTORSET(std::vector) res;
1196
1197 unitBox->setCondition(0,BoundaryConditions::Ignore);
1198 stretchedBox1->setCondition(0,BoundaryConditions::Ignore);
1199 stretchedBox2->setCondition(0,BoundaryConditions::Ignore);
1200 stretchedBox3->setCondition(0,BoundaryConditions::Ignore);
1201 stretchedBox4->setCondition(0,BoundaryConditions::Ignore);
1202 tiltedBox1->setCondition(0,BoundaryConditions::Ignore);
1203 tiltedBox2->setCondition(0,BoundaryConditions::Ignore);
1204 tiltedBox3->setCondition(0,BoundaryConditions::Ignore);
1205 tiltedBox4->setCondition(0,BoundaryConditions::Ignore);
1206
1207 {
1208 testVector = Vector(0,0,0);
1209 res = unitBox->explode(testVector,1);
1210 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1211 res = stretchedBox1->explode(testVector,1);
1212 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1213 res = stretchedBox2->explode(testVector,1);
1214 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1215 res = stretchedBox3->explode(testVector,1);
1216 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1217 res = stretchedBox4->explode(testVector,1);
1218 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1219 res = tiltedBox1->explode(testVector,1);
1220 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1221 res = tiltedBox2->explode(testVector,1);
1222 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1223 res = tiltedBox3->explode(testVector,1);
1224 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1225 res = tiltedBox4->explode(testVector,1);
1226 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1227 }
1228
1229 {
1230 testVector = Vector(0.5,0.5,0.5);
1231 res = unitBox->explode(testVector,1);
1232 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1233 res = stretchedBox1->explode(testVector,1);
1234 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1235 res = stretchedBox2->explode(testVector,1);
1236 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1237 res = stretchedBox3->explode(testVector,1);
1238 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1239 res = stretchedBox4->explode(testVector,1);
1240 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1241 res = tiltedBox1->explode(testVector,1);
1242 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1243 res = tiltedBox2->explode(testVector,1);
1244 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1245 res = tiltedBox3->explode(testVector,1);
1246 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1247 res = tiltedBox4->explode(testVector,1);
1248 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1249 }
1250
1251 {
1252 testVector = Vector(0,0,0);
1253 res = unitBox->explode(testVector,2);
1254 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1255 res = stretchedBox1->explode(testVector,2);
1256 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1257 res = stretchedBox2->explode(testVector,2);
1258 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1259 res = stretchedBox3->explode(testVector,2);
1260 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1261 res = stretchedBox4->explode(testVector,2);
1262 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1263 res = tiltedBox1->explode(testVector,2);
1264 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1265 res = tiltedBox2->explode(testVector,2);
1266 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1267 res = tiltedBox3->explode(testVector,2);
1268 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1269 res = tiltedBox4->explode(testVector,2);
1270 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1271 }
1272
1273 {
1274 testVector = Vector(0.5,0.5,0.5);
1275 res = unitBox->explode(testVector,2);
1276 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1277 res = stretchedBox1->explode(testVector,2);
1278 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1279 res = stretchedBox2->explode(testVector,2);
1280 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1281 res = stretchedBox3->explode(testVector,2);
1282 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1283 res = stretchedBox4->explode(testVector,2);
1284 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1285 res = tiltedBox1->explode(testVector,2);
1286 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1287 res = tiltedBox2->explode(testVector,2);
1288 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1289 res = tiltedBox3->explode(testVector,2);
1290 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1291 res = tiltedBox4->explode(testVector,2);
1292 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1293 }
1294
1295 unitBox->setCondition(1,BoundaryConditions::Ignore);
1296 stretchedBox1->setCondition(1,BoundaryConditions::Ignore);
1297 stretchedBox2->setCondition(1,BoundaryConditions::Ignore);
1298 stretchedBox3->setCondition(1,BoundaryConditions::Ignore);
1299 stretchedBox4->setCondition(1,BoundaryConditions::Ignore);
1300 tiltedBox1->setCondition(1,BoundaryConditions::Ignore);
1301 tiltedBox2->setCondition(1,BoundaryConditions::Ignore);
1302 tiltedBox3->setCondition(1,BoundaryConditions::Ignore);
1303 tiltedBox4->setCondition(1,BoundaryConditions::Ignore);
1304
1305 {
1306 testVector = Vector(0,0,0);
1307 res = unitBox->explode(testVector,1);
1308 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1309 res = stretchedBox1->explode(testVector,1);
1310 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1311 res = stretchedBox2->explode(testVector,1);
1312 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1313 res = stretchedBox3->explode(testVector,1);
1314 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1315 res = stretchedBox4->explode(testVector,1);
1316 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1317 res = tiltedBox1->explode(testVector,1);
1318 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1319 res = tiltedBox2->explode(testVector,1);
1320 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1321 res = tiltedBox3->explode(testVector,1);
1322 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1323 res = tiltedBox4->explode(testVector,1);
1324 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1325 }
1326
1327 {
1328 testVector = Vector(0.5,0.5,0.5);
1329 res = unitBox->explode(testVector,1);
1330 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1331 res = stretchedBox1->explode(testVector,1);
1332 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1333 res = stretchedBox2->explode(testVector,1);
1334 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1335 res = stretchedBox3->explode(testVector,1);
1336 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1337 res = stretchedBox4->explode(testVector,1);
1338 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1339 res = tiltedBox1->explode(testVector,1);
1340 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1341 res = tiltedBox2->explode(testVector,1);
1342 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1343 res = tiltedBox3->explode(testVector,1);
1344 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1345 res = tiltedBox4->explode(testVector,1);
1346 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1347 }
1348
1349 {
1350 testVector = Vector(0,0,0);
1351 res = unitBox->explode(testVector,2);
1352 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1353 res = stretchedBox1->explode(testVector,2);
1354 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1355 res = stretchedBox2->explode(testVector,2);
1356 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1357 res = stretchedBox3->explode(testVector,2);
1358 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1359 res = stretchedBox4->explode(testVector,2);
1360 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1361 res = tiltedBox1->explode(testVector,2);
1362 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1363 res = tiltedBox2->explode(testVector,2);
1364 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1365 res = tiltedBox3->explode(testVector,2);
1366 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1367 res = tiltedBox4->explode(testVector,2);
1368 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1369 }
1370
1371 {
1372 testVector = Vector(0.5,0.5,0.5);
1373 res = unitBox->explode(testVector,2);
1374 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1375 res = stretchedBox1->explode(testVector,2);
1376 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1377 res = stretchedBox2->explode(testVector,2);
1378 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1379 res = stretchedBox3->explode(testVector,2);
1380 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1381 res = stretchedBox4->explode(testVector,2);
1382 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1383 res = tiltedBox1->explode(testVector,2);
1384 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1385 res = tiltedBox2->explode(testVector,2);
1386 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1387 res = tiltedBox3->explode(testVector,2);
1388 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1389 res = tiltedBox4->explode(testVector,2);
1390 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1391 }
1392
1393 unitBox->setCondition(2,BoundaryConditions::Ignore);
1394 stretchedBox1->setCondition(2,BoundaryConditions::Ignore);
1395 stretchedBox2->setCondition(2,BoundaryConditions::Ignore);
1396 stretchedBox3->setCondition(2,BoundaryConditions::Ignore);
1397 stretchedBox4->setCondition(2,BoundaryConditions::Ignore);
1398 tiltedBox1->setCondition(2,BoundaryConditions::Ignore);
1399 tiltedBox2->setCondition(2,BoundaryConditions::Ignore);
1400 tiltedBox3->setCondition(2,BoundaryConditions::Ignore);
1401 tiltedBox4->setCondition(2,BoundaryConditions::Ignore);
1402
1403 {
1404 testVector = Vector(0,0,0);
1405 res = unitBox->explode(testVector,1);
1406 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1407 res = stretchedBox1->explode(testVector,1);
1408 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1409 res = stretchedBox2->explode(testVector,1);
1410 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1411 res = stretchedBox3->explode(testVector,1);
1412 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1413 res = stretchedBox4->explode(testVector,1);
1414 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1415 res = tiltedBox1->explode(testVector,1);
1416 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1417 res = tiltedBox2->explode(testVector,1);
1418 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1419 res = tiltedBox3->explode(testVector,1);
1420 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1421 res = tiltedBox4->explode(testVector,1);
1422 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1423 }
1424
1425 {
1426 testVector = Vector(0.5,0.5,0.5);
1427 res = unitBox->explode(testVector,1);
1428 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1429 res = stretchedBox1->explode(testVector,1);
1430 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1431 res = stretchedBox2->explode(testVector,1);
1432 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1433 res = stretchedBox3->explode(testVector,1);
1434 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1435 res = stretchedBox4->explode(testVector,1);
1436 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1437 res = tiltedBox1->explode(testVector,1);
1438 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1439 res = tiltedBox2->explode(testVector,1);
1440 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1441 res = tiltedBox3->explode(testVector,1);
1442 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1443 res = tiltedBox4->explode(testVector,1);
1444 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1445 }
1446
1447 {
1448 testVector = Vector(0,0,0);
1449 res = unitBox->explode(testVector,2);
1450 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1451 res = stretchedBox1->explode(testVector,2);
1452 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1453 res = stretchedBox2->explode(testVector,2);
1454 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1455 res = stretchedBox3->explode(testVector,2);
1456 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1457 res = stretchedBox4->explode(testVector,2);
1458 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1459 res = tiltedBox1->explode(testVector,2);
1460 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1461 res = tiltedBox2->explode(testVector,2);
1462 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1463 res = tiltedBox3->explode(testVector,2);
1464 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1465 res = tiltedBox4->explode(testVector,2);
1466 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1467 }
1468
1469 {
1470 testVector = Vector(0.5,0.5,0.5);
1471 res = unitBox->explode(testVector,2);
1472 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1473 res = stretchedBox1->explode(testVector,2);
1474 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1475 res = stretchedBox2->explode(testVector,2);
1476 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1477 res = stretchedBox3->explode(testVector,2);
1478 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1479 res = stretchedBox4->explode(testVector,2);
1480 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1481 res = tiltedBox1->explode(testVector,2);
1482 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1483 res = tiltedBox2->explode(testVector,2);
1484 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1485 res = tiltedBox3->explode(testVector,2);
1486 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1487 res = tiltedBox4->explode(testVector,2);
1488 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1489 }
1490}
1491
1492void BoxUnittest::BoundaryMixedTest(){
1493 Vector testVector(0,0,0);
1494 VECTORSET(std::vector) res;
1495
1496 unitBox->setCondition(0,BoundaryConditions::Bounce);
1497 unitBox->setCondition(1,BoundaryConditions::Ignore);
1498 unitBox->setCondition(2,BoundaryConditions::Wrap);
1499
1500 stretchedBox1->setCondition(0,BoundaryConditions::Bounce);
1501 stretchedBox1->setCondition(1,BoundaryConditions::Ignore);
1502 stretchedBox1->setCondition(2,BoundaryConditions::Wrap);
1503
1504 stretchedBox2->setCondition(0,BoundaryConditions::Bounce);
1505 stretchedBox2->setCondition(1,BoundaryConditions::Ignore);
1506 stretchedBox2->setCondition(2,BoundaryConditions::Wrap);
1507
1508 stretchedBox3->setCondition(0,BoundaryConditions::Bounce);
1509 stretchedBox3->setCondition(1,BoundaryConditions::Ignore);
1510 stretchedBox3->setCondition(2,BoundaryConditions::Wrap);
1511
1512 stretchedBox4->setCondition(0,BoundaryConditions::Bounce);
1513 stretchedBox4->setCondition(1,BoundaryConditions::Ignore);
1514 stretchedBox4->setCondition(2,BoundaryConditions::Wrap);
1515
1516 tiltedBox1->setCondition(0,BoundaryConditions::Bounce);
1517 tiltedBox1->setCondition(1,BoundaryConditions::Ignore);
1518 tiltedBox1->setCondition(2,BoundaryConditions::Wrap);
1519
1520 tiltedBox2->setCondition(0,BoundaryConditions::Bounce);
1521 tiltedBox2->setCondition(1,BoundaryConditions::Ignore);
1522 tiltedBox2->setCondition(2,BoundaryConditions::Wrap);
1523
1524 tiltedBox3->setCondition(0,BoundaryConditions::Bounce);
1525 tiltedBox3->setCondition(1,BoundaryConditions::Ignore);
1526 tiltedBox3->setCondition(2,BoundaryConditions::Wrap);
1527
1528 tiltedBox4->setCondition(0,BoundaryConditions::Bounce);
1529 tiltedBox4->setCondition(1,BoundaryConditions::Ignore);
1530 tiltedBox4->setCondition(2,BoundaryConditions::Wrap);
1531
1532 {
1533 testVector = Vector(0,0,0);
1534 res = unitBox->explode(testVector,1);
1535 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1536 res = stretchedBox1->explode(testVector,1);
1537 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1538 res = stretchedBox2->explode(testVector,1);
1539 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1540 res = stretchedBox3->explode(testVector,1);
1541 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1542 res = stretchedBox4->explode(testVector,1);
1543 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1544 res = tiltedBox1->explode(testVector,1);
1545 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1546 res = tiltedBox2->explode(testVector,1);
1547 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1548 res = tiltedBox3->explode(testVector,1);
1549 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1550 res = tiltedBox4->explode(testVector,1);
1551 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1552 }
1553
1554 {
1555 testVector = Vector(0.5,0.5,0.5);
1556 res = unitBox->explode(testVector,1);
1557 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1558 res = stretchedBox1->explode(testVector,1);
1559 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1560 res = stretchedBox2->explode(testVector,1);
1561 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1562 res = stretchedBox3->explode(testVector,1);
1563 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1564 res = stretchedBox4->explode(testVector,1);
1565 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1566 res = tiltedBox1->explode(testVector,1);
1567 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1568 res = tiltedBox2->explode(testVector,1);
1569 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1570 res = tiltedBox3->explode(testVector,1);
1571 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1572 res = tiltedBox4->explode(testVector,1);
1573 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1574 }
1575
1576 {
1577 testVector = Vector(0,0,0);
1578 res = unitBox->explode(testVector,2);
1579 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1580 res = stretchedBox1->explode(testVector,2);
1581 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1582 res = stretchedBox2->explode(testVector,2);
1583 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1584 res = stretchedBox3->explode(testVector,2);
1585 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1586 res = stretchedBox4->explode(testVector,2);
1587 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1588 res = tiltedBox1->explode(testVector,2);
1589 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1590 res = tiltedBox2->explode(testVector,2);
1591 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1592 res = tiltedBox3->explode(testVector,2);
1593 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1594 res = tiltedBox4->explode(testVector,2);
1595 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1596 }
1597
1598 {
1599 testVector = Vector(0.5,0.5,0.5);
1600 res = unitBox->explode(testVector,2);
1601 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1602 res = stretchedBox1->explode(testVector,2);
1603 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1604 res = stretchedBox2->explode(testVector,2);
1605 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1606 res = stretchedBox3->explode(testVector,2);
1607 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1608 res = stretchedBox4->explode(testVector,2);
1609 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1610 res = tiltedBox1->explode(testVector,2);
1611 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1612 res = tiltedBox2->explode(testVector,2);
1613 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1614 res = tiltedBox3->explode(testVector,2);
1615 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1616 res = tiltedBox4->explode(testVector,2);
1617 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1618 }
1619
1620}
1621
1622/** Unit test on whether observer is working.
1623 *
1624 */
1625void BoxUnittest::ObserverTest()
1626{
1627 // create some observers
1628 UpdateCountObserver *observer_general = new UpdateCountObserver();
1629 NotificationObserver *observer_matrix = new NotificationObserver(
1630 unitBox->getChannel(Box::MatrixChanged));
1631 NotificationObserver *observer_bc = new NotificationObserver(
1632 unitBox->getChannel(Box::BoundaryConditionsChanged));
1633 CPPUNIT_ASSERT_EQUAL((int)0, observer_general->updates);
1634 CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified);
1635 CPPUNIT_ASSERT_EQUAL(false, observer_bc->wasNotified);
1636 unitBox->signOn(observer_general);
1637 unitBox->signOn(observer_matrix, Box::MatrixChanged);
1638 unitBox->signOn(observer_bc, Box::BoundaryConditionsChanged);
1639
1640 // create update MatrixChanged
1641 unitBox->setM(*unit);
1642 CPPUNIT_ASSERT_EQUAL((int)1, observer_general->updates);
1643 CPPUNIT_ASSERT_EQUAL(true, observer_matrix->wasNotified);
1644 CPPUNIT_ASSERT_EQUAL(false, observer_bc->wasNotified);
1645 observer_matrix->wasNotified = false;
1646
1647 // create update BoundaryConditionsChanged
1648 unitBox->setCondition(0, BoundaryConditions::Wrap);
1649 CPPUNIT_ASSERT_EQUAL((int)2, observer_general->updates);
1650 CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified);
1651 CPPUNIT_ASSERT_EQUAL(true, observer_bc->wasNotified);
1652
1653 // remove observers again
1654 unitBox->signOff(observer_general);
1655 unitBox->signOff(observer_matrix, Box::MatrixChanged);
1656 unitBox->signOff(observer_bc, Box::BoundaryConditionsChanged);
1657 delete observer_general;
1658 delete observer_matrix;
1659 delete observer_bc;
1660}
Note: See TracBrowser for help on using the repository browser.