Search in sources :

Example 1 with DataGenerator

use of cbit.vcell.math.DataGenerator in project vcell by virtualcell.

the class OutputFunctionContext method getEntries.

// public abstract void validateNamingConflicts(String symbolDescription, Class<?> newSymbolClass, String newSymbolName, PropertyChangeEvent e)  throws PropertyVetoException ;
public void getEntries(Map<String, SymbolTableEntry> entryMap) {
    // add all valid entries (variables) from mathdescription
    MathDescription mathDescription = simulationOwner.getMathDescription();
    if (mathDescription != null) {
        Enumeration<Variable> varEnum = mathDescription.getVariables();
        while (varEnum.hasMoreElements()) {
            Variable var = varEnum.nextElement();
            if (!(var instanceof PseudoConstant) && !(var instanceof Constant)) {
                entryMap.put(var.getName(), var);
            }
        }
        for (DataGenerator dataGenerator : mathDescription.getPostProcessingBlock().getDataGeneratorList()) {
            entryMap.put(dataGenerator.getName(), dataGenerator);
        }
    }
    entryMap.put(ReservedVariable.TIME.getName(), ReservedVariable.TIME);
    int dimension = mathDescription.getGeometry().getDimension();
    if (dimension > 0) {
        entryMap.put(ReservedVariable.X.getName(), ReservedVariable.X);
        if (dimension > 1) {
            entryMap.put(ReservedVariable.Y.getName(), ReservedVariable.Y);
            if (dimension > 2) {
                entryMap.put(ReservedVariable.Z.getName(), ReservedVariable.Z);
            }
        }
    }
    // then add list of output functions.
    for (SymbolTableEntry ste : outputFunctionsList) {
        entryMap.put(ste.getName(), ste);
    }
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ReservedVariable(cbit.vcell.math.ReservedVariable) InsideVariable(cbit.vcell.math.InsideVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) Variable(cbit.vcell.math.Variable) MathDescription(cbit.vcell.math.MathDescription) Constant(cbit.vcell.math.Constant) PseudoConstant(cbit.vcell.math.PseudoConstant) PseudoConstant(cbit.vcell.math.PseudoConstant) DataGenerator(cbit.vcell.math.DataGenerator)

Example 2 with DataGenerator

use of cbit.vcell.math.DataGenerator in project vcell by virtualcell.

the class Xmlproducer method getXML.

private Element getXML(PostProcessingBlock postProcessingBlock) {
    Element element = new Element(XMLTags.PostProcessingBlock);
    for (DataGenerator dataGenerator : postProcessingBlock.getDataGeneratorList()) {
        if (dataGenerator instanceof ExplicitDataGenerator) {
            Element e = new Element(XMLTags.ExplicitDataGenerator);
            e.setAttribute(XMLTags.NameAttrTag, mangle(dataGenerator.getName()));
            if (dataGenerator.getDomain() != null) {
                e.setAttribute(XMLTags.DomainAttrTag, mangle(dataGenerator.getDomain().getName()));
            }
            e.addContent(mangleExpression(dataGenerator.getExpression()));
            element.addContent(e);
        } else if (dataGenerator instanceof ProjectionDataGenerator) {
            element.addContent(getXML((ProjectionDataGenerator) dataGenerator));
        } else if (dataGenerator instanceof ConvolutionDataGenerator) {
            element.addContent(getXML((ConvolutionDataGenerator) dataGenerator));
        }
    }
    return element;
}
Also used : Element(org.jdom.Element) DataGenerator(cbit.vcell.math.DataGenerator) ExplicitDataGenerator(cbit.vcell.math.ExplicitDataGenerator) ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) ProjectionDataGenerator(cbit.vcell.math.ProjectionDataGenerator) ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) ProjectionDataGenerator(cbit.vcell.math.ProjectionDataGenerator) ExplicitDataGenerator(cbit.vcell.math.ExplicitDataGenerator)

Example 3 with DataGenerator

use of cbit.vcell.math.DataGenerator 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();
}
Also used : ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) ImageException(cbit.image.ImageException) FileNotFoundException(java.io.FileNotFoundException) SolverException(cbit.vcell.solver.SolverException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) ConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel) PostProcessingBlock(cbit.vcell.math.PostProcessingBlock) Expression(cbit.vcell.parser.Expression) ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) DataGenerator(cbit.vcell.math.DataGenerator) ProjectionDataGenerator(cbit.vcell.math.ProjectionDataGenerator) ProjectionDataGenerator(cbit.vcell.math.ProjectionDataGenerator) GaussianConvolutionDataGeneratorKernel(cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel) SolverException(cbit.vcell.solver.SolverException) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) SubDomain(cbit.vcell.math.SubDomain) Domain(cbit.vcell.math.Variable.Domain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain)

Example 4 with DataGenerator

use of cbit.vcell.math.DataGenerator in project vcell by virtualcell.

the class OutputFunctionContext method getEntry.

public SymbolTableEntry getEntry(java.lang.String identifierString) {
    // 
    // use MathDescription as the primary SymbolTable, just replace the Constants with the overrides.
    // 
    SymbolTableEntry ste = null;
    MathDescription mathDescription = simulationOwner.getMathDescription();
    if (mathDescription != null) {
        ste = mathDescription.getEntry(identifierString);
        if (ste != null && !(ste instanceof PseudoConstant) && !(ste instanceof Constant)) {
            return ste;
        }
        ste = mathDescription.getPostProcessingBlock().getDataGenerator(identifierString);
        if (ste instanceof DataGenerator) {
            return ste;
        }
    }
    // see if it is an output function.
    ste = getOutputFunction(identifierString);
    return ste;
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) MathDescription(cbit.vcell.math.MathDescription) Constant(cbit.vcell.math.Constant) PseudoConstant(cbit.vcell.math.PseudoConstant) PseudoConstant(cbit.vcell.math.PseudoConstant) DataGenerator(cbit.vcell.math.DataGenerator)

Aggregations

DataGenerator (cbit.vcell.math.DataGenerator)4 Constant (cbit.vcell.math.Constant)2 ConvolutionDataGenerator (cbit.vcell.math.ConvolutionDataGenerator)2 MathDescription (cbit.vcell.math.MathDescription)2 ProjectionDataGenerator (cbit.vcell.math.ProjectionDataGenerator)2 PseudoConstant (cbit.vcell.math.PseudoConstant)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 ImageException (cbit.image.ImageException)1 GeometryException (cbit.vcell.geometry.GeometryException)1 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)1 ConvolutionDataGeneratorKernel (cbit.vcell.math.ConvolutionDataGenerator.ConvolutionDataGeneratorKernel)1 GaussianConvolutionDataGeneratorKernel (cbit.vcell.math.ConvolutionDataGenerator.GaussianConvolutionDataGeneratorKernel)1 ExplicitDataGenerator (cbit.vcell.math.ExplicitDataGenerator)1 InsideVariable (cbit.vcell.math.InsideVariable)1 MathException (cbit.vcell.math.MathException)1 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)1 OutsideVariable (cbit.vcell.math.OutsideVariable)1 PostProcessingBlock (cbit.vcell.math.PostProcessingBlock)1 ReservedVariable (cbit.vcell.math.ReservedVariable)1 SubDomain (cbit.vcell.math.SubDomain)1