mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
GIT: resolve merge conflict
This commit is contained in:
113
src/OpenFOAM/containers/Lists/BinSum/BinSum.C
Normal file
113
src/OpenFOAM/containers/Lists/BinSum/BinSum.C
Normal file
@ -0,0 +1,113 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "BinSum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class IndexType, class List, class CombineOp>
|
||||
Foam::BinSum<IndexType, List, CombineOp>::BinSum
|
||||
(
|
||||
const IndexType min,
|
||||
const IndexType max,
|
||||
const IndexType delta
|
||||
)
|
||||
:
|
||||
List(ceil((max-min)/delta), pTraits<typename List::value_type>::zero),
|
||||
min_(min),
|
||||
max_(max),
|
||||
delta_(delta),
|
||||
lowSum_(pTraits<typename List::value_type>::zero),
|
||||
highSum_(pTraits<typename List::value_type>::zero)
|
||||
{}
|
||||
|
||||
|
||||
template<class IndexType, class List, class CombineOp>
|
||||
Foam::BinSum<IndexType, List, CombineOp>::BinSum
|
||||
(
|
||||
const IndexType min,
|
||||
const IndexType max,
|
||||
const IndexType delta,
|
||||
const UList<IndexType>& indexVals,
|
||||
const List& vals,
|
||||
const CombineOp& cop
|
||||
)
|
||||
:
|
||||
List(ceil((max-min)/delta), pTraits<typename List::value_type>::zero),
|
||||
min_(min),
|
||||
max_(max),
|
||||
delta_(delta),
|
||||
lowSum_(pTraits<typename List::value_type>::zero),
|
||||
highSum_(pTraits<typename List::value_type>::zero)
|
||||
{
|
||||
forAll(indexVals, i)
|
||||
{
|
||||
add(indexVals[i], vals[i], cop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class IndexType, class List, class CombineOp>
|
||||
void Foam::BinSum<IndexType, List, CombineOp>::add
|
||||
(
|
||||
const IndexType& indexVal,
|
||||
const typename List::const_reference val,
|
||||
const CombineOp& cop
|
||||
)
|
||||
{
|
||||
if (indexVal < min_)
|
||||
{
|
||||
cop(lowSum_, val);
|
||||
}
|
||||
else if (indexVal >= max_)
|
||||
{
|
||||
cop(highSum_, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
label index = (indexVal-min_)/delta_;
|
||||
cop(this->operator[](index), val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class IndexType, class List, class CombineOp>
|
||||
void Foam::BinSum<IndexType, List, CombineOp>::add
|
||||
(
|
||||
const UList<IndexType>& indexVals,
|
||||
const List& vals,
|
||||
const CombineOp& cop
|
||||
)
|
||||
{
|
||||
forAll(indexVals, i)
|
||||
{
|
||||
add(indexVals[i], vals[i], cop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
149
src/OpenFOAM/containers/Lists/BinSum/BinSum.H
Normal file
149
src/OpenFOAM/containers/Lists/BinSum/BinSum.H
Normal file
@ -0,0 +1,149 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::BinSum
|
||||
|
||||
Description
|
||||
Sums into bins
|
||||
|
||||
SourceFiles
|
||||
BinSum.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BinSum_H
|
||||
#define BinSum_H
|
||||
|
||||
#include "ops.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class BinSum Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template
|
||||
<
|
||||
class IndexType,
|
||||
class List,
|
||||
class CombineOp = plusEqOp<typename List::value_type>
|
||||
>
|
||||
class BinSum
|
||||
:
|
||||
public List
|
||||
{
|
||||
// Private data
|
||||
|
||||
const IndexType min_;
|
||||
|
||||
const IndexType max_;
|
||||
|
||||
const IndexType delta_;
|
||||
|
||||
|
||||
//- Sum < lowest bin
|
||||
typename List::value_type lowSum_;
|
||||
|
||||
//- Sum of >= highest bin
|
||||
typename List::value_type highSum_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given min, max, delta
|
||||
BinSum
|
||||
(
|
||||
const IndexType min,
|
||||
const IndexType max,
|
||||
const IndexType delta
|
||||
);
|
||||
|
||||
//- Construct given min, max, delta and data
|
||||
BinSum
|
||||
(
|
||||
const IndexType min,
|
||||
const IndexType max,
|
||||
const IndexType delta,
|
||||
const UList<IndexType>& indexVals,
|
||||
const List& vals,
|
||||
const CombineOp& cop = plusEqOp<typename List::value_type>()
|
||||
);
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the delta
|
||||
inline IndexType delta() const
|
||||
{
|
||||
return delta_;
|
||||
}
|
||||
|
||||
//- Return the sum of all added elements < min
|
||||
inline const IndexType& lowSum() const
|
||||
{
|
||||
return lowSum_;
|
||||
}
|
||||
|
||||
//- Return the sum of all added elements >= max
|
||||
inline const IndexType& highSum() const
|
||||
{
|
||||
return highSum_;
|
||||
}
|
||||
|
||||
void add
|
||||
(
|
||||
const IndexType& indexVal,
|
||||
const typename List::const_reference val,
|
||||
const CombineOp& cop = plusEqOp<typename List::value_type>()
|
||||
);
|
||||
|
||||
void add
|
||||
(
|
||||
const UList<IndexType>& indexVals,
|
||||
const List& vals,
|
||||
const CombineOp& cop = plusEqOp<typename List::value_type>()
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "BinSum.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,33 +58,25 @@ void Foam::wedgePolyPatch::initTransforms()
|
||||
);
|
||||
centreNormal_ /= mag(centreNormal_);
|
||||
|
||||
if
|
||||
(
|
||||
mag(centreNormal_.x() + centreNormal_.y() + centreNormal_.z())
|
||||
< (1 - SMALL)
|
||||
)
|
||||
const scalar cnCmptSum =
|
||||
centreNormal_.x() + centreNormal_.y() + centreNormal_.z();
|
||||
|
||||
if (mag(cnCmptSum) < (1 - SMALL))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"wedgePolyPatch::wedgePolyPatch(const polyPatch&, "
|
||||
"const fvBoundaryMesh&)"
|
||||
) << "wedge " << name()
|
||||
FatalErrorIn("wedgePolyPatch::initTransforms()")
|
||||
<< "wedge " << name()
|
||||
<< " centre plane does not align with a coordinate plane by "
|
||||
<< 1
|
||||
- mag(centreNormal_.x()+centreNormal_.y()+centreNormal_.z())
|
||||
<< 1 - mag(cnCmptSum)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
axis_ = centreNormal_ ^ patchNormal_;
|
||||
scalar magAxis = mag(axis_);
|
||||
axis_ /= magAxis;
|
||||
|
||||
if (magAxis < SMALL)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"wedgePolyPatch::initTransforms()"
|
||||
) << "wedge " << name()
|
||||
FatalErrorIn("wedgePolyPatch::initTransforms()")
|
||||
<< "wedge " << name()
|
||||
<< " plane aligns with a coordinate plane." << nl
|
||||
<< " The wedge plane should make a small angle (~2.5deg)"
|
||||
" with the coordinate plane" << nl
|
||||
@ -95,6 +87,8 @@ void Foam::wedgePolyPatch::initTransforms()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
axis_ /= magAxis;
|
||||
|
||||
faceT_ = rotationTensor(centreNormal_, patchNormal_);
|
||||
cellT_ = faceT_ & faceT_;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -51,6 +51,31 @@ Foam::word Foam::name(const quaternion& q)
|
||||
}
|
||||
|
||||
|
||||
Foam::quaternion Foam::slerp
|
||||
(
|
||||
const quaternion& qa,
|
||||
const quaternion& qb,
|
||||
const scalar t
|
||||
)
|
||||
{
|
||||
// Calculate angle between the quaternions
|
||||
scalar cosHalfTheta = qa & qb;
|
||||
|
||||
if (mag(cosHalfTheta) >= 1)
|
||||
{
|
||||
return qa;
|
||||
}
|
||||
|
||||
scalar halfTheta = acos(cosHalfTheta);
|
||||
scalar sinHalfTheta = sqrt(1.0 - sqr(cosHalfTheta));
|
||||
|
||||
scalar wa = sin((1 - t)*halfTheta)/sinHalfTheta;
|
||||
scalar wb = sin(t*halfTheta)/sinHalfTheta;
|
||||
|
||||
return wa*qa + wb*qb;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, quaternion& q)
|
||||
|
||||
@ -106,6 +106,15 @@ public:
|
||||
// and angle theta
|
||||
inline quaternion(const vector& d, const scalar theta);
|
||||
|
||||
//- Construct a rotation quaternion given the direction d
|
||||
// and cosine angle cosTheta and a if d is normalized
|
||||
inline quaternion
|
||||
(
|
||||
const vector& d,
|
||||
const scalar cosTheta,
|
||||
const bool normalized
|
||||
);
|
||||
|
||||
//- Construct given scalar part, the vector part = vector::zero
|
||||
inline explicit quaternion(const scalar w);
|
||||
|
||||
@ -140,6 +149,8 @@ public:
|
||||
//- The rotation tensor corresponding the quaternion
|
||||
inline tensor R() const;
|
||||
|
||||
inline quaternion normalized() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
@ -207,6 +218,14 @@ inline quaternion inv(const quaternion& q);
|
||||
//- Return a string representation of a quaternion
|
||||
word name(const quaternion&);
|
||||
|
||||
//- Spherical linear interpolation of quaternions
|
||||
quaternion slerp
|
||||
(
|
||||
const quaternion& qa,
|
||||
const quaternion& qb,
|
||||
const scalar t
|
||||
);
|
||||
|
||||
//- Data associated with quaternion type are contiguous
|
||||
template<>
|
||||
inline bool contiguous<quaternion>() {return true;}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,9 +37,27 @@ inline Foam::quaternion::quaternion(const scalar w, const vector& v)
|
||||
inline Foam::quaternion::quaternion(const vector& d, const scalar theta)
|
||||
:
|
||||
w_(cos(0.5*theta)),
|
||||
v_((sin(0.5*theta)/magSqr(d))*d)
|
||||
v_((sin(0.5*theta)/mag(d))*d)
|
||||
{}
|
||||
|
||||
inline Foam::quaternion::quaternion
|
||||
(
|
||||
const vector& d,
|
||||
const scalar cosTheta,
|
||||
const bool normalized
|
||||
)
|
||||
{
|
||||
normalize();
|
||||
scalar cosHalfTheta2 = 0.5*(cosTheta + 1);
|
||||
w_ = sqrt(cosHalfTheta2);
|
||||
|
||||
if (normalized)
|
||||
{
|
||||
v_ = sqrt(1 - cosHalfTheta2)*d;
|
||||
}
|
||||
else
|
||||
{
|
||||
v_ = (sqrt(1 - cosHalfTheta2)/mag(d))*d;
|
||||
}
|
||||
}
|
||||
|
||||
inline Foam::quaternion::quaternion(const scalar w)
|
||||
@ -71,9 +89,10 @@ inline Foam::quaternion::quaternion
|
||||
const tensor& rotationTensor
|
||||
)
|
||||
{
|
||||
scalar trace = rotationTensor.xx()
|
||||
+ rotationTensor.yy()
|
||||
+ rotationTensor.zz();
|
||||
scalar trace =
|
||||
rotationTensor.xx()
|
||||
+ rotationTensor.yy()
|
||||
+ rotationTensor.zz();
|
||||
|
||||
if (trace > 0)
|
||||
{
|
||||
@ -168,6 +187,12 @@ inline Foam::vector& Foam::quaternion::v()
|
||||
}
|
||||
|
||||
|
||||
inline Foam::quaternion Foam::quaternion::normalized() const
|
||||
{
|
||||
return *this/mag(*this);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::quaternion::normalize()
|
||||
{
|
||||
operator/=(mag(*this));
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -1604,6 +1604,8 @@ Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::polyMeshAdder::add
|
||||
polyBoundaryMesh& allPatches =
|
||||
const_cast<polyBoundaryMesh&>(mesh0.boundaryMesh());
|
||||
allPatches.setSize(allPatchNames.size());
|
||||
labelList patchSizes(allPatches.size());
|
||||
labelList patchStarts(allPatches.size());
|
||||
|
||||
label startFaceI = nInternalFaces;
|
||||
|
||||
@ -1629,7 +1631,9 @@ Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::polyMeshAdder::add
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clone.
|
||||
// Clone. Note dummy size and start. Gets overwritten later in
|
||||
// resetPrimitives. This avoids getting temporarily illegal
|
||||
// SubList construction in polyPatch.
|
||||
allPatches.set
|
||||
(
|
||||
allPatchI,
|
||||
@ -1637,10 +1641,12 @@ Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::polyMeshAdder::add
|
||||
(
|
||||
allPatches,
|
||||
allPatchI,
|
||||
nFaces[patch0],
|
||||
startFaceI
|
||||
0, // dummy size
|
||||
0 // dummy start
|
||||
)
|
||||
);
|
||||
patchSizes[allPatchI] = nFaces[patch0];
|
||||
patchStarts[allPatchI] = startFaceI;
|
||||
|
||||
// Record new index in allPatches
|
||||
from0ToAllPatches[patch0] = allPatchI;
|
||||
@ -1686,10 +1692,12 @@ Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::polyMeshAdder::add
|
||||
(
|
||||
allPatches,
|
||||
allPatchI,
|
||||
nFaces[uncompactAllPatchI],
|
||||
startFaceI
|
||||
0, // dummy size
|
||||
0 // dummy start
|
||||
)
|
||||
);
|
||||
patchSizes[allPatchI] = nFaces[uncompactAllPatchI];
|
||||
patchStarts[allPatchI] = startFaceI;
|
||||
|
||||
// Record new index in allPatches
|
||||
from1ToAllPatches[patch1] = allPatchI;
|
||||
@ -1702,6 +1710,8 @@ Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::polyMeshAdder::add
|
||||
}
|
||||
|
||||
allPatches.setSize(allPatchI);
|
||||
patchSizes.setSize(allPatchI);
|
||||
patchStarts.setSize(allPatchI);
|
||||
|
||||
|
||||
// Construct map information before changing mesh0 primitives
|
||||
@ -1740,9 +1750,6 @@ Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::polyMeshAdder::add
|
||||
// Now we have extracted all information from all meshes.
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
labelList patchSizes(getPatchSizes(allPatches));
|
||||
labelList patchStarts(getPatchStarts(allPatches));
|
||||
|
||||
mesh0.resetMotion(); // delete any oldPoints.
|
||||
mesh0.resetPrimitives
|
||||
(
|
||||
|
||||
@ -216,7 +216,7 @@ Foam::scalar Foam::LiquidEvaporation<CloudType>::dh
|
||||
}
|
||||
case (parent::etEnthalpyDifference):
|
||||
{
|
||||
scalar hc = this->owner().composition().carrier().Hs(idc, p, T);
|
||||
scalar hc = this->owner().composition().carrier().Ha(idc, p, T);
|
||||
scalar hp = liquids_.properties()[idl].h(p, T);
|
||||
|
||||
dh = hc - hp;
|
||||
|
||||
@ -171,8 +171,8 @@ void Foam::LiquidEvaporationBoil<CloudType>::calculate
|
||||
forAll(this->owner().thermo().carrier().Y(), i)
|
||||
{
|
||||
scalar Yc = this->owner().thermo().carrier().Y()[i][cellI];
|
||||
Hc += Yc*this->owner().thermo().carrier().Hs(i, pc, Tc);
|
||||
Hsc += Yc*this->owner().thermo().carrier().Hs(i, ps, Ts);
|
||||
Hc += Yc*this->owner().thermo().carrier().Ha(i, pc, Tc);
|
||||
Hsc += Yc*this->owner().thermo().carrier().Ha(i, ps, Ts);
|
||||
Cpc += Yc*this->owner().thermo().carrier().Cp(i, ps, Ts);
|
||||
kappac += Yc*this->owner().thermo().carrier().kappa(i, ps, Ts);
|
||||
}
|
||||
@ -315,7 +315,7 @@ Foam::scalar Foam::LiquidEvaporationBoil<CloudType>::dh
|
||||
}
|
||||
case (parent::etEnthalpyDifference):
|
||||
{
|
||||
scalar hc = this->owner().composition().carrier().Hs(idc, p, TDash);
|
||||
scalar hc = this->owner().composition().carrier().Ha(idc, p, TDash);
|
||||
scalar hp = liquids_.properties()[idl].h(p, TDash);
|
||||
|
||||
dh = hc - hp;
|
||||
|
||||
@ -99,6 +99,7 @@ $(cellSources)/sphereToCell/sphereToCell.C
|
||||
$(cellSources)/cylinderToCell/cylinderToCell.C
|
||||
$(cellSources)/faceZoneToCell/faceZoneToCell.C
|
||||
$(cellSources)/cylinderAnnulusToCell/cylinderAnnulusToCell.C
|
||||
$(cellSources)/targetVolumeToCell/targetVolumeToCell.C
|
||||
|
||||
faceSources = sets/faceSources
|
||||
$(faceSources)/faceToFace/faceToFace.C
|
||||
|
||||
@ -0,0 +1,328 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "targetVolumeToCell.H"
|
||||
#include "polyMesh.H"
|
||||
#include "globalMeshData.H"
|
||||
#include "plane.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(targetVolumeToCell, 0);
|
||||
|
||||
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word);
|
||||
|
||||
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Foam::topoSetSource::addToUsageTable Foam::targetVolumeToCell::usage_
|
||||
(
|
||||
targetVolumeToCell::typeName,
|
||||
"\n Usage: targetVolumeToCell (nx ny nz)\n\n"
|
||||
" Adjust plane until obtained selected volume\n\n"
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::targetVolumeToCell::volumeOfSet
|
||||
(
|
||||
const PackedBoolList& selected
|
||||
) const
|
||||
{
|
||||
scalar sumVol = 0.0;
|
||||
forAll(selected, cellI)
|
||||
{
|
||||
if (selected[cellI])
|
||||
{
|
||||
sumVol += mesh_.cellVolumes()[cellI];
|
||||
}
|
||||
}
|
||||
return returnReduce(sumVol, sumOp<scalar>());
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::targetVolumeToCell::selectCells
|
||||
(
|
||||
const scalar normalComp,
|
||||
PackedBoolList& selected
|
||||
) const
|
||||
{
|
||||
selected.setSize(mesh_.nCells());
|
||||
selected = false;
|
||||
|
||||
label nSelected = 0;
|
||||
|
||||
forAll(mesh_.cellCentres(), cellI)
|
||||
{
|
||||
const point& cc = mesh_.cellCentres()[cellI];
|
||||
|
||||
if ((cc&n_) < normalComp)
|
||||
{
|
||||
selected[cellI] = true;
|
||||
nSelected++;
|
||||
}
|
||||
}
|
||||
return returnReduce(nSelected, sumOp<label>());
|
||||
}
|
||||
|
||||
|
||||
void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
{
|
||||
if (vol_ <= 0)
|
||||
{
|
||||
// Select no cells
|
||||
return;
|
||||
}
|
||||
else if (gSum(mesh_.cellVolumes()) < vol_)
|
||||
{
|
||||
// Select all cells
|
||||
forAll(mesh_.cellVolumes(), cellI)
|
||||
{
|
||||
addOrDelete(set, cellI, add);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get plane for min,max volume.
|
||||
// Planes all have base (0 0 0) and fixed normal so work only on normal
|
||||
// component.
|
||||
|
||||
scalar maxComp = -GREAT;
|
||||
label maxCells = 0;
|
||||
scalar maxVol = 0;
|
||||
scalar minComp = GREAT;
|
||||
{
|
||||
const boundBox& bb = mesh_.bounds();
|
||||
pointField points(bb.points());
|
||||
|
||||
label minPointI = -1;
|
||||
label maxPointI = -1;
|
||||
forAll(points, pointI)
|
||||
{
|
||||
scalar c = (points[pointI]&n_);
|
||||
if (c > maxComp)
|
||||
{
|
||||
maxComp = c;
|
||||
maxPointI = pointI;
|
||||
}
|
||||
else if (c < minComp)
|
||||
{
|
||||
minComp = c;
|
||||
minPointI = pointI;
|
||||
}
|
||||
}
|
||||
|
||||
PackedBoolList maxSelected(mesh_.nCells());
|
||||
maxCells = selectCells(maxComp, maxSelected);
|
||||
maxVol = volumeOfSet(maxSelected);
|
||||
|
||||
// Check that maxPoint indeed selects all cells
|
||||
if (maxCells != mesh_.globalData().nTotalCells())
|
||||
{
|
||||
WarningIn("targetVolumeToCell::combine(topoSet&, const bool) const")
|
||||
<< "Plane " << plane(points[maxPointI], n_)
|
||||
<< " selects " << maxCells
|
||||
<< " cells instead of all " << mesh_.globalData().nTotalCells()
|
||||
<< " cells. Results might be wrong." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Bisection
|
||||
// ~~~~~~~~~
|
||||
|
||||
PackedBoolList selected(mesh_.nCells());
|
||||
label nSelected = -1;
|
||||
scalar selectedVol = 0.0;
|
||||
scalar selectedComp = 0.0;
|
||||
|
||||
|
||||
scalar low = minComp;
|
||||
scalar high = maxComp;
|
||||
|
||||
const scalar tolerance = SMALL*100*(maxComp-minComp);
|
||||
|
||||
while ((high-low) > tolerance)
|
||||
{
|
||||
scalar mid = 0.5*(low + high);
|
||||
|
||||
nSelected = selectCells(mid, selected);
|
||||
selectedVol = volumeOfSet(selected);
|
||||
|
||||
//Pout<< "High:" << high << " low:" << low << " mid:" << mid << nl
|
||||
// << " nSelected:" << nSelected << nl
|
||||
// << " vol :" << selectedVol << nl
|
||||
// << endl;
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
low = mid;
|
||||
|
||||
PackedBoolList highSelected(mesh_.nCells());
|
||||
label nHigh = selectCells(high, selected);
|
||||
if (nSelected == nHigh)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
high = mid;
|
||||
|
||||
PackedBoolList lowSelected(mesh_.nCells());
|
||||
label nLow = selectCells(low, selected);
|
||||
if (nSelected == nLow)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nSelected = selectCells(high, selected);
|
||||
selectedVol = volumeOfSet(selected);
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
selectedComp = high;
|
||||
}
|
||||
else
|
||||
{
|
||||
nSelected = selectCells(low, selected);
|
||||
selectedVol = volumeOfSet(selected);
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
selectedComp = low;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("targetVolumeToCell::combine(topoSet&, const bool) const")
|
||||
<< "Did not converge onto plane. " << nl
|
||||
<< "high plane:"
|
||||
<< plane(high*n_, n_)
|
||||
<< nl
|
||||
<< "low plane :"
|
||||
<< plane(low*n_, n_)
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Info<< " Selected " << nSelected << " with actual volume " << selectedVol
|
||||
<< endl;
|
||||
|
||||
forAll(selected, cellI)
|
||||
{
|
||||
if (selected[cellI])
|
||||
{
|
||||
addOrDelete(set, cellI, add);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::targetVolumeToCell::targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const scalar vol,
|
||||
const vector& n
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
vol_(vol),
|
||||
n_(n)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::targetVolumeToCell::targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
vol_(readScalar(dict.lookup("volume"))),
|
||||
n_(dict.lookup("normal"))
|
||||
{}
|
||||
|
||||
|
||||
// Construct from Istream
|
||||
Foam::targetVolumeToCell::targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
vol_(readScalar(checkIs(is))),
|
||||
n_(checkIs(is))
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::targetVolumeToCell::~targetVolumeToCell()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::targetVolumeToCell::applyToSet
|
||||
(
|
||||
const topoSetSource::setAction action,
|
||||
topoSet& set
|
||||
) const
|
||||
{
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||
{
|
||||
Info<< " Adding cells up to target volume " << vol_
|
||||
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
|
||||
|
||||
combine(set, true);
|
||||
}
|
||||
else if (action == topoSetSource::DELETE)
|
||||
{
|
||||
Info<< " Removing cells up to target volume " << vol_
|
||||
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
|
||||
|
||||
combine(set, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::targetVolumeToCell
|
||||
|
||||
Description
|
||||
A topoSetSource to select cells based on the wanted volume of selected
|
||||
cells. Adapts a plane until it has enough.
|
||||
|
||||
SourceFiles
|
||||
targetVolumeToCell.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef targetVolumeToCell_H
|
||||
#define targetVolumeToCell_H
|
||||
|
||||
#include "topoSetSource.H"
|
||||
//#include "plane.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class targetVolumeToCell Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class targetVolumeToCell
|
||||
:
|
||||
public topoSetSource
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
//- Add usage string
|
||||
static addToUsageTable usage_;
|
||||
|
||||
//- Wanted volume
|
||||
const scalar vol_;
|
||||
|
||||
//- Normal of plane to sweep
|
||||
vector n_;
|
||||
//plane pl_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
scalar volumeOfSet(const PackedBoolList&) const;
|
||||
|
||||
label selectCells
|
||||
(
|
||||
const scalar normalComp,
|
||||
PackedBoolList& selected
|
||||
) const;
|
||||
|
||||
void combine(topoSet& set, const bool add) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("targetVolumeToCell");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const scalar vol,
|
||||
//const plane&
|
||||
const vector&
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~targetVolumeToCell();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual sourceType setType() const
|
||||
{
|
||||
return CELLSETSOURCE;
|
||||
}
|
||||
|
||||
virtual void applyToSet
|
||||
(
|
||||
const topoSetSource::setAction action,
|
||||
topoSet&
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -61,51 +61,6 @@ namespace Foam
|
||||
|
||||
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
janafThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
@ -185,6 +140,87 @@ makeBasicMixture
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
janafThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
incompressible
|
||||
);
|
||||
|
||||
makeBasicPolyMixture
|
||||
(
|
||||
pureMixture,
|
||||
3,
|
||||
sensibleInternalEnergy
|
||||
);
|
||||
|
||||
makeBasicPolyMixture
|
||||
(
|
||||
pureMixture,
|
||||
8,
|
||||
sensibleInternalEnergy
|
||||
);
|
||||
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
isobaricPerfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
isobaricPerfectGas
|
||||
);
|
||||
|
||||
makeBasicMixture
|
||||
(
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
janafThermo,
|
||||
isobaricPerfectGas
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -84,27 +84,27 @@ makeThermo
|
||||
|
||||
/* * * * * * * * * * * * * * Internal-energy-based * * * * * * * * * * * * * */
|
||||
|
||||
makeThermo
|
||||
(
|
||||
psiThermo,
|
||||
hePsiThermo,
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
// makeThermo
|
||||
// (
|
||||
// psiThermo,
|
||||
// hePsiThermo,
|
||||
// pureMixture,
|
||||
// constTransport,
|
||||
// sensibleInternalEnergy,
|
||||
// eConstThermo,
|
||||
// perfectGas
|
||||
// );
|
||||
|
||||
makeThermo
|
||||
(
|
||||
psiThermo,
|
||||
hePsiThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
eConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
// makeThermo
|
||||
// (
|
||||
// psiThermo,
|
||||
// hePsiThermo,
|
||||
// pureMixture,
|
||||
// sutherlandTransport,
|
||||
// sensibleInternalEnergy,
|
||||
// eConstThermo,
|
||||
// perfectGas
|
||||
// );
|
||||
|
||||
makeThermo
|
||||
(
|
||||
|
||||
@ -149,6 +149,104 @@ makeThermo
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makeThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
janafThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
incompressible
|
||||
);
|
||||
|
||||
makePolyThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
3,
|
||||
sensibleInternalEnergy
|
||||
);
|
||||
|
||||
makePolyThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
8,
|
||||
sensibleInternalEnergy
|
||||
);
|
||||
|
||||
makeThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
constTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
isobaricPerfectGas
|
||||
);
|
||||
|
||||
makeThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
hConstThermo,
|
||||
isobaricPerfectGas
|
||||
);
|
||||
|
||||
makeThermo
|
||||
(
|
||||
rhoThermo,
|
||||
heRhoThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
sensibleInternalEnergy,
|
||||
janafThermo,
|
||||
isobaricPerfectGas
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -128,10 +128,14 @@ greyDiffusiveViewFactorFixedValueFvPatchScalarField
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
|
||||
updateCoeffs()
|
||||
{
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Do nothing
|
||||
|
||||
if (debug)
|
||||
@ -149,6 +153,7 @@ updateCoeffs()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ Foam::porousMedia::fixedTemperature::~fixedTemperature()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::porousMedia::fixedTemperature::addEnthalpySource
|
||||
void Foam::porousMedia::fixedTemperature::addEnergySource
|
||||
(
|
||||
const basicThermo& thermo,
|
||||
const volScalarField& rho,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -78,7 +78,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Add the thermal source to the enthalpy equation
|
||||
virtual void addEnthalpySource
|
||||
virtual void addEnergySource
|
||||
(
|
||||
const basicThermo&,
|
||||
const volScalarField& rho,
|
||||
@ -100,4 +100,3 @@ public:
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -63,7 +63,7 @@ Foam::porousMedia::noThermalModel::~noThermalModel()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::porousMedia::noThermalModel::addEnthalpySource
|
||||
void Foam::porousMedia::noThermalModel::addEnergySource
|
||||
(
|
||||
const basicThermo&,
|
||||
const volScalarField&,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -70,7 +70,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Add the thermal source to the enthalpy equation
|
||||
virtual void addEnthalpySource
|
||||
virtual void addEnergySource
|
||||
(
|
||||
const basicThermo&,
|
||||
const volScalarField& rho,
|
||||
@ -92,4 +92,3 @@ public:
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -105,7 +105,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Add the thermal source to the enthalpy equation
|
||||
virtual void addEnthalpySource
|
||||
virtual void addEnergySource
|
||||
(
|
||||
const basicThermo&,
|
||||
const volScalarField& rho,
|
||||
@ -127,4 +127,3 @@ public:
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -44,7 +44,7 @@ Foam::thermalPorousZone::thermalPorousZone
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::thermalPorousZone::addEnthalpySource
|
||||
void Foam::thermalPorousZone::addEnergySource
|
||||
(
|
||||
const basicThermo& thermo,
|
||||
const volScalarField& rho,
|
||||
@ -53,7 +53,7 @@ void Foam::thermalPorousZone::addEnthalpySource
|
||||
{
|
||||
if (model_.valid())
|
||||
{
|
||||
model_->addEnthalpySource(thermo, rho, hEqn);
|
||||
model_->addEnergySource(thermo, rho, hEqn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -125,7 +125,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Add the thermal source to the enthalpy equation
|
||||
void addEnthalpySource
|
||||
void addEnergySource
|
||||
(
|
||||
const basicThermo&,
|
||||
const volScalarField& rho,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -46,7 +46,7 @@ Foam::thermalPorousZones::thermalPorousZones
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::thermalPorousZones::addEnthalpySource
|
||||
void Foam::thermalPorousZones::addEnergySource
|
||||
(
|
||||
const basicThermo& thermo,
|
||||
const volScalarField& rho,
|
||||
@ -55,7 +55,7 @@ void Foam::thermalPorousZones::addEnthalpySource
|
||||
{
|
||||
forAll(*this, i)
|
||||
{
|
||||
operator[](i).addEnthalpySource(thermo, rho, hEqn);
|
||||
operator[](i).addEnergySource(thermo, rho, hEqn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -93,7 +93,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Add the thermal source to the enthalpy equation
|
||||
void addEnthalpySource
|
||||
void addEnergySource
|
||||
(
|
||||
const basicThermo&,
|
||||
const volScalarField& rho,
|
||||
|
||||
@ -28,14 +28,14 @@ Group
|
||||
grpCmpLESTurbulence
|
||||
|
||||
Description
|
||||
One Equation Eddy Viscosity Model for incompressible flows
|
||||
One Equation Eddy Viscosity Model for compressible flows
|
||||
|
||||
Eddy viscosity SGS model using a modeled balance equation to simulate the
|
||||
behaviour of k, hence,
|
||||
\verbatim
|
||||
d/dt(rho*k) + div(rho*U*k) - div(muEff*grad(k))
|
||||
=
|
||||
-rho*D:B - ce*rho*k^3/2/delta
|
||||
-rho*D:B - ce*rho*k^(3/2)/delta
|
||||
|
||||
and
|
||||
|
||||
@ -44,10 +44,11 @@ Description
|
||||
where
|
||||
|
||||
D = symm(grad(U));
|
||||
muSgs = ck*rho*sqrt(k)*delta
|
||||
nuSgs = ck*sqrt(k)*delta
|
||||
muSgs = rho*nuSgs
|
||||
muEff = muSgs + mu
|
||||
\endverbatim
|
||||
|
||||
|
||||
SourceFiles
|
||||
oneEqEddy.C
|
||||
|
||||
|
||||
@ -142,6 +142,8 @@ void convectiveHeatTransferFvPatchScalarField::updateCoeffs()
|
||||
htc[faceI] = 0.037*pow(Re, 0.8)*cbrt(Pr[faceI])*kappaw[faceI]/L_;
|
||||
}
|
||||
}
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -353,7 +353,7 @@ void kOmegaSSTSAS::correct(const tmp<volTensorField>& gradU)
|
||||
volScalarField L(sqrt(k_)/(pow025(Cmu_)*omega_));
|
||||
volScalarField CDkOmega((2.0*alphaOmega2_)*(gradK & gradOmega)/omega_);
|
||||
volScalarField F1(this->F1(CDkOmega));
|
||||
volScalarField G(nuSgs_*0.5*S2);
|
||||
volScalarField G(nuSgs_*S2);
|
||||
|
||||
// Turbulent kinetic energy equation
|
||||
{
|
||||
|
||||
@ -35,7 +35,7 @@ Description
|
||||
\verbatim
|
||||
d/dt(k) + div(U*k) - div(nuEff*grad(k))
|
||||
=
|
||||
-B*L - ce*k^3/2/delta
|
||||
-D:B - ce*k^(3/2)/delta
|
||||
|
||||
and
|
||||
|
||||
|
||||
@ -71,9 +71,9 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
|
||||
kappa_(ptf.kappa_),
|
||||
Uref_(ptf.Uref_),
|
||||
Href_(ptf.Href_),
|
||||
z0_(ptf.z0_),
|
||||
zGround_(ptf.zGround_),
|
||||
Ustar_(ptf.Ustar_)
|
||||
z0_(ptf.z0_, mapper),
|
||||
zGround_(ptf.zGround_, mapper),
|
||||
Ustar_(ptf.Ustar_, mapper)
|
||||
{}
|
||||
|
||||
|
||||
@ -116,7 +116,8 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
|
||||
|
||||
z_ /= mag(z_);
|
||||
|
||||
evaluate();
|
||||
const vectorField& c = patch().Cf();
|
||||
scalarField::operator=(pow3(Ustar_)/(kappa_*((c & z_) - zGround_ + z0_)));
|
||||
}
|
||||
|
||||
|
||||
@ -169,14 +170,6 @@ void atmBoundaryLayerInletEpsilonFvPatchScalarField::rmap
|
||||
}
|
||||
|
||||
|
||||
void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
const vectorField& c = patch().Cf();
|
||||
tmp<scalarField> coord = (c & z_);
|
||||
scalarField::operator=(pow3(Ustar_)/(kappa_*(coord - zGround_ + z0_)));
|
||||
}
|
||||
|
||||
|
||||
void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
|
||||
@ -207,7 +207,7 @@ public:
|
||||
// Access
|
||||
|
||||
//- Return max value
|
||||
scalarField Ustar() const
|
||||
const scalarField& Ustar() const
|
||||
{
|
||||
return Ustar_;
|
||||
}
|
||||
@ -235,12 +235,6 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update coefficients
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
@ -68,14 +68,14 @@ atmBoundaryLayerInletVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
|
||||
Ustar_(ptf.Ustar_),
|
||||
Ustar_(ptf.Ustar_, mapper),
|
||||
n_(ptf.n_),
|
||||
z_(ptf.z_),
|
||||
z0_(ptf.z0_),
|
||||
z0_(ptf.z0_, mapper),
|
||||
kappa_(ptf.kappa_),
|
||||
Uref_(ptf.Uref_),
|
||||
Href_(ptf.Href_),
|
||||
zGround_(ptf.zGround_)
|
||||
zGround_(ptf.zGround_, mapper)
|
||||
{}
|
||||
|
||||
|
||||
@ -120,7 +120,25 @@ atmBoundaryLayerInletVelocityFvPatchVectorField
|
||||
Ustar_[i] = kappa_*Uref_/(log((Href_ + z0_[i])/max(z0_[i] , 0.001)));
|
||||
}
|
||||
|
||||
evaluate();
|
||||
const vectorField& c = patch().Cf();
|
||||
const scalarField coord(c & z_);
|
||||
scalarField Un(coord.size());
|
||||
|
||||
forAll(coord, i)
|
||||
{
|
||||
if ((coord[i] - zGround_[i]) < Href_)
|
||||
{
|
||||
Un[i] =
|
||||
(Ustar_[i]/kappa_)
|
||||
* log((coord[i] - zGround_[i] + z0_[i])/max(z0_[i], 0.001));
|
||||
}
|
||||
else
|
||||
{
|
||||
Un[i] = Uref_;
|
||||
}
|
||||
}
|
||||
|
||||
vectorField::operator=(n_*Un);
|
||||
}
|
||||
|
||||
|
||||
@ -145,29 +163,32 @@ atmBoundaryLayerInletVelocityFvPatchVectorField
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
void atmBoundaryLayerInletVelocityFvPatchVectorField::autoMap
|
||||
(
|
||||
const fvPatchFieldMapper& m
|
||||
)
|
||||
{
|
||||
const vectorField& c = patch().Cf();
|
||||
const scalarField coord(c & z_);
|
||||
scalarField Un(coord.size());
|
||||
fixedValueFvPatchVectorField::autoMap(m);
|
||||
z0_.autoMap(m);
|
||||
zGround_.autoMap(m);
|
||||
Ustar_.autoMap(m);
|
||||
}
|
||||
|
||||
forAll(coord, i)
|
||||
{
|
||||
if ((coord[i] - zGround_[i]) < Href_)
|
||||
{
|
||||
Un[i] =
|
||||
(Ustar_[i]/kappa_)
|
||||
* log((coord[i] - zGround_[i] + z0_[i])/max(z0_[i], 0.001));
|
||||
}
|
||||
else
|
||||
{
|
||||
Un[i] = Uref_;
|
||||
}
|
||||
}
|
||||
|
||||
vectorField::operator=(n_*Un);
|
||||
void atmBoundaryLayerInletVelocityFvPatchVectorField::rmap
|
||||
(
|
||||
const fvPatchVectorField& ptf,
|
||||
const labelList& addr
|
||||
)
|
||||
{
|
||||
fixedValueFvPatchVectorField::rmap(ptf, addr);
|
||||
|
||||
fixedValueFvPatchVectorField::updateCoeffs();
|
||||
const atmBoundaryLayerInletVelocityFvPatchVectorField& blptf =
|
||||
refCast<const atmBoundaryLayerInletVelocityFvPatchVectorField>(ptf);
|
||||
|
||||
z0_.rmap(blptf.z0_, addr);
|
||||
zGround_.rmap(blptf.zGround_, addr);
|
||||
Ustar_.rmap(blptf.Ustar_, addr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -215,26 +215,42 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return Ustar
|
||||
scalarField& Ustar()
|
||||
{
|
||||
return Ustar_;
|
||||
}
|
||||
// Access
|
||||
|
||||
//- Return flow direction
|
||||
vector& n()
|
||||
{
|
||||
return n_;
|
||||
}
|
||||
//- Return Ustar
|
||||
const scalarField& Ustar() const
|
||||
{
|
||||
return Ustar_;
|
||||
}
|
||||
|
||||
//- Return z direction
|
||||
vector& z()
|
||||
{
|
||||
return z_;
|
||||
}
|
||||
//- Return flow direction
|
||||
const vector& n() const
|
||||
{
|
||||
return n_;
|
||||
}
|
||||
|
||||
//- Return z direction
|
||||
const vector& z() const
|
||||
{
|
||||
return z_;
|
||||
}
|
||||
|
||||
|
||||
// Mapping functions
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap
|
||||
(
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Reverse map the given fvPatchField onto this fvPatchField
|
||||
virtual void rmap
|
||||
(
|
||||
const fvPatchVectorField&,
|
||||
const labelList&
|
||||
);
|
||||
|
||||
//- Update coefficients
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
|
||||
Reference in New Issue
Block a user