示例#1
0
    # Spatial discretisation
    'tracer_family': args.family or 'dg',
    'stabilisation_tracer': args.stabilisation or 'lax_friedrichs',
    'use_limiter_for_tracers': False if args.limiters == "0" else True,
    # 'use_limiter_for_tracers': bool(args.limiters or False),

    # Mesh movement
    'nonlinear_method': 'relaxation',
    'r_adapt_rtol': 5.0e-2,

    # Misc
    'debug': bool(args.debug or False),
}
if os.getenv('REGRESSION_TEST') is not None:
    kwargs['end_time'] = 1.5
op = BubbleOptions(approach='lagrangian', n=int(args.n or 1))
op.update(kwargs)
if args.dt is not None:
    op.dt = float(args.dt)
if args.end_time is not None:
    op.end_time = float(args.end_time)

# --- Initialise the mesh

tp = AdaptiveProblem(op)

# NOTE: We use Monge-Ampere with a monitor function indicating the initial condition

alpha = 10.0  # Parameter controlling prominance of refined region
eps = 1.0e-03  # Parameter controlling width of refined region
示例#2
0
from thetis import *

import matplotlib.pyplot as plt

from adapt_utils.unsteady.test_cases.bubble_shear.options import BubbleOptions
from adapt_utils.plotting import *

op = BubbleOptions(n=1)
mesh = op.default_mesh
P1_vec = VectorFunctionSpace(mesh, "CG", 1)
u = Function(P1_vec, name="Fluid velocity")

# Plot to pvd
outfile = File('plots/velocity.pvd')
t = 0.0
tc = Constant(0.0)
while t < op.end_time - 1.0e-05:
    print("t = {:.4f}".format(t))
    tc.assign(t)
    u.interpolate(op.get_velocity(mesh.coordinates, tc))
    outfile.write(u)
    t += op.dt_per_export * op.dt * 50

# Plot to jpg
plot_dir = 'plots'
for i in [0, 65, 131, 196]:
    t = 0.0025 * i
    u.interpolate(op.get_velocity(mesh.coordinates, t))
    outfile.write(u)

    fig, axes = plt.subplots()
示例#3
0
    'stabilisation_tracer': args.stabilisation or 'supg',
    'use_limiter_for_tracers': bool(args.limiters or False),

    # Mesh adaptation
    'approach': args.approach or 'hessian',
    'num_meshes': int(args.num_meshes or 50),
    'max_adapt': int(args.max_adapt or 3),
    'hessian_time_combination': args.hessian_time_combination or 'integrate',
    'norm_order': 1,
    'normalisation': 'complexity',

    # I/O and debugging
    'plot_pvd': False,
    'debug': bool(args.debug or False),
}
op = BubbleOptions(approach='hessian', n=int(args.n or 1))
op.update(kwargs)
if args.dt is not None:
    op.dt = float(args.dt)
if args.end_time is not None:
    op.end_time = float(args.end_time)
op.di = create_directory(os.path.join(op.di, op.hessian_time_combination))

# --- Solve the tracer transport problem

assert op.approach != 'fixed_mesh'
for n in range(int(args.min_level or 0), int(args.max_level or 5)):
    op.target = 1000*2**n
    op.dt = 0.01*0.5**n
    op.dt_per_export = 2**n
示例#4
0
    'use_limiter_for_tracers': bool(args.limiters or False),

    # Mesh movement
    'nonlinear_method': 'relaxation',
    'r_adapt_rtol': 5.0e-2,
    'scaled_jacobian_tol': 0.01,
    'target': 2000,
    'normalisation': 'complexity',
    'norm_order': 1,
    'max_adapt': 4,  # TODO
    'hybrid_mode': args.mode or 'm',

    # Misc
    'debug': bool(args.debug or False),
}
op = BubbleOptions(approach='hybrid', n=int(args.n or 1))
op.update(kwargs)


# --- Initialise the mesh

tp = AdaptiveProblem(op)

# NOTE: We use Monge-Ampere with a monitor function indicating the initial condition

alpha = 10.0   # Parameter controlling prominance of refined region
eps = 1.0e-03  # Parameter controlling width of refined region


def monitor(mesh):
    x, y = SpatialCoordinate(mesh)
示例#5
0
kwargs = {
    'tracer_family': args.family or 'cg',
    'stabilisation_tracer': args.stabilisation or 'supg',
    'use_limiter_for_tracers': bool(args.limiters or False),
    'debug': bool(args.debug or False),
}
l2_error = []
cons_error = []
times = []
num_cells = []
dofs = []
for level in range(4):

    # Setup
    op = BubbleOptions(approach='fixed_mesh', n=level)
    op.update(kwargs)
    op.dt_per_export = 2**level
    tp = AdaptiveProblem(op)
    dofs.append(tp.Q[0].dof_count)
    num_cells.append(tp.mesh.num_cells())
    tp.set_initial_condition()
    init_l1_norm = norm(tp.fwd_solutions_tracer[0], norm_type='L1')
    init_l2_norm = norm(tp.fwd_solutions_tracer[0], norm_type='L2')
    init_sol = tp.fwd_solutions_tracer[0].copy(deepcopy=True)

    # Solve forward problem
    cpu_timestamp = perf_counter()
    tp.solve_forward()
    times.append(perf_counter() - cpu_timestamp)
示例#6
0
    'stabilisation_tracer': args.stabilisation or 'supg',
    'use_limiter_for_tracers': bool(args.limiters or False),

    # Mesh adaptation
    'approach': 'hessian',
    'num_meshes': 1,
    'num_adapt': int(args.num_adapt or 3 if metric_advection else 0),
    'target': 1000 * 2**n,
    'norm_order': 1,
    'normalisation': 'complexity',

    # I/0 and debugging
    'plot_pvd': False,
    'debug': bool(args.debug or False),
}
op = BubbleOptions(approach='hessian', n=1)
op.update(kwargs)
op.dt = 0.01 * 0.5**n
num_meshes = int(args.num_meshes or 50)
op.end_time /= num_meshes
dt_per_mesh = int(op.end_time / op.dt)
end_time = op.end_time
dtc = Constant(op.dt)
if metric_advection:
    op.di = os.path.join(op.di, 'metric_advection')
else:
    op.di = os.path.join(op.di, 'on_the_fly')
if plot_pvd:
    tracer_file = File(os.path.join(op.di, 'tracer.pvd'))
theta = Constant(0.5)
示例#7
0
parser.add_argument("-debug", help="Toggle debugging mode.")
args = parser.parse_args()

# --- Set parameters

kwargs = {
    'tracer_family': args.family or 'cg',
    'stabilisation_tracer': args.stabilisation or 'supg',
    'use_limiter_for_tracers': bool(args.limiters or False),
    'debug': bool(args.debug or False),
}
if os.getenv('REGRESSION_TEST') is not None:
    kwargs['dt'] = 0.015
    kwargs['end_time'] = 1.5
op = BubbleOptions(approach='fixed_mesh', n=int(args.n or 1))
op.update(kwargs)
if args.dt is not None:
    op.dt = float(args.dt)
if args.end_time is not None:
    op.end_time = float(args.end_time)

# --- Solve the tracer transport problem

tp = AdaptiveProblem(op)
tp.set_initial_condition()
init_sol = tp.fwd_solutions_tracer[0].copy(deepcopy=True)
init_l1_norm = norm(init_sol, norm_type='L1')
init_l2_norm = norm(init_sol, norm_type='L2')
tp.solve_forward()