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/MakeHeader | 32 + 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 + src/particles/contactDetection/contactDetection.h | 66 + src/particles/contactDetection/nanoflann.hpp | 1634 ++++++++++++++ .../contactDetection/nanoflann_adaptor.hpp | 127 ++ src/particles/contactDetection/pLattice.h | 205 ++ src/particles/contactDetection/sortAlgorithms.h | 31 + src/particles/forces/MakeHeader | 36 + src/particles/forces/buoyancyForce3D.cpp | 35 + src/particles/forces/buoyancyForce3D.h | 58 + src/particles/forces/buoyancyForce3D.hh | 67 + src/particles/forces/force3D.cpp | 34 + src/particles/forces/force3D.h | 58 + src/particles/forces/force3D.hh | 50 + src/particles/forces/forceFromExtField3D.cpp | 35 + src/particles/forces/forceFromExtField3D.h | 57 + src/particles/forces/forceFromExtField3D.hh | 66 + src/particles/forces/forces.h | 42 + src/particles/forces/forces.hh | 40 + src/particles/forces/hertzMindlinDeresiewicz3D.cpp | 36 + src/particles/forces/hertzMindlinDeresiewicz3D.h | 75 + src/particles/forces/hertzMindlinDeresiewicz3D.hh | 202 ++ ...ndlinDeresiewiczForCombWithCollisionModel3D.cpp | 36 + ...MindlinDeresiewiczForCombWithCollisionModel3D.h | 76 + ...indlinDeresiewiczForCombWithCollisionModel3D.hh | 235 ++ src/particles/forces/interpMagForceForMagP3D.cpp | 40 + src/particles/forces/interpMagForceForMagP3D.h | 59 + src/particles/forces/interpMagForceForMagP3D.hh | 158 ++ src/particles/forces/linearContactForce3D.cpp | 36 + src/particles/forces/linearContactForce3D.h | 76 + src/particles/forces/linearContactForce3D.hh | 208 ++ .../linearDampingForceForMagDipoleMoment3D.cpp | 37 + .../linearDampingForceForMagDipoleMoment3D.h | 55 + .../linearDampingForceForMagDipoleMoment3D.hh | 63 + src/particles/forces/magneticForceForMagP3D.cpp | 35 + src/particles/forces/magneticForceForMagP3D.h | 64 + src/particles/forces/magneticForceForMagP3D.hh | 85 + src/particles/forces/magneticForceFromHField3D.cpp | 35 + src/particles/forces/magneticForceFromHField3D.h | 57 + src/particles/forces/magneticForceFromHField3D.hh | 119 ++ src/particles/forces/module.mk | 27 + src/particles/forces/stokesDragForce3D.cpp | 36 + src/particles/forces/stokesDragForce3D.h | 71 + src/particles/forces/stokesDragForce3D.hh | 127 ++ .../forces/stokesDragForceForHomVelField3D.cpp | 38 + .../forces/stokesDragForceForHomVelField3D.h | 54 + .../forces/stokesDragForceForHomVelField3D.hh | 57 + src/particles/forces/transferExternalForce3D.cpp | 33 + src/particles/forces/transferExternalForce3D.h | 48 + src/particles/forces/transferExternalForce3D.hh | 54 + src/particles/forces/weightForce3D.cpp | 34 + src/particles/forces/weightForce3D.h | 50 + src/particles/forces/weightForce3D.hh | 50 + src/particles/hlbm/hlbmDynamics2D.h | 110 + src/particles/hlbm/hlbmDynamics2D.hh | 261 +++ src/particles/hlbm/hlbmDynamics3D.h | 108 + src/particles/hlbm/hlbmDynamics3D.hh | 317 +++ src/particles/module.mk | 27 + src/particles/particle3D.cpp | 32 + src/particles/particle3D.h | 407 ++++ src/particles/particle3D.hh | 537 +++++ src/particles/particleSystem3D.cpp | 95 + src/particles/particleSystem3D.h | 456 ++++ src/particles/particleSystem3D.hh | 1917 +++++++++++++++++ src/particles/particles3D.h | 32 + src/particles/particles3D.hh | 32 + src/particles/superParticleSysVTUout.cpp | 36 + src/particles/superParticleSysVTUout.h | 138 ++ src/particles/superParticleSysVTUout.hh | 1328 ++++++++++++ src/particles/superParticleSystem3D.cpp | 85 + src/particles/superParticleSystem3D.h | 413 ++++ src/particles/superParticleSystem3D.hh | 2257 ++++++++++++++++++++ src/particles/twoWayCouplings/backCouplingModels.h | 124 ++ .../twoWayCouplings/backCouplingModels.hh | 230 ++ src/particles/twoWayCouplings/dragModels3D.h | 113 + src/particles/twoWayCouplings/dragModels3D.hh | 150 ++ .../twoWayCouplings/forwardCouplingModels3D.h | 148 ++ .../twoWayCouplings/forwardCouplingModels3D.hh | 280 +++ src/particles/twoWayCouplings/twoWayCouplings3D.h | 32 + src/particles/twoWayCouplings/twoWayCouplings3D.hh | 32 + .../twoWayCouplings/twoWayHelperFunctionals.h | 232 ++ .../twoWayCouplings/twoWayHelperFunctionals.hh | 431 ++++ 98 files changed, 16598 insertions(+) create mode 100644 src/particles/MakeHeader 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 create mode 100644 src/particles/contactDetection/contactDetection.h create mode 100644 src/particles/contactDetection/nanoflann.hpp create mode 100644 src/particles/contactDetection/nanoflann_adaptor.hpp create mode 100644 src/particles/contactDetection/pLattice.h create mode 100644 src/particles/contactDetection/sortAlgorithms.h create mode 100644 src/particles/forces/MakeHeader create mode 100644 src/particles/forces/buoyancyForce3D.cpp create mode 100644 src/particles/forces/buoyancyForce3D.h create mode 100644 src/particles/forces/buoyancyForce3D.hh create mode 100644 src/particles/forces/force3D.cpp create mode 100644 src/particles/forces/force3D.h create mode 100644 src/particles/forces/force3D.hh create mode 100644 src/particles/forces/forceFromExtField3D.cpp create mode 100755 src/particles/forces/forceFromExtField3D.h create mode 100755 src/particles/forces/forceFromExtField3D.hh create mode 100644 src/particles/forces/forces.h create mode 100644 src/particles/forces/forces.hh create mode 100644 src/particles/forces/hertzMindlinDeresiewicz3D.cpp create mode 100755 src/particles/forces/hertzMindlinDeresiewicz3D.h create mode 100755 src/particles/forces/hertzMindlinDeresiewicz3D.hh create mode 100644 src/particles/forces/hertzMindlinDeresiewiczForCombWithCollisionModel3D.cpp create mode 100755 src/particles/forces/hertzMindlinDeresiewiczForCombWithCollisionModel3D.h create mode 100755 src/particles/forces/hertzMindlinDeresiewiczForCombWithCollisionModel3D.hh create mode 100644 src/particles/forces/interpMagForceForMagP3D.cpp create mode 100644 src/particles/forces/interpMagForceForMagP3D.h create mode 100644 src/particles/forces/interpMagForceForMagP3D.hh create mode 100644 src/particles/forces/linearContactForce3D.cpp create mode 100755 src/particles/forces/linearContactForce3D.h create mode 100755 src/particles/forces/linearContactForce3D.hh create mode 100644 src/particles/forces/linearDampingForceForMagDipoleMoment3D.cpp create mode 100644 src/particles/forces/linearDampingForceForMagDipoleMoment3D.h create mode 100644 src/particles/forces/linearDampingForceForMagDipoleMoment3D.hh create mode 100644 src/particles/forces/magneticForceForMagP3D.cpp create mode 100755 src/particles/forces/magneticForceForMagP3D.h create mode 100755 src/particles/forces/magneticForceForMagP3D.hh create mode 100644 src/particles/forces/magneticForceFromHField3D.cpp create mode 100755 src/particles/forces/magneticForceFromHField3D.h create mode 100755 src/particles/forces/magneticForceFromHField3D.hh create mode 100644 src/particles/forces/module.mk create mode 100644 src/particles/forces/stokesDragForce3D.cpp create mode 100644 src/particles/forces/stokesDragForce3D.h create mode 100644 src/particles/forces/stokesDragForce3D.hh create mode 100644 src/particles/forces/stokesDragForceForHomVelField3D.cpp create mode 100644 src/particles/forces/stokesDragForceForHomVelField3D.h create mode 100644 src/particles/forces/stokesDragForceForHomVelField3D.hh create mode 100644 src/particles/forces/transferExternalForce3D.cpp create mode 100644 src/particles/forces/transferExternalForce3D.h create mode 100644 src/particles/forces/transferExternalForce3D.hh create mode 100644 src/particles/forces/weightForce3D.cpp create mode 100644 src/particles/forces/weightForce3D.h create mode 100644 src/particles/forces/weightForce3D.hh create mode 100644 src/particles/hlbm/hlbmDynamics2D.h create mode 100644 src/particles/hlbm/hlbmDynamics2D.hh create mode 100644 src/particles/hlbm/hlbmDynamics3D.h create mode 100644 src/particles/hlbm/hlbmDynamics3D.hh create mode 100644 src/particles/module.mk create mode 100644 src/particles/particle3D.cpp create mode 100644 src/particles/particle3D.h create mode 100755 src/particles/particle3D.hh create mode 100644 src/particles/particleSystem3D.cpp create mode 100755 src/particles/particleSystem3D.h create mode 100755 src/particles/particleSystem3D.hh create mode 100644 src/particles/particles3D.h create mode 100644 src/particles/particles3D.hh create mode 100644 src/particles/superParticleSysVTUout.cpp create mode 100644 src/particles/superParticleSysVTUout.h create mode 100644 src/particles/superParticleSysVTUout.hh create mode 100644 src/particles/superParticleSystem3D.cpp create mode 100644 src/particles/superParticleSystem3D.h create mode 100644 src/particles/superParticleSystem3D.hh create mode 100644 src/particles/twoWayCouplings/backCouplingModels.h create mode 100644 src/particles/twoWayCouplings/backCouplingModels.hh create mode 100644 src/particles/twoWayCouplings/dragModels3D.h create mode 100644 src/particles/twoWayCouplings/dragModels3D.hh create mode 100644 src/particles/twoWayCouplings/forwardCouplingModels3D.h create mode 100644 src/particles/twoWayCouplings/forwardCouplingModels3D.hh create mode 100644 src/particles/twoWayCouplings/twoWayCouplings3D.h create mode 100644 src/particles/twoWayCouplings/twoWayCouplings3D.hh create mode 100644 src/particles/twoWayCouplings/twoWayHelperFunctionals.h create mode 100644 src/particles/twoWayCouplings/twoWayHelperFunctionals.hh (limited to 'src/particles') diff --git a/src/particles/MakeHeader b/src/particles/MakeHeader new file mode 100644 index 0000000..0ea7b65 --- /dev/null +++ b/src/particles/MakeHeader @@ -0,0 +1,32 @@ +# 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 := particle3D \ + particleSystem3D \ + superParticleSystem3D \ + superParticleSysVTUout + # particleSysVTUout \ + +# TODO: add cpp files for "precompiled" as soon as they are created 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 */ diff --git a/src/particles/contactDetection/contactDetection.h b/src/particles/contactDetection/contactDetection.h new file mode 100644 index 0000000..c5a6218 --- /dev/null +++ b/src/particles/contactDetection/contactDetection.h @@ -0,0 +1,66 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2015 Thomas Henn + * 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 CONTACTDETECTION_H +#define CONTACTDETECTION_H + +namespace olb { + +template class PARTICLETYPE> +class ParticleSystem3D; + +/* + * Prototype for future contact detection algorithms + **/ + +template class PARTICLETYPE> +class ContactDetection { +public: + ContactDetection(ParticleSystem3D& pSys) : _pSys(pSys), _name("ContactDetection") {}; + ContactDetection(ParticleSystem3D& pSys, std::string name) : _pSys(pSys), _name(name) {}; + + virtual void sort() {}; + virtual int getMatches(int pInt, std::vector >& matches) + { + return 0; + }; + + virtual ~ContactDetection() {}; + virtual ContactDetection* generate(ParticleSystem3D& pSys) + { + return this; + }; + + inline std::string getName() + { + return _name; + } + +protected: + ParticleSystem3D& _pSys; + std::string _name; +}; + +} // namespace olb + +#endif /*CONTACTDETECTION_H*/ diff --git a/src/particles/contactDetection/nanoflann.hpp b/src/particles/contactDetection/nanoflann.hpp new file mode 100644 index 0000000..2e33377 --- /dev/null +++ b/src/particles/contactDetection/nanoflann.hpp @@ -0,0 +1,1634 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * Copyright 2011-2014 Jose Luis Blanco (joseluisblancoc@gmail.com). + * All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *************************************************************************/ + +#ifndef NANOFLANN_HPP_ +#define NANOFLANN_HPP_ + +#include +#include +#include +#include +#include // for fwrite() +#include // for fabs(),... +#include + +// Avoid conflicting declaration of min/max macros in windows headers +#if !defined(NOMINMAX) && (defined(_WIN32) || defined(_WIN32_) || defined(WIN32) || defined(_WIN64)) +# define NOMINMAX +# ifdef max +# undef max +# undef min +# endif +#endif + +namespace nanoflann { +/** @addtogroup nanoflann_grp nanoflann C++ library for ANN + * @{ */ + +/** Library version: 0xMmP (M=Major,m=minor,P=patch) */ +#define NANOFLANN_VERSION 0x119 + +/** @addtogroup result_sets_grp Result set classes + * @{ */ +template +class KNNResultSet { + IndexType * indices; + DistanceType* dists; + CountType capacity; + CountType count; + + public: + inline KNNResultSet(CountType capacity_) + : indices(0), + dists(0), + capacity(capacity_), + count(0) { + } + + inline void init(IndexType* indices_, DistanceType* dists_) { + indices = indices_; + dists = dists_; + count = 0; + dists[capacity - 1] = (std::numeric_limits::max)(); + } + + inline CountType size() const { + return count; + } + + inline bool full() const { + return count == capacity; + } + + inline void addPoint(DistanceType dist, IndexType index) { + CountType i; + for (i = count; i > 0; --i) { +#ifdef NANOFLANN_FIRST_MATCH // If defined and two poins have the same distance, the one with the lowest-index will be returned first. + if ( (dists[i-1]>dist) || ((dist==dists[i-1])&&(indices[i-1]>index)) ) { +#else + if (dists[i - 1] > dist) { +#endif + if (i < capacity) { + dists[i] = dists[i - 1]; + indices[i] = indices[i - 1]; + } + } else + break; + } + if (i < capacity) { + dists[i] = dist; + indices[i] = index; + } + if (count < capacity) + count++; + } + + inline DistanceType worstDist() const { + return dists[capacity - 1]; + } +}; + +/** + * A result-set class used when performing a radius based search. + */ +template +class RadiusResultSet { + public: + const DistanceType radius; + + std::vector >& m_indices_dists; + + inline RadiusResultSet( + DistanceType radius_, + std::vector >& indices_dists) + : radius(radius_), + m_indices_dists(indices_dists) { + init(); + } + + inline ~RadiusResultSet() { + } + + inline void init() { + clear(); + } + inline void clear() { + m_indices_dists.clear(); + } + + inline size_t size() const { + return m_indices_dists.size(); + } + + inline bool full() const { + return true; + } + + inline void addPoint(DistanceType dist, IndexType index) { + if (dist < radius) + m_indices_dists.push_back(std::make_pair(index, dist)); + } + + inline DistanceType worstDist() const { + return radius; + } + + /** Clears the result set and adjusts the search radius. */ + inline void set_radius_and_clear(const DistanceType r) { + radius = r; + clear(); + } + + /** + * Find the worst result (furtherest neighbor) without copying or sorting + * Pre-conditions: size() > 0 + */ + std::pair worst_item() const { + if (m_indices_dists.empty()) + throw std::runtime_error( + "Cannot invoke RadiusResultSet::worst_item() on an empty list of results."); + typedef typename std::vector >::const_iterator DistIt; + DistIt it = std::max_element(m_indices_dists.b