Skip to content

Funz/fz-Cast3M

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fz-Cast3m

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.

Features

Input Syntax

  • Variable syntax: $(variable_name)
  • Formula syntax: %(formula)
  • Comment character: *

Supported Output Variables

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)

Installation

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-cast3m

Usage

With fz Python API

import 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']])

Directory Structure

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

Example Input File

* 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

Creating Your Own Plugin

This repository can serve as a template for creating Cast3m-based studies:

  1. Clone this repository as a starting point
  2. Customize input files:
    • Add your .dgibi files to examples/Cast3m/
    • Use $(variable) syntax for parameters
    • Use MESS 'varname=' varname; for outputs
  3. Run parametric studies:
    • Use fz Python API or command-line tools
    • Results are automatically extracted from Cast3m outputs

Model Configuration

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 model
  • varprefix: Character prefix for variables (e.g., $ for $(x))
  • formulaprefix: Character prefix for formulas
  • delim: Delimiter characters around variable names
  • commentline: Character(s) that start a comment line
  • output: Shell commands that extract output values

Calculator Configuration

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

Remote Execution

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"
)

Troubleshooting

Cast3m executable not found

Ensure Cast3m (castem2000 or cast3m) is installed and in PATH:

which castem2000
# or
which cast3m

Output variable not found

Check that your .dgibi file includes output commands:

MESS 'varname=' varname;

Running Tests

python tests/test_plugin.py

License

BSD 3-Clause License. See LICENSE file.

Related Links

Acknowledgments

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •