In [1]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
%load_ext line_profiler
from Lib.BEM_Solver.BEM_2D import *
In [2]:
BEM_Case1=BEM2D()
#1.Build Mesh
Boundary_vert=[(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)] #Anti-clock wise for internal domain
Trace_vert=[((0.3, 0.0), (0.3, 0.5)),((0.6, 0.0), (0.6, 0.5))]#No direction requirement
element_esize=1.0
element_tszie=0.2
BEM_Case1.set_Mesh(Boundary_vert,Trace_vert,element_esize,element_tszie,Type="Quad")
#2.Set Boundary condition
bc0=[(3,100)]
bc1=[(2,-25),(0,-25)]
BEM_Case1.set_BoundaryCondition(DirichletBC=bc0,NeumannBC=bc1)
#BEM_Case1.print_debug()
#3. Solve and plot
BEM_Case1.DFN=0
BEM_Case1.Solve()
PUV=BEM_Case1.plot_Solution(v_range=(0,160),p_range=(50,100))
PUV2=BEM_Case1.plot_SolutionBD()
In [3]:
from Lib.Mesh.TriMesh2D import *
In [5]:
#Mesh2D matlab backend-Win
import transplant #Matlab processer
mlab = transplant.Matlab(arguments=('-nosplash','-nodesktop','-nojvm','-minimize'))
mlab.addpath(r'G:\2.MeshGenerator-0428\mesh2d',nargout=0)
In [4]:
#Mesh2D matlab backend-Linux
import transplant #Matlab processer
mlab = transplant.Matlab(arguments=('-nosplash','-nodesktop','-nojvm','-minimize'))
mlab.addpath(r'/media/binwang/9CF2A927F2A9069C/2.MeshGenerator-0428/mesh2d',nargout=0)
In [5]:
Mesh=Mesh2D(Boundary_vert,Trace_vert,element_size=0.1)
Mesh.MeshBuild(Library="Mesh2D",matlab=mlab)
In [82]:
#Trace_vert=[((0.6, 0.0), (0.3, 0.5)),((0.2, 0.2), (0.7, 0.9)),((0.9, 0.0), (0.8, 0.9)),((0.0, 0.3), (1.0, 0.3))]
Mesh=Mesh2D(Boundary_vert,Trace_vert,element_size=1,trace_element_size=0.15/3)
Mesh.MeshBuild(Library="Mesh2D",matlab=mlab,refinement=0.3)
In [6]:
#4. Assign the pressure, velocity to mesh nodes
NumNodes=len(Mesh.mesh_points)
for i in range(NumNodes):
Pts=Mesh.mesh_points[i]
PUV=BEM_Case1.get_Solution(Pts)
Mesh.p[i]=PUV[0]
Mesh.vx[i]=PUV[1]
Mesh.vy[i]=PUV[2]
In [7]:
from Lib.Streamline.Streamline_Tracing import *
SLs_Case1=Streamlines()
In [14]:
#Define the start edge,streamline number
StartPts=SLs_Case1.initSL(NSL=20,BDid=3,Meshobj=Mesh)
#Trace streamline
SLs,TOFs=SLs_Case1.traceSLs()
#PLot streamline
SLs_Case1.plotSLs(SLs,mode=1)
In [11]:
#Function test
for i in range(SLs_Case1.NumSL):
print("Current",i,StartPts[i])
SLs_Case1.trace1SL(Pts0=StartPts[i],TOF0=0.0,debug=1)
In [12]:
#TOFs of the end point
for i in range(SLs_Case1.NumSL):
print(TOFs[i][-1])
In [ ]: