[Dune] Boundary Segments with 3D ALUGrid

Oliver Sander sander at igpm.rwth-aachen.de
Tue Mar 11 16:03:55 CET 2014


> 
> In 2D I succeeded to create a segment of a circle (but only with the boundary segment, the boundary projection interface provided by ALUGrid did not create a "reasonable" grid...).
> However, adding the z-component leads to the above error :-(
>

Hi Martin,
I can't say anything about your crash, but you may want to be aware of

https://dune-project.org/flyspray/index.php?do=details&task_id=1269&project=1&pagenum=3

Cheers,
Oliver


> Any help would be appreciated!
> Regards, Martin
> 
> My sample code produces the following macro grid file:
> 
>    !Tetrahedra
>    4
>    0.000000e+00 0.000000e+00 0.000000e+00
>    1.000000e+00 0.000000e+00 0.000000e+00
>    0.000000e+00 1.000000e+00 0.000000e+00
>    0.000000e+00 0.000000e+00 1.000000e+00
>    1
>    0  1  2  3
>    4
>    -1  3  0  2  1
>    -1  3  0  1  3
>    -1  3  0  3  2
>    -1  3  1  2  3
>    0 -1
>    1 -1
>    2 -1
>    3 -1
> 
> Here my sample code:
> 
>    #include <math.h>
>    #include <iostream>
>    #include <string>
> 
>    #include <dune/common/mpihelper.hh>
>    #include <dune/common/exceptions.hh>
>    #include <dune/common/fvector.hh>
>    #include <dune/grid/io/file/gmshwriter.hh>
> 
>    #include <dune/grid/common/gridfactory.hh>
> 
>    #include <dune/grid/alugrid.hh>
>    #include <dune/grid/alugrid/3d/alu3dgridfactory.hh>
> 
>    struct ConeBoundarySegment : public Dune::BoundarySegment<3,3>
>    {
> 
>       virtual Dune::FieldVector<double,3> operator()(const
>    Dune::FieldVector<double,2> &l) const
>       {
>         double x = l[0];    double y = l[1];
> 
>         double phi  = x*M_PI/2.0;
> 
>         Dune::FieldVector<double,3> g(0);
>         g[0] = std::cos(phi) * (1.-y);
>         g[1] = std::sin(phi) * (1.-y);
>         g[2] = y;
>         return g;
>       }
>    };
> 
>    int main(int argc, char** argv)
>    {
>       try{
> 
>       constexpr unsigned dim = 3;
> 
>       Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
> 
>       typedef Dune::ALUGrid< dim, dim, Dune::simplex,
>    Dune::nonconforming > Grid;
> 
>       Dune::GridFactory<Grid> gf;
> 
>       Dune::FieldVector<typename Grid::ctype, dim> pos;
> 
>       Dune::GeometryType type(Dune::GeometryType::simplex,dim);
> 
>        // A Tetrahedron
> 
>        // counter clockwise lower vertices
>        pos[0] = 0; pos[1] =   0; pos[2] = 0; gf.insertVertex(pos);
>    unsigned l0 = 0;
>        pos[0] = 1; pos[1] =   0; pos[2] = 0; gf.insertVertex(pos);
>    unsigned l1 = 1;
>        pos[0] = 0; pos[1] =   1; pos[2] = 0; gf.insertVertex(pos);
>    unsigned l2 = 2;
> 
>        // top
>        pos[0] = 0;   pos[1] = 0;   pos[2] = 1; gf.insertVertex(pos);    unsigned t  = 3;
> 
>        gf.insertElement(type, {l0,l1,l2,t});
> 
>       // create and insert segment
>       typedef Dune::shared_ptr<Dune::BoundarySegment<dim,dim> >
>    SegmentPointer;
>       gf.insertBoundarySegment({l1,l2,t},SegmentPointer(new
>    ConeBoundarySegment()));
> 
>       Dune::shared_ptr<Grid> gridp(gf.createGrid());
> 
>       gridp->writeMacroGrid("./","macrogrid.txt");
>       Dune::GmshWriter<typename Grid::LeafGridView>
>    writer(gridp->leafView());
> 
>       writer.write("rr0.gmsh");
>       gridp->globalRefine(1);
>       writer.write("rr1.gmsh");
>       gridp->globalRefine(1);
>       writer.write("rr2.gmsh");
>       gridp->globalRefine(1);
>       writer.write("rr3.gmsh");
>       gridp->globalRefine(1);
>       writer.write("r4.gmsh");
>       gridp->globalRefine(1);
>       writer.write("r5.gmsh");
>       }
>       catch (Dune::Exception &e){
>         std::cerr << "Dune reported error: " << e << std::endl;
>       }
>       catch (std::exception &e){
>         std::cerr << "std::exception thrown: " << e.what()<< std::endl;
>       }
>       catch(...){
>         std::cerr << "Unknown exception thrown!" << std::endl;
>       }
>    }
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 534 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20140311/9d635f23/attachment.sig>


More information about the Dune mailing list