Exemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(FunctionAssigner, self).__init__(*args, **kwargs)
     self.input_spaces = Enlist(args[1])
     self.output_spaces = Enlist(args[0])
     self.adj_assigner = backend.FunctionAssigner(args[1],
                                                  args[0],
                                                  **kwargs)
Exemplo n.º 2
0
def vector_mesh_to_boundary(func, b_mesh):
    v_split = func.split(deepcopy=True)
    v_b = []
    for v in v_split:
        v_b.append(mesh_to_boundary(v, b_mesh))
    Vb = backend.VectorFunctionSpace(b_mesh, "CG", 1)
    vb_out = backend.Function(Vb)
    scalar_to_vec = backend.FunctionAssigner(Vb,
                                             [v.function_space() for v in v_b])
    scalar_to_vec.assign(vb_out, v_b)
    return vb_out
Exemplo n.º 3
0
def vector_boundary_to_mesh(boundary_func, mesh):
    """
    Transfer a Vector-CG1 function from a Boundary mesh to
    a CG-1 function living on the Parent mesh (where all interior
    values are 0). This function is only meant to be called internally in
    pyadjoint, or for verification purposes.
    """
    V = backend.VectorFunctionSpace(mesh, "CG", 1)
    vb_split = boundary_func.split(deepcopy=True)
    v_vol = []
    for vb in vb_split:
        v_vol.append(boundary_to_mesh(vb, mesh))
    scalar_to_vec = backend.FunctionAssigner(
        V, [v.function_space() for v in v_vol])
    v_out = backend.Function(V)
    scalar_to_vec.assign(v_out, v_vol)
    return v_out
        def __init__(self, *args, **kwargs):
            super(FunctionAssigner, self).__init__(*args, **kwargs)

            # The adjoint function assigner with swapped FunctionSpace arguments
            self.adj_function_assigner = backend.FunctionAssigner(
                args[1], args[0])