예제 #1
0
    def initialize(self,evaluation_points):

        accuracy_options = _bempplib.createAccuracyOptions()
        accuracy_options.doubleRegular.setRelativeQuadratureOrder(self._relative_regular_quadrature_order)
        accuracy_options.doubleSingular.setRelativeQuadratureOrder(self._relative_singular_quadrature_order)
        accuracy_options.singleRegular.setRelativeQuadratureOrder(self._relative_regular_quadrature_order)
        
        assembly_options = _bempplib.createAssemblyOptions()
        assembly_options.setVerbosityLevel('low')
        if self._use_aca:
            aca_options = _bempplib.createAcaOptions()
            aca_options.maximumBlockSize = 2000
            aca_options.maximumRank = 100
            aca_options.eps = self._aca_epsilon
            assembly_options.switchToAca(aca_options)
        quad_strategy = _bempplib.createNumericalQuadratureStrategy("float64","complex128",accuracy_options)
        
        
        self._quad_strategy = quad_strategy
        self._context = _bempplib.createContext(quad_strategy,assembly_options)
        pconsts = _bempplib.createPiecewiseConstantScalarSpace(self._context,self._mesh)
        self._spaces = [pconsts,pconsts,pconsts]        
        self._mass_matrix = _bempplib.createIdentityOperator(self._context,pconsts,pconsts,pconsts).weakForm()

        self._boundary_operator_cache = _tools.OperatorCache(self._operator_cache_tol)
        self._potential_operator_cache = _tools.OperatorCache(self._operator_cache_tol)
        self._residuals = {}
        self._evaluation_points = evaluation_points
예제 #2
0
    def evaluate_potential(self,wavenumber,density):

        from bempp import lib as bempplib
        
        op_found_in_cache = False
        if self._use_cache:
            try:
                potential = self._potential_operator_cache.get(wavenumber)
                op_found_in_cache = True
            except:
                pass
        
        if not op_found_in_cache:
            evalOps = _bempplib.createEvaluationOptions()
            #evalOps.setVerbosityLevel('low')
            acaOps = _bempplib.createAcaOptions()
            acaOps.eps = self._aca_epsilon
            evalOps.switchToAcaMode(acaOps)
 
        
            potential = _bempplib.createModifiedHelmholtz3dDoubleLayerPotentialOperator(self._context,wavenumber).assemble(self._spaces[0],
                                                                                                                           self._evaluation_points,
                                                                                                                           self._quad_strategy,
                                                                                                                           evalOps).discreteOperator()
        
            if self._use_cache: self._potential_operator_cache.insert(wavenumber,potential)
            
        n = len(density[0])
        return (potential*density[0].reshape(n,1)).ravel()
def initialize_context():
    
    accuracyOptions = lib.createAccuracyOptions()
    accuracyOptions.doubleRegular.setRelativeQuadratureOrder(2)
    accuracyOptions.doubleSingular.setRelativeQuadratureOrder(1)
    quadStrategy = lib.createNumericalQuadratureStrategy("float64","complex128",accuracyOptions)
    options = lib.createAssemblyOptions()
    options.setVerbosityLevel("low")
    aca_ops = lib.createAcaOptions()
    aca_ops.eps=1E-6
    options.switchToAcaMode(aca_ops)
    context = lib.createContext(quadStrategy,options)
    return context
def initialize_context():

    accuracyOptions = lib.createAccuracyOptions()
    accuracyOptions.doubleRegular.setRelativeQuadratureOrder(2)
    accuracyOptions.doubleSingular.setRelativeQuadratureOrder(1)
    quadStrategy = lib.createNumericalQuadratureStrategy(
        "float64", "complex128", accuracyOptions)
    options = lib.createAssemblyOptions()
    options.setVerbosityLevel("low")
    aca_ops = lib.createAcaOptions()
    aca_ops.eps = 1E-6
    options.switchToAcaMode(aca_ops)
    context = lib.createContext(quadStrategy, options)
    return context
예제 #5
0
# integrals, 1 order higher than default.

accuracyOptions = lib.createAccuracyOptions()
accuracyOptions.doubleRegular.setRelativeQuadratureOrder(2)
accuracyOptions.doubleSingular.setRelativeQuadratureOrder(1)

# The default strategy for numerical quadrature.
# "float64" is the basis function type and "complex128" is the result type".

quadStrategy = lib.createNumericalQuadratureStrategy(
    "float64", "complex128", accuracyOptions)

# Use ACA to accelerate the assembly

options = lib.createAssemblyOptions()
options.switchToAca(lib.createAcaOptions())

# The context object combines these settings

context = lib.createContext(quadStrategy, options)

# Load a grid approximating a unit sphere

grid_factory = lib.createGridFactory()
grid = grid_factory.importGmshGrid(
    "triangular", "../../meshes/sphere-h-0.1.msh")

# Create a space of piecewise constant basis functions over the grid.

pwiseConstants = lib.createPiecewiseConstantScalarSpace(context, grid)
예제 #6
0
os.remove(s3_geo_name)
os.remove(s1_msh_name)
os.remove(s2_msh_name)
os.remove(s3_msh_name)

# Create Context

accuracy_options = blib.createAccuracyOptions()
accuracy_options.doubleRegular.setRelativeQuadratureOrder(
    2)  # 2 orders higher than default accuracy for regular integrals
accuracy_options.doubleSingular.setRelativeQuadratureOrder(
    1)  # 1 order higher than default accuracy for singular integrals
strategy = blib.createNumericalQuadratureStrategy("float64", "complex128",
                                                  accuracy_options)
options = blib.createAssemblyOptions()
aca_options = blib.createAcaOptions()
aca_options.eps = 1E-5
options.switchToAca(aca_options)
context = blib.createContext(strategy, options)

# Create the spaces

sphere1_plc = blib.createPiecewiseLinearContinuousScalarSpace(context, sphere1)
sphere2_plc = blib.createPiecewiseLinearContinuousScalarSpace(context, sphere2)
sphere3_plc = blib.createPiecewiseLinearContinuousScalarSpace(context, sphere3)

# Now create the operators
slp11 = blib.createModifiedHelmholtz3dSingleLayerBoundaryOperator(
    context, sphere1_plc, sphere1_plc, sphere1_plc, w1)
dlp11 = blib.createModifiedHelmholtz3dDoubleLayerBoundaryOperator(
    context, sphere1_plc, sphere1_plc, sphere1_plc, w1)
예제 #7
0
os.remove(s1_geo_name)
os.remove(s2_geo_name)
os.remove(s3_geo_name)
os.remove(s1_msh_name)
os.remove(s2_msh_name)
os.remove(s3_msh_name)

# Create Context

accuracy_options = blib.createAccuracyOptions()
accuracy_options.doubleRegular.setRelativeQuadratureOrder(2) # 2 orders higher than default accuracy for regular integrals
accuracy_options.doubleSingular.setRelativeQuadratureOrder(1) # 1 order higher than default accuracy for singular integrals
strategy = blib.createNumericalQuadratureStrategy("float64", "complex128", accuracy_options)
options = blib.createAssemblyOptions()
aca_options = blib.createAcaOptions()
aca_options.eps=1E-5
options.switchToAca(aca_options)
context = blib.createContext(strategy, options)


# Create the spaces

sphere1_plc = blib.createPiecewiseLinearContinuousScalarSpace(context,sphere1)
sphere2_plc = blib.createPiecewiseLinearContinuousScalarSpace(context,sphere2)
sphere3_plc = blib.createPiecewiseLinearContinuousScalarSpace(context,sphere3)

# Now create the operators
slp11 = blib.createModifiedHelmholtz3dSingleLayerBoundaryOperator(context,sphere1_plc,sphere1_plc,sphere1_plc,w1)
dlp11 = blib.createModifiedHelmholtz3dDoubleLayerBoundaryOperator(context,sphere1_plc,sphere1_plc,sphere1_plc,w1)
id11  = blib.createIdentityOperator(context,sphere1_plc,sphere1_plc,sphere1_plc)
예제 #8
0
from bempp.lib import *
import numpy as np
import bempp.lib as lib
import scipy.special as sc
import numpy.polynomial.legendre as leg
import time

accuracyOptions = lib.createAccuracyOptions()
accuracyOptions.doubleRegular.setRelativeQuadratureOrder(2)
accuracyOptions.singleRegular.setRelativeQuadratureOrder(2)
quadStrategy = lib.createNumericalQuadratureStrategy("float64", "complex128",
                                                     accuracyOptions)

options = lib.createAssemblyOptions()
options.switchToAca(lib.createAcaOptions())
context = lib.createContext(quadStrategy, options)

grid = lib.createGridFactory().importGmshGrid("triangular", "airplane.msh")
pconsts = lib.createPiecewiseConstantScalarSpace(context, grid)

k = 16
#k = 64; #16; #0.16

# ansatz: direction of incident plane wave: assume x here
lhsOp = lib.createHelmholtz3dSingleLayerBoundaryOperator(
    context, pconsts, pconsts, pconsts, k, "SLP")


# Create a grid function representing the Dirichlet trace of the incident wave
def uIncData(point):
예제 #9
0
파일: tools.py 프로젝트: rorypeck/tdbempp
def create_bempp_options(solver_use_aca = True,
                         evaluation_use_aca = True,
                         solver_aca_epsilon = 1E-6,
                         solver_aca_maximum_rank = 200,
                         solver_aca_maximum_block_size = 2000,
                         solver_aca_mode = 'hybrid_assembly',
                         solver_aca_eta = 1.2,
                         evaluation_aca_epsilon = 1E-3,
                         evaluation_aca_eta = 0.4,
                         evaluation_aca_maximum_rank = 30,
                         evaluation_aca_maximum_block_size = 2000,
                         evaluation_aca_mode = 'global_assembly',
                         relative_double_singular_quadrature_order = 2,
                         relative_double_regular_quadrature_order = 1,
                         relative_single_regular_quadrature_order = 1,
                         verbosity_level = 'low',
                         basis_function_type = 'float64',
                         result_type = 'complex128',
                         number_of_threads = None
                         ):
                         
    solver_assembly_options = _bempplib.createAssemblyOptions()
    
    if number_of_threads is not None:
        solver_assembly_options.setMaxThreadCount(number_of_threads)
    
        
    solver_assembly_options.setVerbosityLevel(verbosity_level)
    
    if solver_use_aca:
        solver_aca_options = _bempplib.createAcaOptions()
        solver_aca_options.mode = solver_aca_mode
        solver_aca_options.eps = solver_aca_epsilon
        solver_aca_options.eta = solver_aca_eta
        solver_aca_options.maximumBlockSize = solver_aca_maximum_block_size
        solver_aca_options.maximumRank = solver_aca_maximum_rank
        solver_assembly_options.switchToAca(solver_aca_options)
    
    
    solver_accuracy_options = _bempplib.createAccuracyOptions()
    solver_accuracy_options.doubleRegular.setRelativeQuadratureOrder(relative_double_regular_quadrature_order)
    solver_accuracy_options.doubleSingular.setRelativeQuadratureOrder(relative_double_singular_quadrature_order)
    
    quadrature_strategy = _bempplib.createNumericalQuadratureStrategy(basis_function_type,result_type,solver_accuracy_options)
    context = _bempplib.createContext(quadrature_strategy,solver_assembly_options)
    
    evaluation_options = _bempplib.createEvaluationOptions()
    evaluation_accuracy_options = _bempplib.createAccuracyOptions()
    evaluation_accuracy_options.singleRegular.setRelativeQuadratureOrder(relative_single_regular_quadrature_order)
    evaluation_quadrature_strategy = _bempplib.createNumericalQuadratureStrategy(basis_function_type,result_type,evaluation_accuracy_options)
    if evaluation_use_aca:
        evaluation_aca_options = _bempplib.createAcaOptions()
        evaluation_aca_options.eps = evaluation_aca_epsilon
        evaluation_aca_options.eta = evaluation_aca_eta
        evaluation_aca_options.mode = evaluation_aca_mode
        evaluation_aca_options.maximumBlockSize = evaluation_aca_maximum_block_size
        evaluation_aca_options.maximumRank = evaluation_aca_maximum_rank
        evaluation_options.switchToAcaMode(evaluation_aca_options)
    return (context,evaluation_options,evaluation_quadrature_strategy)