mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
set default bcname to valid string pointer, some occ tests
This commit is contained in:
parent
9537ccdb7a
commit
06031e665a
@ -626,11 +626,9 @@ namespace netgen
|
||||
for(auto k : Range(faces))
|
||||
{
|
||||
auto & face = *faces[k];
|
||||
mesh.SetBCName(k, face.properties.GetName());
|
||||
// todo find attached solids
|
||||
FaceDescriptor fd(k+1, face.domin+1, face.domout+1, k+1);
|
||||
fd.SetBCName(mesh.GetBCNamePtr(k));
|
||||
mesh.AddFaceDescriptor(fd);
|
||||
mesh.SetBCName(k, face.properties.GetName());
|
||||
if(face.primary == &face)
|
||||
{
|
||||
if(MeshFace(mesh, mparam, k, glob2loc))
|
||||
|
@ -6887,14 +6887,11 @@ namespace netgen
|
||||
int oldsize = bcnames.Size();
|
||||
bcnames.SetSize (bcnr+1); // keeps contents
|
||||
for (int i = oldsize; i <= bcnr; i++)
|
||||
bcnames[i] = nullptr;
|
||||
bcnames[i] = new string("default");
|
||||
}
|
||||
|
||||
if ( bcnames[bcnr] ) delete bcnames[bcnr];
|
||||
if ( abcname != "default" )
|
||||
bcnames[bcnr] = new string ( abcname );
|
||||
else
|
||||
bcnames[bcnr] = nullptr;
|
||||
bcnames[bcnr] = new string ( abcname );
|
||||
|
||||
for (auto & fd : facedecoding)
|
||||
if (fd.BCProperty() <= bcnames.Size())
|
||||
|
43
tests/pytest/test_occ.py
Normal file
43
tests/pytest/test_occ.py
Normal file
@ -0,0 +1,43 @@
|
||||
import pytest
|
||||
import math
|
||||
from pytest import approx
|
||||
from pytest_check import check
|
||||
|
||||
def check_volume(shape, volume, dim=3):
|
||||
from netgen.occ import OCCGeometry
|
||||
geo = OCCGeometry(shape, dim=dim)
|
||||
|
||||
m = geo.GenerateMesh()
|
||||
assert len(m.Elements2D()) > 0
|
||||
assert len(m.Elements1D()) > 0
|
||||
if dim==3:
|
||||
assert len(m.Elements3D()) > 0
|
||||
|
||||
ngs = pytest.importorskip("ngsolve")
|
||||
mesh = ngs.Mesh(m)
|
||||
mesh.Curve(5)
|
||||
with check: assert ngs.Integrate(1.0, mesh) == approx(volume)
|
||||
|
||||
def test_rect_with_two_holes():
|
||||
occ = pytest.importorskip("netgen.occ")
|
||||
|
||||
face = occ.WorkPlane().Rectangle(7,4) \
|
||||
.Circle(2,2,1).Reverse() \
|
||||
.Circle(5,2,1).Reverse().Face()
|
||||
check_volume(face, 7*4-2*math.pi, 2)
|
||||
|
||||
def test_unit_square():
|
||||
occ = pytest.importorskip("netgen.occ")
|
||||
check_volume(occ.unit_square.shape, 1, dim=2)
|
||||
|
||||
def test_box_and_cyl():
|
||||
occ = pytest.importorskip("netgen.occ")
|
||||
box = occ.Box(occ.Pnt(0,0,0), occ.Pnt(1,1,1))
|
||||
check_volume(box, 1)
|
||||
r = 0.3
|
||||
h = 0.5
|
||||
vcyl = r*r*math.pi*h
|
||||
cyl = occ.Cylinder(occ.Pnt(1,0.5,0.5), occ.X, r=r, h=h)
|
||||
check_volume(cyl, vcyl)
|
||||
fused = box+cyl
|
||||
check_volume(fused, 1+vcyl)
|
Loading…
Reference in New Issue
Block a user