25#ifndef SUPER_LATTICE_H
26#define SUPER_LATTICE_H
44template <
typename T,
typename DESCRIPTOR>
49 std::vector<std::unique_ptr<BlockLattice<T,DESCRIPTOR>>> _block;
51 std::map<std::type_index,std::unique_ptr<SuperCommunicator<T,SuperLattice>>> _communicator;
53 bool _communicationNeeded;
55 std::map<std::type_index,std::vector<std::function<void()>>> _customTasks;
57 std::map<std::type_index,std::vector<std::future<void>>> _backgroundTasks;
65 bool _statisticsEnabled;
67 void collectStatistics();
70 constexpr static unsigned d = DESCRIPTOR::d;
93 template <
typename BLOCK>
96 return *
dynamic_cast<BLOCK*
>(_block[locC].get());
101 return *_block[locC];
104 template <
typename BLOCK>
107 return *
dynamic_cast<const BLOCK*
>(_block[locIC].get());
111 template <Platform PLATFORM,
typename F>
114 if (_block[iC]->getPlatform() == PLATFORM) {
129 waitForBackgroundTasks<stage::PreContextSwitchTo<ProcessingContext::Evaluation>>();
132 _block[iC]->setProcessingContext(context);
140 template <
typename FIELD_TYPE>
144 if (_block[iC]->
template hasData<FIELD_TYPE>()) {
145 _block[iC]->template getData<FIELD_TYPE>().setProcessingContext(context);
151 template <
typename STAGE>
164 template <
typename... R>
176 template <
typename DYNAMICS>
179 template <
typename DYNAMICS>
183 template <
template<
typename...>
typename DYNAMICS>
186 template <
template<
typename...>
typename DYNAMICS>
246 template <
typename FIELD>
250 template <
typename FIELD>
254 template <
typename FIELD>
258 template <
typename FIELD>
262 template <
typename FIELD>
265 template <
typename FIELD>
275 template <
typename PARAMETER>
279 template <
typename PARAMETER,
typename DYNAMICS>
282 template <
typename PARAMETER,
template<
typename...>
typename DYNAMICS>
292 template <
typename PARAMETER, Platform PLATFORM,
typename FIELD>
345 _statisticsEnabled =
true;
347 _block[iC]->setStatisticsEnabled(
true);
356 _statisticsEnabled =
false;
358 _block[iC]->setStatisticsEnabled(
false);
363 template <
typename STAGE=stage::PostStream>
366 template <
typename STAGE=stage::PostStream>
370 template <
typename STAGE=stage::PostStream>
374 template <
typename STAGE=stage::PostStream>
378 template <
typename STAGE=stage::PostStream>
386 template <
typename STAGE=stage::PostStream>
390 template <
typename PARTNER_DESCRIPTOR>
394 template <
typename PARTNER_DESCRIPTOR>
399 template <
typename PARTNER_DESCRIPTOR>
404 template <
typename... PARTNER_DESCRIPTORS>
406 PARTNER_DESCRIPTORS&... partnerLattices);
408 template <
typename... PARTNER_DESCRIPTORS>
411 PARTNER_DESCRIPTORS&... partnerLattices);
413 template <
typename... PARTNER_DESCRIPTORS>
416 PARTNER_DESCRIPTORS&... partnerLattices);
427 template <
typename STAGE>
429 _customTasks[
typeid(STAGE)].emplace_back(f);
432 template <
typename STAGE>
436 template <
typename STAGE,
typename F>
439 template <
typename F>
446 template <
typename CONTEXT>
449 template <
typename STAGE>
457 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Platform-abstracted block lattice for external access and inter-block interaction.
Base class for serializable objects of dynamic size
Highest-level interface to Cell data.
Implementation of BlockLattice on a concrete PLATFORM.
SoA storage for instances of a single FIELD.
Smart pointer for managing the various ways of passing functors around.
IndicatorF2D is an application from .
IndicatorF3D is an application from .
Factory for instances of a specific POST_PROCESSOR type.
Generic communicator for overlaps between blocks of SUPER.
Representation of a statistic for a parallel 2D geometry.
Super class maintaining block lattices for a cuboid decomposition.
void communicate() override
Perform full overlap communication if needed.
SuperCommunicator< T, SuperLattice > & getCommunicator(STAGE stage=STAGE())
Return communicator for given communication stage.
DESCRIPTOR descriptor_t
Descriptor / discrete velocity set of the lattice.
void waitForBackgroundTasks(STAGE stage=STAGE{})
Block until all background tasks scheduled for STAGE are completed.
LatticeStatistics< T > & getStatistics()
Return a handle to the LatticeStatistics object.
void iniRegularized(FunctorPtr< SuperIndicatorF< 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.
T value_t
Base value type of the lattice.
void forBlocksOnPlatform(F f)
Apply f to every ConcreteBlockLattice of PLATFORM.
void defineDynamics(SuperGeometry< T, DESCRIPTOR::d > &sGeometry, int material)
Set dynamics of indicated cells to DYNAMICS<T,DESCRIPTOR>
void collideAndStream()
Core implementation of a single iteration of the collide and stream loop.
BLOCK & getBlock(int locC)
Return locC-th block lattice casted to BLOCK.
void addPostProcessor(PostProcessorGenerator< T, DESCRIPTOR > const &ppGen)
Add a non-local post-processing step (legacy)
void executeCoupling()
Executes coupling with partner lattices (legacy)
void defineField(FunctorPtr< SuperIndicatorF< T, DESCRIPTOR::d > > &&indicator, FunctorPtr< SuperF< DESCRIPTOR::d, T, T > > &&field)
Define an external field on a domain described by an indicator.
void defineRho(FunctorPtr< SuperIndicatorF< T, DESCRIPTOR::d > > &&, AnalyticalF< DESCRIPTOR::d, T, T > &rho)
Define rho on a domain described by an indicator.
void addLatticeCoupling(LatticeCouplingGenerator< T, DESCRIPTOR > const &lcGen, std::vector< SuperLattice< T, PARTNER_DESCRIPTOR > * > partnerLattices)
Adds a coupling generator for a vector of partner superLattice (legacy)
void setParameter(FieldD< T, DESCRIPTOR, PARAMETER > field)
Update PARAMETER in all dynamics and post processors.
void setProcessingContext(ProcessingContext context)
Set processing context of FIELD_TYPE in block lattices.
void stripeOffDensityOffset(T offset)
Subtract constant offset from the density.
void statisticsOff()
Switch Statistics off (default on)
static constexpr unsigned d
void definePopulations(FunctorPtr< SuperIndicatorF< T, DESCRIPTOR::d > > &&indicator, AnalyticalF< DESCRIPTOR::d, T, T > &Pop)
Define a population on a domain described by an indicator.
void setProcessingContext(ProcessingContext context)
Set processing context of block lattices.
std::size_t getSerializableSize() const override
Binary size for the serializer.
const BlockLattice< T, DESCRIPTOR > & getBlock(int locC) const
Return read-only BlockLattice with local index locC.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
void iniEquilibrium(FunctorPtr< SuperIndicatorF< 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 statisticsOn()
Switch Statistics on (default on)
const BLOCK & getBlock(int locIC) const
Return locC-th block lattice casted to BLOCK (read-only)
SuperLattice(SuperGeometry< T, DESCRIPTOR::d > &superGeometry)
Construct lattice for the cuboid decomposition of superGeometry.
void addCustomTask(std::function< void()> f)
Schedules f for execution during every invocation of STAGE.
void executeCustomTasks(STAGE stage=STAGE())
Executes custom tasks assigned to STAGE.
void defineDynamics(FunctorPtr< SuperIndicatorF< T, DESCRIPTOR::d > > &&indicator)
Set dynamics of indicated cells to DYNAMICS.
void initialize()
Initialize lattice to be ready for simulation.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
void defineU(FunctorPtr< SuperIndicatorF< T, DESCRIPTOR::d > > &&indicator, AnalyticalF< DESCRIPTOR::d, T, T > &u)
Define u on a domain described by an indicator.
void defineRhoU(FunctorPtr< SuperIndicatorF< 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.
void scheduleBackgroundOutput(F &&f)
Schedule F(iC) for one-off background output of block data.
void scheduleBackgroundOutputVTK(CONTEXT &&vtkContext)
Schedule one-off background output of given VTK CONTEXT.
void setParameterOfDynamics(FieldD< T, DESCRIPTOR, PARAMETER > &&field)
Update PARAMETER in DYNAMICS.
void scheduleBackgroundTask(F &&f)
Schedule F for one-off background execution to be finished by STAGE.
SuperLattice(const SuperLattice &)=delete
Cell< T, DESCRIPTOR > get(LatticeR< DESCRIPTOR::d+1 > latticeR)
Get local cell interface.
void executePostProcessors(STAGE stage=STAGE())
Executes post processors for STAGE.
LoadBalancer< T > & _loadBalancer
Distribution of the cuboids of the cuboid structure.
Top level namespace for all of OpenLB.
ProcessingContext
OpenLB processing contexts.
std::conditional_t< DESCRIPTOR::d==2, LatticeCouplingGenerator2D< T, DESCRIPTOR >, LatticeCouplingGenerator3D< T, DESCRIPTOR > > LatticeCouplingGenerator
std::conditional_t< D==2, SuperF2D< T, U >, SuperF3D< T, U > > SuperF
std::conditional_t< DESCRIPTOR::d==2, PostProcessorGenerator2D< T, DESCRIPTOR >, PostProcessorGenerator3D< T, DESCRIPTOR > > PostProcessorGenerator
std::conditional_t< D==2, SuperIndicatorF2D< T >, SuperIndicatorF3D< T > > SuperIndicatorF
Curried ConcreteBlockLattice template for use in callUsingConcretePlatform.
Interface for per-cell dynamics.
Representation of a parallel 2D geometry – header file.