Saving file in .pvd every x iterations


239
views
-1
8 months ago by
Hi,

I'm trying to store my values every 5 minutes in a pvd file (or xdmf) and using conditional statements does not work; when I open them in paraview there is an error. This is how I'm trying to do it:

fileu5min = File('sol/umin5_.pvd')
fileT5min = File('sol/Tmin5_.pvd')
fileP5min = File('sol/Pmin5_.pvd')
filee5min = File('sol/emin5_.pvd')

fileu10min = File('sol/umin10_.pvd')
fileT10min = File('sol/Tmin10_.pvd')
fileP10min = File('sol/Pmin10_.pvd')
filee10min = File('sol/emin10_.pvd')

fileu15min = File('sol/umin15_.pvd')
fileT15min = File('sol/Tmin15_.pvd')
fileP15min = File('sol/Pmin15_.pvd')
filee15min = File('sol/emin15_.pvd')

fileu20min = File('sol/umin20_.pvd')
fileT20min = File('sol/Tmin20_.pvd')
fileP20min = File('sol/Pmin20_.pvd')
filee20min = File('sol/emin20_.pvd')

fileu25min = File('sol/umin25_.pvd')
fileT25min = File('sol/Tmin25_.pvd')
fileP25min = File('sol/Pmin25_.pvd')
filee25min = File('sol/emin25_.pvd')

...
# Time stepping
t=0
while t < T + DOLFIN_EPS:
if t == 15.0: # 5 minutes
        fileu5min << u_
        fileT5min << theta_
        fileP5min << p_
        filee5min << e_
    elif t == 600.0: # 10 minutes
        fileu10min << u_
        fileT10min << theta_
        fileP10min << p_
        filee10min << e_
    elif t == 900.0: # 15 minutes
        fileu15min << u_
        fileT15min << theta_
        fileP15min << p_
        filee15min << e_
    elif t == 1200.0: # 20 minutes
        fileu20min << u_
        fileT20min << theta_
        fileP20min << p_
        filee20min << e_
    elif t == 1500.0: # 25 minutes
        fileu25min << u_
        fileT25min << theta_
        fileP25min << p_
        filee25min << e_
    elif t == 1800.0: # 30 minutes
        fileu30min << u_
        fileT30min << theta_
        fileP30min << p_
        filee30min << e_​


However, I get this error from paraview when I try opening the files:
ERROR: In /home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3/VTK/IO/vtkXMLParser.cxx, line 484

vtkXMLDataParser (0x2248960): Error parsing XML in stream at line 7, column 2, byte index 12632095: mismatched tag

 

ERROR: In /home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3/VTK/IO/vtkXMLReader.cxx, line 362

vtkXMLUnstructuredGridReader (0x2244320): Error parsing input file. ReadXMLInformation aborting.

 

ERROR: In /home/kitware/ParaView3/Utilities/BuildScripts/ParaView-3.6/ParaView3/VTK/Filtering/vtkExecutive.cxx, line 757

vtkStreamingDemandDrivenPipeline (0x2240a60): Algorithm vtkXMLUnstructuredGridReader(0x2244320) returned failure for request: vtkInformation (0x223efe0)

Debug: Off

Modified Time: 77448

Reference Count: 1

Registered Events: (none)

Request: REQUEST_INFORMATION

FORWARD_DIRECTION: 0

ALGORITHM_AFTER_FORWARD: 1​


Is there a way to do this without cbcpost? I haven't had luck using that either...

Thanks!
Community: FEniCS Project
can we save something like this:
# V: Required space to save
V = FunctionSpace(mesh, 'CG',1)

curlvtk = Function(V)
vtkplot = File('u_.pvd')

while t < T:
      if t%5.0==0:
            
            curlvtk.assign(p)
            vtkplot << curlvtk​
written 8 months ago by hirshikesh  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »