Commit 45a78fd8 authored by Matthieu Constant's avatar Matthieu Constant
Browse files

cas test deux fluides

parent 52dce14a
L = 5;
H = 1;
y = 0;
lc = .05;
Point(1) = {-L, H, 0, lc};
Point(2) = {-L, H/2., 0, lc};
Point(3) = {-L,0,0,lc};
Point(4) = {L, 0, 0, lc};
Point(5) = {L,H/2.,0,lc};
Point(6) = {L, H, 0, lc};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 5};
Line(5) = {5, 6};
Line(6) = {6, 1};
Line Loop(1) = {1:6};
Plane Surface(1) = {1};
Physical Line("LeftUp") = {1};
Physical Line("LeftDown") = {2};
Physical Line("RightDown") = {4};
Physical Line("RightUp") = {5};
Physical Line("Bottom") = {3};
Physical Line("Top") = {6};
Physical Surface("Domain") = {1};
Physical Point("PtFix") = {1};
# Marblesbag - Copyright (C) <2010-2018>
# <Universite catholique de Louvain (UCL), Belgium
# Universite de Montpellier, France>
#
# List of the contributors to the development of Marblesbag: see AUTHORS file.
# Description and complete License: see LICENSE file.
#
# This program (Marblesbag) is free software:
# you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program (see COPYING and COPYING.LESSER files). If not,
# see <http://www.gnu.org/licenses/>.
#!/usr/bin/env python
from marblesbag import fluid as fluid
from marblesbag import scontact2
import numpy as np
import os
import time
import shutil
import random
#Physical parameters for the drops are the ones presented by Metzger et al. (2007) "Falling clouds of particles in viscous fluids"
outputdir = "output"
if not os.path.isdir(outputdir) :
os.makedirs(outputdir)
t = 0
ii = 0
#physical parameters
g = -9.81 # gravity
rho = 1000 # fluid density
nu = 1 # kinematic viscosity
mu = nu*rho # dynamic viscosity
tEnd = 100000 # final time
#numerical parameters
lcmin = .1 # mesh size
dt = 5 # time step
alpha = 1e-4 # stabilization coefficient
epsilon = alpha*lcmin**2 /nu # stabilization parametre
print('epsilon',epsilon)
shutil.copy("mesh.msh", outputdir +"/mesh.msh")
outf = 10 # number of iterations between output files
#Object fluid creation + Boundary condition of the fluid (field 0 is horizontal velocity; field 1 is vertical velocity; field 2 is pressure)
#Format: strong_boundaries = [(Boundary tag, Fluid field, Value)
strong_boundaries = [("Top",1,0.),("Bottom",1,0.),("LeftUp",1,0),("RightUp",1,0),("LeftDown",1,0),("RightDown",1,0),("Top",0,0),("Bottom",0,0),("Right",6,0),("LeftUp",0,lambda x : 1/(20*mu)*x[:,1]*(1-x[:, 1])),("LeftDown",0,lambda x : 1/(20*mu)*x[:,1]*(1-x[:, 1])),("LeftUp",2,1),("RightUp",2,1),("Top",2,1),("LeftDown",5,1),("RightDown",5,1),("Bottom",5,1),("LeftUp",5,0),("RightUp",5,0),("Top",5,0),("LeftDown",2,0),("RightDown",2,0),("Bottom",2,0)]
fluid = fluid.fluid_problem("mesh.msh",g,nu*rho,rho,epsilon,strong_boundaries,1)
ii = 0
t = 0
fluid.export_vtk(outputdir,0,0)
ii = 0
tic = time.clock()
while t < tEnd :
#Fluid solver
fluid.implicit_euler(dt)
t += dt
#Output files writting
if ii %outf == 0 :
ioutput = int(ii/outf) + 1
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment