From 652b680fb9e446c3bac024b513342d6cefdd369b Mon Sep 17 00:00:00 2001 From: vsitaraman Date: Tue, 31 Mar 2026 17:24:23 -0400 Subject: [PATCH] modified: anasen_fem/paraview_plotter.py made changes to allow field lines to only originate fom equipotential lines. --- anasen_fem/paraview_plotter.py | 10 ++++++---- anasen_fem/run.py | 10 +++++----- anasen_fem/scalars.dat.names | 4 ++-- anasen_fem/wires_gmsh2d_bc.py | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/anasen_fem/paraview_plotter.py b/anasen_fem/paraview_plotter.py index 1a66bb8..563fc9b 100755 --- a/anasen_fem/paraview_plotter.py +++ b/anasen_fem/paraview_plotter.py @@ -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. diff --git a/anasen_fem/run.py b/anasen_fem/run.py index 5e56840..79f18ae 100755 --- a/anasen_fem/run.py +++ b/anasen_fem/run.py @@ -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)) diff --git a/anasen_fem/scalars.dat.names b/anasen_fem/scalars.dat.names index 444d15d..1deb76e 100755 --- a/anasen_fem/scalars.dat.names +++ b/anasen_fem/scalars.dat.names @@ -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 diff --git a/anasen_fem/wires_gmsh2d_bc.py b/anasen_fem/wires_gmsh2d_bc.py index 9d44e5f..7ec4144 100755 --- a/anasen_fem/wires_gmsh2d_bc.py +++ b/anasen_fem/wires_gmsh2d_bc.py @@ -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()