Esempio n. 1
0
H_OUT = FREE_SURFACE_0
FINAL_TIME = 1000.

################################################################################
#
# Time loop:
#--------------------

simutime = fk.SimuTime(final_time=FINAL_TIME,
                       time_iteration_max=100000,
                       second_order=True)

# Plot figure scheduler:
WHEN = [FINAL_TIME - 1.]
create_figure_scheduler = fk.schedules(times=WHEN)

################################################################################
#
# Mesh:
#--------------------
# .. math::
#
#     L = 25 m, l = 1 m
#
dir_path = os.path.abspath(os.path.dirname(sys.argv[0]))
triangular_mesh = fk.TriangularMesh.from_msh_file(dir_path +
                                                  '/inputs/bump.mesh')

if not args.nographics:
    fk_plt.plot_mesh(triangular_mesh)
Esempio n. 2
0
BOX_X_MIN = 0
BOX_Y_MAX = -1
BOX_Y_MIN = -2
RADIUS = 0.6
A = ga.Point3D(-3.14, 2.3, 0.84)
B = ga.Point3D(-3.14, 0.6, 0.84)
SCALE_H = 5.

################################################################################
#
# Time loop:
#--------------------

simutime = fk.SimuTime(final_time=FINAL_TIME, second_order=False)

output_scheduler = fk.schedules(count=NB_VTK)
output_scheduler_lag = fk.schedules(count=NB_VTK)

################################################################################
#
# Mesh:
#--------------------

dir_path = os.path.abspath(os.path.dirname(sys.argv[0]))
triangular_mesh = fk.TriangularMesh.from_msh_file(dir_path +
                                                  '/inputs/raceway.msh')
NC = triangular_mesh.NV
if WITH_PARTICLES: triangular_mesh.set_neighbours()

if not args.nographics:
    fk_plt.plot_mesh(triangular_mesh, plot_labels=False)
Esempio n. 3
0
os.system('rm -r outputs')
#sphinx_gallery_thumbnail_number = 4

################################################################################
#
# Restart scheduler:
#--------------------
#
#To enable the restart, you have to set a restart ``Scheduler`` and pass it to the
#``Problem`` class. Here we set the restart scheduler to time and set it to 1,2 and 3s.
#At the first time set simulation will stop and create a back up save file. Saved data ara stored
#inside a ``restart_data.h5`` file that allow to perform a restart of the simulation
#from the time it stopped.
#
restart_times = [1., 2., 3.]
restart_scheduler = fk.schedules(times=restart_times)

################################################################################
#
#.. note::
#   Restart can be performed several times in the same simulation. In our case,
#   simulation time is splitted in 4 sections, and 3 iterative restarts are performed.
#

################################################################################
#
# Case set-up:
#--------------------
#
simutime = fk.SimuTime(final_time=4.,
                       time_iteration_max=20000,
    ], 'bx')
    if scheduler.now(simutime):
        plt.plot([simutime.time], [yplot], 'ro')
    while not simutime.is_finished:
        simutime.increment()
        plt.plot([
            simutime.time,
        ], [
            yplot,
        ], 'bx')
        if scheduler.now(simutime):
            plt.plot([simutime.time], [yplot], 'ro')
    plt.text(0., yplot + 0.25, text)
    yplot -= 1


yplot = 6

run(fk.schedules(time_delta=1.5), 'Every 1.5 seconds')
run(fk.schedules(iteration_delta=5), 'Every 5 time iterations')
run(fk.schedules(times=[0.5, 1., 4.5, 5.]), 'At given times')
run(fk.schedules(iterations=[10, 12, 14, 16]), 'At given time iterations')
run(fk.schedules(count=4), '4 equaly time-separated')
run(fk.schedules(never=True), 'Never')
run(fk.schedules(always=True), 'Always')

plt.xlim(-0.5, 5.5)
plt.ylim(-0.5, 7)
plt.grid()
plt.show()
Esempio n. 5
0
################################################################################
#
#.. note::
#
#   * Once again, tracer labels are used to apply source terms on each one of the tracers.
#   * Note that tracer sources can be set in kg instead of [T]=kg/m3 in the case of species. The corresponding concentration source term is computed based on cell volume and mass source.

################################################################################
#
# Writter:
#----------------------
#

NB_VTK = 10
vtk_writer = fk.VTKWriter(triangular_mesh,
                          scheduler=fk.schedules(count=NB_VTK),
                          scale_h=5.)

################################################################################
#
# Problem definition:
#--------------------

problem = fk.Problem(simutime,
                     triangular_mesh,
                     layer,
                     primitives,
                     slides=slides,
                     fluvial_heights=fluvial_heights,
                     fluvial_flowrates=fluvial_flowrates,
                     tracers=tracers,
        'ipres':case.ipres}

    simutime_list.append(fk.SimuTime(
        final_time=FINAL_TIME,
        time_iteration_max=1000000,
        second_order=time_second_order))

    bump_analytic_list.append(fk.Bump(
        triangular_mesh_list[mesh_id],
        case=FLOW,
        q_in=Q_IN,
        h_out=H_OUT,
        free_surface_init=FREE_SURFACE_0,
        x_b = X_B,
        topo = topo_gaussian,
        scheduler=fk.schedules(times=WHEN),
        compute_error=True,
        error_type='L2',
        error_output='txt'))

    bump_analytic_list[I](0.)

    layer_list.append(fk.Layer(
        case.NL, triangular_mesh_list[mesh_id],
        topography=bump_analytic_list[I].topography))

    primitives_list.append(fk.Primitive(
        triangular_mesh_list[mesh_id],
        layer_list[I],
        free_surface=FREE_SURFACE_0,
        QXinit=Q_IN,
Esempio n. 7
0
#Numerical scheme:
IPRES = True
SECOND_ORDER = True
NL = 2

################################################################################
#
# Time loop:
#--------------------

simutime = fk.SimuTime(final_time=4.5,
                       time_iteration_max=10000,
                       second_order=SECOND_ORDER)

when = [0., 2.25, 4.5]
create_figure_scheduler = fk.schedules(times=when)

################################################################################
#
# Mesh:
#--------------------
dir_path = os.path.abspath(os.path.dirname(sys.argv[0]))
TG, vertex_labels, boundary_labels = fk.read_msh(dir_path +
                                                 '/inputs/thacker2d.msh')
x = np.asarray(TG.x)
y = np.asarray(TG.y)
trivtx = np.asarray(TG.trivtx)

x *= 0.4
y *= 0.4
    HL = problem.primitives.HL
    NC = HL.shape[0]
    NL = HL.shape[1]
    unity = np.ones((NC,NL))
    cell_area = problem.finite_volume_mesh.cells.area
    volume = fk.compute_integral(cell_area, HL, unity)
    print("Total volume = ", volume, "m3")

def compute_mass(problem):
    HL = problem.primitives.HL
    Rho = problem.primitives.Rho
    cell_area = problem.finite_volume_mesh.cells.area
    mass = fk.compute_integral(cell_area, HL, Rho)
    print("Total mass = ", mass, "kg")

custom_scheduler = fk.schedules(count=5)
custom_functions = {'volume':compute_volume, 'mass':compute_mass}

################################################################################
#
# Writter: 
#----------------------
#

NB_VTK = 10

vtk_writer = fk.VTKWriter(triangular_mesh, scheduler=fk.schedules(count=NB_VTK),
                          scale_h=20.)

################################################################################
#  
Esempio n. 9
0
fluvial_heights = [fk.FluvialHeight(ref=3, height=10.)]

slides = [
    fk.Slide(ref=1,
             horizontal_viscosity=PHY_PARAMS['horizontal_viscosity'],
             wall_friction_coeff=PHY_PARAMS['friction_coeff'])
]

################################################################################
#
# Writter:
#----------------------

vtk_writer = fk.VTKWriter(triangular_mesh,
                          scheduler=fk.schedules(count=10),
                          scale_h=10.)

################################################################################
#
# Problem definition:
#--------------------
#
#Problem is called with basic parameters (simutime, mesh, layer, primitives and
#boundary conditions). See API for other useful ``fk.Problem`` parameters.

river = fk.Problem(simutime,
                   triangular_mesh,
                   layer,
                   primitives,
                   slides=slides,
Esempio n. 10
0
parser.add_argument('--nographics', action='store_true')
args = parser.parse_args()

#sphinx_gallery_thumbnail_number = 3

################################################################################
#
# Time loop:
#--------------------

FINAL_TIME = 10.
simutime = fk.SimuTime(final_time=FINAL_TIME,
                       time_iteration_max=20000,
                       second_order=True)

create_figure_scheduler = fk.schedules(times=[0., 4., 8.])

################################################################################
#
# Mesh:
#--------------------

dir_path = os.path.abspath(os.path.dirname(sys.argv[0]))
triangular_mesh = fk.TriangularMesh.from_msh_file(dir_path +
                                                  '/inputs/square2.mesh')

if not args.nographics:
    fk_plt.plot_mesh(triangular_mesh)

################################################################################
#
Esempio n. 11
0
parser = argparse.ArgumentParser()
parser.add_argument('--nographics', action='store_true')
args = parser.parse_args()

#sphinx_gallery_thumbnail_number = 2

################################################################################
#
# Time loop:
#--------------------

simutime = fk.SimuTime(final_time=5.,
                       time_iteration_max=2000,
                       second_order=True)

create_figure_scheduler = fk.schedules(times=[1., 2., 3., 4., 5.])

################################################################################
#
# Mesh:
#--------------------

dir_path = os.path.abspath(os.path.dirname(sys.argv[0]))
triangular_mesh = fk.TriangularMesh.from_msh_file(dir_path +
                                                  '/inputs/square.msh')

if not args.nographics:
    fk_plt.plot_mesh(triangular_mesh, plot_labels=False)

################################################################################
#
Esempio n. 12
0
os.system('rm -r outputs')

#sphinx_gallery_thumbnail_number = 5
parser = argparse.ArgumentParser()
parser.add_argument('--nographics', action='store_true')
args = parser.parse_args()

################################################################################
#
# Time loop:
#--------------------

FINAL_TIME = 20.
simutime = fk.SimuTime(final_time=FINAL_TIME, time_iteration_max=20000, second_order=True)

create_figure_scheduler = fk.schedules(times=[0., 4., 6., 8.])

################################################################################
#  
# Mesh:
#--------------------

dir_path = os.path.abspath(os.path.dirname(sys.argv[0]))
TG, vertex_labels, boundary_labels = fk.read_msh(dir_path + '/inputs/square2.mesh')
x = np.asarray(TG.x)
y = np.asarray(TG.y)
trivtx = np.asarray(TG.trivtx)

x *= 10.
y *= 10.
Esempio n. 13
0
    else:
        T0 = 0.0
    return T0


tracers = [fk.Tracer(triangular_mesh, layer, primitives, Tinit_funct=T_0)]

################################################################################
#
# Writter:
#----------------------
#

NB_VTK = 10
vtk_writer = fk.VTKWriter(triangular_mesh,
                          scheduler=fk.schedules(count=NB_VTK),
                          scale_h=5.)

txt_writer = fk.TXTWriter([84], scheduler=fk.schedules(count=5))

################################################################################
#
# Problem definition:
#--------------------

problem = fk.Problem(simutime,
                     triangular_mesh,
                     layer,
                     primitives,
                     slides=slides,
                     lagrangian=lagrangian,