summaryrefslogtreecommitdiff
path: root/src/particles/boundaries
diff options
context:
space:
mode:
Diffstat (limited to 'src/particles/boundaries')
-rw-r--r--src/particles/boundaries/MakeHeader29
-rw-r--r--src/particles/boundaries/boundaries.h36
-rw-r--r--src/particles/boundaries/boundaries.hh33
-rw-r--r--src/particles/boundaries/boundary3D.cpp34
-rw-r--r--src/particles/boundaries/boundary3D.h57
-rw-r--r--src/particles/boundaries/boundary3D.hh48
-rw-r--r--src/particles/boundaries/boundarySimpleReflection3D.cpp35
-rw-r--r--src/particles/boundaries/boundarySimpleReflection3D.h56
-rw-r--r--src/particles/boundaries/boundarySimpleReflection3D.hh206
-rw-r--r--src/particles/boundaries/materialBoundary3D.cpp34
-rw-r--r--src/particles/boundaries/materialBoundary3D.h84
-rw-r--r--src/particles/boundaries/materialBoundary3D.hh83
-rw-r--r--src/particles/boundaries/module.mk27
-rw-r--r--src/particles/boundaries/periodicBoundary3D.h136
-rwxr-xr-xsrc/particles/boundaries/wireBoundaryForMagP3D.cpp33
-rwxr-xr-xsrc/particles/boundaries/wireBoundaryForMagP3D.h80
-rwxr-xr-xsrc/particles/boundaries/wireBoundaryForMagP3D.hh88
17 files changed, 1099 insertions, 0 deletions
diff --git a/src/particles/boundaries/MakeHeader b/src/particles/boundaries/MakeHeader
new file mode 100644
index 0000000..7918ac8
--- /dev/null
+++ b/src/particles/boundaries/MakeHeader
@@ -0,0 +1,29 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias Krause
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+# <http://www.openlb.net/>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+
+generic :=
+
+precompiled := boundary3D \
+ materialBoundary3D \
+ wireBoundaryForMagP3D \
+ boundarySimpleReflection3D
diff --git a/src/particles/boundaries/boundaries.h b/src/particles/boundaries/boundaries.h
new file mode 100644
index 0000000..9543bbb
--- /dev/null
+++ b/src/particles/boundaries/boundaries.h
@@ -0,0 +1,36 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+/** \file
+ * Groups all the include files for 3D particles boundaries in
+ * the particles boundaries directory.
+ */
+
+#include "boundary3D.h"
+#include "materialBoundary3D.h"
+#include "periodicBoundary3D.h"
+#include "wireBoundaryForMagP3D.h"
+#include "boundarySimpleReflection3D.h"
+
+
+
diff --git a/src/particles/boundaries/boundaries.hh b/src/particles/boundaries/boundaries.hh
new file mode 100644
index 0000000..5560689
--- /dev/null
+++ b/src/particles/boundaries/boundaries.hh
@@ -0,0 +1,33 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2016 Thomas Henn, Mathias J. Krause, Marie-Luise Maier
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+/** \file
+ * Groups all the include files for 3D particles boundaries in
+ * the particles boundaries directory.
+ */
+
+#include "boundary3D.hh"
+#include "materialBoundary3D.hh"
+#include "wireBoundaryForMagP3D.hh"
+#include "boundarySimpleReflection3D.hh"
+
diff --git a/src/particles/boundaries/boundary3D.cpp b/src/particles/boundaries/boundary3D.cpp
new file mode 100644
index 0000000..50efb54
--- /dev/null
+++ b/src/particles/boundaries/boundary3D.cpp
@@ -0,0 +1,34 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2016 Mathias J. Krause, Marie-Luise Maier
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include"particles/particle3D.h"
+#include"particles/particle3D.hh"
+#include"boundary3D.h"
+#include"boundary3D.hh"
+
+namespace olb {
+
+template class Boundary3D<double,Particle3D>;
+template class Boundary3D<double,MagneticParticle3D>;
+
+} // namespace olb
diff --git a/src/particles/boundaries/boundary3D.h b/src/particles/boundaries/boundary3D.h
new file mode 100644
index 0000000..bef74b0
--- /dev/null
+++ b/src/particles/boundaries/boundary3D.h
@@ -0,0 +1,57 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#ifndef BOUNDARY3D_H
+#define BOUNDARY3D_H
+
+#include "particles/particleSystem3D.h"
+#include "particles/particleSystem3D.h"
+#include "io/ostreamManager.h"
+
+namespace olb {
+
+template<typename T, template<typename U> class PARTICLETYPE>
+class ParticleSystem3D;
+
+
+/**
+ * Prototype for all particle boundaries
+ */
+
+template<typename T, template<typename U> class PARTICLETYPE>
+class Boundary3D {
+public:
+ Boundary3D();
+ Boundary3D(Boundary3D<T, PARTICLETYPE>&);
+ Boundary3D(const Boundary3D<T, PARTICLETYPE>&);
+
+ virtual ~Boundary3D() {};
+ virtual void applyBoundary(typename std::deque<PARTICLETYPE<T> >::iterator& p, ParticleSystem3D<T, PARTICLETYPE>& psSys)=0;
+
+protected:
+ mutable OstreamManager clout;
+};
+
+}
+#endif /* BOUNDARY3D_H */
diff --git a/src/particles/boundaries/boundary3D.hh b/src/particles/boundaries/boundary3D.hh
new file mode 100644
index 0000000..6e4951d
--- /dev/null
+++ b/src/particles/boundaries/boundary3D.hh
@@ -0,0 +1,48 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+
+#ifndef BOUNDARY3D_HH
+#define BOUNDARY3D_HH
+
+#include "boundary3D.h"
+
+namespace olb {
+
+template<typename T, template<typename U> class PARTICLETYPE>
+Boundary3D<T, PARTICLETYPE>::Boundary3D(Boundary3D<T, PARTICLETYPE>& f) : clout(f.clout)
+{
+}
+
+template<typename T, template<typename U> class PARTICLETYPE>
+Boundary3D<T, PARTICLETYPE>::Boundary3D(const Boundary3D<T, PARTICLETYPE>& f) : clout(f.clout)
+{
+}
+
+template<typename T, template<typename U> class PARTICLETYPE>
+Boundary3D<T, PARTICLETYPE>::Boundary3D(): clout(std::cout,"Boundary3D")
+{
+}
+
+}
+#endif /* BOUNDARY3D_HH */
diff --git a/src/particles/boundaries/boundarySimpleReflection3D.cpp b/src/particles/boundaries/boundarySimpleReflection3D.cpp
new file mode 100644
index 0000000..faf737a
--- /dev/null
+++ b/src/particles/boundaries/boundarySimpleReflection3D.cpp
@@ -0,0 +1,35 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Robin Trunk, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include"particles/particle3D.h"
+#include"particles/particle3D.hh"
+#include"boundarySimpleReflection3D.h"
+#include"boundarySimpleReflection3D.hh"
+
+namespace olb {
+
+template class SimpleReflectBoundary3D<double,Particle3D>;
+template class SimpleReflectBoundary3D<double,MagneticParticle3D>;
+
+} // namespace olb
+
diff --git a/src/particles/boundaries/boundarySimpleReflection3D.h b/src/particles/boundaries/boundarySimpleReflection3D.h
new file mode 100644
index 0000000..44f7abe
--- /dev/null
+++ b/src/particles/boundaries/boundarySimpleReflection3D.h
@@ -0,0 +1,56 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Robin Trunk, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BOUNDARYSIMPLEREFLECTION3D_H
+#define BOUNDARYSIMPLEREFLECTION3D_H
+
+#include <set>
+#include <math.h>
+#include "geometry/superGeometry3D.h"
+#include "particles/particleSystem3D.h"
+#include "boundary3D.h"
+
+namespace olb {
+
+template<typename T, template<typename U> class PARTICLETYPE>
+class ParticleSystem3D;
+
+template<typename T, template<typename U> class PARTICLETYPE>
+class SimpleReflectBoundary3D : public Boundary3D<T, PARTICLETYPE> {
+
+public:
+ SimpleReflectBoundary3D(T dT, SuperGeometry3D<T>& sg, std::set<int> materials);
+ ~SimpleReflectBoundary3D() override {};
+ void applyBoundary(typename std::deque<PARTICLETYPE<T> >::iterator& p, ParticleSystem3D<T, PARTICLETYPE>& psSys) override;
+
+private:
+ T _dT;
+ SuperGeometry3D<T>& _sg;
+ std::set<int> _materials;
+ std::set<int>::iterator _matIter;
+
+
+};
+
+}
+#endif
diff --git a/src/particles/boundaries/boundarySimpleReflection3D.hh b/src/particles/boundaries/boundarySimpleReflection3D.hh
new file mode 100644
index 0000000..b4d8749
--- /dev/null
+++ b/src/particles/boundaries/boundarySimpleReflection3D.hh
@@ -0,0 +1,206 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Robin Trunk, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BOUNDARYSIMPLEREFLECTION3D_HH
+#define BOUNDARYSIMPLEREFLECTION3D_HH
+
+#include <set>
+#include "boundarySimpleReflection3D.h"
+
+namespace olb {
+
+template<typename T, template<typename U> class PARTICLETYPE>
+SimpleReflectBoundary3D<T, PARTICLETYPE>::SimpleReflectBoundary3D(T dT, SuperGeometry3D<T>& sg, std::set<int> materials) :
+ Boundary3D<T, PARTICLETYPE>(), _dT(dT), _sg(sg), _materials(materials) {
+ _matIter = _materials.begin();
+}
+
+template<typename T, template<typename U> class PARTICLETYPE>
+void SimpleReflectBoundary3D<T, PARTICLETYPE>::applyBoundary(typename std::deque<PARTICLETYPE<T> >::iterator& p, ParticleSystem3D<T, PARTICLETYPE>& psSys) {
+ std::vector<T> oldPos(3,T());
+ oldPos[0] = p->getPos()[0] - _dT * p->getVel()[0];
+ oldPos[1] = p->getPos()[1] - _dT * p->getVel()[1];
+ oldPos[2] = p->getPos()[2] - _dT * p->getVel()[2];
+
+ std::vector<T> line(3,T());
+ line[0] = p->getPos()[0] - oldPos[0];
+ line[1] = p->getPos()[1] - oldPos[1];
+ line[2] = p->getPos()[2] - oldPos[2];
+
+ std::vector<T> reflection(3, T());
+ int latticeR[4] = { 0,0,0,0 };
+ bool outer = false;
+
+ // get material number (Trigger)
+ // TODO: take particle radius into account for collision detection
+ latticeR[0] = p->getCuboid();
+ _sg.getCuboidGeometry().get(latticeR[0]).getLatticeR(&(latticeR[1]),&p->getPos()[0]);
+ int mat = _sg.get(latticeR);
+
+ for (_matIter = _materials.begin(); _matIter != _materials.end();_matIter++) {
+ if (mat == *_matIter) {
+ // compute discrete normal
+ // TODO: rearrange the if to make computation more efficient
+ std::vector<int> normal(3, T());
+ if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2], latticeR[3]) == 1) normal[0] = -1;
+ if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2], latticeR[3]) == 1) normal[0] = 1;
+ if (_sg.get(latticeR[0], latticeR[1], latticeR[2] - 1, latticeR[3]) == 1) normal[1] = -1;
+ if (_sg.get(latticeR[0], latticeR[1], latticeR[2] + 1, latticeR[3]) == 1) normal[1] = 1;
+ if (_sg.get(latticeR[0], latticeR[1], latticeR[2], latticeR[3] - 1) == 1) normal[2] = -1;
+ if (_sg.get(latticeR[0], latticeR[1], latticeR[2], latticeR[3] + 1) == 1) normal[2] = 1;
+
+ if (normal[0]==0 && normal[1]==0 && normal[2]==0) {
+ outer = true;
+ // check for outer edge
+ if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] - 1, latticeR[3]) == 1) {
+ normal[0] = -1;
+ normal[1] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] + 1, latticeR[3]) == 1) {
+ normal[0] = -1;
+ normal[1] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] - 1, latticeR[3]) == 1) {
+ normal[0] = 1;
+ normal[1] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] + 1, latticeR[3]) == 1) {
+ normal[0] = 1;
+ normal[1] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2], latticeR[3] - 1) == 1) {
+ normal[0] = -1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2], latticeR[3] + 1) == 1) {
+ normal[0] = -1;
+ normal[2] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2], latticeR[3] - 1) == 1) {
+ normal[0] = 1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2], latticeR[3] + 1) == 1) {
+ normal[0] = 1;
+ normal[2] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] - 1, latticeR[3] - 1) == 1) {
+ normal[1] = -1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] - 1, latticeR[3] + 1) == 1) {
+ normal[1] = -1;
+ normal[2] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] + 1, latticeR[3] - 1) == 1) {
+ normal[1] = +1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] + 1, latticeR[3] + 1) == 1) {
+ normal[1] = +1;
+ normal[2] = 1;
+ }
+ // check for outer corner
+ else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] - 1, latticeR[3] - 1) == 1) {
+ normal[0] = -1;
+ normal[1] = -1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] - 1, latticeR[3] + 1) == 1) {
+ normal[0] = -1;
+ normal[1] = -1;
+ normal[2] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] + 1, latticeR[3] - 1) == 1) {
+ normal[0] = -1;
+ normal[1] = +1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] + 1, latticeR[3] + 1) == 1) {
+ normal[0] = -1;
+ normal[1] = +1;
+ normal[2] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] - 1, latticeR[3] - 1) == 1) {
+ normal[0] = +1;
+ normal[1] = -1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] - 1, latticeR[3] + 1) == 1) {
+ normal[0] = +1;
+ normal[1] = -1;
+ normal[2] = 1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] + 1, latticeR[3] - 1) == 1) {
+ normal[0] = +1;
+ normal[1] = +1;
+ normal[2] = -1;
+ }
+ else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] + 1, latticeR[3] + 1) == 1) {
+ normal[0] = +1;
+ normal[1] = +1;
+ normal[2] = 1;
+ }
+ // Error since normal is still zero
+ else {
+ std::cout << "----->>>>> ERROR Normal is ZERO" << std::endl;
+ outer=false;
+ }
+ }
+
+ T prod = line[0]*normal[0] + line[1]*normal[1] + line[2]*normal[2];
+ // if particle has obtuse angle to normal do nothing
+ if (!outer) {
+ if (prod >= 0) {
+ return;
+ }
+ }
+
+ // if particle has acute angle to normal reverse normal component of velocity
+ T invNormNormal = 1. / util::norm2(normal);
+ reflection[0] = line[0] - 2.*prod*normal[0]*invNormNormal;
+ reflection[1] = line[1] - 2.*prod*normal[1]*invNormNormal;
+ reflection[2] = line[2] - 2.*prod*normal[2]*invNormNormal;
+
+ // compute new velocity vector
+ T vel = util::norm(p->getVel());
+ reflection = util::normalize(reflection);
+ reflection[0] = reflection[0]*vel;
+ reflection[1] = reflection[1]*vel;
+ reflection[2] = reflection[2]*vel;
+
+ // TODO: take distance to impact point into account, not just 0.5
+ oldPos[0] += 0.5 * (line[0] + reflection[0]) * _dT;
+ oldPos[1] += 0.5 * (line[1] + reflection[1]) * _dT;
+ oldPos[2] += 0.5 * (line[2] + reflection[2]) * _dT;
+
+ p->getVel() = reflection;
+ p->setPos(oldPos);
+
+ return;
+ }
+ }
+}
+
+}
+#endif
diff --git a/src/particles/boundaries/materialBoundary3D.cpp b/src/particles/boundaries/materialBoundary3D.cpp
new file mode 100644
index 0000000..e08eec0
--- /dev/null
+++ b/src/particles/boundaries/materialBoundary3D.cpp
@@ -0,0 +1,34 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2016 Mathias J. Krause, Marie-Luise Maier
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include"particles/particle3D.h"
+#include"particles/particle3D.hh"
+#include"materialBoundary3D.h"
+#include"materialBoundary3D.hh"
+
+namespace olb {
+
+template class MaterialBoundary3D<double,Particle3D>;
+template class MaterialBoundary3D<double,MagneticParticle3D>;
+
+} // namespace olb
diff --git a/src/particles/boundaries/materialBoundary3D.h b/src/particles/boundaries/materialBoundary3D.h
new file mode 100644
index 0000000..2c4267b
--- /dev/null
+++ b/src/particles/boundaries/materialBoundary3D.h
@@ -0,0 +1,84 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MATERIALBOUNDARY3D_H
+#define MATERIALBOUNDARY3D_H
+
+#include <set>
+
+#include "geometry/superGeometry3D.h"
+#include "particles/particleSystem3D.h"
+#include "boundary3D.h"
+
+namespace olb {
+
+template<typename T, template<typename U> class PARTICLETYPE>
+class ParticleSystem3D;
+
+
+/*
+ * Particle boundary based on the fluids material number.
+ * If a particle moves in the vincinity of a lattice node with
+ * specified material number it is set inactive and its velocity is set to 0.
+ **/
+
+template<typename T, template<typename U> class PARTICLETYPE>
+class MaterialBoundary3D : public Boundary3D<T, PARTICLETYPE> {
+public:
+ /// Constructor
+ MaterialBoundary3D(SuperGeometry3D<T>& sg);
+ /// Copy constructor
+ MaterialBoundary3D(MaterialBoundary3D<T, PARTICLETYPE>& f);
+ /// Constructor with set of material numbers
+ MaterialBoundary3D(SuperGeometry3D<T>& sg,
+ std::set<int> material);
+ ~MaterialBoundary3D() override
+ {
+ }
+ /// Add a single material number
+ void addMaterial(int mat)
+ {
+ _materials.insert(mat);
+ }
+ /// Add several material numbers
+ void addMaterial(std::vector<int> mats)
+ {
+ for (unsigned i=0; i< mats.size(); ++i) {
+ _materials.insert(mats[i]);
+ }
+ }
+ /// Apply the boundary condition
+ void applyBoundary(
+ typename std::deque<PARTICLETYPE<T> >::iterator& p,
+ ParticleSystem3D<T, PARTICLETYPE>& psSys) override;
+
+private:
+ SuperGeometry3D<T>& _sg;
+ std::set<int> _materials;
+ std::set<int>::iterator _matIter;
+ // int x0, y0, z0;
+};
+
+}
+
+#endif /* MATERIALBOUNDARY3D_H */
diff --git a/src/particles/boundaries/materialBoundary3D.hh b/src/particles/boundaries/materialBoundary3D.hh
new file mode 100644
index 0000000..349f13b
--- /dev/null
+++ b/src/particles/boundaries/materialBoundary3D.hh
@@ -0,0 +1,83 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MATERIALBOUNDARY3D_HH
+#define MATERIALBOUNDARY3D_HH
+
+#include <set>
+#include "materialBoundary3D.h"
+
+namespace olb {
+
+template<typename T, template<typename U> class PARTICLETYPE>
+MaterialBoundary3D<T, PARTICLETYPE>::MaterialBoundary3D(
+ SuperGeometry3D<T>& sg)
+ : Boundary3D<T, PARTICLETYPE>(),
+ _sg(sg)
+{
+ _matIter = _materials.begin();
+}
+
+template<typename T, template<typename U> class PARTICLETYPE>
+MaterialBoundary3D<T, PARTICLETYPE>::MaterialBoundary3D(
+ SuperGeometry3D<T>& sg,
+ std::set<int> materials)
+ : Boundary3D<T, PARTICLETYPE>(),
+ _sg(sg),
+ _materials(materials.begin(),materials.end())
+{
+}
+
+template<typename T, template<typename U> class PARTICLETYPE>
+void MaterialBoundary3D<T, PARTICLETYPE>::applyBoundary(
+ typename std::deque<PARTICLETYPE<T> >::iterator& p,
+ ParticleSystem3D<T, PARTICLETYPE>& psSys)
+{
+ int latticeR[3] = { 0 };
+ _sg.getCuboidGeometry().get(p->getCuboid()).getFloorLatticeR(latticeR, &p->getPos()[0]);
+ // Read only access to the material numbers of nodes around particle position
+ const BlockGeometryStructure3D<T>& bg = _sg.getExtendedBlockGeometry(
+ _sg.getLoadBalancer().loc(p->getCuboid()));
+ // + overlap is because of lower boundaries, latticeR has to be shifted up
+ int iX = latticeR[0]+_sg.getOverlap();
+ int iY = latticeR[1]+_sg.getOverlap();
+ int iZ = latticeR[2]+_sg.getOverlap();
+ for (_matIter = _materials.begin(); _matIter != _materials.end(); _matIter++) {
+ if (bg.get(iX, iY, iZ) == *_matIter ||
+ bg.get(iX, iY+1, iZ) == *_matIter ||
+ bg.get(iX, iY, iZ+1) == *_matIter ||
+ bg.get(iX, iY+1, iZ+1) == *_matIter ||
+ bg.get(iX+1, iY, iZ) == *_matIter ||
+ bg.get(iX+1, iY+1, iZ) == *_matIter ||
+ bg.get(iX+1, iY, iZ+1) == *_matIter ||
+ bg.get(iX+1, iY+1, iZ+1) == *_matIter
+ ) {
+ p->setActive(false);
+ return;
+ }
+ }
+}
+
+}
+
+#endif /* MATERIALBOUNDARY3D_HH */
diff --git a/src/particles/boundaries/module.mk b/src/particles/boundaries/module.mk
new file mode 100644
index 0000000..6e42e3e
--- /dev/null
+++ b/src/particles/boundaries/module.mk
@@ -0,0 +1,27 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2017 Markus Mohrhard
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+# <http://www.openlb.net/>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+current_dir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+
+include $(addsuffix /MakeHeader, $(current_dir))
+
+LIB_OBJECTS += $(foreach file, $($(BUILDTYPE)), $(OBJDIR)/$(current_dir)$(file).o)
diff --git a/src/particles/boundaries/periodicBoundary3D.h b/src/particles/boundaries/periodicBoundary3D.h
new file mode 100644
index 0000000..370b83b
--- /dev/null
+++ b/src/particles/boundaries/periodicBoundary3D.h
@@ -0,0 +1,136 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PERIODICBOUNDARY3D_H_
+#define PERIODICBOUNDARY3D_H_
+
+#include <math.h>
+#include <vector>
+