Ejemplo n.º 1
0
fespace = mfem.FiniteElementSpace(mesh, fec, dim)

fe_size = fespace.GetVSize()
print("Number of velocity/deformation unknowns: " + str(fe_size))
fe_offset = intArray([0, fe_size, 2 * fe_size])

vx = mfem.BlockVector(fe_offset)
x = mfem.GridFunction()
v = mfem.GridFunction()
v.MakeRef(fespace, vx.GetBlock(0), 0)
x.MakeRef(fespace, vx.GetBlock(1), 0)

x_ref = mfem.GridFunction(fespace)
mesh.GetNodes(x_ref)

w_fec = mfem.L2_FECollection(order + 1, dim)
w_fespace = mfem.FiniteElementSpace(mesh, w_fec)
w = mfem.GridFunction(w_fespace)


# 6. Set the initial conditions for v and x, and the boundary conditions on
#    a beam-like mesh (see description above).
class InitialVelocity(mfem.VectorPyCoefficient):
    def EvalValue(self, x):
        dim = len(x)
        s = 0.1 / 64.

        v = np.zeros(len(x))
        v[-1] = s * x[0]**2 * (8.0 - x[0])
        v[0] = -s * x[0]**2
        return v
Ejemplo n.º 2
0
        return -pFunc_exact(x)


order = 1
static_cond = False
meshfile = expanduser(join(path, 'data', 'star.mesh'))
mesh = mfem.Mesh(meshfile, 1, 1)

dim = mesh.Dimension()

ref_levels = int(np.floor(np.log(10000. / mesh.GetNE()) / np.log(2.) / dim))
for x in range(ref_levels):
    mesh.UniformRefinement()

hdiv_coll = mfem.RT_FECollection(order, dim)
l2_coll = mfem.L2_FECollection(order, dim)

R_space = mfem.FiniteElementSpace(mesh, hdiv_coll)
W_space = mfem.FiniteElementSpace(mesh, l2_coll)

dimR = R_space.GetVSize()
dimW = W_space.GetVSize()

print("***********************************************************")
print("dim(R) = " + str(dimR))
print("dim(W) = " + str(dimW))
print("dim(R+W) = " + str(dimR + dimW))
print("***********************************************************")

block_offsets = intArray([0, dimR, dimW])
block_offsets.PartialSum()
Ejemplo n.º 3
0
#     - The test space, test_space, is an enriched space where the enrichment
#       degree may depend on the spatial dimension of the domain, the type of
#       the mesh and the trial space order.
   
trial_order = order
trace_order = order - 1;
test_order  = order  # reduced order, full order is (order + dim - 1)

if (dim == 2 and  (order%2 == 0 or (mesh.MeshGenerator() & 2 and order > 1))):
    test_order = test_order + 1
if (test_order < trial_order):
    print("Warning, test space not enriched enough to handle primal trial space")

x0_fec   = mfem.H1_FECollection(trial_order, dim)
xhat_fec = mfem.RT_Trace_FECollection(trace_order, dim)
test_fec = mfem.L2_FECollection(test_order, dim)
    
x0_space   = mfem.FiniteElementSpace(mesh, x0_fec)
xhat_space = mfem.FiniteElementSpace(mesh, xhat_fec)
test_space = mfem.FiniteElementSpace(mesh, test_fec)

# 5. Define the block structure of the problem, by creating the offset
#    variables. Also allocate two BlockVector objects to store the solution
#    and rhs.

x0_var = 0;  xhat_var = 1;  NVAR = 2

s0 = x0_space.GetVSize()
s1 = xhat_space.GetVSize()
s_test = test_space.GetVSize()