I am working on a C++ shape optimization project with a HDG solver which interfaces Netgen. I am exclusively working with spline geometries from the SplineGeometry2D class.
For this project, I would like to modify the coordinates of the geometry points (one at a time) in the normal direction. To do that, I have access to a shared pointer , from which I access the Netgen geometry through:
Up to that, everything works fine. But I would like to use the routines of SplineGeometry2d (such as GetSpline()) so I tried to cast my NetgenGeometry shared_ptr to a SplineGeometry2d shared_ptr (knowing SplineGeometry2d is a derived class of NetgenGeometry) with:
Thank you very much for your reply! I followed your advice but whenever I add #include <geometry2d.hpp> (even if the rest of the function is empty), I have new error messages:
In file included from /home/joachim/Documents/ResearchProject/ngsuite/ngsolve-install/bin/../include/include/geometry2d.hpp:1:0,
from ShapeOptimization/deformgeometry.h:1,
from main.cpp:406:
/home/joachim/Documents/ResearchProject/ngsuite/ngsolve-install/bin/../include/include/../geom2d/geometry2d.hpp:21:40: error: expected template-name before ‘<’ token
class SplineSegExt : public SplineSeg<2>
^
/home/joachim/Documents/ResearchProject/ngsuite/ngsolve-install/bin/../include/include/../geom2d/geometry2d.hpp:21:40: error: expected ‘{’ before ‘<’ token
/home/joachim/Documents/ResearchProject/ngsuite/ngsolve-install/bin/../include/include/../geom2d/geometry2d.hpp:21:40: error: expected unqualified-id before ‘<’ token
/home/joachim/Documents/ResearchProject/ngsuite/ngsolve-install/bin/../include/include/../geom2d/geometry2d.hpp:131:49: error: expected template-name before ‘<’ token
class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry
^
/home/joachim/Documents/ResearchProject/ngsuite/ngsolve-install/bin/../include/include/../geom2d/geometry2d.hpp:131:49: error: expected ‘{’ before ‘<’ token
/home/joachim/Documents/ResearchProject/ngsuite/ngsolve-install/bin/../include/include/../geom2d/geometry2d.hpp:131:49: error: expected unqualified-id before ‘<’ token
I tried to sort out the issue, and I thought that it could come from the fact that the compiler does not know SplineSeg and SplineGeometry at the time geometry2d.hpp is defined. So I tried to include these with:
before the #include “geometry2d.hpp” but that does not change anything to the errors.
I am a bit out of ideas because #include <gprim.hpp> and #include <meshing.hpp> do not trigger any errors, it is only the #include <geometry2d.hpp> which causes my troubles.
[EDIT: problem solved]
I put #include <geometry2d.hpp> at the top of my main file and everything runs smoothly now.