39template <
typename T,
typename PARAMETERS>
103 template <
typename KEY>
107 template <
typename KEY>
111 template <
typename KEY>
115 template <
typename KEY>
136 static constexpr unsigned dim = LATTICES::values_t::template get<0>::d;
138 template<
typename... DESCRIPTORS>
139 using SuperLattices = std::tuple<std::shared_ptr<SuperLattice<T,DESCRIPTORS>>...>;
145 typename LATTICES::values_t::template decompose_into<SuperLattices>
_sLattices;
147 std::unique_ptr<util::Timer<BaseType<T>>>
_timer;
149 static constexpr bool isStationary = PARAMETERS::keys_t::template contains<names::Stationarity>();
152 return PARAMETERS::template value<names::Stationarity>::numberOfStationaryLattices;
156 __builtin_unreachable();
158 std::array<std::unique_ptr<util::ValueTracer<T>>,
161 static constexpr bool outputGnuplot = PARAMETERS::keys_t::template contains<names::VisualizationGnuplot>();
162 static constexpr bool outputImages = PARAMETERS::keys_t::template contains<names::VisualizationImages>();
163 static constexpr bool outputVTK = PARAMETERS::keys_t::template contains<names::VisualizationVTK>();
186 void timeStep(std::size_t iT)
override;
229 void renewLattices();
233 virtual void printLog(std::size_t iT)
const;
254 template<
typename... ARGS>
256 using SimulationParameters_t =
typename PARAMETERS::template value<names::Simulation>;
257 if constexpr(std::is_invocable_v<
decltype(&SimulationParameters_t::converter),ARGS...>) {
263 __builtin_unreachable();
265 template<
typename... ARGS>
267 using SimulationParameters_t =
typename PARAMETERS::template value<names::Simulation>;
268 if constexpr(std::is_invocable_v<
decltype(&SimulationParameters_t::converter),ARGS...>) {
274 __builtin_unreachable();
276 template <
typename KEY>
278 return *std::get<(LATTICES::keys_t::template index<KEY>())>(
_sLattices);
280 template <
typename KEY>
282 return *std::get<(LATTICES::keys_t::template index<KEY>())>(
_sLattices);
284 template <
typename KEY>
286 return *std::get<(LATTICES::keys_t::template index<KEY>())>(
_sLattices);
288 template <
typename KEY>
290 return *std::get<(LATTICES::keys_t::template index<KEY>())>(
_sLattices);
293 static_assert((LATTICES::size == 1),
"Lattice name must be provided");
297 static_assert((LATTICES::size == 1),
"Lattice name must be provided");
316template<
typename T,
typename SOLVER>
317std::function<T (
const std::vector<T>&,
unsigned)>
getCallable(std::shared_ptr<SOLVER> solver){
318 return [=](
const std::vector<T>& control,
unsigned optiStep) -> T {
319 solver->parameters(
names::Opti()).applyControl(control);
327template<
typename SOLVER>
330 solver->postProcess();
337template <
class SOLVER>
340 using parameters_map =
typename SOLVER::BaseSolver::Parameters_t;
341 auto paramsTuple = createParametersTuple<parameters_map>(xml);
342 return std::make_shared<SOLVER>(paramsTuple);
BaseSolver implements the solving process of an instationary simulation, consisting of preSimulationT...
auto & parameters(meta::id< KEY >)
utilities::TypeIndexedSharedPtrTuple< PARAMETERS > _parameters
virtual void prepareSimulation()=0
Actions that shall be executed before the time-stepping.
auto & parameters(KEY=KEY())
Access to parameter structs as parameters(KEY())
virtual void initialize()=0
Actions that shall be executed once after construction.
virtual void preProcess()
Configurations that take place before solving.
virtual bool exitCondition(std::size_t iT) const =0
Condition, when to exit the time-stepping loop Returns true if the loop shall be continued.
auto & parameters(meta::id< KEY >) const
BaseSolver(utilities::TypeIndexedSharedPtrTuple< PARAMETERS > params)
virtual void postProcess()
Actions that take place after solving.
auto & parameters(KEY=KEY()) const
virtual void timeStep(std::size_t iT)=0
Defines what to do in a single time step.
virtual void postSimulation()=0
Actions that shall be executed after the time-stepping.
LbSolver is a generic solver for Lattice-Boltzmann problems.
void buildAndReturn()
Build geometry, lattice and call computeResults.
virtual void printLog(std::size_t iT) const
std::tuple< std::shared_ptr< SuperLattice< T, DESCRIPTORS > >... > SuperLattices
void prepareSimulation() override
Set up lattice and initialize fields.
std::shared_ptr< CuboidGeometry< T, dim > > _cGeometry
LbSolver(utilities::TypeIndexedSharedPtrTuple< PARAMETERS > params)
auto & converter(ARGS &&... args)
static constexpr bool isStationary
void timeStep(std::size_t iT) override
Collide-and-stream + additional computations.
virtual void prepareVTK() const
Write geometric information for vtk output The default version writes geometry, cuboid,...
auto & lattice(KEY=KEY()) const
static constexpr bool outputImages
auto & lattice(KEY=KEY())
virtual void writeLogConverter() const
virtual void prepareLattices()=0
Choose dynamics and boundary conditions.
static constexpr unsigned dim
virtual bool checkStability(std::size_t iT)
check stability: maxU should be <= _boundMaxU for a stable simulation Returns true if this fulfilled
std::shared_ptr< SuperGeometry< T, dim > > _sGeometry
virtual void getResults(std::size_t iT)
Computation of results and output with full flexibility.
virtual void writeGnuplot(std::size_t iT) const
auto & converter(ARGS &&... args) const
auto & lattice(meta::id< KEY >)
std::shared_ptr< LoadBalancer< T > > _loadBalancer
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.
std::array< std::unique_ptr< util::ValueTracer< T > >, getNumberStationaryLattices()> _convergenceCheck
LATTICES::values_t::template decompose_into< SuperLattices > _sLattices
std::size_t _itBoundaryUpdate
virtual void prepareGeometry()=0
Define the geometry.
virtual void computeResults(std::size_t iT)
Perform further computations (compute errors etc.)
std::unique_ptr< util::Timer< BaseType< T > > > _timer
auto & lattice(meta::id< KEY >) const
void postSimulation() override
Evaluate results.
virtual void setBoundaryValues(std::size_t iT)=0
Update fields and boundary values.
virtual void computeResults()
static constexpr bool outputVTK
virtual void writeImages(std::size_t iT) const
void initialize() override
Set up geometry.
virtual void writeVTK(std::size_t iT) const
static constexpr unsigned getNumberStationaryLattices()
static constexpr bool outputGnuplot
std::size_t _itCheckStability
virtual void setInitialValues()=0
Define fields and initialize lattice populations.
class for marking output with some text
Top level namespace for all of OpenLB.
std::function< void()> doPostProcess(std::shared_ptr< SOLVER > solver)
Returns a function that encapsulates the solving process.
typename util::BaseTypeHelper< T >::type BaseType
std::shared_ptr< SOLVER > createLbSolver(XMLreader const &xml)
std::function< T(const std::vector< T > &, unsigned) getCallable)(std::shared_ptr< SOLVER > solver)
Returns a function that encapsulates the solving process.
Mapping between KEYs and instances of type VALUEs.
This class allows calculation and display of various time data including remaining runtime data in cp...