Skip to content

Template Case file

The structure of a Template Case .py file. Most settings can also be changed in the Template Case editor, which writes them back into the file. For a complete working example, see isolated-front-wing.py in the tutorial example data.

Structure

A Template Case is a Python module that defines one class, CFDModel, with settings as class attributes:

from bramble.core.geometry import Point, Bounds, Vector
from chickweed.model import FeaturedCFDModel   # CCMFeaturedCFDModel for Star-CCM+

API_VERSION = 1

class CFDModel(FeaturedCFDModel):
    velocity = 50.0
    solution_stages = [
        {'solver': 'potential', 'iterations': 0},
        {'solver': 'RANS', 'iterations': 4000},
    ]
    # ...
  • API_VERSION = 1 and a class named CFDModel are required.
  • The base class is FeaturedCFDModel for OpenFoam, OpenFoam with CHT and Acoustic, and CCMFeaturedCFDModel for Star-CCM+. Import only the base class you use. Importing the other one makes Bramble treat the file as the other type.
  • Bramble runs the file on its servers when you upload or save it, so it must be self-contained. Only import from bramble.core.geometry (Point, Vector, Bounds), bramble.cfd.case.components and chickweed.model. Helper functions and constants in the file are fine.
  • Saving from the editor rewrites the attributes it edits as literal values.

Units

  • Lengths are in metres. The exceptions are the Star-CCM+ prism-layer thickness and base size, which are in mm.
  • Velocity in m/s, angles in degrees, density in kg/m³, pressure in Pa, temperature in K, kinematic viscosity in m²/s, and memory in GB.
  • Uploaded geometry is in millimetres. See coordinate system and units.

Validation messages

Cause Message
API_VERSION or CFDModel missing "Can't find '<name>', which is required to process this template case"
Syntax or indentation error "SyntaxError found on line <n>: …" (or IndentationError, and so on)
File can't be read "Import of template case with error: … Was it a valid python file?"
Settings for the wrong base class "Invalid keys: …", e.g. wheels in a Star-CCM+ file, or ccm_wheels in an OpenFOAM one
Other errors on save "Error in template case …"
The Template Case is locked "Template case is being used by a case and cannot be replaced"

Main attributes

Simulation

Attribute Default Notes
solution_stages — A list of {'solver', 'iterations', 'time_step'}. Solvers: 'potential', 'RANS', 'RANS LIMITED', 'DES', and the CHT stages. For transient stages, iterations is the solution time in seconds
averaging_window 500 Iterations (or time steps) to average over. For DES: averaging time ÷ time step
output_interval 500
convergence_criteria — {'start_time', 'n_times_unconverged', 'monitors': [{'force_group', 'direction': 0/1/2, 'type', 'tolerance'}]}. Direction 0 = drag, 1 = side, 2 = lift. {} turns it off
resource 96 partitions, 3.0 GB/core {'nr_partitions', 'nr_mesh_partitions', 'memory_per_core'}
meancalc_settings, mc_stopping_criteria — MeanCalc workflows only

Example transient (DES) stages:

solution_stages = [
    {'solver': 'potential', 'iterations': 0},
    {'solver': 'RANS', 'iterations': 0.5, 'time_step': 0.001},
    {'solver': 'DES', 'iterations': 1.5, 'time_step': 0.00025},
]

Domain and reference values

Attribute Default Notes
velocity 50 Used when the Map doesn't set velocity
yaw 0
ref_density, ref_pressure, ref_temperature, ref_viscosity 1.225, 0, 303.15, 1.41e-5
ref_area frontal area Used for coefficients
location_in_mesh — Point(x, y, z) inside the fluid
domain — (Point1, Point2, Point3, height): three ground-plane corners and the height
domain_nr_cells — [nx, ny, nz]
half_domain False Bramble adjusts the domain itself
ground_patch, nr_car_points False Refined ground patch and its extent in ground cells

Mesh recipe

Attribute Notes
mesh_defaults {'surface', 'proximity', 'curvature', 'feature_edge'} settings applied to every component
components ({'name', 'regex', 'mesh': {...}},). A component's mesh settings override the defaults for its zones
mesh_ref_boxes {'name': {'level': 7, 'bounds': Bounds([xmin, xmax, ymin, ymax, zmin, zmax])}}
mesh_ref_geometry Parts used as refinement regions, e.g. {'regex': 'refine-rs', 'level': 6, 'distance': 0.0015, 'mode': 'distance'}

Mesh settings:

Setting Keys
surface level, nr_layers, expansion_ratio, final_layer_ratio, min_thickness, first_layer_thickness, gap, passive
proximity level, distance (m)
curvature on, curvature, level_increment
feature_edge on, feature_angle, level, min_length, levels: [(distance, level), …]

Any setting can also have: - regex, to apply to only some zones in the component - default: True, a lower-priority fallback - workflow (see below)

Regular expressions match zone names as in the rest of Bramble. See zone naming.

Settings for specific workflows

Add 'workflow': '<regex>' to a component mesh setting to apply it only when the Attitude's workflow name matches. The match starts at the beginning of the name and is case-sensitive, so use .* either side to match anywhere:

components = (
    {'name': 'BrakeDiscs', 'regex': '.*disc.*', 'mesh': {
        'surface': (
            {'level': 9, 'nr_layers': 2},
            {'level': 11, 'nr_layers': 5, 'workflow': '.*Thermal.*'},  # only in thermal workflows
        )}},
)

This applies to component mesh settings (surface, proximity, curvature and feature edges), not to refinement boxes. Check the exact workflow names on your Attitudes' CFD Setup.

Boundary conditions, rotation and porous zones

Attribute Contents
velocity_inlets, velocity_outlets, total_pressure_inlets, pressure_outlets, slippy_walls, roughness, temperatures, grounds Lists of {'component', 'regex', …values}. component must match a name in components. Give grounds 'tags': ['ground__ground']
wheels Rotating regions with an MRF: {'name', 'regex', 'axis', 'origin', 'omega', 'mrf_point', 'non_rotating_patches', 'zoneless', 'zoneless_patches'}
rotating Rotating walls without an MRF: {'name', 'regex', 'axis', 'origin', 'omega'}
radiators {'name', 'point', 'coefficients': (darcy, forchheimer), 'coordinate_system': (through, orthogonal), 'factors': (1, 10, 10), 'up_down'}
porous_jumps, fan_jumps, mfps Interior zones

Forces, monitors and exports

Attribute Contents
solve_forces [{'name', 'regex'}]. Include an all group
solve_monitors [{'regex', 'type', 'variable'}] on toint surfaces
solve_balances ({'name': 'pitch', 'centre': Point(...), 'span': ...},)
export_surfaces, export_movies, export_custom_movies, export_iso_surfaces, export_volumes, export_point_probes, export_surface_probes, streamline exports See the editor reference for fields

Related: Edit a Template Case · Template Case editor reference