Entity and geometry details¶
This page collects advanced details of the Entity and Geometry interfaces
that become important when writing generic and robust DUNE code.
Learning goals
After this page, you should be able to:
- distinguish topological and geometric parts of an entity,
- use entity metadata (
level,partitionType,type,seed) correctly, - apply geometry mappings and Jacobian-based quantities in assembly code.
Entity interface details¶
For entities of all codimensions, commonly used methods are:
entity.level();
entity.partitionType();
entity.type();
entity.geometry();
entity.subEntities(codim);
entity.seed();
Important points:
- entities are view objects exposed by iterators; user code does not modify them directly,
- structural modification happens through grid adaptation operations,
seed()stores a lightweight handle to recreate an entity later.
For codim-0 entities (elements), the interface is extended with access to subentities and hierarchical relations (grid-dependent).
Geometry interface details¶
An entity geometry maps reference coordinates to global coordinates:
const auto geo = entity.geometry();
auto x = geo.global(xi); // reference -> global
auto xi2 = geo.local(x); // global -> reference
Core geometry methods:
geo.type();
geo.affine();
geo.corners();
geo.corner(i);
geo.center();
geo.volume();
geo.integrationElement(xi);
Jacobians and gradient transformations¶
For finite element operators, these methods are central:
geo.jacobianTransposed(xi);
geo.jacobianInverseTransposed(xi);
geo.jacobian(xi);
geo.jacobianInverse(xi);
Typical usage for gradients:
where g is the geometry mapping and \hat f(\xi) = f(g(\xi)).
integrationElement(xi) provides the geometric factor for transformed integrals.
Practical notes from the interface docs¶
- Geometry objects stay valid until the grid is modified or deleted.
center()is a convenient representative point, not a guaranteed geometric centroid.- In non-square mappings, inverse Jacobian methods use pseudo-inverse semantics.
Where this fits in your workflow¶
- Use Grid traversal for iteration patterns.
- Use Grid intersections for face-based terms.
- Use Integrating functions on a grid for quadrature loops.
Summary and next steps¶
You now have the advanced Entity/Geometry concepts needed for generic assembly code.
Continue with Grid intersections or Grid data attachment, depending on whether your next step is face terms or data layout.