def check(self, time, soln, tolerance, expected=True):
     from ooflib.engine import mesh
     from ooflib.SWIG.engine import field
     
     mesh_obj = mesh.meshes["microstructure:skeleton:mesh"].getObject()
     L2_error = exact_solns.computeScalarErrorL2(
         soln, mesh_obj, Temperature, self.numX, self.numY, time=time)
     print >> sys.stderr, "L2 error = %g" % L2_error
     self.assert_((L2_error < tolerance) == expected)
示例#2
0
    def check(self, time, soln, tolerance, expected=True):
        from ooflib.engine import mesh
        from ooflib.SWIG.engine import field

        mesh_obj = mesh.meshes["microstructure:skeleton:mesh"].getObject()
        L2_error = exact_solns.computeScalarErrorL2(soln,
                                                    mesh_obj,
                                                    Temperature,
                                                    self.numX,
                                                    self.numY,
                                                    time=time)
        print >> sys.stderr, "L2 error = %g" % L2_error
        self.assert_((L2_error < tolerance) == expected)
    def heatEqnEngine(self, test_no, soln_no, test_solver, test_stepper,
                      tolerance):

        soln_func = self.heat_solns[soln_no]["Solution"]
        init_func = self.heat_solns[soln_no]["InitialValue"]

        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=UniformDriver(stepsize=self.timestep,
                                           stepper=test_stepper),
                nonlinear_solver=test_solver,
                symmetric_solver=ConjugateGradient(
                    preconditioner=ILUPreconditioner(),
                    tolerance=1e-13,
                    max_iterations=1000),
                asymmetric_solver=BiConjugateGradient(
                    preconditioner=ILUPreconditioner(),
                    tolerance=1e-13,
                    max_iterations=1000)))

        OOF.Mesh.Set_Field_Initializer(
            mesh='microstructure:skeleton:mesh',
            field=Temperature,
            initializer=FuncScalarFieldInit(function=init_func))
        OOF.Mesh.Apply_Field_Initializers_at_Time(
            mesh='microstructure:skeleton:mesh', time=0.0)

        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=self.time)

        from ooflib.engine import mesh
        from ooflib.SWIG.engine import field

        mesh_obj = mesh.meshes["microstructure:skeleton:mesh"].getObject()
        field_ptr = field.getField("Temperature")

        L2_error = exact_solns.computeScalarErrorL2(soln_func,
                                                    mesh_obj,
                                                    field_ptr,
                                                    self.numX,
                                                    self.numY,
                                                    self.numZ,
                                                    time=self.time)
        print "L2 error: ", L2_error

        self.assert_(L2_error < tolerance)
    def heatEqnEngine(self, test_no, soln_no):

        soln_func = self.heat_solns[soln_no]["Solution"]

        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=StaticDriver(),
                nonlinear_solver=NoNonlinearSolver(),
                symmetric_solver=ConjugateGradient(
                    preconditioner=ILUPreconditioner(),
                    tolerance=1e-13,
                    max_iterations=1000),
                asymmetric_solver=BiConjugateGradient(
                    preconditioner=ILUPreconditioner(),
                    tolerance=1e-13,
                    max_iterations=1000)))

        OOF.Mesh.Set_Field_Initializer(
            mesh='microstructure:skeleton:mesh',
            field=Temperature,
            initializer=ConstScalarFieldInit(value=0.0))
        OOF.Mesh.Apply_Field_Initializers(mesh='microstructure:skeleton:mesh')

        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=self.time)

        from ooflib.engine import mesh
        from ooflib.SWIG.engine import field

        mesh_obj = mesh.meshes["microstructure:skeleton:mesh"].getObject()
        field_ptr = field.getField("Temperature")

        L2_error = exact_solns.computeScalarErrorL2(soln_func,
                                                    mesh_obj,
                                                    field_ptr,
                                                    self.numX,
                                                    self.numY,
                                                    self.numZ,
                                                    time=self.time)
        print "L2 error: ", L2_error

        # We've checked that the L2_error is scaling correctly with
        # the grid size, so this test is run with a coarse grid and a
        # large tolerance to make it fast.
        self.assert_(L2_error < 1.e-1)