OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::AllenCahnPostProcessor Struct Reference

#include <phaseFieldCoupling.h>

+ Collaboration diagram for olb::AllenCahnPostProcessor:

Classes

struct  NONLOCALITY
 
struct  RHOS
 
struct  SIGMA
 
struct  TAUS
 
struct  W
 

Public Types

using parameters = meta::list<SIGMA,W,TAUS,RHOS,NONLOCALITY>
 

Public Member Functions

int getPriority () const
 
template<typename CELL , typename PARAMETERS >
void apply (CELL &cells, PARAMETERS &parameters) any_platform
 

Static Public Attributes

static constexpr OperatorScope scope = OperatorScope::PerCellWithParameters
 

Detailed Description

Definition at line 270 of file phaseFieldCoupling.h.

Member Typedef Documentation

◆ parameters

Member Function Documentation

◆ apply()

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

Definition at line 284 of file phaseFieldCoupling.h.

285 {
286 using V = typename CELL::template value_t<names::NavierStokes>::value_t;
287 using DESCRIPTOR = typename CELL::template value_t<names::NavierStokes>::descriptor_t;
288
289 auto& cellNS = cells.template get<names::NavierStokes>();
290 auto& cellAC = cells.template get<names::Component1>();
291
292 V phi = cellAC.template getFieldComponent<descriptors::STATISTIC>(0);
293 Vector<V,DESCRIPTOR::d> gradPhi{};
294 V laplacePhi = 0;
295 //TODO: use lattice gradient schemes here from Cahn-Hilliard implementation
296 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
297 const V phi_i = cellAC.neighbor(descriptors::c<DESCRIPTOR>(iPop)).template getFieldComponent<descriptors::STATISTIC>(0);
299 laplacePhi += 2*(phi_i - phi) * descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
300 }
301
302 auto scale = cellNS.template getField<descriptors::SCALAR>();
303 auto sigma = parameters.template get<SIGMA>()*(0.99*scale+0.01);
304 auto w = parameters.template get<W>();
305 auto rho_v = parameters.template get<RHOS>()[0];
306 auto rho_l = parameters.template get<RHOS>()[1];
307 V rho = rho_v + (rho_l-rho_v)*phi;
308 auto tau_v = parameters.template get<TAUS>()[0];
309 auto tau_l = parameters.template get<TAUS>()[1];
310 V tau = (tau_v + (tau_l-tau_v)*phi);//*(-9.*scale+10.);
311 auto gamma = parameters.template get<NONLOCALITY>();
312 auto tau_mobil = parameters.template get<TAUS>()[2];
313 V M = (tau_mobil-0.5)/descriptors::invCs2<V,DESCRIPTOR>();
314
315 // Computation and storage of forces
316 Vector<V,DESCRIPTOR::d> forceNS{};
317 V u[DESCRIPTOR::d] {};
318 //cellNS.computeU(u);
319 V k = 1.5*sigma*w;
320 V beta = 12*sigma/w;
321 V mu = 4*beta*phi*(phi-1.)*(phi-0.5)-k*laplacePhi;
322 forceNS += mu*gradPhi;
323 auto externalForce = cellNS.template getField<descriptors::EXTERNAL_FORCE>();
324 cellNS.template setField<descriptors::FORCE>(externalForce + forceNS/rho);
325 cellNS.template setField<descriptors::NABLARHO>((rho_l-rho_v)*gradPhi);
326 cellNS.template setField<descriptors::TAU_EFF>(tau);
327 cellNS.template setField<descriptors::RHO>(rho);
328 cellNS.computeU(u);
329
330 V psi = cellAC.template getField<descriptors::PSI>();
331 V interfaceIndicator = 0.;
332 if (util::fabs(psi) < 3.*w) interfaceIndicator = 1;
333 Vector<V,DESCRIPTOR::d> forceAC{};
334 Vector<V,DESCRIPTOR::d> old_phiU{};
337 V gradPhiSqr = 0;
338 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
339 gradPhiSqr += gradPhi[iD]*gradPhi[iD];
340 phiU[iD] = phi*u[iD];
341 }
342 if (gradPhiSqr >= 1e-28) {
343 n += gradPhi/util::sqrt(gradPhiSqr);
344 }
345 old_phiU = cellAC.template getField<descriptors::OLD_PHIU>();
346 cellAC.template setField<descriptors::OLD_PHIU>(phiU);
347 V lambda = 4*phi*(1.-phi)/w;
348 V D_N = 4*beta/k*(interfaceIndicator-1.)*(phi*(phi-1.)*(phi-0.5)-gamma*(1.-phi)*phi);
349 V source_old = cellAC.template getField<descriptors::SOURCE_OLD>();
350 cellAC.template setField<descriptors::SOURCE_OLD>(M*D_N);
351 forceAC += (phiU - old_phiU) + interfaceIndicator*lambda*n/descriptors::invCs2<V,DESCRIPTOR>();
352 cellAC.template setField<descriptors::FORCE>(forceAC);
353 V source = 1.5*M*D_N-0.5*source_old;
354 cellAC.template setField<descriptors::SOURCE>(source);
355 cellAC.template setField<descriptors::VELOCITY>(u);
356 }
platform_constant Fraction M[Q][Q]
Definition mrt.h:57
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
T scale(std::function< T(const Vector< T, D > &)> sdf, const Vector< T, D > &p, T s, const Vector< T, D > &center=(T(0))) any_platform
Function to scale a geometry The object has to be placed in the origin of the coodinate system.
Definition sdf.h:477
Expr sqrt(Expr x)
Definition expr.cpp:225
Expr fabs(Expr x)
Definition expr.cpp:230
Vector(T &&t, Ts &&... ts) -> Vector< std::remove_cvref_t< T >, 1+sizeof...(Ts)>
meta::list< SIGMA, W, TAUS, RHOS, NONLOCALITY > parameters

References olb::descriptors::c(), olb::util::fabs(), olb::descriptors::invCs2(), olb::util::sqrt(), and olb::descriptors::t().

+ Here is the call graph for this function:

◆ getPriority()

int olb::AllenCahnPostProcessor::getPriority ( ) const
inline

Definition at line 279 of file phaseFieldCoupling.h.

279 {
280 return 0;
281 }

Member Data Documentation

◆ scope

OperatorScope olb::AllenCahnPostProcessor::scope = OperatorScope::PerCellWithParameters
staticconstexpr

Definition at line 271 of file phaseFieldCoupling.h.


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