Source code for edelweissfe.solvers.nonlinearimplicitstaticparallel

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#  ---------------------------------------------------------------------
#
#  _____    _      _              _         _____ _____
# | ____|__| | ___| |_      _____(_)___ ___|  ___| ____|
# |  _| / _` |/ _ \ \ \ /\ / / _ \ / __/ __| |_  |  _|
# | |__| (_| |  __/ |\ V  V /  __/ \__ \__ \  _| | |___
# |_____\__,_|\___|_| \_/\_/ \___|_|___/___/_|   |_____|
#
#
#  Unit of Strength of Materials and Structural Analysis
#  University of Innsbruck,
#  2017 - today
#
#  Matthias Neuner matthias.neuner@uibk.ac.at
#
#  This file is part of EdelweissFE.
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2.1 of the License, or (at your option) any later version.
#
#  The full text of the license can be found in the file LICENSE.md at
#  the top level directory of EdelweissFE.
#  ---------------------------------------------------------------------

"""
Parallel implementation of the NIST solver.
"""

import edelweissfe.utils.performancetiming as performancetiming
from edelweissfe.numerics.parallelizationutilities import (
    getNumberOfThreads,
    getNumberOfWorkerThreads,
    mapChunksInParallel,
    reportThreadAvailability,
)
from edelweissfe.solvers.base.parallelelementcomputation import (
    computeElementsInParallel,
)
from edelweissfe.solvers.nonlinearimplicitstatic import NIST


[docs] class NISTParallel(NIST): """:class:`~edelweissfe.solvers.nonlinearimplicitstatic.NIST`, with the elements computed on the available threads (:meth:`computeElements`). Parameters ---------- jobInfo A dictionary containing the job information. journal The journal instance for logging. """ identification = "NISTPSolver"
[docs] def beginStep(self, step, model, fieldOutputController, outputmanagers): reportThreadAvailability(getNumberOfThreads(), self.journal, self.identification) return super().beginStep(step, model, fieldOutputController, outputmanagers)
[docs] def forEachChunk(self, entities: list, work): """Call ``work(chunk)`` for chunks of ``entities`` on the available threads, as the elements are computed (see :func:`~edelweissfe.numerics.parallelizationutilities.mapChunksInParallel`); otherwise as :meth:`~edelweissfe.solvers.nonlinearimplicitstatic.NIST.forEachChunk`.""" mapChunksInParallel(entities, work)
[docs] def numberOfAssemblyWorkers(self) -> int: """How many threads write blocks of the system matrix at the same time: those that compute the elements. Returns ------- int The number of workers. """ return getNumberOfWorkerThreads()
[docs] @performancetiming.timeit("elements") def computeElements(self, elements, Un1, dU, P, K, F, timeStep): """Compute the elements on the available threads, see :func:`~edelweissfe.solvers.base.parallelelementcomputation.computeElementsInParallel`; otherwise as :meth:`~edelweissfe.solvers.nonlinearimplicitstatic.NIST.computeElements`.""" return computeElementsInParallel(elements, Un1, dU, P, K, F, timeStep)