Example #1
0
                       dune.grid.cartesianDomain([0, 0], [1, 1], [9, 9]),
                       dimgrid=2)

d = 0.001
p = 1.7

uflSpace = Space((2, 2), 1)
u = TrialFunction(uflSpace)
v = TestFunction(uflSpace)
x = SpatialCoordinate(uflSpace.cell())

rhs = (x[0] + x[1]) * v[0]
a = (pow(d + inner(grad(u), grad(u)), (p - 2) / 2) * inner(grad(u), grad(v)) +
     grad(u[0])[0] * v[0]) * dx + 10 * inner(u, v) * ds
b = rhs * dx + 10 * rhs * ds
model = create.model("integrands", grid, a == b)


def test(space):
    if test_numpy:
        numpySpace = create.space(space,
                                  grid,
                                  dimRange=1,
                                  order=1,
                                  storage='numpy')
        numpyScheme = create.scheme("galerkin", model, numpySpace)
        numpy_h = create.function("discrete", numpySpace, name="numpy")
        numpy_dofs = numpy_h.as_numpy
        # numpyScheme.solve(target = numpy_h)
        start = time.time()
        for i in range(testLoop):
Example #2
0
    (A1(cortexCalc(u_n, u_0, l_0)) + l_0 * NuC), A1(v))

# Model equation

a_ex = (omega * inner(A1(u_n), A1(v)) + tau *
        (Tension_ex + Pressure + Linkers_ex)) * dx
a_im = (omega * inner(A1(u), A1(v)) + tau *
        (Tension_im + Bending + Linkers_im) + g - f) * dx

equation = a_im == a_ex

# now generate the model code and compile
model = create.model("elliptic",
                     surface,
                     equation,
                     coefficients={
                         u_n: solution_n,
                         u_0: solution_0
                     })

# Create volume
Volume = (1 / 3) * inner(Nu(solution, solution_0), A1(solution))
intVolume = integrate(surface, Volume, order=1)[0]

# create the solver using a standard fem scheme
scheme = create.scheme("h1", SolutionSpace, model, solver="bicgstab")
scheme.model.tau = deltaT
scheme.model.x_0 = X_0
scheme.model.omega = Omega
scheme.model.k_psi = K_PSI
scheme.model.k_b = K_B
Example #3
0
tmp = solution.copy()


def limit(target):
    tmp.assign(target)
    limiter(tmp, target)


# <markdowncell>
# Time stepping
# Converting UFL forms to scheme

# <codecell>
if coupled:
    form = form_s + form_p
    tpModel = create.model("integrands", grid, form == 0)
    # tpModel.penalty  = penalty
    # tpModel.timeStep = dt
    scheme = create.scheme(
        "galerkin",
        tpModel,
        spc, ("suitesparse", "umfpack"),
        parameters={"newton." + k: v
                    for k, v in newtonParameters.items()})
else:
    uflSpace1 = Space((P.dimWorld, P.dimWorld), 1)
    u1 = TrialFunction(uflSpace1)
    v1 = TestFunction(uflSpace1)
    form_p = replace(form_p, {
        u: as_vector([u1[0], intermediate.s[0]]),
        v: as_vector([v1[0], 0.])
Example #4
0
mu = 1.
# he = MaxFacetEdgeLength(uflSpace.cell())('+') # this is wrong
# hT = MaxCellEdgeLength(uflSpace.cell())
hT = CellVolume(uflSpace.cell())
hF = FacetArea(uflSpace.cell())
# he = FacetArea(uflSpace.cell()) / Min( avg('+'), avg('-') )
heInv = hF / avg(hT)
exact = as_vector([cos(pi * x[0]) * cos(pi * x[1])])

#########

a = inner(grad(u - exact), grad(v)) * dx
a += mu * hT * div(grad(u[0] - exact[0])) * div(grad(v[0])) * dx
s = mu / heInv * inner(jump(grad(u[0])), jump(grad(v[0]))) * dS
s += mu / hF * inner(u - exact, v) * ds
model = create.model("integrands", grid, a + s == 0)
scheme = create.scheme(
    "galerkin",
    model,
    spc,
    solver="cg",
    parameters={"newton." + k: v
                for k, v in newtonParameter.items()})
solA = spc.interpolate([0], name="solA")
scheme.solve(solA)

########

a = div(grad(u[0] - exact[0])) * div(grad(v[0])) * dx
s = mu * heInv * inner(jump(grad(u[0])), jump(grad(v[0]))) * dS
s += mu / hF**3 * inner(u - exact, v) * ds