<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Duners,<br>
maybe someone has had a similar problem.<br>
Ultimately I want to achieve a rotational symmetric 3D boundary,
looking similar to a mushroom / light bulb.<br>
Hence, I started to create a 3D cone segment. However, my code does
crash with an assertion error:<br>
<br>
<blockquote>spine:
/home/mrueckl/opt/alugrid-1.52/include/serial/gitter_tetra_top.h:1116:
ALUGridSpace::TetraTop<A>::TetraTop(int,
ALUGridSpace::TetraTop<A>::myhface3_t*, int,
ALUGridSpace::TetraTop<A>::myhface3_t*, int,
ALUGridSpace::TetraTop<A>::myhface3_t*, int,
ALUGridSpace::TetraTop<A>::myhface3_t*, int,
ALUGridSpace::TetraTop<A>::innertetra_t*, int, double) [with
A = ALUGridSpace::GitterBasis::Objects::TetraEmpty;
ALUGridSpace::TetraTop<A>::myhface3_t =
ALUGridSpace::Gitter::Geometric::hface3;
ALUGridSpace::TetraTop<A>::innertetra_t =
ALUGridSpace::TetraTop<ALUGridSpace::GitterBasis::Objects::TetraEmpty>]:
Assertion `std::abs( calculatedVolume - _volume ) / _volume <
1e-10' failed.<br>
</blockquote>
<br>
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...).<br>
However, adding the z-component leads to the above error :-(<br>
<br>
Any help would be appreciated! <br>
Regards, Martin<br>
<br>
My sample code produces the following macro grid file:<br>
<blockquote><small>!Tetrahedra<br>
4<br>
0.000000e+00 0.000000e+00 0.000000e+00<br>
1.000000e+00 0.000000e+00 0.000000e+00<br>
0.000000e+00 1.000000e+00 0.000000e+00<br>
0.000000e+00 0.000000e+00 1.000000e+00<br>
1<br>
0 1 2 3 <br>
4<br>
-1 3 0 2 1 <br>
-1 3 0 1 3 <br>
-1 3 0 3 2 <br>
-1 3 1 2 3 <br>
0 -1<br>
1 -1<br>
2 -1<br>
3 -1<br>
</small></blockquote>
Here my sample code:<br>
<blockquote><small>#include <math.h><br>
#include <iostream><br>
#include <string><br>
<br>
#include <dune/common/mpihelper.hh><br>
#include <dune/common/exceptions.hh><br>
#include <dune/common/fvector.hh><br>
#include <dune/grid/io/file/gmshwriter.hh><br>
<br>
#include <dune/grid/common/gridfactory.hh><br>
<br>
#include <dune/grid/alugrid.hh><br>
#include <dune/grid/alugrid/3d/alu3dgridfactory.hh><br>
<br>
struct ConeBoundarySegment : public
Dune::BoundarySegment<3,3><br>
{<br>
<br>
virtual Dune::FieldVector<double,3> operator()(const
Dune::FieldVector<double,2> &l) const<br>
{<br>
double x = l[0]; double y = l[1];<br>
<br>
double phi = x*M_PI/2.0;<br>
<br>
Dune::FieldVector<double,3> g(0);<br>
g[0] = std::cos(phi) * (1.-y);<br>
g[1] = std::sin(phi) * (1.-y);<br>
g[2] = y;<br>
return g;<br>
}<br>
};<br>
<br>
int main(int argc, char** argv)<br>
{<br>
try{<br>
<br>
constexpr unsigned dim = 3;<br>
<br>
Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc,
argv);<br>
<br>
typedef Dune::ALUGrid< dim, dim, Dune::simplex,
Dune::nonconforming > Grid;<br>
<br>
Dune::GridFactory<Grid> gf;<br>
<br>
Dune::FieldVector<typename Grid::ctype, dim> pos;<br>
<br>
Dune::GeometryType type(Dune::GeometryType::simplex,dim);<br>
<br>
// A Tetrahedron<br>
<br>
// counter clockwise lower vertices<br>
pos[0] = 0; pos[1] = 0; pos[2] = 0; gf.insertVertex(pos);
unsigned l0 = 0;<br>
pos[0] = 1; pos[1] = 0; pos[2] = 0; gf.insertVertex(pos);
unsigned l1 = 1;<br>
pos[0] = 0; pos[1] = 1; pos[2] = 0; gf.insertVertex(pos);
unsigned l2 = 2;<br>
<br>
// top<br>
pos[0] = 0; pos[1] = 0; pos[2] = 1;
gf.insertVertex(pos); unsigned t = 3;<br>
<br>
gf.insertElement(type, {l0,l1,l2,t});<br>
<br>
// create and insert segment<br>
typedef
Dune::shared_ptr<Dune::BoundarySegment<dim,dim> >
SegmentPointer;<br>
gf.insertBoundarySegment({l1,l2,t},SegmentPointer(new
ConeBoundarySegment()));<br>
<br>
Dune::shared_ptr<Grid> gridp(gf.createGrid());<br>
<br>
gridp->writeMacroGrid("./","macrogrid.txt");<br>
Dune::GmshWriter<typename Grid::LeafGridView>
writer(gridp->leafView());<br>
<br>
writer.write("rr0.gmsh");<br>
gridp->globalRefine(1); <br>
writer.write("rr1.gmsh");<br>
gridp->globalRefine(1); <br>
writer.write("rr2.gmsh");<br>
gridp->globalRefine(1); <br>
writer.write("rr3.gmsh");<br>
gridp->globalRefine(1); <br>
writer.write("r4.gmsh");<br>
gridp->globalRefine(1); <br>
writer.write("r5.gmsh");<br>
}<br>
catch (Dune::Exception &e){<br>
std::cerr << "Dune reported error: " << e
<< std::endl;<br>
}<br>
catch (std::exception &e){<br>
std::cerr << "std::exception thrown: " <<
e.what()<< std::endl;<br>
}<br>
catch(...){<br>
std::cerr << "Unknown exception thrown!" <<
std::endl;<br>
}<br>
}<br>
</small></blockquote>
<br>
<br>
<br>
<br>
</body>
</html>