コード例 #1
0
def test_neumann():
    boundary_derivative_function = flux_functions.Zero()
    bc = boundary.Neumann(boundary_derivative_function)

    basis_ = basis.LegendreBasis1D(3)
    mesh_ = mesh.Mesh1DUniform(0.0, 1.0, 10)
    f = x_functions.Sine()
    dg_solution = basis_.project(f, mesh_)
    problem = smooth_scalar_example.SmoothScalarExample(1.0, f)

    riemann_solver = riemann_solvers.LocalLaxFriedrichs(problem)
    boundary_faces = mesh_.boundary_faces
    t = 0.0

    flux = bc.evaluate_boundary(dg_solution, boundary_faces[0], riemann_solver,
                                t)
    assert flux is not None
コード例 #2
0
def test_interior():
    bc = boundary.Extrapolation()

    basis_ = basis.LegendreBasis1D(3)
    mesh_ = mesh.Mesh1DUniform(0.0, 1.0, 10)
    f = x_functions.Sine()
    dg_solution = basis_.project(f, mesh_)
    problem = smooth_scalar_example.SmoothScalarExample(1.0, f)

    riemann_solver = riemann_solvers.LocalLaxFriedrichs(problem)
    boundary_faces = mesh_.boundary_faces
    t = 0.0

    flux = bc.evaluate_boundary(dg_solution, boundary_faces[0], riemann_solver,
                                t)
    x = mesh_.get_face_position(boundary_faces[0])
    assert flux == dg_solution(x)
コード例 #3
0
def test_periodic():
    bc = boundary.Periodic()
    basis_ = basis.LegendreBasis1D(3)
    mesh_ = mesh.Mesh1DUniform(0.0, 1.0, 10)

    f = x_functions.Sine()
    dg_solution = basis_.project(f, mesh_)
    problem = smooth_scalar_example.SmoothScalarExample(1.0, f)

    riemann_solver = riemann_solvers.LocalLaxFriedrichs(problem)
    boundary_faces = mesh_.boundary_faces
    t = 0.0

    flux_0 = bc.evaluate_boundary(dg_solution, boundary_faces[0],
                                  riemann_solver, t)
    flux_1 = bc.evaluate_boundary(dg_solution, boundary_faces[1],
                                  riemann_solver, t)
    # fluxes should be the same
    assert flux_0 == flux_1
コード例 #4
0
from apps.onedimensional.advection.smoothscalarexample import smooth_scalar_example as asse
from apps.onedimensional.burgers import burgers
from apps.onedimensional.linearsystem.smoothexample import smooth_example as lsse
from pydogpack.riemannsolvers import riemann_solvers
from pydogpack.utils import x_functions

import numpy as np

tolerance = 1e-12

advection_problem = asse.SmoothScalarExample(1.0, x_functions.Sine())
# burgers_problem = None
ic = x_functions.ComposedVector([x_functions.Sine(), x_functions.Cosine()])
linear_system_problem = lsse.SmoothExample(np.array([[1, 5], [5, 1]]), ic)
# shallow_water_problem = None
problem_list = [
    advection_problem,
    # burgers_problem,
    linear_system_problem,
    # shallow_water_problem,
]
default_q_list = [
    0.5,
    # 0.5,
    np.array([0.5, 0.5]),
    # np.array([0.5, 0.5]),
]


def sample_problems(riemann_solver_class, do_check_monotonicity=True):
    for i in range(len(problem_list)):
コード例 #5
0
from pydogpack.basis import basis
from pydogpack.mesh import boundary
from pydogpack.mesh import mesh
from pydogpack.riemannsolvers import riemann_solvers
from pydogpack.tests.utils import utils
from pydogpack.utils import dg_utils
from pydogpack.utils import functions
from pydogpack.utils import math_utils
from pydogpack.utils import x_functions

# TODO: could refactor these tests possibly

tolerance = 1e-10
initial_condition = functions.Sine(offset=2.0)

advection_problem = advection_sse.SmoothScalarExample()
burgers_problem = burgers_se.SmoothExample()

test_problems = [advection_problem, burgers_problem]


def test_evaluate_weak_form():
    periodic_bc = boundary.Periodic()
    t = 0.0
    for problem in test_problems:
        exact_time_derivative = problem.exact_time_derivative
        initial_time_derivative = x_functions.FrozenT(exact_time_derivative,
                                                      0.0)
        riemann_solver = riemann_solvers.LocalLaxFriedrichs(problem)
        for basis_class in basis.BASIS_LIST:
            for num_basis_cpts in range(1, 4):