use of cbit.vcell.geometry.SubVolume in project vcell by virtualcell.
the class XmlReader method getGeometrySurfaceDescription.
private GeometrySurfaceDescription getGeometrySurfaceDescription(Element param, Geometry geom) throws XmlParseException {
GeometrySurfaceDescription gsd = geom.getGeometrySurfaceDescription();
String cutoffStr = param.getAttributeValue(XMLTags.CutoffFrequencyAttrTag);
String xDim = param.getAttributeValue(XMLTags.NumSamplesXAttrTag);
String yDim = param.getAttributeValue(XMLTags.NumSamplesYAttrTag);
String zDim = param.getAttributeValue(XMLTags.NumSamplesZAttrTag);
if (cutoffStr == null || xDim == null || yDim == null || zDim == null) {
throw new XmlParseException("Attributes for element Surface Description not properly set, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
try {
ISize isize = new ISize(Integer.parseInt(xDim), Integer.parseInt(yDim), Integer.parseInt(zDim));
gsd.setVolumeSampleSize(isize);
gsd.setFilterCutoffFrequency(new Double(cutoffStr));
// these lists are allowed to be empty.
ArrayList<Element> memRegions = new ArrayList<Element>(param.getChildren(XMLTags.MembraneRegionTag, vcNamespace));
ArrayList<Element> volRegions = new ArrayList<Element>(param.getChildren(XMLTags.VolumeRegionTag, vcNamespace));
ArrayList<GeometricRegion> regions = new ArrayList<GeometricRegion>();
GeometryUnitSystem geometryUnitSystem = geom.getUnitSystem();
for (Element temp : volRegions) {
String regionID = temp.getAttributeValue(XMLTags.RegionIDAttrTag);
String name = temp.getAttributeValue(XMLTags.NameAttrTag);
String subvolumeRef = temp.getAttributeValue(XMLTags.SubVolumeAttrTag);
if (regionID == null || name == null || subvolumeRef == null) {
throw new XmlParseException("Attributes for element Volume Region not properly set, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
SubVolume subvolume = geom.getGeometrySpec().getSubVolume(subvolumeRef);
if (subvolume == null) {
throw new XmlParseException("The subvolume " + subvolumeRef + " could not be resolved.");
}
double size = -1;
VCUnitDefinition unit = null;
String sizeStr = temp.getAttributeValue(XMLTags.SizeAttrTag);
if (sizeStr != null) {
size = Double.parseDouble(sizeStr);
String unitSymbol = temp.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
if (unitSymbol != null) {
unit = geometryUnitSystem.getInstance(unitSymbol);
}
}
VolumeGeometricRegion vgr = new VolumeGeometricRegion(name, size, unit, subvolume, Integer.parseInt(regionID));
regions.add(vgr);
}
for (Element temp : memRegions) {
String volRegion_1 = temp.getAttributeValue(XMLTags.VolumeRegion_1AttrTag);
String volRegion_2 = temp.getAttributeValue(XMLTags.VolumeRegion_2AttrTag);
String name = temp.getAttributeValue(XMLTags.NameAttrTag);
if (volRegion_1 == null || volRegion_2 == null || name == null) {
throw new XmlParseException("Attributes for element Membrane Region not properly set, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
VolumeGeometricRegion region1 = getAdjacentVolumeRegion(regions, volRegion_1);
VolumeGeometricRegion region2 = getAdjacentVolumeRegion(regions, volRegion_2);
if (region1 == null || region2 == null) {
throw new XmlParseException("Element Membrane Region refernces invalid volume regions, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
double size = -1;
VCUnitDefinition unit = null;
String sizeStr = temp.getAttributeValue(XMLTags.SizeAttrTag);
if (sizeStr != null) {
size = Double.parseDouble(sizeStr);
String unitSymbol = temp.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
if (unitSymbol != null) {
unit = geometryUnitSystem.getInstance(unitSymbol);
}
}
SurfaceGeometricRegion rsl = new SurfaceGeometricRegion(name, size, unit);
rsl.addAdjacentGeometricRegion(region1);
region1.addAdjacentGeometricRegion(rsl);
rsl.addAdjacentGeometricRegion(region2);
region2.addAdjacentGeometricRegion(rsl);
regions.add(rsl);
}
if (regions.size() > 0) {
gsd.setGeometricRegions((GeometricRegion[]) regions.toArray(new GeometricRegion[regions.size()]));
}
} catch (Exception e) {
System.err.println("Unable to read geometry surface description from XML, for geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
e.printStackTrace();
}
return gsd;
}
use of cbit.vcell.geometry.SubVolume in project vcell by virtualcell.
the class XmlReader method getMembraneSubDomain.
/**
* This method returns a MembraneSubDomain object from a XML Element.
* Creation date: (5/18/2001 4:23:30 PM)
* @return cbit.vcell.math.MembraneSubDomain
* @param param org.jdom.Element
* @exception cbit.vcell.xml.XmlParseException The exception description.
*/
@SuppressWarnings("unchecked")
private MembraneSubDomain getMembraneSubDomain(Element param, MathDescription mathDesc) throws XmlParseException {
// no need to do anything with the 'Name' attribute : constructor of MembraneSubDomain creates name from inside/outside compartmentSubDomains.
// String msdName = unMangle( param.getAttributeValue(XMLTags.NameAttrTag) );
// if ( msdName != null) {
// }
// get compartmentSubDomain references
// inside
String name = unMangle(param.getAttributeValue(XMLTags.InsideCompartmentTag));
CompartmentSubDomain insideRef = (CompartmentSubDomain) mathDesc.getCompartmentSubDomain(name);
if (insideRef == null) {
throw new XmlParseException("The reference to the inside CompartmentSubDomain " + name + ", could not be resolved!");
}
// outside
name = unMangle(param.getAttributeValue(XMLTags.OutsideCompartmentTag));
CompartmentSubDomain outsideRef = (CompartmentSubDomain) mathDesc.getCompartmentSubDomain(name);
if (outsideRef == null) {
throw new XmlParseException("The reference to the outside CompartmentSubDomain " + name + ", could not be resolved!");
}
// *** create new Membrane SubDomain ***
SubVolume insideSubVolume = mathDesc.getGeometry().getGeometrySpec().getSubVolume(insideRef.getName());
SubVolume outsideSubVolume = mathDesc.getGeometry().getGeometrySpec().getSubVolume(outsideRef.getName());
SurfaceClass surfaceClass = mathDesc.getGeometry().getGeometrySurfaceDescription().getSurfaceClass(insideSubVolume, outsideSubVolume);
MembraneSubDomain subDomain = new MembraneSubDomain(insideRef, outsideRef, surfaceClass.getName());
transcribeComments(param, subDomain);
// Process BoundaryConditions
Iterator<Element> iterator = param.getChildren(XMLTags.BoundaryTypeTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element tempelement = (Element) iterator.next();
// create BoundaryConditionType
String temp = tempelement.getAttributeValue(XMLTags.BoundaryTypeAttrTag);
BoundaryConditionType bType = new BoundaryConditionType(temp);
// Process Xm
if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueXm)) {
subDomain.setBoundaryConditionXm(bType);
} else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueXp)) {
// Process Xp
subDomain.setBoundaryConditionXp(bType);
} else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueYm)) {
// Process Ym
subDomain.setBoundaryConditionYm(bType);
} else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueYp)) {
// Process Yp
subDomain.setBoundaryConditionYp(bType);
} else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueZm)) {
// Process Zm
subDomain.setBoundaryConditionZm(bType);
} else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueZp)) {
// Process Zp
subDomain.setBoundaryConditionZp(bType);
} else {
// If not indentified throw an exception!!
throw new XmlParseException("Unknown BoundaryConditionType: " + tempelement.getAttributeValue(XMLTags.BoundaryAttrTag));
}
}
// Add OdeEquations
iterator = param.getChildren(XMLTags.OdeEquationTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element tempElement = (Element) iterator.next();
OdeEquation odeEquation = getOdeEquation(tempElement, mathDesc);
try {
subDomain.addEquation(odeEquation);
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("A MathException was fired when adding an OdeEquation to a MembraneSubDomain!", e);
}
}
// process PdeEquations
iterator = param.getChildren(XMLTags.PdeEquationTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element tempElement = (Element) iterator.next();
try {
subDomain.addEquation(getPdeEquation(tempElement, mathDesc));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("A MathException was fired when adding an PdeEquation to the MembraneSubDomain " + name, e);
}
}
// Add JumpConditions
iterator = param.getChildren(XMLTags.JumpConditionTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element tempElement = (Element) iterator.next();
try {
subDomain.addJumpCondition(getJumpCondition(tempElement, mathDesc));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("A MathException was fired when adding a JumpCondition to a MembraneSubDomain!", e);
}
}
// Add the FastSystem (if any)
Element tempElement = param.getChild(XMLTags.FastSystemTag, vcNamespace);
if (tempElement != null) {
subDomain.setFastSystem(getFastSystem(tempElement, mathDesc));
}
// add MembraneRegionEquation
iterator = param.getChildren(XMLTags.MembraneRegionEquationTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempElement = (Element) iterator.next();
try {
subDomain.addEquation(getMembraneRegionEquation(tempElement, mathDesc));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("A MathException was fired when adding a MembraneRegionEquation to a MEmbraneSubDomain!", e);
}
}
iterator = param.getChildren(XMLTags.ParticleJumpProcessTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element tempelement = (Element) iterator.next();
try {
subDomain.addParticleJumpProcess(getParticleJumpProcess(tempelement, mathDesc));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("A MathException was fired when adding a jump process to the MembraneSubDomain " + name, e);
}
}
iterator = param.getChildren(XMLTags.ParticlePropertiesTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element tempelement = (Element) iterator.next();
try {
subDomain.addParticleProperties(getParticleProperties(tempelement, mathDesc));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("A MathException was fired when adding a jump process to the MembraneSubDomain " + name, e);
}
}
// process ComputeNormal "equations"
iterator = param.getChildren(XMLTags.ComputeNormalTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element tempelement = (Element) iterator.next();
try {
subDomain.addEquation(getComputeNormal(tempelement, mathDesc));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("A MathException was fired when adding an ComputeNormal 'equation' to the MembraneSubDomain " + name, e);
}
}
Element velElem = param.getChild(XMLTags.VelocityTag, vcNamespace);
setMembraneSubdomainVelocity(velElem, XMLTags.XAttrTag, subDomain::setVelocityX);
setMembraneSubdomainVelocity(velElem, XMLTags.YAttrTag, subDomain::setVelocityY);
return subDomain;
}
use of cbit.vcell.geometry.SubVolume 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.geometry.SubVolume in project vcell by virtualcell.
the class XmlReader method getSubVolume.
/**
* This method returns a SubVolume element type from a XML representation.
* Creation date: (4/26/2001 4:14:01 PM)
* @return SubVolume
* @param param org.jdom.Element
*/
private SubVolume getSubVolume(Element param) throws XmlParseException {
String typeString = param.getAttributeValue(XMLTags.TypeAttrTag);
SubVolume newsubvolume = null;
if (typeString != null) {
// process the subvolume upon the 'type'
if (typeString.equalsIgnoreCase(XMLTags.CompartmentBasedTypeTag)) {
// Process compartmental based
newsubvolume = getCompartmentSubVolume(param);
} else if (typeString.equalsIgnoreCase(XMLTags.AnalyticBasedTypeTag)) {
// Process Analytic based
newsubvolume = getAnalyticSubVolume(param);
} else if (typeString.equalsIgnoreCase(XMLTags.ImageBasedTypeTag)) {
// Process Image based
newsubvolume = getImageSubVolume(param);
} else if (typeString.equalsIgnoreCase(XMLTags.CSGBasedTypeTag)) {
// Process Constructed Solid Geometry based
newsubvolume = getCSGObject(param, null);
} else {
// Throw an exception
throw new XmlParseException("Parse Error! Unknown Subvolume type:" + typeString);
}
} else {
System.out.println("Invalid VCML format! Error in <Subvolume name=\"" + param.getAttributeValue(XMLTags.NameAttrTag) + "\"/>");
System.out.println("Valid format is:");
System.out.println("<SubVolume Name=\"??\" Handle=\"?\" ImagePixelValue=\"?\"/>");
throw new XmlParseException("Invalid VCML syntax in <Subvolume name=\"" + param.getAttributeValue(XMLTags.NameAttrTag) + "\"/>");
}
return newsubvolume;
}
use of cbit.vcell.geometry.SubVolume in project vcell by virtualcell.
the class XmlReader method getSurfaceClass.
private SurfaceClass getSurfaceClass(Element param, Geometry geom) throws XmlParseException {
Set<SubVolume> surfaceClassSubVolumeSet = new HashSet<SubVolume>();
KeyValue surfaceClassKey = null;
String surfaceClassName = null;
surfaceClassName = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String surfaceClassKeyStr = param.getAttributeValue(XMLTags.KeyValueAttrTag);
surfaceClassKey = (surfaceClassKeyStr == null ? null : new KeyValue(surfaceClassKeyStr));
String subVol1Ref = param.getAttributeValue(XMLTags.SubVolume1RefAttrTag);
String subVol2Ref = param.getAttributeValue(XMLTags.SubVolume2RefAttrTag);
if (subVol1Ref != null) {
SubVolume subVolume = geom.getGeometrySpec().getSubVolume(subVol1Ref);
if (subVolume == null) {
throw new XmlParseException("SurfaceClass missing subvolume '" + subVol1Ref + "'");
}
surfaceClassSubVolumeSet.add(subVolume);
}
if (subVol2Ref != null) {
SubVolume subVolume = geom.getGeometrySpec().getSubVolume(subVol2Ref);
if (subVolume == null) {
throw new XmlParseException("SurfaceClass missing subvolume '" + subVol2Ref + "'");
}
surfaceClassSubVolumeSet.add(subVolume);
}
return new SurfaceClass(surfaceClassSubVolumeSet, surfaceClassKey, surfaceClassName);
}
Aggregations