def test_mpi_dependent_jiting(): # FIXME: Not a proper unit test... from dolfin import (Expression, UnitSquareMesh, Function, TestFunction, Form, FunctionSpace, dx, CompiledSubDomain, SubSystemsManager) # Init petsc (needed to initalize petsc and slepc collectively on # all processes) SubSystemsManager.init_petsc() try: import mpi4py.MPI as mpi except ImportError: return try: import petsc4py.PETSc as petsc except ImportError: return # Set communicator and get process information comm = mpi.COMM_WORLD group = comm.Get_group() size = comm.Get_size() # Only consider parallel runs if size == 1: return rank = comm.Get_rank() group_comm_0 = petsc.Comm(comm.Create(group.Incl(range(1)))) group_comm_1 = petsc.Comm(comm.Create(group.Incl(range(1, 2)))) if size > 2: group_comm_2 = petsc.Comm(comm.Create(group.Incl(range(2, size)))) if rank == 0: e = Expression("4", mpi_comm=group_comm_0, degree=0) elif rank == 1: e = Expression("5", mpi_comm=group_comm_1, degree=0) assert (e) domain = CompiledSubDomain("on_boundary", mpi_comm=group_comm_1, degree=0) assert (domain) else: mesh = UnitSquareMesh(group_comm_2, 2, 2) V = FunctionSpace(mesh, "P", 1) u = Function(V) v = TestFunction(V) Form(u * v * dx)
def test_mpi_dependent_jiting(): # FIXME: Not a proper unit test... from dolfin import (Expression, UnitSquareMesh, Function, TestFunction, Form, FunctionSpace, dx, CompiledSubDomain, SubSystemsManager) # Init petsc (needed to initalize petsc and slepc collectively on # all processes) SubSystemsManager.init_petsc() try: import mpi4py.MPI as mpi except: return try: import petsc4py.PETSc as petsc except: return # Set communicator and get process information comm = mpi.COMM_WORLD group = comm.Get_group() size = comm.Get_size() # Only consider parallel runs if size == 1: return rank = comm.Get_rank() group_comm_0 = petsc.Comm(comm.Create(group.Incl(range(1)))) group_comm_1 = petsc.Comm(comm.Create(group.Incl(range(1, 2)))) if size > 2: group_comm_2 = petsc.Comm(comm.Create(group.Incl(range(2,size)))) if rank == 0: e = Expression("4", mpi_comm=group_comm_0, degree=0) elif rank == 1: e = Expression("5", mpi_comm=group_comm_1, degree=0) domain = CompiledSubDomain("on_boundary", mpi_comm=group_comm_1, degree=0) else: mesh = UnitSquareMesh(group_comm_2, 2, 2) V = FunctionSpace(mesh, "P", 1) u = Function(V) v = TestFunction(V) Form(u*v*dx)
# # 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the # following disclaimer in the documentation and/or other materials provided with the distribution. # # 3. The name of the copyright holder(s), any contributors, the United States Government, the United States Department # of Energy, or any of their employees may not be used to endorse or promote products derived from this software # without specific prior written permission from the respective party. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, # OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Error message handling for PETSc from dolfin import SubSystemsManager SubSystemsManager.init_petsc() from petsc4py import PETSc PETSc.Sys.pushErrorHandler("traceback") del SubSystemsManager, PETSc # Import public API from pfibs.block_preconditioners import * from pfibs.custom_linear import CustomKrylovSolver from pfibs.custom_nonlinear import NLP, NS from pfibs.block_problem import BlockProblem from pfibs.block_solver import LinearBlockSolver, NonlinearBlockSolver
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with FENaPack. If not, see <http://www.gnu.org/licenses/>. """This is FENaPack, FEniCS Navier-Stokes preconditioning package.""" __author__ = "Jan Blechta, Martin Řehoř" __version__ = "2019.2.0.dev0" __license__ = "GNU LGPL v3" # Do not use petsc4py python error handler (hides error messages # to PETSc C calls), workaround to DOLFIN issue #801 from dolfin import SubSystemsManager SubSystemsManager.init_petsc() # init PETSc by DOLFIN before petsc4py import from petsc4py import PETSc PETSc.Sys.pushErrorHandler("traceback") del SubSystemsManager, PETSc # Import public API from fenapack.field_split import PCDKSP, PCDKrylovSolver from fenapack.assembling import PCDAssembler, PCDForm from fenapack.nonlinear_solvers import PCDNewtonSolver, PCDNonlinearProblem from fenapack.preconditioners import PCDPC_BRM1, PCDPC_BRM2 from fenapack.preconditioners import PCDRPC_BRM1, PCDRPC_BRM2 from fenapack.stabilization import StabilizationParameterSD # Monkey patch dolfin.NewtonSolver in 2018.1.0 from dolfin import NewtonSolver, compile_cpp_code _cpp = """
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with FENaPack. If not, see <http://www.gnu.org/licenses/>. """This is FENaPack, FEniCS Navier-Stokes preconditioning package.""" __author__ = "Jan Blechta, Martin Řehoř" __version__ = "2018.2.0.dev0" __license__ = "GNU LGPL v3" # Do not use petsc4py python error handler (hides error messages # to PETSc C calls), workaround to DOLFIN issue #801 from dolfin import SubSystemsManager SubSystemsManager.init_petsc() # init PETSc by DOLFIN before petsc4py import from petsc4py import PETSc PETSc.Sys.pushErrorHandler("traceback") del SubSystemsManager, PETSc # Import public API from fenapack.field_split import PCDKSP, PCDKrylovSolver from fenapack.assembling import PCDAssembler, PCDForm from fenapack.nonlinear_solvers import PCDNewtonSolver, PCDNonlinearProblem from fenapack.preconditioners import PCDPC_BRM1, PCDPC_BRM2 from fenapack.preconditioners import PCDRPC_BRM1, PCDRPC_BRM2 from fenapack.stabilization import StabilizationParameterSD # Monkey patch dolfin.NewtonSolver in 2018.1.0 from dolfin import NewtonSolver, compile_cpp_code
# You should have received a copy of the GNU Lesser General Public License # along with dolfin-tape. If not, see <http://www.gnu.org/licenses/>. """This is dolfin-tape, the DOLFIN tools for a posteriori error estimation.""" __author__ = "Jan Blechta" __version__ = "2017.1.0.dev0" __license__ = 'LGPL v3' # Avoid PETSc being initialized by DOLFIN, which sets some performance # degrading parameters since e91b4100. This assumes that this module # is imported before DOLFIN; otherwise the assertion may fail. # TODO: Test whether it works! from petsc4py import PETSc from dolfin import SubSystemsManager assert not SubSystemsManager.responsible_petsc() del PETSc, SubSystemsManager # Reduce DOLFIN logging bloat in parallel from dolfin import set_log_level, get_log_level, MPI, mpi_comm_world set_log_level(get_log_level()+(0 if MPI.rank(mpi_comm_world())==0 else 1)) del set_log_level, get_log_level # Parse command-line options # FIXME: Automatic parsing temporarily commented out as it disallows parsing # our own application specific parameters. Do we need it somewhere? #from dolfin import parameters #parameters.parse() # Enable info_{green,red,blue} on rank 0 import ufl