FreeFem++ model element
FreeFem++ defines a script that can be run on a external FreeFem++ program
The element encapsulates access to FreeFem++ either installed in your computer or running on a server.
Usage
To add a FreeFem++ element to your model, drag the icon element to the list of your model elements
and edit the desired script. The script can make use of the following predefined method:
- $(variable): will add to the script the value of the given variable of your model
The element implements the following basic methods:
- String getScript(): returns the actual script to run.
- ScriptOutput runScript(): runs the script provided in the editor.
- ScriptOutput runScript(int nProcesses)::same as before, but using nProcesses processes on an MPI installation.
- ScriptOutput runScript(String script): runs the script of your choice.
- ScriptOutput runScript(int nProcesses, String script)::same as before, but using nProcesses processes on an MPI installation.
- ScriptOutput continueReading(ScriptOutput output): continues reading a script that pause because of a wait=1 instruction
- PDEData solveAndGet(int plotNumber, int dataNumber):runs the script in the editor and gets the PDEData at the given position for a given plot command
- PDEData solveAndGet(int nProcesses, int plotNumber, int dataNumber):same as before, but using nProcesses processes on an MPI installation
- FreeFem.ErrorCode getErrorCode(): returns the error code after running the last script.
- void setUserDirectory(String directory): sets the working directory on a server.
For more information, consult the EJS Javadoc documentation for objects in the org.colos.freefem package.
It is also convenient that you add the following import statement to your simulation Imports field: org.colos.freefem.*.
No further customization is required if the server URL, username, and password were provided in the element's editor.
Alternatively, you can choose to control directly the connection. In this case, you can use the following methods.
- void setServer(String serverURL, int protNumber): sets the server URL and port number.
- void setUserAndPassword(String username, String password): sets the user name and password required to access the server, if any.
Example of use
ScriptOutput output = freeFem.runScript(); // runs the script in the editor
if (output!=null) {
_println ("Script was successful and its output contains: "+ output.getPlotCount()+" PLOT commands");
}