[ I first sent my reply to only Markus by accident, resending it to the list]

Hi Markus!

I can see why you are confused.
The UnstructuredGrid (UG for now) docs are not quite good enough.

See the docs for the field face_cells. For a face f, face_cells[2*f] and 
face_cells[2*f+1]
are its cells, and the face is oriented from the first to the second. Either 
can be -1 if
the face is on the boundary.

In CpGrid, the OrientedEntityTable stores the neighbours (cells in this case) in
arbitrary order, but it does keep an orientation with the indices instead. I'll 
denote
this using "~" to mean negative orientation. So let's say that face f has two 
cell neighbours,
called a and b, and is oriented from a to b. In UG.face_cells this must be [a 
b]. In CpGrid,
the corresponding row can be either [a ~b] or [~b a]. So the use_first variable 
tries to 
see whether we should extract a from the first or second position.

A minor added complication is that while the UG always stores two, the CpGrid 
stores just one
cell for boundary faces.

Hope this clarifies a little.

Atgeirr

PS. Be aware of the most dangerous thing about UG, the normals are really (unit 
normals) * area, not unit normals.
This is documented, but I mention it since it is a 'gotcha' difference to 
CpGrid/Dune. I am not fond of this convention,
but it was established in MRST ages ago and cannot be changed without a lot of 
trouble.

Den 24. jan. 2014 kl. 12:28 skrev Markus Blatt:

> Hi,
> 
> somehow I do not get the following code at all:
> 
> int faceCell(int face, int local_index) const
>       {
>           cpgrid::OrientedEntityTable<1,0>::row_type r
>               = face_to_cell_[cpgrid::EntityRep<1>(face, true)];
>           bool a = (local_index == 0);
>           bool b = r[0].orientation();
>           bool use_first = a ? b : !b;
>           if (r.size() == 2) {
>               assert(r[0].orientation() != r[1].orientation());
>               return use_first ? r[0].index() : r[1].index();
>           } else {
>               return use_first ? r[0].index() : -1;
>           }
>       }
> 
> What are the implicit assumption here?
> 
> For clarity I rephrase the algorithm in my own words:
> If we request a cell by a local_index, then the orientation of the
> first cell always tells which of the cell we will return:
> - if there is only one cell, cell 0 is return for local_index 0 and
> otherwise -1 to indicate "no such cell" (->clear to me)
> - if local_index==0 then it is cell 0 if the orientation of cell 0 is true
> otherwise cell 1
> - if local_index!=0 then it is cell 1 if the orientation of cell 0 is true
> otherwise cell 0
> 
> The last two items just puzzle me.
> 
> If somewhat could comment on how this relates to
> UnstructuredGrid::face_cells[2*f+local_index] I would be most
> grateful.
> 
> Markus
> -- 
> Dr. Markus Blatt - HPC-Simulation-Software & Services http://www.dr-blatt.de
> Hans-Bunte-Str. 8-10, 69123 Heidelberg, Germany,  USt-Id: DE279960836
> Tel.: +49 (0) 160 97590858
> _______________________________________________
> Opm mailing list
> [email protected]
> http://www.opm-project.org/mailman/listinfo/opm


_______________________________________________
Opm mailing list
[email protected]
http://www.opm-project.org/mailman/listinfo/opm

Reply via email to