コード例 #1
0
ファイル: subgridsolver.py プロジェクト: unterweg/pyclaw
    def __init__(self, solver, global_state, q, qbc, aux, position, size, subdivision_factor, unknowns_per_cell, aux_fields_per_cell, current_time):
        r"""
        Initializes this subgrid solver. It get's all information to prepare a domain and state for a
        single subgrid. 
        
        :Input:
         -  *solver* - (:class:`pyclaw.Solver`) The PyClaw-solver used for advancing this subgrid in time.
         -  *global_state* - (:class:`pyclaw.State`) The global state. This is not the state used for
                            for the actual solving of the timestep on the subgrid.
         -  *q* - The array storing the current solution.
         -  *qbc* - The array storing the solution of the last timestep including the ghostlayer.
         -  *position* - A d-dimensional tuple holding the position of the grid in the computational domain.
                         This measures the continuous real-world position in floats, not the integer position 
                         in terms of cells. 
         -  *size* - A d-dimensional tuple holding the size of the grid in the computational domain. This
                     measures the continuous real-world size in floats, not the size in terms of cells.
         -  *subdivision_factor* - The number of cells in one dimension of this subgrid. At the moment only
                                    square subgrids are allowed, so the total number of cells in the subgrid
                                    (excluding the ghostlayer) is subdivision_factor x subdivision_factor.
         -  *unknowns_per_cell* - The number of equations or unknowns that are stored per cell of the subgrid.
        
        """
        self.solver = solver
        number_of_dimensions = get_number_of_dimensions(q)

        self.domain = create_domain(number_of_dimensions, position, size, subdivision_factor)
        subgrid_state = create_subgrid_state(global_state, self.domain, q, qbc, aux, unknowns_per_cell, aux_fields_per_cell)
        subgrid_state.problem_data = global_state.problem_data
        self.solution = pyclaw.Solution(subgrid_state, self.domain)
        self.solution.t = current_time
        
        self.solver.bc_lower[:] = [pyclaw.BC.custom] * len(self.solver.bc_lower)
        self.solver.bc_upper[:] = [pyclaw.BC.custom] * len(self.solver.bc_upper)
        
        self.qbc = qbc
        self.solver.user_bc_lower = self.user_bc_lower
        self.solver.user_bc_upper = self.user_bc_upper
        
        self.recover_ghostlayers = False
コード例 #2
0
      def callback_interpolation(
                                 source_q, 
                                 source_qbc, 
                                 source_aux, 
                                 source_subdivision_factor_x0, 
                                 source_subdivision_factor_x1, 
                                 source_subdivision_factor_x2, 
                                 source_size_x0, 
                                 source_size_x1, 
                                 source_size_x2, 
                                 source_position_x0, 
                                 source_position_x1, 
                                 source_position_x2, 
                                 source_current_time, 
                                 source_timestep_size,
                                 destination_q, 
                                 destination_qbc, 
                                 destination_aux, 
                                 destination_subdivision_factor_x0, 
                                 destination_subdivision_factor_x1, 
                                 destination_subdivision_factor_x2, 
                                 destination_size_x0, 
                                 destination_size_x1, 
                                 destination_size_x2, 
                                 destination_position_x0, 
                                 destination_position_x1, 
                                 destination_position_x2, 
                                 destination_current_time, 
                                 destination_timestep_size,
                                 unknowns_per_cell,
                                 aux_fields_per_cell):
        # Fix aux array
        if(aux_fields_per_cell == 0):
          source_aux = None
          destination_aux = None

        number_of_dimensions = get_number_of_dimensions(source_q)
        source_domain = create_domain(number_of_dimensions, 
                               (source_position_x0, source_position_x1, source_position_x2), 
                               (source_size_x0, source_size_x1, source_size_x2),
                               (source_subdivision_factor_x0, source_subdivision_factor_x1, source_subdivision_factor_x2))
        source_subgrid_state = create_subgrid_state(
                               self.solver.solution.state, 
                               source_domain, 
                               source_q, 
                               source_qbc, 
                               source_aux, 
                               unknowns_per_cell, 
                               aux_fields_per_cell)
        
        destination_domain = create_domain(number_of_dimensions, 
                               (destination_position_x0, destination_position_x1, destination_position_x2), 
                               (destination_size_x0, destination_size_x1, destination_size_x2),
                               (destination_subdivision_factor_x0, destination_subdivision_factor_x1, destination_subdivision_factor_x2))
        destination_subgrid_state = create_subgrid_state(
                                    self.solver.solution.state, 
                                    destination_domain, 
                                    destination_q, 
                                    destination_qbc, 
                                    destination_aux, 
                                    unknowns_per_cell, 
                                    aux_fields_per_cell)
          
        self.interpolation(source_subgrid_state, source_qbc, destination_subgrid_state, destination_qbc)