A Funz plugin for Cast3m finite element software.
Cast3m is a finite element software developed by CEA (French Alternative Energies and Atomic Energy Commission) for structural and fluid mechanics simulations. This plugin enables the Funz fz framework to run parametric studies with Cast3m.
This repository contains the port of the old Cast3m plugin to the new fz framework.
- Variable syntax:
$(variable_name) - Formula syntax:
%(formula) - Comment character:
*
The Cast3m plugin extracts these output variables:
- MESS variables: Scalar values from
MESS 'varname=' varname;commands - Text files: Numeric data from
SORT 'CHAI'outputs (*.txt) - CSV files: Tabular data from
SORT 'EXCE'outputs (*.csv)
This plugin requires the Funz/fz framework and Cast3m software.
# Install fz framework
pip install git+https://github.com/Funz/fz.git
# Ensure Cast3m is installed and in PATH
# (castem2000 or cast3m executable)Clone this repository to use the plugin:
git clone https://github.com/Funz/fz-cast3m.git
cd fz-cast3mimport fz
# Example: Run parametric study with Cast3m
results = fz.fzr(
input_path="examples/Cast3m/poutre_parametric.dgibi",
input_variables={
"long": [0.20, 0.25, 0.30, 0.35, 0.40],
"haut": [0.001, 0.002],
"larg": 0.01,
"F": 1.0
},
model="Cast3m",
calculators="localhost_Cast3m",
results_dir="beam_study"
)
print(results[['long', 'haut', 'larg', 'F', 'dep_P2']])your_project/
├── examples/
│ └── Cast3m/
│ ├── poutre.dgibi # Simple beam example
│ ├── poutre_parametric.dgibi # Parametric beam example
│ └── outvar.dgibi # Output variables example
├── .fz/
│ ├── models/
│ │ └── Cast3m.json # Model configuration
│ └── calculators/
│ ├── Cast3m.sh # Calculator script
│ └── localhost_Cast3m.json # Local calculator config
├── tests/
│ └── test_plugin.py # Test suite
└── results/ # Generated by fz
* POUTRE CONSOLE EN FLEXION SIMPLE
OPTI DIME 2 ELEM SEG2;
long = $(long);
haut = $(haut);
larg = $(larg);
F = $(F);
* ... calculation code ...
MESS 'dep_P2=' dep_P2;
FIN;
In this example:
$(long),$(haut),$(larg), and$(F)are variable parameters that will be substituted by fz- Lines starting with
*are comments MESS 'dep_P2=' dep_P2;defines an output variable
This repository can serve as a template for creating Cast3m-based studies:
- Clone this repository as a starting point
- Customize input files:
- Add your
.dgibifiles toexamples/Cast3m/ - Use
$(variable)syntax for parameters - Use
MESS 'varname=' varname;for outputs
- Add your
- Run parametric studies:
- Use fz Python API or command-line tools
- Results are automatically extracted from Cast3m outputs
The model JSON file (.fz/models/Cast3m.json) defines variable syntax and output parsing:
{
"id": "Cast3m",
"varprefix": "$",
"formulaprefix": "%",
"delim": "()",
"commentline": "*",
"output": {
"outputs": "python3 << 'PYEOF'\n... [Python code for output parsing] ...\nPYEOF\n"
}
}Fields:
id: Unique identifier for the modelvarprefix: Character prefix for variables (e.g.,$for$(x))formulaprefix: Character prefix for formulasdelim: Delimiter characters around variable namescommentline: Character(s) that start a comment lineoutput: Shell commands that extract output values
The calculator JSON files define how to execute Cast3m:
{
"uri": "sh://",
"models": {
"Cast3m": "bash .fz/calculators/Cast3m.sh"
}
}uri: Execution method (sh://for local shell)models: Mapping of model names to execution commands
To run calculations on a remote server:
results = fz.fzr(
input_path="examples/Cast3m/poutre_parametric.dgibi",
input_variables={"long": [0.25, 0.30, 0.35]},
model="Cast3m",
calculators="ssh://user@server.com/bash /path/to/calculators/Cast3m.sh",
results_dir="remote_results"
)Ensure Cast3m (castem2000 or cast3m) is installed and in PATH:
which castem2000
# or
which cast3mCheck that your .dgibi file includes output commands:
MESS 'varname=' varname;
python tests/test_plugin.pyBSD 3-Clause License. See LICENSE file.
- Funz/fz - Main framework
- Cast3m official website - Cast3m software
- Original Cast3m plugin - Java-based plugin for old Funz framework
This plugin is a port of the original Cast3m plugin to the new fz framework. The original plugin was:
- Copyright: IRSN, Paris, FRANCE
- Developed by: Artenum SARL
- Authors: Laurent Mallet, Arnaud Trouche
Ported to fz framework: 2024-2025