def getPfem():
    global w
    if w: return w
    w = pfem
    
    mshFile = runPath+os.sep+'birdImpact_deformable_panel_Mtf_Pfem_Smojver.msh'
    
    print 'mshFile: ', mshFile
    
    rho0 = 938.
    mu = 0.001
    U0 = 145.7

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.nonLinAlgorithm = 1
    pbl.solScheme = 1
    pbl.alpha = 1.2
    pbl.beta = 0.
    pbl.gravity = 0.
    pbl.scalingU = U0
    
    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh
    
    scheme = w.BackwardEuler(msh, pbl)

    w.Medium(msh, 13, mu, rho0, 3)
    w.Medium(msh, 16, mu, rho0, 1)
    
    # boundaries
    w.Boundary(msh, 15, 3, 0.0)
    w.Boundary(msh, 13, 1, 0.0)
    w.Boundary(msh, 13, 2, 0.0)
    
    #Initial velocity
    bird = w.Group(msh, 16)
    loadingset = w.LoadingSet(msh)
    loadingset.add(1,w.InitialVelocity(msh,bird,0.,-U0,0.))
    
    scheme.savefreq=1
    scheme.nthreads=3
    scheme.gamma = 0.5
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True
    scheme.tollNLalgo = 1e-7
    
    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1,w.PositionExtractor(msh,163))
    extManager.add(6,wt.KineticEnergyExtractor(msh,pbl,16))
    extManager.add(7,wt.ViscousEnergyExtractor(msh,pbl,scheme,16))
    extManager.add(8,wt.PressureWorkExtractor(msh,pbl,scheme,16))
    extManager.add(9,w.MassExtractor(msh,pbl,16))
    
    gui = v.MeshViewer(msh, scheme, True) 
    
    return Module(w, msh, pbl, bird, loadingset, scheme, extManager, gui)
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'StaticCylinder.msh'

    rho0 = 1.0
    mu = 0.01

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.alpha = 1.4
    pbl.extP = 1.0
    pbl.scalingU = 1.0
    pbl.bodyForceY = -9.81

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    toll = 1e-6
    nItMax = 20

    solScheme = w.SchemeMonolithicPSPG(msh, pbl)
    convCriterion = w.ForcesBalanceNormedBodyForceCriterion(msh, pbl, toll)
    nonLinAlgo = w.PicardAlgorithm(solScheme, convCriterion, nItMax)

    scheme = w.BackwardEuler(msh, pbl, nonLinAlgo)

    msh.ptags[9].name = "Cylinder"
    msh.ntags["Cylinder"] = msh.ptags[9]

    w.Medium(msh, 9, 0., 0., 3)
    w.Medium(msh, 14, mu, rho0, 1)

    # boundaries
    w.Boundary(msh, 8, 3, pbl.extP)
    w.Boundary(msh, 7, 1, 0.0)
    w.Boundary(msh, 7, 2, 0.0)
    w.Boundary(msh, 9, 1, 0.0)
    w.Boundary(msh, 9, 2, 0.0)

    scheme.savefreq = 1
    scheme.nthreads = 3
    scheme.gamma = 0.6
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True

    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 6))
    extManager.add(20, w.IntForceExtractor(msh, "Cylinder"))
    extManager.add(21, wt.TotalIntForceExtractor(msh, "Cylinder"))

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, solScheme, nonLinAlgo, convCriterion, scheme,
                  extManager, gui)
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'waterColoumnFallFakeSolidSolver.msh'

    rho0 = 1000.
    mu = 0.001

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.nonLinAlgorithm = 1
    pbl.solScheme = 1
    pbl.alpha = 1.2
    pbl.extP = 100.
    pbl.scalingU = 1.0

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    scheme = w.BackwardEuler(msh, pbl)

    w.Medium(msh, "Walls", mu, rho0, 3)
    w.Medium(msh, "Face1", mu, rho0, 1)

    # boundaries
    w.Boundary(msh, "Free", 3, pbl.extP)
    w.Boundary(msh, "Walls", 1, 0.0)
    w.Boundary(msh, "Walls", 2, 0.0)

    scheme.ttot = 1.0
    scheme.savefreq = 1
    scheme.nthreads = 3
    scheme.gamma = 0.5
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True
    scheme.tollNLalgo = 1e-12

    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 1))
    extManager.add(2, w.IntForceExtractor(msh, 1))
    extManager.add(3, w.ExtForceExtractor(msh, 1))
    extManager.add(4, w.IneForceExtractor(msh, 1))
    extManager.add(5, w.IntForceExtractor(msh, 6))
    extManager.add(6, w.ExtForceExtractor(msh, 6))
    extManager.add(7, w.IneForceExtractor(msh, 6))
    extManager.add(8, w.PressureExtractor(msh, 1))
    extManager.add(9, w.VelocityExtractor(msh, "Face1"))
    extManager.add(10, w.MassExtractor(msh, pbl, "Face1"))
    extManager.add(11, wt.KineticEnergyExtractor(msh, pbl, "Face1"))
    extManager.add(12, wt.ViscousEnergyExtractor(msh, pbl, scheme, "Face1"))

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, scheme, extManager, gui)
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'waterColumnOnElasticColumn_Mtf_Pfem.msh'

    rho0 = 1000.
    mu = 0.

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.alpha = 2.0
    pbl.extP = 0.
    pbl.scalingU = 15.0
    pbl.bodyForceY = -10.
    pbl.remeshing = False

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    toll = 1e-6
    nItMax = 20

    solScheme = w.SchemeMonolithicPSPG(msh, pbl)
    solScheme.tauPSPGcomputation = 3
    convCriterion = w.ForcesBalanceNormedBodyForceCriterion(msh, pbl, toll)
    # convCriterion = w.PositionIncrementCriterion(msh, pbl, toll)
    nonLinAlgo = w.PicardAlgorithm(solScheme, convCriterion, nItMax)

    scheme = w.BackwardEuler(msh, pbl, nonLinAlgo)

    w.Medium(msh, 14, mu, rho0, 3)
    w.Medium(msh, 18, mu, rho0, 1)

    # boundaries
    w.Boundary(msh, 16, 3, pbl.extP)
    w.Boundary(msh, 15, 1, 0.0)
    w.Boundary(msh, 14, 1, 0.0)
    w.Boundary(msh, 14, 2, 0.0)

    scheme.nthreads = 1

    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 3))
    extManager.add(2, w.PositionExtractor(msh, 6))
    extManager.add(3, w.PositionExtractor(msh, 76))

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, solScheme, nonLinAlgo, convCriterion, scheme,
                  extManager, gui)
Esempio n. 5
0
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'birdImpact_deformable_panel_Mtf_Pfem_Axisym.msh'

    rho0 = 1000.
    mu = 0.001
    U0 = 100

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.nonLinAlgorithm = 1
    pbl.solScheme = 1
    pbl.alpha = 1.2
    pbl.beta = 0.
    pbl.gravity = 0.
    pbl.scalingU = U0
    pbl.isAxisymmetric = True

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    scheme = w.BackwardEuler(msh, pbl)

    w.Medium(msh, 13, mu, rho0, 3)
    w.Medium(msh, 17, mu, rho0, 1)

    # boundaries
    w.Boundary(msh, 15, 7, 0.0)
    w.Boundary(msh, 16, 3, 0.0)
    w.Boundary(msh, 13, 1, 0.0)
    w.Boundary(msh, 13, 2, 0.0)

    # --- Necessary for the correct elimination of nodes along the axis of symmetry ---
    n4 = msh.getNode(4)
    n4.isOnAxisOfSymmetry = True
    # ---

    #Initial velocity
    bird = w.Group(msh, 17)
    loadingset = w.LoadingSet(msh)
    loadingset.add(1, w.InitialVelocity(msh, bird, 0., -U0, 0.))

    scheme.savefreq = 1
    scheme.nthreads = 3
    scheme.gamma = 0.5
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True
    scheme.tollNLalgo = 1e-7

    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 4))
    extManager.add(6, wt.KineticEnergyExtractor(msh, pbl, 17))
    extManager.add(7, wt.ViscousEnergyExtractor(msh, pbl, scheme, 17))
    extManager.add(8, wt.PressureWorkExtractor(msh, pbl, scheme, 17))
    extManager.add(9, w.MassExtractor(msh, pbl, 17))

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, bird, loadingset, scheme, extManager, gui)
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'birdImpact_deformable_panel_Mtf_Pfem_Smojver_Axisym.msh'

    rho0 = 938.
    mu = 0.001
    U0 = 145.7

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.nonLinAlgorithm = 1
    pbl.solScheme = 1
    pbl.alpha = 1.2
    pbl.beta = 0.
    pbl.gravity = 0.
    pbl.scalingU = U0
    pbl.isAxisymmetric = True

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    toll = 1e-6
    nItMax = 10

    solScheme = w.SchemeMonolithicPSPG(msh, pbl)
    convCriterion = w.ForcesBalanceNormedBodyForceCriterion(msh, pbl, toll)
    nonLinAlgo = w.PicardAlgorithm(solScheme, convCriterion, nItMax)

    scheme = w.BackwardEuler(msh, pbl, nonLinAlgo)

    w.Medium(msh, 17, mu, rho0, 3)
    w.Medium(msh, 21, mu, rho0, 1)

    # boundaries
    w.Boundary(msh, 20, 7, 0.0)
    w.Boundary(msh, 19, 3, 0.0)
    w.Boundary(msh, 17, 1, 0.0)
    w.Boundary(msh, 17, 2, 0.0)

    # --- Necessary for the correct elimination of nodes along the axis of symmetry ---
    n4 = msh.getNode(6)
    n4.isOnAxisOfSymmetry = True
    # ---

    #Initial velocity
    bird = w.Group(msh, 21)
    loadingset = w.LoadingSet(msh)
    loadingset.add(1, w.InitialVelocity(msh, bird, 0., -U0, 0.))

    scheme.savefreq = 1
    scheme.nthreads = 3
    scheme.gamma = 0.5
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True
    scheme.tollNLalgo = 1e-7

    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 6))
    extManager.add(6, wt.KineticEnergyExtractor(msh, pbl, 21))
    extManager.add(7, wt.ViscousEnergyExtractor(msh, pbl, scheme, 21))
    extManager.add(8, wt.PressureWorkExtractor(msh, pbl, scheme, 21))
    extManager.add(9, w.MassExtractor(msh, pbl, 21))

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, solScheme, nonLinAlgo, convCriterion, scheme,
                  extManager, gui)
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'waterColoumnFallWithFlexibleObstacle_Mtf_Pfem.msh'

    rho0 = 1000.
    mu = 0.001

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.alpha = 1.2
    pbl.extP = 0.
    pbl.scalingU = 5.0
    pbl.bodyForceY = -9.81

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    toll = 1e-6
    nItMax = 20

    solScheme = w.SchemeMonolithicPSPG(msh, pbl)
    convCriterion = w.ForcesBalanceNormedBodyForceCriterion(msh, pbl, toll)
    nonLinAlgo = w.PicardAlgorithm(solScheme, convCriterion, nItMax)

    scheme = w.BackwardEuler(msh, pbl, nonLinAlgo)

    contactTag = w.Tag(100, "Contact", 2)
    msh.ptags[100] = contactTag
    msh.ntags["Contact"] = contactTag

    w.Medium(msh, 100, 0., 0., 0., 4)
    w.Medium(msh, 17, 0., 0., 3)
    w.Medium(msh, 16, mu, rho0, 1)
    w.Medium(msh, 20, mu, rho0, 1)

    # boundaries
    w.Boundary(msh, 18, 3, pbl.extP)
    w.Boundary(msh, 16, 1, 0.0)
    w.Boundary(msh, 16, 2, 0.0)
    w.Boundary(msh, 17, 1, 0.0)
    w.Boundary(msh, 17, 2, 0.0)

    scheme.savefreq = 1
    scheme.nthreads = 3
    scheme.gamma = 0.6
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True

    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 6))
    '''extManager.add(1,w.PositionExtractor(msh,1))
    extManager.add(2,w.IntForceExtractor(msh,1))
    extManager.add(3,w.ExtForceExtractor(msh,1))
    extManager.add(4,w.IneForceExtractor(msh,1))'''
    extManager.add(5, w.IntForceExtractor(msh, 6))
    '''extManager.add(6,w.ExtForceExtractor(msh,6))
    extManager.add(7,w.IneForceExtractor(msh,6))
    extManager.add(8,w.PressureExtractor(msh,1))
    extManager.add(9,w.VelocityExtractor(msh,"Water"))
    extManager.add(10,w.MassExtractor(msh,"Water"))
    extManager.add(11,wt.KineticEnergyExtractor(msh,pbl,"Water"))
    extManager.add(12,wt.ViscousEnergyExtractor(msh,pbl,scheme,"Water"))'''

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, contactTag, solScheme, nonLinAlgo,
                  convCriterion, scheme, extManager, gui)
Esempio n. 8
0
def getPfem():
    global w
    if w: return w
    w = pfem
    
    mshFile = runPath+os.sep+'MovingSquareCoarse.msh'
    
    # Physical parameters for the fluid
    rho0 = 1. #kg/m3
    mu = 0.
    
    # Problem definition
    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.alpha = 1.4                         # Alpha-shapes parameter
    pbl.extP = 1.                           # External pressure (arbitrary in incompressible formulations)
    pbl.scalingU = 0.03                        # Global scaling velocity for PSPG stabilization
    pbl.bodyForceY = -10.                  # Gravity
    
    # Initial mesh
    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh
    
    # Formulation (PSPG stabilization/Fractional step/Algebraic splitting)
    solScheme = w.SchemeMonolithicPSPG(msh, pbl)
    
    # Non-linear iteration algorithm
    toll = 1e-6
    nItMax = 20
    convCriterion = w.ForcesBalanceNormedBodyForceCriterion(msh, pbl, toll)
    nonLinAlgo = w.PicardAlgorithm(solScheme, convCriterion, nItMax)
    
    # Time integration scheme
    scheme = w.BackwardEuler(msh, pbl, nonLinAlgo)
    
    msh.ptags[3].name = "Square"
    msh.ntags["Square"] = msh.ptags[3]
    
    w.Medium(msh, 3, 0., 0., 3)
    w.Medium(msh, 4, mu, rho0, 1)
    
    # boundaries
    w.Boundary(msh, 1, 1, 0.0)
    w.Boundary(msh, 1, 2, 0.0)
    w.Boundary(msh, 2, 3, pbl.extP)
    w.Boundary(msh, 3, 1, 0.0)
    w.Boundary(msh, 3, 2, 0.0)
    
    # Time integration
    scheme.nthreads=4
    scheme.gamma = 0.5
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True
    
    extManager = w.ExtractorsManager(msh)
    extManager.add(1,w.PositionExtractor(msh,"Square"))
    extManager.add(2,w.VelocityExtractor(msh,"Square"))
    extManager.add(3,w.IntForceExtractor(msh,"Square"))
    extManager.add(4,wt.TotalIntForceExtractor(msh,"Square"))
    extManager.add(5,wt.TotalExtForceExtractor(msh,"Square"))
    extManager.add(6,wt.TotalIneForceExtractor(msh,"Square"))
    extManager.add(7,w.PressureExtractor(msh,"Square"))
    
    gui = v.MeshViewer(msh, scheme, True) 
    
    return Module(w, msh, pbl, scheme, solScheme, nonLinAlgo, convCriterion, extManager, gui)
Esempio n. 9
0
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'PingPongCylinder_depth_1D.msh'

    rho0 = 1000.
    mu = 0.001

    #Problem data
    D = 0.04  # Cylinder diameter [m]
    l = 0.2  # Tank half-width [m]
    h0 = D  # Initial depth [m]
    h = h0 + D + 3 * D  #Tank height [m]

    # Physical parameters for the fluid
    rho0 = 1000.  #kg/m3
    mu = 0.001

    # Problem definition
    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.alpha = 1.3  # Alpha-shapes parameter
    pbl.extP = 0.  # External pressure (arbitrary in incompressible formulations)
    pbl.scalingU = 10.  # Global scaling velocity for PSPG stabilization
    pbl.bodyForceY = -9.81  # Gravity
    pbl.surfTensionAtFreeSurface = 72.86e-3  # Water/air surface tension coefficient

    # Initial mesh
    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    # Formulation (PSPG stabilization/Fractional step/Algebraic splitting)
    solScheme = w.SchemeMonolithicPSPG(msh, pbl)

    # Non-linear iteration algorithm
    toll = 1e-3
    nItMax = 10
    convCriterion = w.PositionIncrementCriterion(msh, pbl, toll)
    nonLinAlgo = w.PicardAlgorithm(solScheme, convCriterion, nItMax)

    # Time integration scheme
    scheme = w.BackwardEuler(msh, pbl, nonLinAlgo)

    # Physical domains
    w.Medium(msh, 13, mu, rho0, 1)
    w.Medium(msh, 15, mu, rho0, 1)
    w.Medium(msh, 17, mu, rho0, 1)

    # boundaries
    w.Boundary(msh, 13, 1, 0.0)
    w.Boundary(msh, 13, 2, 0.0)
    w.Boundary(msh, 15, 1, 0.0)
    w.Boundary(msh, 15, 2, 0.0)
    w.Boundary(msh, 14, 3, pbl.extP)
    w.Boundary(msh, 16, 1, 0.0)
    w.Boundary(msh, 16, 2, 0.0)

    # Time integration
    scheme.nthreads = 4
    scheme.gamma = 0.5
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True

    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 16))
    extManager.add(2, w.VelocityExtractor(msh, 16))
    extManager.add(3, w.PressureExtractor(msh, 16))
    extManager.add(4, w.IntForceExtractor(msh, 16))
    extManager.add(5, w.MassExtractor(msh, pbl, 17))

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, scheme, solScheme, nonLinAlgo, convCriterion,
                  extManager, gui)
def getPfem():
    global w
    if w: return w
    w = pfem
    
    mshFile = runPath+os.sep+'birdStrike_lsDyna_benchmark_Mtf_Pfem.msh'
    
    rho0 = 781.
    mu = 0.01
    U0 = 0.05
    V0 = -0.01
    N = 10

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.nonLinAlgorithm = 1
    pbl.solScheme = 1
    pbl.alpha = 1.2
    pbl.beta = 0.
    pbl.gravity = 0.
    pbl.scalingU = U0
    
    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh
    
    scheme = w.BackwardEuler(msh, pbl)

    w.Medium(msh, 15, mu, rho0, 3)
    w.Medium(msh, 17, mu, rho0, 1)
    
    # boundaries
    w.Boundary(msh, 14, 3, 0.0)
    w.Boundary(msh, 15, 1, 0.0)
    w.Boundary(msh, 15, 2, 0.0)
    
    #Initial velocity
    bird = w.Group(msh, 17)
    loadingset = w.LoadingSet(msh)
    loadingset.add(1,w.InitialVelocity(msh,bird,U0,V0,0.))
    
    scheme.savefreq=1
    scheme.nthreads=1
    scheme.gamma = 0.5
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True
    scheme.tollNLalgo = 1e-7
    
    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1,w.PositionExtractor(msh,4))
    extManager.add(2,w.PositionExtractor(msh,3))
    '''extManager.add(1,w.IntForceExtractor(msh,"Wall"))
    extManager.add(2,w.ExtForceExtractor(msh,"Wall"))
    extManager.add(3,w.IneForceExtractor(msh,"Wall"))
    extManager.add(4,w.PressureExtractor(msh,"Wall"))
    extManager.add(5,w.PositionExtractor(msh,"Wall"))
    extManager.add(6,wt.KineticEnergyExtractor(msh,pbl,"Body"))
    extManager.add(7,wt.ViscousEnergyExtractor(msh,pbl,scheme,"Body"))'''
    
    gui = v.MeshViewer(msh, scheme, True) 
    
    return Module(w, msh, pbl, bird, loadingset, scheme, extManager, gui)
def getPfem():
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'elasticContainerFilling.msh'

    rho0 = 1000.
    mu = 100.0

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.alpha = 1.2
    pbl.extP = 0.
    pbl.scalingU = 10.0
    pbl.bodyForceY = -9.81

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    toll = 1e-6
    nItMax = 20

    solScheme = w.SchemeMonolithicPSPG(msh, pbl)
    convCriterion = w.ForcesBalanceNormedBodyForceCriterion(msh, pbl, toll)
    nonLinAlgo = w.PicardAlgorithm(solScheme, convCriterion, nItMax)

    scheme = w.BackwardEuler(msh, pbl, nonLinAlgo)

    contactTag = w.Tag(100, "Contact", 2)
    msh.ptags[100] = contactTag
    msh.ntags["Contact"] = contactTag

    w.Medium(msh, 100, 0., 0., 0., 4)
    w.Medium(msh, 2, 0., 0., 3)
    w.Medium(msh, 4, 0., 0., 3)
    w.Medium(msh, 5, 0., 0., 3)
    w.Medium(msh, 6, mu, rho0, 1)

    # boundaries
    w.Boundary(msh, 1, 3, pbl.extP)
    w.Boundary(msh, 2, 1, 0.0)
    w.Boundary(msh, 2, 2, 0.0)
    w.Boundary(msh, 4, 1, 0.0)
    w.Boundary(msh, 4, 2, 0.0)
    w.Boundary(msh, 5, 1, 0.0)
    w.Boundary(msh, 5, 2, 0.0)

    scheme.savefreq = 1
    scheme.nthreads = 4
    scheme.gamma = 0.6
    scheme.omega = 0.5
    scheme.addRemoveNodesOption = True

    #Results
    extManager = w.ExtractorsManager(msh)
    extManager.add(1, w.PositionExtractor(msh, 462))
    extManager.add(2, w.PositionExtractor(msh, 463))

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, contactTag, solScheme, nonLinAlgo,
                  convCriterion, scheme, extManager, gui)
def getPfem():
    global contactTag
    global w
    if w: return w
    w = pfem

    mshFile = runPath + os.sep + 'VIV_cantileverBeam_freeSlip.msh'

    rho0 = 1.18
    mu = 1.82e-5
    U = 0.513

    pbl = w.Problem()
    pbl.rho0 = rho0
    pbl.mu = mu
    pbl.nonLinAlgorithm = 1
    pbl.solScheme = 1
    pbl.alpha = 100.0
    pbl.extP = 0.
    pbl.scalingU = U

    msh = w.MshData(pbl)
    msh.load(mshFile)
    print msh

    msh.boundingBox = True
    msh.xMin = -0.0601
    msh.xMax = 0.0601
    msh.yMin = -0.144
    msh.yMax = 0.0501

    contactTag = w.Tag(100, "Contact", 2)
    msh.ptags[100] = contactTag
    msh.ntags["Contact"] = contactTag

    scheme = w.BackwardEuler(msh, pbl)

    w.Medium(msh, "Contact", 0., 0., 0., 4)
    w.Medium(msh, 23, mu, rho0, 3)
    w.Medium(msh, 22, mu, rho0, 3)
    w.Medium(msh, 25, mu, rho0, 1)

    print msh.media.size()

    # boundaries
    w.Boundary(msh, 19, 9, 0.0)
    w.Boundary(msh, 20, 3, 0.0)
    w.Boundary(msh, 20, 6, 0.0)
    w.Boundary(msh, 21, 1, 0.)
    w.Boundary(msh, 21, 2, -U)
    w.Boundary(msh, 21, 5, 0.0)
    w.Boundary(msh, 22, 1, 0.0)
    w.Boundary(msh, 22, 2, 0.0)
    w.Boundary(msh, 23, 1, 0.0)
    w.Boundary(msh, 23, 2, 0.0)

    # --- Necessary for the correct elimination of nodes on the Outlet using slip conditions ---
    n2 = msh.getNode(2)
    n3 = msh.getNode(3)
    n2.isOnFreeSlipBoundaryY = True
    n3.isOnFreeSlipBoundaryY = True
    # ---

    scheme.savefreq = 100
    scheme.nthreads = 4
    scheme.gamma = 0.8
    scheme.omega = 0.7
    scheme.addRemoveNodesOption = True

    #Results
    extManager = w.ExtractorsManager(msh)

    gui = v.MeshViewer(msh, scheme, True)

    return Module(w, msh, pbl, scheme, extManager, gui)