OpenLB 1.8.1
Loading...
Searching...
No Matches
setSignedDistanceBoundary2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2024 Tim Bingert
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 Signed Distance Function Boundary
25#ifndef SET_SIGNED_DISTANCE_BOUNDARY_2D_HH
26#define SET_SIGNED_DISTANCE_BOUNDARY_2D_HH
27
29
30namespace olb {
32template<typename T, typename DESCRIPTOR>
34{
35 setSignedDistanceBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material));
36}
37
39template<typename T, typename DESCRIPTOR>
41{
42 int _overlap = 1;
43 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
44 setSignedDistanceBoundary<T,DESCRIPTOR>(sLattice.getBlock(iCloc),indicator->getBlockIndicatorF(iCloc));
45 }
47 auto& communicator = sLattice.getCommunicator(stage::IterativePostProcess());
48 communicator.template requestField<descriptors::PSI>();
49
50 SuperIndicatorBoundaryNeighbor<T,DESCRIPTOR::d> neighborIndicator(std::forward<decltype(indicator)>(indicator), _overlap);
51 communicator.requestOverlap(_overlap, neighborIndicator);
52 communicator.exchangeRequests();
53}
54
56template<typename T, typename DESCRIPTOR>
58{
59 using namespace boundaryhelper;
60 auto& blockGeometryStructure = indicator.getBlockGeometry();
61 const int margin = 1;
62 std::vector<int> discreteNormal(3, 0);
63 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY) {
64 if (blockGeometryStructure.getNeighborhoodRadius({iX, iY}) >= margin
65 && indicator(iX, iY)) {
66 discreteNormal = indicator.getBlockGeometry().getStatistics().getType(iX, iY);
67 T discreteNormalSum=0;
68 for (int iD=0; iD<DESCRIPTOR::d; iD++) {
69 discreteNormalSum += abs(discreteNormal[iD+1]);
70 }
71 if (discreteNormalSum == 0) {
72 block.addPostProcessor(typeid(stage::IterativePostProcess),{iX,iY},meta::id<normGradPsi>{});
73 } else {
74 block.addPostProcessor(typeid(stage::IterativePostProcess),{iX,iY},
75 promisePostProcessorForNormal<T,DESCRIPTOR,normGradPsiBoundary2D>(
76 Vector<int,2>(discreteNormal.data() + 1)));
77 }
78 }
79 });
80}
81
82}//namespace olb
83
84#endif
const BlockGeometryStatistics< T, D > & getStatistics() const
Read only access to the associated block statistic.
Base block indicator functor (discrete)
Definition aliases.h:203
BlockGeometry< T, 2 > & getBlockGeometry()
Get underlying block geometry structure.
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
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.
SuperCommunicator< T, SuperLattice > & getCommunicator(STAGE stage=STAGE())
Return communicator for given communication stage.
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.
Top level namespace for all of OpenLB.
void setSignedDistanceBoundary(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 2 > &superGeometry, int material)
Initialising the setSignedDistanceBoundary function on the superLattice domain.
std::conditional_t< D==2, SuperIndicatorBoundaryNeighbor2D< T >, SuperIndicatorBoundaryNeighbor3D< T > > SuperIndicatorBoundaryNeighbor
Definition aliases.h:297
std::enable_if_t< std::is_arithmetic< T >::type::value, T > abs(T x) any_platform
Definition util.h:464
Identity type to pass non-constructible types as value.
Definition meta.h:79
Communication after solving for another field.
Definition stages.h:40