def getMetafor(p={}):
    global metafor
    if metafor:
        return metafor
    metafor = Metafor()
    p = params(p)
    domain = metafor.getDomain()
    geometry = domain.getGeometry()
    geometry.setDimPlaneStrain(1.0)
    from toolbox.gmsh import GmshImport
    f = os.path.join(os.path.dirname(__file__), 'waterColoumnFallWithFlexibleObstacle_Mtf_Pfem.msh')
    importer = GmshImport(f, domain)
    importer.execute2D()
    groupset = domain.getGeometry().getGroupSet()
    interactionset = domain.getInteractionSet()
    app1 = FieldApplicator(1)
    app1.push(groupset(21))
    interactionset.add(app1)
    materset = domain.getMaterialSet()
    materset.define(1, ElastHypoMaterial)
    mater1 = materset(1)
    mater1.put(MASS_DENSITY, 2500.0)
    mater1.put(ELASTIC_MODULUS, 1000000.0)
    mater1.put(POISSON_RATIO, 0.0)
    prp = ElementProperties(Volume2DElement)
    app1.addProperty(prp)
    prp.put(MATERIAL, 1)
    prp.put(EASS, 2)
    prp.put(EASV, 2)
    prp.put(PEAS, 1e-12)
    loadingset = domain.getLoadingSet()
    loadingset.define(groupset(19), Field1D(TX, RE))
    loadingset.define(groupset(19), Field1D(TY, RE))
    mim = metafor.getMechanicalIterationManager()
    mim.setMaxNbOfIterations(4)
    mim.setResidualTolerance(p['tolNR'])
    ti = AlphaGeneralizedTimeIntegration(metafor)
    metafor.setTimeIntegration(ti)
    if 0:
        tsm = metafor.getTimeStepManager()
        tsm.setInitialTime(0.0, 1.0)
        tsm.setNextTime(1.0, 1, 1.0)
    return metafor
def getMetafor(p={}):
    global metafor
    if metafor:
        return metafor
    metafor = Metafor()
    p = params(p)
    domain = metafor.getDomain()
    geometry = domain.getGeometry()
    geometry.setDimPlaneStrain(1.0)
    from toolbox.gmsh import GmshImport
    f = os.path.join(os.path.dirname(__file__), 'waterColoumnFallWithFlexibleObstacle_Mtf_Pfem.msh')
    importer = GmshImport(f, domain)
    importer.execute2D()
    groupset = domain.getGeometry().getGroupSet()
    interactionset = domain.getInteractionSet()
    app1 = FieldApplicator(1)
    app1.push(groupset(21))
    interactionset.add(app1)
    materset = domain.getMaterialSet()
    materset.define(1, ElastHypoMaterial)
    mater1 = materset(1)
    mater1.put(MASS_DENSITY, 2500.0)
    mater1.put(ELASTIC_MODULUS, 1000000.0)
    mater1.put(POISSON_RATIO, 0.0)
    prp = ElementProperties(Volume2DElement)
    app1.addProperty(prp)
    prp.put(MATERIAL, 1)
    prp.put(EASS, 2)
    prp.put(EASV, 2)
    prp.put(PEAS, 1e-12)
    loadingset = domain.getLoadingSet()
    loadingset.define(groupset(19), Field1D(TX, RE))
    loadingset.define(groupset(19), Field1D(TY, RE))
    mim = metafor.getMechanicalIterationManager()
    mim.setMaxNbOfIterations(4)
    mim.setResidualTolerance(p['tolNR'])
    ti = AlphaGeneralizedTimeIntegration(metafor)
    metafor.setTimeIntegration(ti)
    if 0:
        tsm = metafor.getTimeStepManager()
        tsm.setInitialTime(0.0, 1.0)
        tsm.setNextTime(1.0, 1, 1.0)
    return metafor