コード例 #1
0
ファイル: test_1DWetAvalanche.py プロジェクト: szz-11/sedfoam
try:
    proc = subprocess.Popen(['foamListTimes', '-latestTime', '-case', sol],
                            stdout=subprocess.PIPE)
except:
    print("foamListTimes : command not found")
    print("Do you have load OpenFoam environement?")
    sys.exit(0)
output = proc.stdout.read()
tread = output.decode().rstrip().split('\n')[0]

#########################################
# Reading SedFoam results
#########################################
prec = 9
X, Y, Z = fluidfoam.readmesh(sol)

alpha_0 = fluidfoam.readscalar(sol, tread, 'alpha_a')
Ua_0 = fluidfoam.readvector(sol, tread, 'Ua')
p_rbgh_0 = fluidfoam.readscalar(sol, tread, 'p_rbgh')
delta_0 = fluidfoam.readscalar(sol, tread, 'delta')

Y_list = []
alpha_list = []
vel_list = []
p_rbgh_list = []
delta_list = []

tolAlpha = 0.54
for k in range(len(alpha_0)):
    if (alpha_0[k] < tolAlpha):
コード例 #2
0
unstructured mesh by triangulation WITHOUT interpolation on a structured grid
"""

###############################################################################
# Reads the mesh
# --------------
#
# .. note:: It reads the mesh coordinates and stores them in variables x, y
#           and z

# import readmesh function from fluidfoam package
from fluidfoam import readmesh

sol = '../../output_samples/pipeline/'

x, y, z = readmesh(sol)

###############################################################################
# Reads vector and scalar field
# -----------------------------
#
# .. note:: It reads volume scalar field from an unstructured mesh
#           and stores it

# import readvector and readscalar functions from fluidfoam package
from fluidfoam import readvector, readscalar

timename = '25'
vel = readvector(sol, timename, 'Ub')
alpha = readscalar(sol, timename, 'alpha')
コード例 #3
0
    proc = subprocess.Popen(['foamListTimes', '-latestTime', '-case', sol],
                            stdout=subprocess.PIPE)
except:
    print("foamListTimes : command not found")
    print("Do you have load OpenFoam environement?")
    sys.exit(0)
output = proc.stdout.read()
tread = output.decode().rstrip().split('\n')[0]

eps_file = sol + case + '.eps'

#########################################
# Reading SedFoam results
#########################################
prec = 9
X, Y, Z = fluidfoam.readmesh(sol, True, precision=prec)
nx, ny, nz = X.shape

alpha = fluidfoam.readscalar(sol, tread, 'alpha_a', True, precision=prec)
Ua = fluidfoam.readvector(sol, tread, 'Ua', True, precision=prec)
pa = fluidfoam.readscalar(sol, tread, 'pa', True, precision=prec)
Theta = fluidfoam.readscalar(sol, tread, 'Theta', True, precision=prec)

Ny = np.size(Y)
H = np.max(np.max(Y))
U = 1

#########################################
# figure 1
#########################################
コード例 #4
0

#Input file
sol = input('Nombre de la carpeta de la simulacion: ')
#Create time list
Folders = glob.glob(sol + '*')

timename = []
for folder in Folders:
    folder = folder.replace(sol, '')
    if isfloat(folder):
        if float(folder) != 0:
            timename.append(folder)
Outdir = ''  #'Figures/Vel_vec/'

x, y, z = flf.readmesh(sol, True, precision=5)

for t in timename:
    vel = flf.readvector(sol, t, 'U', True, precision=5)
    V = np.sqrt(vel[0, :, :, 0]**2 + vel[1, :, :, 0]**2)
    #Color plot
    plt.figure(figsize=(6, 6))
    plt.title('z = 0 (m)')
    plt.quiver(x[:, :, 0], y[:, :, 0], vel[0, :, :, 0] / V,
               vel[1, :, :, 0] / V, V)
    plt.colorbar().ax.set_ylabel('|U| (m/s)')
    plt.xlabel('x (m)')
    plt.ylabel('y (m)')
    plt.savefig(Outdir + 'cavity_vec_' + t + '.png')
    plt.close()
コード例 #5
0
#
#
#---------------Loading OpenFoam results--------------------
#
basepath='../'


#
# Loading OpenFoam results
#
casedir='1DBoundaryLayer/'
tout='2000'

sol=basepath+casedir

x, z, y = fluidfoam.readmesh(sol)
k      = fluidfoam.readscalar(sol, tout,'k')
U      = fluidfoam.readvector(sol,tout,'Ub')
Tauf   = fluidfoam.readtensor(sol, tout, 'Taub')
u=U[0,:]
#########################################
#
# Physical parameters
#

rhof=1
nu=7.2727e-5

wallShear = np.max(Tauf[3,:])/rhof

H=np.max(z)
コード例 #6
0
#
# Loading OpenFoam results
#
mypath='../'
#
#  Solution folder
#
basepath='1DStokesBL/'

############################################
# case 1
#
sol = mypath + basepath

x, y, z = fluidfoam.readmesh(sol)

datalist=['3.5','4','4.5','5','5.5' ]

#%%  graphs

#
#
# U
#
#   
i=-1

zex=np.linspace(0,h,200)

コード例 #7
0
component of an OpenFoam vector field from a structured mesh
"""

###############################################################################
# First reads the mesh
# --------------------
#
# .. note:: It reads the mesh coordinates for a structured mesh (argument True)
#           and stores them in variables x, y and z

# import readmesh function from fluidfoam package
from fluidfoam import readmesh

sol = '../../output_samples/box/'

x, y, z = readmesh(sol, True)

###############################################################################
# Reads a vector field
# --------------------
#
# .. note:: It reads a vector field from a structured mesh
#           and stores it in vel variable

# import readvector function from fluidfoam package
from fluidfoam import readvector

timename = '0'
vel = readvector(sol, timename, 'U', True)

###############################################################################
コード例 #8
0
def readXY(sol):
    X, Y, Z = fluidfoam.readmesh(sol)
    return X, Y
コード例 #9
0
from netCDF4 import Dataset
import fluidfoam
import numpy as np

case = '3DChannel560'
basepath = '../LES/'
sol = basepath + case + '/'

#
# Reading SedFoam results
#
tread = '16'

print('########## Writing averaged data file ##########')
# Read vertical coordinates
x, y, z = fluidfoam.readmesh(sol, True, precision=12)
ny = len(y[0, :, 0])
uny = int(ny / 2)
yi = y[0, 0:uny, 0]

# Read temporaly averaged variables
alpha_ta = fluidfoam.readscalar(sol, tread, 'alpha_aMean', True, precision=12)
ubf_ta = fluidfoam.readvector(sol, tread, 'UbMeanF', True, precision=12)
uaf_ta = fluidfoam.readvector(sol, tread, 'UaMeanF', True, precision=12)
ubprimf_ta = fluidfoam.readtensor(sol,
                                  tread,
                                  'UbPrime2MeanF',
                                  True,
                                  precision=12)
uaprimf_ta = fluidfoam.readtensor(sol,
                                  tread,
コード例 #10
0

sol = input('Nombre de la carpeta de la simulacion: ')
#Create time list
Folders = glob.glob(sol + '*')

timename = []
for folder in Folders:
    folder = folder.replace(sol, '')
    if isfloat(folder):
        if float(folder) != 0:
            timename.append(folder)

Outdir = ''  #'Figures/Streamlines/'

x, y, z = flf.readmesh(sol, True)

for t in timename:
    vel = flf.readvector(sol, t, 'U', True)
    #Module of velocity. The quantity is measured transposed, according to stream plot config.
    V = np.sqrt(vel[0, :, :, 0].T**2 + vel[1, :, :, 0].T**2)
    #Color plot
    plt.figure(figsize=(6, 6))
    plt.title('z = 0 (m)')
    #plt.plot(y[:,:,0],x[:,:,0],'.w')
    plt.streamplot(y[:, :, 0],
                   x[:, :, 0],
                   vel[0, :, :, 0].T,
                   vel[1, :, :, 0].T,
                   color=V,
                   linewidth=2,
コード例 #11
0
ファイル: plot_1_contour.py プロジェクト: fluiddyn/fluidfoam
vector field from a structured mesh
"""

###############################################################################
# First reads the mesh and print the shape/size of the mesh
# ---------------------------------------------------------
#
# .. note:: It reads the mesh coordinates for a structured mesh (argument True)
#           and stores them in variables x, y and z

# import readmesh function from fluidfoam package
from fluidfoam import readmesh

sol = '../../output_samples/box/'

x, y, z = readmesh(sol, structured=True)

nx, ny, nz = x.shape
print("Nx = ", nx, "Ny = ", ny, "Nz = ", nz)

###############################################################################
# Reads a vector field
# --------------------
#
# .. note:: It reads a vector field from a structured mesh
#           and stores it in vel variable

# import readvector function from fluidfoam package
from fluidfoam import readvector

timename = '0'
コード例 #12
0
vector field from a boundary (patch) of a structured mesh
"""

###############################################################################
# First reads the mesh and print the shape/size of the mesh boundary
# ------------------------------------------------------------------
#
# .. note:: It reads the mesh coordinates of a boundary for a structured mesh
#           and stores them in variables x, y and z

# import readmesh function from fluidfoam package
from fluidfoam import readmesh

sol = "../../output_samples/box/"

x, y, z = readmesh(path=sol, structured=True, boundary="topWall")

nface = x.shape
print("Boundary shape = ", nface)

###############################################################################
# Reads a vector field
# --------------------
#
# .. note:: It reads a vector field of a boundary from a structured mesh
#           and stores it in vel variable

# import readvector function from fluidfoam package
from fluidfoam import readvector

timename = "0"