use of cbit.vcell.math.PostProcessingBlock in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a MathDescription object.
* Creation date: (3/2/2001 10:57:25 AM)
* @return Element
* @param mathdes cbit.vcell.math.MathDescription
*/
Element getXML(MathDescription mathdes) throws XmlParseException {
Element math = new Element(XMLTags.MathDescriptionTag);
// Add attributes
math.setAttribute(XMLTags.NameAttrTag, mangle(mathdes.getName()));
// Add annotation
if (mathdes.getDescription() != null && mathdes.getDescription().length() > 0) {
Element annotationElem = new Element(XMLTags.AnnotationTag);
annotationElem.setText(mangle(mathdes.getDescription()));
math.addContent(annotationElem);
}
List<ParticleMolecularType> particleMolecularTypes = mathdes.getParticleMolecularTypes();
for (ParticleMolecularType particleMolecularType : particleMolecularTypes) {
math.addContent(getXML(particleMolecularType));
}
// Add Constant subelements
Enumeration<Variable> enum1 = mathdes.getVariables();
/*java.util.Iterator k;
try {
VariableHash varHash = new VariableHash();
while (enum1.hasMoreElements())
varHash.addVariable((Variable)enum1.nextElement());
Variable vars [] = varHash.getReorderedVariables();
k = new ArrayList(java.util.Arrays.asList(vars)).iterator();
} catch (cbit.vcell.mapping.MappingException e) {
e.printStackTrace();
return null;
}*/
while (enum1.hasMoreElements()) {
Variable var = enum1.nextElement();
Element element = null;
if (var instanceof Constant) {
element = getXML((Constant) var);
} else if (var instanceof FilamentRegionVariable) {
element = getXML((FilamentRegionVariable) var);
} else if (var instanceof FilamentVariable) {
element = getXML((FilamentVariable) var);
} else if (var instanceof PointVariable) {
element = getXML((PointVariable) var);
} else if (var instanceof Function) {
element = getXML((Function) var);
} else if (var instanceof RandomVariable) {
element = getXML((RandomVariable) var);
} else if (var instanceof InsideVariable) {
// *** for internal use! Ignore it ***
continue;
} else if (var instanceof MembraneRegionVariable) {
element = getXML((MembraneRegionVariable) var);
} else if (var instanceof MemVariable) {
element = getXML((MemVariable) var);
} else if (var instanceof OutsideVariable) {
// *** for internal use! Ignore it ****
continue;
} else if (var instanceof VolumeRegionVariable) {
element = getXML((VolumeRegionVariable) var);
} else if (var instanceof VolVariable) {
element = getXML((VolVariable) var);
} else if (var instanceof StochVolVariable) {
// added for stochastic volumn variables
element = getXML((StochVolVariable) var);
} else if (var instanceof ParticleVariable) {
element = getXML((ParticleVariable) var);
} else if (var instanceof ParticleObservable) {
element = getXML((ParticleObservable) var);
} else {
throw new XmlParseException("An unknown variable type " + var.getClass().getName() + " was found when parsing the mathdescription " + mathdes.getName() + "!");
}
transcribeComments(var, element);
math.addContent(element);
}
// this was moved to the simspec!
/* buffer.append("\n");
if (geometry != null){
buffer.append(geometry.getXML());
}
buffer.append("\n");*/
// Add subdomains
Enumeration<SubDomain> enum2 = mathdes.getSubDomains();
while (enum2.hasMoreElements()) {
SubDomain subDomain = enum2.nextElement();
math.addContent(getXML(subDomain));
}
// Add Metadata (Version) if there is!
if (mathdes.getVersion() != null) {
math.addContent(getXML(mathdes.getVersion(), mathdes));
}
Iterator<Event> iter = mathdes.getEvents();
while (iter.hasNext()) {
math.addContent(getXML(iter.next()));
}
PostProcessingBlock postProcessingBlock = mathdes.getPostProcessingBlock();
if (postProcessingBlock.getNumDataGenerators() > 0) {
math.addContent(getXML(postProcessingBlock));
}
return math;
}
use of cbit.vcell.math.PostProcessingBlock in project vcell by virtualcell.
the class FiniteVolumeFileWriter method writePostProcessingBlock.
private void writePostProcessingBlock() throws Exception {
// SolverException, ExpressionException and exceptions from roiDataGenerator.getROIDataGeneratorDescription()
PostProcessingBlock postProcessingBlock = simTask.getSimulation().getMathDescription().getPostProcessingBlock();
if (postProcessingBlock.getNumDataGenerators() == 0) {
// to make c++ code write default var statisitcs, without the token it won't write anything
printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_BEGIN);
printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_END);
printWriter.println();
return;
}
if (bChomboSolver && postProcessingBlock.getDataGeneratorList().size() > 0) {
throw new Exception("Data generators are not supported by " + simTask.getSimulation().getSolverTaskDescription().getSolverDescription().getDisplayLabel());
}
printWriter.println(" # Post Processing Block");
printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_BEGIN);
for (DataGenerator dataGenerator : postProcessingBlock.getDataGeneratorList()) {
String varName = dataGenerator.getName();
Domain domain = dataGenerator.getDomain();
String domainName = domain == null ? null : domain.getName();
if (dataGenerator instanceof ProjectionDataGenerator) {
ProjectionDataGenerator pdg = (ProjectionDataGenerator) dataGenerator;
Expression function = subsituteExpression(pdg.getFunction(), VariableDomain.VARIABLEDOMAIN_VOLUME);
printWriter.println(FVInputFileKeyword.PROJECTION_DATA_GENERATOR + " " + varName + " " + domainName + " " + pdg.getAxis() + " " + pdg.getOperation() + " " + function.infix() + ";");
} else if (dataGenerator instanceof ConvolutionDataGenerator) {
ConvolutionDataGenerator convolutionDataGenerator = (ConvolutionDataGenerator) dataGenerator;
ConvolutionDataGeneratorKernel kernel = convolutionDataGenerator.getKernel();
if (kernel instanceof GaussianConvolutionDataGeneratorKernel) {
GaussianConvolutionDataGeneratorKernel gck = (GaussianConvolutionDataGeneratorKernel) kernel;
Expression volFunction = subsituteExpression(convolutionDataGenerator.getVolFunction(), VariableDomain.VARIABLEDOMAIN_VOLUME);
Expression memFunction = subsituteExpression(convolutionDataGenerator.getMemFunction(), VariableDomain.VARIABLEDOMAIN_MEMBRANE);
Expression sigmaXY = subsituteExpression(gck.getSigmaXY_um(), VariableDomain.VARIABLEDOMAIN_VOLUME);
Expression sigmaZ = subsituteExpression(gck.getSigmaZ_um(), VariableDomain.VARIABLEDOMAIN_VOLUME);
String volFuncStr = volFunction.infix();
String memFuncStr = memFunction.infix();
printWriter.println(FVInputFileKeyword.GAUSSIAN_CONVOLUTION_DATA_GENERATOR + " " + varName + " " + domainName + " " + sigmaXY.infix() + " " + sigmaZ.infix() + " " + FVInputFileKeyword.GAUSSIAN_CONVOLUTION_VOL_FUNCTION + " " + volFuncStr + "; " + FVInputFileKeyword.GAUSSIAN_CONVOLUTION_MEM_FUNCTION + " " + memFuncStr + ";");
}
} else if (dataGenerator instanceof cbit.vcell.microscopy.ROIDataGenerator) {
/*
ROI_DATA_GENERATOR_BEGIN roidata
VolumePoints 20
2667 2676 2679 2771 2969 2877 3067 3277 3185 3283 3473 3580 3690 3687 3878 4086 3990 4182 4193 1077 (all points in one line)
SampleImage 9 0 1341426862190 vcField('sumROIData','roiSumDataVar',0.0,'Volume')
StoreEnabled false
SampleImageFile roiSumDataVar 0.0 C:\Users\abcde\VirtualMicroscopy\SimulationData\SimID_1341426862125_0_sumROIData_roiSumDataVar_0_0_Volume.fdat
DATA_PROCESSOR_END
*/
cbit.vcell.microscopy.ROIDataGenerator roiDataGenerator = (cbit.vcell.microscopy.ROIDataGenerator) dataGenerator;
printWriter.println(roiDataGenerator.getROIDataGeneratorDescription(workingDirectory, simTask.getSimulationJob()));
} else if (dataGenerator instanceof org.vcell.vmicro.workflow.data.ROIDataGenerator) {
/*
ROI_DATA_GENERATOR_BEGIN roidata
VolumePoints 20
2667 2676 2679 2771 2969 2877 3067 3277 3185 3283 3473 3580 3690 3687 3878 4086 3990 4182 4193 1077 (all points in one line)
SampleImage 9 0 1341426862190 vcField('sumROIData','roiSumDataVar',0.0,'Volume')
StoreEnabled false
SampleImageFile roiSumDataVar 0.0 C:\Users\abcde\VirtualMicroscopy\SimulationData\SimID_1341426862125_0_sumROIData_roiSumDataVar_0_0_Volume.fdat
DATA_PROCESSOR_END
*/
org.vcell.vmicro.workflow.data.ROIDataGenerator roiDataGenerator = (org.vcell.vmicro.workflow.data.ROIDataGenerator) dataGenerator;
printWriter.println(roiDataGenerator.getROIDataGeneratorDescription(workingDirectory, simTask.getSimulationJob()));
} else {
throw new SolverException(dataGenerator.getClass() + " : data generator not supported yet.");
}
}
printWriter.println(FVInputFileKeyword.POST_PROCESSING_BLOCK_END);
printWriter.println();
}
Aggregations