OpenLB 1.7
Loading...
Searching...
No Matches
setFreeEnergyWallBoundary3D.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#ifndef SET_FREE_ENERGY_WALL_BOUNDARY_3D_HH
24#define SET_FREE_ENERGY_WALL_BOUNDARY_3D_HH
25
27
28namespace olb {
37
39
41template<typename T, typename DESCRIPTOR>
43 T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber)
44{
45 setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material),
46 alpha, kappa1, kappa2, h1, h2, latticeNumber);
47
48}
49
51template<typename T, typename DESCRIPTOR>
53 T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber)
54{
55 OstreamManager clout(std::cout, "setFreeEnergyWallBoundary");
56 bool includeOuterCells = false;
57 int _overlap = 1;
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(sLattice, std::forward<decltype(indicator)>(indicator), _overlap);
78}
79
80
81
82
93
95
97template<typename T, typename DESCRIPTOR>
99 T alpha, T kappa1, T kappa2, T kappa3, T h1, T h2,T h3, int latticeNumber)
100{
101 setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material),
102 alpha, kappa1, kappa2, kappa3, h1, h2, h3, latticeNumber);
103}
104
105
107template<typename T, typename DESCRIPTOR>
109 T alpha, T kappa1, T kappa2, T kappa3, T h1, T h2, T h3, int latticeNumber)
110{
111 OstreamManager clout(std::cout, "setFreeEnergyWallBoundary");
112 bool includeOuterCells = false;
113 int _overlap = indicator->getSuperGeometry().getOverlap();
114 if (indicator->getSuperGeometry().getOverlap() == 1) {
115 includeOuterCells = true;
116 clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
117 }
118 T addend = 0;
119 if (latticeNumber==1) {
120 addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) + (h3/kappa3) );
121 }
122 else if (latticeNumber==2) {
123 addend = 1./(alpha*alpha) * ( (h1/kappa1) + (-h2/kappa2) );
124 }
125 else if (latticeNumber==3) {
126 addend = 1./(alpha*alpha) * ( (h3/kappa3) );
127 }
128 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
129 setFreeEnergyWallBoundary<T,DESCRIPTOR>(sLattice.getBlock(iCloc),
130 indicator->getBlockIndicatorF(iCloc), addend, latticeNumber, includeOuterCells);
131 }
133 addPoints2CommBC(sLattice, std::forward<decltype(indicator)>(indicator), _overlap);
134}
135
137
138
139//set FreeEnergyWallBoundary on block domain.
140//This function works for the setFreeEnergyWallBoundary with h1,h2,h3 Parameters and h1,h2 Parameters
141template<typename T, typename DESCRIPTOR>
143 T addend, int latticeNumber, bool includeOuterCells)
144{
145 using namespace boundaryhelper;
146 OstreamManager clout(std::cout, "setFreeEnergyWallBoundary");
147 const auto& blockGeometryStructure = indicator.getBlockGeometry();
148 const int margin = includeOuterCells ? 0 : 1;
149 std::vector<int> discreteNormal(4, 0);
150 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY, auto iZ) {
151 if (blockGeometryStructure.getNeighborhoodRadius({iX, iY, iZ}) >= margin
152 && indicator(iX, iY, iZ)) {
153 discreteNormal = blockGeometryStructure.getStatistics().getType(iX, iY, iZ, true);
154 if (discreteNormal[1]!=0 || discreteNormal[2]!=0 || discreteNormal[3]!=0) {
155 if (latticeNumber == 1) {
156 _block.template defineDynamics<BounceBackBulkDensity>({iX,iY,iZ});
157 }
158 else {
159 _block.template defineDynamics<FreeEnergyWallDynamics>({iX,iY,iZ});
160 }
161
162 _block.addPostProcessor(
163 typeid(stage::PostStream), {iX, iY, iZ},
164 olb::boundaryhelper::promisePostProcessorForNormal<T,DESCRIPTOR,FreeEnergyWallProcessor3D>(
165 Vector<int,3>(discreteNormal.data() + 1)));
166 _block.get(iX, iY, iZ).template setField<olb::descriptors::ADDEND>(addend);
167
168
169 if(latticeNumber == 1){
170 _block.addPostProcessor(
171 typeid(stage::PostStream), {iX, iY, iZ},
172 promisePostProcessorForNormal<T,DESCRIPTOR,FreeEnergyChemPotBoundaryProcessor3DA>(
173 Vector<int,3>(discreteNormal.data() + 1)));
174 } else {
175 _block.addPostProcessor(
176 typeid(stage::PostStream), {iX, iY, iZ},
177 promisePostProcessorForNormal<T,DESCRIPTOR,FreeEnergyChemPotBoundaryProcessor3DB>(
178 Vector<int,3>(discreteNormal.data() + 1)));
179 }
180
181 }
182 }
183 });
184}
185}//namespace olb
186
187#endif
Base block indicator functor.
BlockGeometry< T, 3 > & 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.
Base indicator functor (discrete)
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 addPoints2CommBC(SuperLattice< T, DESCRIPTOR > &sLattice, FunctorPtr< SuperIndicatorF2D< T > > &&indicator, int _overlap)
Adds needed Cells to the Communicator _commBC in SuperLattice.
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