OpenLB 1.7
Loading...
Searching...
No Matches
fdBoundaryPostProcessors2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2006, 2007 Jonas Latt, Davide Dapelo
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#ifndef FD_NO_PENETRATION_BOUNDARIES_2D_DEV03_HH
25#define FD_NO_PENETRATION_BOUNDARIES_2D_DEV03_HH
26
27namespace olb {
28
29
31
32template<typename T, typename DESCRIPTOR, typename MODEL, typename SCHEME_BOUND, typename PARAMS, typename FIELD, typename SOURCE>
34 : FdBasePostProcessor2D<T,DESCRIPTOR,FIELD,SOURCE>()
35{
36 OLB_PRECONDITION( DESCRIPTOR::template provides<descriptors::NORMAL_X>() );
37 OLB_PRECONDITION( DESCRIPTOR::template provides<descriptors::NORMAL_Y>() );
38}
39
40template<typename T, typename DESCRIPTOR, typename MODEL, typename SCHEME_BOUND, typename PARAMS, typename FIELD, typename SOURCE>
45
46template<typename T, typename DESCRIPTOR, typename MODEL, typename SCHEME_BOUND, typename PARAMS, typename FIELD, typename SOURCE>
47template <typename CELL, typename PARAMETERS>
49{
50 int normalX = (int)( cell.template getField<descriptors::NORMAL_X>() );
51 int normalY = (int)( cell.template getField<descriptors::NORMAL_Y>() );
52 if (normalX!=0 || normalY!=0) { // does absolutely nothing if the cell does not belong to a border
53 constexpr int extraExtent = MODEL::extent() + SCHEME_BOUND::getExtraExtent();
54 std::size_t iT = vars.template get<fd::fdParams::Timestep>();
55 T f[MODEL::extent()*DESCRIPTOR::d], F[MODEL::extent()*DESCRIPTOR::d];
56 T fGhost[MODEL::extent()*DESCRIPTOR::d], fNormal[extraExtent*DESCRIPTOR::d];
57 T u[DESCRIPTOR::d];
58 int normal[] {normalX, normalY};
59 std::fill(std::begin(fGhost), std::end(fGhost), 0);
60 T* fNew = fd::accessNew<T,FIELD>(cell, iT);
61 T* f0 = fd::accessOld<T,FIELD>(cell, iT);
62 for (int iN=1; iN<=extraExtent; ++iN) {
63 fNormal[fd::getArrayPos<extraExtent>(iN-1,0)] = *fd::accessOld<T,FIELD>( cell.neighbor({normalX*iN, 0}), iT );
64 fNormal[fd::getArrayPos<extraExtent>(iN-1,1)] = *fd::accessOld<T,FIELD>( cell.neighbor({ 0, normalY*iN}), iT );
65 }
66 cell.computeU(u);
67 SCHEME_BOUND::apply(fGhost, *f0, fNormal, normal, u, vars);
68 for (int iN=1; iN<=MODEL::extent(); ++iN) {
69 f[fd::getArrayPos<MODEL::extent()>(iN-1,0)] = normalX<=0 ? *fd::accessOld<T,FIELD>( cell.neighbor({-iN, 0}), iT )
70 : fGhost[fd::getArrayPos<MODEL::extent()+SCHEME_BOUND::getExtraExtent()>(iN-1,0)];
71 F[fd::getArrayPos<MODEL::extent()>(iN-1,0)] = normalX>=0 ? *fd::accessOld<T,FIELD>( cell.neighbor({+iN, 0}), iT )
72 : fGhost[fd::getArrayPos<MODEL::extent()+SCHEME_BOUND::getExtraExtent()>(iN-1,0)];
73 f[fd::getArrayPos<MODEL::extent()>(iN-1,1)] = normalY<=0 ? *fd::accessOld<T,FIELD>( cell.neighbor({ 0, -iN}), iT )
74 : fGhost[fd::getArrayPos<MODEL::extent()+SCHEME_BOUND::getExtraExtent()>(iN-1,1)];
75 F[fd::getArrayPos<MODEL::extent()>(iN-1,1)] = normalY>=0 ? *fd::accessOld<T,FIELD>( cell.neighbor({ 0, +iN}), iT )
76 : fGhost[fd::getArrayPos<MODEL::extent()+SCHEME_BOUND::getExtraExtent()>(iN-1,1)];
77 }
78 MODEL::apply(fNew, f0, f, F, u, vars);
79 this->applySourceTerm(fNew, cell);
80 }
81}
82
83
84} // namespace olb
85
86#endif
void apply(CELL &cell, PARAMETERS &vars) any_platform
Top level namespace for all of OpenLB.
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46