Skip to content

Commit

Permalink
bdf_vectorized3:
Browse files Browse the repository at this point in the history
 - finally adding thermal tests
 - adding test for tri_volume/quad_volume
  • Loading branch information
SteveDoyle2 committed Jan 2, 2024
1 parent 18b0e92 commit 04e8a26
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
9 changes: 5 additions & 4 deletions pyNastran/dev/bdf_vectorized3/cards/elements/shell_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ def tri_volume(grid: GRID,
assert normal.shape == (nelements, 3)
unit_normal = normal / norm[:, np.newaxis]

iequal = (dthickness.max(axis=0) == dthickness.min(axis=0))
iequal = (dthickness.max(axis=1) == dthickness.min(axis=1))
assert len(iequal) == nelements

inot_equal = ~iequal
nequal = iequal.sum()
nnot_equal = inot_equal.sum()
Expand Down Expand Up @@ -264,7 +266,8 @@ def quad_volume(grid: GRID,
assert normal.shape == (nelements, 3)
unit_normal = normal / norm[:, np.newaxis]

iequal = (dthickness.max(axis=0) == dthickness.min(axis=0))
iequal = (dthickness.max(axis=1) == dthickness.min(axis=1))
assert len(iequal) == nelements
inot_equal = ~iequal
nequal = iequal.sum()
nnot_equal = inot_equal.sum()
Expand All @@ -288,8 +291,6 @@ def quad_volume(grid: GRID,
return volume




def shell_thickness(model: BDF,
tflag: np.ndarray,
T: np.ndarray,
Expand Down
3 changes: 2 additions & 1 deletion pyNastran/dev/bdf_vectorized3/cards/test/all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_rigid import *
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_rods import *
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_sets import *
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_shells import TestShells, TestAcoustic
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_shells import TestShells, TestAxisymmetricShells, TestAcoustic
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_solids import *
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_springs import *
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_superelements import *
from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_thermal import *


if __name__ == '__main__': # pragma: no cover
Expand Down
50 changes: 49 additions & 1 deletion pyNastran/dev/bdf_vectorized3/cards/test/test_vector_shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pyNastran.dev.bdf_vectorized3.cards.test.utils import save_load_deck
#from pyNastran.bdf.mesh_utils.mass_properties import (
#mass_properties, mass_properties_no_xref, mass_properties_nsm)

from pyNastran.dev.bdf_vectorized3.cards.elements.shell_utils import tri_volume, quad_volume

#try:
#import matplotlib
Expand Down Expand Up @@ -1751,6 +1751,54 @@ def test_pshln2(self):
model.pshln2.write()
save_load_deck(model)

def test_tri_volume(self):
log = get_logger(level='warning')
model = BDF(log=log)
rho = 0.0
nu = 0.3
E = 3.0e7
G = None
t = 1.0
nsm = 0.0
self._make_ctria3(model, rho, nu, G, E, t, nsm)
model.setup()

ctria3 = model.ctria3
nodes = ctria3.nodes
nelements = len(ctria3)
area = ctria3.area()
average_thickness = 3.1
expected_volume = area * average_thickness

dthickness = np.ones((nelements, 3), dtype='float64') * average_thickness
vol = tri_volume(model.grid, nodes, dthickness)
assert np.allclose(vol, expected_volume), (vol, expected_volume)


def test_quad_volume(self):
log = get_logger(level='warning')
model = BDF(log=log)
rho = 0.0
nu = 0.3
E = 3.0e7
G = None
t = 1.0
nsm = 0.0
self._make_cquad4(model, rho, nu, G, E, t, nsm)
model.setup()

cquad4 = model.cquad4
nodes = cquad4.nodes
nelements = len(cquad4)
area = cquad4.area()
average_thickness = 3.1
expected_volume = area * average_thickness

dthickness = np.ones((nelements, 4), dtype='float64') * average_thickness
vol = quad_volume(model.grid, nodes, dthickness)
assert np.allclose(vol, expected_volume), (vol, expected_volume)


class TestAxisymmetricShells(unittest.TestCase):
def test_cquadx4(self):
"""tests a CQUADX4"""
Expand Down

0 comments on commit 04e8a26

Please sign in to comment.