Old-leaf -> new-leaf solution transfer plan for one adaptation epoch of the 2-D quad-forest:
the driver layer of AMR Stage 3 that connects the element-local transfer operators
(SELF_SolutionTransfer_2D) to the forest mutation (SELF_QuadTreeMesh_2D).
One adaptation epoch mutates the forest between two leaf configurations:
nOld=forest%nLeaves; oldLeaf = forest%leaf(1:nOld) ! snapshot BEFORE mutatingcallforest%AdaptFromFlags(flag)!atmostonecall,thencallforest%Balance2to1()!anynumberoffurther!refinements(RefineNodetoo)callBuildTransferPlan(forest,nOld,oldLeaf,plan)!AFTERthelastmutation
Solution element index = leaf-list position (the element ordering EmitMesh produces), so the
plan records, for every new leaf, where its data comes from in the old element ordering:
SELF_TRANSFER_COPY : the leaf survived unchanged; copy old element sourceElem.
SELF_TRANSFER_PROLONG : the leaf descends from old leaf sourceElem; interpolate the old
element's degree-N polynomial down the quadtree path (one step per
level, so depth > 1 handles a fresh child that 2:1 balancing
refined again in the same epoch). Exact, no loss.
SELF_TRANSFER_RESTRICT : the leaf is (an ancestor of) a coarsened family; L2-project the
four old children family(1:4) onto their parent, then prolong down
depth >= 0 further steps (depth > 0 occurs when a just-coarsened
parent is immediately re-refined by 2:1 balancing). Conservative.
The reconstruction is possible after the fact because forest node ids are stable: refinement
only appends nodes and coarsening only detaches children, whose level/parent/quadrant entries
persist. Each new leaf therefore ascends its parent chain until it meets either an old leaf
or a node holding a complete four-child old-leaf family; anything else means the snapshot
does not describe the epoch that produced the forest, and the builder stops with an error.
ApplyTransferPlan executes the plan on nodal data u(1:N+1,1:N+1,1:nElem,1:nVar) (the layout
of MappedScalar2D %interior; units are those of the transferred fields) and inherits the
Stage-3 operator identities: prolongation is exact polynomial interpolation and restriction
is the conservative L2 projection, so the Jacobian-weighted cell integral of every variable
is conserved and a refine-then-coarsen round trip is the identity to roundoff. Transfer runs
once per adaptation epoch, between time steps; it is not a per-step hot path.
Nodes of different colours represent the following:
Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Execute a transfer plan on nodal element data: uNew(:,:,li,:) receives old element data
copied, prolonged (exact interpolation), or restricted (conservative L2 projection)
according to plan entry li. interp must be the solution interpolant the data lives on
(its mortar operators drive the transfer). Runs once per adaptation epoch - not a
per-time-step hot path - so clarity is preferred over fused loops here.
Execute the contiguous sub-range eFirst..eLast of a transfer plan: uNew(:,:,k,:)
receives the data of new element eFirst+k-1. uOld is the full (global) old field; the
output is only the requested slice. This is the decomposed-mesh (AMR Stage 5) entry
point: each rank passes its own contiguous range of the new element ordering and a
gathered global old solution, and fills exactly its rank-local storage.
Build the old->new transfer plan for the adaptation epoch that took the forest from the
leaf configuration (nOld, oldLeaf) - a snapshot of (forest%nLeaves, forest%leaf) taken
before mutating - to its current leaf configuration. See the module documentation for the
allowed mutations within one epoch. The plan is valid until the forest is mutated again.