diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C new file mode 100644 index 0000000000..deee624c17 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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. + + OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "LocalInteraction.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +bool Foam::LocalInteraction::applyToPatch(const polyPatch& pp) const +{ + forAll(patchIds_, patchI) + { + if (patchIds_[patchI] == pp.index()) + { + return true; + } + } + + return false; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::LocalInteraction::LocalInteraction +( + const dictionary& dict, + CloudType& cloud +) +: + PatchInteractionModel(dict, cloud, typeName), + patchData_(this->coeffDict().lookup("patches")), + patchIds_(patchData_.size()) +{ + const polyMesh& mesh = cloud.mesh(); + + forAll(patchData_, patchI) + { + const word& patchName = patchData_[patchI].patchName(); + patchIds_[patchI] = mesh.boundaryMesh().findPatchID(patchName); + if (patchIds_[patchI] < 0) + { + FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)") + << "Patch " << patchName << " not found. Available patches " + << "are: " << mesh.boundaryMesh().names() << endl; + } + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::LocalInteraction::~LocalInteraction() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::LocalInteraction::active() const +{ + return true; +} + + +template +void Foam::LocalInteraction::correct +( + const polyPatch& pp, + const label faceId, + vector& U +) const +{ + if (applyToPatch(pp)) + { + vector nw = pp.faceAreas()[pp.whichFace(faceId)]; + nw /= mag(nw); + + scalar Un = U & nw; + vector Ut = U - Un*nw; + + if (Un > 0) + { + U -= (1.0 + patchData_[pp.index()].e())*Un*nw; + } + + U -= patchData_[pp.index()].mu()*Ut; + } +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H new file mode 100644 index 0000000000..928110f07d --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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. + + OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::LocalInteraction + +Description + Patch interaction specified on a patch-by-patch basis + +\*---------------------------------------------------------------------------*/ + +#ifndef LocalInteraction_H +#define LocalInteraction_H + +#include "PatchInteractionModel.H" +#include "dictionaryEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class LocalInteraction Declaration +\*---------------------------------------------------------------------------*/ + +template +class LocalInteraction +: + public PatchInteractionModel +{ + class patchInteractionData + { + // Private data + + //- Patch name + word patchName_; + + //- Elasticity coefficient + scalar e_; + + //- Restitution coefficient + scalar mu_; + + + public: + + //- Construct null + patchInteractionData() + : + patchName_("unknownPatch"), + e_(0.0), + mu_(0.0) + {} + + //- Construct from dictionary + patchInteractionData(const dictionary& dict); + + // Member functions + + // Access + + //- Return const access to the patch name + const word& patchName() const + { + return patchName_; + } + + //- Return const access to the elasticity coefficient + scalar e() const + { + return e_; + } + + //- Return const access to the restitution coefficient + scalar mu() const + { + return mu_; + } + + + // I-O + + //- Istream operator + friend Istream& operator>>(Istream& is, patchInteractionData& pid) + { + is.check + ( + "Istream& operator>>" + "(Istream&, patchInteractionData&)" + ); + + const dictionaryEntry entry(dictionary::null, is); + + pid.patchName_ = entry.keyword(); + entry.lookup("e") >> pid.e_; + entry.lookup("mu") >> pid.mu_; + + return is; + } + }; + + + // Private data + + //- List of participating patches + const List patchData_; + + //- List of participating patch ids + List