Exemplo n.º 1
0
def run_problem(plot_frequency=1):
    """
    Run the GEOSX problem
    """
    # PYGEOSX_INITIALIZATION
    # Get the MPI rank
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    # Initialize the code and set initial conditions
    xml.apply_xml_preprocessor()
    problem = pygeosx.initialize(rank, sys.argv)
    pygeosx.apply_initial_conditions()
    # PYGEOSX_INITIALIZATION_END

    # PYGEOSX_KEY_SEARCH
    # Rather than specifying the wrapper paths explicitly,
    # search for them using a set of filters
    fracture_location_key = wrapper.get_matching_wrapper_path(
        problem, ['Fracture', 'elementCenter'])
    fracture_aperture_key = wrapper.get_matching_wrapper_path(
        problem, ['Fracture', 'effectiveAperture'])
    # PYGEOSX_KEY_SEARCH_END

    # Note: we will be plotting our results.
    # This will modify the fonts so that they a bit easier to read
    plot_font = {'weight': 'normal', 'size': 8}
    plt.rc('font', **plot_font)

    # PYGEOSX_QUERY_SETUP
    # Setup values to record
    records = {
        fracture_location_key: {
            'label': 'Fracture Extents (m)',
            'scale': 1.0,
            'history': [],
            'fhandle': plt.figure()
        },
        fracture_aperture_key: {
            'label': 'Aperture (mm)',
            'scale': 1e3,
            'history': [],
            'fhandle': plt.figure()
        },
        'time': {
            'label': 'Time (min)',
            'scale': 1.0 / 60.0,
            'history': []
        }
    }
    # PYGEOSX_QUERY_SETUP_END

    # PYGEOSX_MAIN_LOOP
    # Run the code
    query_count = 0
    while pygeosx.run() != pygeosx.COMPLETED:
        wrapper.run_queries(problem, records)
        query_count += 1
        if (query_count % plot_frequency == 0):
            wrapper.plot_history(records)
Exemplo n.º 2
0
def main():
    print_and_flush("In python before initialization.")

    problem = pygeosx.initialize(rank, sys.argv)

    try:
        problem.get_group("Solvers/lagsolve", None).register(callback)
    except AttributeError:
        pass

    curr_time = problem.get_wrapper("Events/time").value(False)
    print_and_flush("In python after initialization: current time = {}".format(
        curr_time[0]))

    pygeosx.apply_initial_conditions()
    curr_time = problem.get_wrapper("Events/time").value(False)
    print_and_flush(
        "In python after applyInitialConditions: current time = {}".format(
            curr_time[0]))

    while pygeosx.run() != pygeosx.COMPLETED:
        curr_time = problem.get_wrapper("Events/time").value(True)
        print_and_flush("In python: current time = {}".format(curr_time[0]))
        curr_time[0] += 1e-6

    curr_time = problem.get_wrapper("Events/time").value(False)
    print_and_flush(
        "In python after after the simulation has ended: current time = {}".
        format(curr_time[0]))
Exemplo n.º 3
0
def run_problem():
    """
    Run the GEOSX problem
    """
    # Initialize the code
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()
    problem = pygeosx.initialize(rank, sys.argv)

    # Rather than specifying the wrapper paths explicitly,
    # search for them using a set of filters
    location_keys = []
    location_keys.append(wrapper.get_matching_wrapper_path(problem, ['ReferencePosition']))
    location_keys.append(wrapper.get_matching_wrapper_path(problem, ['Region2', 'elementCenter']))

    # Map the node, element locations
    print('Warning: this mapping will change the mesh, but for things to work correctly')
    print('         we would need to re-calculate the geometric parameters, shape functions')
    for ka in location_keys:
        wrapper.set_wrapper_with_function(problem, ka, ka, surface_mapping, target_index=2)

    # Apply initial conditions
    pygeosx.apply_initial_conditions()

    # Run the code
    while pygeosx.run() != pygeosx.COMPLETED:
        # Do something
        pass
Exemplo n.º 4
0
def run_problem():
    """
    Run the GEOSX problem
    """
    # Initialize the code
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()
    problem = pygeosx.initialize(rank, sys.argv)

    # Rather than specifying the wrapper paths explicitly,
    time_key = 'Events/time'
    bc_key = wrapper.get_matching_wrapper_path(problem, ['sourceTerm', 'scale'])
    fracture_location_key = wrapper.get_matching_wrapper_path(problem, ['Fracture', 'elementCenter'])
    fracture_aperture_key = wrapper.get_matching_wrapper_path(problem, ['Fracture', 'effectiveAperture'])

    # Apply initial conditions
    pygeosx.apply_initial_conditions()

    # Setup monitor
    records = {fracture_location_key: {'label': 'Fracture Extents (m)',
                                       'scale': 1.0,
                                       'history': [],
                                       'fhandle': plt.figure()},
               fracture_aperture_key: {'label': 'Aperture (mm)',
                                       'scale': 1e3,
                                       'history': [],
                                       'fhandle': plt.figure()},
               'time': {'label': 'Time (min)',
                        'scale': 1.0 / 60.0,
                        'history': []}}

    # Run the code
    while pygeosx.run() != pygeosx.COMPLETED:
        time = problem.get_wrapper(time_key).value(False)
        current_flow_rate = -5.0 - np.sin(np.pi * time / 60.0)
        wrapper.set_wrapper_to_value(problem, bc_key, current_flow_rate)
        if (wrapper.rank == 0):
            print('t = %1.4f, q = %1.4f' % (time, current_flow_rate), flush=True)

        wrapper.run_queries(problem, records)
        wrapper.plot_history(records, show_figures=True)
Exemplo n.º 5
0
def main():
    # Get the MPI rank
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    if rank == 0:
        print('In python')
        sys.stdout.flush()

    # If not a restart run then we'll run the SSLE-sedov problem first.
    if '-r' not in sys.argv:
        arg_copy = list(sys.argv)

        xml_index = arg_copy.index('-i') + 1
        arg_copy[xml_index] = os.path.join(os.path.dirname(__file__), '..',
                                           '..', 'integratedTests', 'update',
                                           'run', 'solidMechanicsSSLE',
                                           'SSLE-sedov.xml')

        output_index = arg_copy.index('-o') + 1
        arg_copy[output_index] = sys.argv[output_index] + '_ssle_dummy'

        problem = pygeosx.initialize(rank, arg_copy)
        pygeosx.apply_initial_conditions()

        # run to completion
        while pygeosx.run() != pygeosx.COMPLETED:
            pass

        if rank == 0:
            print('\n\nIn python second time around')
            sys.stdout.flush()

        problem = pygeosx.reinit(sys.argv)
    else:
        problem = pygeosx.initialize(rank, sys.argv)

    pygeosx.apply_initial_conditions()

    while pygeosx.run() != pygeosx.COMPLETED:
        pass
Exemplo n.º 6
0
def run_problem():
    """
    Run the GEOSX problem
    """
    # PYGEOSX_INITIALIZATION
    # Get the MPI rank
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()

    # Initialize the code and set initial conditions
    xml.apply_xml_preprocessor()
    problem = pygeosx.initialize(rank, sys.argv)
    pygeosx.apply_initial_conditions()

    # Rather than specifying the wrapper paths explicitly,
    # search for them using a set of filters
    location_key = wrapper.get_matching_wrapper_path(
        problem, ['Region2', 'elementCenter'])
    stress_key = wrapper.get_matching_wrapper_path(
        problem, ['Region2', 'shale', 'stress'])
    ghost_key = wrapper.get_matching_wrapper_path(
        problem, ['Region2', 'cb1', 'ghostRank'])
    # PYGEOSX_INITIALIZATION_END

    # PYGEOSX_STRESS_IC
    # Print initial stress
    wrapper.print_global_value_range(problem, stress_key, 'stress')

    # Zero out stress
    wrapper.set_wrapper_to_value(problem, stress_key, 0.0)
    wrapper.print_global_value_range(problem, stress_key, 'stress')

    # Set stress via a function
    wrapper.set_wrapper_with_function(problem,
                                      stress_key,
                                      location_key,
                                      stress_fn,
                                      target_index=0)
    wrapper.set_wrapper_with_function(problem,
                                      stress_key,
                                      location_key,
                                      stress_fn,
                                      target_index=1)
    wrapper.set_wrapper_with_function(problem,
                                      stress_key,
                                      location_key,
                                      stress_fn,
                                      target_index=2)
    wrapper.print_global_value_range(problem, stress_key, 'stress')
    # PYGEOSX_STRESS_IC_END

    # PYGEOSX_MAIN_LOOP
    # Run the code
    while pygeosx.run() != pygeosx.COMPLETED:
        wrapper.print_global_value_range(problem, stress_key, 'stress')

        # Gather/allgather tests
        tmp = wrapper.gather_wrapper(problem, stress_key)
        print(wrapper.rank, 'gather', np.shape(tmp), flush=True)

        tmp = wrapper.allgather_wrapper(problem, stress_key)
        print(wrapper.rank, 'allgather', np.shape(tmp), flush=True)

        tmp = wrapper.allgather_wrapper(problem,
                                        stress_key,
                                        ghost_key=ghost_key)
        print(wrapper.rank,
              'allgather_ghost_filtered',
              np.shape(tmp),
              flush=True)