OpenLB 1.7
Loading...
Searching...
No Matches
materialSTLBoundary3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
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 MATERIALSTLBOUNDARY3D_HH
25#define MATERIALSTLBOUNDARY3D_HH
26
27#include <set>
29
30namespace olb {
31
32
33
34template<typename T, template<typename U> class PARTICLETYPE>
37 std::set<int> materials,
38 STLreader<T> &stlReader)
39 : Boundary3D<T, PARTICLETYPE>(),
40 _sg(sg),
41 _materials(materials.begin(),materials.end()),
42 _stlReader(stlReader)
43{
44
45}
46/*
47template<typename T, template<typename U> class PARTICLETYPE>
48MaterialBoundary3D<T, PARTICLETYPE>::MaterialBoundary3D(
49 SuperGeometry<T,3>& sg,
50 std::set<int> materials)
51 : Boundary3D<T, PARTICLETYPE>(),
52 _sg(sg),
53 _materials(materials.begin(),materials.end()
54 )
55{
56}
57
58
59
60template<typename T, template<typename U> class PARTICLETYPE>
61void MaterialBoundary3D<T, PARTICLETYPE>::applyBoundary(
62 typename std::deque<PARTICLETYPE<T> >::iterator& p,
63 ParticleSystem3D<T, PARTICLETYPE>& psSys)
64{
65 int latticeR[3] = { 0 };
66 _sg.getCuboidGeometry().get(p->getCuboid()).getFloorLatticeR(latticeR, &p->getPos()[0]);
67 // Read only access to the material numbers of nodes around particle position
68 const BlockGeometry<T,3>& bg = _sg.getBlockGeometry(
69 _sg.getLoadBalancer().loc(p->getCuboid()));
70 // + overlap is because of lower boundaries, latticeR has to be shifted up
71 int iX = latticeR[0];
72 int iY = latticeR[1];
73 int iZ = latticeR[2];
74 for (_matIter = _materials.begin(); _matIter != _materials.end(); _matIter++) {
75 if (bg.get({iX, iY, iZ}) == *_matIter ||
76 bg.get({iX, iY+1, iZ}) == *_matIter ||
77 bg.get({iX, iY, iZ+1}) == *_matIter ||
78 bg.get({iX, iY+1, iZ+1}) == *_matIter ||
79 bg.get({iX+1, iY, iZ}) == *_matIter ||
80 bg.get({iX+1, iY+1, iZ}) == *_matIter ||
81 bg.get({iX+1, iY, iZ+1}) == *_matIter ||
82 bg.get({iX+1, iY+1, iZ+1}) == *_matIter
83 ) {
84 p->setActive(false);
85 return;
86 }
87 }
88}
89
90}*/
91
92template<typename T, template<typename U> class PARTICLETYPE>
94 typename std::deque<PARTICLETYPE<T> >::iterator& p,
96{
97
98 /*Particle3D<T>& particle= &p;
99 auto &position = particle->getPos();
100 std::cout << position << std::endl;*/
101
102 int latticeR[3] = { 0 };
103 _sg.getCuboidGeometry().get(p->getCuboid()).getFloorLatticeR(latticeR, &p->getPos()[0]);
104 //std::cout <<"particle position " << p->getPos()[0] << '\t' << p->getPos()[1] << '\t' << p->getPos()[2] << std::endl;
105 // std::cout << "output stlReader " << _stlReader.signedDistance(Vector<T,3>(p->getPos())) << std::endl;
106
107 // Read only access to the material numbers of nodes around particle position
108
109 const BlockGeometry<T,3>& bg = _sg.getBlockGeometry(
110 _sg.getLoadBalancer().loc(p->getCuboid()));
111 // + overlap is because of lower boundaries, latticeR has to be shifted up
112 int iX = latticeR[0];
113 int iY = latticeR[1];
114 int iZ = latticeR[2];
115 for (_matIter = _materials.begin(); _matIter != _materials.end(); _matIter++) {
116 if (bg.get({iX, iY, iZ}) == *_matIter ||
117 bg.get({iX, iY+1, iZ}) == *_matIter ||
118 bg.get({iX, iY, iZ+1}) == *_matIter ||
119 bg.get({iX, iY+1, iZ+1}) == *_matIter ||
120 bg.get({iX+1, iY, iZ}) == *_matIter ||
121 bg.get({iX+1, iY+1, iZ}) == *_matIter ||
122 bg.get({iX+1, iY, iZ+1}) == *_matIter ||
123 bg.get({iX+1, iY+1, iZ+1}) == *_matIter
124 ) {
125 if(p->getActive()){
126 //std::vector<std::vector<T>> direction//std::cout << "signed function called" << std::endl;
127 //for ( auto i=0; i <
128//if ( std::abs(_stlReader.signedDistance(Vector<T,3>(p->getPos()))) < p->getRad())
129 T distance = 0.;
130 //std::cout <<"new distance function" << std::endl;
131 _stlReader.distance(distance, Vector<T,3>(p->getPos()), p->getVel());
132 if ( std::abs(distance) < p->getRad())
133 {
134 //std::cout << "signed function called ended" << std::endl;
135 p->setActive(false);
136 /*std::cout << "Particle " <<p->getID() << " deposited at material number " << *_matIter << std::endl;
137 std::cout <<"Particle position " << p->getPos()[0] << '\t' << p->getPos()[1] << '\t' << p->getPos()[2] << std::endl;
138 std::cout << "Output stlReader " << std::abs(distance) << std::endl;
139 std::cout << "Particle Radius " << p->getRad() << std::endl;*/
140
141 }
142
143 }
144 //p->setActive(false);
145 return;
146 }
147 }
148}
149
150}
151
152#endif /* MATERIALSTLBOUNDARY3D_HH */
Representation of a block geometry.
std::enable_if_t< sizeof...(L)==D, int > get(L... latticeR) const
Read-only access to a material number.
Prototype for all particle boundaries.
Definition boundary3D.h:43
MaterialSTLBoundary3D(SuperGeometry< T, 3 > &sg)
Constructor.
void applyBoundary(typename std::deque< PARTICLETYPE< T > >::iterator &p, ParticleSystem3D< T, PARTICLETYPE > &psSys) override
Apply the boundary condition.
Representation of a statistic for a parallel 2D geometry.
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.