你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Create Updates abstract class
这个提交包含在:
@@ -22,10 +22,11 @@ from gprMax import config
|
||||
from gprMax.cython.fields_updates_normal import update_electric as update_electric_cpu
|
||||
from gprMax.cython.fields_updates_normal import update_magnetic as update_magnetic_cpu
|
||||
from gprMax.fields_outputs import store_outputs as store_outputs_cpu
|
||||
from gprMax.updates.updates import Updates
|
||||
from gprMax.utilities.utilities import timer
|
||||
|
||||
|
||||
class CPUUpdates:
|
||||
class CPUUpdates(Updates):
|
||||
"""Defines update functions for CPU-based solver."""
|
||||
|
||||
def __init__(self, G):
|
||||
|
@@ -28,12 +28,13 @@ from gprMax.cuda_opencl import knl_fields_updates, knl_snapshots, knl_source_upd
|
||||
from gprMax.receivers import dtoh_rx_array, htod_rx_arrays
|
||||
from gprMax.snapshots import Snapshot, dtoh_snapshot_array, htod_snapshot_array
|
||||
from gprMax.sources import htod_src_arrays
|
||||
from gprMax.updates.updates import Updates
|
||||
from gprMax.utilities.utilities import round32
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CUDAUpdates:
|
||||
class CUDAUpdates(Updates):
|
||||
"""Defines update functions for GPU-based (CUDA) solver."""
|
||||
|
||||
def __init__(self, G):
|
||||
|
@@ -27,11 +27,12 @@ from gprMax.cuda_opencl import knl_fields_updates, knl_snapshots, knl_source_upd
|
||||
from gprMax.receivers import dtoh_rx_array, htod_rx_arrays
|
||||
from gprMax.snapshots import Snapshot, dtoh_snapshot_array, htod_snapshot_array
|
||||
from gprMax.sources import htod_src_arrays
|
||||
from gprMax.updates.updates import Updates
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OpenCLUpdates:
|
||||
class OpenCLUpdates(Updates):
|
||||
"""Defines update functions for OpenCL-based solver."""
|
||||
|
||||
def __init__(self, G):
|
||||
|
96
gprMax/updates/updates.py
普通文件
96
gprMax/updates/updates.py
普通文件
@@ -0,0 +1,96 @@
|
||||
# Copyright (C) 2015-2024: The University of Edinburgh, United Kingdom
|
||||
# Authors: Craig Warren, Antonis Giannopoulos, and John Hartley
|
||||
#
|
||||
# This file is part of gprMax.
|
||||
#
|
||||
# gprMax is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# gprMax is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class Updates(ABC):
|
||||
"""Defines update functions for a solver."""
|
||||
|
||||
@abstractmethod
|
||||
def store_outputs(self) -> None:
|
||||
"""Stores field component values for every receiver and transmission line."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def store_snapshots(self, iteration: int) -> None:
|
||||
"""Stores any snapshots.
|
||||
|
||||
Args:
|
||||
iteration: int for iteration number.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_magnetic(self) -> None:
|
||||
"""Updates magnetic field components."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_magnetic_pml(self) -> None:
|
||||
"""Updates magnetic field components with the PML correction."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_magnetic_sources(self) -> None:
|
||||
"""Updates magnetic field components from sources."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_electric_a(self) -> None:
|
||||
"""Updates electric field components."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_electric_pml(self) -> None:
|
||||
"""Updates electric field components with the PML correction."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_electric_sources(self) -> None:
|
||||
"""Updates electric field components from sources -
|
||||
update any Hertzian dipole sources last.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_electric_b(self) -> None:
|
||||
"""If there are any dispersive materials do 2nd part of dispersive
|
||||
update - it is split into two parts as it requires present and
|
||||
updated electric field values. Therefore it can only be completely
|
||||
updated after the electric field has been updated by the PML and
|
||||
source updates.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def time_start(self) -> None:
|
||||
"""Starts timer used to calculate solving time for model."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def calculate_solve_time(self) -> float:
|
||||
"""Calculates solving time for model."""
|
||||
pass
|
||||
|
||||
def finalise(self) -> None:
|
||||
pass
|
||||
|
||||
def cleanup(self) -> None:
|
||||
pass
|
在新工单中引用
屏蔽一个用户