mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: Code refactoring
This commit is contained in:
@ -3,7 +3,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) 2013-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -188,29 +188,22 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
|
|||||||
|
|
||||||
bool Foam::functionObjects::wallShearStress::execute()
|
bool Foam::functionObjects::wallShearStress::execute()
|
||||||
{
|
{
|
||||||
typedef compressible::turbulenceModel cmpModel;
|
|
||||||
typedef incompressible::turbulenceModel icoModel;
|
|
||||||
|
|
||||||
volVectorField& wallShearStress =
|
volVectorField& wallShearStress =
|
||||||
const_cast<volVectorField&>
|
mesh_.lookupObjectRef<volVectorField>(type());
|
||||||
(
|
|
||||||
mesh_.lookupObject<volVectorField>(type())
|
|
||||||
);
|
|
||||||
|
|
||||||
tmp<volSymmTensorField> Reff;
|
const word& turbModelName = turbulenceModel::propertiesName;
|
||||||
if (mesh_.foundObject<cmpModel>(turbulenceModel::propertiesName))
|
auto cmpModelPtr =
|
||||||
|
mesh_.lookupObjectPtr<compressible::turbulenceModel>(turbModelName);
|
||||||
|
auto icoModelPtr =
|
||||||
|
mesh_.lookupObjectPtr<incompressible::turbulenceModel>(turbModelName);
|
||||||
|
|
||||||
|
if (cmpModelPtr)
|
||||||
{
|
{
|
||||||
const cmpModel& model =
|
calcShearStress(cmpModelPtr->devRhoReff(), wallShearStress);
|
||||||
mesh_.lookupObject<cmpModel>(turbulenceModel::propertiesName);
|
|
||||||
|
|
||||||
Reff = model.devRhoReff();
|
|
||||||
}
|
}
|
||||||
else if (mesh_.foundObject<icoModel>(turbulenceModel::propertiesName))
|
else if (icoModelPtr)
|
||||||
{
|
{
|
||||||
const icoModel& model =
|
calcShearStress(icoModelPtr->devReff(), wallShearStress);
|
||||||
mesh_.lookupObject<icoModel>(turbulenceModel::propertiesName);
|
|
||||||
|
|
||||||
Reff = model.devReff();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -219,8 +212,6 @@ bool Foam::functionObjects::wallShearStress::execute()
|
|||||||
<< "database" << exit(FatalError);
|
<< "database" << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
calcShearStress(Reff(), wallShearStress);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,15 +73,15 @@ const Foam::basicThermo& Foam::fv::tabulatedNTUHeatTransfer::thermo
|
|||||||
const fvMesh& mesh
|
const fvMesh& mesh
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (!mesh.foundObject<basicThermo>("thermophysicalProperties"))
|
if (!mesh.foundObject<basicThermo>(basicThermo::dictName))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< " on mesh " << mesh.name()
|
<< " on mesh " << mesh.name()
|
||||||
<< " could not find thermophysicalProperties "
|
<< " could not find " << basicThermo::dictName
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mesh.lookupObject<basicThermo>("thermophysicalProperties");
|
return mesh.lookupObject<basicThermo>(basicThermo::dictName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -43,29 +43,26 @@ void Foam::AABBTree<Type>::writeOBJ
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const pointField pts(bb.points());
|
const pointField pts(bb.points());
|
||||||
forAll(pts, i)
|
for (const point& pt : pts)
|
||||||
{
|
{
|
||||||
meshTools::writeOBJ(os, pts[i]);
|
meshTools::writeOBJ(os, pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writeLinesOnly)
|
if (writeLinesOnly)
|
||||||
{
|
{
|
||||||
forAll(bb.edges, i)
|
for (const edge& e : bb.edges)
|
||||||
{
|
{
|
||||||
const edge& e = bb.edges[i];
|
|
||||||
os << "l " << e[0] + vertI + 1 << ' ' << e[1] + vertI + 1 << nl;
|
os << "l " << e[0] + vertI + 1 << ' ' << e[1] + vertI + 1 << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
forAll(bb.faces, i)
|
for (const face& f : bb.faces)
|
||||||
{
|
{
|
||||||
const face& f = bb.faces[i];
|
|
||||||
|
|
||||||
os << 'f';
|
os << 'f';
|
||||||
forAll(f, fp)
|
for (const label fpi : f)
|
||||||
{
|
{
|
||||||
os << ' ' << f[fp] + vertI + 1;
|
os << ' ' << fpi + vertI + 1;
|
||||||
}
|
}
|
||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
@ -144,7 +141,7 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
|
|
||||||
direction maxDir = 0;
|
direction maxDir = 0;
|
||||||
scalar maxSpan = span[maxDir];
|
scalar maxSpan = span[maxDir];
|
||||||
for (label dirI = 1; dirI < 3; dirI++)
|
for (label dirI = 1; dirI < 3; ++dirI)
|
||||||
{
|
{
|
||||||
if (span[dirI] > maxSpan)
|
if (span[dirI] > maxSpan)
|
||||||
{
|
{
|
||||||
@ -163,14 +160,12 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
PackedBoolList isUsedPoint(points.size());
|
PackedBoolList isUsedPoint(points.size());
|
||||||
DynamicList<scalar> component(points.size());
|
DynamicList<scalar> component(points.size());
|
||||||
|
|
||||||
forAll(objectIDs, i)
|
for (const label objI : objectIDs)
|
||||||
{
|
{
|
||||||
const label objI = objectIDs[i];
|
|
||||||
const Type& obj = objects[objI];
|
const Type& obj = objects[objI];
|
||||||
|
|
||||||
forAll(obj, pI)
|
for (const label pointI : obj)
|
||||||
{
|
{
|
||||||
const label pointI = obj[pI];
|
|
||||||
if (isUsedPoint.set(pointI))
|
if (isUsedPoint.set(pointI))
|
||||||
{
|
{
|
||||||
component.append(points[pointI][maxDir]);
|
component.append(points[pointI][maxDir]);
|
||||||
@ -203,17 +198,15 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
DynamicList<label> maxBinObjectIDs(objectIDs.size());
|
DynamicList<label> maxBinObjectIDs(objectIDs.size());
|
||||||
treeBoundBox maxBb(boundBox::invertedBox);
|
treeBoundBox maxBb(boundBox::invertedBox);
|
||||||
|
|
||||||
forAll(objectIDs, i)
|
for (const label objI : objectIDs)
|
||||||
{
|
{
|
||||||
const label objI = objectIDs[i];
|
|
||||||
const Type& obj = objects[objI];
|
const Type& obj = objects[objI];
|
||||||
|
|
||||||
bool intoMin = false;
|
bool intoMin = false;
|
||||||
bool intoMax = false;
|
bool intoMax = false;
|
||||||
|
|
||||||
forAll(obj, pI)
|
for (const label pointI : obj)
|
||||||
{
|
{
|
||||||
const label pointI = obj[pI];
|
|
||||||
const point& pt = points[pointI];
|
const point& pt = points[pointI];
|
||||||
if (pt[maxDir] < divMin)
|
if (pt[maxDir] < divMin)
|
||||||
{
|
{
|
||||||
@ -225,7 +218,8 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: object is inserted into both min/max child boxes (duplicated)
|
||||||
|
// if it crosses the bin boundaries
|
||||||
if (intoMin)
|
if (intoMin)
|
||||||
{
|
{
|
||||||
minBinObjectIDs.append(objI);
|
minBinObjectIDs.append(objI);
|
||||||
@ -238,7 +232,7 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inflate box in case geometry reduces to 2-D
|
// Inflate box in case geometry reduces to 2-D
|
||||||
if (minBinObjectIDs.size())
|
if (minBinObjectIDs.size())
|
||||||
{
|
{
|
||||||
minBb.inflate(0.01);
|
minBb.inflate(0.01);
|
||||||
@ -255,13 +249,13 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
label minI;
|
label minI;
|
||||||
if (minBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
|
if (minBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
|
||||||
{
|
{
|
||||||
// new leaf
|
// New leaf
|
||||||
minI = nodes.size();
|
minI = nodes.size();
|
||||||
nodes.append(labelPair(-1, -1));
|
nodes.append(labelPair(-1, -1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// update existing leaf
|
// Update existing leaf
|
||||||
minI = -addressing.size() - 1;
|
minI = -addressing.size() - 1;
|
||||||
addressing.append(minBinObjectIDs);
|
addressing.append(minBinObjectIDs);
|
||||||
}
|
}
|
||||||
@ -269,13 +263,13 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
label maxI;
|
label maxI;
|
||||||
if (maxBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
|
if (maxBinObjectIDs.size() > minLeafSize_ && level < maxLevel_)
|
||||||
{
|
{
|
||||||
// new leaf
|
// New leaf
|
||||||
maxI = nodes.size();
|
maxI = nodes.size();
|
||||||
nodes.append(labelPair(-1, -1));
|
nodes.append(labelPair(-1, -1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// update existing leaf
|
// Update existing leaf
|
||||||
maxI = -addressing.size() - 1;
|
maxI = -addressing.size() - 1;
|
||||||
addressing.append(maxBinObjectIDs);
|
addressing.append(maxBinObjectIDs);
|
||||||
}
|
}
|
||||||
@ -283,7 +277,7 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
nodes(nodeI) = labelPair(minI, maxI);
|
nodes(nodeI) = labelPair(minI, maxI);
|
||||||
bbs(nodeI) = Pair<treeBoundBox>(minBb, maxBb);
|
bbs(nodeI) = Pair<treeBoundBox>(minBb, maxBb);
|
||||||
|
|
||||||
// recurse
|
// Recurse
|
||||||
if (minI >= 0)
|
if (minI >= 0)
|
||||||
{
|
{
|
||||||
createBoxes
|
createBoxes
|
||||||
@ -437,10 +431,8 @@ const Foam::List<Foam::labelList>& Foam::AABBTree<Type>::addressing() const
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::AABBTree<Type>::pointInside(const point& pt) const
|
bool Foam::AABBTree<Type>::pointInside(const point& pt) const
|
||||||
{
|
{
|
||||||
forAll(boundBoxes_, i)
|
for (const treeBoundBox& bb : boundBoxes_)
|
||||||
{
|
{
|
||||||
const treeBoundBox& bb = boundBoxes_[i];
|
|
||||||
|
|
||||||
if (bb.contains(pt))
|
if (bb.contains(pt))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -454,10 +446,8 @@ bool Foam::AABBTree<Type>::pointInside(const point& pt) const
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::AABBTree<Type>::overlaps(const boundBox& bbIn) const
|
bool Foam::AABBTree<Type>::overlaps(const boundBox& bbIn) const
|
||||||
{
|
{
|
||||||
forAll(boundBoxes_, i)
|
for (const treeBoundBox& bb : boundBoxes_)
|
||||||
{
|
{
|
||||||
const treeBoundBox& bb = boundBoxes_[i];
|
|
||||||
|
|
||||||
if (bb.overlaps(bbIn))
|
if (bb.overlaps(bbIn))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -49,8 +49,7 @@ const Foam::word Foam::basicThermo::dictName("thermophysicalProperties");
|
|||||||
|
|
||||||
Foam::wordList Foam::basicThermo::heBoundaryBaseTypes()
|
Foam::wordList Foam::basicThermo::heBoundaryBaseTypes()
|
||||||
{
|
{
|
||||||
const volScalarField::Boundary& tbf =
|
const volScalarField::Boundary& tbf = this->T_.boundaryField();
|
||||||
this->T_.boundaryField();
|
|
||||||
|
|
||||||
wordList hbt(tbf.size(), word::null);
|
wordList hbt(tbf.size(), word::null);
|
||||||
|
|
||||||
@ -81,8 +80,7 @@ Foam::wordList Foam::basicThermo::heBoundaryBaseTypes()
|
|||||||
|
|
||||||
Foam::wordList Foam::basicThermo::heBoundaryTypes()
|
Foam::wordList Foam::basicThermo::heBoundaryTypes()
|
||||||
{
|
{
|
||||||
const volScalarField::Boundary& tbf =
|
const volScalarField::Boundary& tbf = this->T_.boundaryField();
|
||||||
this->T_.boundaryField();
|
|
||||||
|
|
||||||
wordList hbt = tbf.types();
|
wordList hbt = tbf.types();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user