OpenLB 1.7
Loading...
Searching...
No Matches
setFreeEnergyWallBoundary2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Alexander Schulz
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24//This file contains the Free Energy Wall Boundary
25//This is a new version of the Boundary, which only contains free floating functions
26#ifndef SET_FREE_ENERGY_WALL_BOUNDARY_2D_HH
27#define SET_FREE_ENERGY_WALL_BOUNDARY_2D_HH
28
30
31
32namespace olb {
40
42template<typename T, typename DESCRIPTOR>
44 int material, T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber)
45{
46 setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material),
47 alpha, kappa1, kappa2, h1, h2, latticeNumber);
48}
49
51template<typename T, typename DESCRIPTOR>
53 T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber)
54{
55 int _overlap = 1;
56 OstreamManager clout(std::cout, "setFreeEnergyWallBoundary");
57 bool includeOuterCells = false;
58 if (indicator->getSuperGeometry().getOverlap() == 1) {
59 includeOuterCells = true;
60 clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
61 }
62 T addend = 0;
63 if (latticeNumber==1) {
64 addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) );
65 }
66 else if (latticeNumber==2) {
67 addend = 1./(alpha*alpha) * ( (h1/kappa1) + (-h2/kappa2) );
68 }
69 else if (latticeNumber==3) {
70 addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) );
71 }
72 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
73 setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice.getBlock(iCloc),
74 indicator->getBlockIndicatorF(iCloc), addend, latticeNumber, includeOuterCells);
75 }
77 addPoints2CommBC<T,DESCRIPTOR>(sLattice, std::forward<decltype(indicator)>(indicator), _overlap);
78}
79
80
81
82
92
93
95template<typename T, typename DESCRIPTOR>
97 int material, T alpha, T kappa1, T kappa2, T kappa3, T h1, T h2, T h3, int latticeNumber)
98{
99 setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material),
100 alpha, kappa1, kappa2, kappa3, h1, h2, h3, latticeNumber);
101}
102
104template<typename T, typename DESCRIPTOR>
106 T alpha, T kappa1, T kappa2, T kappa3, T h1, T h2, T h3, int latticeNumber)
107{
108
109 int _overlap = indicator->getSuperGeometry().getOverlap();
110 OstreamManager clout(std::cout, "setFreeEnergyWallBoundary");
111 bool includeOuterCells = false;
112 if (indicator->getSuperGeometry().getOverlap() == 1) {
113 includeOuterCells = true;
114 clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
115 }
116 T addend = 0;
117 if (latticeNumber==1) {
118 addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) + (h3/kappa3) );
119 }
120 else if (latticeNumber==2) {
121 addend = 1./(alpha*alpha) * ( (h1/kappa1) + (-h2/kappa2) );
122 }
123 else if (latticeNumber==3) {
124 addend = 1./(alpha*alpha) * ( (h3/kappa3) );
125 }
126 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
127 setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice.getBlock(iCloc),
128 indicator->getBlockIndicatorF(iCloc), addend, latticeNumber, includeOuterCells);
129 }
131 addPoints2CommBC<T,DESCRIPTOR>(sLattice, std::forward<decltype(indicator)>(indicator), _overlap);
132}
133
134
135//set FreeEnergyWallBoundary on block domain.
136//This function works for the setFreeEnergyWallBoundary with h1,h2,h3 Parameters and h1,h2 Parameters
137template<typename T, typename DESCRIPTOR>
139 T addend, int latticeNumber, bool includeOuterCells)
140{
141 using namespace boundaryhelper;
142 OstreamManager clout(std::cout, "setFreeEnergyWallBoundary");
143 auto& blockGeometryStructure = indicator.getBlockGeometry();
144 const int margin = includeOuterCells ? 0 : 1;
145 std::vector<int> discreteNormal(3, 0);
146 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY) {
147 if (blockGeometryStructure.getNeighborhoodRadius({iX, iY}) >= margin
148 && indicator(iX, iY)) {
149 discreteNormal = blockGeometryStructure.getStatistics().getType(iX,iY);
150 if (discreteNormal[1]!=0 || discreteNormal[2]!=0) {
151 if (latticeNumber == 1) {
152 block.template defineDynamics<BounceBackBulkDensity>({iX,iY});
153 }
154 else {
155 block.template defineDynamics<FreeEnergyWallDynamics>({iX,iY});
156 }
157
158 block.addPostProcessor(
159 typeid(stage::PostStream), {iX, iY},
160 promisePostProcessorForNormal<T,DESCRIPTOR,FreeEnergyWallProcessor2D>(
161 Vector<int,2>(discreteNormal.data() + 1)));
162 block.get(iX, iY).template setField<olb::descriptors::ADDEND>(addend);
163
164 if(latticeNumber == 1){
165 block.addPostProcessor(
166 typeid(stage::PostStream), {iX, iY},
167 promisePostProcessorForNormal<T,DESCRIPTOR, FreeEnergyChemPotBoundaryProcessor2DA>(
168 Vector<int,2>(discreteNormal.data() + 1)));
169 } else {
170 block.addPostProcessor(
171 typeid(stage::PostStream), {iX, iY},
172 promisePostProcessorForNormal<T,DESCRIPTOR, FreeEnergyChemPotBoundaryProcessor2DB>(
173 Vector<int,2>(discreteNormal.data() + 1)));
174 }
175
176 }
177 }
178 });
179}
180
181}//namespace olb
182#endif
Base block indicator functor (discrete)
BlockGeometry< T, 2 > & getBlockGeometry()
Get underlying block geometry structure.
Platform-abstracted block lattice for external access and inter-block interaction.
virtual void addPostProcessor(std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Schedule post processor for application to latticeR in stage.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
class for marking output with some text
Representation of a statistic for a parallel 2D geometry.
std::unique_ptr< SuperIndicatorF< T, D > > getMaterialIndicator(std::vector< int > &&materials)
Returns a material indicator using the given vector of materials.
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
void setFreeEnergyWallBoundary(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 2 > &superGeometry, int material, T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber)
Implementation of a wetting boundary condition for the ternary free energy model, consisting of a Bou...
Communication after propagation.
Definition stages.h:36