use of cbit.vcell.solver.SolverException in project vcell by virtualcell.
the class MovingBoundarySolver method initialize.
/**
* This method was created by a SmartGuide.
*/
protected void initialize() throws SolverException {
writeFunctionsFile();
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INIT));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
try (PrintWriter pw = new PrintWriter(inputFilename)) {
MovingBoundaryFileWriter mbfw = new MovingBoundaryFileWriter(pw, simTask, resampledGeometry, bMessaging, getBaseName());
mbfw.write();
} catch (Exception e) {
throw new SolverException("Can't open input file " + inputFilename, e);
}
setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
}
use of cbit.vcell.solver.SolverException in project vcell by virtualcell.
the class MovingBoundarySolver method getResampledGeometry.
/*
@Override
protected String[] getMathExecutableCommand() {
String exeSuffix = System.getProperty(PropertyLoader.exesuffixProperty); // ".exe";
String baseName = "MovingBoundary" ;
File exeFile = new File(getSaveDirectory(), baseName + exeSuffix);
return new String[] { exeFile.getAbsolutePath() };
}
*/
public Geometry getResampledGeometry() throws SolverException {
if (resampledGeometry == null) {
// clone and resample geometry
try {
resampledGeometry = (Geometry) BeanUtils.cloneSerializable(simTask.getSimulation().getMathDescription().getGeometry());
GeometrySurfaceDescription geoSurfaceDesc = resampledGeometry.getGeometrySurfaceDescription();
ISize newSize = simTask.getSimulation().getMeshSpecification().getSamplingSize();
geoSurfaceDesc.setVolumeSampleSize(newSize);
geoSurfaceDesc.updateAll();
} catch (Exception e) {
e.printStackTrace();
throw new SolverException(e.getMessage());
}
}
return resampledGeometry;
}
use of cbit.vcell.solver.SolverException in project vcell by virtualcell.
the class GibsonSolver method initialize.
/**
* This method takes the place of the old runUnsteady()...
*/
protected void initialize() throws SolverException {
if (lg.isTraceEnabled())
lg.trace("StochSolver.initialize()");
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
writeFunctionsFile();
writeLogFile();
String inputFilename = getInputFilename();
if (lg.isTraceEnabled())
lg.trace("StochSolver.initialize() baseName = " + getBaseName());
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
PrintWriter pw = null;
try {
pw = new PrintWriter(inputFilename);
StochFileWriter stFileWriter = new StochFileWriter(pw, simTask, bMessaging);
stFileWriter.write();
} catch (Exception e) {
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not generate input file: " + e.getMessage())));
e.printStackTrace(System.out);
throw new SolverException("solver input file exception: " + e.getMessage());
} finally {
if (pw != null) {
pw.close();
}
}
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
// get executable path+name.
setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
// setMathExecutable(new cbit.vcell.solvers.MathExecutable(executableName + " gibson " + getBaseName() + ".stochInput" + " " + getBaseName() + ".stoch"));
}
use of cbit.vcell.solver.SolverException in project vcell by virtualcell.
the class HybridSolver method writeLogFile.
private void writeLogFile() throws SolverException {
String logFile = getBaseName() + LOGFILE_EXTENSION;
String netCDFFileName = new File(getBaseName() + NETCDF_DATA_EXTENSION).getName();
PrintWriter pw = null;
try {
pw = new PrintWriter(logFile);
pw.println(NETCDF_DATA_IDENTIFIER);
pw.println(NETCDF_DATA_FORMAT_ID);
pw.println(netCDFFileName);
pw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new SolverException(e.getMessage());
} finally {
if (pw != null) {
pw.close();
}
}
}
use of cbit.vcell.solver.SolverException in project vcell by virtualcell.
the class FVSolverStandalone method initialize.
//
//
// /**
// * Insert the method's description here.
// * Creation date: (6/27/2001 2:33:03 PM)
// */
// public void propertyChange(java.beans.PropertyChangeEvent event) {
// super.propertyChange(event);
//
// if (event.getSource() == getMathExecutable() && event.getPropertyName().equals("applicationMessage")) {
// String messageString = (String)event.getNewValue();
// if (messageString==null || messageString.length()==0){
// return;
// }
// ApplicationMessage appMessage = getApplicationMessage(messageString);
// if (appMessage!=null && appMessage.getMessageType() == ApplicationMessage.DATA_MESSAGE) {
// fireSolverPrinted(appMessage.getTimepoint());
// }
// }
// }
/**
* This method was created by a SmartGuide.
*/
protected void initialize() throws SolverException {
try {
Simulation sim = simTask.getSimulation();
if (sim.isSerialParameterScan()) {
// write functions file for all the simulations in the scan
for (int scan = 0; scan < sim.getScanCount(); scan++) {
SimulationJob simJob = new SimulationJob(sim, scan, simTask.getSimulationJob().getFieldDataIdentifierSpecs());
// ** Dumping the functions of a simulation into a '.functions' file.
String basename = new File(getSaveDirectory(), simJob.getSimulationJobID()).getPath();
String functionFileName = basename + FUNCTIONFILE_EXTENSION;
Vector<AnnotatedFunction> funcList = simJob.getSimulationSymbolTable().createAnnotatedFunctionsList(simTask.getSimulation().getMathDescription());
// Try to save existing user defined functions
try {
File existingFunctionFile = new File(functionFileName);
if (existingFunctionFile.exists()) {
Vector<AnnotatedFunction> oldFuncList = FunctionFileGenerator.readFunctionsFile(existingFunctionFile, simTask.getSimulationJobID());
for (AnnotatedFunction func : oldFuncList) {
if (func.isOldUserDefined()) {
funcList.add(func);
}
}
}
} catch (Exception e) {
e.printStackTrace();
// ignore
}
// Try to save existing user defined functions
FunctionFileGenerator functionFileGenerator = new FunctionFileGenerator(functionFileName, funcList);
try {
functionFileGenerator.generateFunctionFile();
} catch (Exception e) {
e.printStackTrace(System.out);
throw new RuntimeException("Error creating .function file for " + functionFileGenerator.getBasefileName() + e.getMessage());
}
}
} else {
writeFunctionsFile();
}
// not for Chombo solver
if (!isChombo) {
writeVCGAndResampleFieldData();
}
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INIT));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
File fvinputFile = new File(getInputFilename());
PrintWriter pw = null;
try {
pw = new PrintWriter(new FileWriter(fvinputFile));
new FiniteVolumeFileWriter(pw, simTask, getResampledGeometry(), getSaveDirectory(), destinationDirectory, bMessaging).write();
} finally {
if (pw != null) {
pw.close();
}
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
throw new SolverException(ex.getMessage());
}
}
Aggregations