Example #1
0
    def __init__(self, log=None, debug=False):
        self.log = get_logger(log, 'debug' if debug else 'info')

        self.nodes = None
        self.elements = None
        self.header = ''
        self.infilename = None
    def __init__(self, inputs=None):
        if inputs is None:
            inputs = {
                'magnify' : 1,
                'debug' : False,
                'console' : True,
            }

        res_widget = MockResWidget()
        GuiAttributes.__init__(self, inputs, res_widget)
        self.is_testing = True
        self.debug = False
        self._form = []
        self.result_cases = {}
        self._finish_results_io = self.passer1
        self._finish_results_io2 = self.passer2
        #self.geometry_actors = {
            #'main' : GeometryActor(),
        #}
        self.grid = Grid()
        self.scalarBar = ScalarBar()
        self.alt_geometry_actor = ScalarBar()
        self.alt_grids = {
            'main' : self.grid,
        }
        #self.geometry_properties = {
            ##'main' : None,
            ##'caero' : None,
            ##'caero_sub' : None,
        #}
        #self._add_alt_actors = _add_alt_actors

        level = 'debug' if self.debug else 'info'
        self.log = get_logger(log=None, level=level)
Example #3
0
 def __init__(self, log=None, debug=None):
     self.nodes = None
     self.tris = None
     self.tets = None
     self.bcs = None
     self.precision = 'double'
     self.log = get_logger(log, 'debug' if debug else 'info')
Example #4
0
    def __init__(self, log=None, debug=True):
        self.infilename = None
        self.title_lines = []
        self.xz_symmetry = 0
        self.xy_symmetry = 0
        self.nsymmetry_planes = 0
        self.title = ''

        self.nnetworks = 0
        self.patches = {}
        self.lines = []

        self.alphas = [0.]
        self.ncases = None
        self.betas = [0.]
        self.alpha_compressibility = 0.
        self.beta_compressibility = 0.

        self.sref = 1.
        self.bref = 1.
        self.cref = 1.
        self.dref = 1.

        self.xref = 0.
        self.yref = 0.
        self.zref = 0.

        self.isings = 0.0
        self.isingp = 0.0
        self.igeomp = 0.0
        self.icontp = 0.0
        self.ibconp = 0.0
        self.iedgep = 0.0
        self.ipraic = 0.0
        self.nexdgn = 0.0
        self.ioutpr = 0.0
        self.ifmcpr = 0.0
        self.icostp = 0.0

        self.epsgeo = 0.0
        self.igeoin = -1.0
        self.igeout = 0.
        self.nwxref = 0.
        self.triint = 0.0
        self.iabsum = -0.0
        self.is_end = None
        self.pea_section = ''
        self.mach = 0.0
        self.data_check = 2
        self.title_section = ''
        self.xyz_section = ''
        self.streamline_section = ''
        self.flow_section = ''
        self.sectional_prop_section = ''
        self.grid_section = ''
        self.symmetry_section = ''

        self.msg = ''
        self.log = get_logger(log, 'debug' if debug else 'info')
Example #5
0
 def __init__(self, log=None, debug=False):
     self.readHalf = False
     self.cartType = None  # grid, results
     self.nPoints = None
     self.nElements = None
     self.infile = None
     self.infilename = None
     self.log = get_logger(log, 'debug' if debug else 'info')
Example #6
0
    def _start_log(self, log=None, debug=False):
        """
        Sets up a dummy logger if one is not provided

        :self:  the object pointer
        :log:   a python logging object
        :debug: adds debug messages (True/False)
        """
        self.log = get_logger(log, 'debug' if debug else 'info')
Example #7
0
    def __init__(self, log=None, debug=True):
        self.nNetworks = 0
        self.patches = {}
        self.lines = []

        self.alphas = [0.]
        self.ncases = None
        self.betas = [0.]
        self.alphaC = 0.
        self.betaC = 0.

        self.sref = 1.
        self.bref = 1.
        self.cref = 1.
        self.dref = 1.

        self.xref = 0.
        self.yref = 0.
        self.zref = 0.

        self.isings = 0.0
        self.isingp = 0.0
        self.igeomp = 0.0
        self.icontp = 0.0
        self.ibconp = 0.0
        self.iedgep = 0.0
        self.ipraic = 0.0
        self.nexdgn = 0.0
        self.ioutpr = 0.0
        self.ifmcpr = 0.0
        self.icostp = 0.0

        self.epsgeo = 0.0
        self.igeoin = -1.0
        self.igeout = 0.
        self.nwxref = 0.
        self.triint = 0.0
        self.iabsum = -0.0

        self.isEnd = None

        self.peaSection = ''


        self.mach = 0.0
        self.dataCheck = 2
        self.titleSection = ''
        self.xyzSection = ''
        self.streamlineSection = ''
        self.flowSection = ''
        self.sectionalPropSection = ''
        self.gridSection = ''
        self.symmetrySection = ''

        self.msg = ''

        self.log = get_logger(log, 'debug' if debug else 'info')
Example #8
0
    def __init__(self, lines, log=None):
        """
        Parameters
        ----------
        lines : List[str]
            list of lines that represent the case control deck
            ending with BEGIN BULK
        log : log()
            a :mod: `logging` object
        """
        # pulls the logger from the BDF object
        self.log = get_logger(log, "debug")
        self.debug = False

        self.sol_200_map = {
            'STATICS' : 101,
            'STATIC' : 101,

            'MODES' : 103,
            'MODE' : 103,

            'BUCK' : 105,
            'BUCKLING' : 105,

            'DFREQ' : 108,
            'MFREQ' : 111,
            'SAERO' : 144,

            'FLUTTER' : 145,
            'FLUT' : 145,

            'DIVERGE' : 144,
            'DIVERG' : 145,

            # 'HEAT' : ,
            # 'STRUCTURE' : ,
            'NLSTATICS' : 400,
            'LNSTATICS' : 400,
            'MTRAN' : 112,
            'DCEIG' : None,
        }
        # 'HEAT', 'ANALYSIS', 'MFREQ', 'STATICS', 'MODES', 'DFREQ',
        # 'MTRAN', 'BUCK', 'MCEIG', 'DCEIG', 'SAERO', 'NLSTATIC', 'NLSTAT',
        # 'STATIC', 'MTRANS', 'MODE', 'FLUTTER', 'DIVERG', 'NLTRAN', 'FLUT',
        #self.debug = True

        #: stores a single copy of 'BEGIN BULK' or 'BEGIN SUPER'
        self.begin_bulk = ['BEGIN', 'BULK']

        # allows BEGIN BULK to be turned off
        self.write_begin_bulk = True
        self._begin_count = 0

        self.lines = lines
        self.subcases = {0: Subcase(id=0)}
        self._read(self.lines)
Example #9
0
def add_dummy_gui_functions(test):
    def removeOldGeometry(self):
        pass
    def cycleResults(self):
        pass
    def TurnTextOn():
        pass
    def TurnTextOff():
        pass
    def update_axes_length(value):
        pass
    def passer():
        pass
    def passer2(a, b):
        pass

    class Grid(object):
        def Reset(self):
            pass
        def Allocate(self, nelements, delta):
            pass
        def InsertNextCell(self, *cell):
            pass
        def SetPoints(self, *cell):
            pass
        def Modified(self):
            pass
        def Update(self):
            pass

    class ScalarBar(object):
        def VisibilityOff(self):
            pass
        def VisibilityOn(self):
            pass
        def Modified(self):
            pass

    test._finish_results_io2 = passer2

    test.grid = Grid()
    test.grid2 = Grid()
    test.scalarBar = ScalarBar()
    test.alt_geometry_actor = ScalarBar()

    test.log = get_logger(log=None, level='debug')
    test.log_info = print
    test.removeOldGeometry = removeOldGeometry
    test.cycleResults = cycleResults
    test.TurnTextOn = TurnTextOn
    test.TurnTextOff = TurnTextOff
    test.update_axes_length = update_axes_length
    test.cycleResults_explicit = passer
Example #10
0
    def __init__(self, infileName, log=None, debug=True):
        assert os.path.exists(infileName), print_bad_path(infileName)

        self.infileName = infileName
        self.nNetworks = 0
        self.patches = {}
        self.lines = []

        self.alphas = [0.]
        self.ncases = None
        self.betas = [0.]
        self.alphaC = 0.
        self.betaC = 0.

        self.sref = 1.
        self.bref = 1.
        self.cref = 1.
        self.dref = 1.

        self.xref = 0.
        self.yref = 0.
        self.zref = 0.

        self.isings = 0.0
        self.isingp = 0.0
        self.igeomp = 0.0
        self.icontp = 0.0
        self.ibconp = 0.0
        self.iedgep = 0.0
        self.ipraic = 0.0
        self.nexdgn = 0.0
        self.ioutpr = 0.0
        self.ifmcpr = 0.0
        self.icostp = 0.0

        self.isEnd = None

        self.peaSection = ''


        self.mach = 0.0
        self.dataCheck = 2
        self.titleSection = ''
        self.xyzSection = ''
        self.streamlineSection = ''
        self.flowSection = ''
        self.sectionalPropSection = ''
        self.gridSection = ''

        self.msg = ''

        self.log = get_logger(log, 'debug' if debug else 'info')
Example #11
0
 def __init__(self, log=None, debug=False):
     self.log = get_logger(log, 'debug' if debug else 'info')
     self._endian = b''
     self.n = 0
     self.infile = None
     # self.readHalf = False
     # self.nPoints = None
     # self.nElements = None
     self.infilename = None
     self.points = None
     self.elements = None
     self.regions = None
     self.loads = {}
Example #12
0
    def __init__(self, log=None, debug=False):
        ShabpOut.__init__(self, log, debug)
        #self.xyz = {}
        self.X = {}
        self.Y = {}
        self.Z = {}
        self.trailer = None

        self.component_name_to_patch = {}
        self.patch_to_component_num = {}
        self.component_to_params = {}
        self.component_num_to_name = {}
        self.component_name_to_num = {}
        self.log = get_logger(log, 'debug' if debug else 'info')
Example #13
0
    def __init__(self, log=None, debug=False):
        self.log = get_logger(log, 'debug' if debug else 'info')
        self._endian = b''
        self.n = 0
        self.infile = None
        self.readHalf = False
        self.cartType = None  # grid, results
        self.nPoints = None
        self.nElements = None
        self.infilename = None

        # updated later
        self.nResults = 0
        self.nElementsSkip = 0
        self.nElementsRead = 0
Example #14
0
    def __init__(self, log=None, debug=False):
        FortranFormat.__init__(self)
        self.endian = b'<'
        self.log = get_logger(log, 'debug' if debug else 'info')
        self.debug = debug
        self.xyz = array([], dtype='float32')

        self.tet_elements = array([], dtype='int32')
        self.hexa_elements = array([], dtype='int32')

        self.quad_elements = array([], dtype='int32')
        self.tri_elements = array([], dtype='int32')

        self.results = array([], dtype='float32')
        self.tecplot_filename = ''
        self.variables = []
Example #15
0
    def __init__(self, log=None, debug=False):
        #FortranFormat.__init__(self)
        self.log = get_logger(log, 'debug' if debug else 'info')
        self.debug = debug
        self.n = 0

        self.nodes = array([], dtype='float32')
        self.tris = array([], dtype='int32')
        self.quads = array([], dtype='int32')
        self.pids = array([], dtype='int32')

        self.tets = array([], dtype='int32')
        self.penta5s = array([], dtype='int32')
        self.penta6s = array([], dtype='int32')
        self.hexas = array([], dtype='int32')

        self.isort = None
Example #16
0
    def __init__(self, fem, pids, debug=False):
        Model.__init__(self)

        self.log = get_logger(None, 'debug' if debug else 'info')

        self.debug = debug
        if self.debug:
            print("*StructuralModel.init")
        self.fem = fem
        #nodes = fem.getNodes()
        #elements = fem.getElements()
        nodeIDs = fem.node_ids
        elementIDs = fem.elementIDs()

        self.nNodes = len(nodeIDs)
        self.nElements = len(elementIDs)
        self.pids = pids
        #self.points   = points
        #self.elements = elements
        if self.debug:
            self.log.debug("***StructuralModel.init")
Example #17
0
    def __init__(self, lines, log=None):
        """
        :param self:  the CaseControlDeck object
        :param lines: list of lines that represent the case control deck
                ending with BEGIN BULK
        :param log:   a :mod: `logging` object
        """
        # pulls the logger from the BDF object
        self.log = get_logger(log, "debug")
        self.debug = False
        #self.debug = True

        #: stores a single copy of 'BEGIN BULK' or 'BEGIN SUPER'
        self.begin_bulk = ['BEGIN', 'BULK']

        # allows BEGIN BULK to be turned off
        self.write_begin_bulk = True
        self._begin_count = 0

        self.lines = lines
        self.subcases = {0: Subcase(id=0)}
        self._read(self.lines)
Example #18
0
# my code
from mathFunctions import pierce_plane_vector, shepard_weight, Normal, ListPrint

# from mathFunctions import get_triangle_weights
from structural_model import StructuralModel
from aero_model import AeroModel
from kdtree import KdTree

# pyNastran
from pyNastran.converters.cart3d.cart3d_reader import Cart3DReader
from pyNastran.bdf.bdf import BDF
from pyNastran.utils.log import get_logger

debug = True
log = get_logger(None, "debug" if debug else "info")

# ------------------------------------------------------------------


def entryExit(f):
    def new_f(*args, **kwargs):
        log.info("Entering", f.__name__)
        f(*args, **kwargs)
        log.info("Exited", f.__name__)

    return new_f


class LoadMapping(object):
    def __init__(self, aeroModel, structuralModel, configpath="", workpath=""):
Example #19
0
 def test_stl_to_cart3d_01(self):
     log = get_logger(level='warning')
     stl_filename = os.path.join(TEST_PATH, 'sphere.stl')
     cart3d_filename = os.path.join(TEST_PATH, 'sphere.tri')
     stl_to_cart3d(stl_filename, cart3d_filename, log=log)
     os.remove(cart3d_filename)
Example #20
0
from pyNastran.utils.log import get_logger

log = None
debug = True
log = get_logger(log, 'debug' if debug else 'info')

def run_arg_parse():
    msg  = 'This program creates a CFD tet mesh from a nastran surface..\n'
    msg += 'Usage:\n'
    msg += '  stl_reader INPUT [-o OUTPUT]\n'
    msg += '             [-n] [-q]\n'
    msg += '  stl_reader -h | --help\n'
    msg += '  stl_reader -v | --version\n'
    msg += "  INPUT      path to input file\n"
    msg += "\n"
    msg += "Options:\n"
    msg += "  -h, --help                  show this help message and exit\n"
    msg += "  -f FORMAT, --format FORMAT  format type (usm3d, fun3d)\n"
    msg += "  -o OUTPUT, --output OUTPUT  path to output file\n"
    msg += "  -n, --normal                flip the element normals\n"
    #msg += "  -r XYZ, --rotation XYZ      [x, y, z, -x, -y, -z] default is ???\n"

    msg += "  -q, --quiet                 prints debug messages (default=True)\n"
    msg += "  -v, --version               show program's version number and exit\n"

    ver = str(pyNastran.__version__)
    data = docopt(msg, version=ver)
    #print data

    #format  = data['--format']
    input = data['INPUT']
Example #21
0
    def test_tecplot_01(self):
        log = get_logger(level='warning')
        tecplot_filename1 = os.path.join(model_path, 'ascii', 'point_fetri_2d_02.dat')
        tecplot_filename2 = os.path.join(model_path, 'ascii', 'point_fetri_2d_02.dat_out')

        tecplot = read_tecplot(tecplot_filename1, log=log)
Example #22
0
 def test_tecplot_02(self):
     log = get_logger(level='warning')
     nastran_filename1 = os.path.join(nastran_path, 'solid_bending', 'solid_bending.bdf')
     nastran_filename2 = os.path.join(nastran_path, 'solid_bending', 'solid_bending2.bdf')
     tecplot_filename = os.path.join(nastran_path, 'solid_bending', 'solid_bending.plt')
     tecplot = nastran_to_tecplot_filename(nastran_filename1, tecplot_filename, log=log)
Example #23
0
from numpy import array, allclose, array_equal, set_printoptions
set_printoptions(suppress=True, precision=3)

import pyNastran
from pyNastran.bdf.bdf import BDF, BDFCard, DAREA, PLOAD4, read_bdf, RROD
from pyNastran.bdf.cards.base_card import expand_thru_by
from pyNastran.bdf.cards.collpase_card import collapse_thru_by
from pyNastran.bdf.cards.test.utils import save_load_deck
#from pyNastran.bdf.errors import DuplicateIDsError

from pyNastran.op2.op2 import OP2
from pyNastran.utils.log import get_logger

bdf = BDF(debug=False)
test_path = pyNastran.__path__[0]
log = get_logger(level='warning')


class TestLoads(unittest.TestCase):
    def test_force(self):
        """CONROD, FORCE"""
        model = BDF(debug=False)
        eid = 1
        mid = 100
        nids = [10, 11]
        A = 3.14
        model.add_conrod(eid, mid, nids, A, j=0.0, c=0.0, nsm=0.0,
                         comment='')
        model.add_grid(10, [10., 0., 0.])
        model.add_grid(11, [11., 0., 0.])
        E = 3.0e7
Example #24
0
from six import iteritems
from pyNastran.utils.log import get_logger

log = None
debug = True
log = get_logger(log, 'debug' if debug else 'info')

def run_arg_parse():
    msg  = 'This program creates a CFD tet mesh from a nastran surface..\n'
    msg += 'Usage:\n'
    msg += '  stl_reader INPUT [-o OUTPUT]\n'
    msg += '             [-n] [-q]\n'
    msg += '  stl_reader -h | --help\n'
    msg += '  stl_reader -v | --version\n'
    msg += "  INPUT      path to input file\n"
    msg += "\n"
    msg += "Options:\n"
    msg += "  -h, --help                  show this help message and exit\n"
    msg += "  -f FORMAT, --format FORMAT  format type (usm3d, fun3d)\n"
    msg += "  -o OUTPUT, --output OUTPUT  path to output file\n"
    msg += "  -n, --normal                flip the element normals\n"
    #msg += "  -r XYZ, --rotation XYZ      [x, y, z, -x, -y, -z] default is ???\n"

    msg += "  -q, --quiet                 prints debug messages (default=True)\n"
    msg += "  -v, --version               show program's version number and exit\n"

    ver = str(pyNastran.__version__)
    data = docopt(msg, version=ver)
    #print(data)

    #format  = data['--format']
Example #25
0
 def __init__(self, log=None, debug=False):
     self.log = get_logger(log, 'debug' if debug else 'info')
    def test_stress(self):
        log = get_logger(level='warning')
        is_failed = False
        for folder, prefix, freqs in CASES:
            bdf = BDF(debug=False, log=log)
            basepath = os.path.join(pkg_path, 'op2', 'test', 'examples',
                                    folder)
            bdf.read_bdf(os.path.join(basepath, prefix + '.bdf'))
            op2 = read_op2(
                os.path.join(basepath, prefix + '.op2'),
                debug=False,
                log=log,
                exclude_results=['element_forces', 'strain'],
            )
            try:
                op2_new = data_in_material_coord(bdf, op2)
            except ValueError as e:
                op2.log.error('failed rotating %r' % prefix)
                is_failed = True
                #continue
                raise

            for freq in freqs:
                for vecname in stress_vectors:
                    vector = getattr(op2_new, vecname).get(1)
                    if vector is None:
                        continue
                    if 'center' in prefix:
                        name = os.path.join(
                            basepath,
                            '%s_center_freq_%1.1f.txt' % (vecname, freq))
                    else:
                        name = os.path.join(
                            basepath,
                            '%s_corner_freq_%1.1f.txt' % (vecname, freq))
                    if not os.path.isfile(name):
                        raise AssertionError(
                            'Not found reference result {0}'.format(name))
                    ref_stress = np.loadtxt(name)
                    mag = ref_stress[:, 1::2]
                    phase = ref_stress[:, 2::2]
                    if freq == 1.0:
                        data = vector.data[0]
                    elif freq == 9.5:
                        data = vector.data[17]
                    eids = get_eids_from_op2_vector(vector)
                    check = eids != 0
                    if 'cquad8' in vecname:
                        assert np.allclose(np.abs(data[check][0::10, :]),
                                           mag[0::10],
                                           rtol=RTOL)
                        assert np.allclose(calc_phasedeg(
                            data[check][1::10, :]),
                                           phase[1::10],
                                           rtol=RTOL)
                    else:
                        assert np.allclose(np.abs(data[check]), mag, rtol=RTOL)
                        assert np.allclose(calc_phasedeg(data[check]),
                                           phase,
                                           rtol=RTOL)
        if is_failed:
            raise ValueError('see previous message')
Example #27
0
    def __init__(self, lines, log=None):
        # (List[str], Optional[object]) -> None
        """
        Parameters
        ----------
        lines : List[str]
            list of lines that represent the case control deck
            ending with BEGIN BULK
        log : log()
            a :mod: `logging` object

        """
        # pulls the logger from the BDF object
        self.log = get_logger(log, "debug")
        self.debug = False

        self.sol_200_map = {
            'STATICS' : 101,
            'STATIC' : 101,

            'MODES' : 103,
            'MODE' : 103,

            'BUCK' : 105,
            'BUCKLING' : 105,

            'DFREQ' : 108,
            'MFREQ' : 111,
            'SAERO' : 144,

            'FLUTTER' : 145,
            'FLUT' : 145,

            'DIVERGE' : 144,
            'DIVERG' : 145,

            # 'HEAT' : ,
            # 'STRUCTURE' : ,
            'NLSTATICS' : 400,
            'LNSTATICS' : 400,
            'MTRAN' : 112,
            'DCEIG' : 107,
        }
        # 'HEAT', 'ANALYSIS', 'MFREQ', 'STATICS', 'MODES', 'DFREQ',
        # 'MTRAN', 'BUCK', 'MCEIG', 'DCEIG', 'SAERO', 'NLSTATIC', 'NLSTAT',
        # 'STATIC', 'MTRANS', 'MODE', 'FLUTTER', 'DIVERG', 'NLTRAN', 'FLUT',
        #self.debug = True

        #: stores a single copy of 'BEGIN BULK' or 'BEGIN SUPER'
        self.reject_lines = []  # type: List[str]
        self.begin_bulk = ['BEGIN', 'BULK']

        # allows BEGIN BULK to be turned off
        self.write_begin_bulk = True
        self._begin_count = 0

        self.lines = lines
        self.subcases = {0: Subcase(id=0)}  # type: Dict[int, Subcase]
        try:
            self._read(self.lines)
        except:
            self.log.error('Invalid Case Control Deck:\n' + '\n'.join(self.lines))
            raise
Example #28
0
 def __init__(self, log=None, debug=False):
     self.log = get_logger(log, "debug" if debug else "info")
     FortranFormat.__init__(self)
Example #29
0
from numpy import argsort, mean, array, cross

# my code
from mathFunctions import pierce_plane_vector, shepard_weight, Normal, ListPrint
#from mathFunctions import get_triangle_weights
from structural_model import StructuralModel
from aero_model import AeroModel
from kdtree import KdTree

# pyNastran
from pyNastran.converters.cart3d.cart3d_reader import Cart3DReader
from pyNastran.bdf.bdf import BDF
from pyNastran.utils.log import get_logger

debug = True
log = get_logger(None, 'debug' if debug else 'info')

#------------------------------------------------------------------

def entryExit(f):
    def new_f(*args, **kwargs):
        log.info("Entering", f.__name__)
        f(*args, **kwargs)
        log.info("Exited", f.__name__)
    return new_f

class LoadMapping(object):
    def __init__(self, aeroModel, structuralModel, configpath='', workpath=''):
        self.nCloseElements = 30

        self.configpath = configpath
Example #30
0
    def __init__(self, log=None, debug=False):
        self.log = get_logger(log, 'debug' if debug else 'info')

        self.nodes = None
        self.elements = None
Example #31
0
 def test_nastran_to_stl(self):
     """tests nastran_to_stl"""
     bdf_filename = os.path.join(MODEL_PATH, 'plate', 'plate.bdf')
     stl_filename = os.path.join(MODEL_PATH, 'plate', 'plate.stl')
     log = get_logger(log=None, level='warning', encoding='utf-8')
     nastran_to_stl(bdf_filename, stl_filename, is_binary=False, log=log)
Example #32
0
from numpy import array, dot, cross, argsort
from numpy.linalg import det, solve, norm

# Steve's code
from delauney.premorph import runPremorph
from delauneyReader import Tet4, DelauneyReader
from mathFunctions import ListPrint
#from f06Reader import f06Reader

from pyNastran.op2.op2 import OP2
from pyNastran.converters.cart3d.cart3d_reader import generic_cart3d_reader

from pyNastran.utils.log import get_logger

debug = True
log = get_logger(None, 'debug' if debug else 'info')

#------------------------------------------------------------------


class DeflectionReader(object):
    def __init__(self, infilename='fem.op2'):
        log.info('---starting deflectionReader.init of %s---' % infilename)
        op2 = OP2Reader(infilename)
        terms = [
            'force', 'stress', 'stress_comp', 'strain', 'strain_comp',
            'displacement', 'grid_point_forces'
        ]
        op2.read(terms)
        self.displacement = op2.nastranModel.displacement
        #op2.nastranModel.printDisplacement()
Example #33
0
def main():
    """runs the gui"""
    (formati, input_filenames, output_filenames, failed_cases_filename,
     log_method, test) = run_docopt()
    log = get_logger(log=None, level=log_method, encoding='utf-8')
    npass = 0
    nfailed = 0
    failed_files = []
    ntotal = len(input_filenames)

    print('test =', test)
    test_gui = FakeGUI(formati)
    test_gui.log = log
    stop_on_failure = ntotal == 1
    time0 = time.time()
    for input_filename, output_filename in zip(input_filenames,
                                               output_filenames):
        input_filename = os.path.abspath(input_filename)
        #output_filename =
        print("filename = %s" % input_filename)
        is_passed = True
        try:
            test_gui.load_geometry(input_filename)
        except KeyboardInterrupt:
            sys.exit('KeyboardInterrupt...sys.exit()')
        except SystemExit:
            sys.exit('sys.exit...')

        except NoGeometry:
            traceback.print_exc(file=sys.stdout)
            print('failed test because NoGeometry...ignoring')
        except CrossReferenceError:
            traceback.print_exc(file=sys.stdout)
            print('failed test because CrossReferenceError...ignoring')
        except CardParseSyntaxError:
            traceback.print_exc(file=sys.stdout)
            print('failed test because CardParseSyntaxError...ignoring')
        except DuplicateIDsError:
            traceback.print_exc(file=sys.stdout)
            print('failed test because DuplicateIDsError...ignoring')
        except MissingDeckSections:
            traceback.print_exc(file=sys.stdout)
            print('failed test because MissingDeckSections...ignoring')
        except OverflowError:
            traceback.print_exc(file=sys.stdout)
            print('failed test because OverflowError...ignoring')

        except:
            is_passed = False
            traceback.print_exc(file=sys.stdout)
            if stop_on_failure:
                print('input_filenames =', input_filenames)
                raise

        if output_filename:
            test_gui.load_results(output_filename)

        if is_passed:
            sys.stderr.write('%i  %s' % (npass, input_filename))
            npass += 1
        else:
            sys.stderr.write('*%s ' % nfailed + input_filename)
            nfailed += 1
            failed_files.append(input_filename)
        sys.stderr.write('\n')

        if not stop_on_failure:
            print('-' * 80)
    dt = time.time() - time0
    nfailed = len(failed_files)
    npassed = ntotal - nfailed
    time_msg = 'dt = %.0f sec = %.1f min' % (dt, dt / 60.)
    sys.stderr.write('%i/%i passed\n' % (npassed, ntotal))
    sys.stderr.write(time_msg)

    if PY2:
        write = 'wb'
    else:
        write = 'w'

    if ntotal > 1:
        with open(failed_cases_filename, write) as failed_cases_file:
            for fname in failed_files:
                failed_cases_file.write('%s\n' % fname)
        print(time_msg)
        sys.exit('finished...')
Example #34
0
 def test_cart3d_to_stl(self):
     """convert to stl"""
     log = get_logger(level='warning', encoding='utf-8')
     cart3d_filename = os.path.join(TEST_PATH, 'threePlugs.bin.tri')
     stl_filename = os.path.join(TEST_PATH, 'threePlugs.stl')
     cart3d_to_stl_filename(cart3d_filename, stl_filename, log=log)
Example #35
0
 def test_cart3d_to_tecplot(self):
     """convert to tecplot"""
     log = get_logger(level='warning', encoding='utf-8')
     cart3d_filename = os.path.join(TEST_PATH, 'threePlugs.bin.tri')
     tecplot_filename = os.path.join(TEST_PATH, 'threePlugs.plt')
     cart3d_to_tecplot(cart3d_filename, tecplot_filename, log=log)
Example #36
0
 def __init__(self, log=None, debug=False):
     self.log = get_logger(log, 'debug' if debug else 'info')
Example #37
0
 def test_cart3d_input_c3d(self):
     """tests the input.c3d reading"""
     log = get_logger(level='warning', encoding='utf-8')
     input_c3d_filename = os.path.join(TEST_PATH, 'input.c3d')
     read_input_c3d(input_c3d_filename, log=log, debug=False, stack=True)
Example #38
0
 def __init__(self, log=None, debug=False):
     self.log = get_logger(log, 'debug' if debug else 'info')
     self.nodes = None
     self.tris = None
     self.tets = None
Example #39
0
from __future__ import print_function
import os

from six.moves import zip
from numpy import array, cross, dot, abs as npabs
from numpy.linalg import norm, solve  #, cond

from pyNastran.applications.cart3d_nastran_fsi.math_functions import (
    is_list_ranged, list_print, shepard_weight)
#from pyNastran.applications.cart3d_nastran_fsi.matTest import fIsNatural
from pyNastran.bdf.field_writer_8 import print_card_8

from pyNastran.utils.log import get_logger

log = get_logger(log=None, level='debug', encoding='utf-8')

#------------------------------------------------------------------


class Tet4(object):
    def __init__(self, p0, p1, p2, p3, ID=None, nodes=None, neighbors=None):
        """
        The internal tets dont need a number or list of nodes.
        The Delauney TETs do!
        """
        if neighbors is None:
            neighbors = []
        self.p0 = array(p0)
        self.p1 = array(p1)
        self.p2 = array(p2)
        self.p3 = array(p3)