LESARD: Proposed running scripts



Page navigation



Problem solving script


The file RunProblem.py provides a simple interface to run the desired solver on a target problem for a given mesh resolution. When targetting a problem to solve, make sure that:

  • the problem of interest is already defined according to the given template (see the problem creation part of the User Manual) and is stored in the PredefinedTests/PredefinedProblems folder (or corresponding if the Pathes got edited in the file Pathes.py)

  • the mesh associated to the problem is stored in the PredifinedTests/PredefinedMeshes folder (or corresponding if the Pathes got edited in the file Pathes.py) and the wished resolution is available

  • the wished solver settings to consider for computing the numerical solution is valid (see the compatibility table given on the documentation homepage and the settings’ file format in the User Manual), and is stored in the folder PredefinedTests/PredefinedSettings (or corresponding if the Pathes got edited in the file Pathes.py) and the wished resolution is available


The numerical solution can be computed by editing the fields of the file accordingly. By example, for solving an advection-translation problem on two fluids, using a coarse mesh and a first order solver one can set the fields of the file RunProblem.py to

ProblemDefinition = "Advection_Translation_2Fluids"
SettingsChoice    = "FirstOrderGalerkin"
MeshResolution    = 20

Solving the problem is then done as simply by the two lines

import SourceCode.Solve  as Solve
Solve.Solve(ProblemDefinition, SettingsChoice, MeshResolution)

There is then just left to run the script by

$ python RunProblem.py

The solution will be periodically exported as binary pickle and vtk file in the folder Solutions/$ProblemDefinition_$SettingsChoice/Res$MeshResolution/RawResults, where the $ indicates that the associated variables names are used.


Warning

Computing a solution to a problem will automatically erase any previous computation performed over the same tripplet (problem, resolution, solver).


Note

  • Make sure that you are using python3, otherwise some module-depency may fail (in particular)

  • The solution is only computed and periodically exported. No post-processing task is performed through this script.






PostProcessing script


The file RunPostProcess.py provides a simple interface to post-process a previously exported solution. To access the solution, one needs

  • the problem’s name

  • the mesh’s resolution that has been used to compute the solution

  • the solver settings that has been used to compute the solution


The solution will be looked for in the folder Solutions/$ProblemDefinition_$SettingsChoice/Res$MeshResolution/RawResults, where the $ indicates that the associated variables names are used. Adapt the following lines of the script to your case. If no corresponding solution folder is found, the script is aborting with an explicit error message.

# Parameters to load the solution to an advection-translation problem
# on a coarse mesh from a First order Galerkin solver
ProblemDefinition = "Advection_Translation_1Fluid"
SettingsChoice    = "FirstOrderGalerkin"
MeshResolution    = 20

Select then the type of postprocessing routine you would like to execute by commenting or uncommenting the following lines.

# Plotting the solution's evolution in plotly considering all the exported timestamps
PostProcess.Plots_AnimationsPlotly(ProblemDefinition, SettingsChoice, MeshResolution)

# Plotting graphics at given time steps. Furnish either the list of time step to export the plots
# at (should match the exported times, look within the folder before hand as only 7 digits are considered in the export file name)
# or the keyword "all" for which each exported result will lead to a plot.
PostProcess.Plots_StaticMatplotlib(ProblemDefinition, SettingsChoice, "all", MeshResolution)
PostProcess.Plots_StaticPlotly(ProblemDefinition, SettingsChoice, [0.0, 1.179924], MeshResolution)

All those routine are gathering predefined sets of plotting functions whose list is available under the routine documentation in the Technical Manual under the rubric “Automatic post-processing routines”. Feel free to add other pre-defined plotting-routine wrap-up in the file SourceCode/PostProcess.py at your wish.


Running the postprocessing tasks is then done as simply by the two lines

$ python RunPostProcess.py


Note

  • A debugging routine is also available, plotting raw information graphically
    PostProcess.Plot_DebugMatplotlib(ProblemDefinition, SettingsChoice, ExplicitTimeStampList, MeshResolution)
  • Make sure that you are using python3, otherwise some module-depency may fail (in particular)