Skip to content

Commit

Permalink
build based on 4cc1ff5
Browse files Browse the repository at this point in the history
  • Loading branch information
jipolanco authored and Documenter.jl committed Feb 21, 2023
1 parent 5cb3ff2 commit 054f29a
Show file tree
Hide file tree
Showing 1,158 changed files with 825,052 additions and 2,899 deletions.
23 changes: 23 additions & 0 deletions dev/LocalGrids/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Working with grids · PencilArrays.jl</title><script data-outdated-warner src="../assets/warner.js"></script><link rel="canonical" href="https://jipolanco.github.io/PencilArrays.jl/LocalGrids/"/><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/custom.css" rel="stylesheet" type="text/css"/><script src="../assets/tomate.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../"><img src="../assets/logo.svg" alt="PencilArrays.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="../">PencilArrays.jl</a></span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><span class="tocitem">Library</span><ul><li><a class="tocitem" href="../Pencils/">Pencil configurations</a></li><li><a class="tocitem" href="../PencilArrays/">Array wrappers</a></li><li class="is-active"><a class="tocitem" href>Working with grids</a><ul class="internal"><li><a class="tocitem" href="#Creating-local-grids"><span>Creating local grids</span></a></li><li><a class="tocitem" href="#Using-local-grids"><span>Using local grids</span></a></li><li><a class="tocitem" href="#Library"><span>Library</span></a></li><li><a class="tocitem" href="#Index"><span>Index</span></a></li></ul></li><li><a class="tocitem" href="../Transpositions/">Global MPI operations</a></li><li><a class="tocitem" href="../PencilIO/">Parallel I/O</a></li><li><a class="tocitem" href="../MPITopology/">MPI topology</a></li><li><a class="tocitem" href="../PencilArrays_timers/">Measuring performance</a></li></ul></li><li><span class="tocitem">Additional notes</span><ul><li><a class="tocitem" href="../notes/reductions/">Reductions</a></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Library</a></li><li class="is-active"><a href>Working with grids</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Working with grids</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/jipolanco/PencilArrays.jl/blob/master/docs/src/LocalGrids.md#L" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Working-with-grids"><a class="docs-heading-anchor" href="#Working-with-grids">Working with grids</a><a id="Working-with-grids-1"></a><a class="docs-heading-anchor-permalink" href="#Working-with-grids" title="Permalink"></a></h1><p>PencilArrays.jl includes functionality for conveniently working with the coordinates associated to a multidimensional domain. For this, the <a href="#PencilArrays.LocalGrids.localgrid"><code>localgrid</code></a> function can be used to construct an object describing the grid coordinates associated to the local MPI process. This object can be used to easily and efficiently perform operations that depend on the local coordinates.</p><h2 id="Creating-local-grids"><a class="docs-heading-anchor" href="#Creating-local-grids">Creating local grids</a><a id="Creating-local-grids-1"></a><a class="docs-heading-anchor-permalink" href="#Creating-local-grids" title="Permalink"></a></h2><p>As an example, say we are performing a 3D simulation on a <a href="https://en.wikipedia.org/wiki/Regular_grid#Rectilinear_grid">rectilinear grid</a>, so that the coordinates of a grid point are given by <span>$\bm{x}_{ijk} = (x_i, y_j, z_k)$</span> where <code>x</code>, <code>y</code> and <code>z</code> are separate one-dimensional arrays. For instance:</p><pre><code class="language-julia hljs">Nx, Ny, Nz = 65, 17, 21
xs = range(0, 1; length = Nx)
ys = range(-1, 1; length = Ny)
zs = range(0, 2; length = Nz)</code></pre><p>Before continuing, let&#39;s create a domain decomposition configuration:</p><pre><code class="language-julia hljs">using MPI
using PencilArrays

MPI.Init()
comm = MPI.COMM_WORLD

pen = Pencil((Nx, Ny, Nz), comm)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Decomposition of 3D data
Data dimensions: (65, 17, 21)
Decomposed dimensions: (2, 3)
Data permutation: NoPermutation()
Array type: Array</code></pre><p>Now, we can extract the local grid associated to the local MPI process:</p><pre><code class="language-julia hljs">grid = localgrid(pen, (xs, ys, zs))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">LocalRectilinearGrid{3} with coordinates:
(1) 0.0:0.015625:1.0
(2) -1.0:0.125:1.0
(3) 0.0:0.1:2.0</code></pre><p>Note that this example was run on a single MPI process, which makes things somewhat less interesting, but the same applies to more processes. With more than one process, the local grid is a subset of the global grid defined by the coordinates <code>(xs, ys, zs)</code>.</p><h2 id="Using-local-grids"><a class="docs-heading-anchor" href="#Using-local-grids">Using local grids</a><a id="Using-local-grids-1"></a><a class="docs-heading-anchor-permalink" href="#Using-local-grids" title="Permalink"></a></h2><p>The <code>grid</code> object just created can be used to operate with <code>PencilArray</code>s. In particular, say we want to initialise a <code>PencilArray</code> to a function that depends on the domain coordinates, <span>$u(x, y, z) = x + 2y + z^2$</span>. This can be easily done using the broadcasting syntax (here we use the <code>@.</code> macro for convenience):</p><pre><code class="language-julia hljs">u = PencilArray{Float64}(undef, pen) # construct PencilArray first
@. u = grid.x + 2 * grid.y + grid.z^2</code></pre><p>Here, <code>grid.x</code>, <code>grid.y</code> and <code>grid.z</code> are a convenient way of extracting the three components of the grid. Alternatively, one can use the syntax <code>grid[1]</code>, <code>grid[2]</code>, etc..., which is in particularly useful when working in dimensions higher than 3.</p><p>Note that one could do the same as above using indexing instead of broadcasting:</p><pre><code class="language-julia hljs">for I ∈ eachindex(grid)
x, y, z = grid[I]
u[I] = x + 2y + z^2
end</code></pre><h2 id="Library"><a class="docs-heading-anchor" href="#Library">Library</a><a id="Library-1"></a><a class="docs-heading-anchor-permalink" href="#Library" title="Permalink"></a></h2><article class="docstring"><header><a class="docstring-binding" id="PencilArrays.LocalGrids.AbstractLocalGrid" href="#PencilArrays.LocalGrids.AbstractLocalGrid"><code>PencilArrays.LocalGrids.AbstractLocalGrid</code></a><span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">AbstractLocalGrid{N, Perm &lt;: AbstractPermutation}</code></pre><p>Abstract type specifying the local portion of an <code>N</code>-dimensional grid.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/jipolanco/PencilArrays.jl/blob/4cc1ff5e8b8b22cbb825913a827777142dbbc4d3/src/LocalGrids/LocalGrids.jl#LL12-L16">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="PencilArrays.LocalGrids.LocalRectilinearGrid" href="#PencilArrays.LocalGrids.LocalRectilinearGrid"><code>PencilArrays.LocalGrids.LocalRectilinearGrid</code></a><span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">LocalRectilinearGrid{N, Perm} &lt;: AbstractLocalGrid{N, Perm}</code></pre><p>Defines the local portion of a rectilinear grid in <code>N</code> dimensions.</p><p>A rectilinear grid is represented by a set of orthogonal coordinates <code>(x, y, z, ...)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/jipolanco/PencilArrays.jl/blob/4cc1ff5e8b8b22cbb825913a827777142dbbc4d3/src/LocalGrids/rectilinear.jl#LL1-L7">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="PencilArrays.LocalGrids.localgrid" href="#PencilArrays.LocalGrids.localgrid"><code>PencilArrays.LocalGrids.localgrid</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">localgrid(x::PencilArray, args...)</code></pre><p>Equivalent of <code>localgrid(pencil(x), args...)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/jipolanco/PencilArrays.jl/blob/4cc1ff5e8b8b22cbb825913a827777142dbbc4d3/src/arrays.jl#LL549-L553">source</a></section><section><div><pre><code class="nohighlight hljs">localgrid((xs, ys, ...), perm = NoPermutation()) -&gt; LocalRectilinearGrid</code></pre><p>Create a <a href="#PencilArrays.LocalGrids.LocalRectilinearGrid"><code>LocalRectilinearGrid</code></a> from a set of orthogonal coordinates <code>(xs, ys, ...)</code>, where each element is an <code>AbstractVector</code>.</p><p>Optionally, one can pass a static permutation (as in <code>Permutation(2, 1, 3)</code>) to change the order in which the coordinates are iterated.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/jipolanco/PencilArrays.jl/blob/4cc1ff5e8b8b22cbb825913a827777142dbbc4d3/src/LocalGrids/rectilinear.jl#LL17-L25">source</a></section><section><div><pre><code class="nohighlight hljs">localgrid(p::Pencil, (x_global, y_global, ...)) -&gt; LocalRectilinearGrid
localgrid(u::PencilArray, (x_global, y_global, ...)) -&gt; LocalRectilinearGrid</code></pre><p>Create a <a href="#PencilArrays.LocalGrids.LocalRectilinearGrid"><code>LocalRectilinearGrid</code></a> from a decomposition configuration and from a set of orthogonal global coordinates <code>(x_global, y_global, ...)</code>.</p><p>In this case, each <code>*_global</code> is an <code>AbstractVector</code> describing the coordinates along one dimension of the global grid.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/jipolanco/PencilArrays.jl/blob/4cc1ff5e8b8b22cbb825913a827777142dbbc4d3/src/Pencils/Pencils.jl#LL589-L599">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="PencilArrays.LocalGrids.components" href="#PencilArrays.LocalGrids.components"><code>PencilArrays.LocalGrids.components</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">LocalGrids.components(g::LocalRectilinearGrid) -&gt; (xs, ys, zs, ...)</code></pre><p>Get coordinates associated to the current MPI process.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/jipolanco/PencilArrays.jl/blob/4cc1ff5e8b8b22cbb825913a827777142dbbc4d3/src/LocalGrids/LocalGrids.jl#LL23-L27">source</a></section></article><h2 id="Index"><a class="docs-heading-anchor" href="#Index">Index</a><a id="Index-1"></a><a class="docs-heading-anchor-permalink" href="#Index" title="Permalink"></a></h2><ul><li><a href="#PencilArrays.LocalGrids.AbstractLocalGrid"><code>PencilArrays.LocalGrids.AbstractLocalGrid</code></a></li><li><a href="#PencilArrays.LocalGrids.LocalRectilinearGrid"><code>PencilArrays.LocalGrids.LocalRectilinearGrid</code></a></li><li><a href="#PencilArrays.LocalGrids.components"><code>PencilArrays.LocalGrids.components</code></a></li><li><a href="#PencilArrays.LocalGrids.localgrid"><code>PencilArrays.LocalGrids.localgrid</code></a></li></ul></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../PencilArrays/">« Array wrappers</a><a class="docs-footer-nextpage" href="../Transpositions/">Global MPI operations »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.24 on <span class="colophon-date" title="Tuesday 21 February 2023 08:44">Tuesday 21 February 2023</span>. Using Julia version 1.8.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 054f29a

Please sign in to comment.