Example #1
0
    _tip = "Function of x, y, z, and t."


def _scalarFunction_shortrepr(self):
    return self.resolveAlias("f").value.string()


ScalarFunctionOutput = output.Output(
    name="Function",
    callback=_scalarFunctionOutput,
    otype=outputval.ScalarOutputValPtr,
    instancefn=scalar_instancefn,
    srepr=_scalarFunction_shortrepr,
    column_names=single_column_name,
    params=[
        strfunction.XYTStrFunctionParameter(
            "f", default=strfunction.XYTStrFunction('1.0'), tip=_tip)
    ])


def _vectorFunctionOutput(mesh, elements, coords, fx=None, fy=None, fz=None):
    ans = []
    for element, coordlist in itertools.izip(elements, coords):
        realcoords = map(element.from_master, coordlist)
        for coord in realcoords:
            val = outputval.VectorOutputVal(config.dimension())
            it = val.getIterator()
            # Although f has three components, the third one won't be
            # used if we're not in three dimensions.
            f = iter([fx, fy, fz])
            while not it.end():  # use size of val, not f!
                fi = f.next()  # python iterator
Example #2
0
    def func(self, position, time, component):
        return self.function(position, time)

    def shortrepr(self):
        return str(self.function)


registeredclass.Registration(
    funcstring,
    ScalarFieldInit,
    FuncScalarFieldInit,
    1,
    params=[
        strfunction.XYTStrFunctionParameter('function',
                                            default='0.0',
                                            tip='A function ' + funcofstring)
    ],
    tip="Initialize a scalar field with a function " + funcofstring + ".",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/func_scalar_init.xml'))

################


class FuncTwoVectorFieldInit(TwoVectorFieldInit):
    def __init__(self, fx, fy):
        self.fx = fx
        self.fy = fy

    def func(self, position, time, component):