From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001
From: Adrian Kummerlaender
Date: Mon, 24 Jun 2019 14:43:36 +0200
Subject: Initialize at openlb-1-3
---
src/particles/boundaries/MakeHeader | 29 +++
src/particles/boundaries/boundaries.h | 36 ++++
src/particles/boundaries/boundaries.hh | 33 ++++
src/particles/boundaries/boundary3D.cpp | 34 ++++
src/particles/boundaries/boundary3D.h | 57 ++++++
src/particles/boundaries/boundary3D.hh | 48 +++++
.../boundaries/boundarySimpleReflection3D.cpp | 35 ++++
.../boundaries/boundarySimpleReflection3D.h | 56 ++++++
.../boundaries/boundarySimpleReflection3D.hh | 206 +++++++++++++++++++++
src/particles/boundaries/materialBoundary3D.cpp | 34 ++++
src/particles/boundaries/materialBoundary3D.h | 84 +++++++++
src/particles/boundaries/materialBoundary3D.hh | 83 +++++++++
src/particles/boundaries/module.mk | 27 +++
src/particles/boundaries/periodicBoundary3D.h | 136 ++++++++++++++
src/particles/boundaries/wireBoundaryForMagP3D.cpp | 33 ++++
src/particles/boundaries/wireBoundaryForMagP3D.h | 80 ++++++++
src/particles/boundaries/wireBoundaryForMagP3D.hh | 88 +++++++++
17 files changed, 1099 insertions(+)
create mode 100644 src/particles/boundaries/MakeHeader
create mode 100644 src/particles/boundaries/boundaries.h
create mode 100644 src/particles/boundaries/boundaries.hh
create mode 100644 src/particles/boundaries/boundary3D.cpp
create mode 100644 src/particles/boundaries/boundary3D.h
create mode 100644 src/particles/boundaries/boundary3D.hh
create mode 100644 src/particles/boundaries/boundarySimpleReflection3D.cpp
create mode 100644 src/particles/boundaries/boundarySimpleReflection3D.h
create mode 100644 src/particles/boundaries/boundarySimpleReflection3D.hh
create mode 100644 src/particles/boundaries/materialBoundary3D.cpp
create mode 100644 src/particles/boundaries/materialBoundary3D.h
create mode 100644 src/particles/boundaries/materialBoundary3D.hh
create mode 100644 src/particles/boundaries/module.mk
create mode 100644 src/particles/boundaries/periodicBoundary3D.h
create mode 100755 src/particles/boundaries/wireBoundaryForMagP3D.cpp
create mode 100755 src/particles/boundaries/wireBoundaryForMagP3D.h
create mode 100755 src/particles/boundaries/wireBoundaryForMagP3D.hh
(limited to 'src/particles/boundaries')
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
+#
+#
+# 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
+ *
+ *
+ * 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
+ *
+ *
+ * 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
+ *
+ *
+ * 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;
+template class Boundary3D;
+
+} // 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
+ *
+ *
+ * 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 class PARTICLETYPE>
+class ParticleSystem3D;
+
+
+/**
+ * Prototype for all particle boundaries
+ */
+
+template class PARTICLETYPE>
+class Boundary3D {
+public:
+ Boundary3D();
+ Boundary3D(Boundary3D&);
+ Boundary3D(const Boundary3D&);
+
+ virtual ~Boundary3D() {};
+ virtual void applyBoundary(typename std::deque >::iterator& p, ParticleSystem3D& 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
+ *
+ *
+ * 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 class PARTICLETYPE>
+Boundary3D::Boundary3D(Boundary3D& f) : clout(f.clout)
+{
+}
+
+template class PARTICLETYPE>
+Boundary3D::Boundary3D(const Boundary3D& f) : clout(f.clout)
+{
+}
+
+template class PARTICLETYPE>
+Boundary3D::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
+ *
+ *
+ * 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;
+template class SimpleReflectBoundary3D;
+
+} // 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
+ *
+ *
+ * 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
+#include
+#include "geometry/superGeometry3D.h"
+#include "particles/particleSystem3D.h"
+#include "boundary3D.h"
+
+namespace olb {
+
+template class PARTICLETYPE>
+class ParticleSystem3D;
+
+template class PARTICLETYPE>
+class SimpleReflectBoundary3D : public Boundary3D {
+
+public:
+ SimpleReflectBoundary3D(T dT, SuperGeometry3D& sg, std::set materials);
+ ~SimpleReflectBoundary3D() override {};
+ void applyBoundary(typename std::deque >::iterator& p, ParticleSystem3D& psSys) override;
+
+private:
+ T _dT;
+ SuperGeometry3D& _sg;
+ std::set _materials;
+ std::set::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
+ *
+ *
+ * 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
+#include "boundarySimpleReflection3D.h"
+
+namespace olb {
+
+template class PARTICLETYPE>
+SimpleReflectBoundary3D::SimpleReflectBoundary3D(T dT, SuperGeometry3D& sg, std::set materials) :
+ Boundary3D(), _dT(dT), _sg(sg), _materials(materials) {
+ _matIter = _materials.begin();
+}
+
+template class PARTICLETYPE>
+void SimpleReflectBoundary3D::applyBoundary(typename std::deque >::iterator& p, ParticleSystem3D& psSys) {
+ std::vector 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 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 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 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
+ *
+ *
+ * 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;
+template class MaterialBoundary3D;
+
+} // 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
+ *
+ *
+ * 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
+
+#include "geometry/superGeometry3D.h"
+#include "particles/particleSystem3D.h"
+#include "boundary3D.h"
+
+namespace olb {
+
+template 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 class PARTICLETYPE>
+class MaterialBoundary3D : public Boundary3D {
+public:
+ /// Constructor
+ MaterialBoundary3D(SuperGeometry3D& sg);
+ /// Copy constructor
+ MaterialBoundary3D(MaterialBoundary3D& f);
+ /// Constructor with set of material numbers
+ MaterialBoundary3D(SuperGeometry3D& sg,
+ std::set material);
+ ~MaterialBoundary3D() override
+ {
+ }
+ /// Add a single material number
+ void addMaterial(int mat)
+ {
+ _materials.insert(mat);
+ }
+ /// Add several material numbers
+ void addMaterial(std::vector mats)
+ {
+ for (unsigned i=0; i< mats.size(); ++i) {
+ _materials.insert(mats[i]);
+ }
+ }
+ /// Apply the boundary condition
+ void applyBoundary(
+ typename std::deque >::iterator& p,
+ ParticleSystem3D& psSys) override;
+
+private:
+ SuperGeometry3D& _sg;
+ std::set _materials;
+ std::set::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
+ *
+ *
+ * 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
+#include "materialBoundary3D.h"
+
+namespace olb {
+
+template class PARTICLETYPE>
+MaterialBoundary3D::MaterialBoundary3D(
+ SuperGeometry3D& sg)
+ : Boundary3D(),
+ _sg(sg)
+{
+ _matIter = _materials.begin();
+}
+
+template class PARTICLETYPE>
+MaterialBoundary3D::MaterialBoundary3D(
+ SuperGeometry3D& sg,
+ std::set materials)
+ : Boundary3D(),
+ _sg(sg),
+ _materials(materials.begin(),materials.end())
+{
+}
+
+template class PARTICLETYPE>
+void MaterialBoundary3D::applyBoundary(
+ typename std::deque >::iterator& p,
+ ParticleSystem3D& 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& 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
+#
+#
+# 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
+ *
+ *
+ * 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
+#include
+
+namespace olb {
+
+template class PARTICLETYPE>
+class ParticleSystem3D;
+
+/*
+ * Particle boundary based on a cube around the area with material number 1.
+ * Only applicable to rectangles since if a particle leaves the area with
+ * material number 1 it is moved to the opposing side of the area by
+ * newPosition = oldPosition +/- extend(MaterialNumber=1).
+ **/
+
+template class PARTICLETYPE>
+class PeriodicBoundary3D : public Boundary3D {
+public:
+ PeriodicBoundary3D(SuperGeometry3D sg, bool x,
+ bool y, bool z);
+ PeriodicBoundary3D(PeriodicBoundary3D& f);
+ virtual ~PeriodicBoundary3D() { };
+ virtual void applyBoundary(typename std::deque >::iterator& p, ParticleSystem3D& psSys);
+ /// Returns number of particles that moved through the periodic boundary
+ /// Order: x+, x-, y+, y-, z+, z-
+ unsigned int* getJumper();
+private:
+ //cube extents with origin (0,0,0)
+ std::vector _minPhys, _maxPhys, _extend;
+ bool _x, _y, _z;
+ unsigned int _jumper[6];
+ CuboidGeometry3D& _cuboidGeometry;
+ T _overlap;
+};
+
+template class PARTICLETYPE>
+PeriodicBoundary3D::PeriodicBoundary3D(
+ SuperGeometry3D sg, bool x, bool y, bool z) : Boundary3D(),
+ _minPhys(3, T()), _maxPhys(3, T()), _extend(3, T()),
+ _x(x),
+ _y(y),
+ _z(z), _cuboidGeometry(sg.getCuboidGeometry())
+{
+ _minPhys = sg.getStatistics().getMinPhysR(1);
+ _maxPhys = sg.getStatistics().getMaxPhysR(1);
+ _extend[0] = _maxPhys[0] - _minPhys[0];
+ _extend[1] = _maxPhys[1] - _minPhys[1];
+ _extend[2] = _maxPhys[2] - _minPhys[2];
+ for (int i=0; i<6; ++i) {
+ _jumper[i] = 0;
+ }
+ _overlap = sg.getOverlap();
+}
+
+template class PARTICLETYPE>
+void PeriodicBoundary3D::applyBoundary(
+ typename std::deque >::iterator& p,
+ ParticleSystem3D& psSys)
+{
+ if (_x) {
+ if (p->getPos()[0] > _maxPhys[0]) {
+ p->getPos()[0] -= _extend[0];
+ ++_jumper[0];
+ int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
+ p->setCuboid(C);
+ } else if (p->getPos()[0] < _minPhys[0]) {
+ p->getPos()[0] += _extend[0];
+ ++_jumper[1];
+ int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
+ p->setCuboid(C);
+ }
+ }
+ if (_y) {
+ if (p->getPos()[1] > _maxPhys[1]) {
+ p->getPos()[1] -= _extend[1];
+ ++_jumper[2];
+ int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
+ p->setCuboid(C);
+ } else if (p->getPos()[1] < _minPhys[1]) {
+ p->getPos()[1] += _extend[1];
+ ++_jumper[3];
+ int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
+ p->setCuboid(C);
+ }
+ }
+ if (_z) {
+ if (p->getPos()[2] > _maxPhys[2]) {
+ p->getPos()[2] -= _extend[2];
+ ++_jumper[4];
+ int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
+ p->setCuboid(C);
+ } else if (p->getPos()[2] < _minPhys[2]) {
+ p->getPos()[2] += _extend[2];
+ ++_jumper[5];
+ int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
+ p->setCuboid(C);
+ }
+ }
+}
+
+template class PARTICLETYPE>
+unsigned int* PeriodicBoundary3D::getJumper()
+{
+ return _jumper;
+}
+
+
+}
+
+#endif
diff --git a/src/particles/boundaries/wireBoundaryForMagP3D.cpp b/src/particles/boundaries/wireBoundaryForMagP3D.cpp
new file mode 100755
index 0000000..aa131ae
--- /dev/null
+++ b/src/particles/boundaries/wireBoundaryForMagP3D.cpp
@@ -0,0 +1,33 @@
+/* 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
+ *
+ *
+ * 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"wireBoundaryForMagP3D.h"
+#include"wireBoundaryForMagP3D.hh"
+
+namespace olb {
+
+template class WireBoundaryForMagP3D;
+
+} // namespace olb
diff --git a/src/particles/boundaries/wireBoundaryForMagP3D.h b/src/particles/boundaries/wireBoundaryForMagP3D.h
new file mode 100755
index 0000000..ed3c8cd
--- /dev/null
+++ b/src/particles/boundaries/wireBoundaryForMagP3D.h
@@ -0,0 +1,80 @@
+/* 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
+ *
+ *
+ * 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 WireBoundaryForMagP3D_H
+#define WireBoundaryForMagP3D_H
+
+#include
+
+#include "geometry/superGeometry3D.h"
+#include "particles/particleSystem3D.h"
+#include "boundary3D.h"
+
+
+namespace olb {
+
+template class PARTICLETYPE>
+class ParticleSystem3D;
+
+/*
+ * Particle boundary based on the fluids material number.
+ **/
+
+template class PARTICLETYPE>
+class WireBoundaryForMagP3D : public Boundary3D {
+
+public:
+ /// Copy constructor
+ WireBoundaryForMagP3D(WireBoundaryForMagP3D& f);
+ /// Constructor with set of material numbers
+ WireBoundaryForMagP3D(SuperGeometry3D& sg, std::set materials);
+
+ ~WireBoundaryForMagP3D() override {};
+
+ /// Add a single material number
+ void addMaterial(int mat)
+ {
+ _materials.insert(mat);
+ }
+ /// Add several material numbers
+ void addMaterial(std::vector mats)
+ {
+ for (unsigned i = 0; i < mats.size(); ++i) {
+ _materials.insert(mats[i]);
+ }
+ }
+ /// Apply the boundary condition
+ void applyBoundary(
+ typename std::deque >::iterator& p,
+ ParticleSystem3D& psSys) override;
+
+private:
+ SuperGeometry3D& _sg;
+ std::set _materials;
+ std::set::iterator _matIter;
+ // int x0, y0, z0;
+};
+
+}
+
+#endif /* WireBoundaryForMagP3D */
diff --git a/src/particles/boundaries/wireBoundaryForMagP3D.hh b/src/particles/boundaries/wireBoundaryForMagP3D.hh
new file mode 100755
index 0000000..5b2e707
--- /dev/null
+++ b/src/particles/boundaries/wireBoundaryForMagP3D.hh
@@ -0,0 +1,88 @@
+/* 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
+ *
+ *
+ * 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 WireBoundaryForMagP3D_HH
+#define WireBoundaryForMagP3D_HH
+
+#include
+#include "wireBoundaryForMagP3D.h"
+
+namespace olb {
+
+
+template class PARTICLETYPE>
+WireBoundaryForMagP3D::WireBoundaryForMagP3D(
+ SuperGeometry3D& sg, std::set materials)
+ : Boundary3D(),
+ _sg(sg),
+ _materials(materials.begin(), materials.end())
+{
+}
+
+template class PARTICLETYPE>
+void WireBoundaryForMagP3D::applyBoundary(
+ typename std::deque >::iterator& p,
+ ParticleSystem3D& 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& 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) {
+
+ if ((*_matIter == 5) && (p->getSActivity() != 3)) {
+
+ std::vector vel(3, T()) ;
+ p->setVel(vel) ;
+ p->setSActivity(3) ;
+ break;
+ }
+ if ((*_matIter == 4) && (p->getActive() != false)) {
+
+ p->setActive(false) ;
+ break;
+ }
+ }
+ }
+ return;
+}
+}
+
+#endif /* WireBoundaryForMagP3D_HH */
--
cgit v1.2.3