1# -*- coding: utf-8 -*- 2 3from pyfr.integrators.base import BaseIntegrator 4from pyfr.integrators.base import BaseCommon 5from pyfr.util import proxylist 6 7 8class BaseStdIntegrator(BaseCommon, BaseIntegrator): 9 formulation = 'std' 10 11 def __init__(self, backend, systemcls, rallocs, mesh, initsoln, cfg): 12 super().__init__(backend, rallocs, mesh, initsoln, cfg) 13 14 # Sanity checks 15 if self.controller_needs_errest and not self.stepper_has_errest: 16 raise TypeError('Incompatible stepper/controller combination') 17 18 # Ensure the system is compatible with our formulation 19 if 'std' not in systemcls.elementscls.formulations: 20 raise RuntimeError(f'System {systemcls.name} does not support ' 21 f'time stepping formulation std') 22 23 # Determine the amount of temp storage required by this method 24 self.nregs = self.stepper_nregs 25 26 # Construct the relevant system 27 self.system = systemcls(backend, rallocs, mesh, initsoln, 28 nregs=self.nregs, cfg=cfg) 29 30 # Register index list and current index 31 self._regidx = list(range(self.nregs)) 32 self._idxcurr = 0 33 34 # Global degree of freedom count 35 self._gndofs = self._get_gndofs() 36 37 # Event handlers for advance_to 38 self.completed_step_handlers = proxylist(self._get_plugins(initsoln)) 39 40 # Delete the memory-intensive elements map from the system 41 del self.system.ele_map 42 43 @property 44 def soln(self): 45 # If we do not have the solution cached then fetch it 46 if not self._curr_soln: 47 self._curr_soln = self.system.ele_scal_upts(self._idxcurr) 48 49 return self._curr_soln 50 51 @property 52 def grad_soln(self): 53 # If we do not have the solution gradients cached then compute and fetch them 54 if not self._curr_grad_soln: 55 self.system.compute_grads(self.tcurr, self._idxcurr) 56 self._curr_grad_soln = self.system.eles_vect_upts.get() 57 58 return self._curr_grad_soln 59 60 @property 61 def controller_needs_errest(self): 62 pass 63