[Dune] questions about ElementID_to_physical_entity
Alexander Schlaich
schlaich at icp.uni-stuttgart.de
Tue Apr 12 18:43:18 CEST 2011
Dear Dune,
I'm trying to use the boundaryToElementID exactly as described below with
typedef Dune::ALUSimplexGrid<dimgrid,2> GridType;
Dune::GridFactory<GridType> factory;
// read my gmsh file
Dune::GmshReader<GridType> gmshreader;
gmshreader.read(factory, sysParams.get_meshfile(), boundaryIndexToEntity,
elementIndexToEntity, true, false);
...
(no modifications to the grid, especially no refine() or loadBalance() is
done)
...
int physgroup_index = pg[factory.insertionIndex(i.intersection())];
std::cout << "Set boundary type" << physgroup_index << " at " <<
i.geometry().center() << std::endl;
But for my file (which is attached) I always get
...
Set boundary type1 at -3.1 0 (correct)
Set boundary type1 at -3.1 0 (correct)
Set boundary type2 at -3.64286 0 (wrong!)
Set boundary type2 at -3.64286 0 (wrong!)
Set boundary type2 at -4.18571 0 (wrong!)
Set boundary type2 at -4.18571 0 (wrong!)
Set boundary type0 at -5 1.875 (correct)
Set boundary type0 at -5 1.875 (correct)
...
In the Meshfile it seems correct (type 1) to me:
in $Nodes:
31 -2.828571428571428 0 0
32 -3.371428571428571 0 0
33 -3.914285714285714 0 0
34 -4.457142857142856 0 0
and in $Elements:
29 1 2 1 7 31 32
30 1 2 1 7 32 33
31 1 2 1 7 33 34
32 1 2 1 7 34 3
Is this way of accessing physical IDs wrong? Or is this some special
behaviour of gmshreader?
By the way I'm using 2.1-svn and also had these problems with the UG
example like in the pdelab howto.
Thanks a lot for your replies,
Alexander Schlaich
On Sat, April 9, 2011 12:09 pm, Jayesh Badwaik wrote:
> Hi,
> thanks for your help
> the code is working properly now.
>
> I was using the Dune::GridPtr<Grid> before as you had suspected.
> I actually got that idea from the dune-pdelab-howto manual
> where they are using the same thing.
> especially the crankdiffusion problem (listing 16).
>
>
>
> Cheers and Regards,
> Jayesh Vinay Badwaik
> -----------------------------------------------------------------------------------------------------------
>
> We are servants rather than masters in mathematics --- Charles Hermite
>
>
>
>
>
>
> On Sat, Apr 9, 2011 at 15:10, Jö Fahlke <jorrit at jorrit.de> wrote:
>
>> Am Sat, 9. Apr 2011, 14:32:31 +0530 schrieb Jayesh Badwaik:
>> > i am trying to use elementid_to_physical_entity feature of the gmsh
>> reader
>> > and the code i'm using is as follows
>> >
>> > std::vector<int> boundaryid;
>> > std::vector<int> elementid;
>> > GridReader gridreader;
>> > GridPointer gridptr = gridreader.read(gridfile, boundaryid,
>> elementid,
>> > true, true);
>>
>> I'm assuming GridPointer is something like Grid*, specifically that it
>> is
>> *not* something like Dune::GridPtr<Grid>.
>>
>> The problem is probably that the GmshReader stores the element and
>> boundary
>> ids in the order the elements and boundary segments were inserted into
>> the
>> grid. Of course, you cannot know this order. You can however obtain it
>> from
>> the gridfactory the GmshReader uses to insert the mesh elements:
>>
>> Dune::GmshReader<Grid> gridreader;
>> Dune::GridFactory<Grid> factory;
>> gridreader.read(factory, gridfile, boundaryid, elementid, true, true);
>> Grid *gridptr = factory.create();
>>
>> and later
>>
>> int eid = elementid[factory.insertionIndex(element)];
>> int bid = 0;
>> if(factory.wasInserted(intersection))
>> bid = boundaryid[factory.insertionIndex(intersection)];
>>
>> Note that calling insertionIndex() is only valid as long as you didn't
>> change
>> the grid since creation -- i.e. no globalRefine(), no adapt(), no
>> loadBalance().
>>
>> @Dune: what is the purpose of those GmshReader::read() methods that fill
>> element and boundary id but don't take a GidFactory?
>>
>> Bye,
>> Jö.
>>
>> --
>> If God had intended Man to Smoke, He would have set him on Fire.
>> -- fortune
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sphere2d.msh
Type: model/mesh
Size: 9918 bytes
Desc: not available
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20110412/f11ee1e7/attachment.msh>
More information about the Dune
mailing list