def testEuler(order=9): """Test euler formulations, with different flux types, slopelimiters, and curved integrations""" import globalVar2D as glb glb.globalInit() import mesh2D # Order of polynomials used for approximation glb.N = order # Define Simulation Data fluxType = 'HLL' gssState = 'on' cubState = 'on' limiter = 'on' simData = [fluxType, gssState, cubState, limiter] # Read in Mesh #filename = 'Grid/neu/Euler2D/vortexA04.neu' #InitialSolution = isentropicVortexIC2D #ExactSolution = isentropicVortexIC2D #BCSolution = isentropicVortexBC2D # Read in Mesh filename = 'Grid/msh/2Dcyl.msh' #filename = 'Grid/neu/Euler2D/fstepA001.neu' InitialSolution = fwdStepIC2D ExactSolution = fwdStepIC2D BCSolution = fwdStepBC2D # read mesh from file [glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV, glb.BCType] = mesh2D.readGmsh(filename) #[glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV, glb.BCType] = mesh2D.createBC(filename) # set up nodes and basic operations execfile("initiate2D.py") # turn cylinders into walls # There are no curved elements in isentropic vortex case ids = numpy.nonzero(glb.BCType == glb.Cyl) glb.BCType[ids] = glb.Wall glb.straight = range(glb.K) functions2D.BuildBCMaps2D() # compute initial condition Q = InitialSolution(glb.x, glb.y, 0.) # Solve Problem FinalTime = 1.0 Q = Euler2D(Q, FinalTime, ExactSolution, BCSolution, simData) # Calculate error err = Q - ExactSolution(glb.x, glb.y, FinalTime) L2Err = [(numpy.average((err[:, :, i]**2).flatten()))**0.5 for i in range(4)] return (Q, L2Err)
def testEuler(order=9): """Test euler formulations, with different flux types, slopelimiters, and curved integrations""" import globalVar2D as glb glb.globalInit() import mesh2D # Order of polynomials used for approximation glb.N = order # Define Simulation Data fluxType = 'HLL' gssState = 'on' cubState = 'on' limiter = 'on' simData = [fluxType,gssState,cubState,limiter] # Read in Mesh #filename = 'Grid/neu/Euler2D/vortexA04.neu' #InitialSolution = isentropicVortexIC2D #ExactSolution = isentropicVortexIC2D #BCSolution = isentropicVortexBC2D # Read in Mesh filename = 'Grid/msh/2Dcyl.msh' #filename = 'Grid/neu/Euler2D/fstepA001.neu' InitialSolution = fwdStepIC2D ExactSolution = fwdStepIC2D BCSolution = fwdStepBC2D # read mesh from file [glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV, glb.BCType] = mesh2D.readGmsh(filename) #[glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV, glb.BCType] = mesh2D.createBC(filename) # set up nodes and basic operations execfile("initiate2D.py") # turn cylinders into walls # There are no curved elements in isentropic vortex case ids = numpy.nonzero(glb.BCType==glb.Cyl) glb.BCType[ids] = glb.Wall glb.straight=range(glb.K) functions2D.BuildBCMaps2D() # compute initial condition Q = InitialSolution(glb.x, glb.y, 0.) # Solve Problem FinalTime = 1.0 Q = Euler2D(Q, FinalTime, ExactSolution, BCSolution, simData) # Calculate error err=Q-ExactSolution(glb.x,glb.y,FinalTime) L2Err=[(numpy.average((err[:,:,i]**2).flatten()))**0.5 for i in range(4)] return(Q,L2Err)
import math import numpy import matplotlib.pyplot as plt glb.globalInit() # Polynomial order used for approximation glb.N = 4 # Read in Mesh import mesh2D # Check .neu mesh #[glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV,glb.BCType] = mesh2D.createBC('Grid/neu/Euler2D/fstepA001.neu') # Check gmsh mesh [glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV, glb.BCType] = mesh2D.readGmsh('Grid/msh/fStep.msh') ### Initialize solver and construct grid and metric execfile("initiate2D.py") ###Check overall Mesh print "Checking overall Mesh" #Check size of x and y if glb.x.shape[0] != glb.Np or glb.x.shape[1] != glb.K or glb.y.shape[ 0] != glb.Np or glb.y.shape[1] != glb.K: print "Error in shapes of x and y" else: print "x and y shapes checked!" if __name__ == "__main__": #Plot all points plt.figure(1)
import globalVar2D as glb import math import numpy import matplotlib.pyplot as plt glb.globalInit() # Polynomial order used for approximation glb.N = 4 # Read in Mesh import mesh2D # Check .neu mesh #[glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV,glb.BCType] = mesh2D.createBC('Grid/neu/Euler2D/fstepA001.neu') # Check gmsh mesh [glb.Nv, glb.VX, glb.VY, glb.K, glb.EToV,glb.BCType] = mesh2D.readGmsh('Grid/msh/fStep.msh') ### Initialize solver and construct grid and metric execfile("initiate2D.py") ###Check overall Mesh print "Checking overall Mesh" #Check size of x and y if glb.x.shape[0]!=glb.Np or glb.x.shape[1]!=glb.K or glb.y.shape[0]!=glb.Np or glb.y.shape[1]!=glb.K: print "Error in shapes of x and y" else: print "x and y shapes checked!" if __name__ == "__main__": #Plot all points plt.figure(1) plt.title('All points')