OpenLB 1.8.1
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 "fieldArrayD.h"
44
45#include "platform/cpu/sisd.h"
46
47#ifdef PLATFORM_CPU_SIMD
48#include "platform/cpu/simd.h"
49#endif
50
51#ifdef PLATFORM_GPU_CUDA
52#include "platform/gpu/cuda.h"
53#endif
54
55#include "blockDynamicsMap.h"
57
59
60#include <memory>
61#include <vector>
62#include <map>
63#include <functional>
64
65namespace olb {
66
67
68template<typename T, typename DESCRIPTOR> class SuperLattice;
69template<typename T, typename DESCRIPTOR> struct Dynamics;
70template<typename T, typename DESCRIPTOR, Platform PLATFORM> class ConcreteBlockLattice;
71
73template<typename T, typename DESCRIPTOR>
75
76using value_t = T;
77
79
80template <Platform PLATFORM>
82
83};
84
85template<typename T, typename DESCRIPTOR> class BlockLattice { };
86
88template<concepts::BaseType T, typename DESCRIPTOR>
89requires (!concepts::LatticeDescriptor<DESCRIPTOR>)
90class BlockLattice<T,DESCRIPTOR> { };
91
93template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
94class BlockLattice<T,DESCRIPTOR> : public BlockStructure<DESCRIPTOR>
95 , public Serializable {
96protected:
99
103
105
109
110public:
111 BlockLattice(Vector<int,DESCRIPTOR::d> size, int padding, Platform platform);
112 virtual ~BlockLattice();
113
115 virtual void collide() = 0;
117 virtual void stream() = 0;
118
120
125
127
131
134 return _platform;
135 }
136
137 template <Platform PLATFORM>
139 if (auto* ptr = dynamic_cast<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>*>(this)) [[likely]] {
140 return *ptr;
141 } else {
142 throw std::runtime_error("Invalid PLATFORM");
143 }
144 }
145
147 template<typename FIELD_TYPE>
148 bool hasData()
149 {
151 _platform,
152 this,
153 [&](const auto* lattice) -> bool {
154 return lattice->template hasData<FIELD_TYPE>();
155 });
156 }
158 template<typename FIELD_TYPE>
159 const auto& getData(FIELD_TYPE field = FIELD_TYPE{}) const
160 {
162 _platform,
163 this,
164 [&](const auto* lattice) -> const auto* {
165 return &(lattice->template getData<FIELD_TYPE>().asAbstract());
166 });
167 }
168
170 template<typename FIELD_TYPE>
171 auto& getData(FIELD_TYPE field = FIELD_TYPE{})
172 {
174 _platform,
175 this,
176 [&](auto* lattice) -> auto* {
177 return &(lattice->template getData<FIELD_TYPE>().asAbstract());
178 });
179 }
180
182 template<typename FIELD>
183 const auto& getField(FIELD field = FIELD{}) const
184 {
185 return getData(Array<FIELD>{});
186 }
187
189 template<typename FIELD>
190 auto& getField(FIELD field = FIELD{})
191 {
192 return getData(Array<FIELD>{});
193 }
194
197 {
198 return Cell<T,DESCRIPTOR>(*this, iCell);
199 }
202 {
203 return ConstCell<T,DESCRIPTOR>(*this, iCell);
204 }
205
208 {
209 return get(this->getCellId(loc));
210 }
213 {
214 return get(this->getCellId(loc));
215 }
216
218 template <typename... R>
219 std::enable_if_t<sizeof...(R) == DESCRIPTOR::d, Cell<T,DESCRIPTOR>>
220 get(R... latticeR)
221 {
222 return get(this->getCellId(latticeR...));
223 }
225 template <typename... R>
226 std::enable_if_t<sizeof...(R) == DESCRIPTOR::d, ConstCell<T,DESCRIPTOR>>
227 get(R... latticeR) const
228 {
229 return get(this->getCellId(latticeR...));
230 }
231
233 void initialize();
234
235 bool statisticsEnabled() const {
236 return _statisticsEnabled;
237 }
238 void setStatisticsEnabled(bool state) {
239 _statisticsEnabled = state;
240 }
241
242 bool isIntrospectable() const {
243 return _introspectable && !std::is_same_v<T,Expr>;
244 }
245 void setIntrospectability(bool state) {
246 _introspectable = state;
247 }
248
251
255 template <typename... R>
256 std::enable_if_t<sizeof...(R) == DESCRIPTOR::d, Dynamics<T,DESCRIPTOR>*>
257 getDynamics(R... latticeR)
258 {
259 return getDynamics(this->getCellId(latticeR...));
260 }
261
265 {
266 setDynamics(this->getCellId(latticeR),
267 std::forward<DynamicsPromise<T,DESCRIPTOR>&&>(promise));
268 }
270 template <template<typename...> typename DYNAMICS>
272 {
273 setDynamics(this->getCellId(latticeR),
274 DynamicsPromise(meta::id<DYNAMICS<T,DESCRIPTOR>>{}));
275 }
276
278 template <typename DYNAMICS>
279 void defineDynamics();
281 template <typename DYNAMICS>
282 void defineDynamics(BlockIndicatorF<T,DESCRIPTOR::d>& indicator);
284 void defineDynamics(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
286
288
295 template <typename FIELD>
298 _platform,
299 this,
300 [&](auto* lattice) {
301 lattice->template setParameter<FIELD>(value);
302 });
303 }
304
305 template <typename PARAMETER, typename _DESCRIPTOR, typename FIELD>
308 _platform,
309 this,
310 [&](auto* lattice) {
311 lattice->template setParameter<PARAMETER>(fieldArray);
312 });
313 }
314 template <typename PARAMETER, typename _DESCRIPTOR, Platform PLATFORM, typename FIELD>
317 _platform,
318 this,
319 [&](auto* lattice) {
320 lattice->template setParameter<PARAMETER>(fieldArray);
321 });
322 }
323
325 virtual bool hasPostProcessor(std::type_index stage,
328 virtual void addPostProcessor(std::type_index stage,
332 virtual void addPostProcessor(std::type_index stage,
335 virtual void addPostProcessor(std::type_index stage,
338
340 virtual void writeDescription(std::ostream&) const = 0;
342
345 virtual void writeDynamicsAsCSV(std::ostream&) const = 0;
347
350 virtual void writeOperatorAsCSV(std::ostream&) const = 0;
351
353 virtual void postProcess(std::type_index stage = typeid(stage::PostStream)) = 0;
355 template <typename STAGE>
356 void postProcess() {
357 postProcess(typeid(STAGE));
358 }
359
360 virtual bool hasCommunicatable(std::type_index) const = 0;
361 virtual Communicatable& getCommunicatable(std::type_index) = 0;
362
364
368 template <typename FIELD>
369 void defineField(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
372
376 template <typename FIELD>
377 void defineField(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
380
383 template <typename FIELD>
384 void defineField(BlockGeometry<T,DESCRIPTOR::d>& blockGeometry,
385 IndicatorF<T,DESCRIPTOR::d>& indicatorF,
387
388
390
394 void defineRho(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
396
398
402 void defineU(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
404
406
411 void defineRhoU(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
413
415
419 void definePopulations(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
425 void definePopulations(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
427
429
434 void iniEquilibrium(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
436 void iniEquilibrium(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
438
440
445 void iniRegularized(BlockIndicatorF<T,DESCRIPTOR::d>& indicator,
448 void stripeOffDensityOffset(T offset);
449
451 LatticeStatistics<T>& getStatistics();
453 LatticeStatistics<T> const& getStatistics() const;
454
455};
456
458template<typename T, typename DESCRIPTOR, Platform PLATFORM=Platform::CPU_SISD>
459class ConcreteBlockLattice final : public BlockLattice<T,DESCRIPTOR> {
460private:
466 std::map<std::type_index, std::unique_ptr<Communicatable>> _communicatables;
467
471 std::optional<std::function<void(ConcreteBlockLattice&)>> _customCollisionO;
473 std::map<std::type_index,
474 std::map<int,
476 std::less<int>>
477 > _postProcessors;
478
479public:
480 using value_t = T;
481 using descriptor_t = DESCRIPTOR;
482
483#ifdef PLATFORM_CPU_SIMD
484 static_assert(PLATFORM != Platform::CPU_SIMD || std::is_same_v<T,double> || std::is_same_v<T,float>,
485 "SIMD blocks must use either single or double precision as fundamental type");
486#endif
487
488 static constexpr Platform platform = PLATFORM;
489
490 static_assert(DESCRIPTOR::template provides<descriptors::POPULATION>(),
491 "Lattice DESCRIPTOR must provide POPULATION field");
492
494
496 _data.setProcessingContext(context);
497 }
498
500 return _data;
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
551 {
552 return _dynamicsMap.get(iCell);
553 }
554
555 void setDynamics(CellID iCell, DynamicsPromise<T,DESCRIPTOR>&& promise) override
556 {
557 _dynamicsMap.set(iCell, std::forward<decltype(promise)>(promise));
558 auto cell = this->get(iCell);
559 getDynamics(iCell)->initialize(cell);
560 }
561
562 template <typename FIELD>
564 {
565 _data.template forEachCastable<AbstractedConcreteParameters<T,DESCRIPTOR>>([&](auto* parameters) {
566 auto& params = parameters->asAbstract();
567 if (params.template provides<FIELD>()) {
568 params.template set<FIELD>(value);
569 parameters->setProcessingContext(ProcessingContext::Simulation);
570 }
571 });
572 }
573
574 template <typename PARAMETER, typename _DESCRIPTOR, Platform _PLATFORM, typename FIELD>
576 {
577 static_assert(DESCRIPTOR::template size<PARAMETER>() == DESCRIPTOR::template size<FIELD>(),
578 "PARAMETER field size must match FIELD size");
579 if constexpr (PLATFORM == Platform::GPU_CUDA) {
580 static_assert(PLATFORM == _PLATFORM, "FieldArrayD must be available on PLATFORM");
581 }
582 FieldD<T,DESCRIPTOR,PARAMETER> fieldArrayPointers;
583 for (unsigned iD=0; iD < fieldArray.d; ++iD) {
584 if constexpr (PLATFORM == Platform::GPU_CUDA) {
585 fieldArrayPointers[iD] = fieldArray[iD].deviceData();
586 } else {
587 fieldArrayPointers[iD] = fieldArray[iD].data();
588 }
589 }
590 setParameter<PARAMETER>(std::move(fieldArrayPointers));
591 }
592
593 template <typename PARAMETER, typename _DESCRIPTOR, typename FIELD>
595 {
596 if constexpr (PLATFORM == Platform::CPU_SIMD) {
597 switch (abstractFieldArray.getPlatform()) {
598 case Platform::CPU_SISD: {
599 auto& fieldArray = dynamic_cast<FieldArrayD<T,_DESCRIPTOR,Platform::CPU_SISD,FIELD>&>(abstractFieldArray);
600 setParameter<PARAMETER>(fieldArray);
601 break;
602 }
603 case Platform::CPU_SIMD: {
604 auto& fieldArray = dynamic_cast<FieldArrayD<T,_DESCRIPTOR,Platform::CPU_SIMD,FIELD>&>(abstractFieldArray);
605 setParameter<PARAMETER>(fieldArray);
606 break;
607 }
608 default:
609 throw std::bad_cast();
610 }
611 } else {
612 auto& fieldArray = dynamic_cast<FieldArrayD<T,_DESCRIPTOR,PLATFORM,FIELD>&>(abstractFieldArray);
613 setParameter<PARAMETER>(fieldArray);
614 }
615 }
616
617 bool hasPostProcessor(std::type_index stage,
618 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
619 {
620 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
621 return std::get<1>(*postProcessorsOfPriority).contains(
622 std::forward<decltype(promise)>(promise));
623 }
624
625 void addPostProcessor(std::type_index stage,
627 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
628 {
629 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
630 std::get<1>(*postProcessorsOfPriority).add(this->getCellId(latticeR),
631 std::forward<decltype(promise)>(promise));
632 }
633
634 void addPostProcessor(std::type_index stage,
636 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
637 {
638 if (promise.scope() == OperatorScope::PerBlock) {
639 if (!indicator.isEmpty()) {
640 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
641 std::get<1>(*postProcessorsOfPriority).add(std::forward<decltype(promise)>(promise));
642 }
643 } else {
645 if (indicator(loc)) {
646 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
647 }
648 });
649 }
650 }
651
652 void addPostProcessor(std::type_index stage,
653 PostProcessorPromise<T,DESCRIPTOR>&& promise) override
654 {
655 if (promise.scope() == OperatorScope::PerBlock) {
656 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
657 std::get<1>(*postProcessorsOfPriority).add(std::forward<decltype(promise)>(promise));
658 } else {
660 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
661 });
662 }
663 }
664
666 void postProcess(std::type_index stage) override;
667
669
674 return Vector<T*,DESCRIPTOR::q>([&](unsigned iPop) -> T* {
675 return &pops[iPop][iCell];
676 });
677 }
678
680
684 return _data.getRegistry();
685 }
686
687 void writeDescription(std::ostream& clout) const override;
688 void writeDynamicsAsCSV(std::ostream& clout) const override;
689 void writeOperatorAsCSV(std::ostream& clout) const override;
690
692 std::size_t getNblock() const override;
694 std::size_t getSerializableSize() const override;
696 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
698 void postLoad() override;
699
700
701};
702
704template <typename DESCRIPTOR>
705class ConcreteBlockLattice<Expr,DESCRIPTOR,Platform::CPU_SIMD>;
707template <typename DESCRIPTOR>
708class ConcreteBlockLattice<Expr,DESCRIPTOR,Platform::GPU_CUDA>;
709
711
714template <typename T, typename DESCRIPTOR, Platform SOURCE, Platform TARGET>
715class HeterogeneousCopyTask;
716
717template <typename T, typename DESCRIPTOR, Platform PLATFORM>
718class ConcreteBlockCommunicator<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>
719 final : public BlockCommunicator {
720private:
721 const int _iC;
722#ifdef PARALLEL_MODE_MPI
723 MPI_Comm _mpiCommunicator;
724#endif
725
726#ifdef PARALLEL_MODE_MPI
727 class SendTask;
728 class RecvTask;
729
730 std::vector<std::unique_ptr<SendTask>> _sendTasks;
731 std::vector<std::unique_ptr<RecvTask>> _recvTasks;
732#endif
733
734public:
735 struct CopyTask;
736
738 LoadBalancer<T>& loadBalancer,
739#ifdef PARALLEL_MODE_MPI
741 MPI_Comm comm,
742#endif
743 int iC,
746
747#ifdef PARALLEL_MODE_MPI
748 void receive() override;
749 void send() override;
750 void unpack() override;
751 void wait() override;
752#else
753 void copy() override;
754#endif
755
756private:
758
759 std::vector<std::unique_ptr<CopyTask>> _copyTasks;
760
761};
762
763
764}
765
766#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:49
virtual Platform getPlatform() const =0
Returns Platform of concrete FieldArrayD.
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.
void set(std::size_t iCell, DynamicsPromise< T, DESCRIPTOR > &&promise)
Assigns promised dynamics to cell index and updates block masks.
Dynamics< T, DESCRIPTOR > * get(DynamicsPromise< T, DESCRIPTOR > &&promise)
Returns a pointer to dynamics matching the promise.
Representation of a block geometry.
Stub to filter construction on non-lattice descriptors.
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.
ConstCell< T, DESCRIPTOR > get(LatticeR< DESCRIPTOR::d > loc) const
Get ConstCell interface for location loc.
LatticeStatistics< T > * _statistics
void setParameter(FieldD< T, DESCRIPTOR, FIELD > value)
Set value of parameter FIELD for any dynamics that provide it.
virtual void writeOperatorAsCSV(std::ostream &) const =0
Prints CSV-structured list of all used operators.
const Platform _platform
Platform used by the derived concrete lattice.
virtual void setProcessingContext(ProcessingContext)=0
Set processing context.
bool _statisticsEnabled
True if statistics are gathered during collide.
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.
bool _introspectable
True for lattice that can be introspected.
virtual void writeDescription(std::ostream &) const =0
Prints human-readable summary of all used dynamics and post processors.
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.
auto & getField(FIELD field=FIELD{})
Return abstract interface for FIELD array.
const auto & getData(FIELD_TYPE field=FIELD_TYPE{}) const
Return abstract interface for concrete FIELD_TYPE data.
virtual void collide()=0
Execute the collide step on the non-overlapping block cells.
virtual Communicatable & getCommunicatable(std::type_index)=0
ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > & asConcrete()
void defineDynamics(LatticeR< DESCRIPTOR::d > latticeR, DynamicsPromise< T, DESCRIPTOR > &&promise)
Assign promised DYNAMICS to latticeR.
std::enable_if_t< sizeof...(R)==DESCRIPTOR::d, Cell< T, DESCRIPTOR > > get(R... latticeR)
Get Cell interface for componentwise location latticeR.
virtual void addPostProcessor(std::type_index stage, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Schedule post processor for application to entire block in stage.
bool hasData()
Return whether FIELD_TYPE is available / has been allocated.
void setParameter(FieldArrayD< T, _DESCRIPTOR, PLATFORM, FIELD > &fieldArray)
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.
virtual void stream()=0
Apply the streaming step to the entire block.
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.
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 writeDynamicsAsCSV(std::ostream &) const =0
Prints CSV-structured list of all used dynamics.
virtual Vector< T *, DESCRIPTOR::q > getPopulationPointers(CellID iCell)=0
Returns pointers to host-side population locations of iCell.
void setParameter(AbstractFieldArrayD< T, _DESCRIPTOR, FIELD > &fieldArray)
Map of post processors of a single priority and stage.
Base of a regular block.
void forCoreSpatialLocations(F f) const
static constexpr unsigned d
Implementation of BlockLattice on a concrete PLATFORM.
void collide() override
Apply collision step of non-overlap interior.
bool hasCommunicatable(std::type_index field) const override
void writeOperatorAsCSV(std::ostream &clout) const override
Prints CSV-structured list of all used operators.
void setParameter(AbstractFieldArrayD< T, _DESCRIPTOR, FIELD > &abstractFieldArray)
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.
void writeDescription(std::ostream &clout) const override
Prints human-readable summary of all used dynamics and post processors.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
ConcreteBlockLattice(Vector< int, DESCRIPTOR::d > size, int padding=0)
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 writeDynamicsAsCSV(std::ostream &clout) const override
Prints CSV-structured list of all used dynamics.
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.
Dynamics< T, DESCRIPTOR > * getDynamics(CellID iCell) override
Get reference to dynamics of cell by index.
void setParameter(FieldArrayD< T, _DESCRIPTOR, _PLATFORM, FIELD > &fieldArray)
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.
ConcreteData< T, DESCRIPTOR, PLATFORM > & getData()
Communicatable & getCommunicatable(std::type_index field) override
static constexpr Platform platform
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.
Storage of any FIELD_TYPE data on PLATFORM.
Definition data.h:424
void setProcessingContext(ProcessingContext context) override
Set processing context of all managed fields.
Definition data.h:507
auto & getRegistry()
Expose FieldTypeRegistry for device-support.
Definition data.h:514
Highest-level interface to read-only Cell data.
Definition interface.h:36
Factory for instances of a specific Dynamics type.
SoA storage for instances of a single FIELD.
Base class for all LoadBalancer.
Definition vtiWriter.h:42
Factory for instances of a specific OPERATOR 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.
Interface for post-processing steps – header file.
Top level namespace for all of OpenLB.
auto callUsingConcretePlatform(Platform platform, typename CONCRETIZABLE::base_t *ptr, F f)
Dispatcher for concrete platform access.
Definition dispatch.h:41
std::uint32_t CellID
Type for sequential block-local cell indices.
ProcessingContext
OpenLB processing contexts.
Definition platform.h:54
@ Simulation
Data available on host for e.g. functor evaluation.
std::conditional_t< D==2, BlockF2D< T >, BlockF3D< T > > BlockF
Definition aliases.h:177
Platform
OpenLB execution targets.
Definition platform.h:35
@ 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:207
std::conditional_t< D==2, IndicatorF2D< T >, IndicatorF3D< T > > IndicatorF
Definition aliases.h:247
DynamicsPromise(meta::id< DYNAMICS >) -> DynamicsPromise< typename DYNAMICS::value_t, typename DYNAMICS::descriptor_t >
@ PerBlock
Per-block application, i.e. OPERATOR::apply is passed a ConcreteBlockLattice.
void initialize(int *argc, char ***argv, bool multiOutput, bool verbose)
Initialize OpenLB.
Definition olbInit.cpp:49
Interface for post-processing steps – header file.
Describe FieldArray of a FIELD in Data.
Definition data.h:50
Generic communicator for the overlap neighborhood of a block.
Curried ConcreteBlockLattice template for use in callUsingConcretePlatform.
Interface for per-cell dynamics.
Definition interface.h:56
Identity type to pass non-constructible types as value.
Definition meta.h:79
Communication after propagation.
Definition stages.h:36