Merge github.com-OpenFOAM:OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry Weller
2018-01-11 10:43:20 +00:00
11 changed files with 409 additions and 56 deletions

View File

@ -102,7 +102,7 @@ operator=(const GeoField& gf)
template<class Type>
template<class GeoField>
CrankNicolsonDdtScheme<Type>::DDt0Field<GeoField>&
typename CrankNicolsonDdtScheme<Type>::template DDt0Field<GeoField>&
CrankNicolsonDdtScheme<Type>::ddt0_
(
const word& name,

View File

@ -40,7 +40,7 @@ Usage
velocity (-2.572 0 0);
ramp
{
type quarterSineRamp;
type halfCosineRamp;
start 0;
duration 10;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,6 +28,7 @@ License
#include "fvMatrix.H"
#include "geometricOneField.H"
#include "meshTools.H"
#include "Function1.H"
#include "uniformDimensionedFields.H"
#include "addToRunTimeSelectionTable.H"
@ -59,6 +60,14 @@ void Foam::fv::verticalDamping::add
const DimensionedField<scalar, volMesh>& V = mesh_.V();
// Calculate the scale
const scalarField s
(
ramp_.valid()
? ramp_->value((mesh_.cellCentres() - origin_) & direction_)
: tmp<scalarField>(new scalarField(mesh_.nCells(), 1))
);
// Check dimensions
eqn.dimensions()
- V.dimensions()*(lgg.dimensions() & alphaRhoU.dimensions());
@ -68,7 +77,7 @@ void Foam::fv::verticalDamping::add
forAll(cells_, i)
{
const label c = cells_[i];
force[i] = V[c]*(lgg.value() & alphaRhoU[c]);
force[i] = V[c]*s[c]*(lgg.value() & alphaRhoU[c]);
}
meshTools::constrainDirection(mesh_, mesh_.solutionD(), force);
forAll(cells_, i)
@ -90,7 +99,10 @@ Foam::fv::verticalDamping::verticalDamping
)
:
cellSetOption(name, modelType, dict, mesh),
lambda_("lambda", dimless/dimTime, coeffs_.lookup("lambda"))
lambda_("lambda", dimless/dimTime, coeffs_.lookup("lambda")),
ramp_(),
origin_(),
direction_()
{
read(dict);
}
@ -143,6 +155,25 @@ bool Foam::fv::verticalDamping::read(const dictionary& dict)
coeffs_.lookup(lambda_.name())
);
const bool foundRamp = coeffs_.found("ramp");
const bool foundOrigin = coeffs_.found("origin");
const bool foundDirection = coeffs_.found("direction");
if (foundRamp && foundOrigin && foundDirection)
{
ramp_ = Function1<scalar>::New("ramp", coeffs_);
coeffs_.lookup("origin") >> origin_;
coeffs_.lookup("direction") >> direction_;
direction_ /= mag(direction_);
}
else if (foundRamp || foundOrigin || foundDirection)
{
WarningInFunction
<< "The ramping specification is incomplete. \"ramp\", "
<< "\"origin\" and \"direction\", must all be specified in "
<< "order to ramp the damping. The damping will be applied "
<< "uniformly across the cell set." << endl;
}
fieldNames_ = wordList(1, coeffs_.lookupOrDefault<word>("U", "U"));
applied_.setSize(1, false);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -67,6 +67,30 @@ Usage
}
\endverbatim
Example usage with graduated onset:
\verbatim
verticalDamping1
{
type verticalDamping;
selectionMode all;
origin (1200 0 0);
direction (1 0 0);
ramp
{
type halfCosineRamp;
start 0;
duration 600;
}
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
timeStart 0;
duration 1e6;
}
\endverbatim
SourceFiles
verticalDamping.C
@ -81,6 +105,9 @@ SourceFiles
namespace Foam
{
template<class Type> class Function1;
namespace fv
{
@ -99,6 +126,15 @@ private:
//- Damping coefficient [1/s]
dimensionedScalar lambda_;
//- The ramping function
autoPtr<Function1<scalar>> ramp_;
//- Origin of the ramping coordinate
vector origin_;
//- Direction of increasing ramping coordinate
vector direction_;
// Private Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,6 +33,7 @@ License
#include "ParticleErosion.H"
#include "ParticleTracks.H"
#include "ParticleTrap.H"
#include "PatchCollisionDensity.H"
#include "PatchPostProcessing.H"
#include "VoidFraction.H"
@ -47,6 +48,7 @@ License
makeCloudFunctionObjectType(ParticleErosion, CloudType); \
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
makeCloudFunctionObjectType(VoidFraction, CloudType);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,7 +32,7 @@ Description
particleTrap1
{
type particleTrap;
alphaName alpha; // name volume fraction field
alpha alpha; // name of the volume fraction field
threshold 0.95; // alpha value below which model is active
}
\endverbatim

View File

@ -0,0 +1,168 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "PatchCollisionDensity.H"
#include "Pstream.H"
#include "stringListOps.H"
#include "ListOps.H"
#include "ListListOps.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class CloudType>
void Foam::PatchCollisionDensity<CloudType>::write()
{
const scalarField z(this->owner().mesh().nCells(), 0);
volScalarField
(
IOobject
(
this->owner().name() + ":collisionDensity",
this->owner().mesh().time().timeName(),
this->owner().mesh()
),
this->owner().mesh(),
dimless/dimArea,
z,
collisionDensity_
)
.write();
volScalarField
(
IOobject
(
this->owner().name() + ":collisionDensityRate",
this->owner().mesh().time().timeName(),
this->owner().mesh()
),
this->owner().mesh(),
dimless/dimArea/dimTime,
z,
(collisionDensity_ - collisionDensity0_)
/(this->owner().mesh().time().value() - time0_)
)
.write();
collisionDensity0_ == collisionDensity_;
time0_ = this->owner().mesh().time().value();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::PatchCollisionDensity<CloudType>::PatchCollisionDensity
(
const dictionary& dict,
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
minSpeed_(dict.lookupOrDefault<scalar>("minSpeed", -1)),
collisionDensity_
(
this->owner().mesh().boundary(),
volScalarField::Internal::null(),
calculatedFvPatchField<scalar>::typeName
),
collisionDensity0_
(
this->owner().mesh().boundary(),
volScalarField::Internal::null(),
calculatedFvPatchField<scalar>::typeName
),
time0_(this->owner().mesh().time().value())
{
collisionDensity_ == 0;
collisionDensity0_ == 0;
IOobject io
(
this->owner().name() + ":collisionDensity",
this->owner().mesh().time().timeName(),
this->owner().mesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (io.typeHeaderOk<volScalarField>())
{
const volScalarField collisionDensity(io, this->owner().mesh());
collisionDensity_ == collisionDensity.boundaryField();
collisionDensity0_ == collisionDensity.boundaryField();
}
}
template<class CloudType>
Foam::PatchCollisionDensity<CloudType>::PatchCollisionDensity
(
const PatchCollisionDensity<CloudType>& ppm
)
:
CloudFunctionObject<CloudType>(ppm),
minSpeed_(ppm.minSpeed_),
collisionDensity_(ppm.collisionDensity_),
collisionDensity0_(ppm.collisionDensity0_),
time0_(ppm.time0_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::PatchCollisionDensity<CloudType>::~PatchCollisionDensity()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::PatchCollisionDensity<CloudType>::postPatch
(
const parcelType& p,
const polyPatch& pp,
bool&
)
{
const label patchi = pp.index();
const label patchFacei = p.face() - pp.start();
vector nw, Up;
this->owner().patchData(p, pp, nw, Up);
const scalar speed = (p.U() - Up) & nw;
if (speed > minSpeed_)
{
collisionDensity_[patchi][patchFacei] +=
1/this->owner().mesh().magSf().boundaryField()[patchi][patchFacei];
}
}
// ************************************************************************* //

View File

@ -0,0 +1,152 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::PatchCollisionDensity
Description
Function object which generates fields of the number and rate of collisions
per unit area on all patches. Can optionally take a minimum speed below
which a collision is not counted.
Example usage:
\verbatim
patchCollisionDensity1
{
type patchCollisionDensity;
minSpeed 1e-3;
}
\endverbatim
SourceFiles
PatchCollisionDensity.C
\*---------------------------------------------------------------------------*/
#ifndef PatchCollisionDensity_H
#define PatchCollisionDensity_H
#include "CloudFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class PatchCollisionDensity Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class PatchCollisionDensity
:
public CloudFunctionObject<CloudType>
{
// Private data
typedef typename CloudType::particleType parcelType;
//- The threshold for a collision
const scalar minSpeed_;
//- The field of the number of collisions per unit area
volScalarField::Boundary collisionDensity_;
//- The field of the number of collisions per unit area at the last
// output
volScalarField::Boundary collisionDensity0_;
//- The time at the last output
scalar time0_;
protected:
// Protected Member Functions
//- Write post-processing info
void write();
public:
//- Runtime type information
TypeName("patchCollisionDensity");
// Constructors
//- Construct from dictionary
PatchCollisionDensity
(
const dictionary& dict,
CloudType& owner,
const word& modelName
);
//- Construct copy
PatchCollisionDensity(const PatchCollisionDensity<CloudType>& ppm);
//- Construct and return a clone
virtual autoPtr<CloudFunctionObject<CloudType>> clone() const
{
return autoPtr<CloudFunctionObject<CloudType>>
(
new PatchCollisionDensity<CloudType>(*this)
);
}
//- Destructor
virtual ~PatchCollisionDensity();
// Member Functions
// Evaluation
//- Post-patch hook
virtual void postPatch
(
const parcelType& p,
const polyPatch& pp,
bool& keepParticle
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "PatchCollisionDensity.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -22,8 +22,6 @@ do
runApplication -s $i refineMesh -dict system/refineMeshDictY -overwrite
done
runApplication topoSet
runApplication setWaves -alpha alpha.water
runApplication decomposePar

View File

@ -19,10 +19,18 @@ option1
{
type verticalDamping;
selectionMode cellZone;
cellZone right;
selectionMode all;
lambda 0.1;
origin (1200 0 0);
direction (1 0 0);
ramp
{
type halfCosineRamp;
start 0;
duration 600;
}
lambda 0.5;
timeStart 0;
duration 1e6;

View File

@ -1,42 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name right;
type cellSet;
action new;
source boxToCell;
sourceInfo
{
box (1800 -1e6 -1e6) (1e6 1e6 1e6);
}
}
{
name right;
type cellZoneSet;
action new;
source setToCellZone;
sourceInfo
{
set right;
}
}
);
// ************************************************************************* //