25#ifndef __BITPIT_STENCIL_SOLVER_HPP__
26#define __BITPIT_STENCIL_SOLVER_HPP__
28#if BITPIT_ENABLE_MPI==1
34#include "bitpit_LA.hpp"
40template<
typename stencil_t>
46 virtual std::size_t size()
const = 0;
48 virtual const stencil_t & at(
long rowIndex)
const = 0;
49 virtual const stencil_t & rawAt(std::size_t rowRawIndex)
const = 0;
51 virtual const stencil_t & at(
long blockIndex,
int componentIdx)
const = 0;
52 virtual const stencil_t & rawAt(std::size_t blockRawIndex,
int componentIdx)
const = 0;
59template<
typename stencil_t,
typename stencil_container_t>
63 const stencil_container_t *m_stencils;
70template<
typename stencil_t,
typename stencil_container_t>
76 std::size_t
size()
const override;
78 const stencil_t &
at(
long rowIndex)
const override;
79 const stencil_t &
rawAt(std::size_t rowRawIndex)
const override;
81 const stencil_t &
at(
long blockIndex,
int componentIdx)
const override;
82 const stencil_t &
rawAt(std::size_t blockRawIndex,
int componentIdx)
const override;
86template<
typename stencil_t>
92 std::size_t
size()
const override;
94 const stencil_t &
at(
long rowIndex)
const override;
95 const stencil_t &
rawAt(std::size_t rowRawIndex)
const override;
97 const stencil_t &
at(
long blockIndex,
int componentIdx)
const override;
98 const stencil_t &
rawAt(std::size_t blockRawIndex,
int componentIdx)
const override;
102template<
typename stencil_t,
typename solver_kernel_t = SystemSolver>
106 using stencil_type = stencil_t;
108 using solver_kernel_type = solver_kernel_t;
109 using assembly_type =
typename solver_kernel_t::Assembler;
110 using assembly_options_type =
typename assembly_type::AssemblyOptions;
112 template<
typename stencil_container_t,
typename... AssemblerKernelArgs>
114#if BITPIT_ENABLE_MPI==1
115 template<
typename stencil_container_t,
typename... AssemblerKernelArgs>
117 AssemblerKernelArgs&&... assemblerKernelArgs);
120#if BITPIT_ENABLE_MPI==1
125 assembly_options_type
getOptions()
const override;
135#if BITPIT_ENABLE_MPI==1
159 using stencil_weight_type =
typename stencil_type::weight_type;
160 using stencil_value_type =
typename stencil_type::value_type;
165#if BITPIT_ENABLE_MPI==1
169 long m_globalRowOffset;
170 long m_globalColOffset;
173 std::unique_ptr<DiscretizationStencilStorageInterface<stencil_t>> m_stencils;
179 template<
typename... AssemblerKernelArgs>
181 AssemblerKernelArgs&&... assemblerKernelArgs);
182 template<
typename... AssemblerKernelArgs>
184#if BITPIT_ENABLE_MPI==1
185 template<
typename... AssemblerKernelArgs>
188 AssemblerKernelArgs&&... assemblerKernelArgs);
189 template<
typename... AssemblerKernelArgs>
191 AssemblerKernelArgs&&... assemblerKernelArgs);
199 template<typename W = stencil_weight_type, typename V = stencil_value_type, typename std::enable_if<std::is_fundamental<W>::value>::type * =
nullptr>
201 template<typename W = stencil_weight_type, typename V = stencil_value_type, std::size_t D = std::tuple_size<W>::value,
typename std::enable_if<std::is_same<std::array<V, D>, W>::value>::type * =
nullptr>
203 template<
typename W = stencil_weight_type,
typename V = stencil_value_type,
typename std::enable_if<std::is_same<std::vector<V>, W>::value>::type * =
nullptr>
210 virtual const stencil_t &
getRowStencil(
long rowIndex)
const;
214 template<typename W = stencil_weight_type, typename std::enable_if<std::is_fundamental<W>::value>::type * =
nullptr>
217 template<typename W = stencil_weight_type, typename std::enable_if<!std::is_fundamental<W>::value>::type * =
nullptr>
220 template<typename W = stencil_weight_type, typename std::enable_if<std::is_fundamental<W>::value>::type * =
nullptr>
223 template<typename W = stencil_weight_type, typename std::enable_if<!std::is_fundamental<W>::value>::type * =
nullptr>
227#if BITPIT_ENABLE_MPI==1
229 MPI_Comm m_communicator;
234template<
typename stencil_t,
typename solver_kernel_t = SystemSolver>
240 using solver_kernel_t::solver_kernel_t;
242 void clear()
override;
244 template<
typename stencil_container_t = std::vector<stencil_t>>
245 void assembly(
const stencil_container_t &stencils);
246#if BITPIT_ENABLE_MPI==1
247 template<
typename stencil_container_t = std::vector<stencil_t>>
248 void assembly(MPI_Comm communicator,
bool partitioned,
const stencil_container_t &stencils);
252 template<
typename stencil_container_t = std::vector<stencil_t>>
253 void update(
const stencil_container_t &stencils);
254 template<
typename stencil_container_t = std::vector<stencil_t>>
255 void update(
const std::vector<long> &rows,
const stencil_container_t &stencils);
256 template<
typename stencil_container_t = std::vector<stencil_t>>
257 void update(std::size_t nRows,
const long *rows,
const stencil_container_t &stencils);
266 std::vector<double> m_constants;
268 using solver_kernel_t::assembly;
269 using solver_kernel_t::update;
279#include "stencil_solver.tpp"
284typedef DiscretizationStencilSolverAssembler<StencilScalar> StencilScalarSolverAssembler;
285typedef DiscretizationStencilSolverAssembler<StencilVector> StencilVectorSolverAssembler;
286typedef DiscretizationStencilSolverAssembler<StencilBlock> StencilBlockSolverAssembler;
288typedef DiscretizationStencilSolver<StencilScalar> StencilScalarSolver;
289typedef DiscretizationStencilSolver<StencilVector> StencilVectorSolver;
290typedef DiscretizationStencilSolver<StencilBlock> StencilBlockSolver;
295#ifndef __BITPIT_STENCIL_SOLVER_SRC__
298extern template class DiscretizationStencilSolverAssembler<StencilScalar>;
299extern template class DiscretizationStencilSolverAssembler<StencilVector>;
300extern template class DiscretizationStencilSolverAssembler<StencilBlock>;
302extern template class DiscretizationStencilSolver<StencilScalar>;
303extern template class DiscretizationStencilSolver<StencilVector>;
304extern template class DiscretizationStencilSolver<StencilBlock>;
The DiscretizationStencilProxyBaseStorage class defines a proxy for stencil storage.
DiscretizationStencilProxyBaseStorage(const stencil_container_t *stencils, int stride)
const stencil_t & rawAt(std::size_t rowRawIndex) const override
const stencil_t & at(long rowIndex) const override
std::size_t size() const override
DiscretizationStencilProxyStorage(const stencil_container_t *stencils)
The DiscretizationStencilSolverAssembler class defines an assembler for building the stencil solver.
long getRowNZCount(long rowIndex) const override
virtual void getRowConstant(long rowIndex, bitpit::ConstProxyVector< double > *constant) const
void getRowValues(long rowIndex, ConstProxyVector< double > *values) const override
void getRowPattern(long rowIndex, ConstProxyVector< long > *pattern) const override
long getRowGlobalCount() const override
void setStencils(std::unique_ptr< DiscretizationStencilStorageInterface< stencil_t > > &&stencils)
long getColElementCount() const override
long getColGlobalElementOffset() const override
int getBlockSize() const override
long getMaxRowNZCount() const override
DiscretizationStencilSolverAssembler(const stencil_container_t *stencils, AssemblerKernelArgs &&... assemblerKernelArgs)
long getRowGlobalElementCount() const override
long getRowElementCount() const override
void getValues(const stencil_t &stencil, ConstProxyVector< double > *values) const
long getColCount() const override
void getRowData(long rowIndex, ConstProxyVector< long > *pattern, ConstProxyVector< double > *values) const override
long getRowGlobalOffset() const override
long getRowGlobalElementOffset() const override
long getColGlobalOffset() const override
long getRowCount() const override
const MPI_Comm & getCommunicator() const override
long getColGlobalElementCount() const override
void getPattern(const stencil_t &stencil, ConstProxyVector< long > *pattern) const
assembly_options_type getOptions() const override
virtual const stencil_t & getRowStencil(long rowIndex) const
bool isPartitioned() const override
void getConstant(const stencil_t &stencil, bitpit::ConstProxyVector< double > *constant) const
long getColGlobalCount() const override
void matrixAssembly(const Assembler &assembler)
void assembleConstants(const Assembler &assembler)
void matrixUpdate(long nRows, const long *rows, const Assembler &assembler)
void assembly(const stencil_container_t &stencils)
void update(const stencil_container_t &stencils)
void updateConstants(std::size_t nRows, const long *rows, const Assembler &assembler)
The DiscretizationStencilStorageInterface class defines the interface for stencil storage.
Metafunction for generating a pierced storage.
Metafunction for generating a list of elements that can be either stored in an external vectror or,...