diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b192568..0b6fbd36 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -87,6 +87,16 @@ build_ubuntu: - docker commit `cat netgen_${CI_BUILD_REF_NAME}_${UBUNTU_VERSION}.id` netgen_${CI_BUILD_REF_NAME}_installed:${UBUNTU_VERSION} - rm netgen_${CI_BUILD_REF_NAME}_${UBUNTU_VERSION}.id +build_ubuntu_mpi: + <<: *ubuntu + stage: build + script: + - docker build -t netgen_mpi_${CI_BUILD_REF_NAME}:${UBUNTU_VERSION} -f tests/dockerfile_mpi . + - rm -f netgen_mpi_${CI_BUILD_REF_NAME}_$UBUNTU_VERSION.id_mpi + - docker run --cidfile netgen_mpi_${CI_BUILD_REF_NAME}_${UBUNTU_VERSION}.id -e CCACHE_DIR=/ccache -v /mnt/ccache:/ccache netgen_mpi_${CI_BUILD_REF_NAME}:${UBUNTU_VERSION} bash /root/src/netgen/tests/build_mpi.sh + - docker commit `cat netgen_mpi_${CI_BUILD_REF_NAME}_${UBUNTU_VERSION}.id` netgen_mpi_${CI_BUILD_REF_NAME}_installed:${UBUNTU_VERSION} + - rm netgen_mpi_${CI_BUILD_REF_NAME}_${UBUNTU_VERSION}.id + test_ubuntu: <<: *ubuntu stage: test @@ -98,6 +108,17 @@ test_ubuntu: netgen_${CI_BUILD_REF_NAME}_installed:${UBUNTU_VERSION} bash -c 'cd /root/build/netgen && make test_netgen ARGS="-V"' +test_ubuntu_mpi: + <<: *ubuntu + stage: test + script: + - >- + docker run + -e NETGENDIR=/opt/netgen/bin + -e PYTHONPATH=/opt/netgen/lib/python3/dist-packages + netgen_mpi_${CI_BUILD_REF_NAME}_installed:${UBUNTU_VERSION} + bash -c 'cd /root/build/netgen && make test_netgen ARGS="-V"' + # cpp guideline checks test_guidelines: <<: *ubuntu @@ -125,6 +146,7 @@ cleanup_ubuntu: when: always allow_failure: true + ############################################ # MacOSX ############################################ diff --git a/libsrc/csg/CMakeLists.txt b/libsrc/csg/CMakeLists.txt index eaf7dffc..98475096 100644 --- a/libsrc/csg/CMakeLists.txt +++ b/libsrc/csg/CMakeLists.txt @@ -12,7 +12,9 @@ if(APPLE) endif(APPLE) target_link_libraries(csg PUBLIC mesh ${PYTHON_LIBRARIES}) -install( TARGETS csg ${NG_INSTALL_DIR}) +if(NOT WIN32) + install( TARGETS csg ${NG_INSTALL_DIR}) +endif(NOT WIN32) target_link_libraries(csg PUBLIC ngcore) diff --git a/libsrc/geom2d/CMakeLists.txt b/libsrc/geom2d/CMakeLists.txt index 43c619a0..395141e5 100644 --- a/libsrc/geom2d/CMakeLists.txt +++ b/libsrc/geom2d/CMakeLists.txt @@ -5,7 +5,9 @@ if(APPLE) endif(APPLE) target_link_libraries(geom2d mesh ${PYTHON_LIBRARIES}) -install( TARGETS geom2d ${NG_INSTALL_DIR}) +if(NOT WIN32) + install( TARGETS geom2d ${NG_INSTALL_DIR}) +endif(NOT WIN32) target_link_libraries(geom2d ngcore) diff --git a/libsrc/interface/CMakeLists.txt b/libsrc/interface/CMakeLists.txt index afd301d9..d27061b1 100644 --- a/libsrc/interface/CMakeLists.txt +++ b/libsrc/interface/CMakeLists.txt @@ -9,7 +9,9 @@ add_library(interface ${NG_LIB_TYPE} target_link_libraries(interface mesh csg geom2d) target_link_libraries(interface visual) -install( TARGETS interface ${NG_INSTALL_DIR}) +if(NOT WIN32) + install( TARGETS interface ${NG_INSTALL_DIR}) +endif(NOT WIN32) install(FILES writeuser.hpp diff --git a/libsrc/interface/readuser.cpp b/libsrc/interface/readuser.cpp index 10cb9894..abfc6775 100644 --- a/libsrc/interface/readuser.cpp +++ b/libsrc/interface/readuser.cpp @@ -260,6 +260,7 @@ namespace netgen Point3d pmin, pmax; mesh.ComputeNVertices(); + mesh.RebuildSurfaceElementLists(); mesh.GetBox (pmin, pmax); cout << "bounding-box = " << pmin << "-" << pmax << endl; } diff --git a/libsrc/meshing/CMakeLists.txt b/libsrc/meshing/CMakeLists.txt index 12fe70ae..f1e9ee86 100644 --- a/libsrc/meshing/CMakeLists.txt +++ b/libsrc/meshing/CMakeLists.txt @@ -24,7 +24,9 @@ endif(APPLE) target_link_libraries( mesh PUBLIC ngcore PRIVATE gprim la gen ) target_link_libraries( mesh PUBLIC ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${PYTHON_LIBRARIES} ${METIS_LIBRARY}) -install( TARGETS mesh ${NG_INSTALL_DIR}) +if(NOT WIN32) + install( TARGETS mesh ${NG_INSTALL_DIR}) +endif(NOT WIN32) install(FILES adfront2.hpp adfront3.hpp basegeom.hpp bcfunctions.hpp bisect.hpp diff --git a/libsrc/meshing/curvedelems.cpp b/libsrc/meshing/curvedelems.cpp index 98410568..83c5211f 100644 --- a/libsrc/meshing/curvedelems.cpp +++ b/libsrc/meshing/curvedelems.cpp @@ -409,6 +409,15 @@ namespace netgen static Array> jacpols2; + void CurvedElements::buildJacPols() + { + if (!jacpols2.Size()) + { + jacpols2.SetSize (100); + for (int i = 0; i < 100; i++) + jacpols2[i] = make_shared (100, i, 2); + } + } // compute face bubbles up to order n, 0 < y, y-x < 1, x+y < 1 template @@ -540,7 +549,6 @@ namespace netgen CurvedElements :: ~CurvedElements() { - jacpols2.SetSize(0); } @@ -719,13 +727,7 @@ namespace netgen ComputeGaussRule (aorder+4, xi, weight); // on (0,1) - if (!jacpols2.Size()) - { - jacpols2.SetSize (100); - for (int i = 0; i < 100; i++) - jacpols2[i] = make_shared (100, i, 2); - } - + buildJacPols(); PrintMessage (3, "Curving edges"); if (mesh.GetDimension() == 3 || rational) @@ -2239,6 +2241,20 @@ namespace netgen switch (el.GetType()) { + case TRIG6: + { + AutoDiff<2,T> lam3 = 1-x-y; + AutoDiff<2,T> lami[6] = { x * (2*x-1), y * (2*y-1), lam3 * (2*lam3-1), + 4 * y * lam3, 4 * x * lam3, 4 * x * y }; + for (int j = 0; j < 6; j++) + { + Point<3> p = mesh[el[j]]; + for (int k = 0; k < DIM_SPACE; k++) + mapped_x[k] += p(k) * lami[j]; + } + break; + } + case TRIG: { // if (info.order >= 2) return false; // not yet supported diff --git a/libsrc/meshing/curvedelems.hpp b/libsrc/meshing/curvedelems.hpp index 29c911aa..cd78d708 100644 --- a/libsrc/meshing/curvedelems.hpp +++ b/libsrc/meshing/curvedelems.hpp @@ -33,6 +33,7 @@ class CurvedElements bool rational; bool ishighorder; + void buildJacPols(); public: DLL_HEADER CurvedElements (const Mesh & amesh); @@ -50,6 +51,8 @@ public: virtual void DoArchive(Archive& ar) { + if(ar.Input()) + buildJacPols(); ar & edgeorder & faceorder & edgecoeffsindex & facecoeffsindex & edgecoeffs & facecoeffs & edgeweight & order & rational & ishighorder; } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 9acfacaa..8ae917aa 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -90,6 +90,7 @@ namespace netgen Mesh & Mesh :: operator= (const Mesh & mesh2) { + dimension = mesh2.dimension; points = mesh2.points; // eltyps = mesh2.eltyps; segments = mesh2.segments; @@ -1320,6 +1321,7 @@ namespace netgen archive & segments; archive & facedecoding; archive & materials & bcnames & cd2names & cd3names; + archive & numvertices; archive & *ident; @@ -4995,6 +4997,10 @@ namespace netgen // netgen::Point<3> pmin = p - Vec<3> (pointtol, pointtol, pointtol); // netgen::Point<3> pmax = p + Vec<3> (pointtol, pointtol, pointtol); + if ( (dimension == 2 && !GetNSE()) || + (dimension == 3 && !GetNE() && !GetNSE()) ) + return -1; + if (dimension == 2 || (dimension==3 && !GetNE() && GetNSE())) { int ne; diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 806b6c39..5eaa02d0 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -1140,6 +1140,7 @@ namespace netgen default: break; cerr << "Element::SetType unknown type " << int(typ) << endl; } + is_curved = (np > 4); } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 41fdb11a..a2f76986 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -765,11 +765,12 @@ namespace netgen void DoArchive (Archive & ar) { short _np, _typ; + bool _curved; if (ar.Output()) - { _np = np; _typ = typ; } - ar & _np & _typ & index; + { _np = np; _typ = typ; _curved = is_curved; } + ar & _np & _typ & index & _curved; if (ar.Input()) - { np = _np; typ = ELEMENT_TYPE(_typ); } + { np = _np; typ = ELEMENT_TYPE(_typ); is_curved = _curved; } for (size_t i = 0; i < np; i++) ar & pnum[i]; } diff --git a/libsrc/meshing/parallelmesh.cpp b/libsrc/meshing/parallelmesh.cpp index 7b1248a6..45d6f98b 100644 --- a/libsrc/meshing/parallelmesh.cpp +++ b/libsrc/meshing/parallelmesh.cpp @@ -745,6 +745,38 @@ namespace netgen MPI_Barrier(comm); + PrintMessage( 3, "Clean up local memory"); + + auto & self = const_cast(*this); + self.points = T_POINTS(0); + self.surfelements = T_SURFELEMENTS(0); + self.volelements = T_VOLELEMENTS(0); + self.segments = Array(0); + self.lockedpoints = Array(0); + auto cleanup_ptr = [](auto & ptr) { + if (ptr != nullptr) { + delete ptr; + ptr = nullptr; + } + }; + cleanup_ptr(self.boundaryedges); + cleanup_ptr(self.boundaryedges); + cleanup_ptr(self.segmentht); + cleanup_ptr(self.surfelementht); + self.openelements = Array(0); + self.opensegments = Array(0); + self.numvertices = 0; + self.mlbetweennodes = Array,PointIndex::BASE> (0); + self.mlparentelement = Array(0); + self.mlparentsurfaceelement = Array(0); + self.topology.Update(); + self.curvedelems = new CurvedElements (self); + self.clusters = new AnisotropicClusters (self); + self.ident = new Identifications (self); + self.BuildElementSearchTree(); + + // const_cast(*this).DeleteMesh(); + PrintMessage( 3, "send mesh complete"); } diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 5c4cfbcb..18f0ee0f 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -17,6 +17,8 @@ namespace netgen { extern bool netgen_executable_started; extern shared_ptr ng_geometry; + extern void Optimize2d (Mesh & mesh, MeshingParameters & mp); + #ifdef PARALLEL /** we need allreduce in python-wrapped communicators **/ template @@ -865,14 +867,21 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) }, py::arg("mp")=NGDummyArgument(),py::call_guard()) - .def ("OptimizeVolumeMesh", FunctionPointer - ([](Mesh & self) + .def ("OptimizeVolumeMesh", [](Mesh & self) { MeshingParameters mp; mp.optsteps3d = 5; OptimizeVolume (mp, self); - }),py::call_guard()) + },py::call_guard()) + .def ("OptimizeMesh2d", [](Mesh & self) + { + self.CalcLocalH(0.5); + MeshingParameters mp; + mp.optsteps2d = 5; + Optimize2d (self, mp); + },py::call_guard()) + .def ("Refine", FunctionPointer ([](Mesh & self) { @@ -975,12 +984,17 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) }, py::arg("name"), py::arg("set")=true) - .def ("Scale", FunctionPointer([](Mesh & self, double factor) - { - for(auto i = 0; i (); + *m2 = self; + return m2; + }) ; m.def("ImportMesh", [](const string& filename) diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index 65505e5e..64ed1818 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -4005,8 +4005,8 @@ namespace netgen Array compress(n3); NgProfiler::StartTimer (timer_vals); - Array vertval(mesh->GetNV()); - Array posval(mesh->GetNV()); + Array vertval(mesh->GetNP()); + Array posval(mesh->GetNP()); for (PointIndex pi = vertval.Begin(); pi < vertval.End(); pi++) { Point<3> vert = (*mesh)[pi]; diff --git a/tests/build_mpi.sh b/tests/build_mpi.sh new file mode 100644 index 00000000..464bb395 --- /dev/null +++ b/tests/build_mpi.sh @@ -0,0 +1,6 @@ +cd +mkdir -p build/netgen +cd build/netgen +cmake ../../src/netgen -DUSE_CCACHE=ON -DUSE_MPI=ON +make -j12 +make install diff --git a/tests/dockerfile_mpi b/tests/dockerfile_mpi new file mode 100644 index 00000000..ddb7e51b --- /dev/null +++ b/tests/dockerfile_mpi @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +ENV DEBIAN_FRONTEND=noninteractive +MAINTAINER Matthias Hochsteger +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 python3-tk clang-tidy python3-distutils clang libopenmpi-dev openmpi-bin gfortran +ADD . /root/src/netgen