Пример #1
0
    def before_first_compute(self, get):
        u = get("Velocity")
        V = u.function_space()

        spaces = SpacePool(V.mesh())
        degree = V.ufl_element().degree()
        
        if degree <= 1:
            Q = spaces.get_grad_space(V, shape=(spaces.d,))
        else:
            if degree > 2:
                cbc_warning("Unable to handle higher order WSS space. Using CG1.")
            Q = spaces.get_space(1,1)

        Q_boundary = spaces.get_space(Q.ufl_element().degree(), 1, boundary=True)

        self.v = TestFunction(Q)
        self.tau = Function(Q, name="WSS_full")
        self.tau_boundary = Function(Q_boundary, name="WSS")

        local_dofmapping = mesh_to_boundarymesh_dofmap(spaces.BoundaryMesh, Q, Q_boundary)
        self._keys = np.array(local_dofmapping.keys(), dtype=np.intc)
        self._values = np.array(local_dofmapping.values(), dtype=np.intc)
        self._temp_array = np.zeros(len(self._keys), dtype=np.float_)

        Mb = assemble(inner(TestFunction(Q_boundary), TrialFunction(Q_boundary))*dx)
        self.solver = create_solver("gmres", "jacobi")
        self.solver.set_operator(Mb)

        self.b = Function(Q_boundary).vector()

        self._n = FacetNormal(V.mesh())
Пример #2
0
def test_grad_spaces(mesh):
    p = SpacePool(mesh)
    d = mesh.geometry().dim()

    #Q = get_custom_space("CG", 1, (1,))
    Q = p.get_space(1,0)
    DQ = p.get_grad_space(Q)
    assert DQ.ufl_element().family() == "Discontinuous Lagrange"
    assert DQ.ufl_element().degree() == Q.ufl_element().degree()-1
    assert DQ.ufl_element().value_shape() == (d,)

    V = p.get_space(2,1)
    DV = p.get_grad_space(V)
    assert DV.ufl_element().family() == "Discontinuous Lagrange"
    assert DV.ufl_element().degree() == V.ufl_element().degree()-1
    assert DV.ufl_element().value_shape() == (d,d)

    W = p.get_space(2,2)
    DW = p.get_grad_space(W)
    assert DW.ufl_element().family() == "Discontinuous Lagrange"
    assert DW.ufl_element().degree() == V.ufl_element().degree()-1
    assert DW.ufl_element().value_shape() == (d,d,d)
Пример #3
0
    def before_first_compute(self, get):
        u = get("Velocity")
        V = u.function_space()

        spaces = SpacePool(V.mesh())
        degree = V.ufl_element().degree()

        if degree <= 1:
            Q = spaces.get_grad_space(V, shape=(spaces.d, ))
        else:
            if degree > 2:
                cbc_warning(
                    "Unable to handle higher order WSS space. Using CG1.")
            Q = spaces.get_space(1, 1)

        Q_boundary = spaces.get_space(Q.ufl_element().degree(),
                                      1,
                                      boundary=True)

        self.v = TestFunction(Q)
        self.tau = Function(Q, name="WSS_full")
        self.tau_boundary = Function(Q_boundary, name="WSS")

        local_dofmapping = mesh_to_boundarymesh_dofmap(spaces.BoundaryMesh, Q,
                                                       Q_boundary)
        self._keys = np.array(local_dofmapping.keys(), dtype=np.intc)
        self._values = np.array(local_dofmapping.values(), dtype=np.intc)
        self._temp_array = np.zeros(len(self._keys), dtype=np.float_)

        Mb = assemble(
            inner(TestFunction(Q_boundary), TrialFunction(Q_boundary)) * dx)
        self.solver = create_solver("gmres", "jacobi")
        self.solver.set_operator(Mb)

        self.b = Function(Q_boundary).vector()

        self._n = FacetNormal(V.mesh())