From e315778a2e3461fee481050c0812f78c171f565a Mon Sep 17 00:00:00 2001 From: Jannis Teunissen Date: Fri, 31 May 2024 12:08:35 +0200 Subject: [PATCH 1/3] Compile tools folder by default --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 89000a0b..5d4dec9f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SRC_DIRS := lib_1d lib_2d lib_3d examples tests +SRC_DIRS := lib_1d lib_2d lib_3d examples tests tools # Directories with altered names (useful for cleaning) CLEANSRC := $(SRC_DIRS:%=clean-%) From e5acbe3d62ac93436b664447e6c315dd1d9b8b7b Mon Sep 17 00:00:00 2001 From: Jannis Teunissen Date: Fri, 31 May 2024 16:16:19 +0200 Subject: [PATCH 2/3] Update for new doxygen version --- Doxyfile | 8 +- documentation/my_customlayout.xml | 196 ------------------------------ documentation/time_integration.md | 4 +- src/m_af_advance.f90 | 5 +- src/m_af_core.f90 | 2 +- src/m_af_flux_schemes.f90 | 2 +- src/m_af_ghostcell.f90 | 2 +- src/m_af_interp.f90 | 2 +- src/m_af_limiters.f90 | 2 +- src/m_af_multigrid.f90 | 2 +- src/m_af_output.f90 | 3 +- src/m_af_particles.f90 | 2 +- src/m_af_prolong.f90 | 2 +- src/m_af_restrict.f90 | 3 +- src/m_af_stencil.f90 | 2 +- src/m_af_surface.f90 | 2 +- src/m_af_types.f90 | 2 +- src/m_af_utils.f90 | 2 +- src/m_coarse_solver.f90 | 2 +- 19 files changed, 24 insertions(+), 221 deletions(-) delete mode 100644 documentation/my_customlayout.xml diff --git a/Doxyfile b/Doxyfile index 629b605e..70a79f86 100644 --- a/Doxyfile +++ b/Doxyfile @@ -684,7 +684,7 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = documentation/my_customlayout.xml +LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib @@ -827,7 +827,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = */m_aX_*.f90 */*_Xd.f90 +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -844,7 +844,7 @@ EXCLUDE_SYMBOLS = # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = examples +EXAMPLE_PATH = examples src # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and @@ -938,7 +938,7 @@ INLINE_SOURCES = NO # Fortran comments will always remain visible. # The default value is: YES. -STRIP_CODE_COMMENTS = YES +STRIP_CODE_COMMENTS = NO # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # function all documented functions referencing it will be listed. diff --git a/documentation/my_customlayout.xml b/documentation/my_customlayout.xml deleted file mode 100644 index 8560f369..00000000 --- a/documentation/my_customlayout.xml +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/documentation/time_integration.md b/documentation/time_integration.md index 609de4e5..cae62863 100644 --- a/documentation/time_integration.md +++ b/documentation/time_integration.md @@ -6,9 +6,7 @@ The `m_af_advance` module can be used to perform time integration. Currently, the following explicit methods are included: -* [Forward Euler](https://en.wikipedia.org/wiki/Euler_method) (`af_forward_euler`) -* [Midpoint method](https://en.wikipedia.org/wiki/Midpoint_method) (`af_midpoint_method`) -* [Heun's method](https://en.wikipedia.org/wiki/Heun%27s_method) (`af_heuns_method`) +\snippet m_af_advance.f90 time_integration_schemes New integrators can be added relatively easily by modifying the `af_advance` routine. diff --git a/src/m_af_advance.f90 b/src/m_af_advance.f90 index 2a3b1db5..a0255a10 100644 --- a/src/m_af_advance.f90 +++ b/src/m_af_advance.f90 @@ -1,12 +1,14 @@ -#include "cpp_macros.h" !> Module with methods to perform time integration module m_af_advance +#include "cpp_macros.h" use m_af_types implicit none private integer, parameter, public :: af_num_integrators = 8 + + !< [time_integration_schemes] !> Forward Euler method integer, parameter, public :: af_forward_euler = 1 !> Heun's method (AKA modified Euler's method, explicit trapezoidal rule), CFL @@ -27,6 +29,7 @@ module m_af_advance !> Classic 4th order Runge Kutta method, see e.g. !> https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods integer, parameter, public :: af_rk4_method = 8 + !< [time_integration_schemes] character(len=af_nlen), public :: af_integrator_names(af_num_integrators) = & [character(len=af_nlen) :: "forward_euler", "heuns_method", & diff --git a/src/m_af_core.f90 b/src/m_af_core.f90 index c86b85ea..d722799c 100644 --- a/src/m_af_core.f90 +++ b/src/m_af_core.f90 @@ -1,7 +1,7 @@ -#include "cpp_macros.h" !> This module contains the core routines of Afivo, namely those that deal with !> initializing and changing the quadtree/octree mesh. module m_af_core +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_flux_schemes.f90 b/src/m_af_flux_schemes.f90 index c8ca4ac0..4ab5b2e8 100644 --- a/src/m_af_flux_schemes.f90 +++ b/src/m_af_flux_schemes.f90 @@ -1,7 +1,7 @@ -#include "cpp_macros.h" !> Module containing a couple flux schemes for solving hyperbolic problems !> explicitly, as well as handling diffusion explicitly. module m_af_flux_schemes +#include "cpp_macros.h" use m_af_types use m_af_limiters diff --git a/src/m_af_ghostcell.f90 b/src/m_af_ghostcell.f90 index 18111c56..c6fe6b46 100644 --- a/src/m_af_ghostcell.f90 +++ b/src/m_af_ghostcell.f90 @@ -1,7 +1,7 @@ -#include "cpp_macros.h" !> This module contains routines related to the filling of ghost cells. Note that !> corner ghost cells are not used in Afivo. module m_af_ghostcell +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_interp.f90 b/src/m_af_interp.f90 index 05b3ed2e..fa47401f 100644 --- a/src/m_af_interp.f90 +++ b/src/m_af_interp.f90 @@ -1,8 +1,8 @@ -#include "cpp_macros.h" !> This module contains routines related to interpolation, which can interpolate !> 'to' the grid and 'from' the grid (useful for e.g. particle simulations). The !> interpolation for meshes is called prolongation, see m_aX_prolong. module m_af_interp +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_limiters.f90 b/src/m_af_limiters.f90 index afad30d5..d1ea01d7 100644 --- a/src/m_af_limiters.f90 +++ b/src/m_af_limiters.f90 @@ -1,6 +1,6 @@ -#include "cpp_macros.h" !> Module containing slope limiters module m_af_limiters +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_multigrid.f90 b/src/m_af_multigrid.f90 index 28028685..29d2f76d 100644 --- a/src/m_af_multigrid.f90 +++ b/src/m_af_multigrid.f90 @@ -1,8 +1,8 @@ -#include "../src/cpp_macros.h" !> This module contains the geometric multigrid routines that come with Afivo !> !> @todo How to use box tag with different types of operators? module m_af_multigrid +#include "../src/cpp_macros.h" use m_af_types use m_af_stencil use m_af_ghostcell diff --git a/src/m_af_output.f90 b/src/m_af_output.f90 index a9b7f492..31517e9b 100644 --- a/src/m_af_output.f90 +++ b/src/m_af_output.f90 @@ -1,8 +1,7 @@ -#include "cpp_macros.h" !> This module contains routines for writing output files with Afivo. The Silo !> format should probably be used for larger files, especially in 3D. module m_af_output - +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_particles.f90 b/src/m_af_particles.f90 index 9788e31c..410d5aab 100644 --- a/src/m_af_particles.f90 +++ b/src/m_af_particles.f90 @@ -1,4 +1,3 @@ -#include "cpp_macros.h" !> This module contains routines related to , which can interpolate !> 'to' the grid and 'from' the grid (useful for e.g. particle simulations). The !> interpolation for meshes is called prolongation, see m_aX_prolong. @@ -7,6 +6,7 @@ !> two advantages: first, data does not need to be copied, saving memory. !> Second, the particle id can be cached in the particle's data structured. module m_af_particles +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_prolong.f90 b/src/m_af_prolong.f90 index 0b08d313..eaae294a 100644 --- a/src/m_af_prolong.f90 +++ b/src/m_af_prolong.f90 @@ -1,7 +1,7 @@ -#include "cpp_macros.h" !> This module contains the routines related to prolongation: going from !> coarse to fine variables. module m_af_prolong +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_restrict.f90 b/src/m_af_restrict.f90 index db0e4915..77e9e1ca 100644 --- a/src/m_af_restrict.f90 +++ b/src/m_af_restrict.f90 @@ -1,8 +1,7 @@ -#include "cpp_macros.h" !> This module contains routines for restriction: going from fine to coarse !> variables. module m_af_restrict - +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_stencil.f90 b/src/m_af_stencil.f90 index 8ab2fbcd..bcd02f00 100644 --- a/src/m_af_stencil.f90 +++ b/src/m_af_stencil.f90 @@ -1,6 +1,6 @@ -#include "cpp_macros.h" !> This module contains functionality for dealing with numerical stencils module m_af_stencil +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_surface.f90 b/src/m_af_surface.f90 index 080198cd..3e11c580 100644 --- a/src/m_af_surface.f90 +++ b/src/m_af_surface.f90 @@ -1,8 +1,8 @@ -#include "cpp_macros.h" !> This module contains routines for including flat surfaces between changes in !> epsilon (some material property). This can for example be used to include !> flat dielectrics in electrostatic computations. module m_af_surface +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_af_types.f90 b/src/m_af_types.f90 index b1a7dc57..040ba2f8 100644 --- a/src/m_af_types.f90 +++ b/src/m_af_types.f90 @@ -1,7 +1,7 @@ -#include "cpp_macros.h" !> This module contains the basic types and constants that are used in the !> NDIM-dimensional version of Afivo, together with some basic routines. module m_af_types +#include "cpp_macros.h" use iso_c_binding, only: c_ptr implicit none diff --git a/src/m_af_utils.f90 b/src/m_af_utils.f90 index f140c1ca..b49d53e2 100644 --- a/src/m_af_utils.f90 +++ b/src/m_af_utils.f90 @@ -1,8 +1,8 @@ -#include "cpp_macros.h" !> This module contains all kinds of different 'helper' routines for Afivo. If !> the number of routines for a particular topic becomes large, they should !> probably be put in a separate module. module m_af_utils +#include "cpp_macros.h" use m_af_types implicit none diff --git a/src/m_coarse_solver.f90 b/src/m_coarse_solver.f90 index 0e834b57..3d7372ce 100644 --- a/src/m_coarse_solver.f90 +++ b/src/m_coarse_solver.f90 @@ -1,7 +1,7 @@ -#include "../src/cpp_macros.h" !> Module to solve elliptic PDEs on the coarse grid. This module contains an !> interface to Hypre, assuming Hypre is compiled with OpenMP and without MPI module m_coarse_solver +#include "../src/cpp_macros.h" use m_af_types use m_af_stencil From 19224455c5a589343b351bab3ae48351a9c1b807 Mon Sep 17 00:00:00 2001 From: Jannis Teunissen Date: Sun, 2 Jun 2024 06:07:42 +0200 Subject: [PATCH 3/3] Prevent warning and add variable to plot --- tools/plot_raw_data.py | 11 ++++++++--- tools/raw_reader.py | 12 ++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/plot_raw_data.py b/tools/plot_raw_data.py index c00955fc..97c92606 100755 --- a/tools/plot_raw_data.py +++ b/tools/plot_raw_data.py @@ -103,7 +103,8 @@ def get_uniform_data(grids, domain, min_pixels, interpolation='linear', def plot_uniform_data(uniform_data, x, time, vmin=None, vmax=None, cmap=None, - xlim=None, ylim=None, hide_axes=False, save_plot=None): + xlim=None, ylim=None, hide_axes=False, save_plot=None, + variable=None): # Plot data fig, ax = plt.subplots() ndim = uniform_data.ndim @@ -128,7 +129,10 @@ def plot_uniform_data(uniform_data, x, time, vmin=None, vmax=None, cmap=None, if ylim: ax.set_ylim(*ylim) - ax.set_title(f't = {time:.3e}') + title = f't = {time:.3e}' + if variable is not None: + title = title + ' - ' + variable + ax.set_title(title) if save_plot: print(f'Saving to {save_plot}') @@ -165,7 +169,8 @@ def plot_uniform_data(uniform_data, x, time, vmin=None, vmax=None, cmap=None, vmin=args.vmin, vmax=args.vmax, cmap=args.cmap, xlim=args.xlim, ylim=args.ylim, hide_axes=args.hide_axes, - save_plot=args.save_plot) + save_plot=args.save_plot, + variable=args.variable) else: # All spatial dimensions are projected, only print time and sum grid_values = np.array([g['values'] for g in grids]) diff --git a/tools/raw_reader.py b/tools/raw_reader.py index fc7610ff..ccc0e100 100644 --- a/tools/raw_reader.py +++ b/tools/raw_reader.py @@ -74,7 +74,7 @@ def read_single_grid(f): # Number of cell centers is one less than number of faces n_cells = dims-1 - fmt = '=' + str(np.product(n_cells)) + 'd' + fmt = '=' + str(np.prod(n_cells)) + 'd' tmp = unpack(fmt, f.read(calcsize(fmt))) vals = np.array(tmp).reshape(n_cells, order='F') @@ -143,7 +143,7 @@ def write_single_grid(f, grid): # Number of cell centers is one less than number of faces n_cells = grid['dims']-1 - fmt = '=' + str(np.product(n_cells)) + 'd' + fmt = '=' + str(np.prod(n_cells)) + 'd' f.write(grid['values'].tobytes(order='F')) @@ -226,13 +226,13 @@ def grid_project(in_grid, project_dims, axisymmetric): if axisymmetric and 0 in pdims: # Multiply with 2 * pi * r r = g['coords_cc'][0][valid_ix[0]] - w = np.product(g['dr'][pdims]) * 2 * np.pi * r + w = np.prod(g['dr'][pdims]) * 2 * np.pi * r # Broadcast to have volume weight for every grid cell w = np.broadcast_to(w[:, None], ihi-ilo) g['values'] = (g['values'][valid_ix] * w).sum(axis=tuple(pdims)) else: - fac = np.product(g['dr'][pdims]) + fac = np.prod(g['dr'][pdims]) g['values'] = fac * g['values'][valid_ix].sum(axis=tuple(pdims)) g['n_dims'] -= len(project_dims) @@ -328,7 +328,7 @@ def map_grid_data_to(g, r_min, r_max, dr, axisymmetric=False, cdata = np.zeros(nx) if axisymmetric: - rvolume = np.product(g['dr']/dr) * coords_fine[0]/coords_coarse[0] + rvolume = np.prod(g['dr']/dr) * coords_fine[0]/coords_coarse[0] if rvolume.ndim < len(g['ihi']): # Broadcast to have volume weight for every grid cell @@ -338,7 +338,7 @@ def map_grid_data_to(g, r_min, r_max, dr, axisymmetric=False, values = rvolume.ravel() * g['values'][valid_ix].ravel() else: # Cartesian grid, simple averaging - rvolume = np.product(g['dr']/dr) + rvolume = np.prod(g['dr']/dr) values = rvolume * g['values'][valid_ix].ravel() np.add.at(cdata, tuple(map(np.ravel, ixs)), values)