Testing a python file as a copy&paste with some format

From KratosWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
##################################################################
+
##################################################################
  
##################################################################
+
##################################################################
  
#setting the domain size for the problem to be solved
+
#setting the domain size for the problem to be solved
  
domain_size = 2
+
domain_size = 2
  
 +
  
 +
##################################################################
  
##################################################################
+
##################################################################
  
##################################################################
+
## ATTENTION: here the order is important
  
## ATTENTION: here the order is important
+
  
 +
#including kratos path
  
 +
kratos_libs_path = '../../../../libs' ##kratos_root/libs
  
#including kratos path
+
#kratos_libs_path = 'C:/kratosR1/libs' ##kratos_root/libs
  
kratos_libs_path = '../../../../libs' ##kratos_root/libs
+
kratos_applications_path = '../../../../applications/' ##kratos_root/applications
  
#kratos_libs_path = 'C:/kratosR1/libs' ##kratos_root/libs
+
import sys
  
kratos_applications_path = '../../../../applications/' ##kratos_root/applications
+
sys.path.append(kratos_libs_path)
  
import sys
+
sys.path.append(kratos_applications_path)
  
sys.path.append(kratos_libs_path)
+
  
sys.path.append(kratos_applications_path)
+
#importing Kratos main library
  
 +
from Kratos import *
  
 +
kernel = Kernel()  #defining kernel
  
#importing Kratos main library
+
  
from Kratos import *
+
#importing applications
  
kernel = Kernel()  #defining kernel
+
import applications_interface
  
 +
applications_interface.Import_IncompressibleFluidApplication = True
  
 +
applications_interface.ImportApplications(kernel, kratos_applications_path)
  
#importing applications
+
  
import applications_interface
+
## from now on the order is not anymore crucial
  
applications_interface.Import_IncompressibleFluidApplication = True
+
##################################################################
  
applications_interface.ImportApplications(kernel, kratos_applications_path)
+
##################################################################
  
 +
  
 +
from KratosR1IncompressibleFluidApplication import *
  
## from now on the order is not anymore crucial
+
  
##################################################################
+
  
##################################################################
+
#defining a model part
  
 +
model_part = ModelPart("FluidPart");
  
 +
  
from KratosR1IncompressibleFluidApplication import *
+
##importing the solver files and adding the variables
  
 +
import incompressible_fluid_solver
  
 +
incompressible_fluid_solver.AddVariables(model_part)
  
 +
  
 +
#adding of Variables to Model Part should be here when the "very fix container will be ready"
  
#defining a model part
+
  
model_part = ModelPart("FluidPart");
+
#reading a model
  
 +
gid_io = GidIO("cavity2d",GiDPostMode.GiD_PostBinary)
  
 +
##gid_io.ReadMesh(model_part.GetMesh())
  
##importing the solver files and adding the variables
+
gid_io.ReadModelPart(model_part)
  
import incompressible_fluid_solver
+
gid_io.WriteMesh((model_part).GetMesh(),domain_size,GiDPostMode.GiD_PostBinary);
  
incompressible_fluid_solver.AddVariables(model_part)
+
print model_part
  
 +
  
 +
#the buffer size should be set up here after the mesh is read for the first time
  
#adding of Variables to Model Part should be here when the "very fix container will be ready"
+
model_part.SetBufferSize(3)
  
 +
  
 +
##add Degrees of Freedom to all of the nodes
  
#reading a model
+
incompressible_fluid_solver.AddDofs(model_part)
  
gid_io = GidIO("cavity2d",GiDPostMode.GiD_PostBinary)
+
  
##gid_io.ReadMesh(model_part.GetMesh())
+
  
gid_io.ReadModelPart(model_part)
+
  
gid_io.WriteMesh((model_part).GetMesh(),domain_size,GiDPostMode.GiD_PostBinary);
+
#creating a fluid solver object
  
print model_part
+
fluid_solver = incompressible_fluid_solver.IncompressibleFluidSolver(model_part,domain_size)
  
 +
fluid_solver.laplacian_form = 2;
  
 +
fluid_solver.predictor_corrector = True
  
#the buffer size should be set up here after the mesh is read for the first time
+
fluid_solver.vel_toll = 1e-3
  
model_part.SetBufferSize(3)
+
fluid_solver.time_order = 2
  
 +
fluid_solver.echo_level = 0
  
 +
  
##add Degrees of Freedom to all of the nodes
+
  
incompressible_fluid_solver.AddDofs(model_part)
+
  
 +
#pILUPrecond = ILU0Preconditioner()
  
 +
#fluid_solver.pressure_linear_solver =  BICGSTABSolver(1e-9, 5000,pILUPrecond)
  
 +
pDiagPrecond = DiagonalPreconditioner()
  
 +
fluid_solver.velocity_linear_solver =  BICGSTABSolver(1e-9, 5000,pDiagPrecond)
  
 +
fluid_solver.pressure_linear_solver =  BICGSTABSolver(1e-9, 5000,pDiagPrecond)
  
 +
##fluid_solver.pressure_linear_solver = SkylineLUFactorizationSolver();
  
#creating a fluid solver object
+
fluid_solver.Initialize()
  
fluid_solver = incompressible_fluid_solver.IncompressibleFluidSolver(model_part,domain_size)
+
  
fluid_solver.laplacian_form = 2;
+
#settings to be changed
  
fluid_solver.predictor_corrector = True
+
Re = 100.0
  
fluid_solver.vel_toll = 1e-3
+
nsteps = 200
  
fluid_solver.time_order = 2
+
output_step = 1
  
fluid_solver.echo_level = 0
+
  
 +
Dt = 1000.0/Re
  
 +
if(Dt > 0.1):
  
 +
    Dt = 0.1
  
 +
out = 0
  
 +
for node in model_part.Nodes:
  
 +
    node.SetSolutionStepValue(VISCOSITY,0,1.0/Re)
  
#pILUPrecond = ILU0Preconditioner()
+
  
#fluid_solver.pressure_linear_solver = BICGSTABSolver(1e-9, 5000,pILUPrecond)
+
  for step in range(1,nsteps):
  
pDiagPrecond = DiagonalPreconditioner()
+
    print "line49"
  
fluid_solver.velocity_linear_solver = BICGSTABSolver(1e-9, 5000,pDiagPrecond)
+
   
  
fluid_solver.pressure_linear_solver = BICGSTABSolver(1e-9, 5000,pDiagPrecond)
+
    time = Dt*step
  
##fluid_solver.pressure_linear_solver = SkylineLUFactorizationSolver();
+
    print time
  
fluid_solver.Initialize()
+
    model_part.CloneTimeStep(time)
  
 +
  
 +
    print "qui"
  
#settings to be changed
+
  
Re = 100.0
+
    print time
  
nsteps = 200
+
    #print model_part.ProcessInfo()[TIME]
  
output_step = 1
+
  
 +
    #solving the fluid problem
  
 +
    if(step > 3):
  
Dt = 1000.0/Re
+
        fluid_solver.Solve()
  
if(Dt > 0.1):
+
  
    Dt = 0.1
+
    print "li"
  
out = 0
+
  
for node in model_part.Nodes:
+
  
    node.SetSolutionStepValue(VISCOSITY,0,1.0/Re)
+
    #print the results
  
 +
    if(out == output_step):
  
 +
        gid_io.WriteNodalResults(PRESSURE,model_part.Nodes,time,0)
  
for step in range(1,nsteps):
+
        gid_io.WriteNodalResults(VELOCITY,model_part.Nodes,time,0)
  
    print "line49"
+
        gid_io.WriteNodalResults(PRESS_PROJ,model_part.Nodes,time,0)
  
 +
        gid_io.WriteNodalResults(CONV_PROJ,model_part.Nodes,time,0)
  
 +
        gid_io.WriteNodalResults(NODAL_AREA,model_part.Nodes,time,0)
  
    time = Dt*step
+
        gid_io.WriteNodalResults(VISCOSITY,model_part.Nodes,time,0)
  
    print time
+
        out = 0
  
    model_part.CloneTimeStep(time)
+
    out = out + 1
  
 +
  
 +
node = model_part.Nodes[1]
  
    print "qui"
+
  
 
+
  print node
 
+
    print time
+
 
+
    #print model_part.ProcessInfo()[TIME]
+
 
+
 
+
 
+
    #solving the fluid problem
+
 
+
    if(step > 3):
+
 
+
        fluid_solver.Solve()
+
 
+
 
+
 
+
    print "li"
+
 
+
 
+
 
+
 
+
 
+
    #print the results
+
 
+
    if(out == output_step):
+
 
+
        gid_io.WriteNodalResults(PRESSURE,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(VELOCITY,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(PRESS_PROJ,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(CONV_PROJ,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(NODAL_AREA,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(VISCOSITY,model_part.Nodes,time,0)
+
 
+
        out = 0
+
 
+
    out = out + 1
+
 
+
 
+
 
+
node = model_part.Nodes[1]
+
 
+
 
+
 
+
print node
+
 
+
 
+
 
+
         
+
 
+
       
+
 
+
 
+
 
+
 
+
 
+
##################################################################
+
 
+
##################################################################
+
 
+
#setting the domain size for the problem to be solved
+
 
+
domain_size = 2
+
 
+
 
+
 
+
##################################################################
+
 
+
##################################################################
+
 
+
## ATTENTION: here the order is important
+
 
+
 
+
 
+
#including kratos path
+
 
+
kratos_libs_path = '../../../../libs' ##kratos_root/libs
+
 
+
#kratos_libs_path = 'C:/kratosR1/libs' ##kratos_root/libs
+
 
+
kratos_applications_path = '../../../../applications/' ##kratos_root/applications
+
 
+
import sys
+
 
+
sys.path.append(kratos_libs_path)
+
 
+
sys.path.append(kratos_applications_path)
+
 
+
 
+
 
+
#importing Kratos main library
+
 
+
from Kratos import *
+
 
+
kernel = Kernel()  #defining kernel
+
 
+
 
+
 
+
#importing applications
+
 
+
import applications_interface
+
 
+
applications_interface.Import_IncompressibleFluidApplication = True
+
 
+
applications_interface.ImportApplications(kernel, kratos_applications_path)
+
 
+
 
+
 
+
## from now on the order is not anymore crucial
+
 
+
##################################################################
+
 
+
##################################################################
+
 
+
 
+
 
+
from KratosR1IncompressibleFluidApplication import *
+
 
+
 
+
 
+
 
+
 
+
#defining a model part
+
 
+
model_part = ModelPart("FluidPart");
+
 
+
 
+
 
+
##importing the solver files and adding the variables
+
 
+
import incompressible_fluid_solver
+
 
+
incompressible_fluid_solver.AddVariables(model_part)
+
 
+
 
+
 
+
#adding of Variables to Model Part should be here when the "very fix container will be ready"
+
 
+
 
+
 
+
#reading a model
+
 
+
gid_io = GidIO("cavity2d",GiDPostMode.GiD_PostBinary)
+
 
+
##gid_io.ReadMesh(model_part.GetMesh())
+
 
+
gid_io.ReadModelPart(model_part)
+
 
+
gid_io.WriteMesh((model_part).GetMesh(),domain_size,GiDPostMode.GiD_PostBinary);
+
 
+
print model_part
+
 
+
 
+
 
+
#the buffer size should be set up here after the mesh is read for the first time
+
 
+
model_part.SetBufferSize(3)
+
 
+
 
+
 
+
##add Degrees of Freedom to all of the nodes
+
 
+
incompressible_fluid_solver.AddDofs(model_part)
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
#creating a fluid solver object
+
 
+
fluid_solver = incompressible_fluid_solver.IncompressibleFluidSolver(model_part,domain_size)
+
 
+
fluid_solver.laplacian_form = 2;
+
 
+
fluid_solver.predictor_corrector = True
+
 
+
fluid_solver.vel_toll = 1e-3
+
 
+
fluid_solver.time_order = 2
+
 
+
fluid_solver.echo_level = 0
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
#pILUPrecond = ILU0Preconditioner()
+
 
+
#fluid_solver.pressure_linear_solver = BICGSTABSolver(1e-9, 5000,pILUPrecond)
+
 
+
pDiagPrecond = DiagonalPreconditioner()
+
 
+
fluid_solver.velocity_linear_solver =  BICGSTABSolver(1e-9, 5000,pDiagPrecond)
+
 
+
fluid_solver.pressure_linear_solver =  BICGSTABSolver(1e-9, 5000,pDiagPrecond)
+
 
+
##fluid_solver.pressure_linear_solver = SkylineLUFactorizationSolver();
+
 
+
fluid_solver.Initialize()
+
 
+
 
+
 
+
#settings to be changed
+
 
+
Re = 100.0
+
 
+
nsteps = 200
+
 
+
output_step = 1
+
 
+
 
+
 
+
Dt = 1000.0/Re
+
 
+
if(Dt > 0.1):
+
 
+
    Dt = 0.1
+
 
+
out = 0
+
 
+
for node in model_part.Nodes:
+
 
+
    node.SetSolutionStepValue(VISCOSITY,0,1.0/Re)
+
 
+
 
+
 
+
for step in range(1,nsteps):
+
 
+
    print "line49"
+
 
+
 
+
 
+
    time = Dt*step
+
 
+
    print time
+
 
+
    model_part.CloneTimeStep(time)
+
 
+
 
+
 
+
    print "qui"
+
 
+
 
+
 
+
    print time
+
 
+
    #print model_part.ProcessInfo()[TIME]
+
 
+
 
+
 
+
    #solving the fluid problem
+
 
+
    if(step > 3):
+
 
+
        fluid_solver.Solve()
+
 
+
 
+
 
+
    print "li"
+
 
+
 
+
 
+
 
+
 
+
    #print the results
+
 
+
    if(out == output_step):
+
 
+
        gid_io.WriteNodalResults(PRESSURE,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(VELOCITY,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(PRESS_PROJ,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(CONV_PROJ,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(NODAL_AREA,model_part.Nodes,time,0)
+
 
+
        gid_io.WriteNodalResults(VISCOSITY,model_part.Nodes,time,0)
+
 
+
        out = 0
+
 
+
    out = out + 1
+
 
+
 
+
 
+
node = model_part.Nodes[1]
+
 
+
 
+
 
+
print node
+

Revision as of 19:25, 28 November 2007

##################################################################
##################################################################
#setting the domain size for the problem to be solved
domain_size = 2


##################################################################
##################################################################
## ATTENTION: here the order is important


#including kratos path
kratos_libs_path = '../../../../libs' ##kratos_root/libs
#kratos_libs_path = 'C:/kratosR1/libs' ##kratos_root/libs
kratos_applications_path = '../../../../applications/' ##kratos_root/applications
import sys
sys.path.append(kratos_libs_path)
sys.path.append(kratos_applications_path)


#importing Kratos main library
from Kratos import *
kernel = Kernel()   #defining kernel


#importing applications
import applications_interface
applications_interface.Import_IncompressibleFluidApplication = True
applications_interface.ImportApplications(kernel, kratos_applications_path)


## from now on the order is not anymore crucial
##################################################################
##################################################################


from KratosR1IncompressibleFluidApplication import *



#defining a model part
model_part = ModelPart("FluidPart");


##importing the solver files and adding the variables
import incompressible_fluid_solver
incompressible_fluid_solver.AddVariables(model_part)


#adding of Variables to Model Part should be here when the "very fix container will be ready"


#reading a model
gid_io = GidIO("cavity2d",GiDPostMode.GiD_PostBinary)
##gid_io.ReadMesh(model_part.GetMesh())
gid_io.ReadModelPart(model_part)
gid_io.WriteMesh((model_part).GetMesh(),domain_size,GiDPostMode.GiD_PostBinary);
print model_part


#the buffer size should be set up here after the mesh is read for the first time
model_part.SetBufferSize(3)


##add Degrees of Freedom to all of the nodes
incompressible_fluid_solver.AddDofs(model_part)




#creating a fluid solver object
fluid_solver = incompressible_fluid_solver.IncompressibleFluidSolver(model_part,domain_size)
fluid_solver.laplacian_form = 2;
fluid_solver.predictor_corrector = True
fluid_solver.vel_toll = 1e-3
fluid_solver.time_order = 2
fluid_solver.echo_level = 0




#pILUPrecond = ILU0Preconditioner() 
#fluid_solver.pressure_linear_solver =  BICGSTABSolver(1e-9, 5000,pILUPrecond)
pDiagPrecond = DiagonalPreconditioner()
fluid_solver.velocity_linear_solver =  BICGSTABSolver(1e-9, 5000,pDiagPrecond)
fluid_solver.pressure_linear_solver =  BICGSTABSolver(1e-9, 5000,pDiagPrecond)
##fluid_solver.pressure_linear_solver = SkylineLUFactorizationSolver();
fluid_solver.Initialize()


#settings to be changed
Re = 100.0
nsteps = 200
output_step = 1


Dt = 1000.0/Re
if(Dt > 0.1):
    Dt = 0.1
out = 0
for node in model_part.Nodes:
    node.SetSolutionStepValue(VISCOSITY,0,1.0/Re)


for step in range(1,nsteps):
    print "line49"


    time = Dt*step
    print time
    model_part.CloneTimeStep(time)


    print "qui"


    print time
    #print model_part.ProcessInfo()[TIME]


    #solving the fluid problem
    if(step > 3):
        fluid_solver.Solve()


    print "li"



    #print the results
    if(out == output_step):
        gid_io.WriteNodalResults(PRESSURE,model_part.Nodes,time,0)
        gid_io.WriteNodalResults(VELOCITY,model_part.Nodes,time,0)
        gid_io.WriteNodalResults(PRESS_PROJ,model_part.Nodes,time,0)
        gid_io.WriteNodalResults(CONV_PROJ,model_part.Nodes,time,0)
        gid_io.WriteNodalResults(NODAL_AREA,model_part.Nodes,time,0)
        gid_io.WriteNodalResults(VISCOSITY,model_part.Nodes,time,0)
        out = 0
    out = out + 1


node = model_part.Nodes[1]


print node
Personal tools
Categories