Particle deformation in predefined cell set.

This commit is contained in:
tlichtenegger
2020-04-09 10:57:26 +02:00
parent 9e8a418576
commit 5f16dce15b
2 changed files with 60 additions and 18 deletions

View File

@ -20,6 +20,7 @@ License
#include "particleDeformation.H" #include "particleDeformation.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "dataExchangeModel.H" #include "dataExchangeModel.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,6 +53,10 @@ particleDeformation::particleDeformation
initialExec_(true), initialExec_(true),
refFieldName_(propsDict_.lookup("refFieldName")), refFieldName_(propsDict_.lookup("refFieldName")),
refField_(), refField_(),
defaultDeformCellsName_(propsDict_.lookupOrDefault<word>("defaultDeformCellsName","none")),
defaultDeformCells_(),
existDefaultDeformCells_(false),
defaultDeformation_(propsDict_.lookupOrDefault<scalar>("defaultDeformation",1.0)),
partTypes_(propsDict_.lookupOrDefault<labelList>("partTypes",labelList(1,-1))), partTypes_(propsDict_.lookupOrDefault<labelList>("partTypes",labelList(1,-1))),
lowerBounds_(propsDict_.lookupOrDefault<scalarList>("lowerBounds",scalarList(1,-1.0))), lowerBounds_(propsDict_.lookupOrDefault<scalarList>("lowerBounds",scalarList(1,-1.0))),
upperBounds_(propsDict_.lookupOrDefault<scalarList>("upperBounds",scalarList(1,-1.0))), upperBounds_(propsDict_.lookupOrDefault<scalarList>("upperBounds",scalarList(1,-1.0))),
@ -71,6 +76,19 @@ particleDeformation::particleDeformation
particleCloud_.checkCG(false); 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 // check if only single value instead of list was provided
if (propsDict_.found("partType")) if (propsDict_.found("partType"))
{ {
@ -112,6 +130,12 @@ void particleDeformation::allocateMyArrays() const
double initVal = 0.0; double initVal = 0.0;
particleCloud_.dataExchangeM().allocateArray(partDeformations_,initVal,1); particleCloud_.dataExchangeM().allocateArray(partDeformations_,initVal,1);
} }
bool particleDeformation::defaultDeformCell(label cell) const
{
if (!existDefaultDeformCells_) return false;
else return defaultDeformCells_()[cell];
}
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void particleDeformation::setForce() const void particleDeformation::setForce() const
@ -128,7 +152,7 @@ void particleDeformation::setForce() const
label partType = -1; label partType = -1;
scalar refFieldValue = 0.0; scalar refFieldValue = 0.0;
scalar deformationDegree = 0.0; scalar deformationDegree = 0.0;
interpolationCellPoint<scalar> refFieldInterpolator_(refField_()); interpolationCellPoint<scalar> refFieldInterpolator_(refField_());
for(int index = 0; index < particleCloud_.numberOfParticles(); ++index) for(int index = 0; index < particleCloud_.numberOfParticles(); ++index)
@ -138,27 +162,34 @@ void particleDeformation::setForce() const
label listIndex = getListIndex(partType); label listIndex = getListIndex(partType);
if (cellI >= 0 && listIndex >= 0) if (cellI >= 0 && listIndex >= 0)
{ {
if (forceSubM(0).interpolation()) if (defaultDeformCell(cellI))
{ {
vector position = particleCloud_.position(index); deformationDegree = defaultDeformation_;
refFieldValue = refFieldInterpolator_.interpolate(position,cellI);
} }
else 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]) if (refFieldValue <= lowerBounds_[listIndex])
{ {
deformationDegree = 0.0; deformationDegree = 0.0;
} }
else if (refFieldValue >= upperBounds_[listIndex]) else if (refFieldValue >= upperBounds_[listIndex])
{ {
deformationDegree = 1.0; deformationDegree = 1.0;
} }
else else
{ {
deformationDegree = (refFieldValue - lowerBounds_[listIndex]) / (upperBounds_[listIndex] - lowerBounds_[listIndex]); deformationDegree = (refFieldValue - lowerBounds_[listIndex]) / (upperBounds_[listIndex] - lowerBounds_[listIndex]);
}
} }
partDeformations_[index][0] = deformationDegree; partDeformations_[index][0] = deformationDegree;

View File

@ -34,7 +34,8 @@ SourceFiles
#include "forceModel.H" #include "forceModel.H"
#include "averagingModel.H" #include "averagingModel.H"
#include "interpolationCellPoint.H" #include "interpolationCellPoint.H"
#include "autoPtr.H"
#include "cellSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -58,6 +59,15 @@ private:
mutable autoPtr<volScalarField> refField_; mutable autoPtr<volScalarField> refField_;
// default deformation in region
word defaultDeformCellsName_;
autoPtr<cellSet> defaultDeformCells_;
bool existDefaultDeformCells_;
scalar defaultDeformation_;
labelList partTypes_; labelList partTypes_;
scalarList lowerBounds_; scalarList lowerBounds_;
@ -72,6 +82,7 @@ private:
void init() const; void init() const;
bool defaultDeformCell(label) const;
public: public: