def linearized_manufactured_solution(
        exact_solution, flux_function=None, diffusion_function=None, max_wavespeed=1.0
    ):
        if flux_function is None:
            flux_function = flux_functions.Identity()
        if diffusion_function is None:
            diffusion_function = flux_functions.Polynomial(degree=0)

        # source_function could be computed with original diffusion function
        # or with linearized diffusion function
        # ? Would that make a difference?
        source_function = ExactOperator(
            exact_solution, flux_function, diffusion_function, flux_functions.Zero()
        )
        initial_condition = x_functions.FrozenT(exact_solution, 0.0)

        linearized_diffusion_function = xt_functions.LinearizedAboutQ(
            diffusion_function, exact_solution
        )

        problem = ConvectionDiffusion(
            flux_function,
            linearized_diffusion_function,
            source_function,
            initial_condition,
            max_wavespeed,
        )
        problem.exact_solution = exact_solution

        return problem
Exemple #2
0
    def linearized_manufactured_solution(
        exact_solution, flux_function=None, diffusion_function=None, max_wavespeed=1.0
    ):
        if flux_function is None:
            flux_function = flux_functions.Identity()
        if diffusion_function is None:
            diffusion_function = flux_functions.Polynomial(degree=0)

        source_function = ExactOperator(
            exact_solution, flux_function, diffusion_function, flux_functions.Zero()
        )
        initial_condition = x_functions.FrozenT(exact_solution, 0.0)

        linearized_diffusion_function = flux_functions.LinearizedAboutQ(
            diffusion_function, exact_solution
        )

        problem = ConvectionHyperDiffusion(
            flux_function,
            linearized_diffusion_function,
            source_function,
            initial_condition,
            max_wavespeed,
        )
        problem.exact_solution = exact_solution
        return problem
def test_identity():
    flux_function = flux_functions.Identity()
    utils.check_to_from_dict(flux_function, flux_functions)
    # should always give q back out
    for q in range(-10, 10):
        assert flux_function(q) == q
        for x in range(-10, 10):
            assert flux_function(q, x) == q
            for t in range(-10, 10):
                assert flux_function(q, x, t) == q
Exemple #4
0
from pydogpack.basis import basis
from pydogpack.mesh import mesh
from pydogpack.mesh import boundary
from pydogpack.localdiscontinuousgalerkin import utils as ldg_utils
from pydogpack.solution import solution
from pydogpack.tests.utils import utils
from pydogpack.timestepping import time_stepping
from pydogpack.timestepping import implicit_runge_kutta
from pydogpack.utils import flux_functions
from pydogpack.utils import math_utils
from pydogpack.utils import x_functions
from pydogpack.visualize import plot

import numpy as np

identity = flux_functions.Identity()
squared = flux_functions.Polynomial(degree=2)
diffusion_functions = [identity, squared]
# (q q_x)_x
hyper_diffusion_identity = convection_hyper_diffusion.NonlinearHyperDiffusion(
    identity)
# (q^2 q_x)_x
hyper_diffusion_squared = convection_hyper_diffusion.NonlinearHyperDiffusion(
    squared)
test_problems = [hyper_diffusion_identity, hyper_diffusion_squared]
tolerance = 1e-5


def test_ldg_constant():
    # LDG of one should be zero
    t = 0.0