Search in sources :

Example 1 with FunctionCategory

use of cbit.vcell.solver.AnnotatedFunction.FunctionCategory in project vcell by virtualcell.

the class OutputFunctionsPanel method addFunction.

private void addFunction() throws Exception {
    String funcName = getFunctionNameTextField().getText();
    Expression funcExp = null;
    funcExp = new Expression(getFunctionExpressionTextField().getText());
    Domain domain = null;
    VariableType newFunctionVariableType = null;
    boolean bSpatial = simulationWorkspace.getSimulationOwner().getGeometry().getDimension() > 0;
    if (bSpatial) {
        Object selectedItem = getSubdomainComboBox().getSelectedItem();
        if (selectedItem instanceof GeometryClass) {
            GeometryClass geoClass = (GeometryClass) selectedItem;
            domain = new Domain(geoClass);
            if (selectedItem instanceof SubVolume) {
                newFunctionVariableType = VariableType.VOLUME;
            } else if (selectedItem instanceof SurfaceClass) {
                newFunctionVariableType = VariableType.MEMBRANE;
            }
        } else if (selectedItem instanceof VariableType) {
            newFunctionVariableType = (VariableType) selectedItem;
        } else {
            newFunctionVariableType = VariableType.UNKNOWN;
        }
    } else {
        newFunctionVariableType = VariableType.NONSPATIAL;
    }
    AnnotatedFunction tempFunction = new AnnotatedFunction(funcName, funcExp, domain, null, newFunctionVariableType, FunctionCategory.OUTPUTFUNCTION);
    VariableType vt = outputFunctionContext.computeFunctionTypeWRTExpression(tempFunction, funcExp);
    FunctionCategory category = FunctionCategory.OUTPUTFUNCTION;
    if (vt.equals(VariableType.POSTPROCESSING)) {
        category = FunctionCategory.POSTPROCESSFUNCTION;
    }
    AnnotatedFunction newFunction = new AnnotatedFunction(funcName, funcExp, domain, null, vt, category);
    outputFunctionContext.addOutputFunction(newFunction);
    setSelectedObjects(new Object[] { newFunction });
    enableDeleteFnButton();
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) VariableType(cbit.vcell.math.VariableType) Expression(cbit.vcell.parser.Expression) SurfaceClass(cbit.vcell.geometry.SurfaceClass) SubVolume(cbit.vcell.geometry.SubVolume) Domain(cbit.vcell.math.Variable.Domain) FunctionCategory(cbit.vcell.solver.AnnotatedFunction.FunctionCategory) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Aggregations

GeometryClass (cbit.vcell.geometry.GeometryClass)1 SubVolume (cbit.vcell.geometry.SubVolume)1 SurfaceClass (cbit.vcell.geometry.SurfaceClass)1 Domain (cbit.vcell.math.Variable.Domain)1 VariableType (cbit.vcell.math.VariableType)1 Expression (cbit.vcell.parser.Expression)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1 FunctionCategory (cbit.vcell.solver.AnnotatedFunction.FunctionCategory)1