OpenLB 1.7
Loading...
Searching...
No Matches
blockLattice.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2006-2008 Jonas Latt
4 * 2008-2021 Mathias Krause
5 * 2022 Adrian Kummerlaender
6 * E-mail contact: info@openlb.net
7 * The most recent release of OpenLB can be downloaded at
8 * <http://www.openlb.net/>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24*/
25
26#ifndef BLOCK_LATTICE_H
27#define BLOCK_LATTICE_H
28
29
30#include "utilities/aliases.h"
31
32#include "core/cell.h"
33#include "core/stages.h"
34
35#include "postProcessing.h"
36#include "latticeStatistics.h"
37#include "serializer.h"
38
40
42
43#include "data.h"
44#include "fieldArrayD.h"
45
46#include "platform/cpu/sisd.h"
47
48#ifdef PLATFORM_CPU_SIMD
49#include "platform/cpu/simd.h"
50#endif
51
52#ifdef PLATFORM_GPU_CUDA
53#include "platform/gpu/cuda.h"
54#endif
55
56#include "blockDynamicsMap.h"
58
60
61#include <memory>
62#include <vector>
63#include <map>
64#include <functional>
65
66namespace olb {
67
68
69template<typename T, typename DESCRIPTOR> class SuperLattice;
70template<typename T, typename DESCRIPTOR> struct Dynamics;
71template<typename T, typename DESCRIPTOR, Platform PLATFORM> class ConcreteBlockLattice;
72
74template<typename T, typename DESCRIPTOR>
83
85template<typename T, typename DESCRIPTOR>
86class BlockLattice : public BlockStructure<DESCRIPTOR>
87 , public Serializable {
88protected:
90
93
94public:
95 BlockLattice(Vector<int,DESCRIPTOR::d> size, int padding, Platform platform);
96 virtual ~BlockLattice();
97
99 virtual void collide() = 0;
101 virtual void stream() = 0;
102
104
109
111
115
118 return _platform;
119 }
120
122 template<typename FIELD_TYPE>
123 bool hasData()
124 {
125 return callUsingConcretePlatform<ConcretizableBlockLattice<T,DESCRIPTOR>>(
126 _platform,
127 this,
128 [&](const auto* lattice) -> bool {
129 return lattice->template hasData<FIELD_TYPE>();
130 });
131 }
133 template<typename FIELD_TYPE>
134 const auto& getData(FIELD_TYPE field = FIELD_TYPE{}) const
135 {
136 return *callUsingConcretePlatform<ConcretizableBlockLattice<T,DESCRIPTOR>>(
137 _platform,
138 this,
139 [&](const auto* lattice) -> const auto* {
140 return &(lattice->template getData<FIELD_TYPE>().asAbstract());
141 });
142 }
143
145 template<typename FIELD_TYPE>
146 auto& getData(FIELD_TYPE field = FIELD_TYPE{})
147 {
148 return *callUsingConcretePlatform<ConcretizableBlockLattice<T,DESCRIPTOR>>(
149 _platform,
150 this,
151 [&](auto* lattice) -> auto* {
152 return &(lattice->template getData<FIELD_TYPE>().asAbstract());
153 });
154 }
155
157 template<typename FIELD>
158 const auto& getField(FIELD field = FIELD{}) const
159 {
160 return getData(Array<FIELD>{});
161 }
162
164 template<typename FIELD>
165 auto& getField(FIELD field = FIELD{})
166 {
167 return getData(Array<FIELD>{});
168 }
169
172 {
173 return Cell<T,DESCRIPTOR>(*this, iCell);
174 }
177 {
178 return ConstCell<T,DESCRIPTOR>(*this, iCell);
179 }
180
183 {
184 return get(this->getCellId(loc));
185 }
188 {
189 return get(this->getCellId(loc));
190 }
191
193 template <typename... R>
194 std::enable_if_t<sizeof...(R) == DESCRIPTOR::d, Cell<T,DESCRIPTOR>>
195 get(R... latticeR)
196 {
197 return get(this->getCellId(latticeR...));
198 }
200 template <typename... R>
201 std::enable_if_t<sizeof...(R) == DESCRIPTOR::d, ConstCell<T,DESCRIPTOR>>
202 get(R... latticeR) const
203 {
204 return get(this->getCellId(latticeR...));
205 }
206
208 void initialize();
209
210 bool statisticsEnabled() const {
211 return _statisticsEnabled;
212 }
213 void setStatisticsEnabled(bool state) {
214 _statisticsEnabled = state;
215 }
216
219 // Legacy dynamics setter, to be deprecated
220 virtual void setDynamics(CellID iCell, Dynamics<T,DESCRIPTOR>*) = 0;
221
225 template<typename DYNAMICS>
229
233 template <typename... R>
234 std::enable_if_t<sizeof...(R) == DESCRIPTOR::d, Dynamics<T,DESCRIPTOR>*>
235 getDynamics(R... latticeR)
236 {
237 return getDynamics(this->getCellId(latticeR...));
238 }
239
243 {
244 setDynamics(this->getCellId(latticeR),
245 std::forward<DynamicsPromise<T,DESCRIPTOR>&&>(promise));
246 }
248 template <template<typename,typename> typename DYNAMICS>
250 {
251 setDynamics(this->getCellId(latticeR),
252 DynamicsPromise(meta::id<DYNAMICS<T,DESCRIPTOR>>{}));
253 }
256 Dynamics<T,DESCRIPTOR>* dynamics)
257 {
258 setDynamics(this->getCellId(latticeR), dynamics);
259 }
260
263 Dynamics<T,DESCRIPTOR>* dynamics);
265 template <typename DYNAMICS>
269
271
278 template <typename FIELD>
280 callUsingConcretePlatform<ConcretizableBlockLattice<T,DESCRIPTOR>>(
281 _platform,
282 this,
283 [&](auto* lattice) {
284 lattice->template setParameter<FIELD>(value);
285 });
286 }
287
288 template <typename PARAMETER, typename FIELD>
290 callUsingConcretePlatform<ConcretizableBlockLattice<T,DESCRIPTOR>>(
291 _platform,
292 this,
293 [&](auto* lattice) {
294 lattice->template setParameter<PARAMETER>(fieldArray);
295 });
296 }
297 template <typename PARAMETER, Platform PLATFORM, typename FIELD>
299 callUsingConcretePlatform<ConcretizableBlockLattice<T,DESCRIPTOR>>(
300 _platform,
301 this,
302 [&](auto* lattice) {
303 lattice->template setParameter<PARAMETER>(fieldArray);
304 });
305 }
306
308 virtual bool hasPostProcessor(std::type_index stage,
311 virtual void addPostProcessor(std::type_index stage,
315 virtual void addPostProcessor(std::type_index stage,
318 virtual void addPostProcessor(std::type_index stage,
321
323 virtual void addPostProcessor(std::type_index stage, PostProcessor<T,DESCRIPTOR>* postProcessor) = 0;
325 virtual void addPostProcessor(std::type_index stage, const PostProcessorGenerator<T,DESCRIPTOR>& ppGen) = 0;
327 virtual void addPostProcessor(std::type_index stage,
329 const PostProcessorGenerator<T,DESCRIPTOR>& ppGen) = 0;
330
332 template <typename STAGE=stage::PostStream>
334 addPostProcessor(typeid(STAGE), postProcessor);
335 }
337 template <typename STAGE=stage::PostStream>
339 addPostProcessor(typeid(STAGE), ppGen);
340 }
342 template <typename STAGE=stage::PostStream>
345 addPostProcessor(typeid(STAGE), indicator, ppGen);
346 }
347
349 virtual void postProcess(std::type_index stage = typeid(stage::PostStream)) = 0;
351 template <typename STAGE>
352 void postProcess() {
353 postProcess(typeid(STAGE));
354 }
355
356 virtual bool hasCommunicatable(std::type_index) const = 0;
357 virtual Communicatable& getCommunicatable(std::type_index) = 0;
358
360
364 template <typename FIELD>
368
372 template <typename FIELD>
376
379 template <typename FIELD>
381 IndicatorF<T,DESCRIPTOR::d>& indicatorF,
383
384
386
392
394
400
402
409
411
423
425
434
436
444 void stripeOffDensityOffset(T offset);
445
448 std::vector<BlockStructureD<DESCRIPTOR::d>*> partners);
451 std::vector<BlockStructureD<DESCRIPTOR::d>*> partners);
453 void executeCoupling();
454
458 LatticeStatistics<T> const& getStatistics() const;
459
460};
461
463template<typename T, typename DESCRIPTOR, Platform PLATFORM=Platform::CPU_SISD>
464class ConcreteBlockLattice final : public BlockLattice<T,DESCRIPTOR> {
465private:
471 std::map<std::type_index, std::unique_ptr<Communicatable>> _communicatables;
475 std::optional<std::function<void(ConcreteBlockLattice&)>> _customCollisionO;
477 std::map<std::type_index,
478 std::map<int,
480 std::less<int>>
481 > _postProcessors;
482
483public:
484 using value_t = T;
485 using descriptor_t = DESCRIPTOR;
486
487#ifdef PLATFORM_CPU_SIMD
488 static_assert(PLATFORM != Platform::CPU_SIMD || std::is_same_v<T,double> || std::is_same_v<T,float>,
489 "SIMD blocks must use either single or double precision as fundamental type");
490#endif
491
492 static constexpr Platform platform = PLATFORM;
493
494 static_assert(DESCRIPTOR::template provides<descriptors::POPULATION>(),
495 "Lattice DESCRIPTOR must provide POPULATION field");
496
498
500 _data.setProcessingContext(context);
501 }
502
503 template<typename FIELD_TYPE>
504 bool hasData() const;
505 template<typename FIELD_TYPE>
506 const auto& getData() const;
507 template<typename FIELD_TYPE>
508 auto& getData();
509
510 template<typename FIELD>
511 const auto& getField(FIELD field = FIELD()) const;
512 template<typename FIELD>
513 auto& getField(FIELD field = FIELD());
514
515 bool hasCommunicatable(std::type_index field) const override {
516 return _communicatables.find(field) != _communicatables.end();
517 }
518 Communicatable& getCommunicatable(std::type_index field) override {
519 return *_communicatables.at(field).get();
520 }
521
523 void collide() override;
525
533 void stream() override;
534
536
541 void setCollisionO(std::function<void(ConcreteBlockLattice&)>&& op) {
542 _customCollisionO = op;
543 }
544
546 return _dynamicsMap;
547 }
548
550 return _dynamicsMap.get(std::forward<decltype(promise)>(promise));
551 }
552
555 {
556 return _dynamicsMap.get(iCell);
557 }
558
559 void setDynamics(CellID iCell, DynamicsPromise<T,DESCRIPTOR>&& promise) override
560 {
561 _dynamicsMap.set(iCell, std::forward<decltype(promise)>(promise));
562 auto cell = this->get(iCell);
563 getDynamics(iCell)->initialize(cell);
564 }
565 void setDynamics(CellID iCell, Dynamics<T,DESCRIPTOR>* dynamics) override
566 {
567 _dynamicsMap.set(iCell, dynamics);
568 }
569
570 template <typename FIELD>
572 {
573 _data.template forEachCastable<AbstractedConcreteParameters<T,DESCRIPTOR>>([&](auto* parameters) {
574 auto& params = parameters->asAbstract();
575 if (params.template provides<FIELD>()) {
576 params.template set<FIELD>(value);
577 parameters->setProcessingContext(ProcessingContext::Simulation);
578 }
579 });
580 }
581
582 template <typename PARAMETER, Platform _PLATFORM, typename FIELD>
584 {
585 if constexpr (PLATFORM == Platform::GPU_CUDA) {
586 static_assert(PLATFORM == _PLATFORM, "FieldArrayD must be available on PLATFORM");
587 }
588 FieldD<T,DESCRIPTOR,PARAMETER> fieldArrayPointers;
589 for (unsigned iD=0; iD < fieldArray.d; ++iD) {
590 if constexpr (PLATFORM == Platform::GPU_CUDA) {
591 fieldArrayPointers[iD] = fieldArray[iD].deviceData();
592 } else {
593 fieldArrayPointers[iD] = fieldArray[iD].data();
594 }
595 }
596 setParameter<PARAMETER>(std::move(fieldArrayPointers));
597 }
598
599 template <typename PARAMETER, typename FIELD>
601 {
602 auto& fieldArray = dynamic_cast<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>&>(abstractFieldArray);
603 setParameter<PARAMETER>(fieldArray);
604 }
605
606 bool hasPostProcessor(std::type_index stage,
607 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
608 {
609 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
610 return std::get<1>(*postProcessorsOfPriority).contains(
611 std::forward<decltype(promise)>(promise));
612 }
613
614 void addPostProcessor(std::type_index stage,
616 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
617 {
618 if (!this->isPadding(latticeR)) {
619 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
620 std::get<1>(*postProcessorsOfPriority).add(this->getCellId(latticeR),
621 std::forward<decltype(promise)>(promise));
622 }
623 }
624
625 void addPostProcessor(std::type_index stage,
627 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
628 {
630 if (indicator(loc)) {
631 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
632 }
633 });
634 }
635
636 void addPostProcessor(std::type_index stage,
637 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
638 {
639 if (promise.scope() == OperatorScope::PerBlock) {
640 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
641 std::get<1>(*postProcessorsOfPriority).add(std::forward<decltype(promise)>(promise));
642 } else {
644 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
645 });
646 }
647 }
648
649 void addPostProcessor(std::type_index stage, PostProcessor<T,DESCRIPTOR>* postProcessor) override;
650 void addPostProcessor(std::type_index stage, const PostProcessorGenerator<T,DESCRIPTOR>& ppGen) override;
651 void addPostProcessor(std::type_index stage,
653 const PostProcessorGenerator<T,DESCRIPTOR>& ppGen) override;
654
656 void postProcess(std::type_index stage) override;
657
659
663 auto& pops = getField<descriptors::POPULATION>();
664 return Vector<T*,DESCRIPTOR::q>([&](unsigned iPop) -> T* {
665 return &pops[iPop][iCell];
666 });
667 }
668
670
674 return _data.getRegistry();
675 }
676
678 std::size_t getNblock() const override;
680 std::size_t getSerializableSize() const override;
682 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
684 void postLoad() override;
685
686
687};
688
689
691
694template <typename T, typename DESCRIPTOR, Platform SOURCE, Platform TARGET>
696
697template <typename T, typename DESCRIPTOR, Platform PLATFORM>
699 final : public BlockCommunicator {
700private:
701 const int _iC;
702#ifdef PARALLEL_MODE_MPI
703 MPI_Comm _mpiCommunicator;
704#endif
705
706#ifdef PARALLEL_MODE_MPI
707 class SendTask;
708 class RecvTask;
709
710 std::vector<std::unique_ptr<SendTask>> _sendTasks;
711 std::vector<std::unique_ptr<RecvTask>> _recvTasks;
712#endif
713
714public:
715 struct CopyTask;
716
718 LoadBalancer<T>& loadBalancer,
719#ifdef PARALLEL_MODE_MPI
721 MPI_Comm comm,
722#endif
723 int iC,
726
727#ifdef PARALLEL_MODE_MPI
728 void receive() override;
729 void send() override;
730 void unpack() override;
731 void wait() override;
732#else
733 void copy() override;
734#endif
735
736private:
737 class HomogeneousCopyTask;
738
739 std::vector<std::unique_ptr<CopyTask>> _copyTasks;
740
741};
742
743
744}
745
746#endif
Representation of the 2D block geometry view – header file.
Definition of a LB cell – header file.
Platform-agnostic interface to concrete host-side field arrays.
Definition fieldArrayD.h:50
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Configurable overlap communication neighborhood of a block.
Map between cell indices and concrete dynamics.
Dynamics< T, DESCRIPTOR > * get(DynamicsPromise< T, DESCRIPTOR > &&promise)
Returns a pointer to dynamics matching the promise.
Representation of a block geometry.
Platform-abstracted block lattice for external access and inter-block interaction.
virtual void addPostProcessor(std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Schedule post processor for application to latticeR in stage.
void addPostProcessor(PostProcessor< T, DESCRIPTOR > *postProcessor)
Schedule legacy post processor for application in STAGE.
ConstCell< T, DESCRIPTOR > get(LatticeR< DESCRIPTOR::d > loc) const
Get ConstCell interface for location loc.
LatticeStatistics< T > * _statistics
void addLatticeCoupling(LatticeCouplingGenerator< T, DESCRIPTOR > const &lcGen, std::vector< BlockStructureD< DESCRIPTOR::d > * > partners)
Add a non-local post-processing step (legacy)
void defineDynamics(LatticeR< DESCRIPTOR::d > latticeR, Dynamics< T, DESCRIPTOR > *dynamics)
Assign dynamics to latticeR via pointer (legacy)
void setParameter(AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &fieldArray)
void iniEquilibrium(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho, AnalyticalF< DESCRIPTOR::d, T, T > &u)
Initialize by equilibrium on a domain described by an indicator.
void setParameter(FieldD< T, DESCRIPTOR, FIELD > value)
Set value of parameter FIELD for any dynamics that provide it.
BlockLattice(Vector< int, DESCRIPTOR::d > size, int padding, Platform platform)
virtual Dynamics< T, DESCRIPTOR > * getDynamics(DynamicsPromise< T, DESCRIPTOR > &&)=0
Return pointer to dynamics yielded by promise.
void defineRho(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho)
Define rho on a domain described by an indicator.
virtual void addPostProcessor(std::type_index stage, PostProcessor< T, DESCRIPTOR > *postProcessor)=0
Schedule legacy post processor for application in stage.
const Platform _platform
virtual void setProcessingContext(ProcessingContext)=0
Set processing context.
void defineRhoU(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho, AnalyticalF< DESCRIPTOR::d, T, T > &u)
Define rho and u on a domain described by an indicator.
virtual void addPostProcessor(std::type_index stage, BlockIndicatorF< T, DESCRIPTOR::d > &indicator, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Schedule post processor for application to indicated cells in stage.
Platform getPlatform() const
Return platform used to process lattice.
void setParameter(FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > &fieldArray)
virtual bool hasPostProcessor(std::type_index stage, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Returns true if stage contains post processor.
void postProcess()
Execute post processors of STAGE.
virtual void addPostProcessor(std::type_index stage, const PostProcessorGenerator< T, DESCRIPTOR > &ppGen)=0
Schedule legacy post processor in stage.
auto & getField(FIELD field=FIELD{})
Return abstract interface for FIELD array.
void defineU(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &u)
Define u on a domain described by an indicator.
const auto & getData(FIELD_TYPE field=FIELD_TYPE{}) const
Return abstract interface for concrete FIELD_TYPE data.
void iniRegularized(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho, AnalyticalF< DESCRIPTOR::d, T, T > &u, AnalyticalF< DESCRIPTOR::d, T, T > &pi)
Initialize by non- and equilibrium on a domain described by an indicator.
virtual void collide()=0
Execute the collide step on the non-overlapping block cells.
virtual Communicatable & getCommunicatable(std::type_index)=0
void defineDynamics(LatticeR< DESCRIPTOR::d > latticeR, DynamicsPromise< T, DESCRIPTOR > &&promise)
Assign promised DYNAMICS to latticeR.
void defineField(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &field)
Define a field on a domain described by an indicator.
virtual ~BlockLattice()
virtual void setDynamics(CellID iCell, Dynamics< T, DESCRIPTOR > *)=0
bool statisticsEnabled() const
std::enable_if_t< sizeof...(R)==DESCRIPTOR::d, Cell< T, DESCRIPTOR > > get(R... latticeR)
Get Cell interface for componentwise location latticeR.
void stripeOffDensityOffset(T offset)
Subtract the given offset from all densities.
void initialize()
Initialize the lattice cells to become ready for simulation.
virtual void addPostProcessor(std::type_index stage, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Schedule post processor for application to entire block in stage.
void executeCoupling()
Execute couplings steps (legacy)
void setStatisticsEnabled(bool state)
bool hasData()
Return whether FIELD_TYPE is available / has been allocated.
const auto & getField(FIELD field=FIELD{}) const
Return abstract interface for FIELD array.
virtual void setDynamics(CellID iCell, DynamicsPromise< T, DESCRIPTOR > &&)=0
Set dynamics at iCell to promised dynamics.
Cell< T, DESCRIPTOR > get(LatticeR< DESCRIPTOR::d > loc)
Get Cell interface for location loc.
virtual bool hasCommunicatable(std::type_index) const =0
void defineDynamics(LatticeR< DESCRIPTOR::d > latticeR)
Assign DYNAMICS to latticeR.
Dynamics< T, DESCRIPTOR > * getDynamics()
Return pointer to DYNAMICS (legacy)
virtual void stream()=0
Apply the streaming step to the entire block.
void definePopulations(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &Pop)
Define a population on a domain described by an indicator.
std::enable_if_t< sizeof...(R)==DESCRIPTOR::d, ConstCell< T, DESCRIPTOR > > get(R... latticeR) const
Get ConstCell interface for componentwise location latticeR.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
void addPostProcessor(BlockIndicatorF< T, DESCRIPTOR::d > &indicator, const PostProcessorGenerator< T, DESCRIPTOR > &ppGen)
Schedule legacy post processor for application to indicated cells in STAGE.
LatticeStatistics< T > & getStatistics()
Return a handle to the LatticeStatistics object.
void addPostProcessor(const PostProcessorGenerator< T, DESCRIPTOR > &ppGen)
Schedule legacy post processor for application in STAGE.
virtual Dynamics< T, DESCRIPTOR > * getDynamics(CellID iCell)=0
Return pointer to dynamics at iCell.
std::enable_if_t< sizeof...(R)==DESCRIPTOR::d, Dynamics< T, DESCRIPTOR > * > getDynamics(R... latticeR)
Return pointer to dynamics assigned to latticeR.
virtual void postProcess(std::type_index stage=typeid(stage::PostStream))=0
Execute post processors of stage.
ConstCell< T, DESCRIPTOR > get(CellID iCell) const
Get ConstCell interface for index iCell.
auto & getData(FIELD_TYPE field=FIELD_TYPE{})
Return abstract interface for concrete FIELD_TYPE data.
virtual void addPostProcessor(std::type_index stage, BlockIndicatorF< T, DESCRIPTOR::d > &indicator, const PostProcessorGenerator< T, DESCRIPTOR > &ppGen)=0
Schedule legacy post processor for application to indicated cells in stage.
virtual Vector< T *, DESCRIPTOR::q > getPopulationPointers(CellID iCell)=0
Returns pointers to host-side population locations of iCell.
Map of post processors of a single priority and stage.
Base of a regular block.
void forCoreSpatialLocations(F f) const
bool isPadding(LatticeR< D > latticeR) const
Return whether location is valid.
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
Highest-level interface to Cell data.
Definition cell.h:148
static constexpr unsigned d
const auto & getData() const
void collide() override
Apply collision step of non-overlap interior.
bool hasCommunicatable(std::type_index field) const override
bool hasPostProcessor(std::type_index stage, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
Returns true if stage contains post processor.
void postLoad() override
Reinit population structure after deserialization.
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Return a pointer to the memory of the current block and its size for the serializable interface.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
ConcreteBlockLattice(Vector< int, DESCRIPTOR::d > size, int padding=0)
void setDynamics(CellID iCell, Dynamics< T, DESCRIPTOR > *dynamics) override
auto & getDataRegistry()
Return reference to Data's FieldTypeRegistry.
void stream() override
Perform propagation step on the whole block.
BlockDynamicsMap< T, DESCRIPTOR, PLATFORM > & getDynamicsMap()
Vector< T *, DESCRIPTOR::q > getPopulationPointers(CellID iCell) override
Return pointers to population values of cell index iCell.
std::size_t getSerializableSize() const override
Binary size for the serializer.
void addPostProcessor(std::type_index stage, BlockIndicatorF< T, DESCRIPTOR::d > &indicator, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
Schedule post processor for application to indicated cells in stage.
void setParameter(AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &abstractFieldArray)
Dynamics< T, DESCRIPTOR > * getDynamics(CellID iCell) override
Get reference to dynamics of cell by index.
void setProcessingContext(ProcessingContext context) override
Set processing context.
void addPostProcessor(std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
Schedule post processor for application to latticeR in stage.
void addPostProcessor(std::type_index stage, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
Schedule post processor for application to entire block in stage.
void setDynamics(CellID iCell, DynamicsPromise< T, DESCRIPTOR > &&promise) override
Set dynamics at iCell to promised dynamics.
Communicatable & getCommunicatable(std::type_index field) override
static constexpr Platform platform
void setParameter(FieldArrayD< T, DESCRIPTOR, _PLATFORM, FIELD > &fieldArray)
const auto & getField(FIELD field=FIELD()) const
void setParameter(FieldD< T, DESCRIPTOR, FIELD > value)
void setCollisionO(std::function< void(ConcreteBlockLattice &)> &&op)
Replace default collision logic of BlockDynamicsMap.
Dynamics< T, DESCRIPTOR > * getDynamics(DynamicsPromise< T, DESCRIPTOR > &&promise) override
Return pointer to dynamics yielded by promise.
Highest-level interface to read-only Cell data.
Definition cell.h:53
Storage of any FIELD_TYPE data on PLATFORM.
Definition data.h:155
void setProcessingContext(ProcessingContext context)
Definition data.h:215
auto & getRegistry()
Expose FieldTypeRegistry for device-support.
Definition data.h:243
Factory for instances of a specific Dynamics type.
SoA storage for instances of a single FIELD.
Wrapper for a local heterogeneous block communication request.
Base class for all LoadBalancer.
Factory for instances of a specific POST_PROCESSOR type.
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
Definition serializer.h:145
Communication-free negotation of unique tags for inter-cuboid communication.
Super class maintaining block lattices for a cuboid decomposition.
Plain old scalar vector.
Definition vector.h:47
Interface for post-processing steps – header file.
Top level namespace for all of OpenLB.
std::uint32_t CellID
Type for sequential block-local cell indices.
ProcessingContext
OpenLB processing contexts.
Definition platform.h:55
@ Simulation
Data available on host for e.g. functor evaluation.
std::conditional_t< D==2, BlockF2D< T >, BlockF3D< T > > BlockF
Definition aliases.h:188
std::conditional_t< DESCRIPTOR::d==2, LatticeCouplingGenerator2D< T, DESCRIPTOR >, LatticeCouplingGenerator3D< T, DESCRIPTOR > > LatticeCouplingGenerator
Definition aliases.h:168
Platform
OpenLB execution targets.
Definition platform.h:36
@ CPU_SIMD
Basic scalar CPU.
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)
std::conditional_t< D==2, BlockIndicatorF2D< T >, BlockIndicatorF3D< T > > BlockIndicatorF
Definition aliases.h:218
std::conditional_t< D==2, IndicatorF2D< T >, IndicatorF3D< T > > IndicatorF
Definition aliases.h:258
DynamicsPromise(meta::id< DYNAMICS >) -> DynamicsPromise< typename DYNAMICS::value_t, typename DYNAMICS::descriptor_t >
std::conditional_t< DESCRIPTOR::d==2, PostProcessor2D< T, DESCRIPTOR >, PostProcessor3D< T, DESCRIPTOR > > PostProcessor
Definition aliases.h:67
@ PerBlock
Per-block application, i.e. OPERATOR::apply is passed a ConcreteBlockLattice.
std::conditional_t< DESCRIPTOR::d==2, PostProcessorGenerator2D< T, DESCRIPTOR >, PostProcessorGenerator3D< T, DESCRIPTOR > > PostProcessorGenerator
Definition aliases.h:77
Interface for post-processing steps – header file.
Describe FieldArray of a FIELD in Data.
Definition data.h:42
Generic communicator for the overlap neighborhood of a block.
Curried ConcreteBlockLattice template for use in callUsingConcretePlatform.
Interface for per-cell dynamics.
Definition interface.h:54
Identity type to pass non-constructible types as value.
Definition meta.h:79
Communication after propagation.
Definition stages.h:36