OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::PhaseFieldCouplingPostProcessor2D< T, DESCRIPTOR > Class Template Reference

#include <navierStokesAdvectionDiffusionCouplingPostProcessor2D.h>

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

Public Member Functions

 PhaseFieldCouplingPostProcessor2D (int x0_, int x1_, int y0_, int y1_, T rho_L, T rho_H, T mu_L, T mu_H, T surface_tension, T interface_thickness, 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::PhaseFieldCouplingPostProcessor2D< T, DESCRIPTOR >

Definition at line 37 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

Constructor & Destructor Documentation

◆ PhaseFieldCouplingPostProcessor2D()

template<typename T , typename DESCRIPTOR >
olb::PhaseFieldCouplingPostProcessor2D< T, DESCRIPTOR >::PhaseFieldCouplingPostProcessor2D ( int x0_,
int x1_,
int y0_,
int y1_,
T rho_L,
T rho_H,
T mu_L,
T mu_H,
T surface_tension,
T interface_thickness,
std::vector< BlockStructureD< 2 > * > partners_ )

Definition at line 40 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

44 : x0(x0_), x1(x1_), y0(y0_), y1(y1_),
45 _rho_L(rho_L), _rho_H(rho_H), _delta_rho(rho_H - rho_L), _mu_L(mu_L), _mu_H(mu_H), _surface_tension(surface_tension), _interface_thickness(interface_thickness),
46 _beta(12.0 * surface_tension / interface_thickness), _kappa(1.5 * surface_tension * interface_thickness)
47{
48 this->getName() = "PhaseFieldCouplingPostProcessor2D";
49 tPartner = static_cast<BlockLattice<T,descriptors::D2Q5<descriptors::VELOCITY,descriptors::INTERPHASE_NORMAL>> *>(partners_[0]);
50}
std::string & getName()
read and write access to name

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::PhaseFieldCouplingPostProcessor2D< T, DESCRIPTOR >::extent ( ) const
inlineoverridevirtual

Extent of application area (0 for purely local operations)

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 42 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

43 {
44 return 0;
45 }

◆ extent() [2/2]

template<typename T , typename DESCRIPTOR >
int olb::PhaseFieldCouplingPostProcessor2D< 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 46 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

47 {
48 return 0;
49 }

◆ process()

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

Execute post-processing step.

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 165 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

167{
168 processSubDomain(blockLattice, x0, x1, y0, y1);
169}
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::PhaseFieldCouplingPostProcessor2D< 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 navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

56{
57
58 int newX0, newX1, newY0, newY1;
59 if ( util::intersect ( x0, x1, y0, y1,
60 x0_, x1_, y0_, y1_,
61 newX0, newX1, newY0, newY1 ) ) {
62
63 // generate phi cache
64 auto& phi_cache = blockLattice.template getField<PHI_CACHE>()[0];
65 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
66 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
67 phi_cache[blockLattice.getCellId(iX,iY)] = util::max(util::min(tPartner->get(iX,iY).computeRho(), 1.0), 0.0);
68 }
69 }
70
71 for (int iX=newX0; iX<=newX1; ++iX) {
72 for (int iY=newY0; iY<=newY1; ++iY) {
73 auto cell = blockLattice.get(iX,iY);
74 auto partnerCell = tPartner->get(iX,iY);
75
76 T phi = phi_cache[blockLattice.getCellId(iX,iY)];
77
78 // compute rho from phi
79 T rho = _rho_L + phi * _delta_rho;
80
81 // compute dynamic viscosity
82 T viscosity = _mu_L + phi * (_mu_H - _mu_L);
83
84 // get relaxation time
85 T tau = cell.template getField<descriptors::TAU_EFF>();
86
87 // compute grad phi and laplace phi
88 Vector<T,L::d> grad_phi(0.0, 0.0);
89 T laplace_phi = 0.0;
90 for (int iPop = 1; iPop < L::q; ++iPop) {
91 int nextX = iX + descriptors::c<L>(iPop,0);
92 int nextY = iY + descriptors::c<L>(iPop,1);
93 T neighbor_phi = phi_cache[blockLattice.getCellId(nextX,nextY)];
94
95 laplace_phi += (neighbor_phi - phi) * descriptors::t<T,L>(iPop);
96
97 neighbor_phi *= descriptors::t<T,L>(iPop);
98 grad_phi += neighbor_phi * descriptors::c<L>(iPop);
99 }
100 grad_phi *= descriptors::invCs2<T,L>();
101 laplace_phi *= 2.0 * descriptors::invCs2<T,L>();
102
103 // compute grad rho
104 Vector<T,L::d> grad_rho(_delta_rho, _delta_rho);
105 grad_rho *= grad_phi;
106
107 // compute interphase normal, save to external field
108 T norm_grad_phi = norm(grad_phi);
109 norm_grad_phi = util::max(norm_grad_phi, std::numeric_limits<T>::epsilon());
110 partnerCell.template setField<descriptors::INTERPHASE_NORMAL>(grad_phi / norm_grad_phi);
111
112 // compute forces (F_s, F_b, F_p, F_nu)
113 // F_s (surface tension)
114 T chemical_potential = (4.0 * _beta * (phi - 0.0) * (phi - 0.5) * (phi - 1.0)) - _kappa * laplace_phi;
115 T surface_tension_force[] = {chemical_potential*grad_phi[0], chemical_potential*grad_phi[1]};
116
117 // F_b (body force, e.g. bouyancy)
118 T body_force[] = {0.0, 0.0};
119
120 // F_p (pressure)
121 T pressure = blockLattice.get(iX,iY).computeRho();
122 T pressure_force[] = {-pressure / descriptors::invCs2<T,L>() * grad_rho[0], -pressure / descriptors::invCs2<T,L>() * grad_rho[1]};
123
124 // F_nu (viscous)
125 T viscous_force[] = {0.0, 0.0};
126 T rho_tmp, u_tmp[2];
127 cell.computeRhoU( rho_tmp, u_tmp );
128 T p_tmp = rho_tmp / descriptors::invCs2<T,DESCRIPTOR>();
129 T uSqr_tmp = util::normSqr<T,DESCRIPTOR::d>(u_tmp);
130 T fEq[DESCRIPTOR::q] { };
131 cell.getDynamics()->computeEquilibrium(cell, p_tmp, u_tmp, fEq);
132 for (int iPop = 0; iPop < L::q; ++iPop) {
133 T fNeq = cell[iPop] - fEq[iPop];
134 for (int iD = 0; iD < L::d; ++iD) {
135 for (int jD = 0; jD < L::d; ++jD) {
136 viscous_force[iD] += descriptors::c<L>(iPop,iD) * descriptors::c<L>(iPop,jD) * fNeq * grad_rho[jD];
137 }
138 }
139 }
140 for (int iD = 0; iD < L::d; ++iD) {
141 viscous_force[iD] *= - viscosity / rho / tau * descriptors::invCs2<T,L>();
142 }
143
144 // save force/rho to external field
145 auto force = cell.template getFieldPointer<descriptors::FORCE>();
146 for (int iD = 0; iD < L::d; ++iD) {
147 force[iD] = (surface_tension_force[iD] + body_force[iD] + pressure_force[iD] + viscous_force[iD]) / rho;
148 }
149
150 // compute u, save to external field
152 cell.computeU(u.data());
153 partnerCell.template setField<descriptors::VELOCITY>(u);
154
155 // compute relaxation time, save to external field
156
157 tau = viscosity / rho * descriptors::invCs2<T,L>() + 0.5;
158 cell.template setField<descriptors::TAU_EFF>(tau);
159 }
160 }
161 }
162}
constexpr T invCs2() any_platform
Definition functions.h:107
constexpr T t(unsigned iPop, tag::CUM) any_platform
Definition cum.h:108
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83
Expr min(Expr a, Expr b)
Definition expr.cpp:249
Expr max(Expr a, Expr b)
Definition expr.cpp:245
auto normSqr(const ARRAY_LIKE &u) any_platform
Compute norm square of a d-dimensional vector.
Definition util.h:145
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:85
Vector(T &&t, Ts &&... ts) -> Vector< std::remove_cvref_t< T >, 1+sizeof...(Ts)>
constexpr T norm(const ScalarVector< T, D, IMPL > &a) any_platform
Euclidean vector norm.

References olb::descriptors::c(), olb::util::intersect(), olb::descriptors::invCs2(), olb::util::max(), olb::util::min(), olb::norm(), olb::util::normSqr(), olb::descriptors::t(), and olb::Vector().

+ Here is the call graph for this function:

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