The FieldML Evaluator Graph¶
A Document is more than a mesh — it's a graph of named evaluators. This notebook walks through the evaluator subtypes and how they compose.
In [ ]:
Copied!
from pyfieldml import datasets
doc = datasets.load_unit_cube()
from pyfieldml import datasets
doc = datasets.load_unit_cube()
Types vs evaluators¶
A Document contains:
- Types: BooleanType, EnsembleType, ContinuousType, MeshType.
- Evaluators: the graph that produces values over those types.
In [ ]:
Copied!
print("Types:")
for name in doc.region.continuous:
print(" continuous :", name)
for name in doc.region.ensembles:
print(" ensemble :", name)
for name in doc.region.meshes:
print(" mesh :", name)
print("Types:")
for name in doc.region.continuous:
print(" continuous :", name)
for name in doc.region.ensembles:
print(" ensemble :", name)
for name in doc.region.meshes:
print(" mesh :", name)
Evaluator subtypes¶
Count by kind:
In [ ]:
Copied!
from collections import Counter
kinds = Counter(type(ev).__name__ for ev in doc.region.evaluators.values())
for k, n in kinds.items():
print(f" {k:25s} x{n}")
from collections import Counter
kinds = Counter(type(ev).__name__ for ev in doc.region.evaluators.values())
for k, n in kinds.items():
print(f" {k:25s} x{n}")
Probing a coordinate field¶
Even a unit cube has a full evaluator graph you can probe at any parametric location:
In [ ]:
Copied!
import numpy as np
coords = doc.field("coordinates")
xi = np.array([[0.25, 0.25, 0.25], [0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
for point in xi:
val = coords.evaluate(element=1, xi=point)
print(f"xi={point} -> {val}")
import numpy as np
coords = doc.field("coordinates")
xi = np.array([[0.25, 0.25, 0.25], [0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
for point in xi:
val = coords.evaluate(element=1, xi=point)
print(f"xi={point} -> {val}")
Jacobians¶
For a unit-cube mesh the identity map means the Jacobian is the identity matrix everywhere:
In [ ]:
Copied!
J = coords.jacobian(element=1, xi=(0.5, 0.5, 0.5))
print("Jacobian at centroid:")
print(J)
J = coords.jacobian(element=1, xi=(0.5, 0.5, 0.5))
print("Jacobian at centroid:")
print(J)