void peano::integration::partitioncoupling::builtin::tests::PartitionCoupling4MovingSphereTest::run(){ tarch::la::Vector<DIMENSIONS,double> hexahedronSize(1.0); tarch::la::Vector<DIMENSIONS,double> hexahedronOffset(0.0); peano::geometry::builtin::Hexahedron *hexahedron = new peano::geometry::builtin::Hexahedron(false,hexahedronSize,hexahedronOffset); tarch::la::Vector<DIMENSIONS,double> spherePosition(0.5); double sphereRadius = 1.0/6.0; double sphereDensity = 1.0; double sphereMass = sphereDensity*tarch::la::PI #if (DIMENSIONS==2) *sphereRadius*sphereRadius #elif(DIMENSIONS==3) *4.0/3.0*sphereRadius*sphereRadius*sphereRadius #endif ; int timestepsPerPlotting = 5; double dt = 0.01; tarch::la::Vector<DIMENSIONS,double> force(0.0); tarch::la::Vector<DIMENSIONS,double> forcePosition(0.0); tarch::la::Vector<DIMENSIONS,double> velocityPosition(0.0); std::vector<peano::integration::partitioncoupling::builtin::tests::PartitionCoupling4MovingSphereTest::TestScenario> testScenarios = getTestScenarios(spherePosition,sphereRadius,sphereMass,dt); for (unsigned int i = 0; i < testScenarios.size(); i++){ tarch::la::Vector<DIMENSIONS,double> velocity(0.0); std::stringstream ss(std::stringstream::in | std::stringstream::out); ss << "PartitionCoupling4MovingSphereTest_Test_" << i << "_"; // create receive-,send- and coupling object peano::integration::partitioncoupling::services::ReceiveDataService::getInstance().init( spherePosition,sphereRadius,tarch::la::Vector<3,double>(0.0),tarch::la::Vector<3,double>(0.0) ); peano::integration::partitioncoupling::services::SendDataService::getInstance().init(spherePosition); PartitionCoupling4MovingSphere partitionCoupling( hexahedron,hexahedronSize,hexahedronOffset,spherePosition,sphereRadius,sphereDensity, timestepsPerPlotting,timestepsPerPlotting,ss.str() ); partitionCoupling.initialize(); // add force,advance in time peano::integration::partitioncoupling::services::SendDataService::getInstance().getSendData().sendForce(testScenarios[i].forcePosition,testScenarios[i].force); partitionCoupling.advance(dt); // get velocity and validate its components velocity = peano::integration::partitioncoupling::services::ReceiveDataService::getInstance().getReceiveData().getVelocity(testScenarios[i].velocityPosition); std::cout << "Velocity: " << velocity << ", expected: " << testScenarios[i].expectedVelocity << std::endl; validate(tarch::la::equals( tarch::la::dot(velocity-testScenarios[i].expectedVelocity,velocity-testScenarios[i].expectedVelocity), 0.0 )); } }
float3 NBodySystemInitializator::getNewPosition() { float3 result; switch (mp_properties->formation) { case BodyFormation::SCATTER: result = scatterPosition(); break; case BodyFormation::SPHERE: result = spherePosition(); break; default: result = scatterPosition(); break; } if (mp_properties->dimension == TWO) result.z = 0.0f; return result; }