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

#include <navierStokesAdvectionDiffusionCouplingPostProcessor3D.h>

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

Public Member Functions

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

Definition at line 86 of file navierStokesAdvectionDiffusionCouplingPostProcessor3D.h.

Constructor & Destructor Documentation

◆ PhaseFieldCouplingPostProcessor3D()

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

Definition at line 150 of file navierStokesAdvectionDiffusionCouplingPostProcessor3D.hh.

154 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_),
155 _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),
156 _beta(12.0 * surface_tension / interface_thickness), _kappa(1.5 * surface_tension * interface_thickness)
157{
158 this->getName() = "PhaseFieldCouplingPostProcessor3D";
159 tPartner = static_cast<BlockLattice<T,descriptors::D3Q7<descriptors::VELOCITY,descriptors::INTERPHASE_NORMAL>> *>(partners_[0]);
160}
std::string & getName()
read and write access to name

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

Extent of application area (0 for purely local operations)

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 91 of file navierStokesAdvectionDiffusionCouplingPostProcessor3D.h.

92 {
93 return 0;
94 }

◆ extent() [2/2]

template<typename T , typename DESCRIPTOR >
int olb::PhaseFieldCouplingPostProcessor3D< 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 95 of file navierStokesAdvectionDiffusionCouplingPostProcessor3D.h.

96 {
97 return 0;
98 }

◆ process()

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

Execute post-processing step.

Implements olb::PostProcessor3D< T, DESCRIPTOR >.

Definition at line 269 of file navierStokesAdvectionDiffusionCouplingPostProcessor3D.hh.

271{
272 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
273}
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::PhaseFieldCouplingPostProcessor3D< 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 163 of file navierStokesAdvectionDiffusionCouplingPostProcessor3D.hh.

166{
167
168 int newX0, newX1, newY0, newY1, newZ0, newZ1;
169 if ( util::intersect (
170 x0, x1, y0, y1, z0, z1,
171 x0_, x1_, y0_, y1_, z0_, z1_,
172 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
173
174 // generate phi cache
175 auto& phi_cache = blockLattice.template getField<PHI_CACHE>()[0];
176 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
177 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
178 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
179 phi_cache[blockLattice.getCellId(iX,iY,iZ)] = util::max(util::min(tPartner->get(iX,iY,iZ).computeRho(), 1.0), 0.0);
180 }
181 }
182 }
183
184 for (int iX=newX0; iX<=newX1; ++iX) {
185 for (int iY=newY0; iY<=newY1; ++iY) {
186 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
187 T phi = phi_cache[blockLattice.getCellId(iX, iY, iZ)];
188
189 // compute rho from phi
190 T rho = _rho_L + phi * _delta_rho;
191
192 // compute dynamic viscosity
193 T viscosity = _mu_L + phi * (_mu_H - _mu_L);
194
195 // get relaxation time
196 auto tau = blockLattice.get(iX,iY,iZ).template getFieldPointer<descriptors::TAU_EFF>();
197
198 // compute grad phi and laplace phi
199 Vector<T,3> grad_phi;
200 T laplace_phi = 0.0;
201 for (int iPop = 1; iPop < L::q; ++iPop) {
202 int nextX = iX + descriptors::c<L>(iPop,0);
203 int nextY = iY + descriptors::c<L>(iPop,1);
204 int nextZ = iZ + descriptors::c<L>(iPop,2);
205 T neighbor_phi = phi_cache[blockLattice.getCellId(nextX, nextY, nextZ)];
206
207 laplace_phi += (neighbor_phi - phi) * descriptors::t<T,L>(iPop);
208 neighbor_phi *= descriptors::t<T,L>(iPop);
209 grad_phi += neighbor_phi * descriptors::c<L>(iPop);
210 }
211 grad_phi *= descriptors::invCs2<T,L>();
212 laplace_phi *= 2.0 * descriptors::invCs2<T,L>();
213
214 // compute grad rho
215 Vector<T,3> grad_rho = _delta_rho * grad_phi;
216
217 // compute interphase normal, save to external field
218 T norm_grad_phi = util::max(norm(grad_phi), std::numeric_limits<T>::epsilon());
219 tPartner->get(iX,iY,iZ).template setField<descriptors::INTERPHASE_NORMAL>(grad_phi / norm_grad_phi);
220
221 // compute _forces (F_s, F_b, F_p, F_nu)
222 // F_s (surface tension)
223 T chemical_potential = (4.0 * _beta * (phi - 0.0) * (phi - 0.5) * (phi - 1.0)) - _kappa * laplace_phi;
224 Vector<T,3> surface_tension_force = chemical_potential * grad_phi;
225
226 // F_b (body force, e.g. bouyancy)
227 Vector<T,3> body_force;
228
229 // F_p (pressure)
230 T pressure = blockLattice.get(iX,iY,iZ).computeRho();
231 Vector<T,3> pressure_force = -pressure / descriptors::invCs2<T,L>() * grad_rho;
232
233 // F_nu (viscous)
234 Vector<T,3> viscous_force;
235 T rho_tmp, u_tmp[3];
236 blockLattice.get(iX,iY,iZ).computeRhoU( rho_tmp, u_tmp );
237 T p_tmp = rho_tmp / descriptors::invCs2<T,DESCRIPTOR>();
238 T uSqr_tmp = util::normSqr<T,DESCRIPTOR::d>(u_tmp);
239 for (int iPop = 0; iPop < L::q; ++iPop) {
240 T fEq = blockLattice.get(iX,iY,iZ).getDynamics()->computeEquilibrium( iPop, p_tmp, u_tmp );
241 T fNeq = blockLattice.get(iX,iY,iZ)[iPop] - fEq;
242 for (int iD = 0; iD < L::d; ++iD) {
243 for (int jD = 0; jD < L::d; ++jD) {
244 viscous_force[iD] += descriptors::c<L>(iPop,iD) * descriptors::c<L>(iPop,jD) * fNeq * grad_rho[jD];
245 }
246 }
247 }
248 viscous_force *= -viscosity / rho / tau[0] * descriptors::invCs2<T,L>();
249
250 // save force/rho to external field
251 blockLattice.get(iX,iY,iZ).template setField<descriptors::FORCE>(
252 (surface_tension_force + body_force + pressure_force + viscous_force) / rho
253 );
254
255 // compute u, save to external field
256 auto u = tPartner->get(iX,iY,iZ).template getField<descriptors::VELOCITY>();
257 blockLattice.get(iX,iY,iZ).computeU(u.data());
258 tPartner->get(iX,iY,iZ).template setField<descriptors::VELOCITY>(u);
259
260 // compute relaxation time, save to external field
261 tau[0] = viscosity / rho * descriptors::invCs2<T,L>() + 0.5;
262 }
263 }
264 }
265 }
266}
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130
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
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.

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

+ Here is the call graph for this function:

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