summaryrefslogtreecommitdiff
path: root/src/boundary/momentaOnBoundaries.h
blob: 46e4035f8eaf765c2bdc47c64ddfbbab2d72fa2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2006, 2007 Jonas Latt
 *  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
 * Implementation of boundary cell dynamics -- header file.
 */
#ifndef MOMENTA_ON_BOUNDARIES_H
#define MOMENTA_ON_BOUNDARIES_H

#include "dynamics/dynamics.h"

namespace olb {

template<typename T, typename DESCRIPTOR> class Cell;

/// Dirichlet condition on velocity and/or pressure
template<typename T, typename DESCRIPTOR>
class DirichletBoundaryMomenta : public Momenta<T,DESCRIPTOR> {
};

template<typename T, typename DESCRIPTOR>
class EquilibriumBM : public DirichletBoundaryMomenta<T,DESCRIPTOR> {
public:
  EquilibriumBM();
  EquilibriumBM( T rho, const T u[DESCRIPTOR::d] );
  T computeRho( Cell<T,DESCRIPTOR> const& cell ) const override;
  void computeU( Cell<T,DESCRIPTOR> const& cell, T u[DESCRIPTOR::d] ) const override;
  void computeJ( Cell<T,DESCRIPTOR> const& cell, T j[DESCRIPTOR::d] ) const override;
  void computeStress( Cell<T,DESCRIPTOR> const& cell, T rho, const T u[DESCRIPTOR::d],
                              T pi[util::TensorVal<DESCRIPTOR >::n] ) const override;
  void defineRho( Cell<T,DESCRIPTOR>& cell, T rho) override;
  void defineU( Cell<T,DESCRIPTOR>& cell, const T u[DESCRIPTOR::d]) override;
  void defineAllMomenta( Cell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d],
                                 const T pi[util::TensorVal<DESCRIPTOR >::n] ) override;
private:
  T _rho;
  T _u[DESCRIPTOR::d];   ///< value of the velocity on the boundary
};

/// Computation of velocity momenta on a velocity boundary
template<typename T, typename DESCRIPTOR, int direction, int orientation>
class VelocityBM : virtual public DirichletBoundaryMomenta<T,DESCRIPTOR> {
public:
  /// Default Constructor: initialization to zero
  VelocityBM();
  /// Constructor with boundary initialization
  VelocityBM(const T u[DESCRIPTOR::d]);

  T computeRho(Cell<T,DESCRIPTOR> const& cell) const override;
  void computeU ( Cell<T,DESCRIPTOR> const& cell, T u[DESCRIPTOR::d] ) const override;
  void computeJ ( Cell<T,DESCRIPTOR> const& cell, T j[DESCRIPTOR::d] ) const override;
  void computeU(T u[DESCRIPTOR::d]) const;
  void defineRho(Cell<T,DESCRIPTOR>& cell, T rho) override ;
  void defineU(Cell<T,DESCRIPTOR>& cell, const T u[DESCRIPTOR::d]) override ;
  void defineU(const T u[DESCRIPTOR::d]);
  void defineAllMomenta( Cell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d],
                                 const T pi[util::TensorVal<DESCRIPTOR >::n] ) override;
private:
  T _u[DESCRIPTOR::d];   ///< value of the velocity on the boundary
};

/// Computation of velocity momenta on a velocity boundary
template<typename T, typename DESCRIPTOR, int direction, int orientation>
class PressureBM : virtual public DirichletBoundaryMomenta<T,DESCRIPTOR> {
public:
  /// Default Constructor: initialization to u=0, rho=1
  PressureBM();
  /// Constructor with boundary initialization
  PressureBM(const T values_[DESCRIPTOR::d]);

  T computeRho(Cell<T,DESCRIPTOR> const& cell) const override;
  T computeRho() const;
  void computeU( Cell<T,DESCRIPTOR> const& cell, T u[DESCRIPTOR::d] ) const override;
  void computeJ( Cell<T,DESCRIPTOR> const& cell, T j[DESCRIPTOR::d] ) const override;
  void defineRho(Cell<T,DESCRIPTOR>& cell, T rho) override;
  void defineRho(T rho);
  void defineU(Cell<T,DESCRIPTOR>& cell, const T u[DESCRIPTOR::d]) override;
  void defineAllMomenta( Cell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d],
                                 const T pi[util::TensorVal<DESCRIPTOR >::n] ) override;
private:
  /// Velocity/Density on boundary.
  /** Contains velocity on the boundary, except for values[direction] that
   * contains a prescription for the density.
   */
  T _values[DESCRIPTOR::d];
};

/// Here, the stress is computed from the particle distribution functions
template<typename T, typename DESCRIPTOR>
class FreeStressBM : virtual public DirichletBoundaryMomenta<T,DESCRIPTOR> {
public:
  void computeStress( Cell<T,DESCRIPTOR> const& cell, T rho, const T u[DESCRIPTOR::d],
                              T pi[util::TensorVal<DESCRIPTOR >::n] ) const override;
};

/// Use special trick to compute u resp. rho, but compute pi from part. distr. functions
template<typename T, typename DESCRIPTOR,
         template <
           typename T_, typename Lattice_,
           int direction_, int orientation_ >
         class HydroBM,
         int direction, int orientation>
class BasicDirichletBM : public FreeStressBM<T, DESCRIPTOR>, public HydroBM<T,DESCRIPTOR,direction,orientation> {
};

/// Computation of the stress tensor for regularized boundary
template<typename T, typename DESCRIPTOR, int direction, int orientation>
class RegularizedBM : virtual public DirichletBoundaryMomenta<T,DESCRIPTOR> {
public:
  /// Stress tensor
  void computeStress( Cell<T,DESCRIPTOR> const& cell, T rho, const T u[DESCRIPTOR::d],
                              T pi[util::TensorVal<DESCRIPTOR >::n] ) const override;
};

/// Regularized velocity boundary node
template<typename T, typename DESCRIPTOR, int direction, int orientation>
class RegularizedVelocityBM : public RegularizedBM<T,DESCRIPTOR,direction,orientation>, public VelocityBM<T,DESCRIPTOR,direction,orientation> {
public:
  RegularizedVelocityBM() { }
  RegularizedVelocityBM(const T u[DESCRIPTOR::d]) : VelocityBM<T,DESCRIPTOR,direction,orientation>(u) {}
};

/// Regularized pressure boundary node
template<typename T, typename DESCRIPTOR, int direction, int orientation>
class RegularizedPressureBM : public RegularizedBM<T,DESCRIPTOR,direction,orientation>, public PressureBM<T,DESCRIPTOR,direction,orientation> {
public:
  RegularizedPressureBM() { }
  RegularizedPressureBM(const T values[DESCRIPTOR::d]) : PressureBM<T,DESCRIPTOR,direction,orientation>(values) { }
};

/// In this class, the velocity is fixed
/**
 * As opposed to VelocityBM, the pressure is however not
 * computed from a special trick on the boundary, but the
 * same way it would be in the bulk.
 */
template<typename T, typename DESCRIPTOR>
class FixedVelocityBM : public Momenta<T,DESCRIPTOR> {
public:
  T computeRho(Cell<T,DESCRIPTOR> const& cell) const override;
  void computeU( Cell<T,DESCRIPTOR> const& cell, T u[DESCRIPTOR::d] ) const override;
  void computeJ( Cell<T,DESCRIPTOR> const& cell, T j[DESCRIPTOR::d] ) const override;
  void computeStress( Cell<T,DESCRIPTOR> const& cell, T rho, const T u[DESCRIPTOR::d],
                              T pi[util::TensorVal<DESCRIPTOR >::n] ) const override;
  void computeRhoU( Cell<T,DESCRIPTOR> const& cell, T& rho, T u[DESCRIPTOR::d]) const override;
  void computeAllMomenta( Cell<T,DESCRIPTOR> const& cell, T& rho, T u[DESCRIPTOR::d],
                                  T pi[util::TensorVal<DESCRIPTOR >::n] ) const override;
  void defineRho(Cell<T,DESCRIPTOR>& cell, T rho) override;
  void defineU(Cell<T,DESCRIPTOR>& cell, const T u[DESCRIPTOR::d]) override;
  void defineRhoU( Cell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d]) override;
  void defineAllMomenta( Cell<T,DESCRIPTOR>& cell,