mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: uniformFixedValue: adapt point bc. See #1046.
This commit is contained in:
@ -699,7 +699,6 @@ $(constraintPointPatchFields)/wedge/wedgePointPatchFields.C
|
||||
derivedPointPatchFields = $(pointPatchFields)/derived
|
||||
$(derivedPointPatchFields)/slip/slipPointPatchFields.C
|
||||
$(derivedPointPatchFields)/fixedNormalSlip/fixedNormalSlipPointPatchFields.C
|
||||
$(derivedPointPatchFields)/uniformFixedValue/uniformFixedValuePointPatchFields.C
|
||||
$(derivedPointPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.C
|
||||
$(derivedPointPatchFields)/codedFixedValue/codedFixedValuePointPatchFields.C
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ $(derivedPoint)/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorF
|
||||
$(derivedPoint)/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C
|
||||
$(derivedPoint)/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C
|
||||
$(derivedPoint)/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C
|
||||
$(derivedPoint)/uniformFixedValue/uniformFixedValuePointPatchFields.C
|
||||
$(derivedPoint)/waveDisplacement/waveDisplacementPointPatchVectorField.C
|
||||
|
||||
$(derivedPoint)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -26,6 +26,27 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uniformFixedValuePointPatchField.H"
|
||||
#include "SubField.H"
|
||||
#include "polyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::polyPatch&
|
||||
Foam::uniformFixedValuePointPatchField<Type>::getPatch(const pointPatch& p)
|
||||
{
|
||||
const polyMesh& mesh = p.boundaryMesh().mesh()();
|
||||
label patchi = mesh.boundaryMesh().findPatchID(p.name());
|
||||
|
||||
if (patchi == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot use uniformFixedValue on patch " << p.name()
|
||||
<< " since there is no underlying mesh patch" << exit(FatalError);
|
||||
}
|
||||
return mesh.boundaryMesh()[patchi];
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -52,7 +73,16 @@ uniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF, dict, false),
|
||||
uniformValue_(Function1<Type>::New("uniformValue", dict))
|
||||
uniformValue_
|
||||
(
|
||||
PatchFunction1<Type>::New
|
||||
(
|
||||
this->getPatch(p),
|
||||
"uniformValue",
|
||||
dict,
|
||||
false // generate point values
|
||||
)
|
||||
)
|
||||
{
|
||||
if (dict.found("value"))
|
||||
{
|
||||
@ -63,8 +93,7 @@ uniformFixedValuePointPatchField
|
||||
}
|
||||
else
|
||||
{
|
||||
const scalar t = this->db().time().timeOutputValue();
|
||||
fixedValuePointPatchField<Type>::operator=(uniformValue_->value(t));
|
||||
this->evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,11 +109,18 @@ uniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
|
||||
uniformValue_(ptf.uniformValue_.clone())
|
||||
uniformValue_(ptf.uniformValue_.clone(this->getPatch(p)))
|
||||
{
|
||||
// For safety re-evaluate
|
||||
const scalar t = this->db().time().timeOutputValue();
|
||||
fixedValuePointPatchField<Type>::operator=(uniformValue_->value(t));
|
||||
if (mapper.direct() && !mapper.hasUnmapped())
|
||||
{
|
||||
// Use mapping instead of re-evaluation
|
||||
this->map(ptf, mapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Evaluate since value not mapped
|
||||
this->evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +132,7 @@ uniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf),
|
||||
uniformValue_(ptf.uniformValue_.clone())
|
||||
uniformValue_(ptf.uniformValue_.clone(this->getPatch(this->patch())))
|
||||
{}
|
||||
|
||||
|
||||
@ -109,16 +145,45 @@ uniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, iF),
|
||||
uniformValue_(ptf.uniformValue_.clone())
|
||||
{
|
||||
// For safety re-evaluate
|
||||
const scalar t = this->db().time().timeOutputValue();
|
||||
fixedValuePointPatchField<Type>::operator==(uniformValue_->value(t));
|
||||
}
|
||||
uniformValue_(ptf.uniformValue_.clone(this->getPatch(this->patch())))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::uniformFixedValuePointPatchField<Type>::autoMap
|
||||
(
|
||||
const pointPatchFieldMapper& mapper
|
||||
)
|
||||
{
|
||||
fixedValuePointPatchField<Type>::autoMap(mapper);
|
||||
uniformValue_().autoMap(mapper);
|
||||
|
||||
if (uniformValue_().constant())
|
||||
{
|
||||
// If mapper is not dependent on time we're ok to evaluate
|
||||
this->evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::uniformFixedValuePointPatchField<Type>::rmap
|
||||
(
|
||||
const pointPatchField<Type>& ptf,
|
||||
const labelList& addr
|
||||
)
|
||||
{
|
||||
fixedValuePointPatchField<Type>::rmap(ptf, addr);
|
||||
|
||||
const uniformFixedValuePointPatchField& tiptf =
|
||||
refCast<const uniformFixedValuePointPatchField>(ptf);
|
||||
|
||||
uniformValue_().rmap(tiptf.uniformValue_(), addr);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::uniformFixedValuePointPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
@ -126,10 +191,8 @@ void Foam::uniformFixedValuePointPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const scalar t = this->db().time().timeOutputValue();
|
||||
fixedValuePointPatchField<Type>::operator==(uniformValue_->value(t));
|
||||
|
||||
fixedValuePointPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -51,13 +51,15 @@ SourceFiles
|
||||
#define uniformFixedValuePointPatchField_H
|
||||
|
||||
#include "fixedValuePointPatchField.H"
|
||||
#include "Function1.H"
|
||||
#include "PatchFunction1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class polyPatch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniformFixedValuePointPatchField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -67,9 +69,14 @@ class uniformFixedValuePointPatchField
|
||||
:
|
||||
public fixedValuePointPatchField<Type>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
static const polyPatch& getPatch(const pointPatch&);
|
||||
|
||||
|
||||
// Private data
|
||||
|
||||
autoPtr<Function1<Type>> uniformValue_;
|
||||
autoPtr<PatchFunction1<Type>> uniformValue_;
|
||||
|
||||
|
||||
public:
|
||||
@ -157,6 +164,23 @@ public:
|
||||
return uniformValue_;
|
||||
}
|
||||
|
||||
|
||||
// Mapping functions
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap
|
||||
(
|
||||
const pointPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Reverse map the given fvPatchField onto this fvPatchField
|
||||
virtual void rmap
|
||||
(
|
||||
const pointPatchField<Type>&,
|
||||
const labelList&
|
||||
);
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
@ -102,7 +102,8 @@ Foam::autoPtr<Foam::PatchFunction1<Type>> Foam::PatchFunction1<Type>::New
|
||||
pp,
|
||||
PatchFunction1Types::ConstantField<Type>::typeName,
|
||||
entryName,
|
||||
dict
|
||||
dict,
|
||||
faceValues
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user