initial upload
This commit is contained in:
47
PyLaGriT/examples/julia/calc_volume/calc_volume.jl
Executable file
47
PyLaGriT/examples/julia/calc_volume/calc_volume.jl
Executable file
@@ -0,0 +1,47 @@
|
||||
using PyCall
|
||||
@pyimport pylagrit
|
||||
|
||||
l = pylagrit.PyLaGriT(lagrit_exe="lagrit")
|
||||
|
||||
# Create mesh object 'm'
|
||||
m = l[:create](elem_type="triplane")
|
||||
m[:read]("data.inp")
|
||||
|
||||
# Set imt to 1 for all points
|
||||
m[:setatt]("imt",1)
|
||||
m[:minmax_xyz]()
|
||||
|
||||
# Connect mesh
|
||||
m[:connect]()
|
||||
|
||||
# Lift the triangulation by assigning the Z coordinate to the data value (value)
|
||||
m[:copyatt]("value","zic")
|
||||
m[:minmax_xyz]()
|
||||
|
||||
# Dump surface to vis file
|
||||
m[:dump]("tmp_tri_surf.inp")
|
||||
|
||||
# Extrude mesh to 0
|
||||
mprism = m[:extrude](0.1,offset_type="min",return_type="volume", direction=[0.,0.,-1.])
|
||||
|
||||
# Diagnostic
|
||||
l[:sendline]("quality / volume")
|
||||
|
||||
# Add e_volume attribute of type "volume"
|
||||
mprism[:addatt]("e_volume", keyword="volume")
|
||||
|
||||
# Calculate volume
|
||||
mprism[:math]("sum","volume_sum",attsrc="e_volume")
|
||||
|
||||
# Dump surface to vis file
|
||||
mprism[:dump]("tmp_prism.inp")
|
||||
|
||||
# Just to check the math do this again and assign all the 'values' to 1.0 and see if we get the expected result.
|
||||
mprism[:delete]()
|
||||
m[:setatt]("value", 1.0)
|
||||
m[:copyatt]("value","zic")
|
||||
mprism = m[:extrude](0.1,offset_type="min",return_type="volume", direction=[0.,0.,-1.])
|
||||
l[:sendline]("quality / volume")
|
||||
mprism[:addatt]("e_volume", keyword="volume")
|
||||
mprism[:math]("sum","volume_sum",attsrc="e_volume")
|
||||
|
||||
13
PyLaGriT/examples/julia/calc_volume/data.inp
Executable file
13
PyLaGriT/examples/julia/calc_volume/data.inp
Executable file
@@ -0,0 +1,13 @@
|
||||
5 0 1 0 0
|
||||
1 0. 0. 0.
|
||||
2 1. 0. 0.
|
||||
3 1. 1. 0.
|
||||
4 0. 1. 0.
|
||||
5 .3 .7 0.
|
||||
1 1
|
||||
value, real
|
||||
1 0.1
|
||||
2 0.2
|
||||
3 0.4
|
||||
4 0.4
|
||||
5 0.5
|
||||
112
PyLaGriT/examples/julia/polygon_map/2d_mesh.avs
Executable file
112
PyLaGriT/examples/julia/polygon_map/2d_mesh.avs
Executable file
@@ -0,0 +1,112 @@
|
||||
36 34 4 0 0
|
||||
001 6.013520000000E+01 7.815840000000E+01 0.000000000000E+00
|
||||
002 6.225470000000E+01 7.304140000000E+01 0.000000000000E+00
|
||||
003 6.636100000000E+01 7.733150000000E+01 0.000000000000E+00
|
||||
004 6.743270000000E+01 7.545220000000E+01 0.000000000000E+00
|
||||
005 6.859450000000E+01 7.817220000000E+01 0.000000000000E+00
|
||||
006 6.951440000000E+01 7.399160000000E+01 0.000000000000E+00
|
||||
007 7.084420000000E+01 7.675250000000E+01 0.000000000000E+00
|
||||
008 7.160620000000E+01 7.163580000000E+01 0.000000000000E+00
|
||||
009 7.446970000000E+01 7.667770000000E+01 0.000000000000E+00
|
||||
010 7.634490000000E+01 6.771360000000E+01 0.000000000000E+00
|
||||
011 7.675880000000E+01 6.338200000000E+01 0.000000000000E+00
|
||||
012 7.897770000000E+01 6.857050000000E+01 0.000000000000E+00
|
||||
013 7.901310000000E+01 6.423670000000E+01 0.000000000000E+00
|
||||
014 8.278350000000E+01 6.370140000000E+01 0.000000000000E+00
|
||||
015 8.581780000000E+01 6.354890000000E+01 0.000000000000E+00
|
||||
016 8.837110000000E+01 6.236630000000E+01 0.000000000000E+00
|
||||
017 9.139940000000E+01 5.620000000000E+01 0.000000000000E+00
|
||||
018 9.220260000000E+01 5.174260000000E+01 0.000000000000E+00
|
||||
019 9.029090000000E+01 5.127020000000E+01 0.000000000000E+00
|
||||
020 8.814240000000E+01 4.745050000000E+01 0.000000000000E+00
|
||||
021 8.651860000000E+01 4.605400000000E+01 0.000000000000E+00
|
||||
022 8.447390000000E+01 4.624540000000E+01 0.000000000000E+00
|
||||
023 8.032490000000E+01 4.764650000000E+01 0.000000000000E+00
|
||||
024 7.972940000000E+01 5.571550000000E+01 0.000000000000E+00
|
||||
025 7.884580000000E+01 5.498510000000E+01 0.000000000000E+00
|
||||
026 7.671340000000E+01 5.763060000000E+01 0.000000000000E+00
|
||||
027 7.543020000000E+01 5.673740000000E+01 0.000000000000E+00
|
||||
028 7.536320000000E+01 5.840850000000E+01 0.000000000000E+00
|
||||
029 7.325510000000E+01 6.345750000000E+01 0.000000000000E+00
|
||||
030 7.111320000000E+01 6.315590000000E+01 0.000000000000E+00
|
||||
031 7.113480000000E+01 6.613580000000E+01 0.000000000000E+00
|
||||
032 7.012260000000E+01 6.643770000000E+01 0.000000000000E+00
|
||||
033 6.865560000000E+01 6.764970000000E+01 0.000000000000E+00
|
||||
034 6.784250000000E+01 6.752880000000E+01 0.000000000000E+00
|
||||
035 6.589600000000E+01 6.792520000000E+01 0.000000000000E+00
|
||||
036 6.262800000000E+01 6.655140000000E+01 0.000000000000E+00
|
||||
001 0 tri 1 2 3
|
||||
002 0 tri 3 4 5
|
||||
003 0 tri 5 6 7
|
||||
004 0 tri 9 10 11
|
||||
005 0 tri 13 14 15
|
||||
006 0 tri 15 16 17
|
||||
007 0 tri 17 18 19
|
||||
008 0 tri 19 20 21
|
||||
009 0 tri 21 22 23
|
||||
010 0 tri 23 24 25
|
||||
011 0 tri 25 26 27
|
||||
012 0 tri 28 29 30
|
||||
013 0 tri 34 35 36
|
||||
014 0 tri 1 3 5
|
||||
015 0 tri 5 7 8
|
||||
016 0 tri 8 9 11
|
||||
017 0 tri 13 15 17
|
||||
018 0 tri 17 19 21
|
||||
019 0 tri 21 23 25
|
||||
020 0 tri 25 27 28
|
||||
021 0 tri 28 30 31
|
||||
022 0 tri 1 5 8
|
||||
023 0 tri 8 11 12
|
||||
024 0 tri 13 17 21
|
||||
025 0 tri 21 25 28
|
||||
026 0 tri 28 31 32
|
||||
027 0 tri 1 8 12
|
||||
028 0 tri 12 13 21
|
||||
029 0 tri 21 28 32
|
||||
030 0 tri 12 21 32
|
||||
031 0 tri 12 32 33
|
||||
032 0 tri 1 12 33
|
||||
033 0 tri 1 33 34
|
||||
034 0 tri 1 34 36
|
||||
00004 1 1 1 1
|
||||
imt1, integer
|
||||
itp1, integer
|
||||
icr1, integer
|
||||
isn1, integer
|
||||
0000000001 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000002 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000003 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000004 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000005 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000006 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000007 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000008 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000009 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000010 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000011 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000012 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000013 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000014 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000015 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000016 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000017 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000018 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000019 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000020 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000021 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000022 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000023 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000024 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000025 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000026 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000027 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000028 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000029 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000030 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000031 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000032 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000033 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000034 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000035 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
0000000036 0.000000000000E+00 1.000000000000E+01 0.000000000000E+00 0.000000000000E+00
|
||||
1
PyLaGriT/examples/julia/polygon_map/README
Executable file
1
PyLaGriT/examples/julia/polygon_map/README
Executable file
@@ -0,0 +1 @@
|
||||
This example demonstrates how PyLaGriT can be used within a Julia script. The julia script "polygon_map.jl" and the python script "polygon_map.py" perform the same LaGriT operations. The two scripts can be compared to see how the syntax is modified for the Julia languange.
|
||||
43
PyLaGriT/examples/julia/polygon_map/polygon_map.jl
Executable file
43
PyLaGriT/examples/julia/polygon_map/polygon_map.jl
Executable file
@@ -0,0 +1,43 @@
|
||||
using PyCall
|
||||
@pyimport pylagrit
|
||||
@pyimport numpy as np
|
||||
|
||||
# User parameters #######################
|
||||
# Discretization
|
||||
nx = 61; ny = 61
|
||||
# Polygon delineation filename
|
||||
polygon_file = "2d_mesh.avs"
|
||||
# User parameters #######################
|
||||
|
||||
l = pylagrit.PyLaGriT()
|
||||
|
||||
# Read in polygon delineation mesh
|
||||
mopoly = l[:read](polygon_file)
|
||||
|
||||
# Create quad using polygon min and max coordinates
|
||||
xs = linspace(mopoly[:xmin],mopoly[:xmax],nx)
|
||||
ys = linspace(mopoly[:ymin],mopoly[:ymax],ny)
|
||||
#xs = np.linspace(mopoly.xmin,mopoly.xmax,nx)
|
||||
#ys = np.linspace(mopoly.ymin,mopoly.ymax,ny)
|
||||
moquad = l[:gridder](xs,ys,elem_type="quad",connect=true)
|
||||
mopoly[:setatt]("itetclr",1)
|
||||
|
||||
# Create extruded quad to tet and center at z=0
|
||||
moprism = mopoly[:extrude](1.0)
|
||||
moprism[:trans]((0.,0.,0.),(0.,0.,0.5))
|
||||
motet = moprism[:grid2grid_prismtotet3]()
|
||||
|
||||
# Clean up a little
|
||||
mopoly[:delete]()
|
||||
moprism[:delete]()
|
||||
|
||||
# Add attribute to moquad to store if in polygon or not
|
||||
moquad[:addatt]("if_in_poly",vtype="vint")
|
||||
moquad[:setatt]("if_in_poly", 0) # Make sure attr starts as zero
|
||||
|
||||
# Interpolate motet's itetclr into moquad's if_in_poly
|
||||
moquad[:interpolate_map]("if_in_poly",motet,"itetclr")
|
||||
moquad[:intersect_elements](motet,attr_name="if_inter")
|
||||
|
||||
# Write out file, mapping is stored as cell attribute in if_inter
|
||||
moquad[:dump]("polygon_map_julia.inp")
|
||||
40
PyLaGriT/examples/julia/polygon_map/polygon_map.py
Executable file
40
PyLaGriT/examples/julia/polygon_map/polygon_map.py
Executable file
@@ -0,0 +1,40 @@
|
||||
from pylagrit import PyLaGriT
|
||||
import numpy as np
|
||||
|
||||
# User parameters #######################
|
||||
# Discretization
|
||||
nx = 61; ny = 61
|
||||
# Polygon delineation filename
|
||||
polygon_file = '2d_mesh.avs'
|
||||
# User parameters #######################
|
||||
|
||||
l = PyLaGriT()
|
||||
|
||||
# Read in polygon delineation mesh
|
||||
mopoly = l.read(polygon_file)
|
||||
|
||||
# Create quad using polygon min and max coordinates
|
||||
xs = np.linspace(mopoly.xmin,mopoly.xmax,nx)
|
||||
ys = np.linspace(mopoly.ymin,mopoly.ymax,ny)
|
||||
moquad = l.gridder(xs,ys,elem_type='quad',connect=True)
|
||||
mopoly.setatt('itetclr',1)
|
||||
|
||||
# Create extruded quad to tet and center at z=0
|
||||
mopoly.extrude(1.0)
|
||||
moprism = mopoly.extrude(1.0)
|
||||
moprism.trans((0.,0.,0.),(0.,0.,0.5))
|
||||
motet = moprism.grid2grid_prismtotet3()
|
||||
|
||||
# Clean up a little
|
||||
mopoly.delete()
|
||||
moprism.delete()
|
||||
|
||||
# Add attribute to moquad to store if in polygon or not
|
||||
moquad.addatt('if_in_poly',vtype='vint')
|
||||
moquad.setatt('if_in_poly', 0) # Make sure attr starts as zero
|
||||
|
||||
# Interpolate motet's itetclr into moquad's if_in_poly
|
||||
moquad.interpolate_map('if_in_poly',motet,'itetclr')
|
||||
moquad.intersect_elements(motet,attr_name='if_inter')
|
||||
|
||||
moquad.dump('polygon_map_python.inp')
|
||||
Reference in New Issue
Block a user