Ejemplo n.º 1
0
    def apply_essential(self, engine, gf, kfes, real=False, **kwargs):

        mesh = engine.get_mesh(mm=self)
        ibdr = mesh.bdr_attributes.ToList()
        bdr_attr = [0] * mesh.bdr_attributes.Max()
        for idx in self._sel_index:
            bdr_attr[idx - 1] = 1

        if kfes == 0:
            coeff1 = mfem.VectorArrayCoefficient(3)
            coeff1.Set(0, mfem.ConstantCoefficient(0.0))
            coeff1.Set(1, mfem.ConstantCoefficient(0.0))
            coeff1.Set(2, mfem.ConstantCoefficient(0.0))
            gf.ProjectBdrCoefficientTangent(coeff1, mfem.intArray(bdr_attr))
Ejemplo n.º 2
0
    def apply_essential(self, engine, gf, real = False, kfes = 0):
        if kfes > 1: return
        if real:       
            dprint1("Apply Ess.(real)" + str(self._sel_index))
        else:
            dprint1("Apply Ess.(imag)" + str(self._sel_index))
            
        Erphiz = self.vt.make_value_or_expression(self)              
        mesh = engine.get_mesh(mm = self)        
        ibdr = mesh.bdr_attributes.ToList()
        bdr_attr = [0]*mesh.bdr_attributes.Max()
        for idx in self._sel_index:
            bdr_attr[idx-1] = 1

        if kfes == 0:
            coeff1 = mfem.VectorArrayCoefficient(2)
            coeff1.Set(0, mfem.ConstantCoefficient(0.0))
            coeff1.Set(1, mfem.ConstantCoefficient(0.0))            
            gf.ProjectBdrCoefficientTangent(coeff1,
                                            mfem.intArray(bdr_attr))
        elif kfes == 1:
            coeff1 = mfem.ConstantCoefficient(0.0)
            gf.ProjectBdrCoefficient(coeff1,
                                     mfem.intArray(bdr_attr))
Ejemplo n.º 3
0
#    converting it to a list of true dofs.
ess_bdr = mfem.intArray(pmesh.bdr_attributes.Max())
ess_tdof_list = mfem.intArray()
ess_bdr.Assign(0)
ess_bdr[0] = 1
fespace.GetEssentialTrueDofs(ess_bdr, ess_tdof_list)

#  9. Set up the parallel linear form b(.) which corresponds to the
#     right-hand side of the FEM linear system. In this case, b_i equals the
#     boundary integral of f*phi_i where f represents a "pull down" force on
#     the Neumann part of the boundary and phi_i are the basis functions in
#     the finite element fespace. The force is defined by the object f, which
#     is a vector of Coefficient objects. The fact that f is non-zero on
#     boundary attribute 2 is indicated by the use of piece-wise constants
#     coefficient for its last component.
f = mfem.VectorArrayCoefficient(dim)
for i in range(dim - 1):
    f.Set(i, mfem.ConstantCoefficient(0.0))

pull_force = mfem.Vector([0] * pmesh.bdr_attributes.Max())
pull_force[1] = -1.0e-2
f.Set(dim - 1, mfem.PWConstCoefficient(pull_force))

b = mfem.ParLinearForm(fespace)
b.AddBoundaryIntegrator(mfem.VectorBoundaryLFIntegrator(f))
print('r.h.s. ...')
b.Assemble()

# 10. Define the solution vector x as a parallel finite element grid
#     function corresponding to fespace. Initialize x with initial guess of
#     zero, which satisfies the boundary conditions.