File operatorstencil.hxx#

Classes describing the geometry of stencils used for differentiation operators. These can be used to determine how much memory to preallocate when constructing a sparse matrix to represent the operator.

Copyright 2019 C. MacMackin

Contact: Ben Dudson, bd512@york.ac.uk

This file is part of BOUT++.

BOUT++ is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BOUT++ 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with BOUT++. If not, see http://www.gnu.org/licenses/.

Typedefs

using OffsetInd3D = IndexOffset<Ind3D>#
using OffsetInd2D = IndexOffset<Ind2D>#
using OffsetIndPerp = IndexOffset<IndPerp>#

Functions

template<class T>
inline bool operator==(const IndexOffset<T> &lhs, const IndexOffset<T> &rhs)#
template<class T>
inline bool operator!=(const IndexOffset<T> &lhs, const IndexOffset<T> &rhs)#
template<class T>
inline bool operator<(const IndexOffset<T> &lhs, const IndexOffset<T> &rhs)#
template<class T>
inline const IndexOffset<T> operator+(IndexOffset<T> lhs, const IndexOffset<T> &rhs)#
template<class T>
inline const IndexOffset<T> operator-(IndexOffset<T> lhs, const IndexOffset<T> &rhs)#
template<class T>
inline const T operator+(const T &lhs, const IndexOffset<T> &rhs)#
template<class T>
inline const T operator+(const IndexOffset<T> &lhs, const T &rhs)#
template<class T>
inline const T operator-(const T &lhs, const IndexOffset<T> &rhs)#
template<class T>
OperatorStencil<T> squareStencil(Mesh *localmesh)#

Utility function to create a square stencil Used in both LaplaceXY2 and LaplaceXY2Hypre

Returns a stencil object which indicates that non-boundary cells depend on all of their neighbours to a depth of one, including corners.

template<class T>
OperatorStencil<T> starStencil(Mesh *localmesh)#

Returns a stencil object which indicates that non-boundary cells depend on all of their neighbours to a depth of one, excluding corners.

template<class T>
struct IndexOffset#
#include <operatorstencil.hxx>

A representation of offsets for indices, which can be added and subtracted from them.

Public Functions

inline const IndexOffset xp(int delta_x = 1) const#
inline const IndexOffset xm(int delta_x = 1) const#
inline const IndexOffset yp(int delta_y = 1) const#
inline const IndexOffset ym(int delta_y = 1) const#
inline const IndexOffset zp(int delta_z = 1) const#
inline const IndexOffset zm(int delta_z = 1) const#
inline IndexOffset &operator+=(const IndexOffset &n)#
inline IndexOffset &operator-=(const IndexOffset &n)#

Public Members

int dx = 0#
int dy = 0#
int dz = 0#
template<class T>
class OperatorStencil#
#include <operatorstencil.hxx>

A class which can be used to represent the shape of a stencil used to perform some operation. A stencil is made up of pairs of stencil-parts and stencil-tests. A stencil-part is a vector of OffsetIndices. When added to another index, the result is part of the stencil. A stencil-test indicates whether a particular stencil-part should be applied at a given index.

When trying to get the stencil part for an index, this class will iterate through the part/test pairs in the order which they were added, returning the first stencil-part with a test that passes. If no stencil-part is found with a passing test, then an error is thrown.

Public Types

using offset = IndexOffset<T>#
using stencil_part = std::vector<offset>#
using stencil_test = std::function<bool(T)>#
using iterator = typename std::vector<Stencil>::iterator#

Iterators for the underlying vector data type.

using const_iterator = typename std::vector<Stencil>::const_iterator#
using reverse_iterator = typename std::vector<Stencil>::reverse_iterator#
using const_reverse_iterator = typename std::vector<Stencil>::const_reverse_iterator#

Public Functions

inline OperatorStencil<T> &add(stencil_test test, stencil_part stencil)#

Add a stencil test/part pair Returns this to allow chaining, inline definitions

inline const stencil_part &getStencilPart(int i) const#

Get the ith stencil-part to have been added.

inline const stencil_part &getStencilPart(const T &i) const#

Get the stencil-part to be used on this index. The method will iterate through the part/test pairs in the order which they were added, returning the first stencil-part with a test that passes. If no stencil-part is found with a passing test, then an error is thrown.

inline int getStencilSize(int i) const#

Get the number of elements in the ith stencil-part.

inline int getStencilSize(const T &i) const#

Get the number of elements in the stencil part to be used at this index.

inline int getNumParts() const#

Get the number of stencil-parts to have been added.

inline const std::vector<T> getIndicesWithStencilIncluding(const T &i) const#

Returns a list of indices for which the stencils contain the argument

inline iterator begin()#
inline const_iterator begin() const#
inline const_iterator cbegin() const#
inline iterator end()#
inline const_iterator end() const#
inline const_iterator cend() const#
inline reverse_iterator rbegin()#
inline const_reverse_iterator rbegin() const#
inline const_reverse_iterator crbegin() const#
inline reverse_iterator rend()#
inline const_reverse_iterator rend() const#
inline const_reverse_iterator crend() const#

Private Functions

inline int getStencilNumber(const T &i) const#

Returns the position of the first passing stencil test for this index, or -1 if no test passes.

Private Members

std::vector<Stencil> stencils = {}#
struct Stencil#

Public Members

stencil_test test#
stencil_part part#