OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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 82 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 145 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

149 : x0(x0_), x1(x1_), y0(y0_), y1(y1_),
150 _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),
151 _beta(12.0 * surface_tension / interface_thickness), _kappa(1.5 * surface_tension * interface_thickness)
152{
153 this->getName() = "PhaseFieldCouplingPostProcessor2D";
154 tPartner = static_cast<BlockLattice<T,descriptors::D2Q5<descriptors::VELOCITY,descriptors::INTERPHASE_NORMAL>> *>(partners_[0]);
155}
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 87 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

88 {
89 return 0;
90 }

◆ 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 91 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

92 {
93 return 0;
94 }

◆ 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 269 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

271{
272 processSubDomain(blockLattice, x0, x1, y0, y1);
273}
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 158 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

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