@@ -941,6 +941,42 @@ def test_extractloops(self):
941941 bcutloop .pop ()
942942 self .assertEqual (bcutloop , expected_fc )
943943
944+ def test_meshrefine_addnode (self ):
945+ no1 , el1 , fc1 = meshrefine (self .nbox , self .ebox , [[0.2 , 1 , 1 ], [0.2 , 1 , 2 ]])
946+ self .assertEqual (no1 .shape [0 ] - self .nbox .shape [0 ], 2 )
947+ self .assertEqual (el1 .shape [0 ] - self .ebox .shape [0 ], 7 )
948+ self .assertEqual (no1 [- 2 :, :].tolist (), [[0.2 , 1 , 1 ], [0.2 , 1 , 2 ]])
949+ no1 , el1 , fc1 = meshrefine (
950+ self .nbox , self .ebox , newnode = [[0.2 , 1 , 1 ], [0.2 , 1 , 2 ]]
951+ )
952+ self .assertEqual (no1 [- 2 :, :].tolist (), [[0.2 , 1 , 1 ], [0.2 , 1 , 2 ]])
953+
954+ def test_meshrefine_maxvol (self ):
955+ no1 , el1 , fc1 = meshrefine (self .nbox , self .ebox , maxvol = 0.02 )
956+ self .assertEqual (np .sum (elemvolume (no1 [:, :3 ], el1 [:, :4 ])), 2 )
957+ self .assertEqual (np .sum (elemvolume (no1 [:, :3 ], fc1 [:, :3 ])), 10 )
958+ self .assertTrue (np .max (elemvolume (no1 [:, :3 ], el1 [:, :4 ])) < 0.02 )
959+ no1 , el1 , fc1 = meshrefine (self .nbox , self .ebox , maxvol = 0.01 )
960+ self .assertTrue (np .max (elemvolume (no1 [:, :3 ], el1 [:, :4 ])) < 0.01 )
961+
962+ def test_meshrefine_sizefield (self ):
963+ no1 , el1 , fc1 = meshrefine (
964+ self .nbox , self .ebox , sizefield = (self .nbox [:, 0 ] + 0.1 ) * 0.3
965+ )
966+ self .assertEqual (np .sum (elemvolume (no1 [:, :3 ], el1 [:, :4 ])), 2 )
967+ self .assertAlmostEqual (
968+ np .mean (elemvolume (no1 [:, :3 ], el1 [:, :4 ])), 0.00019615535504119262 , 8
969+ )
970+
971+ def test_meshrefine_externalnode (self ):
972+ node , face , elem = meshasphere ([0 , 0 , 0 ], 24 , 5 , 100 )
973+ extnodes = [[- 5 , - 5 , 25 ], [- 5 , 5 , 25 ], [5 , 5 , 25 ], [5 , - 5 , 25 ]]
974+ no1 , el1 , fc1 = meshrefine (node , elem , newnode = extnodes , extcmdopt = "-Y" )
975+ self .assertEqual (no1 .shape [0 ] - node .shape [0 ], 4 )
976+ self .assertAlmostEqual (
977+ np .sum (elemvolume (no1 [:, :3 ], el1 [:, :4 ])), 56628.62907381002 , 2
978+ )
979+
944980
945981class Test_surfboolean (unittest .TestCase ):
946982 def __init__ (self , * args , ** kwargs ):
0 commit comments