Skip to content
Snippets Groups Projects
Commit c4b35bff authored by Oliver Sander's avatar Oliver Sander
Browse files

Merge branch 'bugfix/sidevector-vectorside-in-parallel' into 'master'

Ensure a side vector's `object` and `VECTORSIDE` are consistent

A side vector belongs to one or two elements. One of them is stored as a
representative in the vector's `object` member and the side of the
`object` it belongs to is stored in `VECTORSIDE` as part of the control
word.

When restoring consistency in `ElementObjMkCons` this reverse link from
the side vector to the element is restored, but the `VECTORSIDE` was
not. This can lead to an inconsistent view for side vectors belonging to
two elements:

On the master, let the vector `v`'s representative element be `A` and
the side of the element be `a`. Let `B` (`b`) be the other
representative and assume `a ≠ b`. As the vector's control word is
global data (`EL_GDATA`), the non-master side vectors will also have
`VECTORSIDE` set to `a`.

If now `ElementObjMkCons` is called first for `A` and then for `B`, then
`v.object` will first be set to `A`, but then `B`. However `VECTORSIDE`
is still `a`!

This change makes sure that `VECTORSIDE` is also updated alongside the
`object` pointer. Note that it is (still) not guaranteed that the same
representative is chosen.

Closes #12

See merge request !23
parents 7c789d2a 48700939
No related branches found
No related tags found
1 merge request!23Ensure a side vector's `object` and `VECTORSIDE` are consistent
Pipeline #
......@@ -1745,8 +1745,10 @@ static void ElementObjMkCons (DDD_OBJ obj, int newness)
if (dddctrl.elemData) VOBJECT(EVECTOR(pe)) = (GEOM_OBJECT*)pe;
if (dddctrl.sideData)
for (i=0; i<SIDES_OF_ELEM(pe); i++)
for (i=0; i<SIDES_OF_ELEM(pe); i++) {
VOBJECT(SVECTOR(pe,i)) = (GEOM_OBJECT*)pe;
SETVECTORSIDE(SVECTOR(pe,i), i);
}
/* if called with prio old=ghost and new=ghost,
then you have eventually to unlink and link
......
......@@ -415,9 +415,15 @@ static void ddd_DefineTypes (void)
/* 1. DDD objects (with DDD_HEADER) */
/*
* A side vector's `VECTORSIDE` depends on which of the `objects` is used
* as a representative. To ensure consistency, both are handled in the same
* place (`ElementObjMkCons`).
*/
gbits = ~((1 << VECTORSIDE_LEN)-1 << VECTORSIDE_SHIFT);
DDD_TypeDefine(TypeVector, &v,
EL_DDDHDR, &v.ddd,
EL_GDATA, ELDEF(v.control),
EL_GBITS, ELDEF(v.control), &gbits,
/* object must be LDATA, because reftype may be a non-DDD-object */
/* (e.g., edge). therefore, 'object' must be updated by MKCONS- */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment