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

#include <phaseFieldCoupling.h>

+ Collaboration diagram for olb::WellBalancedCahnHilliardPostProcessor:

Classes

struct  RHOS
 
struct  TAUS
 

Public Types

using parameters = meta::list<TAUS,RHOS>
 

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 597 of file phaseFieldCoupling.h.

Member Typedef Documentation

◆ parameters

Member Function Documentation

◆ apply()

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

Definition at line 608 of file phaseFieldCoupling.h.

609 {
610 using V = typename CELL::template value_t<names::NavierStokes>::value_t;
611 using DESCRIPTOR = typename CELL::template value_t<names::NavierStokes>::descriptor_t;
612
613 auto& cellNS = cells.template get<names::NavierStokes>();
614 auto& cellCH = cells.template get<names::Component1>();
615
616 V phi = cellCH.template getFieldComponent<descriptors::STATISTIC>(0);
617 V mu = cellCH.template getField<descriptors::CHEM_POTENTIAL>();
618 Vector<V,DESCRIPTOR::d> gradPhi{};
620 V laplacePhi = 0;
621 //TODO: use lattice gradient schemes here from Cahn-Hilliard implementation
622 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
623 const V phi_i = cellCH.neighbor(descriptors::c<DESCRIPTOR>(iPop)).template getFieldComponent<descriptors::STATISTIC>(0);
624 const V mu_i = cellCH.neighbor(descriptors::c<DESCRIPTOR>(iPop)).template getField<descriptors::CHEM_POTENTIAL>();
625 //const V phiMu_i = phi_i*mu_i;
626 //gradPhi += phi_i * descriptors::c<DESCRIPTOR>(iPop) * descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
627 //gradMu += mu_i * descriptors::c<DESCRIPTOR>(iPop) * descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
628 if(int(cellCH.neighbor(descriptors::c<DESCRIPTOR>(iPop)).template getField<descriptors::BOUNDARY>())) gradMu += mu * descriptors::c<DESCRIPTOR>(iPop) * descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
630 if(int(cellCH.neighbor(descriptors::c<DESCRIPTOR>(iPop)).template getField<descriptors::BOUNDARY>())) gradPhi += phi * descriptors::c<DESCRIPTOR>(iPop) * descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
632 laplacePhi += 2*(phi_i - phi) * descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
633 }
634
635 auto rho_v = parameters.template get<RHOS>()[0];
636 auto rho_l = parameters.template get<RHOS>()[1];
637 V rho = rho_v + (rho_l-rho_v)*phi;
638 auto tau_v = parameters.template get<TAUS>()[0];
639 auto tau_l = parameters.template get<TAUS>()[1];
640 V tau = tau_v + (tau_l-tau_v)*phi;
641
642 // Computation and storage of forces
643 Vector<V,DESCRIPTOR::d> forceNS{};
644 V u[DESCRIPTOR::d] {};
645 forceNS += -phi*gradMu;
646 //V mu = cellCH.template getField<descriptors::CHEM_POTENTIAL>();
647 //forceNS += mu*gradPhi;
648 auto externalBlockForce = cellNS.template getField<descriptors::EXTERNAL_FORCE>();
649 cellNS.template setField<descriptors::FORCE>(externalBlockForce + forceNS/rho);
650 cellNS.template setField<descriptors::NABLARHO>((rho_l-rho_v)*gradPhi);
651 cellNS.template setField<descriptors::TAU_EFF>(tau);
652 cellNS.template setField<descriptors::RHO>(rho);
653
654 V source{};
655 cellNS.computeU(u);
656 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
657 source += gradPhi[iD]*u[iD];
658 }
659 V source_old = cellCH.template getField<descriptors::SOURCE_OLD>();
660 cellCH.template setField<descriptors::SOURCE>(1.5*source-0.5*source_old);
661 cellCH.template setField<descriptors::SOURCE_OLD>(source);
662 cellCH.template setField<descriptors::VELOCITY>(u);
663 }
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
Vector(T &&t, Ts &&... ts) -> Vector< std::remove_cvref_t< T >, 1+sizeof...(Ts)>

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

+ Here is the call graph for this function:

◆ getPriority()

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

Definition at line 603 of file phaseFieldCoupling.h.

603 {
604 return 0;
605 }

Member Data Documentation

◆ scope

OperatorScope olb::WellBalancedCahnHilliardPostProcessor::scope = OperatorScope::PerCellWithParameters
staticconstexpr

Definition at line 598 of file phaseFieldCoupling.h.


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