Skip to content
Permalink
Browse files

dynamicFvMesh: Replaced the hard-coded "U" boundary correction to an …

…optional list

In the latest generation of solvers supporting mesh-motion using Uf to correct
phi it is no longer necessary to correct the velocity field boundary conditions
directly following mesh motion so the "velocityFields" input list in
dynamicMeshDict is optional and only provided to support legacy "DyM" solvers
and defaults to an empty list.
  • Loading branch information...
Henry Weller
Henry Weller committed Mar 21, 2019
1 parent a1a225c commit 12c4abe3ba0e2b1304505270e056704351266baf
@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/

#include "dynamicFvMesh.H"
#include "volFields.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

@@ -107,10 +108,37 @@ Foam::dynamicFvMesh::dynamicFvMesh
{}


Foam::dynamicFvMesh::velocityMotionCorrection::velocityMotionCorrection
(
const dynamicFvMesh& mesh,
const dictionary& dict
)
:
mesh_(mesh),
velocityFields_(dict.lookupOrDefault("velocityFields", wordList()))
{}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::dynamicFvMesh::~dynamicFvMesh()
{}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

void Foam::dynamicFvMesh::velocityMotionCorrection::update() const
{
forAll(velocityFields_, i)
{
if (mesh_.foundObject<volVectorField>(velocityFields_[i]))
{
mesh_.lookupObjectRef<volVectorField>
(
velocityFields_[i]
).correctBoundaryConditions();
}
}
}

// ************************************************************************* //
@@ -87,6 +87,33 @@ public:
);


//- Helper class to update the velocity boundary conditions
// following mesh motion
class velocityMotionCorrection
{
// Private data

const dynamicFvMesh& mesh_;

wordList velocityFields_;

public:

// Constructors

velocityMotionCorrection
(
const dynamicFvMesh& mesh,
const dictionary& dict
);


// Member Functions

void update() const;
};


// Constructors

//- Construct from objectRegistry, and read/write options
@@ -57,14 +57,16 @@ Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh(const IOobject& io)
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
),
velocityMotionCorrection_(*this, dynamicMeshDict())
{
Info<< "Performing a dynamic mesh calculation: " << endl
<< "amplitude: " << amplitude_
<< " frequency: " << frequency_
<< " refPlaneX: " << refPlaneX_ << endl;
}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh()
@@ -103,7 +105,7 @@ bool Foam::dynamicInkJetFvMesh::update()

fvMesh::movePoints(newPoints);

lookupObjectRef<volVectorField>("U").correctBoundaryConditions();
velocityMotionCorrection_.update();

return true;
}
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -67,6 +67,11 @@ class dynamicInkJetFvMesh

pointIOField stationaryPoints_;

//- Optional list of vectorFields to update for mesh motion
// For modern solvers using Uf and correctPhi to update the flux
// after motion it is not necessary to specify a "velocityFields" list
velocityMotionCorrection velocityMotionCorrection_;


// Private Member Functions

@@ -55,7 +55,8 @@ Foam::dynamicInterpolatedFvMesh::dynamicInterpolatedFvMesh(const IOobject& io)
displacement_
? new pointIOField(points0IO(*this))
: nullptr
)
),
velocityMotionCorrection_(*this, dynamicMeshDict())
{}


@@ -78,7 +79,7 @@ bool Foam::dynamicInterpolatedFvMesh::update()
fvMesh::movePoints(pointInterpolator_.curPointField());
}

lookupObjectRef<volVectorField>("U").correctBoundaryConditions();
velocityMotionCorrection_.update();

return true;
}
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -85,6 +85,11 @@ class dynamicInterpolatedFvMesh
//- Starting points
autoPtr<pointIOField> points0_;

//- Optional list of vectorFields to update for mesh motion
// For modern solvers using Uf and correctPhi to update the flux
// after motion it is not necessary to specify a "velocityFields" list
velocityMotionCorrection velocityMotionCorrection_;


// Private Member Functions

@@ -26,7 +26,6 @@ License
#include "dynamicMotionSolverFvMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "motionSolver.H"
#include "volFields.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

@@ -47,7 +46,8 @@ namespace Foam
Foam::dynamicMotionSolverFvMesh::dynamicMotionSolverFvMesh(const IOobject& io)
:
dynamicFvMesh(io),
motionPtr_(motionSolver::New(*this, dynamicMeshDict()))
motionPtr_(motionSolver::New(*this, dynamicMeshDict())),
velocityMotionCorrection_(*this, dynamicMeshDict())
{}


@@ -68,11 +68,7 @@ const Foam::motionSolver& Foam::dynamicMotionSolverFvMesh::motion() const
bool Foam::dynamicMotionSolverFvMesh::update()
{
fvMesh::movePoints(motionPtr_->newPoints());

if (foundObject<volVectorField>("U"))
{
lookupObjectRef<volVectorField>("U").correctBoundaryConditions();
}
velocityMotionCorrection_.update();

return true;
}
@@ -44,23 +44,8 @@ namespace Foam

class motionSolver;

class velocityMotionCorrection
{
// Private data

wordList velocityFields_;

public:

velocityMotionCorrection(const dictionary& dict)
:
velocityFields_(dict.lookup("velocityFields"))
{}
};


/*---------------------------------------------------------------------------*\
Class dynamicMotionSolverFvMesh Declaration
Class dynamicMotionSolverFvMesh Declaration
\*---------------------------------------------------------------------------*/

class dynamicMotionSolverFvMesh
@@ -71,6 +56,11 @@ class dynamicMotionSolverFvMesh

autoPtr<motionSolver> motionPtr_;

//- Optional list of vectorFields to update for mesh motion
// For modern solvers using Uf and correctPhi to update the flux
// after motion it is not necessary to specify a "velocityFields" list
velocityMotionCorrection velocityMotionCorrection_;


// Private Member Functions

@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -138,19 +138,6 @@ bool Foam::rawTopoChangerFvMesh::update()
zeroUnmappedValues<symmTensor, fvPatchField, volMesh>(mappedFace);
zeroUnmappedValues<tensor, fvPatchField, volMesh>(mappedFace);

// Special handling for phi: set unmapped faces to recreated phi
Info<< "rawTopoChangerFvMesh :"
<< " recreating phi for unmapped boundary values." << endl;
const volVectorField& U = lookupObject<volVectorField>("U");
surfaceScalarField& phi = lookupObjectRef<surfaceScalarField>("phi");
setUnmappedValues
(
phi,
mappedFace,
(linearInterpolate(U) & Sf())()
);


if (topoChangeMap().hasMotionPoints())
{
pointField newPoints = topoChangeMap().preMotionPoints();

0 comments on commit 12c4abe

Please sign in to comment.
You can’t perform that action at this time.