Netgen 4.9.11 compatibility

This commit is contained in:
adam 2009-10-26 17:13:37 +00:00
parent 5ca9caacaa
commit 9744d220ed
7 changed files with 215 additions and 16 deletions

View File

@ -35,6 +35,8 @@ AC_ARG_WITH(netgen,
NETGEN_INCLUDES=""
NETGEN_LIBS_DIR=""
NETGEN_LIBS=""
NETGEN_NEW=no
Netgen_ok=no
@ -52,29 +54,29 @@ fi
if test "x$NETGEN_HOME" != "x"; then
echo
echo
echo -------------------------------------------------
if test -f ${NETGEN_HOME}/lib/libnglib.so ; then
NETGEN_NEW=yes
fi
echo ----------------------------------------------------------
echo ----------------------------------------------------------
echo You are about to choose to use somehow the
echo Netgen Library to generate Tetrahedric mesh.
echo
echo WARNING
echo ----------------------------------------------------------
echo ----------------------------------------------------------
echo You are strongly advised to consult the file
echo NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers, particularly about
echo assumptions made on the installation of the Netgen
echo NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers, particularly
echo about assumptions made on the installation of the Netgen
echo application and libraries.
echo Ask your system administrator for those details.
echo ----------------------------------------------------------
echo ----------------------------------------------------------
echo
echo
NETGEN_INCLUDES="-I${NETGEN_HOME}/include"
if test "$NETGEN_NEW" = "yes" ; then
NETGEN_INCLUDES="${NETGEN_INCLUDES} -DNETGEN_NEW -I${NETGEN_HOME}/share/salome/include"
fi
# check ${NETGEN_HOME}/lib/LINUX directory for libraries
if test -f ${NETGEN_HOME}/lib/LINUX/libcsg.a ; then
NETGEN_LIBS_DIR="${NETGEN_HOME}/lib/LINUX"
@ -99,6 +101,8 @@ if test "x$NETGEN_HOME" != "x"; then
AC_CHECK_HEADER(nglib.h,Netgen_ok=yes,Netgen_ok=no)
if test "x$Netgen_ok" == "xyes"; then
if test "$NETGEN_NEW" = "no" ; then
AC_MSG_CHECKING(for Netgen libraries)
LDFLAGS_old="$LDFLAGS"
@ -146,6 +150,81 @@ namespace nglib {
])
Netgen_ok="$salome_cv_netgen_lib"
else
LDFLAGS_old="$LDFLAGS"
LDFLAGS="-L${NETGEN_LIBS_DIR} -lnglib $CAS_LDPATH -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKSTL -lTKTopAlgo $LDFLAGS"
AC_MSG_CHECKING(for official Netgen libraries)
AC_CACHE_VAL(salome_cv_netgen_lib,[
AC_TRY_LINK([
#include <iostream>
#include <fstream>
namespace nglib {
#include "nglib.h"
}
],[
nglib::Ng_Init();
nglib::Ng_Exit();
],
[eval "salome_cv_netgen_lib=yes"],
[eval "salome_cv_netgen_lib=no"])
])
Netgen_ok="$salome_cv_netgen_lib"
if test "$Netgen_ok" = "yes" ; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(for occ support in Netgen libraries)
AC_CACHE_VAL(salome_cv_netgen_occ_lib,[
AC_TRY_LINK([
#include <iostream>
#include <fstream>
#define OCCGEOMETRY
namespace nglib {
#include "nglib.h"
}
],[
nglib::Ng_Init();
nglib::Ng_OCC_Geometry * ng_occ_geom = nglib::Ng_OCC_NewGeometry();
nglib::Ng_Exit();
],
[eval "salome_cv_netgen_occ_lib=yes"],
[eval "salome_cv_netgen_occ_lib=no"])
])
Netgen_ok="$salome_cv_netgen_occ_lib"
fi
if test "$Netgen_ok" = "yes" ; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(for salome patch in Netgen installation)
AC_CACHE_VAL(salome_cv_netgen_salome_patch_lib,[
AC_TRY_LINK([
#include <iostream>
#include <fstream>
#define OCCGEOMETRY
namespace nglib {
#include "nglib.h"
}
#include <occgeom.hpp>
],[
nglib::Ng_Init();
netgen::OCCGeometry occgeo;
nglib::Ng_Exit();
],
[eval "salome_cv_netgen_salome_patch_lib=yes"],
[eval "salome_cv_netgen_salome_patch_lib=no"])
])
Netgen_ok="$salome_cv_netgen_salome_patch_lib"
fi
if test "x$Netgen_ok" == xno ; then
AC_MSG_RESULT(no)
AC_MSG_ERROR(Netgen is not properly installed)
fi
NETGEN_LIBS="-L${NETGEN_LIBS_DIR} -lnglib"
fi
LDFLAGS="$LDFLAGS_old"
fi
@ -163,6 +242,8 @@ fi
AC_SUBST(NETGEN_INCLUDES)
AC_SUBST(NETGEN_LIBS_DIR)
AC_SUBST(NETGEN_LIBS)
AM_CONDITIONAL(NETGEN_NEW, [test x"$NETGEN_NEW" = x"yes"])
AC_LANG_RESTORE

View File

@ -27,7 +27,11 @@
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
SUBDIRS = NETGEN NETGENPlugin
SUBDIRS =
if ! NETGEN_NEW
SUBDIRS += NETGEN
endif
SUBDIRS += NETGENPlugin
if NETGENPLUGIN_ENABLE_GUI
SUBDIRS += GUI

View File

@ -1,3 +1,41 @@
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# Notes for Netgen >= 4.9
# ------------------------------------------------------------------
# ------------------------------------------------------------------
Netgen can be find at http://www.hpfem.jku.at/netgen/
1. How to build Netgen for Netgen Plugin
------------------------------
1.1. Download Netgen archive (here netgen-4.9.11.tar.gz) and unpack it
1.2. Configure the netgen compilation. The "good" options are
../netgen-4.9.11/configure \
--prefix=THE_INSTALLATION_PATH \
--enable-occ --enable-nglib --with-occ=${CASROOT} \
CXXFLAGS="-DOCCGEOMETRY -I${CASROOT}/inc -DHAVE_IOSTREAM -DHAVE_LIMITS -DHAVE_LIMITS_H -DHAVE_IOMANIP -I${TOGL_HOME}/include" \
LDFLAGS="-L${TOGL_HOME}/lib/Togl1.7"
1.3. Compile the netgen product
make then make install
1.4. Patch the installation directory to copy include files
needed by NETGEN Plugin. Use the script
NETGENPLUGIN_SRC/src/NETGEN/netgen_copy_include_for_salome
to achieve that. The first argument is the directory containing
the Netgen sources. The second argument is THE_INSTALLATION_PATH
Erwan ADAM
erwan.adam@cea.fr
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# Notes for Netgen 4.5
# ------------------------------------------------------------------
# ------------------------------------------------------------------
The Netgen 4.5 from the web location : http://www.hpfem.jku.at/netgen/
(CVS access) is used in the SMESH Module of Salome3 distribution.
@ -92,3 +130,8 @@ The suggested patch alters some Netgen sources to compile them.
Michael SAZONOV
m-sazonov@opencascade.com
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# ------------------------------------------------------------------

View File

@ -0,0 +1,23 @@
#!/bin/sh
src_dir=$1
install_dir=$2
if ! test -d $src_dir/libsrc ; then
echo "No dir $src_dir/libsrc ... Bye"
exit 1
fi
if ! test -d $install_dir/share/netgen ; then
echo "No dir $install_dir/share/netgen ... Bye"
exit 1
fi
dest_dir=$install_dir/share/salome/include
mkdir -p $dest_dir > /dev/null 2>&1
cp -af $src_dir/libsrc/occ/*.hpp $dest_dir
cp -af $src_dir/libsrc/meshing/*.hpp $dest_dir
cp -af $src_dir/libsrc/general/*.hpp $dest_dir
cp -af $src_dir/libsrc/gprim/*.hpp $dest_dir
cp -af $src_dir/libsrc/linalg/*.hpp $dest_dir
cp -af $src_dir/libsrc/include/mystdlib.h $dest_dir
cp -af $src_dir/libsrc/include/mydefs.hpp $dest_dir

View File

@ -84,8 +84,13 @@ libNETGENEngine_la_CPPFLAGS = \
$(BOOST_CPPFLAGS) \
-I$(top_builddir)/idl
libNETGENEngine_la_LDFLAGS = \
../NETGEN/libNETGEN.la \
if ! NETGEN_NEW
libNETGENEngine_la_LDFLAGS = ../NETGEN/libNETGEN.la
else
libNETGENEngine_la_LDFLAGS = $(NETGEN_LIBS)
endif
libNETGENEngine_la_LDFLAGS += \
../../idl/libSalomeIDLNETGENPLUGIN.la \
$(CAS_LDPATH) -lTKernel -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKMesh -lTKSTL -lTKG3d -lTKTopAlgo -lTKG2d -lTKBool -lTKGeomAlgo -lTKOffset -lTKGeomBase -lTKBO \
$(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine -lStdMeshersEngine -lStdMeshers -lSMESHDS -lSMDS -lSMESHControls \

View File

@ -276,6 +276,10 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo,
}
occgeo.facemeshstatus.SetSize (occgeo.fmap.Extent());
occgeo.facemeshstatus = 0;
#ifdef NETGEN_NEW
occgeo.face_maxh.SetSize(occgeo.fmap.Extent());
occgeo.face_maxh = netgen::mparam.maxh;
#endif
}
@ -384,8 +388,13 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom,
netgen::Segment seg;
// ng node ids
#ifdef NETGEN_NEW
seg.pnums[0] = prevNgId;
seg.pnums[1] = prevNgId = ngNodeId( p2.node, ngMesh, nodeNgIdMap );
#else
seg.p1 = prevNgId;
seg.p2 = prevNgId = ngNodeId( p2.node, ngMesh, nodeNgIdMap );
#endif
// node param on curve
seg.epgeominfo[ 0 ].dist = p1.param;
seg.epgeominfo[ 1 ].dist = p2.param;
@ -411,7 +420,11 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom,
seg.epgeominfo[ 1 ].v = otherSeamParam;
swap (seg.epgeominfo[0].u, seg.epgeominfo[1].u);
}
#ifdef NETGEN_NEW
swap (seg.pnums[0], seg.pnums[1]);
#else
swap (seg.p1, seg.p2);
#endif
swap (seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
seg.edgenr = ngMesh.GetNSeg() + 1; // segment id
ngMesh.AddSegment (seg);
@ -748,7 +761,11 @@ bool NETGENPlugin_Mesher::Compute()
newNodeOnVertex = true;
}
if (!node)
#ifdef NETGEN_NEW
node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
#else
node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
#endif
if (!node)
{
MESSAGE("Cannot create a mesh node");
@ -770,12 +787,20 @@ bool NETGENPlugin_Mesher::Compute()
for (i = nbInitSeg+1; i <= nbSeg/* && isOK*/; ++i )
{
const netgen::Segment& seg = ngMesh->LineSegment(i);
#ifdef NETGEN_NEW
Link link(seg.pnums[0], seg.pnums[1]);
#else
Link link(seg.p1, seg.p2);
#endif
if (linkMap.Contains(link))
continue;
linkMap.Add(link);
TopoDS_Edge aEdge;
#ifdef NETGEN_NEW
int pinds[3] = { seg.pnums[0], seg.pnums[1], seg.pnums[2] };
#else
int pinds[3] = { seg.p1, seg.p2, seg.pmid };
#endif
int nbp = 0;
double param2 = 0;
for (int j=0; j < 3; ++j)
@ -966,6 +991,7 @@ void NETGENPlugin_Mesher::RemoveTmpFiles()
{
removeFile("test.out");
removeFile("problemfaces");
removeFile("occmesh.rep");
}

View File

@ -231,8 +231,13 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
// Add the segment
Segment seg;
#ifdef NETGEN_NEW
seg.pnums[0] = ngMesh.GetNP(); // ng node id
seg.pnums[1] = seg.pnums[0] + 1; // ng node id
#else
seg.p1 = ngMesh.GetNP(); // ng node id
seg.p2 = seg.p1 + 1; // ng node id
#endif
seg.edgenr = ngMesh.GetNSeg() + 1;// segment id
seg.si = faceID; // = geom.fmap.FindIndex (face);
@ -263,7 +268,11 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
// 20526: [CEA] Disk meshing fails
if (reverse)
{
#ifdef NETGEN_NEW
swap (seg.pnums[0], seg.pnums[1]);
#else
swap (seg.p1, seg.p2);
#endif
swap (seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
swap (seg.epgeominfo[0].u, seg.epgeominfo[1].u);
swap (seg.epgeominfo[0].v, seg.epgeominfo[1].v);
@ -282,7 +291,11 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
// << "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl;
}
Segment& seg = ngMesh.LineSegment( ngMesh.GetNSeg() );
#ifdef NETGEN_NEW
seg.pnums[1] = firstPointID;
#else
seg.p2 = firstPointID;
#endif
}
ngMesh.CalcSurfacesOfNode();
@ -417,7 +430,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
for ( int i = nbInputNodes + 1; i <= nbNodes; ++i )
{
const MeshPoint& ngPoint = ngMesh->Point(i);
#ifdef NETGEN_NEW
SMDS_MeshNode * node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
#else
SMDS_MeshNode * node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
#endif
nodeVec[ i-1 ] = node;
}