예제 #1
0
def MaxFacetEdgeLength(mesh: cpp.mesh.Mesh) -> ufl.MaxFacetEdgeLength:
    """Return symbolic maximum facet edge length of a cell
    for given mesh.

    *Example of usage*

        .. code-block:: python

            mesh = UnitSquare(4,4)
            maxfe = MaxFacetEdgeLength(mesh)

    """

    return ufl.MaxFacetEdgeLength(mesh.ufl_domain())
예제 #2
0
def MaxFacetEdgeLength(mesh):
    """
    Return symbolic maximum facet edge length of a cell for given mesh.

    *Arguments*
        mesh
            a :py:class:`Mesh <dolfin.cpp.Mesh>`.

    *Example of usage*

        .. code-block:: python

            mesh = UnitSquare(4,4)
            vol = MaxFacetEdgeLength(mesh)

    """
    return ufl.MaxFacetEdgeLength(_mesh2domain(mesh))
예제 #3
0
top = 1.0
if dim == 3:
    top = ufl.conditional(x[2] > 1.25, 1, 0)

initial_u = iu(x[1]) * top + iu(2.5 - x[1]) * (1.0 - top)
initial_v = ufl.conditional(x[0] < 1.25, 0.5, 0)

uh = space.interpolate(initial_u, name="u")
uh_n = uh.copy()
vh = space.interpolate(initial_v, name="v")
vh_n = vh.copy()

u = ufl.TrialFunction(space)
phi = ufl.TestFunction(space)
hT = ufl.MaxCellEdgeLength(space.cell())
hS = ufl.avg(ufl.MaxFacetEdgeLength(space.cell()))
hs = ufl.MaxFacetEdgeLength(space.cell())('+')
n = ufl.FacetNormal(space.cell())

ustar = lambda v: (v + spiral_b) / spiral_a
diffusiveFlux = lambda w, d: spiral_D * d
source = lambda u1, u2, u3, v: -1 / spiral_eps * u1 * (1 - u2) * (u3 - ustar(v)
                                                                  )
source = lambda u1, u2, u3, v: -1 / spiral_eps * u1 * (1 - u2) * (u3 - ustar(v)
                                                                  )

xForm = inner(diffusiveFlux(u, grad(u)), grad(phi)) * dx
xForm += ufl.conditional(uh_n < ustar(vh_n), source(u, uh_n, uh_n, vh_n),
                         source(uh_n, u, uh_n, vh_n)) * phi * dx

# <markdowncell>
예제 #4
0
        "newton.verbose": False,
        "newton.linear.verbose": False}
scheme = dune.fem.scheme.galerkin(equation,
                                  solver="cg",
                                  parameters=solverParameters)

# <markdowncell>
# Error estimator
# <codecell>

fvspace = dune.fem.space.finiteVolume(uh.space.grid)
estimate = fvspace.interpolate([0], name="estimate")

chi = ufl.TestFunction(fvspace)
hT = ufl.MaxCellEdgeLength(fvspace.cell())
he = ufl.MaxFacetEdgeLength(fvspace.cell())('+')
n = ufl.FacetNormal(fvspace.cell())

residual = (u - uh_n) / dt - div(diffusiveFlux) + source(u, u, u, vh)

estimator_ufl = hT**2 * residual**2 * chi * dx +\
                he * inner( jump(diffusiveFlux), n('+'))**2 * avg(chi) * dS
estimator = dune.fem.operator.galerkin(estimator_ufl)

# <markdowncell>
# Time loop
# <codecell>

nextSaveTime = saveInterval
count = 0
levelFunction = dune.fem.function.levelFunction(gridView)