use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.
the class MovingBoundaryFileWriter method getSpecies.
// TODO: flatten here
private Element getSpecies(Equation eq) throws ExpressionException, MathException {
Element e = new Element(MBTags.species);
e.setAttribute(MBTags.name, eq.getVariable().getName());
VariableDomain varDomain = null;
if (eq.getVariable() instanceof VolVariable) {
e.setAttribute(MBXmlTags.type.name(), MBXmlTags.volume.name());
varDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
} else if (eq.getVariable() instanceof PointVariable) {
e.setAttribute(MBXmlTags.type.name(), MBXmlTags.point.name());
varDomain = VariableDomain.VARIABLEDOMAIN_POINT;
}
Element e1 = null;
e1 = new Element(MBTags.initial);
Expression ex = eq.getInitialExpression();
setExpression(e1, ex, varDomain);
e.addContent(e1);
e1 = new Element(MBTags.source);
ex = eq.getRateExpression();
setExpression(e1, ex, varDomain);
e.addContent(e1);
if (eq instanceof PdeEquation) {
e1 = new Element(MBTags.diffusion);
ex = ((PdeEquation) eq).getDiffusionExpression();
setExpression(e1, ex, varDomain);
e.addContent(e1);
ex = ((PdeEquation) eq).getVelocityX();
if (ex != null) {
e1 = new Element(MBTags.advectVelocityFunctionX);
setExpression(e1, ex, varDomain);
e.addContent(e1);
}
ex = ((PdeEquation) eq).getVelocityY();
if (ex != null) {
e1 = new Element(MBTags.advectVelocityFunctionY);
setExpression(e1, ex, varDomain);
e.addContent(e1);
}
}
return e;
}
use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.
the class DataSetControllerImpl method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(MovingBoundarySimFiles movingBoundaryFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
try {
DataIdentifier[] dataIdentifiers = getDataIdentifiers(outputContext, vcdataID);
if (dataIdentifiers == null) {
return null;
}
ArrayList<VtuVarInfo> vtuVarInfos = new ArrayList<VtuVarInfo>();
for (DataIdentifier di : dataIdentifiers) {
String name = di.getName();
String displayName = di.getDisplayName();
if (di.getDomain() != null) {
System.err.println("DataSetControllerImpl.getVtuVarInfos(movingboundary): need to support proper domain names now");
}
String domainName = MovingBoundaryReader.getFakeInsideDomainName();
VariableDomain variableDomain = null;
VariableType variableType = di.getVariableType();
if (variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
} else if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
} else if (variableType.equals(VariableType.POINT_VARIABLE)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_POINT;
} else if (variableType.equals(VariableType.CONTOUR) || variableType.equals(VariableType.CONTOUR_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_CONTOUR;
} else if (variableType.equals(VariableType.NONSPATIAL)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
} else if (variableType.equals(VariableType.POSTPROCESSING)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_POSTPROCESSING;
} else {
System.err.print("skipping var " + di + ", unsupported data type");
}
String functionExpression = null;
boolean bMeshVariable = false;
if (name.toUpperCase().contains("SIZE")) {
System.err.println("Skipping Moving Boundary variable '" + name + "' because it is a size ... change later");
continue;
}
vtuVarInfos.add(new VtuVarInfo(name, displayName, domainName, variableDomain, functionExpression, DataType.CellData, bMeshVariable));
}
return vtuVarInfos.toArray(new VtuVarInfo[0]);
} catch (Exception e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("failed to retrieve VTK variable list: " + e.getMessage(), e);
}
}
use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.
the class ChomboVtkFileWriter method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(ChomboFiles chomboFiles, OutputContext outputContext, VCData vcData) throws DataAccessException, IOException {
//
// read the time=0 chombo dataset into memory to get the var names (probably a more efficient way of doing this).
//
ChomboDataset chomboDataset;
try {
int timeIndex = 0;
chomboDataset = ChomboFileReader.readDataset(chomboFiles, chomboFiles.getTimeIndices().get(timeIndex));
} catch (Exception e) {
throw new DataAccessException("failed to read chombo dataset: " + e.getMessage(), e);
}
DataIdentifier[] dataIdentifiers = vcData.getVarAndFunctionDataIdentifiers(outputContext);
for (DataIdentifier di : dataIdentifiers) {
System.out.println(((di.getDomain() != null) ? di.getDomain().getName() : "none") + "::" + di.getName() + "-" + di.getVariableType());
}
//
// for each ChomboDomain get list of built-in (mesh) variables, component (regular) volume variables, and Membrane Variables (still tied to the volume).
//
ArrayList<VtuVarInfo> varInfos = new ArrayList<VtuVarInfo>();
for (ChomboCombinedVolumeMembraneDomain chomboCombinedVolumeMembraneDomain : chomboDataset.getCombinedVolumeMembraneDomains()) {
ChomboMeshData chomboMeshData = chomboCombinedVolumeMembraneDomain.getChomboMeshData();
//
// process Volume variables for this combined domain (chombo stores membrane data with volume)
//
{
String volumeDomainName = chomboCombinedVolumeMembraneDomain.getVolumeDomainName();
VariableDomain volVariableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
for (String builtinVarName : chomboMeshData.getVolumeBuiltinNames()) {
String varName = builtinVarName;
String displayName = "(" + volumeDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = true;
varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (String componentVarName : chomboMeshData.getVisibleVolumeDataNames()) {
String varName = componentVarName;
String displayName = "(" + volumeDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = false;
varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (DataIdentifier dataID : dataIdentifiers) {
if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_VOLUME && (dataID.getDomain() == null || dataID.getDomain().getName().equals(volumeDomainName))) {
String displayName = "(" + volumeDomainName + ") " + dataID.getDisplayName();
String expressionString = null;
AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
if (f != null) {
expressionString = f.getExpression().infix();
}
boolean bMeshVar = false;
varInfos.add(new VtuVarInfo(dataID.getName(), displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVar));
}
}
}
//
// process membrane variables for this combined domain (chombo stores membrane data with volume)
//
{
String memDomainName = chomboCombinedVolumeMembraneDomain.getMembraneDomainName();
VariableDomain memVariableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
for (ChomboMembraneVarData membraneVarData : chomboMeshData.getMembraneVarData()) {
String varName = membraneVarData.getName();
String displayName = "(" + membraneVarData.getDomainName() + ") " + varName;
String expressionString = null;
boolean bMeshVariable = false;
varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (String builtinVarName : chomboMeshData.getMembraneBuiltinNames()) {
String varName = builtinVarName;
String displayName = "(" + memDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = true;
varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (DataIdentifier dataID : dataIdentifiers) {
if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_MEMBRANE && (dataID.getDomain() == null || dataID.getDomain().getName().equals(memDomainName))) {
String displayName = "(" + memDomainName + ") " + dataID.getDisplayName();
String expressionString = null;
AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
if (f != null) {
expressionString = f.getExpression().infix();
}
boolean bMeshVar = false;
varInfos.add(new VtuVarInfo(dataID.getName(), displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVar));
}
}
}
}
return varInfos.toArray(new VtuVarInfo[0]);
}
use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.
the class CartesianMeshVtkFileWriter method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(VCellSimFiles vcellFiles, OutputContext outputContext, VCData vcData) throws IOException, DataAccessException, MathException {
CartesianMeshFileReader reader = new CartesianMeshFileReader();
CartesianMesh mesh = reader.readFromFiles(vcellFiles);
List<String> volumeDomainNames = mesh.getVolumeDomainNames();
List<String> membraneDomainNames = mesh.getMembraneDomainNames();
ArrayList<String> allDomains = new ArrayList<String>();
allDomains.addAll(volumeDomainNames);
allDomains.addAll(membraneDomainNames);
DataIdentifier[] dataIdentifiers = vcData.getVarAndFunctionDataIdentifiers(outputContext);
AnnotatedFunction[] annotationFunctions = vcData.getFunctions(outputContext);
ArrayList<VtuVarInfo> varInfos = new ArrayList<VtuVarInfo>();
for (String domainName : allDomains) {
VariableDomain varDomain = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
if (volumeDomainNames.contains(domainName)) {
varDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
} else if (membraneDomainNames.contains(domainName)) {
varDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
}
for (DataIdentifier dataID : dataIdentifiers) {
if (dataID.getDomain() == null || dataID.getDomain().getName().equals(domainName)) {
boolean bMeshVar = isMeshVar(dataID);
String expressionString = null;
if (dataID.isFunction()) {
for (AnnotatedFunction f : annotationFunctions) {
if (f.getName().equals(dataID.getName())) {
expressionString = f.getExpression().infix();
}
}
}
varInfos.add(new VtuVarInfo(dataID.getName(), "(" + domainName + ") " + dataID.getDisplayName(), domainName, varDomain, expressionString, DataType.CellData, bMeshVar));
}
}
varInfos.add(new VtuVarInfo(GLOBAL_INDEX_VAR, "(" + domainName + ") " + GLOBAL_INDEX_VAR, domainName, varDomain, null, DataType.CellData, true));
varInfos.add(new VtuVarInfo(REGION_ID_VAR, "(" + domainName + ") " + REGION_ID_VAR, domainName, varDomain, null, DataType.CellData, true));
}
return varInfos.toArray(new VtuVarInfo[0]);
}
Aggregations