Exemplo n.º 1
0
def _product(thetas: ThetaType, operators: AffineExpansionStorage_DirichletBC):
    # Detect BCs defined on the same boundary
    combined = dict()  # from (function space, boundary) to value
    for (op_index, op) in enumerate(operators):
        for bc in op:
            key = bc.identifier()
            if key not in combined:
                combined[key] = list()
            combined[key].append((bc, op_index))
    # Sum them
    output = ProductOutputDirichletBC()
    for (key, item) in combined.items():
        value = function_copy(item[0][0].value())
        value.vector().zero()
        for addend in item:
            theta = float(thetas[addend[1]])
            fun = addend[0].value()
            value.vector().add_local(theta * fun.vector().get_local())
        value.vector().apply("add")
        args = list()
        args.append(item[0][0].function_space())
        args.append(value)
        args.extend(item[0][0]._domain)
        output.append(DirichletBC(*args, **item[0][0]._kwargs))
    return ProductOutput(output)
Exemplo n.º 2
0
def _product(thetas: ThetaType, operators: AffineExpansionStorage_Function):
    output = function_copy(operators[0])
    output.vector().zero()
    for (theta, operator) in zip(thetas, operators):
        theta = float(theta)
        output.vector().add_local(theta * operator.vector().get_local())
    output.vector().apply("add")
    return ProductOutput(output)
Exemplo n.º 3
0
 def integrate(self):
     vector_over_time = list()
     for function in self._function_over_time:
         vector_over_time.append(function.vector().get_local())
     integrated_vector = simps(vector_over_time, dx=self._time_step_size, axis=0)
     integrated_function = function_copy(self._function_over_time[0])
     integrated_function.vector().zero()
     integrated_function.vector().set_local(integrated_vector)
     integrated_function.vector().apply("insert")
     return integrated_function