From 74dfc46d8c3f1e0e562f256843aec2687f5ab4c6 Mon Sep 17 00:00:00 2001 From: vsitaraman Date: Tue, 31 Mar 2026 13:34:12 -0400 Subject: [PATCH] modified: .gitignore modified: anasen_fem/paraview_plotter.py included code to make and save field plots modified: anasen_fem/run.py included changes for parapview plotter and also save all outputs for mesh and elmer in folders modified: anasen_fem/scalars.dat.names modified: anasen_fem/wires_gmsh2d_bc.py --- .gitignore | 1 + anasen_fem/paraview_plotter.py | 58 +++++++++++++++++++++++++++++++++- anasen_fem/run.py | 14 ++++---- anasen_fem/scalars.dat.names | 4 +-- anasen_fem/wires_gmsh2d_bc.py | 2 +- 5 files changed, 68 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index b0229c9..76f4c74 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ qqq_gains_det3.dat qqq_relative_gains.dat Armory/CorrelateQQQ.h QQQStage2.C +anasen_fem/scalars.dat.names diff --git a/anasen_fem/paraview_plotter.py b/anasen_fem/paraview_plotter.py index 8c83940..1a66bb8 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/24.)] +contour_filter.Isosurfaces = [i for i in np.arange(0,660,650/32.)] renderView = GetActiveViewOrCreate('RenderView') renderView.ViewSize = [2000,2000] @@ -61,3 +61,59 @@ view.CameraParallelProjection = 1 Render() SaveScreenshot("contour_output.png") + +#make glyps for field lines +contour_display.LineWidth = 1.0 # Increase this for thicker lines +contour_display.RenderLinesAsTubes = 0 # Makes lines look smoother at high res + +# 1. Get the active view +view = GetActiveView() + +# 4. Apply settings +# 1. Set the Focal Point to the middle of the quadrant +zoom_center = [-25, 25, 0.0] + +# 2. Tighten the Parallel Scale +view.CameraParallelScale = 15 + +# 3. Position the Camera +# Keep it 0.5m away looking "down" at the new center +view.CameraPosition = [zoom_center[0], zoom_center[1], 0.5] +view.CameraFocalPoint = zoom_center +view.CameraViewUp = [0.0, 1.0, 0.0] +# pot_threshold = Threshold(Input=reader) +# pot_threshold.Scalars = ['POINTS', 'potential'] +# pot_threshold.ThresholdMethod = 'Above Upper Threshold' +# pot_threshold.UpperThreshold = 100.0 + +# --- 2. Create the Glyph Filter (The Arrows) --- +# IMPORTANT: Use 'pot_threshold' as the Input, not the 'reader' +glyph = Glyph(Input=reader, GlyphType='Arrow') + +# Orientation Array: Use the 'electric field' vector from Elmer +glyph.OrientationArray = ['POINTS', 'electric field'] +glyph.ScaleArray = ['POINTS', 'No scale array'] +glyph.ScaleFactor = 1 + +# Sampling: Every nth point (Stride 16) +glyph.GlyphMode = 'Every Nth Point' +glyph.Stride = 96 + +# --- 3. Display the Glyphs --- +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 + +# Optional: Disable the scalar bar for the arrows to avoid cluttering +# the existing 'potential' scalar bar. +glyph_display.SetScalarBarVisibility(renderView, False) + +# --- 4. Final Render --- +Render() +SaveScreenshot("Field_output.png") diff --git a/anasen_fem/run.py b/anasen_fem/run.py index 24c9ff2..5e56840 100755 --- a/anasen_fem/run.py +++ b/anasen_fem/run.py @@ -1,21 +1,21 @@ import code import os -val=-178.3 -# val=17.83 -count=0 -while val<17.83+0.1: +# val=-178.3 +val=17.83 +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("./paraview_plotter.py") - os.system("cp contour_output.png png/contour_output_z_%02d_%1.4f.png"%(count,val)) - # os.system("cp field_output.png field_ouput_z_%02d_%1.4f.png"%(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)) val=val+17.83 count = count + 1 - break diff --git a/anasen_fem/scalars.dat.names b/anasen_fem/scalars.dat.names index f2aeb7a..444d15d 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_00_-178.3000.sif -File started at: 2026/03/31 10:12:11 +Solver input file: wires2d/sif_files/wires2d_11_17.8300.sif +File started at: 2026/03/31 13:26:51 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 8753a1f..9d44e5f 100755 --- a/anasen_fem/wires_gmsh2d_bc.py +++ b/anasen_fem/wires_gmsh2d_bc.py @@ -147,7 +147,7 @@ gmsh.model.setPhysicalName(1,30,"cathode_wires") gmsh.model.addPhysicalGroup(2,[anasen_barrel],tag=13) gmsh.model.setPhysicalName(1,13,"gas") -gmsh.option.setNumber("Mesh.Algorithm", 5) +gmsh.option.setNumber("Mesh.Algorithm", 6) gmsh.model.mesh.generate(dim=2) gmsh.model.mesh.refine()