From 5f16dce15b813fd9b8b58488b3bcce29515ca809 Mon Sep 17 00:00:00 2001 From: tlichtenegger Date: Thu, 9 Apr 2020 10:57:26 +0200 Subject: [PATCH] Particle deformation in predefined cell set. --- .../particleDeformation/particleDeformation.C | 65 ++++++++++++++----- .../particleDeformation/particleDeformation.H | 13 +++- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.C b/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.C index 4842724d..ed1444c7 100644 --- a/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.C +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.C @@ -20,6 +20,7 @@ License #include "particleDeformation.H" #include "addToRunTimeSelectionTable.H" #include "dataExchangeModel.H" +#include "OFstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,6 +53,10 @@ particleDeformation::particleDeformation initialExec_(true), refFieldName_(propsDict_.lookup("refFieldName")), refField_(), + defaultDeformCellsName_(propsDict_.lookupOrDefault("defaultDeformCellsName","none")), + defaultDeformCells_(), + existDefaultDeformCells_(false), + defaultDeformation_(propsDict_.lookupOrDefault("defaultDeformation",1.0)), partTypes_(propsDict_.lookupOrDefault("partTypes",labelList(1,-1))), lowerBounds_(propsDict_.lookupOrDefault("lowerBounds",scalarList(1,-1.0))), upperBounds_(propsDict_.lookupOrDefault("upperBounds",scalarList(1,-1.0))), @@ -71,6 +76,19 @@ particleDeformation::particleDeformation particleCloud_.checkCG(false); + if(defaultDeformCellsName_ != "none") + { + defaultDeformCells_.set(new cellSet(particleCloud_.mesh(),defaultDeformCellsName_)); + existDefaultDeformCells_ = true; + Info << "particleDeformation: default deformation of " << defaultDeformation_ << " in cellSet " << defaultDeformCells_().name() << + " with " << defaultDeformCells_().size() << " cells." << endl; + if (defaultDeformation_ < 0.0 || defaultDeformation_ > 1.0) + { + defaultDeformation_ = min(max(defaultDeformation_,0.0),1.0); + Info << "Resetting defaultDeformation to range [0;1]" << endl; + } + } + // check if only single value instead of list was provided if (propsDict_.found("partType")) { @@ -112,6 +130,12 @@ void particleDeformation::allocateMyArrays() const double initVal = 0.0; particleCloud_.dataExchangeM().allocateArray(partDeformations_,initVal,1); } + +bool particleDeformation::defaultDeformCell(label cell) const +{ + if (!existDefaultDeformCells_) return false; + else return defaultDeformCells_()[cell]; +} // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // void particleDeformation::setForce() const @@ -128,7 +152,7 @@ void particleDeformation::setForce() const label partType = -1; scalar refFieldValue = 0.0; scalar deformationDegree = 0.0; - + interpolationCellPoint refFieldInterpolator_(refField_()); for(int index = 0; index < particleCloud_.numberOfParticles(); ++index) @@ -138,27 +162,34 @@ void particleDeformation::setForce() const label listIndex = getListIndex(partType); if (cellI >= 0 && listIndex >= 0) { - if (forceSubM(0).interpolation()) + if (defaultDeformCell(cellI)) { - vector position = particleCloud_.position(index); - refFieldValue = refFieldInterpolator_.interpolate(position,cellI); + deformationDegree = defaultDeformation_; } else { - refFieldValue = refField_()[cellI]; - } + if (forceSubM(0).interpolation()) + { + vector position = particleCloud_.position(index); + refFieldValue = refFieldInterpolator_.interpolate(position,cellI); + } + else + { + refFieldValue = refField_()[cellI]; + } - if (refFieldValue <= lowerBounds_[listIndex]) - { - deformationDegree = 0.0; - } - else if (refFieldValue >= upperBounds_[listIndex]) - { - deformationDegree = 1.0; - } - else - { - deformationDegree = (refFieldValue - lowerBounds_[listIndex]) / (upperBounds_[listIndex] - lowerBounds_[listIndex]); + if (refFieldValue <= lowerBounds_[listIndex]) + { + deformationDegree = 0.0; + } + else if (refFieldValue >= upperBounds_[listIndex]) + { + deformationDegree = 1.0; + } + else + { + deformationDegree = (refFieldValue - lowerBounds_[listIndex]) / (upperBounds_[listIndex] - lowerBounds_[listIndex]); + } } partDeformations_[index][0] = deformationDegree; diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.H b/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.H index 7b34efdb..ce5718cd 100644 --- a/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.H +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/particleDeformation/particleDeformation.H @@ -34,7 +34,8 @@ SourceFiles #include "forceModel.H" #include "averagingModel.H" #include "interpolationCellPoint.H" - +#include "autoPtr.H" +#include "cellSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -58,6 +59,15 @@ private: mutable autoPtr refField_; + // default deformation in region + word defaultDeformCellsName_; + + autoPtr defaultDeformCells_; + + bool existDefaultDeformCells_; + + scalar defaultDeformation_; + labelList partTypes_; scalarList lowerBounds_; @@ -72,6 +82,7 @@ private: void init() const; + bool defaultDeformCell(label) const; public: