OpenLB 1.7
Loading...
Searching...
No Matches
freeEnergyDynamics.cse.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 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 DYNAMICS_FREE_ENERGY_DYNAMICS_CSE_H
25#define DYNAMICS_FREE_ENERGY_DYNAMICS_CSE_H
26
27
28#ifndef DISABLE_CSE
29
30#include "latticeDescriptors.h"
31
32namespace olb {
33
34namespace collision {
35
36template <typename... FIELDS>
37struct FreeEnergy::type<descriptors::D2Q9<FIELDS...>,momenta::FreeEnergyBulkTuple,equilibria::FreeEnergy> {
38
39template <CONCEPT(MinimalCell) CELL, typename PARAMETERS, typename V=typename CELL::value_t>
40CellStatistic<V> apply(CELL& cell, PARAMETERS& parameters) any_platform
41{
42auto x11 = cell.template getFieldComponent<olb::descriptors::FORCE>(1);
43auto x10 = cell.template getFieldComponent<olb::descriptors::FORCE>(0);
44auto x12 = parameters.template get<olb::descriptors::OMEGA>();
45auto x13 = parameters.template get<olb::collision::FreeEnergy::GAMMA>();
46auto x9 = cell.template getFieldComponent<olb::descriptors::CHEM_POTENTIAL>(0);
47auto x14 = x12 + V{-1};
48auto x15 = cell[0] + cell[1] + cell[2] + cell[3] + cell[4] + cell[5] + cell[6] + cell[7] + cell[8];
49auto x16 = x15 + V{1};
50auto x17 = x10*x10;
51auto x18 = V{1.5}*x17;
52auto x19 = x11*x11;
53auto x20 = V{1.5}*x19;
54auto x21 = x20 + V{-1};
55auto x22 = x18 + x21;
56auto x23 = x15 + V{1};
57auto x24 = -V{3}*x13*x9 + x23;
58auto x25 = V{0.0277777777777778}*x12;
59auto x26 = V{3}*x11;
60auto x27 = -x26;
61auto x28 = x10 - x11;
62auto x29 = -x28;
63auto x30 = V{3}*x10;
64auto x31 = x22 + x30;
65auto x32 = x24*x25;
66auto x33 = V{0.111111111111111}*x12;
67auto x34 = x24*x33;
68auto x35 = x10 + x11;
69auto x36 = V{4.5}*(x35*x35);
70auto x37 = V{3}*x19;
71auto x38 = -x18;
72auto x39 = -x20 + x30 + V{1};
73auto x40 = x26 + x38;
74cell[0] = V{0.555555555555556}*x12*x24 - V{0.444444444444444}*x12*(x16*x22 + V{1}) - x14*cell[0];
75cell[1] = -x14*cell[1] - x25*(x16*(x27 + x31 - V{4.5}*x29*x29) + V{1}) - x32;
76cell[2] = V{0.111111111111111}*x12*(x16*(V{3}*x17 - x21 - x30) + V{-1}) - x14*cell[2] - x34;
77cell[3] = -x14*cell[3] - x25*(x16*(x26 + x31 - x36) + V{1}) - x32;
78cell[4] = -x14*cell[4] - x33*(x16*(x18 + x26 - x37 + V{-1}) + V{1}) - x34;
79cell[5] = -x14*cell[5] - x25*(-x16*(x27 + x38 + x39 + V{4.5}*(x28*x28)) + V{1}) - x32;
80cell[6] = V{0.111111111111111}*x12*(x16*(V{3}*x17 + x39) + V{-1}) - x14*cell[6] - x34;
81cell[7] = V{0.0277777777777778}*x12*(x16*(x36 + x39 + x40) + V{-1}) - x14*cell[7] - x32;
82cell[8] = V{0.111111111111111}*x12*(x16*(x37 + x40 + V{1}) + V{-1}) - x14*cell[8] - x34;
83return { x23, x17 + x19 };
84}
85
86};
87
88template <typename... FIELDS>
89struct FreeEnergy::type<descriptors::D3Q19<FIELDS...>,momenta::FreeEnergyBulkTuple,equilibria::FreeEnergy> {
90
91template <CONCEPT(MinimalCell) CELL, typename PARAMETERS, typename V=typename CELL::value_t>
92CellStatistic<V> apply(CELL& cell, PARAMETERS& parameters) any_platform
93{
94auto x21 = cell.template getFieldComponent<olb::descriptors::FORCE>(1);
95auto x22 = cell.template getFieldComponent<olb::descriptors::FORCE>(2);
96auto x23 = parameters.template get<olb::descriptors::OMEGA>();
97auto x24 = parameters.template get<olb::collision::FreeEnergy::GAMMA>();
98auto x19 = cell.template getFieldComponent<olb::descriptors::CHEM_POTENTIAL>(0);
99auto x20 = cell.template getFieldComponent<olb::descriptors::FORCE>(0);
100auto x25 = x23 + V{-1};
101auto x26 = cell[0] + cell[10] + cell[11] + cell[12] + cell[13] + cell[14] + cell[15] + cell[16] + cell[17] + cell[18] + cell[1] + cell[2] + cell[3] + cell[4] + cell[5] + cell[6] + cell[7] + cell[8] + cell[9];
102auto x27 = x26 + V{1};
103auto x28 = x20*x20;
104auto x29 = V{1.5}*x28;
105auto x30 = x21*x21;
106auto x31 = V{1.5}*x30;
107auto x32 = x22*x22;
108auto x33 = V{1.5}*x32;
109auto x34 = x31 + x33 + V{-1};
110auto x35 = x29 + x34;
111auto x36 = x26 + V{1};
112auto x37 = -V{3}*x19*x24 + x36;
113auto x38 = V{0.0555555555555556}*x23;
114auto x39 = V{3}*x20;
115auto x40 = V{3}*x28;
116auto x41 = x37*x38;
117auto x42 = V{3}*x21;
118auto x43 = V{3}*x30;
119auto x44 = x29 + V{-1};
120auto x45 = V{3}*x22;
121auto x46 = V{3}*x32;
122auto x47 = V{0.0277777777777778}*x23;
123auto x48 = x20 + x21;
124auto x49 = V{4.5}*(x48*x48);
125auto x50 = x35 + x39;
126auto x51 = x37*x47;
127auto x52 = -x42;
128auto x53 = x20 - x21;
129auto x54 = -x53;
130auto x55 = x20 + x22;
131auto x56 = V{4.5}*(x55*x55);
132auto x57 = -x45;
133auto x58 = -x22;
134auto x59 = x20 + x58;
135auto x60 = -x59;
136auto x61 = x21 + x22;
137auto x62 = V{4.5}*(x61*x61);
138auto x63 = x35 + x42;
139auto x64 = x21 + x58;
140auto x65 = -x64;
141auto x66 = -x31;
142auto x67 = V{1} - x33;
143auto x68 = x66 + x67;
144auto x69 = x39 + x68;
145auto x70 = -x29;
146auto x71 = x42 + x70;
147auto x72 = x45 + x70;
148auto x73 = -x39;
149auto x74 = x35 + x45;
150cell[0] = V{0.666666666666667}*x23*x37 - V{0.333333333333333}*x23*(x27*x35 + V{1}) - x25*cell[0];
151cell[1] = -x25*cell[1] - x38*(x27*(x34 + x39 - x40) + V{1}) - x41;
152cell[2] = -x25*cell[2] - x38*(x27*(x33 + x42 - x43 + x44) + V{1}) - x41;
153cell[3] = -x25*cell[3] - x38*(x27*(x31 + x44 + x45 - x46) + V{1}) - x41;
154cell[4] = -x25*cell[4] - x47*(x27*(x42 - x49 + x50) + V{1}) - x51;
155cell[5] = -x25*cell[5] - x47*(x27*(x50 + x52 - V{4.5}*x54*x54) + V{1}) - x51;
156cell[6] = -x25*cell[6] - x47*(x27*(x45 + x50 - x56) + V{1}) - x51;
157cell[7] = -x25*cell[7] - x47*(x27*(x50 + x57 - V{4.5}*x60*x60) + V{1}) - x51;
158cell[8] = -x25*cell[8] - x47*(x27*(x45 - x62 + x63) + V{1}) - x51;
159cell[9] = -x25*cell[9] - x47*(x27*(x57 + x63 - V{4.5}*x65*x65) + V{1}) - x51;
160cell[10] = V{0.0555555555555556}*x23*(x27*(x40 + x69) + V{-1}) - x25*cell[10] - x41;
161cell[11] = V{0.0555555555555556}*x23*(x27*(x43 + x67 + x71) + V{-1}) - x25*cell[11] - x41;
162cell[12] = V{0.0555555555555556}*x23*(x27*(x46 + x66 + x72 + V{1}) + V{-1}) - x25*cell[12] - x41;
163cell[13] = V{0.0277777777777778}*x23*(x27*(x49 + x69 + x71) + V{-1}) - x25*cell[13] - x51;
164cell[14] = -x25*cell[14] - x47*(x27*(x63 + x73 - V{4.5}*x53*x53) + V{1}) - x51;
165cell[15] = V{0.0277777777777778}*x23*(x27*(x56 + x69 + x72) + V{-1}) - x25*cell[15] - x51;
166cell[16] = -x25*cell[16] - x47*(x27*(x73 + x74 - V{4.5}*x59*x59) + V{1}) - x51;
167cell[17] = V{0.0277777777777778}*x23*(x27*(x45 + x62 + x68 + x71) + V{-1}) - x25*cell[17] - x51;
168cell[18] = -x25*cell[18] - x47*(x27*(x52 + x74 - V{4.5}*x64*x64) + V{1}) - x51;
169return { x36, x28 + x30 + x32 };
170}
171
172};
173
174
175
176}
177
178}
179
180#endif
181
182#endif
Descriptor for all types of 2D and 3D lattices.
Tuple< BulkDensity, FreeEnergyMomentum, BulkStress, DefineToNEq > FreeEnergyBulkTuple
Definition aliases.h:224
Top level namespace for all of OpenLB.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
CellStatistic< V > apply(CELL &cell, PARAMETERS &parameters) any_platform
typename meta::list< descriptors::OMEGA, GAMMA > parameters