Skip to content

Meshes (MDPA)

Generate, inspect and validate Kratos .mdpa meshes. All of this is pure Python — no Kratos needed — except deep validation. See the MDPA format guide for the file format itself.

mdpa_create_structured_mesh

Generate a structured mesh with named boundary submodelparts and write it as .mdpa.

ParameterTypeDescription
pathstringoutput file (.mdpa appended if missing)
kindstringline, rectangle or box
sizenumber[][L] / [W, H] / [Lx, Ly, Lz]
divisionsint[][n] / [nx, ny] / [nx, ny, nz]
element_namestring?Kratos element type (defaults below)
condition_namestring?boundary condition type (defaults below)
trianglesboolsplit rectangle quads into triangles

Defaults: rectangle → SmallDisplacementElement2D4N + LineLoadCondition2D2N; box → SmallDisplacementElement3D8N + SurfaceLoadCondition3D4N; line → TrussLinearElement2D2N, no conditions.

Boundary submodelparts (each with nodes and conditions, ready for both Dirichlet fixes and surface loads):

  • line: start, endrectangle: left, right, bottom, topbox: xmin, xmax, ymin, ymax, zmin, zmax
  • plus domain with every node and element (target materials here).
json
// mdpa_create_structured_mesh("/case/mesh.mdpa", "rectangle", [1.0, 0.2], [20, 4])
{
  "written_to": "/case/mesh.mdpa",
  "num_nodes": 105, "num_elements": 80, "num_conditions": 48,
  "sub_model_parts": { "domain": {"nodes": 105, "...": 0}, "left": {"nodes": 5, "conditions": 4}, "...": {} }
}

Thermal / fluid meshes

Use generic simplex elements — element_name: "Element2D3N", triangles: true, and condition_name: "ThermalFace2D2N" (thermal); the solvers replace them with the physical element at import time.

mdpa_inspect

Report the contents of an .mdpa file: counts by entity type, bounding box, property ids and the full submodelpart tree with per-part entity counts.

ParameterTypeDescription
pathstringmesh file

mdpa_validate

Lint a mesh: dangling node/element/condition references, empty submodelparts, parse errors.

ParameterTypeDescription
pathstringmesh file
deepboolalso round-trip through the real Kratos ModelPartIO (needs Kratos; catches unregistered element names, malformed blocks)

Returns: {valid, issues: [...], kratos_read?: {...}}.

mdpa_get_nodes

Return node ids and coordinates — useful for choosing probe points or checking where a boundary region actually is.

ParameterTypeDescription
pathstringmesh file
sub_model_partstring?dotted path, e.g. right or outer.inner
node_idsint[]?explicit selection
limitintmax nodes returned (default 100; truncated flags overflow)