[Dune] Usage of insertBoundary to set ID boundaries

Andreas Buhr andreas at andreasbuhr.de
Wed Feb 12 07:17:21 CET 2014


Hi Andrea,

How are you doing? I hope
On 02/10/2014 01:11 PM, Sacconi, Andrea wrote:
> I would like to ask you a quick question about the method
> insertBoundary of Alberta factory grid. I need to set the boundary
> conditions, i.e. I would like to assign a specific ID to each segment
> on the grid. The grid has been generated from an external mesh
> generator, which stores boundary info in a different way.

Yes, what you describe is possible. I am doing exactly this. You can
give boundary segments to the grid factory. You cannot directly assign
any properties to those boundary segments. Instead, you have to keep
track in which order you gave it to the grid factory. After mesh
creation, you can ask the grid factory for the insertion number of a
given intersection. So you have to keep a data structure which tells you
something like "the n-th boundary segment I gave to the grid factory
belongs to neumann boundary".

The way I do it (for 2D) (pseudocode):

1. Create a grid factory:
Dune::GridFactory<GridType> gf;

2. Insert Vertices:
for(point : points)
  gf.insertVertex(point);

3. Insert boundary segments:
for(segment : interesting_boundary_segments)
  gf.insertBoundarySegment(sid);

4. Insert Triangles:
for(triangle : triangles)
  gf.insertElement(type, vid);

Then you create the grid. On this grid, you can ask the grid factory
whether a given intersection was inserted using "insertBoundarySegment".
Some lines from my code:

if (gf.wasInserted(*intersection_iterator)) {
  auto index = gf.insertionIndex(*intersection_iterator);
  std::pair<int, int> my_index =
  dune_segment_marker_to_my_numbering[index];

I hope this helps?

best,
Andreas




More information about the Dune mailing list