/* This file is part of the OpenLB library
*
* Copyright (C) 2006, 2007 Jonas Latt, Mathias J. Krause
* E-mail contact: info@openlb.net
* The most recent release of OpenLB can be downloaded at
* <http://www.openlb.net/>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/** \file
* A collection of dynamics classes (e.g. BGK) with which a Cell object
* can be instantiated -- header file.
*/
#ifndef LB_DYNAMICS_H
#define LB_DYNAMICS_H
#include "latticeDescriptors.h"
#include "core/util.h"
#include "core/postProcessing.h"
#include "core/latticeStatistics.h"
namespace olb {
template<typename T, typename DESCRIPTOR> class Cell;
/// Interface for the dynamics classes
template<typename T, typename DESCRIPTOR>
struct Dynamics {
/// Destructor: virtual to enable inheritance
virtual ~Dynamics() { }
/// Implementation of the collision step
virtual void collide(Cell<T,DESCRIPTOR>& cell,
LatticeStatistics<T>& statistics_) =0;
/// Compute equilibrium distribution function
virtual T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const;
/// Initialize cell at equilibrium distribution
void iniEquilibrium(Cell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d]);
/// Compute particle density on the cell.
/** \return particle density
*/
virtual T computeRho(Cell<T,DESCRIPTOR> const& cell) const =0;
/// Compute fluid velocity on the cell.
/** \param u fluid velocity
*/
virtual void computeU( Cell<T,DESCRIPTOR> const& cell,
T u[DESCRIPTOR::d] ) const =0;
/// Compute fluid momentum (j=rho*u) on the cell.
/** \param j fluid momentum
*/
virtual void computeJ( Cell<T,DESCRIPTOR> const& cell,
T j[DESCRIPTOR::d] ) const =0;
/// Compute components of the stress tensor on the cell.
/** \param pi stress tensor */
virtual void computeStress (
Cell<T,DESCRIPTOR> const& cell,
T rho, const T u[DESCRIPTOR::d],
T pi[util::TensorVal<DESCRIPTOR >::n] ) const =0;
/// Compute fluid velocity and particle density on the cell.
/** \param rho particle density
* \param u fluid velocity
*/
virtual void computeRhoU (
Cell<T,DESCRIPTOR> const& cell,
T& rho, T u[DESCRIPTOR::d]) const =0;
/// Compute all momenta on the cell, up to second order.
/** \param rho particle density
* \param u fluid velocity
* \param pi stress tensor
*/
virtual void computeAllMomenta (
Cell<T,DESCRIPTOR> const& cell,
T& rho, T u[DESCRIPTOR::d],
T pi[util::TensorVal<DESCRIPTOR >::n] ) const =0;
/// Set particle density on the cell.
/** \param rho particle density
*/
virtual void defineRho(Cell<T,DESCRIPTOR>& cell, T rho) =0;
virtual void defineRho(int iPop, T rho);
/// Set fluid velocity on the cell.
/** \param u fluid velocity
*/
virtual void defineU(Cell<T,DESCRIPTOR>& cell,
const T u[DESCRIPTOR::d]) =0;
/// Functions for offLattice Velocity boundary conditions
virtual void setBoundaryIntersection(int iPop, T distance);
virtual bool getBoundaryIntersection(int iPop, T point[DESCRIPTOR::d]);
virtual void defineU(const T u[DESCRIPTOR::d]);
virtual void defineU(int iPop, const T u[DESCRIPTOR::d]);
virtual T getVelocityCoefficient(int iPop);
/// Define fluid velocity and particle density on the cell.
/** \param rho particle density
* \param u fluid velocity
*/
virtual void defineRhoU (
Cell<T,DESCRIPTOR>& cell,
T rho, const T u[DESCRIPTOR::d]) =0;
/// Define all momenta on the cell, up to second order.
/** \param rho particle density
* \param u fluid velocity
* \param pi stress tensor
*/
virtual void defineAllMomenta (
Cell<T,DESCRIPTOR>& cell,
T rho, const T u[DESCRIPTOR::d],
const T pi[util::TensorVal<DESCRIPTOR >::n] ) =0;
/// Get local relaxation parameter of the dynamics
virtual T getOmega() const =0;
/// Set local relaxation parameter of the dynamics
virtual void setOmega(T omega) =0;
};
/// Interface for classes that compute velocity momenta
/** This class is useful for example to distinguish between bulk and
<