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

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

#include <freeEnergyPostProcessor2D.h>

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

Public Member Functions

 FreeEnergyChemicalPotentialCoupling2D (int x0_, int x1_, int y0_, int y1_, T alpha_, T kappa1_, T kappa2_, T kappa3_, std::vector< BlockStructureD< 2 > * > partners_)
 
 FreeEnergyChemicalPotentialCoupling2D (T alpha_, T kappa1_, T kappa2_, T kappa3_, std::vector< BlockStructureD< 2 > * > 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_) override
 Execute post-processing step on a sublattice.
 
- Public Member Functions inherited from olb::PostProcessor2D< T, DESCRIPTOR >
 PostProcessor2D ()
 
virtual ~PostProcessor2D ()
 
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::PostProcessor2D< T, DESCRIPTOR >
int _priority
 

Detailed Description

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

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

Definition at line 47 of file freeEnergyPostProcessor2D.h.

Constructor & Destructor Documentation

◆ FreeEnergyChemicalPotentialCoupling2D() [1/2]

template<typename T , typename DESCRIPTOR >
olb::FreeEnergyChemicalPotentialCoupling2D< T, DESCRIPTOR >::FreeEnergyChemicalPotentialCoupling2D ( int x0_,
int x1_,
int y0_,
int y1_,
T alpha_,
T kappa1_,
T kappa2_,
T kappa3_,
std::vector< BlockStructureD< 2 > * > 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 freeEnergyPostProcessor2D.hh.

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

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

+ Here is the call graph for this function:

◆ FreeEnergyChemicalPotentialCoupling2D() [2/2]

template<typename T , typename DESCRIPTOR >
olb::FreeEnergyChemicalPotentialCoupling2D< T, DESCRIPTOR >::FreeEnergyChemicalPotentialCoupling2D ( T alpha_,
T kappa1_,
T kappa2_,
T kappa3_,
std::vector< BlockStructureD< 2 > * > 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 freeEnergyPostProcessor2D.hh.

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ extent() [1/2]

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

Extent of application area (0 for purely local operations)

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 64 of file freeEnergyPostProcessor2D.h.

65 {
66 return 1;
67 }

◆ extent() [2/2]

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

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

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 68 of file freeEnergyPostProcessor2D.h.

69 {
70 return 1;
71 }

◆ process()

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

Execute post-processing step.

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 171 of file freeEnergyPostProcessor2D.hh.

173{
174 processSubDomain(blockLattice, x0, x1, y0, y1);
175}
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.

◆ processSubDomain()

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

Execute post-processing step on a sublattice.

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 53 of file freeEnergyPostProcessor2D.hh.

55{
56 // If partners.size() == 1: two fluid components
57 // If partners.size() == 2: three fluid components
58 BlockLattice<T,DESCRIPTOR> *partnerLattice1 = static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[0]);
59 BlockLattice<T,DESCRIPTOR> *partnerLattice2 = 0;
60 if (partners.size() > 1) {
61 partnerLattice2 = static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[1]);
62 }
63
64 int newX0, newX1, newY0, newY1;
65 if ( util::intersect ( x0, x1, y0, y1,
66 x0_, x1_, y0_, y1_,
67 newX0, newX1, newY0, newY1 ) ) {
68
69 auto& rhoField = blockLattice.template getField<RHO_CACHE>();
70
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();
74 //std::cout << "iX: " << iX << " - iY: " << iY << " - blockLattice.getCellID: " << blockLattice.getCellId(iX, iY) << std::endl;
75 //std::cout << "rhoField[0][" << blockLattice.getCellId(iX, iY) << "] = " << blockLattice.get(iX,iY).computeRho() << std::endl;
76 }
77
78 //std::cout << "---------------" << std::endl;
79
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();
83 //std::cout << "rhoField[1][" << blockLattice.getCellId(iX, iY) << "] = " << blockLattice.get(iX,iY).computeRho() << std::endl;
84 }
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();
89 }
90 }
91
92 // calculate chemical potential
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)];
99
100 if (partners.size() > 1) {
101 densitySum -= rhoField[2][blockLattice.getCellId(iX, iY)];
102 densityDifference -= rhoField[2][blockLattice.getCellId(iX, iY)];
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)];
111 term3 = kappa3 * rho3 * (rho3 - 1.) * (2.*rho3 - 1.);
112 }
113
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)]
124 );
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)]
135 );
136 T laplaceRho3 = 0.;
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)]
148 );
149 }
150
151 // setting chemical potential to the respective lattices
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 ));
163 }
164 }
165 }
166
167 }
168}
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: