Open charleskawczynski opened 2 years ago
I'd like to see a clear description of the minimum functionality that we need (e.g., transformation covariant -> contravariant and inverse, in the horizontal and in 3d). That is, put down a set of requirements that need to be fulfilled, and then discuss the code structure that will fulfill them.
From the description here, I have the impression that what we need is not so much an improved design of AxisTensors (how did we ever get to 3486 types?), but getting rid of it and replacing it by much simpler code. I'd be hesitant to invest resources in improving something just because we have sunken costs in it.
I'd like to see a clear description of the minimum functionality that we need (e.g., transformation covariant -> contravariant and inverse, in the horizontal and in 3d). That is, put down a set of requirements that need to be fulfilled, and then discuss the code structure that will fulfill them.
Good point. Since @simonbyrne has some ideas about this, let's wait for when he returns.
From the description here, I have the impression that what we need is not so much an improved design of AxisTensors (how did we ever get to 3486 types?), but getting rid of it and replacing it by much simpler code. I'd be hesitant to invest resources in improving something just because we have sunken costs in it.
In some ways yes. And it's not that we have 3486 types, it's that we can make 3486 (distinguishable) types. Some of these transformations are indistinguishable by changing coordinate systems. For example, transformations in a x-y plane are distinguishable from transformations in a y-z plane.
I think @simonbyrne mentioned that we may be able to continue using what we have and just forward generic transformations to more generic methods (to avoid defining many methods). This would fix the many method issue, however, it wouldn't really address the documentation issue.
On another note, timings in point 2 should be confirmed. I've since run other examples that didn't result in slowdown. It's possible that more inlining is needed.
There are 3 main representations we make use of: covariant, contravariant, local (aka uvw). This means that there are 6 possible conversion directions.
What really causes the blow up is dealing with subvectors (e.g. Covariant12Vector
, WVector
, etc), and subspaces (e.g. shallow water equations operate in a "1,2" space, inertial gravity wave in a "1,3" space). Adding in all these combinations causes a large explosion in the number of methods we use.
Additionally, we also currently define transform
and project
: these are basically the same, but transform
will throw an error if the conversion is not exact (i.e. if you drop a non-zero dimension).
@charleskawczynski do you have a list of the methods we generate? Can you post them in a gist so I can see what we're using? That might help narrow down the scope
@charleskawczynski do you have a list of the methods we generate? Can you post them in a gist so I can see what we're using? That might help narrow down the scope
Yes, here is the gist. It includes:
project
function has 2 and 3 argument methods), I added this mostly for scraping convenienceThere are a lot, but as you've said, it still narrows down the scope
There are actually more methods that I missed, which call project in a nested fashion, those should probably be written to minimize loads/stores/flops, too.
For example:
transform(
ax::ContravariantAxis,
v::CovariantTensor,
local_geometry::LocalGeometry,
) = project(
ax,
local_geometry.∂ξ∂x *
local_geometry.∂ξ∂x' *
project(dual(axes(local_geometry.∂ξ∂x, 1)), v),
)
This is probably very slow.
Purpose
The purpose of this SDI is to improve the design of AxisTensors. There are several issues with the existing design:
typeof(::AxisTensor)
which will not show the alias, but the concrete type ofAxisTensor
, creating a visual mismatch for people debugging.Link to any relevant PRs/issues.
Cost/benefits/risks
Producers
Components
AxisTensor
sInputs
There are many relations (e.g., conversions) that will need to be re-written, but most of this is related to the type design
Results and deliverables
A better design to AxisTensors
Task breakdown
A preliminary list of PRs and a preliminary timeline of PRs, milestones, and key results.
Reviewers