Make element representations opaque to the assembly
module #90
Labels
No labels
bug
design
duplicate
engine
enhancement
maintenance
prospective
question
regression
stub
todo
ui
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: StudioInfinity/dyna3#90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We'd like to keep engine-specific code within the
engine
module as much as possible. Up through pull request #87, we've allowed engine-specific details to leak into theassembly
module by assuming that each element is represented by aDVector<f64>
. Upcoming elements, like lines, will violate this assumption, so now is a good time to redesign theassembly
module so that it no longer needs to know which data types we use to represent elements.A question to keep in mind
When an element has a "compound representation," how do we decide whether that detail is engine-independent enough to use outside the
engine
module? To see how the decision might depend on how things are implemented, consider the following ways of representing a line segment:\mathbb{R}^{4,1}
(much more engine-specific).Proposed redesign
In the
engine
moduleIntroduce a new
ElementRepresentation
trait, and newSphereRepresentation
andPointRepresentation
structures that implement it. In the future, we might also want to implementElementRepresentation
for compound representation types, like[PointRepresentation]
.In the
assembly
moduleChange the
Element
trait in one of these ways:ElementRepresentation
.representation
method to something likeSignal<dyn ElementRepresentation>
.Change the type of the
representation
field to:Signal<SphereRepresentation>
in theSphere
structure.Signal<PointRepresentation>
in thePoint
structure.If we can implement
ElementRepresentation
for compound representation types, as expected, we could also eventually have a field type likeSignal<[PointRepresentation; 3]>
for a hypotheticalTriangle
structure. This would make it clear that we don't have perfect redundancy between element and representation structures.Move the engine-specific parts of the
ProblemPoser
implementations into theengine
module. Some ideas about how:ProblemPoser
for bothSphere
andSphereRepresentation
, lettingSphere
partially or fully forwards calls topose
. Treat other element and representation structures similarly.engine::ElementRepresentation
a subtrait ofProblemPoser
and callpose
on whatever an element'srepresentation
method returns.Make the data types of element representations opaque to theto Make element representations opaque to theassembly
moduleassembly
moduleGoing further, not just the data types of element representations, but really any details of the element representations should not be part of the assembly module. This modularization will be necessary whenever we next want to experiment with a different engine. So the assembly should not know the order or meanings of any representation data. We could imagine that there was an engine that internally dealt with polar coordinates; the assembly should not know about what those coordinates were or anything about their arrangements or semantics.
Thus, information like Point::NORM_COMPONENT and Point::WEIGHT_COMPONENT should be purged from assembly.rs. So the ProblemPoser implementation that freezes the WEIGHT_COMPONENT should be removed from assembly.rs. Instead, there should be some protocol that specifies to the engine that such and such an entity is a "Point", and then (in our case), the engine should be translating that specification to freezing the appropriate component(s).
Presuming the coordinate-regulators PR #118 is merged, another example is the code that freezes the norm component when all of the spatial coordinates are frozen. That should not be happening in the assembly. Instead, perhaps, the engine should be checking if all but one of the coordinates of an entity are frozen, and if so, freeze the third.
Likely to do all these things, we need an abstract constraint specification system, and a layer that translates the abstract specifications to the solver in use. So switching engines would involve writing the new translation layer and then sending the specification to the new solver. This architecture should also allow a given problem to be sent to multiple solvers at once (by being translated into all of them) so that as they come back their solutions can be used.
I'll expand on this a little, since we talked about it during our check-in meeting. We concluded that the engine or the problem translation layer should be responsible for freezing the last component, because it seems like a problem simplification step that depends on the engine and might happen as a prelude to the engine's realization routine.