We start by creating a script. In the toolbox tool window on the right, click on the scripting folder ("scripts" ) and select "Add new script". This will add a new script (with the name you provided) to your "scripts" folder and opens the scripting editor (see Scripting editor overview for more details on the editor). 

To create a new flow flexible mesh model we start by adding the following lines:

from Libraries.FlowFlexibleMeshFunctions import *

fmModel = WaterFlowFMModel()

In the first line we declare that we want to use a library. The first part "from Libraries.FlowFlexibleMeshFunctions" specifies where the library is located. In this case, it is located in the Libraries folder (under the scripting folder "scripts") in the file FlowFlexibleMeshFunctions.py. The second part, "import *", indicates which functionalities we want to use from this library. An asterisk, in this case, means that all the functionalities contained in the file will be available after importing it. It is also possible to select only some parts using a comma separated list. For example, if you only wanted to use the function WaterFlowFMModel, you could use: "from Libraries.FlowFlexibleMeshFunctions import WaterFlowFMModel".

The second line assigns a new WaterFlowFMModel object instance to the variable fmModel. The FlowFlexibleMeshFunctions library defines how a WaterFlowFMModel object must be constructed.

To run the script select the lines and press CTRL + ENTER. The variable fmModel will then contain an instance of a flow flexible mesh model object. It is usually a good idea to run the import command after you type it in, because this will add the functions and types to the code completion. This will make it easier to create the next lines of code. It will also provide documentation for the functions and types.

You will be able to view the model by adding the following lines :

from Libraries.StandardFunctions import *

AddToProject(fmModel)

The first (import ..) line adds all the functions from the StandardFunctions library.  The second line adds the model in the fmModel variable to the current project. 

After running these lines, the model will be placed in the project explorer: