Extraction of Velocity Field #148
Replies: 1 comment
-
Yes. The "Rotor in Hover" tutorial shows how to generate a grid of points where to probe the fluid domain. In that tutorial, The following example generates multiple grid lines in the wake of a rotor: #=##############################################################################
Computes the fluid domain of single rotor simulation using a volumetric domain.
This is done probing the velocity and vorticity that the particle field
induces at each node of a Cartesian grids.
NOTE: The fluid domain generated here does not include the freestream
velocity, which needs to be added manually inside ParaView (if any).
Change log
*
=###############################################################################
import FLOWUnsteady as uns
import FLOWUnsteady: vpm, gt, dot, norm
this_file_path = splitdir(@__FILE__)[1]
this_file_name = splitext(splitdir(@__FILE__)[2])[1]
# --------------- INPUTS AND OUTPUTS -------------------------------------------
# INPUT OPTIONS
simulation_name = "ningdji-test037" # Simulation to read
AOA = 0.0 # (deg) angle of attack
# AOA = 0.0
# AOAeff = AOA==15 ? 8.5 : AOA
AOAeff = AOA
read_path = this_file_path*"/"*simulation_name # Where to read simulation from
pfield_prefix = "singlerotor_pfield" # Prefix of particle field files to read
staticpfield_prefix = "singlerotor_staticpfield" # Prefix of static particle field files to read
# nums = [560] # Time steps to process
# nums = Int.(9*360:-1:6*360)
# nums = Int.(8*360:-1:6.5*360)
nums = Int.(12.5*360:-1:6*360)
# OUTPUT OPTIONS
save_path = joinpath(read_path, "..", simulation_name*"-fdom022-3") # Where to save fluid domain
output_prefix = "singlerotor" # Prefix of output files
prompt = true # Whether to prompt the user
verbose = true # Enable verbose
v_lvl = 0 # Verbose indentation level
# -------------- PARAMETERS ----------------------------------------------------
# Simulation information
R = 0.12 # (m) rotor radius
L = R # (m) reference length
# ntht = 30
ntht = 3
thts = range(0, 360, length=ntht+1)
thts = collect(thts)[1:end-1]
grids = gt.Grid[]
gridnames = String[]
for (xoRi, xoR) in enumerate([0.1, 0.4, 1.2])
dx, dy, dz = L/1000, L/1000, L/1000 # (m) cell size in each direction
Pmin = L*[xoR, -1.25, 0] # (m) minimum bounds
Pmax = L*[xoR, 1.25, 0] # (m) maximum bounds
NDIVS = ceil.(Int, (Pmax .- Pmin)./[dx, dy, dz]) # Number of cells in each direction
for (thti, tht) in enumerate(thts)
grid = gt.Grid(Pmin, Pmax, NDIVS)
M = gt.rotation_matrix2(tht, 0, -AOAeff) # Orientation of grid
gt.lintransform!(grid, M, zeros(3))
push!(grids, grid)
push!(gridnames, "Line_xoR$(xoRi)_tht$(thti)")
end
end
nnodes = sum(grid.nnodes for grid in grids)
# VPM settings
maxparticles = Int(2.5e6 + nnodes) # Maximum number of particles
fmm = vpm.FMM(; p=4, ncrit=50, theta=0.4, phi=0.3) # FMM parameters (decrease phi to reduce FMM noise)
# fmm = vpm.FMM(; p=5, ncrit=400, theta=0.4, phi=0.1) # FMM parameters (decrease phi to reduce FMM noise)
scale_sigma = 1.00 # Shrink smoothing radii by this factor
f_sigma = 0.5 # Smoothing of node particles as sigma = f_sigma*meansigma
maxsigma = L/10 # Particles larger than this get shrunk to this size (this helps speed up computation)
minsigma = -Inf
# minsigma = 0.019
maxmagGamma = Inf # Any vortex strengths larger than this get clipped to this value
# maxmagGamma = 0.001
# maxmagGamma = 0.00003
include_staticparticles = true # Whether to include the static particles embedded in the solid surfaces
other_file_prefs = include_staticparticles ? [staticpfield_prefix] : []
other_read_paths = [read_path for i in 1:length(other_file_prefs)]
if verbose
println("\t"^(v_lvl)*"Fluid domain grid")
# println("\t"^(v_lvl)*"NDIVS =\t$(NDIVS)")
println("\t"^(v_lvl)*"Number of nodes =\t$(nnodes)")
end
# --------------- PROCESSING SETUP ---------------------------------------------
if verbose
println("\t"^(v_lvl)*"Getting ready to process $(read_path)")
println("\t"^(v_lvl)*"Results will be saved under $(save_path)")
end
# Create save path
if save_path != read_path
gt.create_path(save_path, prompt)
end
# Copy this driver file
cp(@__FILE__, joinpath(save_path, splitdir(@__FILE__)[2]); force=true)
# Generate function to process the field clipping particle sizes
preprocessing_pfield = uns.generate_preprocessing_fluiddomain_pfield(maxsigma, maxmagGamma; minsigma=minsigma,
verbose=verbose, v_lvl=v_lvl+1)
# --------------- PROCESS SIMULATION -------------------------------------------
nthreads = 1 # Total number of threads
nthread = 1 # Number of this thread
dnum = floor(Int, length(nums)/nthreads) # Number of time steps per thread
threaded_nums = [view(nums, dnum*i+1:(i<nthreads-1 ? dnum*(i+1) : length(nums))) for i in 0:nthreads-1]
for these_nums in threaded_nums[nthread:nthread]
uns.computefluiddomain( maxparticles,
these_nums, read_path, pfield_prefix,
grids;
fmm=fmm,
f_sigma=f_sigma,
save_path=save_path,
file_pref=output_prefix,
grid_names=gridnames,
other_file_prefs=other_file_prefs,
other_read_paths=other_read_paths,
userfunction_pfield=preprocessing_pfield,
verbose=verbose, v_lvl=v_lvl)
end
|
Beta Was this translation helpful? Give feedback.
-
Is there any way to extract the velocity field for any point in space from the code itself. Can I extract the velocity field for all the particles as well?
Beta Was this translation helpful? Give feedback.
All reactions