60 if (partners.size() > 1) {
64 int newX0, newX1, newY0, newY1;
67 newX0, newX1, newY0, newY1 ) ) {
69 auto& rhoField = blockLattice.template getField<RHO_CACHE>();
71 for (
int iX=newX0-1; iX<=newX1+1; ++iX)
72 for (
int iY=newY0-1; iY<=newY1+1; ++iY) {
73 rhoField[0][blockLattice.
getCellId(iX, iY)] = blockLattice.
get(iX,iY).computeRho();
80 for (
int iX=newX0-1; iX<=newX1+1; ++iX)
81 for (
int iY=newY0-1; iY<=newY1+1; ++iY) {
82 rhoField[1][blockLattice.
getCellId(iX, iY)] = partnerLattice1->
get(iX,iY).computeRho();
85 if (partners.size() > 1) {
86 for (
int iX=newX0-1; iX<=newX1+1; ++iX)
87 for (
int iY=newY0-1; iY<=newY1+1; ++iY) {
88 rhoField[2][blockLattice.
getCellId(iX, iY)] = partnerLattice2->
get(iX,iY).computeRho();
93 for (
int iX=newX0; iX<=newX1; ++iX) {
94 for (
int iY=newY0; iY<=newY1; ++iY) {
95 T densitySum = rhoField[0][blockLattice.
getCellId(iX, iY)]
96 + rhoField[1][blockLattice.
getCellId(iX, iY)];
97 T densityDifference = rhoField[0][blockLattice.
getCellId(iX, iY)]
98 - rhoField[1][blockLattice.
getCellId(iX, iY)];
100 if (partners.size() > 1) {
101 densitySum -= rhoField[2][blockLattice.
getCellId(iX, iY)];
102 densityDifference -= rhoField[2][blockLattice.
getCellId(iX, iY)];
104 T term1 = 0.125 * kappa1 * (densitySum)
105 * (densitySum-1.) * (densitySum-2.);
106 T term2 = 0.125 * kappa2 * (densityDifference)
107 * (densityDifference-1.) * (densityDifference-2.);
109 if (partners.size() > 1) {
110 T rho3 = rhoField[2][blockLattice.
getCellId(iX, iY)];
111 term3 = kappa3 * rho3 * (rho3 - 1.) * (2.*rho3 - 1.);
114 T laplaceRho1 = 0.25 * (
115 rhoField[0][blockLattice.
getCellId(iX-1, iY-1)]
116 + 2. * rhoField[0][blockLattice.
getCellId(iX, iY-1)]
117 + rhoField[0][blockLattice.
getCellId(iX+1, iY-1)]
118 + 2. * rhoField[0][blockLattice.
getCellId(iX-1, iY)]
119 -12. * rhoField[0][blockLattice.
getCellId(iX, iY)]
120 + 2. * rhoField[0][blockLattice.
getCellId(iX+1, iY)]
121 + rhoField[0][blockLattice.
getCellId(iX-1, iY+1)]
122 + 2. * rhoField[0][blockLattice.
getCellId(iX, iY+1)]
123 + rhoField[0][blockLattice.
getCellId(iX+1, iY+1)]
125 T laplaceRho2 = 0.25 * (
126 rhoField[1][blockLattice.
getCellId(iX-1, iY-1)]
127 + 2. * rhoField[1][blockLattice.
getCellId(iX, iY-1)]
128 + rhoField[1][blockLattice.
getCellId(iX+1, iY-1)]
129 + 2. * rhoField[1][blockLattice.
getCellId(iX-1, iY)]
130 -12. * rhoField[1][blockLattice.
getCellId(iX, iY)]
131 + 2. * rhoField[1][blockLattice.
getCellId(iX+1, iY)]
132 + rhoField[1][blockLattice.
getCellId(iX-1, iY+1)]
133 + 2. * rhoField[1][blockLattice.
getCellId(iX, iY+1)]
134 + rhoField[1][blockLattice.
getCellId(iX+1, iY+1)]
137 if (partners.size() > 1) {
138 laplaceRho3 = 0.25 * (
139 rhoField[2][blockLattice.
getCellId(iX-1, iY-1)]
140 + 2. * rhoField[2][blockLattice.
getCellId(iX, iY-1)]
141 + rhoField[2][blockLattice.
getCellId(iX+1, iY-1)]
142 + 2. * rhoField[2][blockLattice.
getCellId(iX-1, iY)]
143 -12. * rhoField[2][blockLattice.
getCellId(iX, iY)]
144 + 2. * rhoField[2][blockLattice.
getCellId(iX+1, iY)]
145 + rhoField[2][blockLattice.
getCellId(iX-1, iY+1)]
146 + 2. * rhoField[2][blockLattice.
getCellId(iX, iY+1)]
147 + rhoField[2][blockLattice.
getCellId(iX+1, iY+1)]
152 blockLattice.
get(iX, iY).template setField<descriptors::CHEM_POTENTIAL>(term1 + term2
153 + 0.25*alpha*alpha*( (kappa2 - kappa1) * laplaceRho2
154 +(kappa2 + kappa1) * (laplaceRho3 - laplaceRho1) ));
155 partnerLattice1->
get(iX, iY).template setField<descriptors::CHEM_POTENTIAL>(term1 - term2
156 + 0.25*alpha*alpha*( (kappa2 - kappa1) * (laplaceRho1 - laplaceRho3)
157 -(kappa2 + kappa1) * laplaceRho2 ));
158 if (partners.size() > 1) {
159 partnerLattice2->
get(iX, iY).template setField<descriptors::CHEM_POTENTIAL>(- term1 - term2 + term3
160 + 0.25*alpha*alpha*( (kappa2 + kappa1) * laplaceRho1
161 -(kappa2 - kappa1) * laplaceRho2
162 -(kappa2 + kappa1 + 4.*kappa3) * laplaceRho3 ));
205 if (partners.size() > 1) {
209 int newX0, newX1, newY0, newY1;
212 newX0, newX1, newY0, newY1) ) {
214 for (
int iX=newX0; iX<=newX1; ++iX) {
215 for (
int iY=newY0; iY<=newY1; ++iY) {
216 T phi = blockLattice.
get(iX,iY).computeRho();
217 T rho = partnerLattice1->
get(iX,iY).computeRho();
218 T gradMuPhiX = 1./12. * ( -blockLattice.
get(iX-1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
219 - 4.* blockLattice.
get(iX-1,iY ).template getField<descriptors::CHEM_POTENTIAL>()
220 - blockLattice.
get(iX-1,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
221 + blockLattice.
get(iX+1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
222 + 4.* blockLattice.
get(iX+1,iY ).template getField<descriptors::CHEM_POTENTIAL>()
223 + blockLattice.
get(iX+1,iY+1).template getField<descriptors::CHEM_POTENTIAL>() );
224 T gradMuPhiY = 1./12. * ( -blockLattice.
get(iX-1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
225 - 4.* blockLattice.
get(iX,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
226 - blockLattice.
get(iX+1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
227 + blockLattice.
get(iX-1,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
228 + 4.* blockLattice.
get(iX,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
229 + blockLattice.
get(iX+1,iY+1).template getField<descriptors::CHEM_POTENTIAL>() );
230 T gradMuRhoX = 1./12. * ( -partnerLattice1->
get(iX-1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
231 - 4.* partnerLattice1->
get(iX-1,iY ).template getField<descriptors::CHEM_POTENTIAL>()
232 - partnerLattice1->
get(iX-1,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
233 + partnerLattice1->
get(iX+1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
234 + 4.* partnerLattice1->
get(iX+1,iY ).template getField<descriptors::CHEM_POTENTIAL>()
235 + partnerLattice1->
get(iX+1,iY+1).template getField<descriptors::CHEM_POTENTIAL>() );
236 T gradMuRhoY = 1./12. * ( -partnerLattice1->
get(iX-1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
237 - 4.* partnerLattice1->
get(iX,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
238 - partnerLattice1->
get(iX+1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
239 + partnerLattice1->
get(iX-1,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
240 + 4.* partnerLattice1->
get(iX,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
241 + partnerLattice1->
get(iX+1,iY+1).template getField<descriptors::CHEM_POTENTIAL>() );
245 if (partners.size() > 1) {
246 psi = partnerLattice2->
get(iX,iY).computeRho();
247 gradMuPsiX = 1./12. * ( -partnerLattice2->
get(iX-1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
248 - 4.* partnerLattice2->
get(iX-1,iY ).template getField<descriptors::CHEM_POTENTIAL>()
249 - partnerLattice2->
get(iX-1,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
250 + partnerLattice2->
get(iX+1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
251 + 4.* partnerLattice2->
get(iX+1,iY ).template getField<descriptors::CHEM_POTENTIAL>()
252 + partnerLattice2->
get(iX+1,iY+1).template getField<descriptors::CHEM_POTENTIAL>() );
253 gradMuPsiY = 1./12. * ( -partnerLattice2->
get(iX-1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
254 - 4.* partnerLattice2->
get(iX,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
255 - partnerLattice2->
get(iX+1,iY-1).template getField<descriptors::CHEM_POTENTIAL>()
256 + partnerLattice2->
get(iX-1,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
257 + 4.* partnerLattice2->
get(iX,iY+1).template getField<descriptors::CHEM_POTENTIAL>()
258 + partnerLattice2->
get(iX+1,iY+1).template getField<descriptors::CHEM_POTENTIAL>() );
261 auto partnerCell = partnerLattice1->
get(iX, iY);
262 partnerCell.template setField<descriptors::FORCE>({
263 -rho*gradMuRhoX - phi*gradMuPhiX - psi*gradMuPsiX,
264 -rho*gradMuRhoY - phi*gradMuPhiY - psi*gradMuPsiY
267 partnerCell.computeU(u);
268 blockLattice.
get(iX, iY).template setField<descriptors::FORCE>(u);
269 if (partners.size() > 1) {
270 partnerLattice2->
get(iX, iY).template setField<descriptors::FORCE>(u);
Interface of 2D post-processing steps.
std::string & getName()
read and write access to name