mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support pTotal as a derived field for surfMeshSamplers (issue #567)
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -58,10 +58,10 @@ void Foam::surfMeshSamplers::checkOutNames
|
|||||||
{
|
{
|
||||||
objectRegistry& reg = const_cast<objectRegistry&>(registry);
|
objectRegistry& reg = const_cast<objectRegistry&>(registry);
|
||||||
|
|
||||||
forAll(names, namei)
|
for (const word& fldName : names)
|
||||||
{
|
{
|
||||||
objectRegistry::iterator iter = reg.find(names[namei]);
|
objectRegistry::iterator iter = reg.find(fldName);
|
||||||
if (iter != reg.end())
|
if (iter.found())
|
||||||
{
|
{
|
||||||
registry.checkOut(*iter());
|
registry.checkOut(*iter());
|
||||||
}
|
}
|
||||||
@ -156,10 +156,8 @@ bool Foam::surfMeshSamplers::execute()
|
|||||||
DynamicList<word> added(derivedNames_.size());
|
DynamicList<word> added(derivedNames_.size());
|
||||||
DynamicList<word> cleanup(derivedNames_.size());
|
DynamicList<word> cleanup(derivedNames_.size());
|
||||||
|
|
||||||
forAll(derivedNames_, namei)
|
for (const word& derivedName : derivedNames_)
|
||||||
{
|
{
|
||||||
const word& derivedName = derivedNames_[namei];
|
|
||||||
|
|
||||||
if (derivedName == "rhoU")
|
if (derivedName == "rhoU")
|
||||||
{
|
{
|
||||||
added.append(derivedName);
|
added.append(derivedName);
|
||||||
@ -190,20 +188,48 @@ bool Foam::surfMeshSamplers::execute()
|
|||||||
{
|
{
|
||||||
cleanup.append(derivedName);
|
cleanup.append(derivedName);
|
||||||
|
|
||||||
db.store
|
const volScalarField& p =
|
||||||
(
|
mesh_.lookupObject<volScalarField>("p");
|
||||||
new volScalarField
|
|
||||||
|
if (p.dimensions() == dimPressure)
|
||||||
|
{
|
||||||
|
db.store
|
||||||
(
|
(
|
||||||
derivedName,
|
new volScalarField
|
||||||
// pTotal = p + U^2 / 2
|
|
||||||
(
|
(
|
||||||
mesh_.lookupObject<volScalarField>("p")
|
derivedName,
|
||||||
+ 0.5
|
// pTotal = p + rho U^2 / 2
|
||||||
* mesh_.lookupObject<volScalarField>("rho")
|
(
|
||||||
* magSqr(mesh_.lookupObject<volVectorField>("U"))
|
p
|
||||||
|
+ 0.5
|
||||||
|
* mesh_.lookupObject<volScalarField>("rho")
|
||||||
|
* magSqr
|
||||||
|
(
|
||||||
|
mesh_.lookupObject<volVectorField>("U")
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
db.store
|
||||||
|
(
|
||||||
|
new volScalarField
|
||||||
|
(
|
||||||
|
derivedName,
|
||||||
|
// pTotal = p + U^2 / 2
|
||||||
|
(
|
||||||
|
p
|
||||||
|
+ 0.5
|
||||||
|
* magSqr
|
||||||
|
(
|
||||||
|
mesh_.lookupObject<volVectorField>("U")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -226,10 +252,8 @@ bool Foam::surfMeshSamplers::execute()
|
|||||||
const wordList fields = acceptable.sortedToc();
|
const wordList fields = acceptable.sortedToc();
|
||||||
if (!fields.empty())
|
if (!fields.empty())
|
||||||
{
|
{
|
||||||
forAll(*this, surfI)
|
for (surfMeshSampler& s : surfaces())
|
||||||
{
|
{
|
||||||
surfMeshSampler& s = operator[](surfI);
|
|
||||||
|
|
||||||
// Potentially monitor the update for writing geometry?
|
// Potentially monitor the update for writing geometry?
|
||||||
if (s.needsUpdate())
|
if (s.needsUpdate())
|
||||||
{
|
{
|
||||||
@ -258,21 +282,20 @@ bool Foam::surfMeshSamplers::write()
|
|||||||
wordReList select(fieldSelection_.size() + derivedNames_.size());
|
wordReList select(fieldSelection_.size() + derivedNames_.size());
|
||||||
|
|
||||||
label nElem = 0;
|
label nElem = 0;
|
||||||
forAll(fieldSelection_, i)
|
for (const auto& item : fieldSelection_)
|
||||||
{
|
{
|
||||||
select[nElem++] = fieldSelection_[i];
|
select[nElem++] = item;
|
||||||
}
|
}
|
||||||
forAll(derivedNames_, i)
|
for (const auto& derivedName : derivedNames_)
|
||||||
{
|
{
|
||||||
select[nElem++] = derivedNames_[i];
|
select[nElem++] = derivedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoid duplicate entries
|
// avoid duplicate entries
|
||||||
select = wordRes::uniq(select);
|
select = wordRes::uniq(select);
|
||||||
|
|
||||||
forAll(*this, surfI)
|
for (const surfMeshSampler& s : surfaces())
|
||||||
{
|
{
|
||||||
const surfMeshSampler& s = operator[](surfI);
|
|
||||||
s.write(select);
|
s.write(select);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,10 +340,8 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
|
|||||||
if (this->size())
|
if (this->size())
|
||||||
{
|
{
|
||||||
Info<< "Reading surface description:" << nl;
|
Info<< "Reading surface description:" << nl;
|
||||||
forAll(*this, surfI)
|
for (surfMeshSampler& s : surfaces())
|
||||||
{
|
{
|
||||||
surfMeshSampler& s = operator[](surfI);
|
|
||||||
|
|
||||||
Info<< " " << s.name() << nl;
|
Info<< " " << s.name() << nl;
|
||||||
if (createOnRead)
|
if (createOnRead)
|
||||||
{
|
{
|
||||||
@ -370,9 +391,9 @@ void Foam::surfMeshSamplers::readUpdate(const polyMesh::readUpdateState state)
|
|||||||
|
|
||||||
bool Foam::surfMeshSamplers::needsUpdate() const
|
bool Foam::surfMeshSamplers::needsUpdate() const
|
||||||
{
|
{
|
||||||
forAll(*this, surfI)
|
for (const surfMeshSampler& s : surfaces())
|
||||||
{
|
{
|
||||||
if (operator[](surfI).needsUpdate())
|
if (s.needsUpdate())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -386,9 +407,9 @@ bool Foam::surfMeshSamplers::expire()
|
|||||||
{
|
{
|
||||||
bool justExpired = false;
|
bool justExpired = false;
|
||||||
|
|
||||||
forAll(*this, surfI)
|
for (surfMeshSampler& s : surfaces())
|
||||||
{
|
{
|
||||||
if (operator[](surfI).expire())
|
if (s.expire())
|
||||||
{
|
{
|
||||||
justExpired = true;
|
justExpired = true;
|
||||||
}
|
}
|
||||||
@ -407,9 +428,9 @@ bool Foam::surfMeshSamplers::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
forAll(*this, surfI)
|
for (surfMeshSampler& s : surfaces())
|
||||||
{
|
{
|
||||||
if (operator[](surfI).update())
|
if (s.update())
|
||||||
{
|
{
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,6 +134,18 @@ class surfMeshSamplers
|
|||||||
const UList<word>& names
|
const UList<word>& names
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Access the sampling surfaces
|
||||||
|
inline const PtrList<surfMeshSampler>& surfaces() const
|
||||||
|
{
|
||||||
|
return static_cast<const PtrList<surfMeshSampler>&>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Access the sampling surfaces
|
||||||
|
inline PtrList<surfMeshSampler>& surfaces()
|
||||||
|
{
|
||||||
|
return static_cast<PtrList<surfMeshSampler>&>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Filter acceptable fields types
|
//- Filter acceptable fields types
|
||||||
template<class Type>
|
template<class Type>
|
||||||
|
|||||||
Reference in New Issue
Block a user