use of cbit.vcell.math.VariableType in project vcell by virtualcell.
the class MathTestingUtilities method comparePDEResults.
/**
* Insert the method's description here.
* Creation date: (8/20/2003 12:58:10 PM)
*/
public static SimulationComparisonSummary comparePDEResults(SimulationSymbolTable testSimSymbolTable, PDEDataManager testDataManager, SimulationSymbolTable refSimSymbolTable, PDEDataManager refDataManager, String[] varsToCompare, double absErrorThreshold, double relErrorThreshold, VCDocument refDocument, DataInfoProvider refDataInfoProvider, VCDocument testDocument, DataInfoProvider testDataInfoProvider) throws DataAccessException, ExpressionException {
java.util.Hashtable<String, DataErrorSummary> tempVarHash = new java.util.Hashtable<String, DataErrorSummary>();
boolean bTimesEqual = true;
double[] testTimeArray = testDataManager.getDataSetTimes();
double[] refTimeArray = refDataManager.getDataSetTimes();
if (testTimeArray.length != refTimeArray.length) {
bTimesEqual = false;
// throw new RuntimeException("Data times for reference and test simulations don't match, cannot compare the two simulations!");
} else {
for (int i = 0; i < testTimeArray.length; i++) {
if (testTimeArray[i] != refTimeArray[i]) {
bTimesEqual = false;
}
}
}
// if (!checkSimVars(testSim, refSim)) {
// //String errorS = "TestVars - ";
// Variable[] testVars = testSim.getVariables();
// //for(int i =0;i<vars.length;i+= 1){
// //errorS+= vars[i].getName()+" ";
// //}
// //errorS+=" <<>> RefVars - ";
// Variable[] refVars = refSim.getVariables();
// //for(int i =0;i<vars.length;i+= 1){
// //errorS+= vars[i].getName()+" ";
// //}
// throw new RuntimeException(
// "VarNotMatch testLength="+(testVars != null?testVars.length+"":"null")+" refLength="+(refVars != null?refVars.length+"":"null"));
// }
CartesianMesh testMesh = testDataManager.getMesh();
MathDescription testMathDesc = testSimSymbolTable.getSimulation().getMathDescription();
// Variable[] refVars = refSim.getVariables();
MathDescription refMathDesc = refSimSymbolTable.getSimulation().getMathDescription();
CartesianMesh refMesh = refDataManager.getMesh();
int[] membraneIndexMapping = null;
// Get volumeSubdomains from mathDesc/mesh and store in lookupTable for testSimulation
int testNumVol = testMesh.getSizeX() * testMesh.getSizeY() * testMesh.getSizeZ();
CompartmentSubDomain[] testVolSubDomainLookup = new CompartmentSubDomain[testNumVol];
for (int i = 0; i < testNumVol; i++) {
int subVolumeIndex = testMesh.getSubVolumeFromVolumeIndex(i);
SubVolume subVolume = testMathDesc.getGeometry().getGeometrySpec().getSubVolume(subVolumeIndex);
CompartmentSubDomain compSubDomain = testMathDesc.getCompartmentSubDomain(subVolume.getName());
testVolSubDomainLookup[i] = compSubDomain;
}
// Get membraneSubdomains from mathDesc/mesh and store in lookupTable for testSimulation
int testNumMem = testMesh.getMembraneElements().length;
MembraneSubDomain[] testMemSubDomainLookup = new MembraneSubDomain[testNumMem];
for (int i = 0; i < testNumMem; i++) {
int insideVolIndex = testMesh.getMembraneElements()[i].getInsideVolumeIndex();
int outsideVolIndex = testMesh.getMembraneElements()[i].getOutsideVolumeIndex();
MembraneSubDomain memSubDomain = testMathDesc.getMembraneSubDomain(testVolSubDomainLookup[insideVolIndex], testVolSubDomainLookup[outsideVolIndex]);
testMemSubDomainLookup[i] = memSubDomain;
}
// Get volumeSubdomains from mathDesc/mesh and store in lookupTable for refSimulation
int refNumVol = refMesh.getSizeX() * refMesh.getSizeY() * refMesh.getSizeZ();
CompartmentSubDomain[] refVolSubDomainLookup = new CompartmentSubDomain[refNumVol];
for (int i = 0; i < refNumVol; i++) {
int subVolumeIndex = refMesh.getSubVolumeFromVolumeIndex(i);
SubVolume subVolume = refMathDesc.getGeometry().getGeometrySpec().getSubVolume(subVolumeIndex);
CompartmentSubDomain compSubDomain = refMathDesc.getCompartmentSubDomain(subVolume.getName());
refVolSubDomainLookup[i] = compSubDomain;
}
// Get membraneSubdomains from mathDesc/mesh and store in lookupTable for refSimulation
int refNumMem = refMesh.getMembraneElements().length;
MembraneSubDomain[] refMemSubDomainLookup = new MembraneSubDomain[refNumMem];
for (int i = 0; i < refNumMem; i++) {
int insideVolIndex = refMesh.getMembraneElements()[i].getInsideVolumeIndex();
int outsideVolIndex = refMesh.getMembraneElements()[i].getOutsideVolumeIndex();
MembraneSubDomain memSubDomain = refMathDesc.getMembraneSubDomain(refVolSubDomainLookup[insideVolIndex], refVolSubDomainLookup[outsideVolIndex]);
refMemSubDomainLookup[i] = memSubDomain;
}
SimulationComparisonSummary simComparisonSummary = new SimulationComparisonSummary();
String hashKey = new String("");
DataErrorSummary tempVar = null;
DataIdentifier[] refDataIDs = refDataManager.getDataIdentifiers();
// for each var, do the following :
for (int i = 0; i < varsToCompare.length; i++) {
DataIdentifier refDataID = null;
for (int j = 0; j < refDataIDs.length; j++) {
if (refDataIDs[j].getName().equals(varsToCompare[i])) {
refDataID = refDataIDs[j];
break;
}
}
//
// Find REFERENCE variable
//
Variable refVar = getSimVar(refSimSymbolTable, varsToCompare[i]);
if (refVar == null) {
// Should only happen if TEST sims were generated 'post-domains' and REFERENCE sims were generated 'pre-domains'
if (refDataID != null) {
throw new RuntimeException("Unexpected reference condition: '" + varsToCompare[i] + "' not found in symboltable but was found in dataidentifiers");
}
if (testDocument instanceof BioModel) {
// Only BioModels need to be checked
// Look in TEST for a speciescontext with matching species name
System.out.println("ReferenceVariable: using alternate method to find '" + varsToCompare[i] + "'");
BioModel refBioModel = (BioModel) refDocument;
BioModel testBioModel = (BioModel) testDocument;
SpeciesContext testSpeciesContext = testBioModel.getModel().getSpeciesContext(varsToCompare[i]);
if (testSpeciesContext != null) {
refVar = refSimSymbolTable.getVariable(testSpeciesContext.getSpecies().getCommonName());
for (int j = 0; j < refDataIDs.length; j++) {
if (refDataIDs[j].getName().equals(testSpeciesContext.getSpecies().getCommonName())) {
refDataID = refDataIDs[j];
break;
}
}
}
}
if (refVar == null || refDataID == null) {
Simulation refSim = refSimSymbolTable.getSimulation();
throw new RuntimeException("The variable " + varsToCompare[i] + " was not found in Simulation (" + refSim.getName() + " " + refSim.getVersion().getDate() + ")\n");
}
}
//
// Find TEST variable (assumed to have sims generated with a software version later than REFERENCE)
//
Variable testVar = getSimVar(testSimSymbolTable, varsToCompare[i]);
if (testVar == null) {
// Should only happen if TEST sims were generated 'post-domains' and REFERENCE sims were generated 'pre-domains'
System.out.println("TestVariable: using alternate method to find '" + varsToCompare[i] + "'");
BioModel testBioModel = (BioModel) testDocument;
SpeciesContext[] speciesContexts = testBioModel.getModel().getSpeciesContexts();
boolean bSkip = false;
for (int j = 0; j < speciesContexts.length; j++) {
if (speciesContexts[j].getSpecies().getCommonName().equals(varsToCompare[i])) {
testVar = testSimSymbolTable.getVariable(speciesContexts[j].getName());
if (testVar == null) {
throw new RuntimeException("Speciescontext name '" + speciesContexts[j].getName() + "' not found in testsimsymboltable");
}
// If we got here it means at least one matching speciescontext was found in TEST with
// a species name matching varsToCompare[i]. We can skip because the matching speciesconetext
// will be used to do a comparison at some point.
bSkip = true;
break;
}
}
if (bSkip) {
// these are tested already using full simcontext names
System.out.println("Skipping '" + varsToCompare[i] + "' as lookup in testSimSymbolTable");
continue;
}
Simulation refSim = refSimSymbolTable.getSimulation();
throw new RuntimeException("The variable " + varsToCompare[i] + " was not found in Simulation (" + refSim.getName() + " " + refSim.getVersion().getDate() + ")\n");
}
// for each time in timeArray. ('t' is used to index the testTimeArray, for interpolation purposes.)
int t = 0;
for (int j = 0; j < refTimeArray.length; j++) {
// get data block from varName, data from datablock
SimDataBlock refSimDataBlock = refDataManager.getSimDataBlock(refVar.getName(), refTimeArray[j]);
double[] refData = refSimDataBlock.getData();
double[] resampledTestData = null;
if (bTimesEqual) {
// If time arrays for both sims are equal, no need to resample/interpolate, just obtain the datablock from dataManager
SimDataBlock testSimDataBlock = testDataManager.getSimDataBlock(testVar.getName(), testTimeArray[j]);
resampledTestData = testSimDataBlock.getData();
} else {
// Time resampling (interpolation) needed.
while ((t < testTimeArray.length - 2) && (refTimeArray[j] >= testTimeArray[t + 1])) {
t++;
}
SimDataBlock testSimDataBlock_1 = testDataManager.getSimDataBlock(testVar.getName(), testTimeArray[t]);
double[] testData_1 = testSimDataBlock_1.getData();
SimDataBlock testSimDataBlock_2 = testDataManager.getSimDataBlock(testVar.getName(), testTimeArray[t + 1]);
double[] testData_2 = testSimDataBlock_2.getData();
resampledTestData = new double[testData_1.length];
//
for (int m = 0; m < testData_1.length; m++) {
resampledTestData[m] = testData_1[m] + (testData_2[m] - testData_1[m]) * (refTimeArray[j] - testTimeArray[t]) / (testTimeArray[t + 1] - testTimeArray[t]);
}
}
// Spatial resampling (interpolation) ...
double[] spaceResampledData = new double[refData.length];
if (!testMathDesc.getGeometry().getExtent().compareEqual(refMathDesc.getGeometry().getExtent()) || !testMathDesc.getGeometry().getOrigin().compareEqual(refMathDesc.getGeometry().getOrigin())) {
throw new RuntimeException("Different origins and/or extents for the 2 geometries. Cannot compare the 2 simulations");
}
if (testMesh.getSizeX() != refMesh.getSizeX() || testMesh.getSizeY() != refMesh.getSizeY() || testMesh.getSizeZ() != refMesh.getSizeZ()) {
if (testVar instanceof VolVariable) {
if (testMathDesc.getGeometry().getDimension() == 1 && refMathDesc.getGeometry().getDimension() == 1) {
spaceResampledData = resample1DSpatial(resampledTestData, testMesh, refMesh);
} else if (testMathDesc.getGeometry().getDimension() == 2 && refMathDesc.getGeometry().getDimension() == 2) {
spaceResampledData = resample2DSpatial(resampledTestData, testMesh, refMesh);
} else if (testMathDesc.getGeometry().getDimension() == 3 && refMathDesc.getGeometry().getDimension() == 3) {
spaceResampledData = resample3DSpatial(resampledTestData, testMesh, refMesh);
} else {
throw new RuntimeException("Comparison of 2 simulations with different geometry dimensions are not handled at this time!");
}
} else {
throw new RuntimeException("spatial resampling for variable type: " + testVar.getClass().getName() + " not supported");
}
} else {
// no space resampling required
if (testVar instanceof MemVariable) {
//
if (membraneIndexMapping == null) {
membraneIndexMapping = testMesh.getMembraneIndexMapping(refMesh);
}
spaceResampledData = new double[resampledTestData.length];
for (int k = 0; k < resampledTestData.length; k++) {
spaceResampledData[k] = resampledTestData[membraneIndexMapping[k]];
}
} else {
//
// no reordering needed for other variable types.
//
spaceResampledData = resampledTestData;
}
}
// for each point in data block ...
testDataInfoProvider.getPDEDataContext().setVariableName(testVar.getName());
for (int k = 0; k < refData.length; k++) {
if (!testDataInfoProvider.isDefined(k)) {
continue;
}
// Determine maxRef, minRef, maxAbsErr for variable
// SubDomain testSubDomain = null;
String sn = null;
VariableType refVarType = refDataID.getVariableType();
if (refVarType.equals(VariableType.VOLUME)) {
// testSubDomain = refVolSubDomainLookup[k];
sn = refVolSubDomainLookup[k].getName();
} else if (refVarType.equals(VariableType.MEMBRANE)) {
// testSubDomain = refMemSubDomainLookup[k];
sn = refMemSubDomainLookup[k].getName();
} else if (refVarType.equals(VariableType.MEMBRANE_REGION)) {
sn = "MRV_" + i;
} else if (refVarType.equals(VariableType.VOLUME_REGION)) {
sn = "VRV_" + i;
} else {
throw new RuntimeException("Var " + refVar.getName() + " not supported yet!");
}
// hashKey = refVar.getName()+":"+testSubDomain.getName();
hashKey = refVar.getName() + ":" + sn;
tempVar = tempVarHash.get(hashKey);
if (tempVar == null) {
tempVar = new DataErrorSummary(null);
tempVarHash.put(hashKey, tempVar);
}
tempVar.addDataValues(refData[k], spaceResampledData[k], refTimeArray[j], k, absErrorThreshold, relErrorThreshold);
}
// end for (k)
}
// end for (j)
}
// end for (i)
Enumeration<String> enumKeys = tempVarHash.keys();
while (enumKeys.hasMoreElements()) {
String key = enumKeys.nextElement();
DataErrorSummary tempVarSummary = tempVarHash.get(key);
simComparisonSummary.addVariableComparisonSummary(new VariableComparisonSummary(key, tempVarSummary.getMinRef(), tempVarSummary.getMaxRef(), tempVarSummary.getMaxAbsoluteError(), tempVarSummary.getMaxRelativeError(), tempVarSummary.getL2Norm(), tempVarSummary.getTimeAtMaxAbsoluteError(), tempVarSummary.getIndexAtMaxAbsoluteError(), tempVarSummary.getTimeAtMaxRelativeError(), tempVarSummary.getIndexAtMaxRelativeError()));
}
return simComparisonSummary;
}
use of cbit.vcell.math.VariableType in project vcell by virtualcell.
the class FiniteVolumeFileWriter method writeVariables.
/**
*# Variables : type name unit time_dependent_flag advection_flag solve_whole_mesh_flag solve_regions
*VARIABLE_BEGIN
*VOLUME_ODE rB uM
*VOLUME_PDE rf uM false false
*VOLUME_PDE r uM false false
*VOLUME_ODE rfB uM
*VARIABLE_END
* @throws MathException
* @throws ExpressionException
* @throws IOException
*/
private void writeVariables() throws MathException, ExpressionException, IOException {
SimulationSymbolTable simSymbolTable = simTask.getSimulationJob().getSimulationSymbolTable();
printWriter.println("# Variables : type name domain time_dependent_flag advection_flag grad_flag solve_whole_mesh_flag solve_regions");
printWriter.println(FVInputFileKeyword.VARIABLE_BEGIN);
MathDescription mathDesc = simSymbolTable.getSimulation().getMathDescription();
Variable[] vars = simSymbolTable.getVariables();
ArrayList<RandomVariable> rvList = new ArrayList<RandomVariable>();
for (int i = 0; i < vars.length; i++) {
String varName = vars[i].getName();
String domainName = vars[i].getDomain() == null ? null : vars[i].getDomain().getName();
if (vars[i] instanceof VolumeRandomVariable || vars[i] instanceof MembraneRandomVariable) {
rvList.add((RandomVariable) vars[i]);
} else if (vars[i] instanceof VolVariable) {
if (bChomboSolver && domainName == null) {
throw new MathException(simTask.getSimulation().getSolverTaskDescription().getSolverDescription().getDisplayLabel() + " requires that every variable is defined in a single domain");
}
VolVariable volVar = (VolVariable) vars[i];
if (mathDesc.isPDE(volVar)) {
boolean hasTimeVaryingDiffusionOrAdvection = simSymbolTable.hasTimeVaryingDiffusionOrAdvection(volVar);
final boolean hasVelocity = mathDesc.hasVelocity(volVar);
final boolean hasGradient = mathDesc.hasGradient(volVar);
if (mathDesc.isPdeSteady(volVar)) {
printWriter.print("VOLUME_PDE_STEADY ");
} else {
printWriter.print("VOLUME_PDE ");
}
printWriter.print(varName + " " + domainName + " " + hasTimeVaryingDiffusionOrAdvection + " " + hasVelocity + " " + hasGradient);
} else {
printWriter.print("VOLUME_ODE " + varName + " " + domainName);
}
if (domainName == null) {
Vector<SubDomain> listOfSubDomains = new Vector<SubDomain>();
int totalNumCompartments = 0;
Enumeration<SubDomain> subDomainEnum = mathDesc.getSubDomains();
while (subDomainEnum.hasMoreElements()) {
SubDomain subDomain = subDomainEnum.nextElement();
if (subDomain instanceof CompartmentSubDomain) {
CompartmentSubDomain compartmentSubDomain = (CompartmentSubDomain) subDomain;
totalNumCompartments++;
Equation varEquation = subDomain.getEquation(vars[i]);
if (varEquation != null) {
if (!(varEquation instanceof PdeEquation) || !((PdeEquation) varEquation).isDummy(simSymbolTable, compartmentSubDomain)) {
listOfSubDomains.add(compartmentSubDomain);
}
}
}
}
if ((totalNumCompartments == listOfSubDomains.size()) || (listOfSubDomains.size() == 0 && simTask.getSimulation().getSolverTaskDescription().getSolverDescription().equals(SolverDescription.SundialsPDE))) {
printWriter.print(" true");
} else {
printWriter.print(" false");
for (int j = 0; j < listOfSubDomains.size(); j++) {
CompartmentSubDomain compartmentSubDomain = (CompartmentSubDomain) listOfSubDomains.elementAt(j);
printWriter.print(" " + compartmentSubDomain.getName());
}
}
printWriter.println();
} else {
printWriter.println(" false " + domainName);
}
} else if (vars[i] instanceof VolumeParticleVariable) {
printWriter.println(FVInputFileKeyword.VOLUME_PARTICLE + " " + varName + " " + domainName);
} else if (vars[i] instanceof MembraneParticleVariable) {
printWriter.println(FVInputFileKeyword.MEMBRANE_PARTICLE + " " + varName + " " + domainName);
} else if (vars[i] instanceof VolumeRegionVariable) {
printWriter.println("VOLUME_REGION " + varName + " " + domainName);
} else if (vars[i] instanceof MemVariable) {
if (bChomboSolver && domainName == null) {
throw new MathException(simTask.getSimulation().getSolverTaskDescription().getSolverDescription().getDisplayLabel() + " requires that every variable is defined in a single domain");
}
MemVariable memVar = (MemVariable) vars[i];
if (mathDesc.isPDE(memVar)) {
printWriter.println("MEMBRANE_PDE " + varName + " " + domainName + " " + simSymbolTable.hasTimeVaryingDiffusionOrAdvection(memVar));
} else {
printWriter.println("MEMBRANE_ODE " + varName + " " + domainName);
}
} else if (vars[i] instanceof MembraneRegionVariable) {
printWriter.println("MEMBRANE_REGION " + varName + " " + domainName);
} else if (vars[i] instanceof FilamentVariable) {
throw new RuntimeException("Filament application not supported yet");
}
}
int numRandomVariables = rvList.size();
if (numRandomVariables > 0) {
ISize samplingSize = simTask.getSimulation().getMeshSpecification().getSamplingSize();
String[] varNameArr = new String[numRandomVariables];
VariableType[] varTypeArr = new VariableType[numRandomVariables];
double[][] dataArr = new double[numRandomVariables][];
for (int i = 0; i < numRandomVariables; i++) {
RandomVariable rv = rvList.get(i);
varNameArr[i] = rv.getName();
int numRandomNumbers = 0;
if (rv instanceof VolumeRandomVariable) {
printWriter.print("VOLUME_RANDOM");
varTypeArr[i] = VariableType.VOLUME;
numRandomNumbers = samplingSize.getXYZ();
} else if (rv instanceof MembraneRandomVariable) {
printWriter.print("MEMBRANE_RANDOM");
varTypeArr[i] = VariableType.MEMBRANE;
numRandomNumbers = resampledGeometry.getGeometrySurfaceDescription().getSurfaceCollection().getTotalPolygonCount();
} else {
throw new RuntimeException("Unknown RandomVariable type");
}
printWriter.println(" " + varNameArr[i]);
dataArr[i] = generateRandomNumbers(rv, numRandomNumbers);
}
File rvFile = new File(workingDirectory, simTask.getSimulationJobID() + RANDOM_VARIABLE_FILE_EXTENSION);
DataSet.writeNew(rvFile, varNameArr, varTypeArr, samplingSize, dataArr);
}
printWriter.println(FVInputFileKeyword.VARIABLE_END);
printWriter.println();
}
use of cbit.vcell.math.VariableType in project vcell by virtualcell.
the class XmlReader method getOutputFunction.
private AnnotatedFunction getOutputFunction(Element param) throws XmlParseException {
// get attributes
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String temp = param.getText();
Expression exp = unMangleExpression(temp);
String errStr = unMangle(param.getAttributeValue(XMLTags.ErrorStringTag));
VariableType funcType = VariableType.UNKNOWN;
String funcTypeAttr = param.getAttributeValue(XMLTags.FunctionTypeTag);
if (funcTypeAttr != null) {
String funcTypeStr = unMangle(funcTypeAttr);
funcType = VariableType.getVariableTypeFromVariableTypeName(funcTypeStr);
}
// -- create new AnnotatedFunction --
String domainStr = unMangle(param.getAttributeValue(XMLTags.DomainAttrTag));
Domain domain = null;
if (domainStr != null) {
domain = new Domain(domainStr);
}
AnnotatedFunction function = new AnnotatedFunction(name, exp, domain, errStr, funcType, FunctionCategory.OUTPUTFUNCTION);
return function;
}
use of cbit.vcell.math.VariableType in project vcell by virtualcell.
the class OutputFunctionsListTableModel method setValueAt.
/**
* Insert the method's description here.
* Creation date: (7/12/2004 2:01:23 PM)
* @param aValue java.lang.Object
* @param rowIndex int
* @param columnIndex int
*/
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
AnnotatedFunction outputFunction = getValueAt(rowIndex);
switch(columnIndex) {
case COLUMN_OUTPUTFN_EXPRESSION:
{
try {
Expression exp = new Expression((String) aValue);
if (exp.compareEqual(outputFunction.getExpression())) {
return;
}
exp.bindExpression(outputFunctionContext);
VariableType vt = outputFunctionContext.computeFunctionTypeWRTExpression(outputFunction, exp);
if (!vt.compareEqual(outputFunction.getFunctionType())) {
}
outputFunction.setExpression(exp);
fireTableRowsUpdated(rowIndex, rowIndex);
outputFunctionContext.firePropertyChange("outputFunctions", null, outputFunctionContext.getOutputFunctionsList());
} catch (ExpressionException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, "Expression error:\n" + e.getMessage());
} catch (InconsistentDomainException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, "Expression error:\n" + e.getMessage());
}
break;
}
}
}
use of cbit.vcell.math.VariableType 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();
}
Aggregations