/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 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 .
\*---------------------------------------------------------------------------*/
#include "expInletFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::expInletFvPatchVectorField::
expInletFvPatchVectorField
(
const fvPatch& p,
const DimensionedField& iF
)
:
fixedValueFvPatchVectorField(p, iF),
meanVelocity_(0.0),
n_(Zero),
R_(Zero)
{
}
Foam::expInletFvPatchVectorField::
expInletFvPatchVectorField
(
const fvPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
//dict.lookup will look for these keywords in the input dictionary
fixedValueFvPatchVectorField(p, iF),
meanVelocity_(dict.lookup("meanVelocity")),
n_(pTraits(dict.lookup("n"))),
R_(pTraits(dict.lookup("R")))
{
fixedValueFvPatchVectorField::evaluate();
if (mag(n_) < SMALL || mag(R_) < SMALL) {
FatalErrorIn("expInletFvPatchVectorField(dict)")
<< "n and/or R given with zero or close to zero."
<< abort(FatalError); //Abort exeuction - solver will exit
}
n_ /= mag(n_); //This is equivalent to n_ = n_/mag(n_)
R_ /= mag(R_); //This is equivalent to R_ = R_/(mag(y_)
/*
// Initialise with the value entry if evaluation is not possible
fvPatchVectorField::operator=
(
vectorField("value", dict, p.size())
);
*/
}
Foam::expInletFvPatchVectorField::
expInletFvPatchVectorField
(
const expInletFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
meanVelocity_(ptf.meanVelocity_),
n_(ptf.n_),
R_(ptf.R_)
{}
Foam::expInletFvPatchVectorField::
expInletFvPatchVectorField
(
const expInletFvPatchVectorField& ptf
)
:
fixedValueFvPatchVectorField(ptf),
meanVelocity_(ptf.meanVelocity_),
n_(ptf.n_),
R_(ptf.R_)
{}
Foam::expInletFvPatchVectorField::
expInletFvPatchVectorField
(
const expInletFvPatchVectorField& ptf,
const DimensionedField& iF
)
:
fixedValueFvPatchVectorField(ptf, iF),
meanVelocity_(ptf.meanVelocity_),
n_(ptf.n_),
R_(ptf.R_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::expInletFvPatchVectorField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchVectorField::autoMap(m);
}
void Foam::expInletFvPatchVectorField::rmap
(
const fvPatchVectorField& ptf,
const labelList& addr
)
{
fixedValueFvPatchVectorField::rmap(ptf, addr);
const expInletFvPatchVectorField& tiptf =
refCast(ptf);
}
void Foam::expInletFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
//Get dimensions of the bounding box: MIN and MAX points
boundBox bb(patch().patch().localPoints(), true);
//Calculate coordinates of centre point of the patch
vector ctr = 0.5*(bb.max() + bb.min());
vector Dh = (bb.max() - bb.min());
//Access centre of the faces in the patch
const vectorField& c = patch().Cf();
//Computes scalar field to be used for defining the parabolic profile
//& denotes dot product of two vectors in OpenFOAM
scalarField coord = 2*((c - ctr) & R_)/(Dh & R_);
fixedValueFvPatchVectorField::operator==
(
n_*meanVelocity_*(1.0 - sqr(coord))
);
fixedValueFvPatchVectorField::updateCoeffs();
Info << endl << "Face centers (c):" << endl;
Info << c << endl;
Info << endl << "Patch center (ctr):" << endl;
Info << ctr << endl;
Info << endl << "Patch (c - ctr):" << endl;
Info << c - ctr << endl;
Info << endl << "Patch max bound (bb.max):" << endl;
Info << bb.max() << endl;
Info << endl << "Patch min bound (bb.max):" << endl;
Info << bb.min() << endl;
Info << endl << "Patch coord ( 2*((c - ctr) & R_)/((Dh & R_) ):" << endl;
Info << coord << endl;
Info << endl << "Patch ( 1.0 - sqr(coord)) :" << endl;
Info << n_*meanVelocity_*(1.0 - sqr(coord))<< endl;
Info << endl << "Loop for c, BC assigment" << endl;
//for (int faceI=0; Cf.size()