def test_bc(self): poissonForm = PoissonFormulation.PoissonFormulation(2, True) poissonBF = poissonForm.bf() mesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.0, 1.0], [2, 3], 4) s = Solution.Solution_solution(mesh) bc = BC.BC_bc() s.setBC(bc) #self.assertEqual(bc, s.bc()) # i want to test that what I set is equal to what I used to set it with, but # since that won't work, I can at least test that they behave in the same way self.assertEqual(bc.singlePointBC(0), s.bc().singlePointBC(0))
def testBC(self): poissonForm = PoissonFormulation.PoissonFormulation(2, True) poissonBF = poissonForm.bf() mesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.0, 1.0], [2, 3], 4) soln = Solution.Solution_solution(mesh) vf = VarFactory.VarFactory() fv = vf.fieldVar("Hello") testBC = BC.BC_bc() soln.setBC(testBC) self.assertEqual(testBC.bcsImposed(fv.ID()), soln.bc().bcsImposed(fv.ID()))
def testZeroMeanConstraint(self): #Initial Test Values & Set up of Dummy variable vf = VarFactory.VarFactory() bc = BC.BC_bc() testVar = vf.fieldVar("testVar", 2) ID = testVar.ID() bc.addZeroMeanConstraint(testVar) #Test to see if ZeroMeanConstraint has been added correctly self.assertTrue(bc.imposeZeroMeanConstraint(ID), "No Zero Mean Constraint Imposed") #Test to see if one can correctly remove ZeroMeanConstraint bc.removeZeroMeanConstraint(ID) self.assertFalse(bc.imposeZeroMeanConstraint(ID), "Zero Mean Constraint not removed")
def testSinglePoint(self): #Initial Test Values & Set up of Dummy variable vf = VarFactory.VarFactory() testVar = vf.fieldVar("testVar", 2) ID = testVar.ID() testVertex = 4294967295 testFieldID = 9 testValue = 17.1 bc = BC.BC_bc() bc.addSinglePointBC(testFieldID, testValue) #Test to see if Single Point BC has been added correctly self.assertFalse(bc.bcsImposed(testFieldID), "Single Point BC not Imposed") self.assertTrue(bc.singlePointBC(testFieldID), "No Single Point BC") self.assertTrue(testValue == bc.valueForSinglePointBC(testFieldID), "Value on Single Point BC not maintained") self.assertEquals(testVertex, bc.vertexForSinglePointBC(testFieldID), "Vertex on Single Point BC not maintained")
def testDirichlet(self): #Initial Test Values & Set up of Dummy variable testSpatialFilter = SpatialFilter.SpatialFilter.allSpace() testFunction = Function.Function.xn() vf = VarFactory.VarFactory() bc = BC.BC_bc() traceVar = vf.traceVar("traceVar", 2) ID = traceVar.ID() a = [testSpatialFilter, testFunction] bc.addDirichlet(traceVar, testSpatialFilter, testFunction) #Tests to see if Dirichlet has been added correctly self.assertTrue( testFunction.evaluate(2, 3) == bc.getDirichletBC(ID)[1].evaluate( 2, 3), "Dirichlet BC failed") #Maybe same thing as line 60 for spatial filter? self.assertTrue( testFunction.evaluate(4, 3) == bc.getSpatiallyFilteredFunctionForDirichletBC(ID).evaluate(4, 3), "Dirichlet Spatially Filtered Funtion failed")
def testExporter(self): #Initial Test Values & Set Up Dummy Variables poissonForm = PoissonFormulation.PoissonFormulation(2, True) poissonBF = poissonForm.bf( ) #ToDo Give the VarFactory a field & test variable testMesh = MeshFactory.MeshFactory_rectilinearMesh( poissonBF, [1.2, 1.4], [2, 3], 2) testFunction = Function.Function.xn() testFunction2 = Function.Function.yn() testVector = [testFunction, testFunction2] testVector2 = ["function1", "function2"] testBC = BC.BC_bc() testSolutionPtr = Solution.Solution_solution(testMesh) testExport = HDF5Exporter.HDF5Exporter(testMesh, "output", ".") #Tests exportFunction using definition #1 testExport.exportFunction(testFunction, "function", 0) #Tests exportFunction using definition #2 testExport.exportFunction(testVector, testVector2, 0) #Tests exportSolution testExport.exportSolution(testSolutionPtr, 0)