Merge remote-tracking branch 'origin/master' into memory_tracing

This commit is contained in:
Matthias Hochsteger 2020-11-24 15:31:00 +01:00
commit 916eb09f1e
7 changed files with 136 additions and 20 deletions

View File

@ -418,12 +418,12 @@ endif(USE_CGNS)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/netgen_version.hpp ${CMAKE_CURRENT_BINARY_DIR}/netgen_config.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel)
add_subdirectory(windows)
add_subdirectory(libsrc)
add_subdirectory(ng)
add_subdirectory(tutorials)
add_subdirectory(py_tutorials)
add_subdirectory(doc)
add_subdirectory(windows)
add_subdirectory(nglib)
if (USE_PYTHON)
add_subdirectory(python)

View File

@ -411,6 +411,10 @@ namespace netgen
}
}
BitArray fixed_points(np+1);
fixed_points.Clear();
BitArray moveboundarypoint(np+1);
moveboundarypoint.Clear();
for(SurfaceElementIndex si = 0; si < nse; si++)
{
// copy because surfaceels array will be resized!
@ -439,11 +443,30 @@ namespace netgen
newel.SetIndex(si_map[sel.GetIndex()]);
mesh.AddSurfaceElement(newel);
}
else
{
bool has_moved = false;
for(auto p : sel.PNums())
if(mapto[p].Size())
has_moved = true;
if(has_moved)
for(auto p : sel.PNums())
{
if(!mapto[p].Size())
{
fixed_points.SetBit(p);
if(move_boundaries.Test(sel.GetIndex()))
moveboundarypoint.SetBit(p);
}
}
}
if(move_boundaries.Test(sel.GetIndex()))
{
for(auto& p : mesh[si].PNums())
if(mapto[p].Size())
p = mapto[p].Last();
}
}
for(SegmentIndex sei = 0; sei < nseg; sei++)
{
@ -456,13 +479,85 @@ namespace netgen
for(ElementIndex ei = 0; ei < ne; ei++)
{
auto& el = mesh[ei];
if(!domains[el.GetIndex()])
auto el = mesh[ei];
ArrayMem<PointIndex,4> fixed;
ArrayMem<PointIndex,4> moved;
bool moved_bnd = false;
for(const auto& p : el.PNums())
{
for(auto& p : el.PNums())
if(fixed_points.Test(p))
fixed.Append(p);
if(mapto[p].Size())
moved.Append(p);
if(moveboundarypoint.Test(p))
moved_bnd = true;
}
bool do_move, do_insert;
if(domains.Test(el.GetIndex()))
{
do_move = fixed.Size() && moved_bnd;
do_insert = do_move;
}
else
{
do_move = !fixed.Size() || moved_bnd;
do_insert = !do_move;
}
if(do_move)
{
for(auto& p : mesh[ei].PNums())
if(mapto[p].Size())
p = mapto[p].Last();
}
if(do_insert)
{
if(el.GetType() != TET)
throw Exception("Boundarylayer only implemented for tets outside yet!");
if(moved.Size() == 2)
{
if(fixed.Size() == 2)
throw Exception("This should not be possible!");
PointIndex p1 = moved[0];
PointIndex p2 = moved[1];
for(auto i : Range(blp.heights))
{
PointIndex p3 = mapto[moved[1]][i];
PointIndex p4 = mapto[moved[0]][i];
Element nel(PYRAMID);
nel[0] = p1;
nel[1] = p2;
nel[2] = p3;
nel[3] = p4;
nel[4] = el[0] + el[1] + el[2] + el[3] - fixed[0] - moved[0] - moved[1];
if(Cross(mesh[p2]-mesh[p1], mesh[p4]-mesh[p1]) * (mesh[nel[4]]-mesh[nel[1]]) > 0)
Swap(nel[1], nel[3]);
nel.SetIndex(el.GetIndex());
mesh.AddVolumeElement(nel);
p1 = p4;
p2 = p3;
}
}
if(moved.Size() == 1 && fixed.Size() == 1)
{
PointIndex p1 = moved[0];
for(auto i : Range(blp.heights))
{
Element nel = el;
PointIndex p2 = mapto[moved[0]][i];
for(auto& p : nel.PNums())
{
if(p == moved[0])
p = p1;
else if(p == fixed[0])
p = p2;
}
p1 = p2;
mesh.AddVolumeElement(nel);
}
}
}
}
for(auto i : Range(1, fd_old+1))

View File

@ -4,11 +4,9 @@ else()
add_definitions(-DINTERNAL_TCL_DEFAULT=0)
endif()
set(netgen_sources ngappinit.cpp onetcl.cpp)
if(WIN32)
# add icon to netgen executable
# add icon and version info to netgen executable
enable_language(RC)
set(netgen_sources ${netgen_sources} ../windows/netgen.rc)
# Don't use ccache here due to incompatibility with the resource compiler
set_directory_properties(PROPERTIES RULE_LAUNCH_COMPILE "")
endif(WIN32)
@ -23,6 +21,9 @@ if(USE_GUI)
)
add_executable(netgen ngappinit.cpp)
if(WIN32)
target_sources(netgen PRIVATE ../windows/netgen.rc)
endif(WIN32)
target_link_libraries( gui PUBLIC nglib )
target_link_libraries( gui PRIVATE ${LIBTOGL} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_Xmu_LIB} ${X11_X11_LIB} ${OCC_LIBRARIES} )

View File

@ -92,3 +92,18 @@ def test_splitted_surface():
mesh = ngs.Mesh(mesh)
assert ngs.Integrate(1, mesh) == pytest.approx(1)
assert ngs.Integrate(1, mesh.Materials("slot")) == pytest.approx(0.4)
@pytest.mark.parametrize("outside", [True, False])
def test_pyramids(outside):
geo = CSGeometry()
box = OrthoBrick((0,0,0), (1,1,1))
plate = OrthoBrick((0.3,0.3,0.4),(0.7,0.7,1)) * Plane((0,0,0.6), (0,0,1)).bc("top")
geo.Add((box-plate).mat("air"))
geo.Add(plate.mat("plate"))
mesh = geo.GenerateMesh()
mesh.BoundaryLayer("top", [0.01], "layer", "plate", outside=outside)
ngs = pytest.importorskip("ngsolve")
mesh = ngs.Mesh(mesh)
assert ngs.Integrate(1, mesh.Materials("plate")) == pytest.approx(0.032 if outside else 0.0304)
assert ngs.Integrate(1, mesh.Materials("layer")) == pytest.approx(0.0016)
assert ngs.Integrate(1, mesh.Materials("air")) == pytest.approx(0.9664 if outside else 0.968)

1
windows/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
netgen.rc

View File

@ -0,0 +1,4 @@
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/netgen.rc.template"
"${CMAKE_CURRENT_SOURCE_DIR}/netgen.rc"
IMMEDIATE @ONLY)

View File

@ -7,7 +7,7 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
#include <windows.h>
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@ -35,8 +35,8 @@ LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,1,0,0
PRODUCTVERSION 5,1,0,0
FILEVERSION @NETGEN_VERSION_MAJOR@,@NETGEN_VERSION_MINOR@,@NETGEN_VERSION_PATCH@,@NETGEN_VERSION_TWEAK@
PRODUCTVERSION @NETGEN_VERSION_MAJOR@,@NETGEN_VERSION_MINOR@,@NETGEN_VERSION_PATCH@,@NETGEN_VERSION_TWEAK@
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x3L
@ -51,14 +51,14 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Vienna UT"
VALUE "CompanyName", "TU Wien"
VALUE "FileDescription", "Netgen Meshing Software"
VALUE "FileVersion", "5.1-dev"
VALUE "FileVersion", "@NETGEN_VERSION@"
VALUE "InternalName", "Netgen"
VALUE "LegalCopyright", "GNU Public License (GPL)"
VALUE "LegalCopyright", "GNU Lesser General Public License (LGPL)"
VALUE "OriginalFilename", "Netgen.exe"
VALUE "ProductName", "Netgen"
VALUE "ProductVersion", "5.1-dev"
VALUE "ProductVersion", "@NETGEN_VERSION@"
END
END
BLOCK "VarFileInfo"