コード例 #1
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
    def test_clear(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)

        x = Function.Function_xn(1)
        one = Function.Function_constant(1)
        zero = Function.Function_constant(0)
        phi = poissonForm.phi(
        )  # VarPtr for main, scalar-valued variable in Poisson problem
        psi = poissonForm.psi()  # VarPtr for gradient of psi, vector-valued

        s = Solution.Solution_solution(mesh)
        s.projectOntoMesh({
            phi.ID(): x,
            psi.ID(): Function.Function_vectorize(one, zero)
        })
        s.addSolution(s, 1.0, [phi.ID()])
        self.assertNotEqual(
            0.0, s.L2NormOfSolution(0))  # not zero since addSolution
        s.clear()
        self.assertIsNotNone(
            s)  #make sure some object still exists since should be in tact
        self.assertEqual(
            0, s.L2NormOfSolution(0))  # zero since zero solutions now
コード例 #2
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 def test_Solution(self):
     poissonForm = PoissonFormulation.PoissonFormulation(2, True)
     poissonBF = poissonForm.bf()
     mesh2 = MeshFactory.MeshFactory_rectilinearMesh(
         poissonBF, [1.0, 1.0], [2, 3], 4)
     s = Solution.Solution_solution(mesh2)
     self.assertIsNotNone(s)  #make sure some object exists
コード例 #3
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 def test_setUseCondensedSolve(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)
     s.setUseCondensedSolve(False)  # if no exception, then successful test
コード例 #4
0
 def testExportSolution(self):
     poissonForm = PoissonFormulation.PoissonFormulation(2, True)
     poissonBF = poissonForm.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.0, 1.0],
                                                    [2, 3], 4)
     hdf5Exp = HDF5Exporter.HDF5Exporter(mesh)
     soln = Solution.Solution_solution(mesh)
     hdf5Exp.exportSolution(soln, poissonBF.varFactory())
コード例 #5
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def tesSetCubatureEnrichmentDegree(self):
     formulation = PoissonFormulation.PoissonFormulation(2, True)
     bf = formulation.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(bf, [1.0, 2.0], [3, 4],
                                                    10)
     soln = Solution.Solution_solution(mesh)
     soln.setCubatureEnrichmentDegree(9)
     self.assertEquals(soln.cubatureEnrichmentDegree(), 9)
コード例 #6
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def testMesh(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)
     self.assertEquals(soln.mesh().numActiveElements(),
                       mesh.numActiveElements(),
                       "Testing Solution's Mesh Method")
コード例 #7
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 def test_ip(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)
     ip = IP.IP_ip()
     s.setIP(ip)
     success = s.ip()
コード例 #8
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def testSolnConstr(self):
     formulation = PoissonFormulation.PoissonFormulation(2, True)
     bf = formulation.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(bf, [1.0, 2.0], [3, 4],
                                                    10)
     #create a new solution with mesh
     soln = Solution.Solution_solution(mesh)
     self.assertEquals(soln.mesh().numActiveElements(), 12,
                       "Testing Solution Constructor")
コード例 #9
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 def test_mesh(self):
     poissonForm = PoissonFormulation.PoissonFormulation(2, True)
     poissonBF = poissonForm.bf()
     mesh1 = MeshFactory.MeshFactory_rectilinearMesh(
         poissonBF, [1.0, 1.0], [2, 3], 4)
     s = Solution.Solution_solution(mesh1)
     #self.assertEqual(mesh1, s.mesh())
     # 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(mesh1.getDimension(), s.mesh().getDimension())
コード例 #10
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def testL2NormOfSolution(self):
     formulation = PoissonFormulation.PoissonFormulation(2, True)
     bf = formulation.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(bf, [1.0, 2.0], [3, 4],
                                                    10)
     #make a bf, add a field variable, then get its id, pass it to L2Norm
     soln = Solution.Solution_solution(mesh)
     vf = VarFactory.VarFactory()
     fv = vf.fieldVar("Hello")
     self.assertEquals(soln.L2NormOfSolution(fv.ID()), 0.0)
コード例 #11
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def testClear(self):
     formulation = PoissonFormulation.PoissonFormulation(2, True)
     bf = formulation.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(bf, [1.0, 2.0], [3, 4],
                                                    10)
     #create a new solution with mesh
     soln = Solution.Solution_solution(mesh)
     soln.clear()
     self.assertIsNotNone(soln)
     self.assertEquals(soln.L2NormOfSolution(0), 0)
コード例 #12
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def testIP(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)
     testIP = IP.IP_ip()
     soln.setIP(testIP)
     worked = soln.ip()
     self.assertIsNotNone(worked)
コード例 #13
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
    def test_addSolution(self):

        # using this method signiture causes an issue with array size mismatch
        # somewhere in your src code
        poissonForm = PoissonFormulation.PoissonFormulation(2, True)
        poissonBF = poissonForm.bf()
        mesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.0, 1.0],
                                                       [2, 3], 4)

        x = Function.Function_xn(1)
        one = Function.Function_constant(1)
        zero = Function.Function_constant(0)
        phi = poissonForm.phi(
        )  # VarPtr for main, scalar-valued variable in Poisson problem
        psi = poissonForm.psi()  # VarPtr for gradient of psi, vector-valued

        q = Solution.Solution_solution(mesh)
        p = Solution.Solution_solution(mesh)
        q.projectOntoMesh({phi.ID(): x})
        p.projectOntoMesh({psi.ID(): Function.Function_vectorize(one, zero)})

        q.addSolution(p, 1.0)
        s = Solution.Solution_solution(mesh)

        s.projectOntoMesh({
            phi.ID(): x,
            psi.ID(): Function.Function_vectorize(one, zero)
        })
        self.assertEqual(s.L2NormOfSolution(phi.ID()),
                         q.L2NormOfSolution(phi.ID()))
        self.assertEqual(s.L2NormOfSolution(psi.ID()),
                         q.L2NormOfSolution(psi.ID()))

        # again with different params for addSolution
        t = Solution.Solution_solution(mesh)
        s.projectOntoMesh({
            phi.ID(): x,
            psi.ID(): Function.Function_vectorize(one, zero)
        })
        s.addSolution(s, 1.0, [phi.ID()])
        self.assertNotEqual(s.L2NormOfSolution(phi.ID()),
                            t.L2NormOfSolution(phi.ID()))
コード例 #14
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def testAddSolution2(self):
     formulation = PoissonFormulation.PoissonFormulation(2, True)
     bf = formulation.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(bf, [1.0, 2.0], [3, 4],
                                                    10)
     x = Function.Function_xn(1)
     one = Function.Function_constant(1)
     zero = Function.Function_constant(0)
     phi = formulation.phi(
     )  # VarPtr for main, scalar-valued variable in Poisson problem
     psi = formulation.psi()  # VarPtr for gradient of psi, vector-valued
     soln = Solution.Solution_solution(mesh)
     soln2 = Solution.Solution_solution(mesh)
     soln.projectOntoMesh({
         phi.ID(): x,
         psi.ID(): Function.Function_vectorize(one, zero)
     })
     soln.addSolution(soln, 1.0, [phi.ID()])
     self.assertNotEqual(soln.L2NormOfSolution(0),
                         soln2.L2NormOfSolution(0))
コード例 #15
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 def test_cubatureEnrichmentDegree(self):
     poissonForm = PoissonFormulation.PoissonFormulation(2, True)
     poissonBF = poissonForm.bf()
     mesh2 = MeshFactory.MeshFactory_rectilinearMesh(
         poissonBF, [1.0, 1.0], [2, 3], 4)
     s = Solution.Solution_solution(mesh2)
     s.setCubatureEnrichmentDegree(3)
     self.assertEqual(3, s.cubatureEnrichmentDegree())
     s.setCubatureEnrichmentDegree(4)
     self.assertEqual(4, s.cubatureEnrichmentDegree())
     self.assertNotEqual(3, s.cubatureEnrichmentDegree())
コード例 #16
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 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()))
コード例 #17
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 def test_rhs(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)
     rhs = RHS.RHS_rhs()
     s.setRHS(rhs)
     #self.assertEqual(rhs, s.rhs()) this and variatons on it won't  work
     # 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(rhs.nonZeroRHS(0), s.rhs().nonZeroRHS(0))
コード例 #18
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 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))
コード例 #19
0
 def test_solution(self):
     vf = VarFactory.VarFactory()
     p = vf.fieldVar("p")
     v = vf.testVar("v", Var.HGRAD)
     b = BF.BF_bf(vf)
     mp = MeshFactory.MeshFactory_rectilinearMesh(b, [1.0, 1.0], [1, 1], 3)
     soln = Solution.Solution_solution(mp)
     soln.projectOntoMesh({p.ID(): f.xn(2)})
     g = f.solution(p, soln)
     self.assertAlmostEqual(0.0,
                            f.xn(2).l2norm(mp, 2) - g.l2norm(mp, 2),
                            delta=1e-12)
コード例 #20
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
    def test_L2NormOfSolution(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)
        self.assertEqual(0.0, s.L2NormOfSolution(0))

        x = Function.Function_xn(1)
        one = Function.Function_constant(1)
        zero = Function.Function_constant(0)
        phi = poissonForm.phi(
        )  # VarPtr for main, scalar-valued variable in Poisson problem
        psi = poissonForm.psi()  # VarPtr for gradient of psi, vector-valued
        r = Solution.Solution_solution(mesh)
        r.projectOntoMesh({
            phi.ID(): x,
            psi.ID(): Function.Function_vectorize(one, zero)
        })
        r.addSolution(r, 1.0, [phi.ID()])
        self.assertAlmostEqual(1.333333333333334, r.L2NormOfSolution(0))
        self.assertAlmostEqual(216, r.L2NormOfSolution(1))
コード例 #21
0
ファイル: TestFunction.py プロジェクト: VsPun/PyCamellia
 def testSolution(self):
     vf = VarFactory.VarFactory()
     p = vf.fieldVar("p")
     v = vf.testVar("v", Var.HGRAD)
     b = BF.BF_bf(vf)
     msh = MeshFactory.MeshFactory_rectilinearMesh(b, [1.0, 1.0], [1, 1], 2)
     s = Solution.Solution_solution(msh)
     s.projectOntoMesh({p.ID(): Function.Function_xn(45)})
     r = Function.Function_solution(p, s)
     self.assertAlmostEqual(Function.Function_xn(45).l2norm(msh, 0) -
                            r.l2norm(msh, 0),
                            0.00028653041840038087,
                            delta=1e-12)
コード例 #22
0
ファイル: MeshTests.py プロジェクト: VsPun/PyCamellia
    def testMeshNormal(self):

        poissonForm = PoissonFormulation.PoissonFormulation(2, True)
        poissonBF = poissonForm.bf()
        h1Order = 2
        cellsX = 2
        cellsY = 3
        numElements = cellsX * cellsY
        activeCellIDs = tuple([])
        for i in range(0, numElements):
            activeCellIDs += tuple([i])
        testMesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.2, 1.4], [cellsX,cellsY], h1Order) 
        

        self.assertTrue(testMesh.cellPolyOrder(0) == h1Order, "h1Order Broken")
        self.assertTrue(testMesh.numFluxDofs() + testMesh.numFieldDofs() == testMesh.numGlobalDofs())
        self.assertTrue(numElements == testMesh.numElements())
        self.assertTrue(numElements == testMesh.numActiveElements())
        self.assertTrue(activeCellIDs == testMesh.getActiveCellIDs())
        self.assertTrue(testMesh.getDimension() == 2)
        polyOrder = testMesh.cellPolyOrder(0)

        testMesh.pRefine(tuple([0]))
        testMesh.hRefine(tuple([0]))
        numElements += 4
        numActiveElements = numElements - 1
        polyOrder += 1


        self.assertTrue(polyOrder == testMesh.cellPolyOrder(0))
        self.assertTrue(numElements == testMesh.numElements())
        self.assertTrue(numActiveElements == testMesh.numActiveElements())


#Could not figure out how to get registersolution, unregistersolution to work

        solution = Solution.Solution_solution(testMesh)
        testMesh.registerSolution(solution)
        testMesh.unregisterSolution(solution)

        filename = "./tests/team6/B.1.HDF5"
        testMesh.saveToHDF5(filename)
        
 #Could not figure out how to get loadfromHDF5 (& maybe save) to work
        # Load saved Mesh from HDF5
#        testMesh2 = MeshFactory.MeshFactory_loadFromHDF5(poissonBF,filename)

        # Load triangle from HDF5
        testMesh3 = MeshFactory.MeshFactory_readTriangle("./tests/team6/A.1", poissonBF, 2, 3)
コード例 #23
0
    def testSolution(self):
        poissonForm = PoissonFormulation.PoissonFormulation(2, True)
        poissonBF = poissonForm.bf()
        mesh1 = MeshFactory.MeshFactory_rectilinearMesh(
            poissonBF, [1.0, 1.0], [1, 1], 2)
        mesh2 = MeshFactory.MeshFactory_rectilinearMesh(
            poissonBF, [4.0, 4.0], [1, 1], 2)
        mesh3 = MeshFactory.MeshFactory_rectilinearMesh(
            poissonBF, [1.0, 4.0], [1, 1], 2)

        varFact = VarFactory.VarFactory()
        fVar = varFact.fieldVar("f")

        sol1 = Solution.Solution_solution(mesh1)
        sol2 = Solution.Solution_solution(mesh2)
        sol3 = Solution.Solution_solution(mesh3)

        sol1.projectOntoMesh({fVar.ID(): Function.Function_xn(1000)})
        sol2.projectOntoMesh({fVar.ID(): Function.Function_xn(1)})
        sol3.projectOntoMesh({fVar.ID(): Function.Function_xn(400)})

        fn1 = Function.Function_solution(fVar, sol1)
        fn2 = Function.Function_solution(fVar, sol2)
        fn3 = Function.Function_solution(fVar, sol3)

        a1 = Function.Function_xn(1000).l2norm(mesh1)
        a2 = Function.Function_xn(1).l2norm(mesh2)
        a3 = Function.Function_xn(400).l2norm(mesh3)

        b1 = fn1.l2norm(mesh1)
        b2 = fn2.l2norm(mesh2)
        b3 = fn3.l2norm(mesh3)

        self.assertAlmostEqual(0.0, a1 - b1, delta=1e-12)
        self.assertAlmostEqual(0.0, a2 - b2, delta=1e-12)
        self.assertAlmostEqual(0.0, a3 - b3, delta=1e-12)
コード例 #24
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
 def test_projectOntoMesh(self):
     poissonForm = PoissonFormulation.PoissonFormulation(2, True)
     poissonBF = poissonForm.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.0, 1.0],
                                                    [2, 3], 4)
     x = Function.Function_xn(1)
     one = Function.Function_constant(1)
     zero = Function.Function_constant(0)
     phi = poissonForm.phi()
     psi = poissonForm.psi()
     r = Solution.Solution_solution(mesh)
     self.assertEqual(0.0, r.L2NormOfSolution(0))
     r.projectOntoMesh({
         phi.ID(): x,
         psi.ID(): Function.Function_vectorize(one, zero)
     })
     self.assertNotEqual(
         0.0, r.L2NormOfSolution(0))  #L2Norm can't be 0 after projection
コード例 #25
0
ファイル: TestSolution.py プロジェクト: kkent908/phase1
 def testProjOntoMesh(self):
     poissonForm = PoissonFormulation.PoissonFormulation(2, True)
     poissonBF = poissonForm.bf()
     mesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.0, 1.0],
                                                    [2, 3], 4)
     phi = poissonForm.phi(
     )  # VarPtr for main, scalar-valued variable in Poisson problem
     psi = poissonForm.psi()  # VarPtr for gradient of psi, vector-valued
     x = Function.Function_xn(1)
     y = Function.Function_yn(1)
     one = Function.Function_constant(1)
     zero = Function.Function_constant(0)
     soln = Solution.Solution_solution(mesh)
     self.assertEquals(0.0, soln.L2NormOfSolution(phi.ID()))
     soln.projectOntoMesh({
         phi.ID(): x,
         psi.ID(): Function.Function_vectorize(one, zero)
     })
     self.assertNotEquals(0.0, soln.L2NormOfSolution(phi.ID()))
コード例 #26
0
ファイル: TestSolution.py プロジェクト: VsPun/PyCamellia
    def test_save_and_load(self):
        poissonForm = PoissonFormulation.PoissonFormulation(2, True)
        poissonBF = poissonForm.bf()
        mesh2 = MeshFactory.MeshFactory_rectilinearMesh(
            poissonBF, [1.0, 1.0], [2, 3], 4)
        s = Solution.Solution_solution(mesh2)

        x = Function.Function_xn(1)
        one = Function.Function_constant(1)
        zero = Function.Function_constant(0)
        phi = poissonForm.phi(
        )  # VarPtr for main, scalar-valued variable in Poisson problem
        psi = poissonForm.psi()  # VarPtr for gradient of psi, vector-valued

        s.projectOntoMesh({
            phi.ID(): x,
            psi.ID(): Function.Function_vectorize(one, zero)
        })
        s.addSolution(s, 1.0, [phi.ID()])
        s.save("location")  # if no exception, this is a success
コード例 #27
0
    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)
コード例 #28
0
ファイル: BFTest.py プロジェクト: VsPun/PyCamellia
fieldVar = varFac.fieldVar("fieldVar")
testVar1 = varFac.testVar("testVar", Var.HGRAD)
testVar2 = varFac.testVar("testVar2", Var.HGRAD)

lttestVars = 1.0 * testVar1
lttrial = 1.0 * fieldVar

testFlux = varFac.fluxVar("testFlux")
testFluxID = testFlux.ID()

bf = BF.BF_bf(varFac)

vecd = [1.0, 1.0]
veci = [1, 1]
mesh = MeshFactory.MeshFactory_rectilinearMesh(bf, vecd, veci, 2)
soln = Solution.Solution_solution(mesh)

spaceDim = 2
function1 = Function.Function_xn()

useConformingTraces = True
poissonForm = PoissonFormulation.PoissonFormulation(spaceDim,
                                                    useConformingTraces)
stokesForm = StokesVGPFormulation.StokesVGPFormulation(spaceDim,
                                                       useConformingTraces)
stokesBF = stokesForm.bf()
poissonBF = poissonForm.bf()

u1 = stokesForm.u(1)  # VarPtr for x component of velocity
p = stokesForm.p()  # VarPtr for pressure
コード例 #29
0
dims = MeshFactory.DoubleVector(2, 1.0)  # 2 entries, both initialized to 1.0

polyOrder = 3
H1Order = polyOrder + 1

mesh = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, dims, elems, H1Order)
mesh2 = MeshFactory.MeshFactory_rectilinearMesh(poissonBF, [1.0, 1.0], [2, 3],
                                                H1Order)

print("Before refinement, mesh2 has %i active elements" %
      mesh2.numActiveElements())

mesh2.hRefine([0])

print("After refinement, mesh2 has %i active elements" %
      mesh2.numActiveElements())

x = Function.Function_xn(1)
y = Function.Function_yn(1)
one = Function.Function_constant(1)
zero = Function.Function_constant(0)

s = Solution.Solution_solution(mesh2)
s.projectOntoMesh({
    phi.ID(): x,
    psi.ID(): Function.Function_vectorize(one, zero)
})
s.addSolution(s, 1.0, [phi.ID()])

solnPhi = Function.Function_solution(phi, s)