OpenLB 1.7
Loading...
Searching...
No Matches
shanChenForcedSingleComponentCoupling.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2022 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef SHAN_CHEN_FORCED_SINGLE_COMPONENT_COUPLING_H
25#define SHAN_CHEN_FORCED_SINGLE_COMPONENT_COUPLING_H
26
27#include "core/operator.h"
28
29namespace olb {
30
31
32template <typename T, typename DESCRIPTOR, typename POTENTIAL>
35
36 struct G : public descriptors::FIELD_BASE<1> { };
37 struct RHO0 : public descriptors::FIELD_BASE<1> { };
38 struct OMEGA : public descriptors::FIELD_BASE<1> { };
39
40 using parameters = typename POTENTIAL::parameters::template include<G,RHO0,OMEGA>;
41
42 int getPriority() const {
43 return 0;
44 }
45
46 template <typename CELL, typename PARAMETERS>
47 void apply(CELL& cell, PARAMETERS& parameters) any_platform
48 {
49 using V = typename CELL::value_t;
50 //using DESCRIPTOR = typename CELL::descriptor_t;
51
52 auto j = cell.template getField<descriptors::VELOCITY>();
54 cell.template setField<descriptors::VELOCITY>(j);
55
56 const V g = parameters.template get<G>();
57 const V rho0 = parameters.template get<RHO0>();
58 const V omega = parameters.template get<OMEGA>();
59
60 const V rho = cell.template getFieldComponent<descriptors::STATISTIC>(0) * rho0;
61 // Computation of the common velocity, shared among the two populations
62 const V rhoTot = rho * omega;
63
65 auto u = cell.template getField<descriptors::VELOCITY>();
66 uTot = (u*rho0*omega) / rhoTot;
67
68 // Computation of the interaction potential
69 Vector<V,DESCRIPTOR::d> rhoContribution;
70 const V psi = POTENTIAL().compute(rho, parameters);
71
72 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
73 const V rho_ = cell.neighbor(descriptors::c<DESCRIPTOR>(iPop))
74 .template getFieldComponent<descriptors::STATISTIC>(0)
75 * rho0;
76 const V psi_ = POTENTIAL().compute(rho_, parameters);
77 rhoContribution += psi * psi_
78 * descriptors::c<DESCRIPTOR>(iPop)
79 * descriptors::t<V,DESCRIPTOR>(iPop);
80 }
81
82 // Computation and storage of the final velocity, consisting
83 // of u and the momentum difference due to interaction
84 // potential plus external force
85 auto force = cell.template getField<descriptors::EXTERNAL_FORCE>();
86 cell.template setField<descriptors::VELOCITY>(uTot);
87 cell.template setField<descriptors::FORCE>(force - g*rhoContribution/rho);
88 }
89
90};
91
92
93}
94
95#endif
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
OperatorScope
Block-wide operator application scopes.
Definition operator.h:54
@ PerCellWithParameters
Per-cell application with parameters, i.e. OPERATOR::apply is passed a CELL concept implementation an...
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
void apply(CELL &cell, PARAMETERS &parameters) any_platform
typename POTENTIAL::parameters::template include< G, RHO0, OMEGA > parameters
Base of a field whose size is defined by [C,U_1,...,U_N]^T * [1,V_1,...V_N].
static void computeJ(CELL &cell, J &j) any_platform
Computation of momentum.
Definition lbm.h:197