Skip to content

Contact patch test

Two conforming solid blocks stacked vertically are loaded by a uniform compressive force on the top surface. The interface is modelled with frictionless hard contact.

Analytical solution (linear elasticity, uniaxial stress state):

sigma_zz = -F / A
delta = sigma_zz * L_total / E

where F is the total applied force, A the cross-sectional area, L_total the combined height and E the Young’s modulus.

The contact pressure at the interface must equal the internal stress, and the vertical displacement must be continuous across the contact surface.

  • Wriggers, P. “Computational Contact Mechanics”, 2nd ed., Springer, 2006, Ch. 4 — patch tests for contact elements.
  • The solver’s own penalty-contact examples.

The model before it is solved: parts, supports and loads

The model before it is solved: its parts, supports (red) and loads (blue).

The result: the model coloured by displacement (magnitude [mm])

The model, coloured by displacement (magnitude [mm]), in xfea’s 3D viewer.

Open in 3D turn it, cut it, pick any field: in xfea's viewer, in your browser

examples/scripts/02_core_concepts/contact/contact_patch_test.py. Run it from the repository with uv run python examples/scripts/02_core_concepts/contact/contact_patch_test.py, or, with xfea-examples installed, xfea-examples run 02_core_concepts/contact/contact_patch_test.py.

from xfea.geometry import Translation
from xfea.model import HardContactNoFriction
from xfea.problem import Problem
from xfea.problem import StaticStep
from xfea.results import ContactForcesFieldResults
from xfea.results import DisplacementFieldResults
from xfea.results import ReactionFieldResults
from xfea_examples import out_dir
from xfea_examples import viewer_wanted
from xfea_examples.models import solid_box_model
from xfea.viewers import Viewer
# 1. Model: two stacked 1000x1000x1000 mm blocks with frictionless contact
stack_offset_z = 1000 # [mm] vertical offset between blocks (cube edge)
total_force = -100_000 # [N] total compressive force on top face (-100 kN)
model, part_a, _, _, _ = solid_box_model(name="reference_contact_patch_test", element_order=2)
part_b = part_a.copy()
part_b.name = "upper_block"
part_b.transform(Translation.from_vector([0, 0, stack_offset_z]))
model.add_part(part_b)
contact = HardContactNoFriction(tol=1)
model.detect_interfaces(behavior=contact, method="face_intersection")
# 2. Boundary conditions
# Fix the base of the lower block (all DOFs).
base_nodes = part_a.find_nodes_on_plane(part_a.bottom_plane)
model.add_fix_bc(base_nodes)
# With frictionless contact the upper block has no lateral restraint.
# Constrain X/Y on the loaded face to prevent rigid-body modes while
# leaving Z free for compression.
top_nodes = part_b.find_nodes_on_plane(part_b.top_plane)
model.add_rollerZ_bc(top_nodes)
# 3. Problem, step and loading
problem = model.add_problem(Problem(name="patch_test_problem"))
# Small initial increment for stable contact convergence.
# nlgeom is not needed for this small-strain problem.
step = problem.add_step(
StaticStep(name="compression", nlgeom=True, initial_inc_size=0.05, max_inc_size=0.1)
)
load_per_node = total_force / max(1, len(top_nodes))
step.add_uniform_forcefield(nodes=top_nodes, z=load_per_node, load_case="compression")
disp = DisplacementFieldResults()
react = ReactionFieldResults()
cf = ContactForcesFieldResults()
step.add_field_outputs([disp, react, cf])
# 4. Analyse
problem.analyse_and_extract(path=out_dir(model.name), verbose=True, cpus=8)
# 5. Compare with analytical solution
# Geometry and material (from solid_box_model: E = 30 GPa, box = 1000 mm cube)
E = 30_000 # [MPa] Young's modulus (= 30 GPa)
cube_edge = 1000.0 # [mm] cube edge length
A = cube_edge * cube_edge # [mm^2] cross-sectional area
L_total = 2 * cube_edge # [mm] total stacked height
F = abs(total_force) # [N] applied force magnitude
sigma_ref = -F / A # [MPa] compressive stress
delta_ref = sigma_ref * L_total / E # [mm]
delta_fea = disp.get_min_result("z").z
print()
print("=" * 60)
print("CONTACT PATCH TEST - Reference Case")
print("=" * 60)
print()
print("Setup:")
print(f" Total applied force: {F / 1e3:.0f} kN")
print(f" Cross-sectional area: {A:.0f} mm^2")
print(f" Total height (2 blocks): {L_total:.0f} mm")
print(f" Young's modulus: {E / 1e3:.0f} GPa")
print(f" Interfaces detected: {len(model.interfaces)}")
print()
print("Analytical reference:")
print(f" sigma_zz: {sigma_ref:.4f} MPa")
print(f" delta_z (top): {delta_ref:.6f} mm")
print()
print("FEA results:")
print(f" Max vertical displacement: {delta_fea}")
print()
print(f" Expected delta_z: {delta_ref:.6f} mm")
viewer = Viewer(plugin="browser")
viewer.add_model(model)
viewer.add_results({disp: "z"}, units="mm")
if viewer_wanted(): # XFEA_EXAMPLES_SHOW_VIEWER=1, or `xfea-examples config set-show-viewer on`
viewer.run()

© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them