Merge branch 'master' into par_fixes

This commit is contained in:
Lukas Kogler 2017-03-22 14:03:11 +01:00
commit d24b996c8f
41 changed files with 501 additions and 279 deletions

View File

@ -138,7 +138,12 @@ test_win64:
.template_test_linux: &test_linux
stage: test
script:
- docker run netgen_${CI_BUILD_REF_NAME}_installed:${UBUNTU_VERSION} bash -c 'cd /root/build/netgen && make test_netgen ARGS="-V"'
- >-
docker run
-e NETGENDIR=/opt/netgen/bin
-e PYTHONPATH=/opt/netgen/lib/python3/dist-packages
netgen_${CI_BUILD_REF_NAME}_installed:${UBUNTU_VERSION}
bash -c 'cd /root/build/netgen && make test_netgen ARGS="-V"'
test_ubuntu_1510:
<<: *ubuntu_1510
@ -151,6 +156,20 @@ test_ubuntu_1604:
# Deploy stage
############################################
deploy_sourceforge:
stage: deploy
tags:
- linux
- docker
script:
- git remote add sourceforge ssh://mhochste@git.code.sf.net/p/netgen-mesher/git || true
- git remote update
- git checkout master
- git pull origin master
- git push sourceforge master
only:
- master
############################################
# Cleanup stage
############################################

View File

@ -19,11 +19,13 @@ option( USE_CCACHE "use ccache")
option( USE_SUPERBUILD "use ccache" ON)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_modules")
if (USE_SUPERBUILD)
project (SUPERBUILD)
# execute the superbuild (this script will be invoked again without the
# USE_SUPERBUILD option this time)
include (cmake_modules/SuperBuild.cmake)
include (cmake/SuperBuild.cmake)
return() # stop processing this file further
else()
project(Netgen)
@ -40,10 +42,9 @@ set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
#######################################################################
if(USE_CCACHE)
find_program(CCACHE_FOUND ccache)
find_program(CCACHE_FOUND NAMES ccache ccache.bat)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
endif(CCACHE_FOUND)
endif(USE_CCACHE)
@ -55,7 +56,7 @@ endif(USE_NATIVE_ARCH)
#######################################################################
if(INTEL_MIC)
set(MKL_ARCH "mic")
include(cmake_modules/mic.cmake)
include(cmake/mic.cmake)
else(INTEL_MIC)
set(MKL_ARCH "intel64")
endif(INTEL_MIC)
@ -69,7 +70,7 @@ if (ADDITIONAL_PATHS)
endif (ADDITIONAL_PATHS)
if(APPLE)
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Netgen.app/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
else(APPLE)
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
endif(APPLE)
@ -94,7 +95,6 @@ include_directories ("${PROJECT_SOURCE_DIR}/libsrc/include")
include_directories ("${PROJECT_BINARY_DIR}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake_modules")
set(INCDIR include CACHE PATH "install directory for header files")
if(APPLE)
@ -241,15 +241,15 @@ endif(INSTALL_PROFILES)
#######################################################################
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake "\
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/netgen_fixup.cmake)
set(APP ${INSTALL_DIR}/Netgen.app)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/netgen_fixup.cmake)
set(APP ${INSTALL_DIR})
message(\${APP})
set(BU_CHMOD_BUNDLE_ITEMS ON)
file(GLOB libs ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.dylib ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.so)
message(\"\${libs}\")
netgen_fixup_bundle( \${APP}/Contents/MacOS/netgen \"\${libs}\" ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib} )
execute_process(COMMAND ln -s /Applications ${INSTALL_DIR}/Applications)
execute_process(COMMAND ln -s /Applications ${INSTALL_DIR}/../Applications)
set (bundle_filename \$ENV{NETGEN_BUNDLE_NAME})
if(NOT bundle_filename)
set(bundle_filename netgen)
@ -258,6 +258,11 @@ execute_process(COMMAND hdiutil create -volname Netgen -srcfolder ${INSTALL_DIR}
")
add_custom_target(bundle COMMAND ${CMAKE_COMMAND} "-P" "${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake")
#######################################################################
# CTest
enable_testing()
include(CTest)
#######################################################################
add_subdirectory(libsrc)
add_subdirectory(ng)
@ -269,13 +274,9 @@ add_subdirectory(py_tutorials)
add_subdirectory(doc)
add_subdirectory(windows)
add_subdirectory(nglib)
add_subdirectory(tests)
#######################################################################
# CTest
enable_testing()
include(CTest)
#######################################################################
# Debian packager
@ -366,13 +367,13 @@ endif()
#######################################################################
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/NetgenConfig.cmake.in
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake DESTINATION share/cmake)

View File

@ -6,8 +6,6 @@ set (NETGEN_DEPENDENCIES)
set (LAPACK_DEPENDENCIES)
set (NETGEN_CMAKE_ARGS "" CACHE INTERNAL "")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake_modules")
macro(set_vars VAR_OUT)
foreach(varname ${ARGN})
if(NOT "${${varname}}" STREQUAL "")
@ -45,8 +43,8 @@ endif(WIN32)
#######################################################################
# find netgen
if(APPLE)
set(INSTALL_DIR /Applications CACHE PATH "Install path")
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Netgen.app/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
set(INSTALL_DIR /Applications/Netgen.app CACHE PATH "Install path")
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
else(APPLE)
set(INSTALL_DIR /opt/netgen CACHE PATH "Install path")
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
@ -105,9 +103,23 @@ endif(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR)
#######################################################################
if(USE_GUI)
include(cmake_modules/ExternalProject_TCLTK.cmake)
include(cmake/external_projects/tcltk.cmake)
endif(USE_GUI)
#######################################################################
if(USE_MPI)
if(UNIX)
find_package(METIS QUIET)
if(NOT METIS_FOUND)
message(STATUS "Could not find METIS, it will be built from source")
include(cmake/external_projects/metis.cmake)
endif()
else(UNIX)
find_package(METIS REQUIRED)
endif(UNIX)
endif(USE_MPI)
#######################################################################
# propagate cmake variables to Netgen subproject
set_vars( NETGEN_CMAKE_ARGS
@ -164,14 +176,14 @@ ExternalProject_Add (netgen
# Check if the git submodules (i.e. pybind11) are up to date
# in case, something is wrong, emit a warning but continue
ExternalProject_Add_Step(netgen check_submodules
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/check_submodules.cmake
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
DEPENDERS install # Steps on which this step depends
)
# Due to 'ALWAYS 1', this step is always run which also forces a build of
# the Netgen subproject
ExternalProject_Add_Step(netgen check_submodules1
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/check_submodules.cmake
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
DEPENDEES configure # Steps on which this step depends
DEPENDERS build # Steps that depend on this step
ALWAYS 1 # No stamp file, step always runs

View File

@ -49,14 +49,8 @@ if (METIS_INCLUDE_DIR)
NAMES ${metis_inc_names}
HINTS ${METIS_INCLUDE_DIR}
NO_DEFAULT_PATH)
if(NOT metis_test_include_path)
message(SEND_ERROR "Can not locate ${metis_inc_names} in ${METIS_INCLUDE_DIR}")
endif()
set(METIS_INCLUDE_DIR "${metis_test_include_path}")
else()
message(SEND_ERROR "METIS_INCLUDE_DIR=${METIS_INCLUDE_DIR} does not exist")
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
endif()
endif()
else()
# Metis sometimes puts the include files in a subdir called Lib
set(metis_inc_suffixes "include" "Lib")
@ -67,9 +61,6 @@ if(METIS_DIR)
HINTS ${METIS_DIR}
PATH_SUFFIXES ${metis_inc_suffixes}
NO_DEFAULT_PATH)
else()
message(SEND_ERROR "METIS_DIR=${METIS_DIR} does not exist")
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
endif()
else()
find_path(METIS_INCLUDE_DIR
@ -77,9 +68,6 @@ else()
PATH_SUFFIXES ${metis_inc_suffixes})
endif()
endif()
if ( NOT METIS_INCLUDE_DIR )
message(SEND_ERROR "Can not locate METIS include directory")
endif()
# Search for libraries
# Search order preference:
# (1) METIS_LIBRARY_DIR - check existence of path AND if the library file exists
@ -93,9 +81,6 @@ if (METIS_LIBRARY_DIR)
NAMES ${metis_lib_names}
HINTS ${METIS_LIBRARY_DIR}
NO_DEFAULT_PATH)
else()
message(SEND_ERROR "METIS_LIBRARY_DIR=${METIS_LIBRARY_DIR} does not exist")
set(METIS_LIBRARY "METIS_LIBRARY-NOTFOUND")
endif()
else()
list(APPEND metis_lib_suffixes "lib" "Lib")
@ -106,9 +91,6 @@ if(METIS_DIR)
HINTS ${METIS_DIR}
PATH_SUFFIXES ${metis_lib_suffixes}
NO_DEFAULT_PATH)
else()
message(SEND_ERROR "METIS_DIR=${METIS_DIR} does not exist")
set(METISLIBRARY "METIS_LIBRARY-NOTFOUND")
endif()
else()
find_library(METIS_LIBRARY
@ -116,9 +98,6 @@ else()
PATH_SUFFIXES ${metis_lib_suffixes})
endif()
endif()
if ( NOT METIS_LIBRARY )
message(SEND_ERROR "Can not locate METIS library")
endif()
# Define prerequisite packages
set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})

View File

@ -0,0 +1,18 @@
set(METIS_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_metis)
set(METIS_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/metis)
ExternalProject_Add(project_metis
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dependencies
URL "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
URL_MD5 5465e67079419a69e0116de24fce58fe
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
CMAKE_ARGS
-DGKLIB_PATH=${METIS_SRC_DIR}/GKlib
-DCMAKE_INSTALL_PREFIX=${METIS_DIR}
UPDATE_COMMAND "" # Disable update
BUILD_IN_SOURCE 1
)
set_vars( NETGEN_CMAKE_ARGS METIS_DIR )
list(APPEND NETGEN_DEPENDENCIES project_metis)

View File

@ -1,12 +1,12 @@
if(APPLE)
set(HOME $ENV{HOME})
set(tcl_prefix ${CMAKE_INSTALL_PREFIX}/../../)
ExternalProject_Add(tcl
ExternalProject_Add(project_tcl
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tcl8.6.4-src.tar.gz"
URL_MD5 d7cbb91f1ded1919370a30edd1534304
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
UPDATE_COMMAND "" # Disable update
CONFIGURE_COMMAND ../tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin
CONFIGURE_COMMAND ../project_tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin
BUILD_COMMAND make -j4 binaries libraries
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
LOG_DOWNLOAD 1
@ -15,13 +15,13 @@ if(APPLE)
LOG_INSTALL 1
)
ExternalProject_Add(tk
DEPENDS tcl
ExternalProject_Add(project_tk
DEPENDS project_tcl
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tk8.6.4-src.tar.gz"
URL_MD5 261754d7dc2a582f00e35547777e1fea
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
UPDATE_COMMAND "" # Disable update
CONFIGURE_COMMAND ../tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework
CONFIGURE_COMMAND ../project_tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework
BUILD_COMMAND make -j4 binaries libraries
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
LOG_DOWNLOAD 1
@ -47,7 +47,7 @@ if(APPLE)
#LOG_INSTALL 1
#)
list(APPEND NETGEN_DEPENDENCIES tcl tk)
list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}../Frameworks)
set(TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework/Headers)
set(TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework)
@ -56,7 +56,7 @@ if(APPLE)
elseif(WIN32)
ExternalProject_Add(win_extlibs
ExternalProject_Add(project_win_extlibs
URL ${EXT_LIBS_DOWNLOAD_URL_WIN}
UPDATE_COMMAND "" # Disable update
BUILD_IN_SOURCE 1
@ -66,7 +66,7 @@ elseif(WIN32)
LOG_DOWNLOAD 1
)
list(APPEND NETGEN_DEPENDENCIES win_extlibs)
list(APPEND NETGEN_DEPENDENCIES project_win_extlibs)
else(WIN32)
find_package(TCL 8.5 REQUIRED)
endif(APPLE)

View File

@ -10,7 +10,6 @@
#include <myadt.hpp>
#include <gprim.hpp>
#include <meshing.hpp>
// #include <geometry2d.hpp>
#include "../gprim/spline.hpp"
#include "../gprim/splinegeometry.hpp"
@ -21,12 +20,12 @@
#include "solid.hpp"
#include "identify.hpp"
#include "singularref.hpp"
#include "splinesurface.hpp"
#include "csgeom.hpp"
#include "csgparser.hpp"
#include "triapprox.hpp"
#include "algprim.hpp"
#include "splinesurface.hpp"
#include "brick.hpp"
#include "spline3d.hpp"
#include "manifold.hpp"

View File

@ -345,7 +345,25 @@ namespace netgen
const ExtrusionFace * ef = dynamic_cast< const ExtrusionFace * > (GetSurface(i));
const RevolutionFace * rf = dynamic_cast< const RevolutionFace * > (GetSurface(i));
const DummySurface * dummyf = dynamic_cast< const DummySurface * > (GetSurface(i));
const SplineSurface * splines = dynamic_cast<const SplineSurface *> (GetSurface(i));
if (splines)
{
splines->GetBase()->GetPrimitiveData(classname,coeffs);
out << classname << " " << coeffs.Size() << "\n";
for (int j=0; j<coeffs.Size(); j++)
out << coeffs[j] << " ";
out << "\n";
for (auto cut : *(splines->GetCuts()))
{
cut->GetPrimitiveData(classname,coeffs);
out << classname << " " << coeffs.Size() << "\n";
for (int j=0; j<coeffs.Size(); j++)
out << coeffs[j] << " ";
out << "\n";
}
return;
}
if(sp)
{
@ -819,6 +837,7 @@ namespace netgen
int inv;
int nsurf = GetNSurf();
isidenticto.SetSize(nsurf);
for (int i = 0; i < nsurf; i++)
isidenticto[i] = i;

View File

@ -143,6 +143,9 @@ namespace netgen
/// filename of inputfile
string filename;
/// store splinesurfaces, such that added ones do not get deleted before geometry does
Array<shared_ptr<SplineSurface>> spline_surfaces;
public:
CSGeometry ();
CSGeometry (const string & afilename);
@ -316,6 +319,8 @@ namespace netgen
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
virtual const Refinement & GetRefinement () const;
void AddSplineSurface (shared_ptr<SplineSurface> ss) { spline_surfaces.Append(ss); }
};

View File

@ -491,7 +491,7 @@ namespace netgen
if(splinesurface)
{
auto name = splinesurface->GetBCNameOf(specpoints[startpoints.Get(refedges[i].edgenr)].p,specpoints[endpoints.Get(refedges[i].edgenr)].p);
mesh.SetCD2Name(refedges[i].edgenr,*name);
mesh.SetCD2Name(refedges[i].edgenr,name);
}
else
{
@ -499,7 +499,7 @@ namespace netgen
if(splinesurface2)
{
auto name = splinesurface2->GetBCNameOf(specpoints[startpoints.Get(refedges[i].edgenr)].p,specpoints[endpoints.Get(refedges[i].edgenr)].p);
mesh.SetCD2Name(refedges[i].edgenr,*name);
mesh.SetCD2Name(refedges[i].edgenr,name);
}
}

View File

@ -207,11 +207,11 @@ DLL_HEADER void ExportCSG(py::module &m)
;
py::class_<SplineSurface, shared_ptr<SplineSurface>> (m, "SplineSurface",
"A surface for co dim 2 integrals on the splines")
"A surface for co dim 2 integrals on the splines")
.def("__init__", FunctionPointer ([](SplineSurface* instance, shared_ptr<SPSolid> base, py::list cuts)
{
auto primitive = dynamic_cast<OneSurfacePrimitive*> (base->GetSolid()->GetPrimitive());
auto acuts = new Array<OneSurfacePrimitive*>();
auto acuts = make_shared<Array<shared_ptr<OneSurfacePrimitive>>>();
for(int i = 0; i<py::len(cuts);i++)
{
py::extract<shared_ptr<SPSolid>> sps(cuts[i]);
@ -219,13 +219,14 @@ DLL_HEADER void ExportCSG(py::module &m)
throw NgException("Cut must be SurfacePrimitive in constructor of SplineSurface!");
auto sp = dynamic_cast<OneSurfacePrimitive*>(sps()->GetSolid()->GetPrimitive());
if(sp)
acuts->Append(sp);
acuts->Append(shared_ptr<OneSurfacePrimitive>(sp));
else
throw NgException("Cut must be SurfacePrimitive in constructor of SplineSurface!");
}
if(!primitive)
throw NgException("Base is not a SurfacePrimitive in constructor of SplineSurface!");
new (instance) SplineSurface(primitive,acuts);
new (instance) SplineSurface(shared_ptr<OneSurfacePrimitive>(primitive),acuts);
py::object obj = py::cast(instance);
}),py::arg("base"), py::arg("cuts")=py::list())
.def("AddPoint", FunctionPointer
([] (SplineSurface & self, double x, double y, double z, bool hpref)
@ -237,8 +238,8 @@ DLL_HEADER void ExportCSG(py::module &m)
.def("AddSegment", FunctionPointer
([] (SplineSurface & self, int i1, int i2, string bcname, double maxh)
{
auto str = new string(bcname);
self.AppendSegment(new LineSeg<3>(self.GetPoint(i1),self.GetPoint(i2)),str,maxh);
auto seg = make_shared<LineSeg<3>>(self.GetPoint(i1),self.GetPoint(i2));
self.AppendSegment(seg,bcname,maxh);
}),
py::arg("pnt1"),py::arg("pnt2"),py::arg("bcname")="default", py::arg("maxh")=-1.)
;
@ -373,7 +374,7 @@ DLL_HEADER void ExportCSG(py::module &m)
self.Save (filename);
}))
.def("Add",
[] (CSGeometry & self, shared_ptr<SPSolid> solid, py::list bcmod)
[] (CSGeometry & self, shared_ptr<SPSolid> solid, py::list bcmod, double maxh)
{
solid->AddSurfaces (self);
solid->GiveUpOwner();
@ -381,6 +382,7 @@ DLL_HEADER void ExportCSG(py::module &m)
self.GetTopLevelObject(tlonr) -> SetMaterial(solid->GetMaterial());
self.GetTopLevelObject(tlonr) -> SetRGB(solid->GetRed(),solid->GetGreen(),solid->GetBlue());
self.GetTopLevelObject(tlonr)->SetTransparent(solid->IsTransparent());
self.GetTopLevelObject(tlonr)->SetMaxH(maxh);
// bcmod is list of tuples ( solid, bcnr )
for (int i = 0; i < py::len(bcmod); i++)
@ -410,7 +412,7 @@ DLL_HEADER void ExportCSG(py::module &m)
}
return tlonr;
},
py::arg("solid"), py::arg("bcmod")=py::list()
py::arg("solid"), py::arg("bcmod")=py::list(), py::arg("maxh")=1e99
)
.def("AddSurface", FunctionPointer
@ -433,14 +435,15 @@ DLL_HEADER void ExportCSG(py::module &m)
([] (CSGeometry & self, shared_ptr<SplineSurface> surf)
{
auto cuttings = surf->CreateCuttingSurfaces();
auto spsol = make_shared<SPSolid>(new Solid(&*surf));
auto spsol = make_shared<SPSolid>(new Solid(surf.get()));
for(auto cut : (*cuttings)){
spsol = make_shared<SPSolid>(SPSolid::SECTION,spsol,make_shared<SPSolid>(new Solid(cut)));
spsol = make_shared<SPSolid>(SPSolid::SECTION,spsol,make_shared<SPSolid>(new Solid(cut.get())));
}
spsol->AddSurfaces(self);
int tlonr = self.SetTopLevelObject(spsol->GetSolid(), &*surf);
int tlonr = self.SetTopLevelObject(spsol->GetSolid(), surf.get());
for(auto p : surf->GetPoints())
self.AddUserPoint(p);
self.AddSplineSurface(surf);
}),
py::arg("SplineSurface"))

View File

@ -10,14 +10,14 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const
geompoints.Last().hpref = hpref;
}
void SplineSurface :: AppendSegment(SplineSeg<3>* spline, string* bcname, double amaxh)
void SplineSurface :: AppendSegment(shared_ptr<SplineSeg<3>> sp, string & bcname, double amaxh)
{
splines.Append(spline);
splines.Append(sp);
bcnames.Append(bcname);
maxh.Append(amaxh);
}
string* SplineSurface :: GetBCNameOf (Point<3> p1, Point<3> p2) const
string SplineSurface :: GetBCNameOf (Point<3> p1, Point<3> p2) const
{
double eps = 1e-5;
@ -32,36 +32,44 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const
return bcnames[i];
}
}
return new string("default");
return "default";
}
Array<OneSurfacePrimitive*>* SplineSurface :: CreateCuttingSurfaces() const
const shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> SplineSurface :: CreateCuttingSurfaces()
{
auto cuttings = new Array<OneSurfacePrimitive*>();
if(all_cuts)
return all_cuts;
auto cuttings = make_shared<Array<shared_ptr<OneSurfacePrimitive>>>();
for (auto cut : *cuts)
cuttings->Append(cut);
for(int i = 0; i<splines.Size(); i++)
{
auto spline = splines[i];
auto lineseg = dynamic_cast<LineSeg<3>*>(spline);
auto p1 = Point<3>(spline->GetPoint(0));
Project(p1);
auto p2 = Point<3>(spline->GetPoint(1));
Project(p2);
auto vec = Vec<3>(p2)-Vec<3>(p1);
auto plane = new Plane(p1,-Cross(vec,baseprimitive->GetNormalVector(p1)));
if(maxh[i]>0)
{
plane->SetMaxH(maxh[i]);
}
cuttings->Append(plane);
auto lineseg = dynamic_cast<LineSeg<3>*>(spline.get());
if(lineseg)
{
auto p1 = Point<3>(spline->GetPoint(0));
Project(p1);
auto p2 = Point<3>(spline->GetPoint(1));
Project(p2);
auto vec = Vec<3>(p2)-Vec<3>(p1);
auto plane = make_shared<Plane>(p1,-Cross(vec,baseprimitive->GetNormalVector(p1)));
if(maxh[i]>0)
{
plane->SetMaxH(maxh[i]);
}
cuttings->Append(plane);
}
else
throw NgException("Spline type not implemented for SplineSurface!");
}
all_cuts = cuttings;
return cuttings;
}
void SplineSurface :: Print(ostream & str) const
{
str << "SplineSurface " << endl;
str << "SplineSurface with base " << *baseprimitive << endl;
}
}

View File

@ -8,19 +8,20 @@ namespace netgen
{
protected:
Array<GeomPoint<3>> geompoints;
Array<SplineSeg<3>*> splines;
Array<string*> bcnames;
Array<shared_ptr<SplineSeg<3>>> splines;
Array<string> bcnames;
Array<double> maxh;
OneSurfacePrimitive* baseprimitive;
Array<OneSurfacePrimitive*>* cuts;
shared_ptr<OneSurfacePrimitive> baseprimitive;
shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> cuts;
shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> all_cuts;
public:
SplineSurface(OneSurfacePrimitive* abaseprimitive, Array<OneSurfacePrimitive*>* acuts) :
SplineSurface(shared_ptr<OneSurfacePrimitive> abaseprimitive, shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> acuts) :
OneSurfacePrimitive(), baseprimitive(abaseprimitive), cuts(acuts)
{ ; }
virtual ~SplineSurface() { ; }
const Array<SplineSeg<3>*> & GetSplines() const { return splines; }
const auto & GetSplines() const { return splines; }
int GetNSplines() const { return splines.Size(); }
const Array<GeomPoint<3>>& GetPoints() const { return geompoints; }
string GetSplineType(const int i) const { return splines[i]->GetType(); }
@ -28,16 +29,15 @@ namespace netgen
const SplineSeg<3> & GetSpline(const int i) const { return *splines[i]; }
int GetNP() const { return geompoints.Size(); }
const GeomPoint<3> & GetPoint(int i) const { return geompoints[i]; }
string* GetBCName(int i) const { return bcnames[i]; }
string* GetBCNameOf(Point<3> p1, Point<3> p2) const;
string GetBCName(int i) const { return bcnames[i]; }
string GetBCNameOf(Point<3> p1, Point<3> p2) const;
DLL_HEADER void AppendPoint(const Point<3> & p, const double reffac = 1., const bool hpref=false);
void AppendSegment(SplineSeg<3>* spline, string* bcname, double amaxh = -1);
OneSurfacePrimitive* GetBase() const { return baseprimitive; }
Array<OneSurfacePrimitive*>* CreateCuttingSurfaces() const;
void AppendSegment(shared_ptr<SplineSeg<3>> spline, string & bcname, double amaxh = -1);
const shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> CreateCuttingSurfaces();
const shared_ptr<Array<shared_ptr<OneSurfacePrimitive>>> GetCuts() const { return all_cuts; }
const shared_ptr<OneSurfacePrimitive> GetBase() const { return baseprimitive; }
virtual void Project (Point<3> & p3d) const { baseprimitive->Project(p3d); }
virtual double CalcFunctionValue (const Point<3> & point) const

View File

@ -267,6 +267,15 @@ namespace netgen
(*this)[i] = a2[i];
}
/// array move
Array (Array && a2)
: FlatArray<T,BASE,TIND> (a2.size, a2.data), allocsize(a2.allocsize), ownmem(a2.ownmem)
{
a2.size = 0;
a2.data = nullptr;
a2.allocsize = 0;
a2.ownmem = false;
}
/// if responsible, deletes memory
@ -377,6 +386,14 @@ namespace netgen
return *this;
}
Array & operator= (Array && a2)
{
Swap (data, a2.data);
Swap (size, a2.size);
Swap (allocsize, a2.allocsize);
Swap (ownmem, a2.ownmem);
return *this;
}
private:
@ -391,7 +408,16 @@ namespace netgen
T * p = new T[nsize];
int mins = (nsize < size) ? nsize : size;
memcpy (p, data, mins * sizeof(T));
// memcpy (p, data, mins * sizeof(T));
#if defined(__GNUG__) && __GNUC__ < 5 && !defined(__clang__)
for (size_t i = 0; i < mins; i++) p[i] = move(data[i]);
#else
if (std::is_trivially_copyable<T>::value)
memcpy (p, data, sizeof(T)*mins);
else
for (size_t i = 0; i < mins; i++) p[i] = move(data[i]);
#endif
if (ownmem)
delete [] data;

View File

@ -10,6 +10,7 @@
/*
Parallel thread, Mutex,
*/
#include <functional>
namespace netgen
{
@ -95,9 +96,9 @@ void ParallelFor( int first, int next, const TFunc & f )
typedef void (*TaskManager)(function<void(int,int)>);
typedef void (*TaskManager)(std::function<void(int,int)>);
inline void DummyTaskManager (function<void(int,int)> func)
inline void DummyTaskManager (std::function<void(int,int)> func)
{
func(0,2);
func(1,2);

View File

@ -34,11 +34,25 @@ protected:
public:
///
BASE_TABLE (BASE_TABLE && table2)
: data(move(table2.data)), oneblock(table2.oneblock)
{
table2.oneblock = nullptr;
}
BASE_TABLE (int size);
///
BASE_TABLE (const FlatArray<int> & entrysizes, int elemsize);
///
~BASE_TABLE ();
BASE_TABLE & operator= (BASE_TABLE && table2)
{
data = move(table2.data);
Swap (oneblock, table2.oneblock);
return *this;
}
///
void SetSize (int size);
///

View File

@ -238,6 +238,29 @@ namespace netgen
}
}
// first add all vertices (for compatible orientation on periodic bnds)
{
double diam2 = Dist2(pmin, pmax);
for (int i = 0; i < splines.Size(); i++)
for (int j : { 1, 2 })
{
Point<2> hnewp = (j == 1) ? splines[i]->StartPI() : splines[i]->EndPI();
Point<3> newp(hnewp(0), hnewp(1), 0);
int layer = GetSpline(i).layer;
int npi = -1;
for (PointIndex pi = PointIndex::BASE;
pi < mesh2d.GetNP()+PointIndex::BASE; pi++)
if (Dist2 (mesh2d.Point(pi), newp) < 1e-12 * diam2 && mesh2d.Point(pi).GetLayer() == layer)
npi = pi;
if (npi == -1)
{
npi = mesh2d.AddPoint (newp, layer);
searchtree.Insert (newp, npi);
}
}
}
for (int i = 0; i < splines.Size(); i++)
if (GetSpline(i).copyfrom == -1)
{

View File

@ -36,54 +36,52 @@ namespace netgen
class Ng_Points
{
public:
int num;
size_t num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
size_t Size() const { return num; }
int operator[] (size_t i) const { return ptr[i]-POINTINDEX_BASE; }
};
class Ng_Vertices
{
public:
int num;
size_t num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
size_t Size() const { return num; }
int operator[] (size_t i) const { return ptr[i]-POINTINDEX_BASE; }
};
class Ng_Edges
{
public:
int num;
size_t num;
const T_EDGE2 * ptr;
int Size() const { return num; }
// int operator[] (int i) const { return abs (ptr[i])-1; }
int operator[] (int i) const { return ptr[i].nr; }
size_t Size() const { return num; }
int operator[] (size_t i) const { return ptr[i].nr; }
};
class Ng_Faces
{
public:
int num;
size_t num;
const T_FACE2 * ptr;
int Size() const { return num; }
// int operator[] (int i) const { return (ptr[i]-1) / 8; }
int operator[] (int i) const { return ptr[i].nr; }
size_t Size() const { return num; }
int operator[] (size_t i) const { return ptr[i].nr; }
};
class Ng_Facets
{
public:
int num;
size_t num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return ptr[i]; }
size_t Size() const { return num; }
int operator[] (size_t i) const { return ptr[i]; }
};
@ -229,11 +227,14 @@ namespace netgen
Ng_Point GetPoint (int nr) const;
template <int DIM>
Ng_Element GetElement (int nr) const;
Ng_Element GetElement (size_t nr) const;
template <int DIM>
int GetElementIndex (int nr) const;
int GetElementIndex (size_t nr) const;
/// material/boundary label of region, template argument is co-dimension
template <int DIM>
const string & GetMaterialCD (int region_nr) const;
/// Curved Elements:
/// elnr .. element nr

View File

@ -5,13 +5,13 @@ NGX_INLINE DLL_HEADER Ng_Point Ngx_Mesh :: GetPoint (int nr) const
template <>
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<0> (int nr) const
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<0> (size_t nr) const
{
return (*mesh).pointelements[nr].index;
}
template <>
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (int nr) const
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (size_t nr) const
{
if(mesh->GetDimension()==3)
return (*mesh)[SegmentIndex(nr)].edgenr;
@ -20,21 +20,21 @@ NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (int nr) const
}
template <>
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<2> (int nr) const
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<2> (size_t nr) const
{
int ind = (*mesh)[SurfaceElementIndex(nr)].GetIndex();
return mesh->GetFaceDescriptor(ind).BCProperty();
}
template <>
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<3> (int nr) const
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<3> (size_t nr) const
{
return (*mesh)[ElementIndex(nr)].GetIndex();
}
template <>
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (int nr) const
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (size_t nr) const
{
const Element0d & el = mesh->pointelements[nr];
@ -60,7 +60,7 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (int nr) const
template <>
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (int nr) const
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
{
const Segment & el = mesh->LineSegment (SegmentIndex(nr));
@ -107,7 +107,7 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (int nr) const
}
template <>
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (int nr) const
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (size_t nr) const
{
const Element2d & el = mesh->SurfaceElement (SurfaceElementIndex (nr));
@ -146,7 +146,7 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (int nr) const
}
template <>
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (int nr) const
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (size_t nr) const
{
const Element & el = mesh->VolumeElement (ElementIndex (nr));
@ -175,8 +175,23 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (int nr) const
template <> NGX_INLINE DLL_HEADER
const string & Ngx_Mesh :: GetMaterialCD<0> (int region_nr) const
{
return mesh->GetMaterial(region_nr+1);
}
template <> NGX_INLINE DLL_HEADER
const string & Ngx_Mesh :: GetMaterialCD<1> (int region_nr) const
{
return mesh->GetBCName(region_nr);
}
template <> NGX_INLINE DLL_HEADER
const string & Ngx_Mesh :: GetMaterialCD<2> (int region_nr) const
{
return mesh->GetCD2Name(region_nr);
}

View File

@ -7,7 +7,7 @@ namespace netgen
static mutex buildsearchtree_mutex;
Mesh :: Mesh ()
: surfarea(*this)
: surfarea(*this), topology(*this)
{
// volelements.SetName ("vol elements");
// surfelements.SetName ("surf elements");
@ -27,7 +27,7 @@ namespace netgen
numvertices = -1;
dimension = 3;
topology = new MeshTopology (*this);
// topology = new MeshTopology (*this);
curvedelems = new CurvedElements (*this);
clusters = new AnisotropicClusters (*this);
ident = new Identifications (*this);
@ -57,7 +57,7 @@ namespace netgen
delete segmentht;
delete curvedelems;
delete clusters;
delete topology;
// delete topology;
delete ident;
delete elementsearchtree;
delete coarsemesh;
@ -126,8 +126,9 @@ namespace netgen
delete ident;
ident = new Identifications (*this);
delete topology;
topology = new MeshTopology (*this);
// delete topology;
// topology = new MeshTopology (*this);
topology = MeshTopology (*this);
delete curvedelems;
curvedelems = new CurvedElements (*this);
delete clusters;
@ -1241,7 +1242,7 @@ namespace netgen
if (ntasks == 1) // sequential run only
{
topology -> Update();
topology.Update();
clusters -> Update();
}
@ -1481,7 +1482,7 @@ namespace netgen
CalcSurfacesOfNode ();
topology -> Update();
topology.Update();
clusters -> Update();
SetNextMajorTimeStamp();
@ -4878,12 +4879,12 @@ namespace netgen
//(*testout) << "velement " << velement << endl;
Array<int> faces;
topology->GetElementFaces(velement,faces);
topology.GetElementFaces(velement,faces);
//(*testout) << "faces " << faces << endl;
for(int i=0; i<faces.Size(); i++)
faces[i] = topology->GetFace2SurfaceElement(faces[i]);
faces[i] = topology.GetFace2SurfaceElement(faces[i]);
//(*testout) << "surfel " << faces << endl;
@ -4910,7 +4911,7 @@ namespace netgen
}
Array<int> faces2;
topology->GetElementFaces(velement,faces2);
topology.GetElementFaces(velement,faces2);
/*
cout << "no matching surf element" << endl
<< "p = " << p << endl
@ -5709,7 +5710,7 @@ namespace netgen
void Mesh :: UpdateTopology (TaskManager tm)
{
topology->Update(tm);
topology.Update(tm);
clusters->Update(tm);
#ifdef PARALLEL
if (paralleltop)

View File

@ -103,7 +103,7 @@ namespace netgen
mutable int elementsearchtreets;
/// element -> face, element -> edge etc ...
MeshTopology * topology;
MeshTopology topology;
/// methods for high order elements
class CurvedElements * curvedelems;
@ -687,7 +687,7 @@ namespace netgen
const MeshTopology & GetTopology () const
{ return *topology; }
{ return topology; }
DLL_HEADER void UpdateTopology (TaskManager tm = &DummyTaskManager);

View File

@ -25,8 +25,24 @@ namespace netgen
HEX = 25
};
/*
typedef int ELEMENT_EDGE[2]; // initial point, end point
typedef int ELEMENT_FACE[4]; // points, last one is -1 for trig
*/
struct ELEMENT_EDGE
{
int vals[2];
int & operator[] (size_t i) { return vals[i]; }
int operator[] (size_t i) const { return vals[i]; }
};
struct ELEMENT_FACE
{
int vals[4];
int & operator[] (size_t i) { return vals[i]; }
int operator[] (size_t i) const { return vals[i]; }
};
#define ELEMENT_MAXPOINTS 12

View File

@ -718,7 +718,7 @@ namespace netgen
NgProfiler::StopTimer (timerloc2);
topology -> Update();
topology.Update();
clusters -> Update();
// paralleltop -> UpdateCoarseGrid();
@ -1218,7 +1218,7 @@ namespace netgen
int ne = GetNE();
int nn = GetNP();
int nedges = topology->GetNEdges();
int nedges = topology.GetNEdges();
idxtype *xadj, * adjacency, *v_weights = NULL, *e_weights = NULL;
@ -1240,7 +1240,7 @@ namespace netgen
for ( int edge = 1; edge <= nedges; edge++ )
{
int v1, v2;
topology->GetEdgeVertices ( edge, v1, v2);
topology.GetEdgeVertices ( edge, v1, v2);
cnt[v1-1] ++;
cnt[v2-1] ++;
}
@ -1257,7 +1257,7 @@ namespace netgen
for ( int edge = 1; edge <= nedges; edge++ )
{
int v1, v2;
topology->GetEdgeVertices ( edge, v1, v2);
topology.GetEdgeVertices ( edge, v1, v2);
adjacency[ xadj[v1-1] + cnt[v1-1] ] = v2-1;
adjacency[ xadj[v2-1] + cnt[v2-1] ] = v1-1;
cnt[v1-1]++;
@ -1313,7 +1313,7 @@ namespace netgen
// int nn = GetNP();
// int nedges = topology->GetNEdges();
int nfaces = topology->GetNFaces();
int nfaces = topology.GetNFaces();
idxtype *xadj, * adjacency, *v_weights = NULL, *e_weights = NULL;
@ -1340,7 +1340,7 @@ namespace netgen
for ( int el=1; el <= ne; el++ )
{
Element volel = VolumeElement(el);
topology->GetElementFaces(el, elfaces);
topology.GetElementFaces(el, elfaces);
for ( int i = 0; i < elfaces.Size(); i++ )
{
if ( facevolels1[elfaces[i]-1] == -1 )

View File

@ -44,23 +44,14 @@ namespace netgen
MeshTopology :: MeshTopology (const Mesh & amesh)
: mesh(amesh)
: mesh(&amesh)
{
buildedges = 1;
buildfaces = 1;
vert2element = 0;
vert2surfelement = 0;
vert2segment = 0;
timestamp = -1;
}
MeshTopology :: ~MeshTopology ()
{
delete vert2element;
delete vert2surfelement;
delete vert2segment;
delete vert2pointelement;
}
MeshTopology :: ~MeshTopology () { ; }
template <typename FUNC>
void LoopOverEdges (const Mesh & mesh, MeshTopology & top, PointIndex v,
@ -350,13 +341,13 @@ namespace netgen
#endif
if (timestamp > mesh.GetTimeStamp()) return;
if (timestamp > mesh->GetTimeStamp()) return;
int ne = mesh.GetNE();
int nse = mesh.GetNSE();
int nseg = mesh.GetNSeg();
int np = mesh.GetNP();
int nv = mesh.GetNV();
int ne = mesh->GetNE();
int nse = mesh->GetNSE();
int nseg = mesh->GetNSeg();
int np = mesh->GetNP();
int nv = mesh->GetNV();
if (id == 0)
PrintMessage (3, "Update mesh topology");
@ -368,11 +359,6 @@ namespace netgen
(*testout) << "np = " << np << endl;
(*testout) << "nv = " << nv << endl;
delete vert2element;
delete vert2surfelement;
delete vert2segment;
delete vert2pointelement;
Array<int,PointIndex::BASE> cnt(nv);
Array<int> vnums;
@ -382,69 +368,67 @@ namespace netgen
vertex to surface element
vertex to segment
*/
cnt = 0;
for (ElementIndex ei = 0; ei < ne; ei++)
{
const Element & el = mesh[ei];
const Element & el = (*mesh)[ei];
for (int j = 0; j < el.GetNV(); j++)
cnt[el[j]]++;
}
vert2element = new TABLE<ElementIndex,PointIndex::BASE> (cnt);
vert2element = TABLE<ElementIndex,PointIndex::BASE> (cnt);
for (ElementIndex ei = 0; ei < ne; ei++)
{
const Element & el = mesh[ei];
const Element & el = (*mesh)[ei];
for (int j = 0; j < el.GetNV(); j++)
vert2element->AddSave (el[j], ei);
vert2element.AddSave (el[j], ei);
}
cnt = 0;
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
{
const Element2d & el = mesh[sei];
const Element2d & el = (*mesh)[sei];
for (int j = 0; j < el.GetNV(); j++)
cnt[el[j]]++;
}
vert2surfelement = new TABLE<SurfaceElementIndex,PointIndex::BASE> (cnt);
vert2surfelement = TABLE<SurfaceElementIndex,PointIndex::BASE> (cnt);
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
{
const Element2d & el = mesh[sei];
const Element2d & el = (*mesh)[sei];
for (int j = 0; j < el.GetNV(); j++)
vert2surfelement->AddSave (el[j], sei);
vert2surfelement.AddSave (el[j], sei);
}
cnt = 0;
for (SegmentIndex si = 0; si < nseg; si++)
{
const Segment & seg = mesh.LineSegment(si);
const Segment & seg = mesh->LineSegment(si);
cnt[seg[0]]++;
cnt[seg[1]]++;
}
vert2segment = new TABLE<SegmentIndex,PointIndex::BASE> (cnt);
vert2segment = TABLE<SegmentIndex,PointIndex::BASE> (cnt);
for (SegmentIndex si = 0; si < nseg; si++)
{
const Segment & seg = mesh.LineSegment(si);
vert2segment->AddSave (seg[0], si);
vert2segment->AddSave (seg[1], si);
const Segment & seg = mesh->LineSegment(si);
vert2segment.AddSave (seg[0], si);
vert2segment.AddSave (seg[1], si);
}
cnt = 0;
for (int pei = 0; pei < mesh.pointelements.Size(); pei++)
for (int pei = 0; pei < mesh->pointelements.Size(); pei++)
{
const Element0d & pointel = mesh.pointelements[pei];
const Element0d & pointel = mesh->pointelements[pei];
cnt[pointel.pnum]++;
}
vert2pointelement = new TABLE<int,PointIndex::BASE> (cnt);
for (int pei = 0; pei < mesh.pointelements.Size(); pei++)
vert2pointelement = TABLE<int,PointIndex::BASE> (cnt);
for (int pei = 0; pei < mesh->pointelements.Size(); pei++)
{
const Element0d & pointel = mesh.pointelements[pei];
vert2pointelement->AddSave (pointel.pnum, pei);
const Element0d & pointel = mesh->pointelements[pei];
vert2pointelement.AddSave (pointel.pnum, pei);
}
@ -477,15 +461,15 @@ namespace netgen
// ensure all coarse grid and intermediate level edges
cnt = 0;
for (int i = mesh.mlbetweennodes.Begin(); i < mesh.mlbetweennodes.End(); i++)
for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++)
{
INDEX_2 parents = Sort (mesh.mlbetweennodes[i]);
INDEX_2 parents = Sort (mesh->mlbetweennodes[i]);
if (parents[0] >= PointIndex::BASE) cnt[parents[0]]++;
}
TABLE<int,PointIndex::BASE> vert2vertcoarse (cnt);
for (int i = mesh.mlbetweennodes.Begin(); i < mesh.mlbetweennodes.End(); i++)
for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++)
{
INDEX_2 parents = Sort (mesh.mlbetweennodes[i]);
INDEX_2 parents = Sort (mesh->mlbetweennodes[i]);
if (parents[0] > PointIndex::BASE) vert2vertcoarse.AddSave (parents[0], parents[1]);
}
@ -495,7 +479,7 @@ namespace netgen
for (int i = PointIndex::BASE; i < nv+PointIndex::BASE; i++)
{
int onv = vert2edge[i].Size() + vert2vertcoarse[i].Size() +
4*(*vert2element)[i].Size() + 2*(*vert2surfelement)[i].Size() + (*vert2segment)[i].Size();
4*(vert2element)[i].Size() + 2*(vert2surfelement)[i].Size() + (vert2segment)[i].Size();
max_edge_on_vertex = max (onv, max_edge_on_vertex);
}
@ -504,7 +488,7 @@ namespace netgen
cnt = 0;
ParallelForRange
(tm, mesh.Points().Size(),
(tm, mesh->Points().Size(),
[&] (size_t begin, size_t end)
{
INDEX_CLOSED_HASHTABLE<int> v2eht(2*max_edge_on_vertex+10);
@ -527,7 +511,7 @@ namespace netgen
v2eht.Set (v2, 33); // some value
}
LoopOverEdges (mesh, *this, v,
LoopOverEdges (*mesh, *this, v,
[&] (INDEX_2 edge, int elnr, int loc_edge, int element_dim, int edgedir)
{
if (!v2eht.Used (edge.I2()))
@ -542,7 +526,7 @@ namespace netgen
// accumulate number of edges
int ned = edge2vert.Size();
for (auto v : mesh.Points().Range())
for (auto v : mesh->Points().Range())
{
auto hv = cnt[v];
cnt[v] = ned;
@ -556,7 +540,7 @@ namespace netgen
// for (PointIndex v = PointIndex::BASE; v < nv+PointIndex::BASE; v++)
ParallelForRange
(tm, mesh.Points().Size(),
(tm, mesh->Points().Size(),
[&] (size_t begin, size_t end)
{
INDEX_CLOSED_HASHTABLE<int> v2eht(2*max_edge_on_vertex+10);
@ -581,7 +565,7 @@ namespace netgen
vertex2.Append (v2);
}
LoopOverEdges (mesh, *this, v,
LoopOverEdges (*mesh, *this, v,
[&](INDEX_2 edge, int elnr, int loc_edge, int element_dim, int edgedir)
{
if (!v2eht.Used(edge.I2()))
@ -600,7 +584,7 @@ namespace netgen
ned++;
}
LoopOverEdges (mesh, *this, v,
LoopOverEdges (*mesh, *this, v,
[&](INDEX_2 edge, int elnr, int loc_edge, int element_dim, int edgedir)
{
int edgenum = v2eht.Get(edge.I2());
@ -661,7 +645,7 @@ namespace netgen
int max_face_on_vertex = 0;
for (int i = PointIndex::BASE; i < nv+PointIndex::BASE; i++)
{
int onv = vert2oldface[i].Size() + (*vert2element)[i].Size() + (*vert2surfelement)[i].Size();
int onv = vert2oldface[i].Size() + vert2element[i].Size() + vert2surfelement[i].Size();
max_face_on_vertex = max (onv, max_face_on_vertex);
}
@ -680,7 +664,7 @@ namespace netgen
// for (auto v : mesh.Points().Range())
NgProfiler::StartTimer (timer2b1);
ParallelForRange
(tm, mesh.Points().Size(),
(tm, mesh->Points().Size(),
[&] (size_t begin, size_t end)
{
INDEX_3_CLOSED_HASHTABLE<int> vert2face(2*max_face_on_vertex+10);
@ -698,7 +682,7 @@ namespace netgen
vert2face.Set (face, 33); // something
}
int cnti = 0;
LoopOverFaces (mesh, *this, v,
LoopOverFaces (*mesh, *this, v,
[&] (INDEX_4 i4, int elnr, int j, bool volume, int facedir)
{
INDEX_3 face(i4.I1(), i4.I2(), i4.I3());
@ -715,7 +699,7 @@ namespace netgen
// accumulate number of faces
int nfa = oldnfa;
for (auto v : mesh.Points().Range())
for (auto v : mesh->Points().Range())
{
auto hv = cnt[v];
cnt[v] = nfa;
@ -726,7 +710,7 @@ namespace netgen
// for (auto v : mesh.Points().Range())
ParallelForRange
(tm, mesh.Points().Size(),
(tm, mesh->Points().Size(),
[&] (size_t begin, size_t end)
{
INDEX_3_CLOSED_HASHTABLE<int> vert2face(2*max_face_on_vertex+10);
@ -746,7 +730,7 @@ namespace netgen
vert2face.Set (face, fnr);
}
LoopOverFaces (mesh, *this, v,
LoopOverFaces (*mesh, *this, v,
[&] (INDEX_4 i4, int elnr, int j, bool volume, int facedir)
{
INDEX_3 face(i4.I1(), i4.I2(), i4.I3());
@ -775,7 +759,7 @@ namespace netgen
}
LoopOverFaces (mesh, *this, v,
LoopOverFaces (*mesh, *this, v,
[&] (INDEX_4 i4, int elnr, int j, bool volume, int facedir)
{
INDEX_3 face(i4.I1(), i4.I2(), i4.I3());
@ -1149,10 +1133,10 @@ namespace netgen
{
// (*testout) << "is face of element " << vertels[k] << endl;
if (mesh.coarsemesh && mesh.hpelements->Size() == mesh.GetNE() )
if (mesh->coarsemesh && mesh->hpelements->Size() == mesh->GetNE() )
{
const HPRefElement & hpref_el =
(*mesh.hpelements) [ mesh[vertels[k]].hp_elnr];
(*mesh->hpelements) [ (*mesh)[vertels[k]].hp_elnr];
(*testout) << "coarse eleme = " << hpref_el.coarse_elnr << endl;
}
@ -1306,7 +1290,7 @@ namespace netgen
void MeshTopology :: GetElementEdges (int elnr, Array<int> & eledges) const
{
int ned = GetNEdges (mesh.VolumeElement(elnr).GetType());
int ned = GetNEdges (mesh->VolumeElement(elnr).GetType());
eledges.SetSize (ned);
for (int i = 0; i < ned; i++)
eledges[i] = edges.Get(elnr)[i].nr+1;
@ -1314,7 +1298,7 @@ namespace netgen
}
void MeshTopology :: GetElementFaces (int elnr, Array<int> & elfaces, bool withorientation) const
{
int nfa = GetNFaces (mesh.VolumeElement(elnr).GetType());
int nfa = GetNFaces (mesh->VolumeElement(elnr).GetType());
elfaces.SetSize (nfa);
if (!withorientation)
@ -1342,7 +1326,7 @@ namespace netgen
void MeshTopology :: GetElementEdgeOrientations (int elnr, Array<int> & eorient) const
{
int ned = GetNEdges (mesh.VolumeElement(elnr).GetType());
int ned = GetNEdges (mesh->VolumeElement(elnr).GetType());
eorient.SetSize (ned);
for (int i = 1; i <= ned; i++)
// eorient.Elem(i) = (edges.Get(elnr)[i-1] > 0) ? 1 : -1;
@ -1352,7 +1336,7 @@ namespace netgen
void MeshTopology :: GetElementFaceOrientations (int elnr, Array<int> & forient) const
{
int nfa = GetNFaces (mesh.VolumeElement(elnr).GetType());
int nfa = GetNFaces (mesh->VolumeElement(elnr).GetType());
forient.SetSize (nfa);
for (int i = 1; i <= nfa; i++)
// forient.Elem(i) = faces.Get(elnr)[i-1].forient;
@ -1366,7 +1350,7 @@ namespace netgen
{
// int ned = GetNEdges (mesh.VolumeElement(elnr).GetType());
if (mesh.GetDimension()==3 || 1)
if (mesh->GetDimension()==3 || 1)
{
if (orient)
{
@ -1454,7 +1438,7 @@ namespace netgen
void MeshTopology :: GetSurfaceElementEdges (int elnr, Array<int> & eledges) const
{
int ned = GetNEdges (mesh.SurfaceElement(elnr).GetType());
int ned = GetNEdges (mesh->SurfaceElement(elnr).GetType());
eledges.SetSize (ned);
for (int i = 0; i < ned; i++)
// eledges[i] = abs (surfedges.Get(elnr)[i]);
@ -1463,7 +1447,7 @@ namespace netgen
void MeshTopology :: GetEdges (SurfaceElementIndex elnr, Array<int> & eledges) const
{
int ned = GetNEdges (mesh[elnr].GetType());
int ned = GetNEdges ( (*mesh)[elnr].GetType());
eledges.SetSize (ned);
for (int i = 0; i < ned; i++)
// eledges[i] = abs (surfedges[elnr][i])-1;
@ -1486,7 +1470,7 @@ namespace netgen
void MeshTopology ::
GetSurfaceElementEdgeOrientations (int elnr, Array<int> & eorient) const
{
int ned = GetNEdges (mesh.SurfaceElement(elnr).GetType());
int ned = GetNEdges (mesh->SurfaceElement(elnr).GetType());
eorient.SetSize (ned);
for (int i = 0; i < ned; i++)
// eorient[i] = (surfedges.Get(elnr)[i] > 0) ? 1 : -1;
@ -1504,7 +1488,7 @@ namespace netgen
int MeshTopology :: GetSurfaceElementEdges (int elnr, int * eledges, int * orient) const
{
int i;
if (mesh.GetDimension() == 3 || 1)
if (mesh->GetDimension() == 3 || 1)
{
if (orient)
{
@ -1554,7 +1538,7 @@ namespace netgen
int MeshTopology :: GetElementEdgeOrientation (int elnr, int locedgenr) const
{
const Element & el = mesh.VolumeElement (elnr);
const Element & el = mesh->VolumeElement (elnr);
const ELEMENT_EDGE * eledges = MeshTopology::GetEdges0 (el.GetType());
int k = locedgenr;
@ -1566,7 +1550,7 @@ namespace netgen
int MeshTopology :: GetElementFaceOrientation (int elnr, int locfacenr) const
{
const Element & el = mesh.VolumeElement (elnr);
const Element & el = mesh->VolumeElement (elnr);
const ELEMENT_FACE * elfaces = MeshTopology::GetFaces0 (el.GetType());
@ -1622,7 +1606,7 @@ namespace netgen
int MeshTopology :: GetSurfaceElementEdgeOrientation (int elnr, int locedgenr) const
{
const Element2d & el = mesh.SurfaceElement (elnr);
const Element2d & el = mesh->SurfaceElement (elnr);
const ELEMENT_EDGE * eledges = MeshTopology::GetEdges0 (el.GetType());
int k = locedgenr;
@ -1633,7 +1617,7 @@ namespace netgen
int MeshTopology :: GetSurfaceElementFaceOrientation2 (int elnr) const
{
const Element2d & el = mesh.SurfaceElement (elnr);
const Element2d & el = mesh->SurfaceElement (elnr);
const ELEMENT_FACE * elfaces = MeshTopology::GetFaces0 (el.GetType());
@ -1687,7 +1671,7 @@ namespace netgen
int MeshTopology :: GetSegmentEdgeOrientation (int elnr) const
{
const Segment & el = mesh.LineSegment (elnr);
const Segment & el = mesh->LineSegment (elnr);
const ELEMENT_EDGE * eledges = MeshTopology::GetEdges0 (el.GetType());
int k = 0;
@ -1760,7 +1744,7 @@ namespace netgen
// find one element having all vertices of the face
for (int i = 0; i < els.Size(); i++)
{
const Element & el = mesh[els[i]];
const Element & el = (*mesh)[els[i]];
int nref_faces = GetNFaces (el.GetType());
const ELEMENT_FACE * ref_faces = GetFaces1 (el.GetType());
int nfa_ref_edges = GetNEdges (GetFaceType(fnr));
@ -1849,12 +1833,12 @@ namespace netgen
void MeshTopology :: GetVertexElements (int vnr, Array<ElementIndex> & elements) const
{
if (vert2element)
if (vert2element.Size())
{
int ne = vert2element->EntrySize(vnr);
int ne = vert2element.EntrySize(vnr);
elements.SetSize(ne);
for (int i = 1; i <= ne; i++)
elements.Elem(i) = vert2element->Get(vnr, i);
elements.Elem(i) = vert2element.Get(vnr, i);
}
}
@ -1884,13 +1868,13 @@ namespace netgen
void MeshTopology :: GetVertexSurfaceElements( int vnr,
Array<SurfaceElementIndex> & elements ) const
{
if (vert2surfelement)
if (vert2surfelement.Size())
{
int i;
int ne = vert2surfelement->EntrySize(vnr);
int ne = vert2surfelement.EntrySize(vnr);
elements.SetSize(ne);
for (i = 1; i <= ne; i++)
elements.Elem(i) = vert2surfelement->Get(vnr, i);
elements.Elem(i) = vert2surfelement.Get(vnr, i);
}
}

View File

@ -27,32 +27,51 @@ struct T_FACE
int fnr; // 0-based
};
template <typename T, int S>
struct FixArray
{
T vals[S];
T & operator[] (size_t i) { return vals[i]; }
T operator[] (size_t i) const { return vals[i]; }
};
class MeshTopology
{
const Mesh & mesh;
const Mesh * mesh;
bool buildedges;
bool buildfaces;
Array<INDEX_2> edge2vert;
Array<INDEX_4> face2vert;
/*
Array<T_EDGE[12]> edges;
Array<T_FACE[6]> faces;
Array<T_EDGE[4]> surfedges;
*/
Array<FixArray<T_EDGE,12>> edges;
Array<FixArray<T_FACE,6>> faces;
Array<FixArray<T_EDGE,4>> surfedges;
Array<T_EDGE> segedges;
Array<T_FACE> surffaces;
Array<INDEX_2> surf2volelement;
Array<int> face2surfel;
TABLE<ElementIndex,PointIndex::BASE> *vert2element;
TABLE<SurfaceElementIndex,PointIndex::BASE> *vert2surfelement;
TABLE<SegmentIndex,PointIndex::BASE> *vert2segment;
TABLE<int,PointIndex::BASE> *vert2pointelement = nullptr;
TABLE<ElementIndex,PointIndex::BASE> vert2element;
TABLE<SurfaceElementIndex,PointIndex::BASE> vert2surfelement;
TABLE<SegmentIndex,PointIndex::BASE> vert2segment;
TABLE<int,PointIndex::BASE> vert2pointelement;
int timestamp;
public:
int GetNSurfedges() const {return surfedges.Size();}
MeshTopology () = default;
MeshTopology (const MeshTopology & top) = default;
MeshTopology (MeshTopology && top) = default;
MeshTopology (const Mesh & amesh);
~MeshTopology ();
MeshTopology & operator= (const MeshTopology & top) = default;
MeshTopology & operator= (MeshTopology && top) = default;
void SetBuildEdges (bool be)
{ buildedges = be; }
@ -145,17 +164,17 @@ public:
void GetVertexElements (int vnr, Array<ElementIndex> & elements) const;
FlatArray<ElementIndex> GetVertexElements (int vnr) const
{ return (*vert2element)[vnr]; }
{ return vert2element[vnr]; }
void GetVertexSurfaceElements( int vnr, Array<SurfaceElementIndex>& elements ) const;
FlatArray<SurfaceElementIndex> GetVertexSurfaceElements (int vnr) const
{ return (*vert2surfelement)[vnr]; }
{ return vert2surfelement[vnr]; }
FlatArray<SegmentIndex> GetVertexSegments (int vnr) const
{ return (*vert2segment)[vnr]; }
{ return vert2segment[vnr]; }
FlatArray<int> GetVertexPointElements (int vnr) const
{ return (*vert2pointelement)[vnr]; }
{ return vert2pointelement[vnr]; }
int GetVerticesEdge ( int v1, int v2) const;
void GetSegmentVolumeElements ( int segnr, Array<ElementIndex> & els ) const;
@ -337,22 +356,22 @@ inline short int MeshTopology :: GetNFaces (ELEMENT_TYPE et)
const ELEMENT_EDGE * MeshTopology :: GetEdges1 (ELEMENT_TYPE et)
{
static int segm_edges[1][2] =
static ELEMENT_EDGE segm_edges[1] =
{ { 1, 2 }};
static int trig_edges[3][2] =
static ELEMENT_EDGE trig_edges[3] =
{ { 3, 1 },
{ 2, 3 },
{ 1, 2 }};
static int quad_edges[4][2] =
static ELEMENT_EDGE quad_edges[4] =
{ { 1, 2 },
{ 3, 4 },
{ 4, 1 },
{ 2, 3 }};
static int tet_edges[6][2] =
static ELEMENT_EDGE tet_edges[6] =
{ { 4, 1 },
{ 4, 2 },
{ 4, 3 },
@ -360,7 +379,7 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges1 (ELEMENT_TYPE et)
{ 1, 3 },
{ 2, 3 }};
static int prism_edges[9][2] =
static ELEMENT_EDGE prism_edges[9] =
{ { 3, 1 },
{ 1, 2 },
{ 3, 2 },
@ -371,7 +390,7 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges1 (ELEMENT_TYPE et)
{ 1, 4 },
{ 2, 5 }};
static int pyramid_edges[8][2] =
static ELEMENT_EDGE pyramid_edges[8] =
{ { 1, 2 },
{ 2, 3 },
{ 1, 4 },
@ -381,7 +400,7 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges1 (ELEMENT_TYPE et)
{ 3, 5 },
{ 4, 5 }};
static int hex_edges[12][2] =
static ELEMENT_EDGE hex_edges[12] =
{
{ 1, 2 },
{ 3, 4 },
@ -435,22 +454,22 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges1 (ELEMENT_TYPE et)
const ELEMENT_EDGE * MeshTopology :: GetEdges0 (ELEMENT_TYPE et)
{
static int segm_edges[1][2] =
static ELEMENT_EDGE segm_edges[1] =
{ { 0, 1 }};
static int trig_edges[3][2] =
static ELEMENT_EDGE trig_edges[3] =
{ { 2, 0 },
{ 1, 2 },
{ 0, 1 }};
static int quad_edges[4][2] =
static ELEMENT_EDGE quad_edges[4] =
{ { 0, 1 },
{ 2, 3 },
{ 3, 0 },
{ 1, 2 }};
static int tet_edges[6][2] =
static ELEMENT_EDGE tet_edges[6] =
{ { 3, 0 },
{ 3, 1 },
{ 3, 2 },
@ -458,7 +477,7 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges0 (ELEMENT_TYPE et)
{ 0, 2 },
{ 1, 2 }};
static int prism_edges[9][2] =
static ELEMENT_EDGE prism_edges[9] =
{ { 2, 0 },
{ 0, 1 },
{ 2, 1 },
@ -469,7 +488,7 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges0 (ELEMENT_TYPE et)
{ 0, 3 },
{ 1, 4 }};
static int pyramid_edges[8][2] =
static ELEMENT_EDGE pyramid_edges[8] =
{ { 0, 1 },
{ 1, 2 },
{ 0, 3 },
@ -479,7 +498,7 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges0 (ELEMENT_TYPE et)
{ 2, 4 },
{ 3, 4 }};
static int hex_edges[12][2] =
static ELEMENT_EDGE hex_edges[12] =
{
{ 0, 1 },
{ 2, 3 },
@ -540,18 +559,18 @@ const ELEMENT_EDGE * MeshTopology :: GetEdges0 (ELEMENT_TYPE et)
inline const ELEMENT_FACE * MeshTopology :: GetFaces1 (ELEMENT_TYPE et)
{
static const int trig_faces[1][4] =
static const ELEMENT_FACE trig_faces[1] =
{ { 1, 2, 3, 0 } };
static const int quad_faces[1][4] =
static const ELEMENT_FACE quad_faces[1] =
{ { 1, 2, 3, 4 } };
static const int tet_faces[4][4] =
static const ELEMENT_FACE tet_faces[4] =
{ { 4, 2, 3, 0 },
{ 4, 3, 1, 0 },
{ 4, 1, 2, 0 },
{ 1, 3, 2, 0 } };
static const int prism_faces[5][4] =
static const ELEMENT_FACE prism_faces[5] =
{
{ 1, 3, 2, 0 },
{ 4, 5, 6, 0 },
@ -560,7 +579,7 @@ inline const ELEMENT_FACE * MeshTopology :: GetFaces1 (ELEMENT_TYPE et)
{ 2, 3, 6, 5 }
};
static const int pyramid_faces[5][4] =
static const ELEMENT_FACE pyramid_faces[5] =
{
{ 1, 2, 5, 0 },
{ 2, 3, 5, 0 },
@ -569,7 +588,7 @@ inline const ELEMENT_FACE * MeshTopology :: GetFaces1 (ELEMENT_TYPE et)
{ 1, 4, 3, 2 }
};
static const int hex_faces[6][4] =
static const ELEMENT_FACE hex_faces[6] =
{
{ 1, 4, 3, 2 },
{ 5, 6, 7, 8 },
@ -622,18 +641,18 @@ inline const ELEMENT_FACE * MeshTopology :: GetFaces1 (ELEMENT_TYPE et)
inline const ELEMENT_FACE * MeshTopology :: GetFaces0 (ELEMENT_TYPE et)
{
static const int trig_faces[1][4] =
static const ELEMENT_FACE trig_faces[1] =
{ { 0, 1, 2, -1 } };
static const int quad_faces[1][4] =
static const ELEMENT_FACE quad_faces[1] =
{ { 0, 1, 2, 3 } };
static const int tet_faces[4][4] =
static const ELEMENT_FACE tet_faces[4] =
{ { 3, 1, 2, -1 },
{ 3, 2, 0, -1 },
{ 3, 0, 1, -1 },
{ 0, 2, 1, -1 } };
static const int prism_faces[5][4] =
static const ELEMENT_FACE prism_faces[5] =
{
{ 0, 2, 1, -1 },
{ 3, 4, 5, -1 },
@ -642,7 +661,7 @@ inline const ELEMENT_FACE * MeshTopology :: GetFaces0 (ELEMENT_TYPE et)
{ 1, 2, 5, 4 }
};
static const int pyramid_faces[5][4] =
static const ELEMENT_FACE pyramid_faces[5] =
{
{ 0, 1, 4, -1 },
{ 1, 2, 4, -1 },
@ -651,7 +670,7 @@ inline const ELEMENT_FACE * MeshTopology :: GetFaces0 (ELEMENT_TYPE et)
{ 0, 3, 2, 1 }
};
static const int hex_faces[6][4] =
static const ELEMENT_FACE hex_faces[6] =
{
{ 0, 3, 2, 1 },
{ 4, 5, 6, 7 },

View File

@ -5,6 +5,8 @@ if(USE_GUI)
# add icon to netgen executable
enable_language(RC)
set(netgen_sources ${netgen_sources} ../windows/netgen.rc)
# Don't use ccache here due to incompatiblity with the resource compiler
set_directory_properties(PROPERTIES RULE_LAUNCH_COMPILE "")
endif(WIN32)
add_executable(netgen ${netgen_sources})

1
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1 @@
add_subdirectory(pytest)

View File

@ -1,4 +1,4 @@
FROM ubuntu:15.10
MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev libboost-python-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy
ADD . /root/src/netgen

View File

@ -1,4 +1,4 @@
FROM ubuntu:16.04
MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev libboost-python-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy
ADD . /root/src/netgen

View File

@ -0,0 +1,4 @@
if(USE_PYTHON)
add_test(NAME pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(pytest ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif(USE_PYTHON)

View File

@ -0,0 +1,52 @@
from netgen.csg import *
from netgen import meshing
import filecmp
import difflib
from math import sqrt, cos, sin
def CreateQuad():
base = Plane(Pnt(0,0,0),Vec(0,0,1))
surface = SplineSurface(base)
pts = [(-0.2,-0.2,0),(-0.2,0.2,0),(0.2,0.2,0),(0.2,-0.2,0)]
geopts = [surface.AddPoint(*p) for p in pts]
for p1,p2,bc in [(0,1,"wire"), (1, 2,"contact"),(2,3,"wire"),(3,0,"wire")]:
surface.AddSegment(geopts[p1],geopts[p2],bc)
return surface
Cross = lambda a,b: [a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-b[0]*a[1]]
def CreateGeo():
geo = CSGeometry()
air = OrthoBrick(Pnt(-1,-1,-1),Pnt(1,1,1))
geo.Add(air.mat("air"))
surface = CreateQuad()
geo.AddSplineSurface(surface)
return geo
def test_BBNDsave():
mesh = CreateGeo().GenerateMesh(maxh=0.4,perfstepsend = meshing.MeshingStep.MESHSURFACE)
for i in range(2):
mesh.GenerateVolumeMesh(mp = MeshingParameters(only3D_domain=i+1,maxh=0.4))
mesh.SetGeometry(None)
mesh.Save("test.vol")
mesh2 = meshing.Mesh()
mesh2.Load("test.vol")
mesh2.Save("test2.vol")
with open("test.vol","r") as f:
first = f.readlines()
with open("test2.vol","r") as f:
second = f.readlines()
# exclude the face colours section (because they aren't in the same order)
for i,line in enumerate(first):
if line[0:12] == "face_colours":
first = first[0:i]
second = second[0:i]
break
diff = difflib.context_diff(first,second)
print("File diff:")
l = list(diff)
print(*l)
assert len(l)==0