modified: anasen_fem/paraview_plotter.py made changes to allow field lines to only originate fom equipotential lines.

This commit is contained in:
Vignesh Sitaraman 2026-03-31 17:24:23 -04:00
parent 74dfc46d8c
commit 652b680fb9
4 changed files with 14 additions and 12 deletions

View File

@ -6,7 +6,7 @@ from paraview.simple import *
reader = XMLUnstructuredGridReader(FileName=["wires2d/elfield_anasen_t0001.vtu"])
contour_filter = Contour(Input=reader,ContourBy = 'potential')
contour_filter.Isosurfaces = [i for i in np.arange(0,660,650/32.)]
contour_filter.Isosurfaces = [i for i in np.arange(0,660,660/40.)]
renderView = GetActiveViewOrCreate('RenderView')
renderView.ViewSize = [2000,2000]
@ -88,7 +88,8 @@ view.CameraViewUp = [0.0, 1.0, 0.0]
# --- 2. Create the Glyph Filter (The Arrows) ---
# IMPORTANT: Use 'pot_threshold' as the Input, not the 'reader'
glyph = Glyph(Input=reader, GlyphType='Arrow')
glyph = Glyph(Input=contour_filter, GlyphType='Arrow') #
# glyph = Glyph(Input=reader, GlyphType='Arrow') #this uses all field line snot just the ones from the equipotential lines shown
# Orientation Array: Use the 'electric field' vector from Elmer
glyph.OrientationArray = ['POINTS', 'electric field']
@ -97,7 +98,7 @@ glyph.ScaleFactor = 1
# Sampling: Every nth point (Stride 16)
glyph.GlyphMode = 'Every Nth Point'
glyph.Stride = 96
glyph.Stride = 24
# --- 3. Display the Glyphs ---
glyph_display = Show(glyph, renderView)
@ -105,10 +106,11 @@ glyph_display = Show(glyph, renderView)
# Set the representation to Surface so we see the full arrow colors
glyph_display.Representation = 'Surface'
# This is the critical line: Color the arrows by the 'potential' scalar
ColorBy(glyph_display, ('POINTS', 'potential'))
contour_display_potentialLUT.RescaleTransferFunction(0.0, 660.0)
glyph_display.LookupTable = contour_display_potentialLUT
contour_display_potentialLUT.RescaleTransferFunction(0.0, 660.0)
# Optional: Disable the scalar bar for the arrows to avoid cluttering
# the existing 'potential' scalar bar.

View File

@ -7,12 +7,12 @@ count=11
while val<178.3+0.1:
print(val)
os.system("python3 wires_gmsh2d_bc.py "+str(val))
os.system("cp wires2d/mesh_files/wires2d.msh wires2d/mesh_files/%02d_%1.4f.msh"%(count,val))
os.system("ElmerGrid 14 2 wires2d/mesh_files/wires2d_%02d_%1.4f.msh"%(count,val))
os.system("cp wires2d.sif wires2d/sif_files/wires2d_%02d_%1.4f.sif"%(count,val))
os.system("ElmerSolver wires2d/sif_files/wires2d_%02d_%1.4f.sif"%(count,val))
os.system("cp wires2d/elfield_anasen_t0001.vtu wires2d/vtu_files/elfield_anasen_%02d_%1.4f.vtu"%(count,val))
os.system("ElmerGrid 14 2 wires2d.msh")
os.system("ElmerSolver wires2d.sif")
os.system("./paraview_plotter.py")
os.system("cp wires2d.msh wires2d/mesh_files/wires2d%02d_%1.4f.msh"%(count,val))
os.system("cp wires2d.sif wires2d/sif_files/wires2d_%02d_%1.4f.sif"%(count,val))
os.system("cp wires2d/elfield_anasen_t0001.vtu wires2d/vtu_files/elfield_anasen_%02d_%1.4f.vtu"%(count,val))
os.system("cp contour_output.png png/Contour_output_z_%02d_%1.4f.png"%(count,val))
os.system("cp Field_output.png png/Field_ouput_z_%02d_%1.4f.png"%(count,val))

View File

@ -1,8 +1,8 @@
Metadata for SaveScalars file: ./scalars.dat
Elmer version: 26.1
Elmer compilation date: 2026-03-15
Solver input file: wires2d/sif_files/wires2d_11_17.8300.sif
File started at: 2026/03/31 13:26:51
Solver input file: wires2d.sif
File started at: 2026/03/31 16:47:17
Variables in columns of matrix:
1: res: potential difference

View File

@ -151,6 +151,6 @@ gmsh.option.setNumber("Mesh.Algorithm", 6)
gmsh.model.mesh.generate(dim=2)
gmsh.model.mesh.refine()
gmsh.write("wires2d/mesh_files/wires2d.msh")
gmsh.write("wires2d.msh")
#gmsh.fltk.run()
gmsh.finalize()