25#ifndef SUPER_PARTICLE_LATTICE_COUPLING_H
26#define SUPER_PARTICLE_LATTICE_COUPLING_H
36template <
typename COUPLER,
typename COUPLEES, Platform PLATFORM>
40 template <
typename VALUED_DESCRIPTOR>
41 using ptr_to_lattice = std::conditional_t<
42 VALUED_DESCRIPTOR::descriptor_t::template provides<descriptors::POPULATION>(),
44 typename VALUED_DESCRIPTOR::descriptor_t,
47 typename VALUED_DESCRIPTOR::descriptor_t,
60 typename COUPLER::parameters,
69 template <
typename LATTICES>
78 std::type_index
id()
const override {
79 return typeid(COUPLER);
91 const auto originR = _parameters.template get<fields::BLOCK_LOWER>();
92 const auto deltaX = _parameters.template get<fields::converter::PHYS_DELTA_X>();
93 #ifdef PARALLEL_MODE_OMP
94 #pragma omp parallel for schedule(static)
96 for (
CellID iP=0; iP < points->getNcells(); ++iP) {
97 const auto physR = points->template getField<fields::PHYS_R>().get(iP);
99 const CellID iCell = _lattices.template get<0>()->getCellId(latticeR);
100 auto cells = _lattices.exchange_values([&](
auto name) ->
auto {
101 if constexpr (std::is_same_v<
typename decltype(name)::type,
names::Points>) {
102 return cpu::Row{*_lattices.get(name), iP};
104 return cpu::Cell{*_lattices.get(name), iCell};
107 COUPLER().apply(cells, _parameters);
112 throw std::bad_function_call();
119template <
typename COUPLER,
typename COUPLEES>
122 template <
typename VALUED_DESCRIPTOR>
123 using ptr_to_lattice = std::conditional_t<
124 VALUED_DESCRIPTOR::descriptor_t::template provides<descriptors::POPULATION>(),
126 typename VALUED_DESCRIPTOR::descriptor_t>,
127 SuperD<
typename VALUED_DESCRIPTOR::value_t,
128 typename VALUED_DESCRIPTOR::descriptor_t>
135 std::vector<std::unique_ptr<AbstractCouplingO<COUPLEES>>> _block;
137 template <Platform PLATFORM>
138 auto constructConcreteBlockPointCoupling(
int iC)
141 using NAME =
typename decltype(name)::type;
142 using T =
typename COUPLEES::template value<NAME>::value_t;
143 using DESCRIPTOR =
typename COUPLEES::template value<NAME>::descriptor_t;
144 if constexpr (DESCRIPTOR::template provides<descriptors::POPULATION>()) {
146 &_lattices.get(name)->
getBlock(iC));
149 &_lattices.get(name)->
getBlock(iC));
152 return std::make_unique<ConcreteBlockPointCouplingO<COUPLEES,PLATFORM,COUPLER,COUPLER::scope>>(
154 _lattices.template get<0>()->getCuboidDecomposition().get(
155 _lattices.template get<0>()->getLoadBalancer().glob(iC)));
159 template <
typename... MAP>
162 auto map = std::make_tuple(&args...);
163 COUPLEES::keys_t::for_each([&](
auto id) {
164 using name_t =
typename decltype(id)::type;
165 constexpr unsigned idx = COUPLEES::keys_t::template index<name_t>();
166 _lattices.template set<name_t>(std::get<2*idx+1>(map));
169 auto& load = _lattices.template get<0>()->getLoadBalancer();
170 auto& cGeometry = _lattices.template get<0>()->getCuboidDecomposition();
172 for (
int iC = 0; iC < load.size(); ++iC) {
173 Platform reference = _lattices.template get<0>()->getBlock(iC).getPlatform();
175 _lattices.for_each([&](
auto name,
auto lattice) {
176 if (lattice->getBlock(iC).getPlatform() != reference) {
177 throw std::runtime_error(
"Platforms of coupled block lattices must match");
183 _block.emplace_back(constructConcreteBlockPointCoupling<platform.value>(iC));
187 for (
int iC = 0; iC < load.size(); ++iC) {
188 const auto origin = cGeometry.get(load.glob(iC)).getOrigin();
189 const auto deltaX = cGeometry.get(load.glob(iC)).getDeltaR();
190 _block[iC]->getParameters().template set<fields::BLOCK_LOWER>(origin);
191 _block[iC]->getParameters().template set<fields::converter::PHYS_DELTA_X>(deltaX);
198 auto& load = _lattices.template get<0>()->getLoadBalancer();
199 #ifdef PARALLEL_MODE_OMP
202 for (
int iC = 0; iC < load.size(); ++iC) {
203 _block[iC]->execute();
208 template <
typename FIELD>
211 auto& load = _lattices.template get<0>()->getLoadBalancer();
212 for (
int iC = 0; iC < load.size(); ++iC) {
213 _block[iC]->getParameters().template set<FIELD>(std::forward<
decltype(field)>(field));
231template <
typename COUPLER,
typename... MAP>
235 typename meta::map<MAP...>::template map_values<descriptors::extract_valued_descriptor_t>
Implementation of BlockD on a concrete PLATFORM.
Implementation of BlockLattice on a concrete PLATFORM.
Particle coupling of COUPLEES using concrete OPERATOR with SCOPE on PLATFORM lattices.
Coupling operator COUPLER on named COUPLEES.
AbstractCouplingO< COUPLEES > & getBlock(int iC)
Return block-level abstract coupling operator.
SuperLatticePointCoupling(COUPLER, MAP &&... args)
void execute()
Execute coupling operation on all blocks.
void setParameter(typename AbstractCouplingO< COUPLEES >::template FieldD< FIELD > &&field)
Set coupling parameter FIELD.
Super class maintaining block lattices for a cuboid decomposition.
Cell concept for concrete block lattices on CPU platforms.
Row concept for concrete non-LBM lattices on CPU platforms.
ADf< T, DIM > floor(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
auto callUsingConcretePlatform(Platform platform, typename CONCRETIZABLE::base_t *ptr, F f)
Dispatcher for concrete platform access.
std::uint32_t CellID
Type for sequential block-local cell indices.
Platform
OpenLB execution targets.
SuperLatticePointCoupling(COUPLER, MAP &&...) -> SuperLatticePointCoupling< COUPLER, typename meta::map< MAP... >::template map_values< descriptors::extract_valued_descriptor_t > >
SuperPointLatticeCoupling.
OperatorScope
Block-wide operator application scopes.
@ PerCellWithParameters
Per-cell application with parameters, i.e. OPERATOR::apply is passed a CELL concept implementation an...
Base of block-wide coupling operators executed by SuperLatticeCoupling.
typename COUPLEES::values_t::template get< 0 >::descriptor_t descriptor_t
Descriptor type used for coupling parameters.
typename COUPLEES::values_t::template get< 0 >::value_t value_t
Value type used for coupling parameters.
Dynamic access interface for FIELD-valued parameters.
Mapping between KEYs and instances of type VALUEs.
constexpr auto exchange_values(F f) any_platform
Returns new TypeIndexedTuple with same keys but values generated by f(key)