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

#include <freeEnergyCoupling3D.h>

+ Collaboration diagram for olb::ChemicalPotentialCoupling3D:

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 freeEnergyCoupling3D.h.

Member Typedef Documentation

◆ parameters

Definition at line 39 of file freeEnergyCoupling3D.h.

Member Function Documentation

◆ apply()

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

Definition at line 42 of file freeEnergyCoupling3D.h.

42 {
43
44 using V = typename CELLS::template value_t<names::A>::value_t;
45 using DESCRIPTOR = typename CELLS::template value_t<names::A>::descriptor_t;
46
47 // Get the cell of the first lattice
48 auto& cellA = cells.template get<names::A>();
49
50 // Get the cell of the second lattice
51 auto& cellB = cells.template get<names::B>();
52
53 V rhoA = cellA.computeRho();
54 V rhoB = cellB.computeRho();
55
56 V densitySum = rhoA + rhoB;
57 V densityDifference = rhoA - rhoB;
58
59 V kappa1 = parameters.template get<KAPPA1>();
60 V kappa2 = parameters.template get<KAPPA2>();
61
62 V term1 = 0.125 * kappa1 * (densitySum)
63 * (densitySum-1.) * (densitySum-2.);
64
65 V term2 = 0.125 * kappa2 * (densityDifference)
66 * (densityDifference-1.) * (densityDifference-2.);
67
68
69 V term3 = 0.;
70
71
72 V laplaceRho1 = -24.0 * rhoA;
73 V laplaceRho2 = -24.0 * rhoB;
74 V laplaceRho3 = 0;
75
76 for(int iPop=1; iPop<DESCRIPTOR::q; iPop++) {
77
78 auto nextCellA = cellA.neighbor(descriptors::c<DESCRIPTOR>(iPop));
79 auto nextCellB = cellB.neighbor(descriptors::c<DESCRIPTOR>(iPop));
80
81
82 V nextRhoA = nextCellA.computeRho();
83 V nextRhoB = nextCellB.computeRho();
84
85 if(iPop == 1 || iPop == 2 || iPop == 3 || iPop == 10 || iPop == 11 || iPop == 12) {
86 laplaceRho1 += (2 * nextRhoA);
87 laplaceRho2 += (2 * nextRhoB);
88 } else {
89 laplaceRho1 += nextRhoA;
90 laplaceRho2 += nextRhoB;
91 }
92 }
93
94 laplaceRho1 *= 1.0 / 6.0;
95 laplaceRho2 *= 1.0 / 6.0;
96
97 auto alpha = parameters.template get<ALPHA>();
98
99 cellA.template setField<descriptors::CHEM_POTENTIAL>(term1 + term2
100 + 0.25*alpha*alpha*( (kappa2 - kappa1) * laplaceRho2
101 +(kappa2 + kappa1) * (laplaceRho3 - laplaceRho1) ));
102
103 cellB.template setField<descriptors::CHEM_POTENTIAL>(term1 - term2
104 + 0.25*alpha*alpha*( (kappa2 - kappa1) * (laplaceRho1 - laplaceRho3)
105 -(kappa2 + kappa1) * laplaceRho2 ));
106
107 }
meta::list< ALPHA, KAPPA1, KAPPA2, KAPPA3 > parameters

Member Data Documentation

◆ scope

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

Definition at line 32 of file freeEnergyCoupling3D.h.


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