OpenLB 1.7
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
olb::ChemicalPotentialCoupling2D Struct Reference

#include <freeEnergyCoupling2D.h>

+ Collaboration diagram for olb::ChemicalPotentialCoupling2D:

Classes

struct  ALPHA
 
struct  KAPPA1
 
struct  KAPPA2
 
struct  KAPPA3
 

Public Types

using parameters = meta::list<ALPHA, KAPPA1, KAPPA2, KAPPA3>
 

Public Member Functions

template<typename CELLS , typename PARAMETERS >
void apply (CELLS &cells, PARAMETERS &parameters) any_platform
 

Static Public Attributes

static constexpr OperatorScope scope = OperatorScope::PerCellWithParameters
 

Detailed Description

Definition at line 29 of file freeEnergyCoupling2D.h.

Member Typedef Documentation

◆ parameters

Definition at line 39 of file freeEnergyCoupling2D.h.

Member Function Documentation

◆ apply()

template<typename CELLS , typename PARAMETERS >
void olb::ChemicalPotentialCoupling2D::apply ( CELLS & cells,
PARAMETERS & parameters )
inline

Definition at line 43 of file freeEnergyCoupling2D.h.

43 {
44
45 using V = typename CELLS::template value_t<names::A>::value_t;
46 using DESCRIPTOR = typename CELLS::template value_t<names::A>::descriptor_t;
47
48 // Get the cell of the first lattice
49 auto& cellA = cells.template get<names::A>();
50
51 // Get the cell of the second lattice
52 auto& cellB = cells.template get<names::B>();
53
54 V rhoA = cellA.computeRho();
55 V rhoB = cellB.computeRho();
56
57 V densitySum = rhoA + rhoB;
58 V densityDifference = rhoA - rhoB;
59
60 V kappa1 = parameters.template get<KAPPA1>();
61 V kappa2 = parameters.template get<KAPPA2>();
62
63 V term1 = 0.125 * kappa1 * (densitySum)
64 * (densitySum-1.) * (densitySum-2.);
65
66 V term2 = 0.125 * kappa2 * (densityDifference)
67 * (densityDifference-1.) * (densityDifference-2.);
68
69 V laplaceRho1 = -12.0 * rhoA;
70 V laplaceRho2 = -12.0 * rhoB;
71 V laplaceRho3 = 0.; // Only used in case of three fluids / lattices
72
73 auto alpha = parameters.template get<ALPHA>();
74
75 // Three fluids / lattices involved: A, B, and C
76 if constexpr (CELLS::map_t::keys_t::template contains<names::C>()){
77 // Cell of the third lattice:
78 auto& cellC = cells.template get<names::C>();
79
80 V rhoC = cellC.computeRho();
81
82 densitySum -= rhoC;
83 densityDifference -= rhoC;
84
85 V kappa3 = parameters.template get<KAPPA3>();
86 V term3 = kappa3 * rhoC * (rhoC - 1.) * (2. * rhoC - 1.);
87
88 laplaceRho3 = -12.0 * rhoC;
89
90 /*
91 * The neighbours of the currently looked at cell
92 * (i.e. cell 0) are ordered as following:
93 *
94 * 1 - 8 - 7
95 * | | |
96 * 2 - 0 - 6
97 * | | |
98 * 3 - 4 - 5
99 */
100 for(int iPop=1; iPop<DESCRIPTOR::q; iPop++) {
101
102 auto nextCellA = cellA.neighbor(descriptors::c<DESCRIPTOR>(iPop));
103 auto nextCellB = cellB.neighbor(descriptors::c<DESCRIPTOR>(iPop));
104 auto nextCellC = cellC.neighbor(descriptors::c<DESCRIPTOR>(iPop));
105
106 V rhoA = nextCellA.computeRho();
107 V rhoB = nextCellB.computeRho();
108 V rhoC = nextCellC.computeRho();
109
110 if(iPop % 2 == 0) {
111 laplaceRho1 += (2. * rhoA);
112 laplaceRho2 += (2. * rhoB);
113 laplaceRho3 += (2. * rhoC);
114 } else {
115 laplaceRho1 += rhoA;
116 laplaceRho2 += rhoB;
117 laplaceRho3 += rhoC;
118 }
119 }
120
121 laplaceRho1 *= 0.25;
122 laplaceRho2 *= 0.25;
123 laplaceRho3 *= 0.25;
124
125 cellC.template setField<descriptors::CHEM_POTENTIAL>( - term1 - term2 + term3
126 + 0.25*alpha*alpha*( (kappa2 + kappa1) * laplaceRho1
127 -(kappa2 - kappa1) * laplaceRho2
128 -(kappa2 + kappa1 + 4.*kappa3) * laplaceRho3 ));
129
130
131 } else { // Only 2 fluids / lattices involved: A and B
132
133 for(int iPop=1; iPop<DESCRIPTOR::q; iPop++) {
134
135 auto nextCellA = cellA.neighbor(descriptors::c<DESCRIPTOR>(iPop));
136 auto nextCellB = cellB.neighbor(descriptors::c<DESCRIPTOR>(iPop));
137
138 V rhoA = nextCellA.computeRho();
139 V rhoB = nextCellB.computeRho();
140
141 if(iPop % 2 == 0) {
142 laplaceRho1 += (2. * rhoA);
143 laplaceRho2 += (2. * rhoB);
144 } else {
145 laplaceRho1 += rhoA;
146 laplaceRho2 += rhoB;
147 }
148 }
149
150 laplaceRho1 *= 0.25;
151 laplaceRho2 *= 0.25;
152
153 }
154
155 cellA.template setField<descriptors::CHEM_POTENTIAL>(term1 + term2
156 + 0.25*alpha*alpha*( (kappa2 - kappa1) * laplaceRho2
157 +(kappa2 + kappa1) * (laplaceRho3 - laplaceRho1) ));
158
159 cellB.template setField<descriptors::CHEM_POTENTIAL>(term1 - term2
160 + 0.25*alpha*alpha*( (kappa2 - kappa1) * (laplaceRho1 - laplaceRho3)
161 -(kappa2 + kappa1) * laplaceRho2 ));
162
163 }
meta::list< ALPHA, KAPPA1, KAPPA2, KAPPA3 > parameters

Member Data Documentation

◆ scope

constexpr OperatorScope olb::ChemicalPotentialCoupling2D::scope = OperatorScope::PerCellWithParameters
staticconstexpr

Definition at line 32 of file freeEnergyCoupling2D.h.


The documentation for this struct was generated from the following file: