Beispiel #1
0
def init(**kwargs):
    """Initialise PyOP2: select the backend and potentially other configuration
    options.

    :arg debug:     The level of debugging output.
    :arg comm:      The MPI communicator to use for parallel communication,
                    defaults to `MPI_COMM_WORLD`
    :arg log_level: The log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
    :arg opt_level: The default optimization level in COFFEE. Options: O0, O1, O2,
                    O3, Ofast. For more information about these levels, refer to
                    ``coffee_init``'s documentation. The default value is O0.

    For debugging purposes, `init` accepts all keyword arguments
    accepted by the PyOP2 :class:`Configuration` object, see
    :meth:`Configuration.__init__` for details of further accepted
    options.

    .. note::
       Calling ``init`` again with a different backend raises an exception.
       Changing the backend is not possible. Calling ``init`` again with the
       same backend or not specifying a backend will update the configuration.
       Calling ``init`` after ``exit`` has been called is an error and will
       raise an exception.
    """
    global _initialised
    configuration.reconfigure(**kwargs)

    set_log_level(configuration['log_level'])
    coffee_init(compiler=configuration['compiler'], isa=configuration['simd_isa'],
                optlevel=configuration.get('opt_level', O0))
    _initialised = True
Beispiel #2
0
def init(**kwargs):
    """Initialise PyOP2: select the backend and potentially other configuration
    options.

    :arg debug:     The level of debugging output.
    :arg comm:      The MPI communicator to use for parallel communication,
                    defaults to `MPI_COMM_WORLD`
    :arg log_level: The log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL

    For debugging purposes, `init` accepts all keyword arguments
    accepted by the PyOP2 :class:`Configuration` object, see
    :meth:`Configuration.__init__` for details of further accepted
    options.

    .. note::
       Calling ``init`` again with a different backend raises an exception.
       Changing the backend is not possible. Calling ``init`` again with the
       same backend or not specifying a backend will update the configuration.
       Calling ``init`` after ``exit`` has been called is an error and will
       raise an exception.
    """
    global _initialised
    configuration.reconfigure(**kwargs)

    set_log_level(configuration['log_level'])

    _initialised = True
Beispiel #3
0
Datei: op2.py Projekt: OP2/PyOP2
def init(**kwargs):
    """Initialise PyOP2: select the backend and potentially other configuration
    options.

    :arg debug:     The level of debugging output.
    :arg comm:      The MPI communicator to use for parallel communication,
                    defaults to `MPI_COMM_WORLD`
    :arg log_level: The log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL

    For debugging purposes, `init` accepts all keyword arguments
    accepted by the PyOP2 :class:`Configuration` object, see
    :meth:`Configuration.__init__` for details of further accepted
    options.

    .. note::
       Calling ``init`` again with a different backend raises an exception.
       Changing the backend is not possible. Calling ``init`` again with the
       same backend or not specifying a backend will update the configuration.
       Calling ``init`` after ``exit`` has been called is an error and will
       raise an exception.
    """
    global _initialised
    configuration.reconfigure(**kwargs)

    set_log_level(configuration['log_level'])

    _initialised = True
Beispiel #4
0
def init(**kwargs):
    """Initialise PyOP2: select the backend and potentially other configuration
    options.

    :arg debug:     The level of debugging output.
    :arg comm:      The MPI communicator to use for parallel communication,
                    defaults to `MPI_COMM_WORLD`
    :arg log_level: The log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
    :arg opt_level: The default optimization level in COFFEE. Options: O0, O1, O2,
                    O3, Ofast. For more information about these levels, refer to
                    ``coffee_init``'s documentation. The default value is O0.

    For debugging purposes, `init` accepts all keyword arguments
    accepted by the PyOP2 :class:`Configuration` object, see
    :meth:`Configuration.__init__` for details of further accepted
    options.

    .. note::
       Calling ``init`` again with a different backend raises an exception.
       Changing the backend is not possible. Calling ``init`` again with the
       same backend or not specifying a backend will update the configuration.
       Calling ``init`` after ``exit`` has been called is an error and will
       raise an exception.
    """
    global _initialised
    configuration.reconfigure(**kwargs)

    set_log_level(configuration['log_level'])
    coffee_init(compiler=configuration['compiler'],
                isa=configuration['simd_isa'],
                optlevel=configuration.get('opt_level', O0))
    _initialised = True
Beispiel #5
0
from firedrake.linear_solver import *
from firedrake.mesh import *
from firedrake.mg.mesh import *
from firedrake.mg.function import *
from firedrake.mg.functionspace import *
from firedrake.mg.ufl_utils import *
from firedrake.mg.interface import *
from firedrake.mg.solver_hierarchy import *
from firedrake.norms import *
from firedrake.nullspace import *
from firedrake.optimizer import *
from firedrake.parameters import *
from firedrake.parloops import *
from firedrake.projection import *
from firedrake.solving import *
from firedrake.ufl_expr import *
from firedrake.utility_meshes import *
from firedrake.variational_solver import *
from firedrake.vector import *
from firedrake.version import __version__ as ver, __version_info__, check  # noqa

# Set default log level
set_log_level(INFO)

check()
del check

from firedrake._version import get_versions
__version__ = get_versions(default={"version": ver, "full": ""})['version']
del get_versions
Beispiel #6
0
from assemble import *
from bcs import *
from constant import *
from expression import *
from function import *
from functionspace import *
from io import *
from linear_solver import *
from mesh import *
from norms import *
from nullspace import *
from parameters import *
from parloops import *
from projection import *
from solving import *
from ufl_expr import *
from utility_meshes import *
from variational_solver import *
from vector import *
from version import __version__ as ver, __version_info__, check  # noqa

# Set default log level
set_log_level(INFO)

check()
del check

from ._version import get_versions
__version__ = get_versions(default={"version": ver, "full": ""})['version']
del get_versions
Beispiel #7
0
    def explosive_source_lf4(self,
                             T=2.5,
                             TS=0,
                             Lx=300.0,
                             Ly=150.0,
                             h=2.5,
                             cn=0.05,
                             mesh_file=None,
                             output=1,
                             poly_order=2,
                             params=None):

        tile_size = params['tile_size']
        num_unroll = params['num_unroll']
        extra_halo = params['extra_halo']
        part_mode = params['partitioning']
        explicit_mode = params['explicit_mode']

        if explicit_mode:
            fusion_scheme = FusionSchemes.get(explicit_mode, part_mode,
                                              tile_size)
            num_solves, params['explicit_mode'] = fusion_scheme
        else:
            num_solves = ElasticLF4.num_solves

        if mesh_file:
            mesh = Mesh(mesh_file)
        else:
            mesh = RectangleMesh(int(Lx / h), int(Ly / h), Lx, Ly)

        set_log_level(INFO)

        kwargs = {}
        if params['mode'] in ['tile', 'only_tile']:
            s_depth = calculate_sdepth(num_solves, num_unroll, extra_halo)
            if part_mode == 'metis':
                kwargs['reorder'] = ('metis-rcm', mesh.num_cells() / tile_size)
        else:
            s_depth = 1
        # FIXME: need s_depth in firedrake to be able to use this
        # kwargs['s_depth'] = s_depth
        params['s_depth'] = s_depth

        mesh.topology.init(**kwargs)
        slope(mesh, debug=True)

        # Instantiate the model
        self.elastic = ElasticLF4(mesh, "DG", poly_order, 2, output, params)

        info("S-depth used: %d" % s_depth)
        info("Polynomial order: %d" % poly_order)

        # Constants
        self.elastic.density = 1.0
        self.elastic.mu = 3600.0
        self.elastic.l = 3599.3664

        self.Vp = Vp(self.elastic.mu, self.elastic.l, self.elastic.density)
        self.Vs = Vs(self.elastic.mu, self.elastic.density)
        info("P-wave velocity: %f" % self.Vp)
        info("S-wave velocity: %f" % self.Vs)

        self.dx = h
        self.courant_number = cn
        self.elastic.dt = cfl_dt(self.dx, self.Vp, self.courant_number)
        info("Using a timestep of %f" % self.elastic.dt)

        # Source
        exp_area = (44.5, 45.5, Ly - 1.5, Ly - 0.5)
        if poly_order == 1:
            # Adjust explosion area
            exp_area = (149.5, 150.5, Ly - 1.5, Ly - 0.5)
        a = 159.42
        self.elastic.source_expression = Expression(((
            "x[0] >= %f && x[0] <= %f && x[1] >= %f && x[1] <= %f ? (-1.0 + 2*a*pow(t - 0.3, 2))*exp(-a*pow(t - 0.3, 2)) : 0.0"
            % exp_area, "0.0"
        ), ("0.0",
            "x[0] >= %f && x[0] <= %f && x[1] >= %f && x[1] <= %f ? (-1.0 + 2*a*pow(t - 0.3, 2))*exp(-a*pow(t - 0.3, 2)) : 0.0"
            % exp_area)),
                                                    a=a,
                                                    t=0)
        self.elastic.source_function = Function(self.elastic.S)
        self.elastic.source = self.elastic.source_expression

        # Absorption
        F = FunctionSpace(mesh, "DG", poly_order, name='F')
        self.elastic.absorption_function = Function(F)
        self.elastic.absorption = Expression(
            "x[0] <= 20 || x[0] >= %f || x[1] <= 20.0 ? 1000 : 0" %
            (Lx - 20, ))

        # Initial conditions
        uic = Expression(('0.0', '0.0'))
        self.elastic.u0.assign(Function(self.elastic.U).interpolate(uic))
        sic = Expression((('0', '0'), ('0', '0')))
        self.elastic.s0.assign(Function(self.elastic.S).interpolate(sic))

        # Run the simulation
        start, end, ntimesteps, u1, s1 = self.elastic.run(T, TS=TS)

        # Print runtime summary
        output_time(start,
                    end,
                    tofile=params['tofile'],
                    verbose=params['verbose'],
                    meshid=("h%s" % h).replace('.', ''),
                    ntimesteps=ntimesteps,
                    nloops=ElasticLF4.loop_chain_length * num_unroll,
                    partitioning=part_mode,
                    tile_size=tile_size,
                    extra_halo=extra_halo,
                    explicit_mode=explicit_mode,
                    glb_maps=params['use_glb_maps'],
                    prefetch=params['use_prefetch'],
                    coloring=params['coloring'],
                    poly_order=poly_order,
                    domain=os.path.splitext(os.path.basename(mesh.name))[0],
                    function_spaces=[self.elastic.S, self.elastic.U])

        return u1, s1