Beispiel #1
0
def test():
    m = model.Model() # generate FEM model

    # Prepare logging
    log_file = __file__[:-3] + '.log'
    log.stop_logging()
    log.add_my_handler(logging.WARNING)
    log.print(log_file, 'IMPORTER (KEYWORDS PARSER) TEST')

    limit = 50000 # how many files to process
    examples_dir = '../../examples'
    # examples_dir = '../../examples/ccx/test'
    # examples_dir = '../../examples/abaqus/eif'
    # examples_dir = '../../examples/yahoo'
    examples = tests.scan_all_files_in(examples_dir, '.inp', limit)

    counter = 0
    for file_name in examples:
        counter += 1
        relpath = os.path.relpath(file_name, start=os.getcwd())
        log.print(log_file, '\n{} {}'.format(counter, relpath))

        # Build new clean/empty keyword object model
        m.KOM = model.kom.KOM(kom_xml='../config/kom.xml')

        # Parse inp_doc end enrich existing KOM
        i = Importer(None, None, m, None, None)
        inp_doc = read_lines(file_name)
        i.split_on_blocks(inp_doc) # fill keyword_blocks
        i.import_inp()

    msg = '\n{} INP files.'
    log.print(log_file, msg.format(len(examples)))
Beispiel #2
0
def test():

    # Prepare logging
    log_file = __file__[:-3] + '.log'
    log.stop_logging()
    log.add_my_handler(logging.DEBUG)
    log.print(log_file, 'MESH PARSER TEST')

    limit = 50000  # how many files to process
    # examples_dir = '../../../../examples/ccx/test'
    examples_dir = '../../../../examples'
    counter = 0

    examples = tests.scan_all_files_in(examples_dir, '.inp', limit)
    for file_name in examples:
        counter += 1
        relpath = os.path.relpath(file_name, start=os.getcwd())
        log.print(log_file, '\n{}\n{}: {}'.format('=' * 50, counter, relpath))

        # Parse mesh
        m = Mesh(ifile=file_name)
Beispiel #3
0
# Test mesh parser on all CalculiX examples
if __name__ == '__main__':
    clean.screen()
    os.chdir(os.path.dirname(__file__))
    start_time = time.perf_counter()
    print = tests.print

    # Prepare logging
    log_file = __file__[:-3] + '.log'
    h = tests.myHandler(log_file)
    logging.getLogger().addHandler(h)
    logging.getLogger().setLevel(logging.INFO)

    limit = 3000  # how many files to process
    examples_dir = '../../../../examples/ccx_2.16.test'
    counter = 0

    print(log_file, 'MESH PARSER TEST\n\n')
    examples = tests.scan_all_files_in(examples_dir, '.inp', limit)
    for file_name in examples:
        counter += 1
        relpath = os.path.relpath(file_name, start=os.getcwd())
        print(log_file, '\n{}\n{}: {}'.format('=' * 50, counter, relpath))

        # Parse mesh
        m = Mesh(INP_file=file_name)

    print(log_file,
          '\nTotal {:.1f} seconds.'.format(time.perf_counter() - start_time))
    clean.cache()