OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::LbSolver< T, PARAMETERS, LATTICES > Class Template Referenceabstract

LbSolver is a generic solver for Lattice-Boltzmann problems. More...

#include <lbSolver.h>

+ Inheritance diagram for olb::LbSolver< T, PARAMETERS, LATTICES >:
+ Collaboration diagram for olb::LbSolver< T, PARAMETERS, LATTICES >:

Public Member Functions

 LbSolver ()
 
 LbSolver (utilities::TypeIndexedSharedPtrTuple< PARAMETERS > params)
 
void initialize () override
 Set up geometry.
 
void buildAndReturn ()
 Build geometry, lattice.
 
template<typename... ARGS>
auto & converter (ARGS &&... args)
 
template<typename... ARGS>
auto & converter (ARGS &&... args) const
 
template<typename KEY >
auto & lattice (KEY=KEY())
 
template<typename KEY >
auto & lattice (KEY=KEY()) const
 
template<typename KEY >
auto & lattice (meta::id< KEY >)
 
template<typename KEY >
auto & lattice (meta::id< KEY >) const
 
auto & lattice ()
 
auto & lattice () const
 
auto & geometry ()
 
auto & geometry () const
 
- Public Member Functions inherited from olb::BaseSolver< T, PARAMETERS >
 BaseSolver ()=default
 
 BaseSolver (utilities::TypeIndexedSharedPtrTuple< PARAMETERS > params)
 
virtual void preProcess ()
 Configurations that take place before solving.
 
void solve ()
 
virtual void postProcess ()
 Actions that take place after solving.
 
template<typename KEY >
auto & parameters (KEY=KEY())
 Access to parameter structs as parameters(KEY())
 
template<typename KEY >
auto & parameters (KEY=KEY()) const
 
template<typename KEY >
auto & parameters (meta::id< KEY >)
 
template<typename KEY >
auto & parameters (meta::id< KEY >) const
 

Static Public Attributes

static constexpr unsigned dim = LATTICES::values_t::template get<0>::d
 

Protected Types

template<typename... DESCRIPTORS>
using SuperLattices = std::tuple<std::shared_ptr<SuperLattice<T,DESCRIPTORS>>...>
 

Protected Member Functions

void prepareSimulation () override
 Set up lattice and initialize fields.
 
void timeStep (std::size_t iT) override
 Collide-and-stream + additional computations.
 
void postSimulation () override
 Evaluate results.
 
virtual void prepareGeometry ()=0
 Define the geometry.
 
virtual void prepareLattices ()=0
 Choose dynamics and boundary conditions.
 
virtual void setInitialValues ()=0
 Define fields and initialize lattice populations.
 
virtual void setBoundaryValues (std::size_t iT)=0
 Update fields and boundary values.
 
virtual void getResults (std::size_t iT)
 Computation of results and output with full flexibility.
 
virtual void computeResults (std::size_t iT)
 Perform further computations (compute errors etc.)
 
virtual void computeResults ()
 
virtual bool exitCondition (std::size_t iT) const override
 Condition, when to exit the time-stepping loop Returns true if the loop shall be continued.
 
virtual bool checkStability (std::size_t iT)
 check stability: maxU should be <= _boundMaxU for a stable simulation Returns true if this fulfilled
 
virtual void printLog (std::size_t iT) const
 
virtual void writeLogConverter () const
 
virtual void prepareVTK () const
 Write geometric information for vtk output The default version writes geometry, cuboid, rank and works for several lattices.
 
virtual void writeVTK (std::size_t iT) const
 
virtual void writeImages (std::size_t iT) const
 
virtual void writeGnuplot (std::size_t iT) const
 
- Protected Member Functions inherited from olb::BaseSolver< T, PARAMETERS >

Static Protected Member Functions

static constexpr unsigned getNumberStationaryLattices ()
 

Protected Attributes

std::shared_ptr< SuperGeometry< T, dim > > _sGeometry
 
std::shared_ptr< CuboidDecomposition< T, dim > > _cGeometry
 
std::shared_ptr< LoadBalancer< T > > _loadBalancer
 
LATTICES::values_t::template decompose_into< SuperLattices_sLattices
 
std::unique_ptr< util::Timer< BaseType< T > > > _timer
 
std::array< std::unique_ptr< util::ValueTracer< T > >, getNumberStationaryLattices()> _convergenceCheck
 
std::size_t _itCheckStability {1}
 
std::size_t _itBoundaryUpdate {1}
 
- Protected Attributes inherited from olb::BaseSolver< T, PARAMETERS >
bool _isInitialized {false}
 
std::size_t _iT {0}
 
bool _finishedTimeLoop {false}
 

Static Protected Attributes

static constexpr bool isStationary = PARAMETERS::keys_t::template contains<names::Stationarity>()
 
static constexpr bool outputGnuplot = PARAMETERS::keys_t::template contains<names::VisualizationGnuplot>()
 
static constexpr bool outputImages = PARAMETERS::keys_t::template contains<names::VisualizationImages>()
 
static constexpr bool outputVTK = PARAMETERS::keys_t::template contains<names::VisualizationVTK>()
 

Additional Inherited Members

- Public Types inherited from olb::BaseSolver< T, PARAMETERS >
using t = T
 
using Parameters_t = PARAMETERS
 
- Public Attributes inherited from olb::BaseSolver< T, PARAMETERS >
utilities::TypeIndexedSharedPtrTuple< PARAMETERS > _parameters
 

Detailed Description

template<typename T, typename PARAMETERS, typename LATTICES>
class olb::LbSolver< T, PARAMETERS, LATTICES >

LbSolver is a generic solver for Lattice-Boltzmann problems.

It holds geometry and lattices and defines the abstract methods of BaseSolver. Every simulation app should be able to inherit from this class.

Definition at line 132 of file lbSolver.h.

Member Typedef Documentation

◆ SuperLattices

template<typename T , typename PARAMETERS , typename LATTICES >
template<typename... DESCRIPTORS>
using olb::LbSolver< T, PARAMETERS, LATTICES >::SuperLattices = std::tuple<std::shared_ptr<SuperLattice<T,DESCRIPTORS>>...>
protected

Definition at line 142 of file lbSolver.h.

Constructor & Destructor Documentation

◆ LbSolver() [1/2]

template<typename T , typename PARAMETERS , typename LATTICES >
olb::LbSolver< T, PARAMETERS, LATTICES >::LbSolver ( )
inline

Definition at line 172 of file lbSolver.h.

173 { }
BaseSolver()=default

◆ LbSolver() [2/2]

template<typename T , typename PARAMETERS , typename LATTICES >
olb::LbSolver< T, PARAMETERS, LATTICES >::LbSolver ( utilities::TypeIndexedSharedPtrTuple< PARAMETERS > params)
inline

Definition at line 175 of file lbSolver.h.

175 : LbSolver::BaseSolver(params)
176 { }

Member Function Documentation

◆ buildAndReturn()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::buildAndReturn ( )

Build geometry, lattice.

Definition at line 60 of file lbSolver.hh.

61{
62 if (! this->_isInitialized) {
63 this->initialize();
64 }
65 build();
67}
bool _isInitialized
Definition lbSolver.h:51
void initialize() override
Set up geometry.
Definition lbSolver.hh:36
virtual void setInitialValues()=0
Define fields and initialize lattice populations.

References olb::initialize().

+ Here is the call graph for this function:

◆ checkStability()

template<typename T , typename PARAMETERS , typename LATTICES >
bool olb::LbSolver< T, PARAMETERS, LATTICES >::checkStability ( std::size_t iT)
protectedvirtual

check stability: maxU should be <= _boundMaxU for a stable simulation Returns true if this fulfilled

Definition at line 277 of file lbSolver.hh.

278{
279 bool result = true;
281 if (lattice->getStatistics().getMaxU() > this->parameters(names::Simulation()).boundMaxU) {
282 clout << "PROBLEM uMax=" << lattice->getStatistics().getMaxU() << std::endl;
283 lattice->getStatistics().print(iT, converter().getPhysTime(iT));
284 if (this->parameters(names::Simulation()).exitMaxU) {
285 exit(1);
286 }
287 result = false;
288 }
289 });
290 return result;
291}
auto & parameters(KEY=KEY())
Access to parameter structs as parameters(KEY())
Definition lbSolver.h:106
auto & converter(ARGS &&... args)
Definition lbSolver.h:260
auto & lattice()
Definition lbSolver.h:297
LATTICES::values_t::template decompose_into< SuperLattices > _sLattices
Definition lbSolver.h:148
void tuple_for_each(TUPLE &tuple, F &&f)
Apply F to each element of TUPLE.
Definition meta.h:373
void exit(int exitcode)
Definition singleton.h:177

References olb::meta::tuple_for_each().

+ Here is the call graph for this function:

◆ computeResults() [1/2]

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::computeResults ( )
inlineprotectedvirtual

Reimplemented in olb::opti::AdjointLbSolver< T, PARAMETERS, LATTICES, MODE >.

Definition at line 221 of file lbSolver.h.

221{ };

◆ computeResults() [2/2]

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::computeResults ( std::size_t iT)
inlineprotectedvirtual

Perform further computations (compute errors etc.)

Definition at line 219 of file lbSolver.h.

219{ };

◆ converter() [1/2]

template<typename T , typename PARAMETERS , typename LATTICES >
template<typename... ARGS>
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::converter ( ARGS &&... args)
inline

Definition at line 260 of file lbSolver.h.

260 {
261 using SimulationParameters_t = typename PARAMETERS::template value<names::Simulation>;
262 if constexpr(std::is_invocable_v<decltype(&SimulationParameters_t::converter),ARGS...>) {
263 return this->parameters(names::Simulation()).converter(args...);
264 }
265 else {
266 return *this->parameters(names::Simulation()).converter;
267 }
268 __builtin_unreachable();
269 }

References olb::BaseSolver< T, PARAMETERS >::parameters().

+ Here is the call graph for this function:

◆ converter() [2/2]

template<typename T , typename PARAMETERS , typename LATTICES >
template<typename... ARGS>
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::converter ( ARGS &&... args) const
inline

Definition at line 271 of file lbSolver.h.

271 {
272 using SimulationParameters_t = typename PARAMETERS::template value<names::Simulation>;
273 if constexpr(std::is_invocable_v<decltype(&SimulationParameters_t::converter),ARGS...>) {
274 return this->parameters(names::Simulation()).converter(args...);
275 }
276 else {
277 return *this->parameters(names::Simulation()).converter;
278 }
279 __builtin_unreachable();
280 }

References olb::BaseSolver< T, PARAMETERS >::parameters().

+ Here is the call graph for this function:

◆ exitCondition()

template<typename T , typename PARAMETERS , typename LATTICES >
bool olb::LbSolver< T, PARAMETERS, LATTICES >::exitCondition ( std::size_t iT) const
overrideprotectedvirtual

Condition, when to exit the time-stepping loop Returns true if the loop shall be continued.

Implements olb::BaseSolver< T, PARAMETERS >.

Definition at line 256 of file lbSolver.hh.

257{
258 if (iT > this->converter().getLatticeTime(this->parameters(names::Simulation()).maxTime)){
259 return true;
260 }
261
262 if constexpr (isStationary){
263 if (std::all_of(_convergenceCheck.cbegin(), _convergenceCheck.cend(), [](auto& c){
264 return c->hasConverged();
265 } )) {
266 if (this->parameters(names::Output()).verbose) {
267 clout << "Simulation converged." << std::endl;
268 }
269 return true;
270 }
271 }
272
273 return false;
274}
static constexpr bool isStationary
Definition lbSolver.h:152
std::array< std::unique_ptr< util::ValueTracer< T > >, getNumberStationaryLattices()> _convergenceCheck
Definition lbSolver.h:162

◆ geometry() [1/2]

template<typename T , typename PARAMETERS , typename LATTICES >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::geometry ( )
inline

Definition at line 305 of file lbSolver.h.

305 {
306 return *_sGeometry;
307 }
std::shared_ptr< SuperGeometry< T, dim > > _sGeometry
Definition lbSolver.h:144

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sGeometry.

◆ geometry() [2/2]

template<typename T , typename PARAMETERS , typename LATTICES >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::geometry ( ) const
inline

Definition at line 308 of file lbSolver.h.

308 {
309 return *_sGeometry;
310 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sGeometry.

◆ getNumberStationaryLattices()

template<typename T , typename PARAMETERS , typename LATTICES >
static constexpr unsigned olb::LbSolver< T, PARAMETERS, LATTICES >::getNumberStationaryLattices ( )
inlinestaticconstexprprotected

Definition at line 153 of file lbSolver.h.

153 {
154 if constexpr (isStationary) {
155 return PARAMETERS::template value<names::Stationarity>::numberOfStationaryLattices;
156 } else {
157 return 0;
158 }
159 __builtin_unreachable();
160 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::isStationary.

◆ getResults()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::getResults ( std::size_t iT)
inlineprotectedvirtual

Computation of results and output with full flexibility.

Definition at line 214 of file lbSolver.h.

214{ };

◆ initialize()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::initialize ( )
overridevirtual

Set up geometry.

Implements olb::BaseSolver< T, PARAMETERS >.

Definition at line 36 of file lbSolver.hh.

37{
38 if (this->parameters(names::Output()).verbose) {
39 clout << "Start initialization" << std::endl;
40 }
41
42 this->prepareGeometry();
43 // Removes all not needed boundary voxels outside the surface
44 //this->geometry().clean(this->parameters(names::Output()).verbose);
45 // Removes all not needed boundary voxels inside the surface
46 this->geometry().innerClean(this->parameters(names::Output()).verbose);
47 geometry().checkForErrors(this->parameters(names::Output()).verbose);
48 if (this->parameters(names::Output()).verbose) {
49 geometry().getStatistics().print();
50 }
51
52 this->_isInitialized = true;
53
54 if (this->parameters(names::Output()).verbose) {
55 clout << "Finished initialization" << std::endl;
56 }
57}
auto & geometry()
Definition lbSolver.h:305
virtual void prepareGeometry()=0
Define the geometry.

◆ lattice() [1/6]

template<typename T , typename PARAMETERS , typename LATTICES >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::lattice ( )
inline

Definition at line 297 of file lbSolver.h.

297 {
298 static_assert((LATTICES::size == 1), "Lattice name must be provided");
299 return *std::get<0>(_sLattices);
300 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sLattices.

+ Here is the caller graph for this function:

◆ lattice() [2/6]

template<typename T , typename PARAMETERS , typename LATTICES >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::lattice ( ) const
inline

Definition at line 301 of file lbSolver.h.

301 {
302 static_assert((LATTICES::size == 1), "Lattice name must be provided");
303 return *std::get<0>(_sLattices);
304 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sLattices.

◆ lattice() [3/6]

template<typename T , typename PARAMETERS , typename LATTICES >
template<typename KEY >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::lattice ( KEY = KEY())
inline

Definition at line 282 of file lbSolver.h.

282 {
283 return *std::get<(LATTICES::keys_t::template index<KEY>())>(_sLattices);
284 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sLattices.

◆ lattice() [4/6]

template<typename T , typename PARAMETERS , typename LATTICES >
template<typename KEY >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::lattice ( KEY = KEY()) const
inline

Definition at line 286 of file lbSolver.h.

286 {
287 return *std::get<(LATTICES::keys_t::template index<KEY>())>(_sLattices);
288 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sLattices.

◆ lattice() [5/6]

template<typename T , typename PARAMETERS , typename LATTICES >
template<typename KEY >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::lattice ( meta::id< KEY > )
inline

Definition at line 290 of file lbSolver.h.

290 {
291 return *std::get<(LATTICES::keys_t::template index<KEY>())>(_sLattices);
292 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sLattices.

◆ lattice() [6/6]

template<typename T , typename PARAMETERS , typename LATTICES >
template<typename KEY >
auto & olb::LbSolver< T, PARAMETERS, LATTICES >::lattice ( meta::id< KEY > ) const
inline

Definition at line 294 of file lbSolver.h.

294 {
295 return *std::get<(LATTICES::keys_t::template index<KEY>())>(_sLattices);
296 }

References olb::LbSolver< T, PARAMETERS, LATTICES >::_sLattices.

◆ postSimulation()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::postSimulation ( )
overrideprotectedvirtual

Evaluate results.

Implements olb::BaseSolver< T, PARAMETERS >.

Definition at line 207 of file lbSolver.hh.

208{
210 // TODO: dispose also communication of fields...
211 lattice->communicate();
212 });
213
214 if ( this->parameters(names::Output()).verbose ) {
215 printLog(this->_iT);
216 }
217 if constexpr (outputVTK) {
218 if ( this->parameters(names::VisualizationVTK()).printOutput == olb::parameters::OutputPlot<T>::pO_final) {
219 writeVTK(this->_iT);
220 }
221 }
222 if constexpr (outputImages) {
223 if ( this->parameters(names::VisualizationImages()).printOutput == olb::parameters::OutputPlot<T>::pO_final) {
224 writeImages(this->_iT);
225 }
226 }
227 if constexpr (outputGnuplot) {
228 if ( this->parameters(names::VisualizationGnuplot()).printOutput == olb::parameters::OutputPlot<T>::pO_final) {
229 writeGnuplot(this->_iT);
230 }
231 }
232 getResults(this->_iT);
233
234 _timer->stop();
235 if (this->parameters(names::Output()).verbose) {
236 clout << "Finished collide-and-stream loop" << std::endl;
237 clout << "Start postprocessing" << std::endl;
238 }
240
241 if (this->parameters(names::Output()).verbose) {
242 _timer->printSummary();
243 }
244
245 // required to finish output tasks during use of gpu
247 lattice->setProcessingContext(ProcessingContext::Evaluation);
248 });
249
250 if (this->parameters(names::Output()).verbose) {
251 clout << "Finished postprocessing" << std::endl;
252 }
253}
std::size_t _iT
Definition lbSolver.h:52
virtual void printLog(std::size_t iT) const
Definition lbSolver.hh:305
static constexpr bool outputImages
Definition lbSolver.h:165
virtual void getResults(std::size_t iT)
Computation of results and output with full flexibility.
Definition lbSolver.h:214
virtual void writeGnuplot(std::size_t iT) const
Definition lbSolver.h:255
std::unique_ptr< util::Timer< BaseType< T > > > _timer
Definition lbSolver.h:150
virtual void computeResults()
Definition lbSolver.h:221
static constexpr bool outputVTK
Definition lbSolver.h:166
virtual void writeImages(std::size_t iT) const
Definition lbSolver.h:252
virtual void writeVTK(std::size_t iT) const
Definition lbSolver.h:249
static constexpr bool outputGnuplot
Definition lbSolver.h:164

References olb::Evaluation, olb::meta::tuple_for_each(), and olb::writeVTK().

+ Here is the call graph for this function:

◆ prepareGeometry()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::prepareGeometry ( )
protectedpure virtual

Define the geometry.

◆ prepareLattices()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::prepareLattices ( )
protectedpure virtual

Choose dynamics and boundary conditions.

◆ prepareSimulation()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::prepareSimulation ( )
overrideprotectedvirtual

Set up lattice and initialize fields.

Implements olb::BaseSolver< T, PARAMETERS >.

Definition at line 100 of file lbSolver.hh.

101{
102 if (this->parameters(names::Output()).verbose) {
103 clout << "Start prepareSimulation" << std::endl;
104 }
105
106 this->_iT = 0;
107
108 build();
109
111
113 lattice->initialize();
114 lattice->getStatistics().reset();
115 lattice->getStatistics().initialize();
116 });
117
118
119 if constexpr (outputVTK) {
120 if (this->parameters(names::VisualizationVTK()).output != "off") {
121 prepareVTK();
122 }
123 }
124
125 if (this->parameters(names::Output()).verbose) {
126 clout << "Finished prepareSimulation" << std::endl;
127 clout << "Start collide-and-stream loop" << std::endl;
128 }
129 _timer->start();
130}
virtual void prepareVTK() const
Write geometric information for vtk output The default version writes geometry, cuboid,...
Definition lbSolver.hh:323

References olb::meta::tuple_for_each().

+ Here is the call graph for this function:

◆ prepareVTK()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::prepareVTK ( ) const
protectedvirtual

Write geometric information for vtk output The default version writes geometry, cuboid, rank and works for several lattices.

This method may be overridden in case e.g. discrete normals shall be visualized (cf. example cavity2d).

Writes the geometry, cuboid no. and rank no. as vti file for visualization

Definition at line 323 of file lbSolver.hh.

324{
325 // write the geometric information. Since this does not depend on the
326 // lattice, we may w.l.o.g. work with the first lattice
327 auto& lattice = *std::get<0>(_sLattices);
328 using DESCRIPTOR = typename LATTICES::values_t::template get<0>;
329
330
331 SuperVTMwriter<T,dim> vtmWriter(this->parameters(names::VisualizationVTK()).filename);
332
336 vtmWriter.write( cuboid );
337 vtmWriter.write( rank );
338 vtmWriter.createMasterFile();
339}
std::conditional_t< DESCRIPTOR::d==2, SuperLatticeRank2D< T, DESCRIPTOR >, SuperLatticeRank3D< T, DESCRIPTOR > > SuperLatticeRank
Definition aliases.h:108
std::conditional_t< DIM==2, SuperVTMwriter2D< T, OUT_T, W >, SuperVTMwriter3D< T, OUT_T, W > > SuperVTMwriter
Definition aliases.h:78
std::conditional_t< DESCRIPTOR::d==2, SuperLatticeCuboid2D< T, DESCRIPTOR >, SuperLatticeCuboid3D< T, DESCRIPTOR > > SuperLatticeCuboid
Definition aliases.h:98

◆ printLog()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::printLog ( std::size_t iT) const
protectedvirtual

Definition at line 305 of file lbSolver.hh.

306{
307 using OutputParameters_t = typename PARAMETERS::template value<names::Output>;
308 OutputParameters_t::printLatticeStatistics::for_each( [&](auto type){
309 lattice(type.get()).getStatistics().print(iT, converter().getPhysTime(iT));
310 } );
311
312 _timer->print(iT, this->parameters(names::Output()).timerPrintMode);
313}

◆ setBoundaryValues()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::setBoundaryValues ( std::size_t iT)
protectedpure virtual

Update fields and boundary values.

◆ setInitialValues()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::setInitialValues ( )
protectedpure virtual

Define fields and initialize lattice populations.

◆ timeStep()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::timeStep ( std::size_t iT)
overrideprotectedvirtual

Collide-and-stream + additional computations.

Implements olb::BaseSolver< T, PARAMETERS >.

Definition at line 134 of file lbSolver.hh.

135{
136 if (iT % _itBoundaryUpdate == 0) {
138 }
139
141 // TODO: dispose also communication of fields
142 lattice->communicate();
143 });
144
145
146 if constexpr (outputVTK) {
147 if ( this->parameters(names::VisualizationVTK()).printOutput == olb::parameters::OutputPlot<T>::pO_intervals
148 && iT % converter().getLatticeTime(this->parameters(names::VisualizationVTK()).saveTime) == 0 ) {
149 writeVTK(iT);
150 }
151 }
152 if constexpr (outputImages) {
153 if ( this->parameters(names::VisualizationImages()).printOutput == olb::parameters::OutputPlot<T>::pO_intervals
154 && iT % converter().getLatticeTime(this->parameters(names::VisualizationImages()).saveTime) == 0 ) {
155 writeImages(iT);
156 }
157 }
158 if constexpr (outputGnuplot) {
159 if ( this->parameters(names::VisualizationGnuplot()).printOutput == olb::parameters::OutputPlot<T>::pO_intervals
160 && iT % converter().getLatticeTime(this->parameters(names::VisualizationGnuplot()).saveTime) == 0 ) {
161 writeGnuplot(iT);
162 }
163 }
164 if ( this->parameters(names::Output()).verbose
165 && iT % converter().getLatticeTime(this->parameters(names::Output()).logT) == 0) {
166 printLog(iT);
167 }
168 computeResults(iT);
169 getResults(iT);
170
172 lattice->collideAndStream();
173 });
174
175 if (this->parameters(names::Simulation()).pressureFilter) {
176 // TODO: allow choosing the lattices here
177 std::get<0>(_sLattices)->stripeOffDensityOffset(std::get<0>(_sLattices)->getStatistics().getAverageRho() - T(1));
178 }
179
180 if constexpr (isStationary){
181 unsigned counter = 0;
182 using parameters_t = typename PARAMETERS::template value<names::Stationarity>;
183 parameters_t::stat_lattices::for_each( [&](auto Id) {
184 // using Name = typename decltype(Id)::type;
185 if (this->parameters(names::Stationarity()).convergenceType[counter] == parameters_t::MaxLatticeVelocity){
186 _convergenceCheck[counter]->takeValue( this->lattice(Id).getStatistics().getMaxU());
187 }
188 else if (this->parameters(names::Stationarity()).convergenceType[counter] == parameters_t::AverageEnergy){
189 _convergenceCheck[counter]->takeValue( this->lattice(Id).getStatistics().getAverageEnergy() );
190 }
191 else if (this->parameters(names::Stationarity()).convergenceType[counter] == parameters_t::AverageRho){
192 _convergenceCheck[counter]->takeValue( this->lattice(Id).getStatistics().getAverageRho());
193 }
194 else {
195 throw std::invalid_argument("Convergence type is not supported.\n");
196 }
197 counter++;
198 });
199 }
200
201 if (iT % _itCheckStability == 0) {
202 checkStability(iT);
203 }
204}
virtual bool checkStability(std::size_t iT)
check stability: maxU should be <= _boundMaxU for a stable simulation Returns true if this fulfilled
Definition lbSolver.hh:277
std::size_t _itBoundaryUpdate
Definition lbSolver.h:169
virtual void setBoundaryValues(std::size_t iT)=0
Update fields and boundary values.
std::size_t _itCheckStability
Definition lbSolver.h:168

References olb::meta::tuple_for_each(), and olb::writeVTK().

+ Here is the call graph for this function:

◆ writeGnuplot()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::writeGnuplot ( std::size_t iT) const
inlineprotectedvirtual

Definition at line 255 of file lbSolver.h.

255{ };

◆ writeImages()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::writeImages ( std::size_t iT) const
inlineprotectedvirtual

Definition at line 252 of file lbSolver.h.

252{ };

◆ writeLogConverter()

template<typename T , typename PARAMETERS , typename LATTICES >
void olb::LbSolver< T, PARAMETERS, LATTICES >::writeLogConverter ( ) const
protectedvirtual

Definition at line 316 of file lbSolver.hh.

317{
318 converter().print();
319 converter().write(this->parameters(names::Output()).name);
320}

◆ writeVTK()

template<typename T , typename PARAMETERS , typename LATTICES >
virtual void olb::LbSolver< T, PARAMETERS, LATTICES >::writeVTK ( std::size_t iT) const
inlineprotectedvirtual

Definition at line 249 of file lbSolver.h.

249{ };

Member Data Documentation

◆ _cGeometry

template<typename T , typename PARAMETERS , typename LATTICES >
std::shared_ptr<CuboidDecomposition<T,dim> > olb::LbSolver< T, PARAMETERS, LATTICES >::_cGeometry
protected

Definition at line 145 of file lbSolver.h.

◆ _convergenceCheck

template<typename T , typename PARAMETERS , typename LATTICES >
std::array<std::unique_ptr<util::ValueTracer<T> >, getNumberStationaryLattices()> olb::LbSolver< T, PARAMETERS, LATTICES >::_convergenceCheck
protected

Definition at line 162 of file lbSolver.h.

◆ _itBoundaryUpdate

template<typename T , typename PARAMETERS , typename LATTICES >
std::size_t olb::LbSolver< T, PARAMETERS, LATTICES >::_itBoundaryUpdate {1}
protected

Definition at line 169 of file lbSolver.h.

169{1};

◆ _itCheckStability

template<typename T , typename PARAMETERS , typename LATTICES >
std::size_t olb::LbSolver< T, PARAMETERS, LATTICES >::_itCheckStability {1}
protected

Definition at line 168 of file lbSolver.h.

168{1};

◆ _loadBalancer

template<typename T , typename PARAMETERS , typename LATTICES >
std::shared_ptr<LoadBalancer<T> > olb::LbSolver< T, PARAMETERS, LATTICES >::_loadBalancer
protected

Definition at line 146 of file lbSolver.h.

◆ _sGeometry

template<typename T , typename PARAMETERS , typename LATTICES >
std::shared_ptr<SuperGeometry<T,dim> > olb::LbSolver< T, PARAMETERS, LATTICES >::_sGeometry
protected

Definition at line 144 of file lbSolver.h.

◆ _sLattices

template<typename T , typename PARAMETERS , typename LATTICES >
LATTICES::values_t::template decompose_into<SuperLattices> olb::LbSolver< T, PARAMETERS, LATTICES >::_sLattices
protected

Definition at line 148 of file lbSolver.h.

◆ _timer

template<typename T , typename PARAMETERS , typename LATTICES >
std::unique_ptr<util::Timer<BaseType<T> > > olb::LbSolver< T, PARAMETERS, LATTICES >::_timer
protected

Definition at line 150 of file lbSolver.h.

◆ dim

template<typename T , typename PARAMETERS , typename LATTICES >
unsigned olb::LbSolver< T, PARAMETERS, LATTICES >::dim = LATTICES::values_t::template get<0>::d
staticconstexpr

Definition at line 138 of file lbSolver.h.

◆ isStationary

template<typename T , typename PARAMETERS , typename LATTICES >
bool olb::LbSolver< T, PARAMETERS, LATTICES >::isStationary = PARAMETERS::keys_t::template contains<names::Stationarity>()
staticconstexprprotected

Definition at line 152 of file lbSolver.h.

◆ outputGnuplot

template<typename T , typename PARAMETERS , typename LATTICES >
bool olb::LbSolver< T, PARAMETERS, LATTICES >::outputGnuplot = PARAMETERS::keys_t::template contains<names::VisualizationGnuplot>()
staticconstexprprotected

Definition at line 164 of file lbSolver.h.

◆ outputImages

template<typename T , typename PARAMETERS , typename LATTICES >
bool olb::LbSolver< T, PARAMETERS, LATTICES >::outputImages = PARAMETERS::keys_t::template contains<names::VisualizationImages>()
staticconstexprprotected

Definition at line 165 of file lbSolver.h.

◆ outputVTK

template<typename T , typename PARAMETERS , typename LATTICES >
bool olb::LbSolver< T, PARAMETERS, LATTICES >::outputVTK = PARAMETERS::keys_t::template contains<names::VisualizationVTK>()
staticconstexprprotected

Definition at line 166 of file lbSolver.h.


The documentation for this class was generated from the following files: