Reply To: Issue with Implementing New Features in .h and .hh Files
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Issue with Implementing New Features in .h and .hh Files › Reply To: Issue with Implementing New Features in .h and .hh Files
Hi Adrian
I truly appreciate your help.
I am working on modifying the wetting boundary conditions in my free energy model by replacing the linear potentials (Eq. 24/25/26 from PhysRevE.93.033305) with cubic and quartic potential. the cubic quartic potential include c1 and c2 concentration fractions of fluids 1, 2 ,and 3 .
so C1 and C2 are defined in the file olb-1.7r0/examples/multiComponent/contactAngle3d/contactAngle3d.cpp as follows:
SuperLatticeVelocity3D<T, DESCRIPTOR> velocity(sLattice1);
SuperLatticeDensity3D<T, DESCRIPTOR> rho(sLattice1);
rho.getName() = “rho”;
SuperLatticeDensity3D<T, DESCRIPTOR> phi(sLattice2);
phi.getName() = “phi”;
SuperIdentity3D<T,T> c1 (half*(rho+phi));
c1.getName() = “density-fluid-1”;
SuperIdentity3D<T,T> c2 (half*(rho-phi));
c2.getName() = “density-fluid-2”;
I need to use C1 and C2 inside the : olb-1.7r0/src/boundary/setFreeEnergyWallBoundary3D.hh file, but I’m unsure how to properly set them up there. Do you have any suggestions on how to structure this so I can access them correctly in the .hh?
For the Duplicate issue:
in the src/boundary/setFreeEnergyWallBoundary3D.hh
I noticed some duplicate code, and out of curiosity, I tried deleting one of the identical parts. Surprisingly, this caused an error. I understand it’s not a major issue, but it triggered my curiosity—why would removing an exact duplicate make a difference?
namespace olb {
/// Implementation of a wetting boundary condition for the ternary free energy model, consisting of a BounceBack
/// dynamics and an FreeEnergyWall PostProcessor.
/// \param[in] alpha_ – Parameter related to the interface width. [lattice units]
/// \param[in] kappa1_ – Parameter related to surface tension. [lattice units]
/// \param[in] kappa2_ – Parameter related to surface tension. [lattice units]
/// \param[in] h1_ – Parameter related to resulting contact angle of the boundary. [lattice units]
/// \param[in] h2_ – Parameter related to resulting contact angle of the boundary. [lattice units]
/// \param[in] latticeNumber – determines the number of the free energy lattice to set the boundary accordingly
/// \param[in] modelNumber
////////// SuperLattice Domain /////////////////////////////////////////
///Initialising the Free Energy Wall Boundary on the superLattice domain
template<typename T, typename DESCRIPTOR>
void setFreeEnergyWallBoundary(SuperLattice<T, DESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry, int material,
T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber, int modelNumber)
{
setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material),
alpha, kappa1, kappa2, h1, h2, latticeNumber,modelNumber);
}
//////////////
///Initialising the Free Energy Wall Boundary on the superLattice domain
template<typename T, typename DESCRIPTOR>
void setFreeEnergyWallBoundary(SuperLattice<T, DESCRIPTOR>& sLattice, FunctorPtr<SuperIndicatorF3D<T>>&& indicator,
T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber,int modelNumber)
{
OstreamManager clout(std::cout, “setFreeEnergyWallBoundary”);
bool includeOuterCells = false;
int _overlap = 1;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << “WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials” << std::endl;
}
T addend = 0;
if (latticeNumber==1) {
if (modelNumber==1) {
addend = 1./(alpha*alpha) *( (h1/kappa1) + (h2/kappa2));
}
}
else if (latticeNumber==2) {
if (modelNumber==1) {
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (-h2/kappa2) );
}
}
else if (latticeNumber==3) {
if (modelNumber==1) {
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) );
}
}
for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice.getBlock(iCloc),
indicator->getBlockIndicatorF(iCloc), addend, latticeNumber,modelNumber ,includeOuterCells);
}
/// Adds needed Cells to the Communicator _commBC in SuperLattice
addPoints2CommBC(sLattice, std::forward<decltype(indicator)>(indicator), _overlap);
}
/// Implementation of a wetting boundary condition for the ternary free energy model, consisting of a BounceBack
/// dynamics and an FreeEnergyWall PostProcessor.
/// \param[in] alpha_ – Parameter related to the interface width. [lattice units]
/// \param[in] kappa1_ – Parameter related to surface tension. [lattice units]
/// \param[in] kappa2_ – Parameter related to surface tension. [lattice units]
/// \param[in] kappa3_ – Parameter related to surface tension. [lattice units]
/// \param[in] h1_ – Parameter related to resulting contact angle of the boundary. [lattice units]
/// \param[in] h2_ – Parameter related to resulting contact angle of the boundary. [lattice units]
/// \param[in] h3_ – Parameter related to resulting contact angle of the boundary. [lattice units]
/// \param[in] latticeNumber – determines the number of the free energy lattice to set the boundary accordingly
////////// SuperLattice Domain /////////////////////////////////////////
///Initialising the Free Energy Wall Boundary on the superLattice domain
template<typename T, typename DESCRIPTOR>
void setFreeEnergyWallBoundary(SuperLattice<T, DESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry, int material,
T alpha, T kappa1, T kappa2, T kappa3, T h1, T h2,T h3, int latticeNumber,int modelNumber)
{
setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material),
alpha, kappa1, kappa2, kappa3, h1, h2, h3, latticeNumber,modelNumber);
}
///Initialising the Free Energy Wall Boundary on the superLattice domain
template<typename T, typename DESCRIPTOR>
void setFreeEnergyWallBoundary(SuperLattice<T, DESCRIPTOR>& sLattice, FunctorPtr<SuperIndicatorF3D<T>>&& indicator,
T alpha, T kappa1, T kappa2, T kappa3, T h1, T h2, T h3, int latticeNumber,int modelNumber)
{
OstreamManager clout(std::cout, “setFreeEnergyWallBoundary”);
bool includeOuterCells = false;
int _overlap = indicator->getSuperGeometry().getOverlap();
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << “WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials” << std::endl;
}
T addend = 0;
if (latticeNumber==1) {
if (modelNumber==1) {
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) );
}
}
else if (latticeNumber==2) {
if (modelNumber==1) {
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (-h2/kappa2) );
}
}
else if (latticeNumber==3) {
if (modelNumber==1) {
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) );
}
}
for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice.getBlock(iCloc),
indicator->getBlockIndicatorF(iCloc), addend, latticeNumber, modelNumber, includeOuterCells);
}
/// Adds needed Cells to the Communicator _commBC in SuperLattice
addPoints2CommBC(sLattice, std::forward<decltype(indicator)>(indicator), _overlap);
}
////////// BlockLattice Domain /////////////////////////////////////////