class ConstantDensityAcousticFrequencyBase(ConstantDensityAcousticBase):

    _local_support_spec = {
        'equation_dynamics': 'frequency',
        # These should be defined by subclasses.
        'spatial_discretization': None,
        'spatial_accuracy_order': None,
        'spatial_dimension': None,
        'boundary_conditions': None,
        'precision': None
    }

    def __init__(self, mesh, solver_style='sparseLU', **kwargs):

        # A dictionary that holds the helmholtz operators as a function of nu
        self.linear_operators = ConstructableDict(
            self._build_helmholtz_operator)

        # A dictionary that holds the helmholtz solver as a function of nu
        solver_builder = self.__getattribute__(solver_style_map[solver_style])
        self.solvers = ConstructableDict(solver_builder)

        ConstantDensityAcousticBase.__init__(self,
                                             mesh,
                                             solver_style=solver_style,
                                             **kwargs)

    def _process_mp_reset(self, *args, **kwargs):

        self.linear_operators.clear()
        self.solvers.clear()
        self._rebuild_operators()

    def _rebuild_operators(self):
        raise NotImplementedError(
            "'_rebuild_operators' must be implemented in a subclass")

    def _build_sparseLU_solver(self, nu):
        return spspla.factorized(self.linear_operators[nu])

    def _build_amg_solver(self, nu):
        raise NotImplementedError(
            'AMG solver for helmholtz is not implemented.')

    def _build_iterative_solver(self, nu):
        raise NotImplementedError(
            'Iterative solver for helmholtz is not implemented.')

    def solve(self, *args, **kwargs):
        """Framework for a single execution of the solver at a given frequency. """
        raise NotImplementedError(
            "Function 'solve' Must be implemented by subclass.")
    def __init__(self, mesh, solver_style='sparseLU', **kwargs):

        # A dictionary that holds the helmholtz operators as a function of nu
        self.linear_operators = ConstructableDict(self._build_helmholtz_operator)

        # A dictionary that holds the helmholtz solver as a function of nu
        solver_builder = self.__getattribute__(solver_style_map[solver_style])
        self.solvers = ConstructableDict(solver_builder)

        VariableDensityAcousticBase.__init__(self,
                                             mesh,
                                             solver_style=solver_style,
                                             **kwargs)
    def __init__(self, mesh, solver_style='sparseLU', **kwargs):

        # A dictionary that holds the helmholtz operators as a function of nu
        self.linear_operators = ConstructableDict(self._build_helmholtz_operator)

        # A dictionary that holds the helmholtz solver as a function of nu
        solver_builder = self.__getattribute__(solver_style_map[solver_style])
        self.solvers = ConstructableDict(solver_builder)

        ConstantDensityAcousticBase.__init__(self,
                                             mesh,
                                             solver_style=solver_style,
                                             **kwargs)
class ConstantDensityAcousticFrequencyBase(ConstantDensityAcousticBase):

    _local_support_spec = {'equation_dynamics': 'frequency',
                           # These should be defined by subclasses.
                           'spatial_discretization': None,
                           'spatial_accuracy_order': None,
                           'spatial_dimension': None,
                           'boundary_conditions': None,
                           'precision': None}

    def __init__(self, mesh, solver_style='sparseLU', **kwargs):

        # A dictionary that holds the helmholtz operators as a function of nu
        self.linear_operators = ConstructableDict(self._build_helmholtz_operator)

        # A dictionary that holds the helmholtz solver as a function of nu
        solver_builder = self.__getattribute__(solver_style_map[solver_style])
        self.solvers = ConstructableDict(solver_builder)

        ConstantDensityAcousticBase.__init__(self,
                                             mesh,
                                             solver_style=solver_style,
                                             **kwargs)

    def _process_mp_reset(self, *args, **kwargs):

        self.linear_operators.clear()
        self.solvers.clear()
        self._rebuild_operators()

    def _rebuild_operators(self):
        raise NotImplementedError("'_rebuild_operators' must be implemented in a subclass")

    def _build_sparseLU_solver(self, nu):
        return spspla.factorized(self.linear_operators[nu])

    def _build_amg_solver(self, nu):
        raise NotImplementedError('AMG solver for helmholtz is not implemented.')

    def _build_iterative_solver(self, nu):
        raise NotImplementedError('Iterative solver for helmholtz is not implemented.')

    def solve(self, *args, **kwargs):
        """Framework for a single execution of the solver at a given frequency. """
        raise NotImplementedError("Function 'solve' Must be implemented by subclass.")
Пример #5
0
    def __init__(self,
                 truncated_mesh_collection,
                 sparse_greens_matrix,
                 petsc='mumps'):
        #The petsc argument takes the type petsc solver you want

        #Create the solver the normal way. This will not generate the correct constructabledict 'self.solvers'. So we need to overwrite that. Hacky...
        self.solver = ConstantDensityAcousticFrequencyScalar_2D_truncated_domain(
            truncated_mesh_collection, sparse_greens_matrix)
        self.solver.solvers = ConstructableDict(
            self.factorize_at_freq)  #This function will be used.
        self.petsc = petsc
    def __init__(self,
                 mesh,
                 spatial_shifted_differences=True,
                 spatial_accuracy_order=4,
                 petsc='mumps',
                 **kwargs):
        #The petsc argument takes the type petsc solver you want

        #Create the solver the normal way. This will not generate the correct constructabledict 'self.solvers'. So we need to overwrite that. Hacky...
        self.solver = ConstantDensityHelmholtz(
            mesh,
            spatial_shifted_differences=spatial_shifted_differences,
            spatial_accuracy_order=spatial_accuracy_order,
            **kwargs)
        self.solver.solvers = ConstructableDict(
            self.factorize_at_freq)  #This function will be used.
        self.petsc = petsc