summaryrefslogtreecommitdiff
path: root/src/dynamics/advectionDiffusionMomenta.hh
blob: 319a87f4d4a25bc744747134800f59b4b61be82d (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
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2008 Orestis Malaspinas, Andrea Parmigiani
 *  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 -- generic implementation.
 */
#ifndef ADVECTION_DIFFUSION_MOMENTA_HH
#define ADVECTION_DIFFUSION_MOMENTA_HH

#include "advectionDiffusionMomenta.h"
#include "lbHelpers.h"

namespace olb {

////////////////////// Class AdvectionDiffusionBulkMomenta //////////////////////////

template<typename T, typename DESCRIPTOR>
T AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::computeRho(Cell<T,DESCRIPTOR> const& cell) const
{
  return lbHelpers<T,DESCRIPTOR>::computeRho(cell);
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::computeU(Cell<T,DESCRIPTOR> const& cell, T u[DESCRIPTOR::d]) const
{
  const T *u_ = cell.template getFieldPointer<descriptors::VELOCITY>();
  for (int iD = 0; iD < DESCRIPTOR::d; ++iD) {
    u[iD] = u_[iD];
  }
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::computeJ(Cell<T,DESCRIPTOR> const& cell, T j[DESCRIPTOR::d]) const
{
  lbHelpers<T,DESCRIPTOR>::computeJ(cell, j);
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::computeStress (
  Cell<T,DESCRIPTOR> const& cell,
  T rho, const T u[DESCRIPTOR::d],
  T pi[util::TensorVal<DESCRIPTOR >::n] ) const
{
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::computeRhoU (
  Cell<T,DESCRIPTOR> const& cell,
  T& rho, T u[DESCRIPTOR::d] ) const
{
  rho = cell.computeRho();
  const T *u_ = cell.template getFieldPointer<descriptors::VELOCITY>();
  for (int iD = 0; iD < DESCRIPTOR::d; ++iD) {
    u[iD] = u_[iD];
  }
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::computeAllMomenta (
  Cell<T,DESCRIPTOR> const& cell,
  T& rho, T u[DESCRIPTOR::d],
  T pi[util::TensorVal<DESCRIPTOR >::n] ) const
{
  rho = cell.computeRho();
  const T *u_ = cell.template getFieldPointer<descriptors::VELOCITY>();
  for (int iD = 0; iD < DESCRIPTOR::d; ++iD) {
    u[iD] = u_[iD];
  }
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::defineRho(Cell<T,DESCRIPTOR>& cell, T rho)
{
  T *u = cell.template getFieldPointer<descriptors::VELOCITY>();
  for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
    cell[iPop] = lbHelpers<T, DESCRIPTOR>::equilibriumFirstOrder( iPop, rho, u );
  }
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::defineU (
  Cell<T,DESCRIPTOR>& cell,
  const T u[DESCRIPTOR::d])
{
  T rho = cell.computeRho();
  T *u_ = cell.template getFieldPointer<descriptors::VELOCITY>();
  for (int iD = 0; iD < DESCRIPTOR::d; ++iD) {
    u_[iD] = u[iD];
  }
  for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
    cell[iPop] = lbHelpers<T, DESCRIPTOR>::equilibriumFirstOrder( iPop, rho, u );
  }
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::defineRhoU (
  Cell<T,DESCRIPTOR>& cell,
  T rho, const T u[DESCRIPTOR::d])
{
  T *u_ = cell.template getFieldPointer<descriptors::VELOCITY>();
  for (int iD = 0; iD < DESCRIPTOR::d; ++iD) {
    u_[iD] = u[iD];
  }
  for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
    cell[iPop] = lbHelpers<T, DESCRIPTOR>::equilibriumFirstOrder( iPop, rho, u );
  }
}

template<typename T, typename DESCRIPTOR>
void AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>::defineAllMomenta (
  Cell<T,DESCRIPTOR>& cell,
  T rho, const T u[DESCRIPTOR::d],
  const T pi[util::TensorVal<DESCRIPTOR >::n] )
{
  T *u_ = cell.template getFieldPointer<descriptors::VELOCITY>();
  for (int iD = 0; iD < DESCRIPTOR::d; ++iD) {
    u_[iD] = u[iD];
  }
  for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
    cell[iPop] = lbHelpers<T, DESCRIPTOR>::equilibriumFirstOrder( iPop, rho, u );
  }
}

/////////////// Singletons //////////////////////////////////

namespace instances {

template<typename T, typename DESCRIPTOR>
AdvectionDiffusionBulkMomenta<T,DESCRIPTOR>& getAdvectionDiffusionBulkMomenta()
{
  static AdvectionDiffusionBulkMomenta<T,DESCRIPTOR> bulkMomentaSingleton;
  return bulkMomentaSingleton;
}
}

}

#endif