OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR > Class Template Reference

This class calculates the chemical potential and stores it in the external field of the respective lattice. More...

#include <freeEnergyPostProcessor3D.h>

+ Inheritance diagram for olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >:
+ Collaboration diagram for olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >:

Public Member Functions

 FreeEnergyChemicalPotentialCoupling3D (int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, T alpha_, T kappa1_, T kappa2_, T kappa3_, std::vector< BlockStructureD< 3 > * > partners_)
 
 FreeEnergyChemicalPotentialCoupling3D (T alpha_, T kappa1_, T kappa2_, T kappa3_, std::vector< BlockStructureD< 3 > * > partners_)
 
int extent () const override
 Extent of application area (0 for purely local operations)
 
int extent (int whichDirection) const override
 Extent of application area along a direction (0 or 1)
 
void process (BlockLattice< T, DESCRIPTOR > &blockLattice) override
 Execute post-processing step.
 
void processSubDomain (BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) override
 Execute post-processing step on a sublattice.
 
- Public Member Functions inherited from olb::PostProcessor3D< T, DESCRIPTOR >
 PostProcessor3D ()
 
virtual ~PostProcessor3D ()
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
int getPriority () const
 read only access to priority
 

Additional Inherited Members

- Protected Attributes inherited from olb::PostProcessor3D< T, DESCRIPTOR >
int _priority
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >

This class calculates the chemical potential and stores it in the external field of the respective lattice.

Definition at line 41 of file freeEnergyPostProcessor3D.h.

Constructor & Destructor Documentation

◆ FreeEnergyChemicalPotentialCoupling3D() [1/2]

template<typename T , typename DESCRIPTOR >
olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >::FreeEnergyChemicalPotentialCoupling3D ( int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_,
T alpha_,
T kappa1_,
T kappa2_,
T kappa3_,
std::vector< BlockStructureD< 3 > * > partners_ )
Parameters
[in]alpha_- Parameter related to the interface width. [lattice units]
[in]kappa1_- Parameter related to the surface tension (needs to be >0). [lattice units]
[in]kappa2_- Parameter related to the surface tension (needs to be >0). [lattice units]
[in]kappa3_- Parameter related to the surface tension (needs to be >0). [lattice units]
[in]partners_- Contains one partner lattice for two fluid components, or two lattices for three components.

Definition at line 34 of file freeEnergyPostProcessor3D.hh.

37 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_), alpha(alpha_),
38 kappa1(kappa1_), kappa2(kappa2_), kappa3(kappa3_), partners(partners_)
39{
40 this->getName() = "FreeEnergyChemicalPotentialCoupling3D";
41}
std::string & getName()
read and write access to name

References olb::PostProcessor3D< T, DESCRIPTOR >::getName().

+ Here is the call graph for this function:

◆ FreeEnergyChemicalPotentialCoupling3D() [2/2]

template<typename T , typename DESCRIPTOR >
olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >::FreeEnergyChemicalPotentialCoupling3D ( T alpha_,
T kappa1_,
T kappa2_,
T kappa3_,
std::vector< BlockStructureD< 3 > * > partners_ )
Parameters
[in]alpha_- Parameter related to the interface width. [lattice units]
[in]kappa1_- Parameter related to the surface tension (needs to be >0). [lattice units]
[in]kappa2_- Parameter related to the surface tension (needs to be >0). [lattice units]
[in]kappa3_- Parameter related to the surface tension (needs to be >0). [lattice units]
[in]partners_- Contains one partner lattice for two fluid components, or two lattices for three components.

Definition at line 44 of file freeEnergyPostProcessor3D.hh.

47 : x0(0), x1(0), y0(0), y1(0), z0(0), z1(0), alpha(alpha_),
48 kappa1(kappa1_), kappa2(kappa2_), kappa3(kappa3_), partners(partners_)
49{
50 this->getName() = "FreeEnergyChemicalPotentialCoupling3D";
51}

References olb::PostProcessor3D< T, DESCRIPTOR >::getName().

+ Here is the call graph for this function:

Member Function Documentation

◆ extent() [1/2]

template<typename T , typename DESCRIPTOR >
int olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >::extent ( ) const
inlineoverridevirtual

Extent of application area (0 for purely local operations)

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 58 of file freeEnergyPostProcessor3D.h.

59 {
60 return 1;
61 }

◆ extent() [2/2]

template<typename T , typename DESCRIPTOR >
int olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >::extent ( int direction) const
inlineoverridevirtual

Extent of application area along a direction (0 or 1)

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 62 of file freeEnergyPostProcessor3D.h.

63 {
64 return 1;
65 }

◆ process()

template<typename T , typename DESCRIPTOR >
void olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >::process ( BlockLattice< T, DESCRIPTOR > & blockLattice)
overridevirtual

Execute post-processing step.

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 209 of file freeEnergyPostProcessor3D.hh.

211{
212 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
213}
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) override
Execute post-processing step on a sublattice.

◆ processSubDomain()

template<typename T , typename DESCRIPTOR >
void olb::FreeEnergyChemicalPotentialCoupling3D< T, DESCRIPTOR >::processSubDomain ( BlockLattice< T, DESCRIPTOR > & blockLattice,
int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_ )
overridevirtual

Execute post-processing step on a sublattice.

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 54 of file freeEnergyPostProcessor3D.hh.

57{
58 // If partners.size() == 1: two fluid components
59 // If partners.size() == 2: three fluid components
60 BlockLattice<T,DESCRIPTOR> *partnerLattice1 = static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[0]);
61 BlockLattice<T,DESCRIPTOR> *partnerLattice2 = 0;
62 if (partners.size() > 1) {
63 partnerLattice2 = static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[1]);
64 }
65
66 int newX0, newX1, newY0, newY1, newZ0, newZ1;
67 if ( util::intersect ( x0, x1, y0, y1, z0, z1,
68 x0_, x1_, y0_, y1_, z0, z1,
69 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
70
71 // compute the density fields for each lattice
72 auto& rhoField = blockLattice.template getField<RHO_CACHE>();
73
74 for (int iX=newX0-1; iX<=newX1+1; ++iX)
75 for (int iY=newY0-1; iY<=newY1+1; ++iY)
76 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
77 rhoField[0][blockLattice.getCellId(iX, iY, iZ)] = blockLattice.get(iX,iY,iZ).computeRho();
78 }
79 for (int iX=newX0-1; iX<=newX1+1; ++iX)
80 for (int iY=newY0-1; iY<=newY1+1; ++iY)
81 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
82 rhoField[1][blockLattice.getCellId(iX, iY, iZ)] = partnerLattice1->get(iX,iY,iZ).computeRho();
83 }
84 if (partners.size() > 1) {
85 for (int iX=newX0-1; iX<=newX1+1; ++iX)
86 for (int iY=newY0-1; iY<=newY1+1; ++iY)
87 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
88 rhoField[2][blockLattice.getCellId(iX, iY, iZ)] = partnerLattice2->get(iX,iY,iZ).computeRho();
89 }
90 }
91
92 // calculate chemical potential
93 for (int iX=newX0; iX<=newX1; ++iX) {
94 for (int iY=newY0; iY<=newY1; ++iY) {
95 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
96 T densitySum = rhoField[0][blockLattice.getCellId(iX, iY, iZ)]
97 + rhoField[1][blockLattice.getCellId(iX, iY, iZ)];
98 T densityDifference = rhoField[0][blockLattice.getCellId(iX, iY, iZ)]
99 - rhoField[1][blockLattice.getCellId(iX, iY, iZ)];
100 if (partners.size() > 1) {
101 densitySum -= rhoField[2][blockLattice.getCellId(iX, iY, iZ)];
102 densityDifference -= rhoField[2][blockLattice.getCellId(iX, iY, iZ)];
103 }
104 T term1 = 0.125 * kappa1 * (densitySum)
105 * (densitySum-1.) * (densitySum-2.);
106 T term2 = 0.125 * kappa2 * (densityDifference)
107 * (densityDifference-1.) * (densityDifference-2.);
108 T term3 = 0.;
109 if (partners.size() > 1) {
110 T rho3 = rhoField[2][blockLattice.getCellId(iX, iY, iZ)];
111 term3 = kappa3 * rho3 * (rho3 - 1.) * (2.*rho3 - 1.);
112 }
113
114 T laplaceRho1 = 1.0 / 6.0 * (
115 rhoField[0][blockLattice.getCellId(iX, iY-1, iZ-1)]
116 + rhoField[0][blockLattice.getCellId(iX-1, iY, iZ-1)]
117 + 2. * rhoField[0][blockLattice.getCellId(iX, iY, iZ-1)]
118 + rhoField[0][blockLattice.getCellId(iX+1, iY, iZ-1)]
119 + rhoField[0][blockLattice.getCellId(iX, iY+1, iZ-1)]
120 + rhoField[0][blockLattice.getCellId(iX-1, iY-1, iZ)]
121 + 2. * rhoField[0][blockLattice.getCellId(iX, iY-1, iZ)]
122 + rhoField[0][blockLattice.getCellId(iX+1, iY-1, iZ)]
123 + 2. * rhoField[0][blockLattice.getCellId(iX-1, iY, iZ)]
124 -24. * rhoField[0][blockLattice.getCellId(iX, iY, iZ)]
125 + 2. * rhoField[0][blockLattice.getCellId(iX+1, iY, iZ)]
126 + rhoField[0][blockLattice.getCellId(iX-1, iY+1, iZ)]
127 + 2. * rhoField[0][blockLattice.getCellId(iX, iY+1, iZ)]
128 + rhoField[0][blockLattice.getCellId(iX+1, iY+1, iZ)]
129 + rhoField[0][blockLattice.getCellId(iX, iY-1, iZ+1)]
130 + rhoField[0][blockLattice.getCellId(iX-1, iY, iZ+1)]
131 + 2. * rhoField[0][blockLattice.getCellId(iX, iY, iZ+1)]
132 + rhoField[0][blockLattice.getCellId(iX+1, iY, iZ+1)]
133 + rhoField[0][blockLattice.getCellId(iX, iY+1, iZ+1)]
134 );
135
136 T laplaceRho2 = 1.0 / 6.0 * (
137 rhoField[1][blockLattice.getCellId(iX, iY-1, iZ-1)]
138 + rhoField[1][blockLattice.getCellId(iX-1, iY, iZ-1)]
139 + 2. * rhoField[1][blockLattice.getCellId(iX, iY, iZ-1)]
140 + rhoField[1][blockLattice.getCellId(iX+1, iY, iZ-1)]
141 + rhoField[1][blockLattice.getCellId(iX, iY+1, iZ-1)]
142 + rhoField[1][blockLattice.getCellId(iX-1, iY-1, iZ)]
143 + 2. * rhoField[1][blockLattice.getCellId(iX, iY-1, iZ)]
144 + rhoField[1][blockLattice.getCellId(iX+1, iY-1, iZ)]
145 + 2. * rhoField[1][blockLattice.getCellId(iX-1, iY, iZ)]
146 -24. * rhoField[1][blockLattice.getCellId(iX, iY, iZ)]
147 + 2. * rhoField[1][blockLattice.getCellId(iX+1, iY, iZ)]
148 + rhoField[1][blockLattice.getCellId(iX-1, iY+1, iZ)]
149 + 2. * rhoField[1][blockLattice.getCellId(iX, iY+1, iZ)]
150 + rhoField[1][blockLattice.getCellId(iX+1, iY+1, iZ)]
151 + rhoField[1][blockLattice.getCellId(iX, iY-1, iZ+1)]
152 + rhoField[1][blockLattice.getCellId(iX-1, iY, iZ+1)]
153 + 2. * rhoField[1][blockLattice.getCellId(iX, iY, iZ+1)]
154 + rhoField[1][blockLattice.getCellId(iX+1, iY, iZ+1)]
155 + rhoField[1][blockLattice.getCellId(iX, iY+1, iZ+1)]
156 );
157
158 T laplaceRho3 = 0.;
159 if (partners.size() > 1) {
160 laplaceRho3 = 1.0 / 6.0 * (
161 rhoField[2][blockLattice.getCellId(iX, iY-1, iZ-1)]
162 + rhoField[2][blockLattice.getCellId(iX-1, iY, iZ-1)]
163 + 2. * rhoField[2][blockLattice.getCellId(iX, iY, iZ-1)]
164 + rhoField[2][blockLattice.getCellId(iX+1, iY, iZ-1)]
165 + rhoField[2][blockLattice.getCellId(iX, iY+1, iZ-1)]
166 + rhoField[2][blockLattice.getCellId(iX-1, iY-1, iZ)]
167 + 2. * rhoField[2][blockLattice.getCellId(iX, iY-1, iZ)]
168 + rhoField[2][blockLattice.getCellId(iX+1, iY-1, iZ)]
169 + 2. * rhoField[2][blockLattice.getCellId(iX-1, iY, iZ)]
170 -24. * rhoField[2][blockLattice.getCellId(iX, iY, iZ)]
171 + 2. * rhoField[2][blockLattice.getCellId(iX+1, iY, iZ)]
172 + rhoField[2][blockLattice.getCellId(iX-1, iY+1, iZ)]
173 + 2. * rhoField[2][blockLattice.getCellId(iX, iY+1, iZ)]
174 + rhoField[2][blockLattice.getCellId(iX+1, iY+1, iZ)]
175 + rhoField[2][blockLattice.getCellId(iX, iY-1, iZ+1)]
176 + rhoField[2][blockLattice.getCellId(iX-1, iY, iZ+1)]
177 + 2. * rhoField[2][blockLattice.getCellId(iX, iY, iZ+1)]
178 + rhoField[2][blockLattice.getCellId(iX+1, iY, iZ+1)]
179 + rhoField[2][blockLattice.getCellId(iX, iY+1, iZ+1)]
180 );
181 }
182
183 // setting chemical potential to the respective lattices
184 blockLattice.get(iX,iY,iZ).template setField<descriptors::CHEM_POTENTIAL>(
185 term1 + term2
186 + 0.25*alpha*alpha*( (kappa2 - kappa1) * laplaceRho2
187 +(kappa2 + kappa1) * (laplaceRho3 - laplaceRho1) )
188 );
189 partnerLattice1->get(iX, iY, iZ).template setField<descriptors::CHEM_POTENTIAL>(
190 term1 - term2
191 + 0.25*alpha*alpha*( (kappa2 - kappa1) * (laplaceRho1 - laplaceRho3)
192 -(kappa2 + kappa1) * laplaceRho2 )
193 );
194 if (partners.size() > 1) {
195 partnerLattice2->get(iX, iY, iZ).template setField<descriptors::CHEM_POTENTIAL>(
196 - term1 - term2 + term3
197 + 0.25*alpha*alpha*( (kappa2 + kappa1) * laplaceRho1
198 -(kappa2 - kappa1) * laplaceRho2
199 -(kappa2 + kappa1 + 4.*kappa3) * laplaceRho3 )
200 );
201 }
202 }
203 }
204 }
205 }
206}
bool intersect(int x0, int x1, int y0, int y1, int x0_, int x1_, int y0_, int y1_, int &newX0, int &newX1, int &newY0, int &newY1)
Definition util.h:89

References olb::BlockLattice< T, DESCRIPTOR >::get(), olb::BlockStructureD< D >::getCellId(), and olb::util::intersect().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: