From 4ddf691936fe0bd7173ea2ba6415bea203184b33 Mon Sep 17 00:00:00 2001 From: tmjnijssen Date: Thu, 14 Apr 2022 15:29:10 +0200 Subject: [PATCH 1/3] add transfer of fluid properties to LIGGGHTS --- src/lagrangian/cfdemParticle/Make/files | 1 + .../transferFluidProperties.C | 108 ++++++++++++++++++ .../transferFluidProperties.H | 80 +++++++++++++ src/lagrangian/cfdemParticleComp/Make/files | 1 + 4 files changed, 190 insertions(+) create mode 100644 src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C create mode 100644 src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H diff --git a/src/lagrangian/cfdemParticle/Make/files b/src/lagrangian/cfdemParticle/Make/files index 00d33dbd..b0f4449f 100644 --- a/src/lagrangian/cfdemParticle/Make/files +++ b/src/lagrangian/cfdemParticle/Make/files @@ -96,6 +96,7 @@ $(forceModels)/potentialRelaxation/potentialRelaxation.C $(forceModels)/BeetstraDrag/BeetstraDrag.C $(forceModels)/BeetstraDragPoly/BeetstraDragPoly.C $(forceModels)/dSauter/dSauter.C +$(forceModels)/transferFluidProperties/transferFluidProperties.C $(forceModels)/Fines/Fines.C $(forceModels)/Fines/FinesFields.C $(forceModels)/Fines/FanningDynFines.C diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C new file mode 100644 index 00000000..5faf375d --- /dev/null +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ +License + This 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 3 of the License, or + (at your option) any later version. + This code 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 code. If not, see . + + Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria + +Description + transfer fluid properties to LIGGGHTS + +SourceFiles + transferFluidProperties.C +\*---------------------------------------------------------------------------*/ + +#include "error.H" + +#include "transferFluidProperties.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(transferFluidProperties, 0); + +addToRunTimeSelectionTable +( + forceModel, + transferFluidProperties, + dictionary +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +transferFluidProperties::transferFluidProperties +( + const dictionary& dict, + cfdemCloud& sm +) +: + forceModel(dict,sm), + propsDict_(dict.subDict(typeName + "Props")), + verbose_(propsDict_.lookupOrDefault("verbose",false)) +{ + particleCloud_.registerParticleProperty("fluidDensity",1); + particleCloud_.registerParticleProperty("fluidViscosity",1); + + // init force sub model + setForceSubModels(propsDict_); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +transferFluidProperties::~transferFluidProperties() +{ +} + +// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // + +void transferFluidProperties::setForce() const +{ + double**& fluidDensity_ = particleCloud_.getParticlePropertyRef("fluidDensity"); + double**& fluidViscosity_ = particleCloud_.getParticlePropertyRef("fluidViscosity"); + + const volScalarField& rhoField = forceSubM(0).rhoField(); + const volScalarField& nufField = forceSubM(0).nuField(); + + label cellI = 0; + + for(int index = 0; index < particleCloud_.numberOfParticles(); ++index) + { + cellI = particleCloud_.cellIDs()[index][0]; + if (cellI >= 0) + { + fluidDensity_[index][0] = rhoField[cellI]; + fluidViscosity_[index][0] = nufField[cellI] * rhoField[cellI]; + } + } + + particleCloud_.dataExchangeM().giveData("fluidDensity","scalar-atom",fluidDensity_); + particleCloud_.dataExchangeM().giveData("fluidViscosity","scalar-atom",fluidViscosity_); + + if (verbose_) Info << "give data done" << endl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H new file mode 100644 index 00000000..9a2853ae --- /dev/null +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ +License + This 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 3 of the License, or + (at your option) any later version. + This code 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 code. If not, see . + + Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria + +Description + transfer fluid properties to LIGGGHTS + +SourceFiles + transferFluidProperties.C +\*---------------------------------------------------------------------------*/ + +#ifndef transferFluidProperties_H +#define transferFluidProperties_H + +#include "forceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class transferFluidProperties Declaration +\*---------------------------------------------------------------------------*/ + +class transferFluidProperties +: + public forceModel +{ +private: + + dictionary propsDict_; + + bool verbose_; + +public: + + //- Runtime type information + TypeName("transferFluidProperties"); + + // Constructors + + //- Construct from components + transferFluidProperties + ( + const dictionary& dict, + cfdemCloud& sm + ); + + // Destructor + + ~transferFluidProperties(); + + + // Member Functions + void setForce() const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/cfdemParticleComp/Make/files b/src/lagrangian/cfdemParticleComp/Make/files index 2907a3ea..dfccc6e6 100644 --- a/src/lagrangian/cfdemParticleComp/Make/files +++ b/src/lagrangian/cfdemParticleComp/Make/files @@ -90,6 +90,7 @@ $(forceModels)/directedDiffusiveRelaxation/directedDiffusiveRelaxation.C $(forceModels)/BeetstraDrag/BeetstraDrag.C $(forceModels)/BeetstraDragPoly/BeetstraDragPoly.C $(forceModels)/dSauter/dSauter.C +$(forceModels)/transferFluidProperties/transferFluidProperties.C $(forceModels)/Fines/Fines.C $(forceModels)/Fines/FinesFields.C $(forceModels)/Fines/FanningDynFines.C From d6dab59bfde879c7e3f75db4de1e6d06a8416322 Mon Sep 17 00:00:00 2001 From: tmjnijssen Date: Thu, 14 Apr 2022 15:50:22 +0200 Subject: [PATCH 2/3] add interpolation --- .../transferFluidProperties.C | 31 ++++++++++++++++--- .../transferFluidProperties.H | 3 +- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C index 5faf375d..5c2695d5 100644 --- a/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.C @@ -52,14 +52,17 @@ transferFluidProperties::transferFluidProperties ) : forceModel(dict,sm), - propsDict_(dict.subDict(typeName + "Props")), - verbose_(propsDict_.lookupOrDefault("verbose",false)) + propsDict_(dict.subDict(typeName + "Props")) { particleCloud_.registerParticleProperty("fluidDensity",1); particleCloud_.registerParticleProperty("fluidViscosity",1); // init force sub model setForceSubModels(propsDict_); + // define switches which can be read from dict + forceSubM(0).setSwitchesList(SW_VERBOSE,true); // activate search for verbose switch + forceSubM(0).setSwitchesList(SW_INTERPOLATION,true); // activate search for interpolate switch + forceSubM(0).readSwitches(); } @@ -82,22 +85,40 @@ void transferFluidProperties::setForce() const const volScalarField& rhoField = forceSubM(0).rhoField(); const volScalarField& nufField = forceSubM(0).nuField(); + interpolationCellPoint rhoInterpolator_(rhoField); + interpolationCellPoint nufInterpolator_(nufField); + label cellI = 0; + double rho = 0.; + double nuf = 0.; + vector position(0,0,0); for(int index = 0; index < particleCloud_.numberOfParticles(); ++index) { cellI = particleCloud_.cellIDs()[index][0]; if (cellI >= 0) { - fluidDensity_[index][0] = rhoField[cellI]; - fluidViscosity_[index][0] = nufField[cellI] * rhoField[cellI]; + if(forceSubM(0).interpolation()) + { + position = particleCloud_.position(index); + rho = rhoInterpolator_.interpolate(position,cellI); + nuf = nufInterpolator_.interpolate(position,cellI); + } + else + { + rho = rhoField[cellI]; + nuf = nufField[cellI]; + } + + fluidDensity_[index][0] = rho; + fluidViscosity_[index][0] = nuf*rho; } } particleCloud_.dataExchangeM().giveData("fluidDensity","scalar-atom",fluidDensity_); particleCloud_.dataExchangeM().giveData("fluidViscosity","scalar-atom",fluidViscosity_); - if (verbose_) Info << "give data done" << endl; + if (forceSubM(0).verbose()) Info << "give data done" << endl; } diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H index 9a2853ae..1dc52f85 100644 --- a/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/transferFluidProperties/transferFluidProperties.H @@ -24,6 +24,7 @@ SourceFiles #define transferFluidProperties_H #include "forceModel.H" +#include "interpolationCellPoint.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -42,8 +43,6 @@ private: dictionary propsDict_; - bool verbose_; - public: //- Runtime type information From 57c8c1c7623ea061801c0c83e21ac774840424a8 Mon Sep 17 00:00:00 2001 From: tmjnijssen Date: Thu, 14 Apr 2022 15:50:39 +0200 Subject: [PATCH 3/3] add doc --- doc/CFDEMcoupling_models.txt | 1 + doc/forceModel_transferFluidProperties.txt | 42 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 doc/forceModel_transferFluidProperties.txt diff --git a/doc/CFDEMcoupling_models.txt b/doc/CFDEMcoupling_models.txt index 00ce8e28..073082dd 100644 --- a/doc/CFDEMcoupling_models.txt +++ b/doc/CFDEMcoupling_models.txt @@ -124,6 +124,7 @@ particleDeformation, potentialRelaxation, "surfaceTensionForce"_forceModel_surfaceTensionForce.html, terminalVelocity, +"transferFluidProperties"_forceModel_transferFluidProperties.html, turbulentDispersion, turbulentVelocityFluctuations, "virtualMassForce"_forceModel_virtualMassForce.html, diff --git a/doc/forceModel_transferFluidProperties.txt b/doc/forceModel_transferFluidProperties.txt new file mode 100644 index 00000000..8606da78 --- /dev/null +++ b/doc/forceModel_transferFluidProperties.txt @@ -0,0 +1,42 @@ +"CFDEMproject Website"_lws - "Main Page"_main :c + +:link(lws,http://www.cfdem.com) +:link(main,CFDEMcoupling_Manual.html) + +:line + +forceModel transferFluidProperties command :h3 + +[Syntax:] + +Defined in "couplingProperties"_CFDEMcoupling_dicts.html#couplingProperties +dictionary. + +forceModels +( + transferFluidProperties +); +transferFluidPropertiesProps +\{ + verbose switch1; + interpolation switch2; +\} :pre + +{switch1} = (optional, default false) sub model switch, see "forceSubModel"_forceSubModel.html for details :ulb,l +{switch2} = (optional, default false) sub model switch, see "forceSubModel"_forceSubModel.html for details :l +:ule + +[Description:] + +This "force model" does not influence the particles or the flow - it transfer to fluid density and (dynamic) +viscosity from OpenFOAM to LIGGGHTS. + + +[Restrictions:] + +This model requires {fix cfd/coupling/fluidproperties} to work. + +[Related commands:] + +"forceModel"_forceModel.html +