Beispiel #1
0
void
divergenceTest()
{
    int maxsize;
    ParmParse pp;
    pp.get("max_grid_size", maxsize);

    //make layouts == domain
    Box domainBoxFine, domainBoxCoar;
    Real dxFine, dxCoar;
    sphereGeometry(domainBoxFine, dxFine);
    domainBoxCoar = coarsen(domainBoxFine, 2);

    //debug
    dxFine = 1.0;
    dxCoar = 2.*dxFine;
    Vector<Box> boxFine;
    domainSplit(domainBoxFine, boxFine, maxsize);

    Vector<int> proc(boxFine.size(), 0);
    DisjointBoxLayout dblFine(boxFine, proc);
    DisjointBoxLayout dblCoar;
    coarsen(dblCoar, dblFine, 2);
    LevelData<EBCellFAB> errorFine, errorCoar;

    EBISLayout ebislFine, ebislCoar;
    const EBIndexSpace* const ebisPtr = Chombo_EBIS::instance();
    ebisPtr->fillEBISLayout(ebislFine, dblFine, domainBoxFine, 2);
    ebisPtr->fillEBISLayout(ebislCoar, dblCoar, domainBoxCoar, 2);

    getError(errorFine, ebislFine, dblFine, dxFine);
    getError(errorCoar, ebislCoar, dblCoar, dxCoar);

    for (DataIterator dit= dblFine.dataIterator(); dit.ok(); ++dit)
    {
        const EBCellFAB& errorFineFAB = errorFine[dit()];
        const EBCellFAB& errorCoarFAB = errorCoar[dit()];
        int i1 = errorFineFAB.getMultiCells().numPts();
        int i2 = errorCoarFAB.getMultiCells().numPts();
        pout() << i1 << i2 << endl;
    }

    compareError(errorFine, ebislFine, dblFine, domainBoxFine,
                 errorCoar, ebislCoar, dblCoar, domainBoxCoar);

}
void createActors()
{
	// Create Material
	physx::PxMaterial* cubeMaterial = gPhysicsSDK->createMaterial(0.5f, 0.5f, 0.5f);
	physx::PxMaterial* sphereMaterial = gPhysicsSDK->createMaterial(0.6f, 0.1f, 0.6f);
	physx::PxMaterial* planeMaterial = gPhysicsSDK->createMaterial(0.5f, 0.5f, 0.5f);

	// Create Floor
	physx::PxReal d = 0.0f;
	physx::PxTransform pose = physx::PxTransform( physx::PxVec3( 0.0f, 0, 0.0f ), physx::PxQuat( physx::PxHalfPi, physx::PxVec3( 0.0f, 0.0f, 1.0f )));

	physx::PxRigidStatic* plane = gPhysicsSDK->createRigidStatic(pose);
	if (!plane)
			std::cerr << "create plane failed!" << std::endl;

	physx::PxShape* shape = plane->createShape(physx::PxPlaneGeometry(), *planeMaterial);
	if (!shape)
		std::cerr << "create shape failed!" << std::endl;
	gScene->addActor(*plane);

	float gap_x = box_size.x * 2.0f;
	float gap_y = box_size.y * 2.0f;

	// Create boxes
	if(total_boxes > 0)
	{
		physx::PxReal density = 1.0f;
		physx::PxTransform boxTransform(physx::PxVec3(0.0f, 0.0f, 0.0f));
		physx::PxBoxGeometry boxGeometry(box_size);
		for(float i = -box_grid_width/2.0f; i < box_grid_width/2.0f; ++i)
		{
			for(unsigned int j = 0; j < box_grid_height; ++j)
			{
				boxTransform.p = physx::PxVec3((i * gap_x) + 1.0f, (j * gap_y) + 1.0f, 0.0f);
	    
				physx::PxRigidDynamic *boxActor = PxCreateDynamic(*gPhysicsSDK, boxTransform, boxGeometry, *cubeMaterial, density);
				if (!boxActor)
					std::cerr << "create actor failed!" << std::endl;
				boxActor->setAngularDamping(0.75f);
				boxActor->setLinearDamping(0.01f);
				boxActor->setMass(10.0f);

				gScene->addActor(*boxActor);

				boxes_actors.push_back(boxActor);
			}
		}
	}

	// Create spheres
	if(total_spheres > 0)
	{
		physx::PxReal density = 2.0f;
		physx::PxTransform sphereTransform(physx::PxVec3(0.0f, 0.0f, 0.0f));
		physx::PxSphereGeometry sphereGeometry(sphere_radius);
		
		for(unsigned int i = 0; i < total_spheres; ++i)
		{
			sphereTransform.p = physx::PxVec3(0.0f, 0.0f, -30.0f);

			physx::PxRigidDynamic *sphereActor = PxCreateDynamic(*gPhysicsSDK, sphereTransform, sphereGeometry, *sphereMaterial, density);
			if (!sphereActor)
				std::cerr << "create actor failed!" << std::endl;
			sphereActor->setAngularDamping(0.2f);
			sphereActor->setLinearDamping(0.1f);
			sphereActor->setMass(5.0f);
			sphereActor->setLinearVelocity(physx::PxVec3(1.3f, box_grid_height * 2, 60.0f)); 

			gScene->addActor(*sphereActor);

			spheres_actors.push_back(sphereActor);
		}
	}
}