def from_xml(cls, fpath, verbose=False, update_altimetry=True, size_criterion=0.0, refine_mesh=True, use_vol_landtakes=False): """Create a project from `fpath` XML file path, on the way update project site infrastructure altimetry if `update_altimetry` is True """ with filter_output(verbose): project = cls(cls.cyclass.from_xml(fpath)) if update_altimetry: project.update_site_altimetry( verbose, size_criterion=size_criterion, refine_mesh=refine_mesh, use_vol_landtakes=use_vol_landtakes) return project
def from_project(cls, project, solverdir, verbose=False): """Load and configure solver 'solverdir' is the directory where one can find the solver library. The configuration is read from the project. """ _set_solver_config(project.current_computation) with filter_output(verbose): solver = load_computation_solver(solverdir, project.current_computation) return cls(solver)
def from_name(cls, name, parameters_file, solverdir=None, verbose=False): """Return an instance of solver with `name`. `name` can be "default" or "Anime3D" for instance. """ solverdir = solverdir or fetch_solverdir() with open(parameters_file) as fp: _set_solver_config(fp) solver_name = cls._solvers.get(name.lower(), name) with filter_output(verbose): solver = _business2solver.acoustic_solver_by_name( solver_name, solverdir) return cls(solver)
def update_site_altimetry(self, altimesh, verbose=False): """Update the altitude of the site infrastructure items Params: - altimesh: tympan.altimetry.AltimetryMesh Site infrastructure items whose altitude can be updated are machines, buildings, sources, receptors, etc. """ with filter_output(verbose): self._project._update_site_altimetry(altimesh.mesh, altimesh.material_by_face)
def from_project(cls, project, solverdir=None, verbose=False): """Load and configure solver 'solverdir' is the directory where one can find the solver library. If None, it will be retrieved from "TYMPAN_SOLVERDIR" environment variable, which must be defined. The configuration is read from the project. """ solverdir = solverdir or fetch_solverdir() parameters_fp = StringIO(project.current_computation.solver_parameters.decode('utf-8')) _set_solver_config(parameters_fp) with filter_output(verbose): solver = _business2solver.acoustic_solver_from_computation( project.current_computation, solverdir) return cls(solver)
def update_site_altimetry(self, verbose=False, size_criterion=0.0, refine_mesh=True, use_vol_landtakes=False): """Update the altitude of the site infrastructure items Site infrastructure items whose altitude can be updated are machines, buildings, sources, receptors, etc. """ with filter_output(verbose): try: self._build_altimetry_mesh( size_criterion=size_criterion, refine_mesh=refine_mesh, use_vol_landtakes=use_vol_landtakes) except InconsistentGeometricModel as exc: message_box = ctypes.windll.user32.MessageBoxW message = exc.message message_box(None, message, 'Erreur altimetrie', 0) raise self._project._update_site_altimetry(self._altimetry_mesh.mesh, self._altimetry_mesh.material_by_face)
def no_output(cls): stdout_log = '%s_stdout.log' % (cls.__name__) stderr_log = '%s_stderr.log' % (cls.__name__) from tympan.models import filter_output with filter_output(verbose=False, to=stdout_log, err_to=stderr_log): yield
def from_xml(cls, fpath, verbose=False): """Create a project from a XML file path""" with filter_output(verbose): return cls(cls.cyclass.from_xml(fpath))