def test_slepc(backends): """Check for petsc + slepc.""" from dolfin import has_linear_algebra_backend, has_slepc if has_linear_algebra_backend("PETSc") and has_slepc(): backends.append("petsc") else: print "Petsc + slepc not found."
def setup_fenics(simulation): """ Setup FEniCS parameters like linear algebra backend """ # Test for PETSc linear algebra backend if not dolfin.has_linear_algebra_backend("PETSc"): ocellaris_error( 'Missing PETSc', 'DOLFIN has not been configured with PETSc ' 'which is needed by Ocellaris.', ) dolfin.parameters['linear_algebra_backend'] = 'PETSc' # Form compiler "uflacs" needed for isoparametric elements form_compiler = simulation.input.get_value('solver/form_compiler', 'auto', 'string') dolfin.parameters['form_compiler']['representation'] = form_compiler
from setuptools import setup, find_packages from os import path from io import open import re try: from dolfin import __version__ as dolfin_version from dolfin import has_linear_algebra_backend, has_slepc except ImportError: raise else: fenics_version_major = int(dolfin_version[0:4]) if (fenics_version_major < 2016 or fenics_version_major >= 2018): raise Exception( 'hIPPYlib requires FEniCS versions 2016.x.x or 2017.x.x') if not has_linear_algebra_backend("PETSc"): raise Exception( 'hIPPYlib requires FEniCS to be installed with PETSc support') if not has_slepc(): raise Exception( 'hIPPYlib requires FEniCS to be installed with SLEPc support') here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() version = {} with open(path.join(here, 'hippylib/version.py')) as f: exec(f.read(), version) VERSION = version['__version__']
import numpy as np from spuq.utils.testing import * try: import dolfin from dolfin import (UnitSquare, FunctionSpace, Expression, interpolate, dx, inner, nabla_grad, TrialFunction, TestFunction, assemble, Constant, DirichletBC, Mesh, PETScMatrix, SLEPcEigenSolver, Function, solve) from spuq.fem.fenics.fenics_basis import FEniCSBasis from spuq.fem.fenics.fenics_vector import FEniCSVector from spuq.fem.fenics.fenics_operator import FEniCSOperator, FEniCSSolveOperator HAVE_FENICS = True # Test for PETSc and SLEPc HAVE_SLEPC = dolfin.has_linear_algebra_backend("PETSc") and dolfin.has_slepc() TestFunction = no_test(TestFunction) except: HAVE_FENICS = False def homogeneous_bc(V): # define boundary conditions def u0_boundary(x, on_boundary): return on_boundary u0 = Constant(0.0) bc = DirichletBC(V, u0, u0_boundary) return bc def assemble_lhs(coeff, V): """Assemble the discrete problem (i.e. the stiffness matrix)."""
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # RBniCS is distributed in the hope that it will be useful, # 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 RBniCS. If not, see <http://www.gnu.org/licenses/>. # # Check that dolfin has been compiled with PETSc and SLEPc from dolfin import has_petsc, has_linear_algebra_backend, parameters, has_slepc assert has_petsc() assert has_linear_algebra_backend("PETSc") assert parameters["linear_algebra_backend"] == "PETSc" assert has_slepc() # Import modules from rbnics.backends.dolfin.abs import abs from rbnics.backends.dolfin.affine_expansion_storage import AffineExpansionStorage from rbnics.backends.dolfin.assign import assign from rbnics.backends.dolfin.basis_functions_matrix import BasisFunctionsMatrix from rbnics.backends.dolfin.copy import copy from rbnics.backends.dolfin.eigen_solver import EigenSolver from rbnics.backends.dolfin.evaluate import evaluate from rbnics.backends.dolfin.export import export from rbnics.backends.dolfin.function import Function from rbnics.backends.dolfin.functions_list import FunctionsList from rbnics.backends.dolfin.gram_schmidt import GramSchmidt
"geometry": ["BoundingBoxTree"] } # FIXME: Graph tests disabled for now since SCOTCH is now required # Run both C++ and Python tests as default only_python = False # Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True # Build prefix list prefixes = [""] if has_mpi() and (has_parmetis() or has_scotch()) and \ (has_linear_algebra_backend("Epetra") or has_linear_algebra_backend("PETSc")): prefixes.append("mpirun -np 3 ") else: print "DOLFIN has not been compiled with MPI and/or ParMETIS/SCOTCH. Unit tests will not be run in parallel." # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Set non-interactive os.putenv('DOLFIN_NOPLOT', '1') failed = [] # Run tests in serial, then in parallel for prefix in prefixes: for test, subtests in tests.items():
"parameter": ["Parameters"], "python-extras": ["test"], "refinement": ["refine"], } # Run both C++ and Python tests as default only_python = False # Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True # Build prefix list prefixes = [""] if has_mpi() and (has_parmetis() or has_scotch()) and \ (has_linear_algebra_backend("Epetra") or \ has_linear_algebra_backend("PETSc")): prefixes.append("mpirun -np 3 ") else: print "DOLFIN has not been compiled with MPI and/or ParMETIS/SCOTCH. " \ "Unit tests will not be run in parallel." # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Set non-interactive os.putenv('DOLFIN_NOPLOT', '1') failed = [] # Run tests in serial, then in parallel
"""This is a cluster-executable version of the Stokes flow PDE solution""" import numpy as np import dolfin as df import time import scipy.io as sio import os import socket import sys # Test for PETSc or Epetra if not df.has_linear_algebra_backend("PETSc") and not df.has_linear_algebra_backend("Epetra"): df.info("DOLFIN has not been configured with Trilinos or PETSc. Exiting.") exit() if df.has_krylov_solver_method("minres"): krylov_method = "minres" elif df.has_krylov_solver_method("tfqmr"): krylov_method = "tfqmr" else: df.info("Default linear algebra backend was not compiled with MINRES or TFQMR " "Krylov subspace method. Terminating.") exit() # general parameters meshes = np.arange(0, 10000) # vector of random meshes to load porousMedium = 'nonOverlappingCircles' # circles or randomField nElements = 256 # Define physical parameters mu = 1 # viscosity