Salome HOME
update CDMATH
[tools/solverlab.git] / CDMATH / tests / examples / WaveSystem_Shock / WaveSystemPStag / WaveSystemPStag.py
old mode 100644 (file)
new mode 100755 (executable)
index d922d0c..593997b
@@ -28,7 +28,7 @@ rho0=p0/c0*c0#reference density
 precision=1e-5
 
 def initial_conditions_shock(my_mesh, isCircle):
-    print "Initial data : Spherical wave"
+    print( "Initial data : Spherical wave" )
     dim     = my_mesh.getMeshDimension()
     nbCells = my_mesh.getNumberOfCells()
 
@@ -148,7 +148,7 @@ def computeDivergenceMatrix(my_mesh,nbVoisinsMax,dt):
                     implMat.addValue(j*nbComp,cellAutre*nbComp,Am)
                     implMat.addValue(j*nbComp,        j*nbComp,Am*(-1.))
                 elif(Fk.getGroupName() != "Neumann"):#Nothing to do for Neumann boundary condition
-                    print Fk.getGroupName()
+                    print( Fk.getGroupName() )
                     raise ValueError("computeFluxes: Unknown boundary condition name");
                 
     return implMat
@@ -177,7 +177,7 @@ def WaveSystemVF(ntmax, tmax, cfl, my_mesh, output_freq, filename,resolution):
     elif(filename.find("disk")>-1 or filename.find("Disk")>-1):
         pressure_field, velocity_field = initial_conditions_shock(my_mesh,True)
     else:
-        print "Mesh name : ", filename
+        print( "Mesh name : ", filename )
         raise ValueError("Mesh name should contain substring square, cube or disk")
 
     for k in range(nbCells):
@@ -218,7 +218,7 @@ def WaveSystemVF(ntmax, tmax, cfl, my_mesh, output_freq, filename,resolution):
         cvgceLS=LS.getStatus();
         iterGMRES=LS.getNumberOfIter();
         if(not cvgceLS):
-            print "Linear system did not converge ", iterGMRES, " GMRES iterations"
+            print( "Linear system did not converge ", iterGMRES, " GMRES iterations" )
             raise ValueError("Pas de convergence du système linéaire");
         dUn-=Un
         
@@ -231,9 +231,9 @@ def WaveSystemVF(ntmax, tmax, cfl, my_mesh, output_freq, filename,resolution):
     
         #Sauvegardes
         if(it%output_freq==0 or it>=ntmax or isStationary or time >=tmax):
-            print"-- Iter: " + str(it) + ", Time: " + str(time) + ", dt: " + str(dt)
-            print "Variation temporelle relative : pressure ", maxVector[0]/p0 ,", velocity x", maxVector[1]/rho0 ,", velocity y", maxVector[2]/rho0
-            print "Linear system converged in ", iterGMRES, " GMRES iterations"
+            print( "-- Iter: " + str(it) + ", Time: " + str(time) + ", dt: " + str(dt) )
+            print( "Variation temporelle relative : pressure ", maxVector[0]/p0 ,", velocity x", maxVector[1]/rho0 ,", velocity y", maxVector[2]/rho0 )
+            print( "Linear system converged in ", iterGMRES, " GMRES iterations" )
 
             for k in range(nbCells):
                 pressure_field[k]=Un[k*(dim+1)+0]
@@ -248,15 +248,15 @@ def WaveSystemVF(ntmax, tmax, cfl, my_mesh, output_freq, filename,resolution):
             velocity_field.setTime(time,it);
             velocity_field.writeVTK("WaveSystem"+str(dim)+"DPStag"+meshName+"_velocity",False);
 
-    print"-- Iter: " + str(it) + ", Time: " + str(time) + ", dt: " + str(dt)
-    print "Variation temporelle relative : pressure ", maxVector[0]/p0 ,", velocity x", maxVector[1]/rho0 ,", velocity y", maxVector[2]/rho0
-    print
+    print( "-- Iter: " + str(it) + ", Time: " + str(time) + ", dt: " + str(dt) )
+    print( "Variation temporelle relative : pressure ", maxVector[0]/p0 ,", velocity x", maxVector[1]/rho0 ,", velocity y", maxVector[2]/rho0)
+    print()
 
     if(it>=ntmax):
-        print "Nombre de pas de temps maximum ntmax= ", ntmax, " atteint"
+        print( "Nombre de pas de temps maximum ntmax= ", ntmax, " atteint")
     elif(isStationary):
-        print "Régime stationnaire atteint au pas de temps ", it, ", t= ", time
-        print "------------------------------------------------------------------------------------"
+        print( "Régime stationnaire atteint au pas de temps ", it, ", t= ", time)
+        print( "------------------------------------------------------------------------------------")
 
         pressure_field.setTime(time,0);
         pressure_field.writeVTK("WaveSystem"+str(dim)+"DPStag"+meshName+"_pressure_Stat");
@@ -268,15 +268,15 @@ def WaveSystemVF(ntmax, tmax, cfl, my_mesh, output_freq, filename,resolution):
         PV_routines.Save_PV_data_to_picture_file("WaveSystem"+str(dim)+"DPStag"+meshName+"_velocity_Stat"+'_0.vtu',"Velocity",'CELLS',"WaveSystem"+str(dim)+"DPStag"+meshName+"_velocity_Stat")
         
     else:
-        print "Temps maximum Tmax= ", tmax, " atteint"
+        print( "Temps maximum Tmax= ", tmax, " atteint" )
 
 
 def solve(my_mesh,meshName,resolution):
-    print "Resolution of the Wave system in dimension ", my_mesh.getSpaceDimension()
-    print "Numerical method : implicit pseudo staggered"
-    print "Initial data : spherical wave"
-    print "Wall boundary conditions"
-    print "Mesh name : ",meshName , my_mesh.getNumberOfCells(), " cells"
+    print( "Resolution of the Wave system in dimension ", my_mesh.getSpaceDimension() )
+    print( "Numerical method : implicit pseudo staggered" )
+    print( "Initial data : spherical wave" )
+    print( "Wall boundary conditions" )
+    print( "Mesh name : ",meshName , my_mesh.getNumberOfCells(), " cells" )
     
     # Problem data
     tmax = 1000.