25#ifndef INTERPOLATION_F_2D_HH
26#define INTERPOLATION_F_2D_HH
35template <
typename T,
typename W>
39 _f(f), _cuboid(cuboid)
44template <
typename T,
typename W>
49 _cuboid.getFloorLatticeR(latticeR, physC);
51 auto& block = _f.getBlockStructure();
52 auto padding = std::min(1, block.getPadding());
55 const int& locX = latticeR[0];
56 const int& locY = latticeR[1];
60 _cuboid.getPhysR(physRiC.
data(), {locX, locY});
63 Vector<W,2> d = (physCv - physRiC) * (1. / _cuboid.getDeltaR());
66 T output_tmp[_f.getTargetDim()];
67 for (
int iD = 0; iD < _f.getTargetDim(); ++iD) {
73 _f(output_tmp,latticeC);
74 for (
int iD = 0; iD < _f.getTargetDim(); ++iD) {
75 output[iD] += output_tmp[iD] * e[0] * e[1];
80 latticeC[1] = locY + 1;
81 _f(output_tmp,latticeC);
82 for (
int iD = 0; iD < _f.getTargetDim(); ++iD) {
83 output[iD] += output_tmp[iD] * e[0] * d[1];
87 latticeC[0] = locX + 1;
89 _f(output_tmp,latticeC);
90 for (
int iD = 0; iD < _f.getTargetDim(); ++iD) {
91 output[iD] += output_tmp[iD] * d[0] * e[1];
95 latticeC[0] = locX + 1;
96 latticeC[1] = locY + 1;
97 _f(output_tmp,latticeC);
98 for (
int iD = 0; iD < _f.getTargetDim(); ++iD) {
99 output[iD] += output_tmp[iD] * d[0] * d[1];
100 output_tmp[iD] = T();
110template <
typename T,
typename W>
112 bool communicateToAll,
bool communicateOverlap)
114 _communicateToAll(communicateToAll),
115 _communicateOverlap(communicateOverlap),
117 _cuboidGeometry(_f.getSuperStructure().getCuboidGeometry())
119 this->
getName() =
"fromSuperF";
122 for (
int iC = 0; iC < load.
size(); ++iC) {
130template <
typename T,
typename W>
133 for (
int iD = 0; iD < _f.getTargetDim(); ++iD) {
138 if (!_cuboidGeometry.getLatticeR(latticeR, physC)) {
142 if (_communicateOverlap) {
143 _f.getSuperStructure().communicate();
150 for (
int iC = 0; iC < load.
size(); ++iC) {
151 if (_blockF[iC]->
operator()(output, physC)) {
152 dataSize += _f.getTargetDim();
157 if (_communicateToAll) {
158#ifdef PARALLEL_MODE_MPI
162 dataSize /= dataFound;
163#ifdef PARALLEL_MODE_MPI
164 for (
int iD = 0; iD < dataSize; ++iD) {
168 for (
int iD = 0; iD < dataSize; ++iD) {
169 output[iD]/=dataFound;
174 dataSize /= dataFound;
175 for (
int iD = 0; iD < dataSize; ++iD) {
176 output[iD]/=dataFound;
187template <
typename T,
typename W>
191 "it is safe to cast std::size_t to int");
192 return _blockF.size();
195template <
typename T,
typename W>
198 OLB_ASSERT(
size_t(iCloc) < _blockF.size() && iCloc >= 0,
199 "block functor index within bounds");
200 return *(_blockF[iCloc]);
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Converts block functors to analytical functors.
bool operator()(W output[], const T physC[]) override
AnalyticalFfromBlockF2D(BlockF2D< W > &f, Cuboid2D< T > &cuboid)
CuboidGeometry2D< T > & _cuboidGeometry
AnalyticalFfromSuperF2D(SuperF2D< T > &f, bool communicateToAll=false, bool communicateOverlap=true)
AnalyticalFfromBlockF2D< T, W > & getBlockF(int iCloc)
std::vector< std::unique_ptr< AnalyticalFfromBlockF2D< T, W > > > _blockF
int getBlockFSize() const
bool operator()(T output[], const T physC[]) override
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
A regular single 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
std::string & getName()
read and write access to name
Base class for all LoadBalancer.
represents all functors that operate on a SuperStructure<T,2> in general
constexpr const T * data() const any_platform
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
Top level namespace for all of OpenLB.
#define OLB_ASSERT(COND, MESSAGE)
The description of a 2D super lattice – header file.