Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2011-10-21 14:37:26 +01:00
77 changed files with 7087 additions and 1653 deletions

View File

@ -45,9 +45,29 @@
),
thermo.rho()
);
volScalarField& p = thermo.p();
volScalarField& hs = thermo.hs();
volScalarField Rspecific
(
IOobject
(
"Rspecific",
runTime.timeName(),
runTime,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar
(
"zero",
dimensionSet(dimEnergy/dimMass/dimTemperature),
0.0
)
);
volVectorField U
(
IOobject

View File

@ -3,7 +3,15 @@
rho = thermo.rho();
if (constProp == "volume")
{
p[0] = rho0*R0*thermo.T()[0];
scalar invW = 0.0;
forAll(Y, i)
{
invW += Y[i][0]/specieData[i].W();
}
Rspecific[0] = 1000.0*constant::physicoChemical::R.value()*invW;
p[0] = rho0*Rspecific[0]*thermo.T()[0];
rho[0] = rho0;
}
}

View File

@ -106,6 +106,7 @@
scalar rho0 = rho[0];
scalar u0 = hs0 - p0/rho0;
scalar R0 = p0/(rho0*T0);
Rspecific[0] = R0;
scalar integratedHeat = 0.0;

View File

@ -0,0 +1,3 @@
Test-PatchEdgeFaceWave.C
EXE = $(FOAM_USER_APPBIN)/Test-PatchEdgeFaceWave

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,132 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Description
Test PatchEdgeFaceWave.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "volFields.H"
#include "PatchEdgeFaceWave.H"
#include "patchEdgeFaceInfo.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::validArgs.append("patch");
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Get name of patch
const word patchName = args[1];
const polyPatch& patch = patches[patchName];
// Data on all edges and faces
List<patchEdgeFaceInfo> allEdgeInfo(patch.nEdges());
List<patchEdgeFaceInfo> allFaceInfo(patch.size());
// Initial seed
DynamicList<label> initialEdges;
DynamicList<patchEdgeFaceInfo> initialEdgesInfo;
// Just set an edge on the master
if (Pstream::master())
{
label edgeI = 0;
Info<< "Starting walk on edge " << edgeI << endl;
initialEdges.append(edgeI);
const edge& e = patch.edges()[edgeI];
initialEdgesInfo.append
(
patchEdgeFaceInfo
(
e.centre(patch.localPoints()),
0.0
)
);
}
// Walk
PatchEdgeFaceWave
<
primitivePatch,
patchEdgeFaceInfo
> calc
(
mesh,
patch,
initialEdges,
initialEdgesInfo,
allEdgeInfo,
allFaceInfo,
returnReduce(patch.nEdges(), sumOp<label>())
);
// Extract as patchField
volScalarField vsf
(
IOobject
(
"patchDist",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("patchDist", dimLength, 0.0)
);
scalarField pf(vsf.boundaryField()[patch.index()].size());
forAll(pf, faceI)
{
pf[faceI] = Foam::sqrt(allFaceInfo[faceI].distSqr());
}
vsf.boundaryField()[patch.index()] = pf;
Info<< "Writing patchDist volScalarField to " << runTime.value()
<< endl;
vsf.write();
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,4 +1,3 @@
patchPointEdgeCirculator.C
createShellMesh.C
extrudeToRegionMesh.C

View File

@ -31,130 +31,381 @@ License
#include "polyAddFace.H"
#include "polyModifyFace.H"
#include "polyAddCell.H"
#include "patchPointEdgeCirculator.H"
#include "labelPair.H"
#include "indirectPrimitivePatch.H"
#include "mapDistribute.H"
#include "globalMeshData.H"
#include "PatchTools.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::createShellMesh, 0);
namespace Foam
{
template<>
class minEqOp<labelPair>
{
public:
void operator()(labelPair& x, const labelPair& y) const
{
x[0] = min(x[0], y[0]);
x[1] = min(x[1], y[1]);
}
};
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::createShellMesh::calcPointRegions
// Synchronise edges
void Foam::createShellMesh::syncEdges
(
const primitiveFacePatch& patch,
const PackedBoolList& nonManifoldEdge,
faceList& pointRegions,
labelList& regionPoints
const globalMeshData& globalData,
const labelList& patchEdges,
const labelList& coupledEdges,
const PackedBoolList& sameEdgeOrientation,
PackedBoolList& isChangedEdge,
DynamicList<label>& changedEdges,
labelPairList& allEdgeData
)
{
pointRegions.setSize(patch.size());
forAll(pointRegions, faceI)
const mapDistribute& map = globalData.globalEdgeSlavesMap();
const PackedBoolList& cppOrientation = globalData.globalEdgeOrientation();
// Convert patch-edge data into cpp-edge data
labelPairList cppEdgeData
(
map.constructSize(),
labelPair(labelMax, labelMax)
);
forAll(patchEdges, i)
{
const face& f = patch.localFaces()[faceI];
pointRegions[faceI].setSize(f.size(), -1);
label patchEdgeI = patchEdges[i];
label coupledEdgeI = coupledEdges[i];
if (isChangedEdge[patchEdgeI])
{
const labelPair& data = allEdgeData[patchEdgeI];
// Patch-edge data needs to be converted into coupled-edge data
// (optionally flipped) and consistent in orientation with
// other coupled edge (optionally flipped)
if (sameEdgeOrientation[i] == cppOrientation[coupledEdgeI])
{
cppEdgeData[coupledEdgeI] = data;
}
else
{
cppEdgeData[coupledEdgeI] = labelPair(data[1], data[0]);
}
}
}
label nRegions = 0;
// Synchronise
globalData.syncData
(
cppEdgeData,
globalData.globalEdgeSlaves(),
globalData.globalEdgeTransformedSlaves(),
map,
minEqOp<labelPair>()
);
forAll(pointRegions, faceI)
// Back from cpp-edge to patch-edge data
forAll(patchEdges, i)
{
label patchEdgeI = patchEdges[i];
label coupledEdgeI = coupledEdges[i];
if (cppEdgeData[coupledEdgeI] != labelPair(labelMax, labelMax))
{
const labelPair& data = cppEdgeData[coupledEdgeI];
if (sameEdgeOrientation[i] == cppOrientation[coupledEdgeI])
{
allEdgeData[patchEdgeI] = data;
}
else
{
allEdgeData[patchEdgeI] = labelPair(data[1], data[0]);
}
if (!isChangedEdge[patchEdgeI])
{
changedEdges.append(patchEdgeI);
isChangedEdge[patchEdgeI] = true;
}
}
}
}
void Foam::createShellMesh::calcPointRegions
(
const globalMeshData& globalData,
const primitiveFacePatch& patch,
const PackedBoolList& nonManifoldEdge,
faceList& pointGlobalRegions,
faceList& pointLocalRegions,
labelList& localToGlobalRegion
)
{
const indirectPrimitivePatch& cpp = globalData.coupledPatch();
// Calculate correspondence between patch and globalData.coupledPatch.
labelList patchEdges;
labelList coupledEdges;
PackedBoolList sameEdgeOrientation;
PatchTools::matchEdges
(
cpp,
patch,
coupledEdges,
patchEdges,
sameEdgeOrientation
);
// Initial unique regions
// ~~~~~~~~~~~~~~~~~~~~~~
// These get merged later on across connected edges.
// 1. Count
label nMaxRegions = 0;
forAll(patch.localFaces(), faceI)
{
const face& f = patch.localFaces()[faceI];
nMaxRegions += f.size();
}
forAll(f, fp)
const globalIndex globalRegions(nMaxRegions);
// 2. Assign unique regions
label nRegions = 0;
pointGlobalRegions.setSize(patch.size());
forAll(pointGlobalRegions, faceI)
{
const face& f = patch.localFaces()[faceI];
labelList& pRegions = pointGlobalRegions[faceI];
pRegions.setSize(f.size());
forAll(pRegions, fp)
{
if (pointRegions[faceI][fp] == -1)
pRegions[fp] = globalRegions.toGlobal(nRegions++);
}
}
DynamicList<label> changedEdges(patch.nEdges());
labelPairList allEdgeData(patch.nEdges(), labelPair(labelMax, labelMax));
PackedBoolList isChangedEdge(patch.nEdges());
// Fill initial seed
// ~~~~~~~~~~~~~~~~~
forAll(patch.edgeFaces(), edgeI)
{
if (!nonManifoldEdge[edgeI])
{
// Take over value from one face only.
const edge& e = patch.edges()[edgeI];
label faceI = patch.edgeFaces()[edgeI][0];
const face& f = patch.localFaces()[faceI];
label fp0 = findIndex(f, e[0]);
label fp1 = findIndex(f, e[1]);
allEdgeData[edgeI] = labelPair
(
pointGlobalRegions[faceI][fp0],
pointGlobalRegions[faceI][fp1]
);
if (!isChangedEdge[edgeI])
{
// Found unassigned point. Distribute current region.
label pointI = f[fp];
label edgeI = patch.faceEdges()[faceI][fp];
changedEdges.append(edgeI);
isChangedEdge[edgeI] = true;
}
}
}
patchPointEdgeCirculator circ
(
patch,
nonManifoldEdge,
edgeI,
findIndex(patch.edgeFaces()[edgeI], faceI),
pointI
);
for
(
patchPointEdgeCirculator iter = circ.begin();
iter != circ.end();
++iter
)
syncEdges
(
globalData,
patchEdges,
coupledEdges,
sameEdgeOrientation,
isChangedEdge,
changedEdges,
allEdgeData
);
// Edge-Face-Edge walk across patch
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Across edge minimum regions win
while (true)
{
// From edge to face
// ~~~~~~~~~~~~~~~~~
DynamicList<label> changedFaces(patch.size());
PackedBoolList isChangedFace(patch.size());
forAll(changedEdges, changedI)
{
label edgeI = changedEdges[changedI];
const labelPair& edgeData = allEdgeData[edgeI];
const edge& e = patch.edges()[edgeI];
const labelList& eFaces = patch.edgeFaces()[edgeI];
forAll(eFaces, i)
{
label faceI = eFaces[i];
const face& f = patch.localFaces()[faceI];
// Combine edgeData with face data
label fp0 = findIndex(f, e[0]);
if (pointGlobalRegions[faceI][fp0] > edgeData[0])
{
label face2 = iter.faceID();
if (face2 != -1)
pointGlobalRegions[faceI][fp0] = edgeData[0];
if (!isChangedFace[faceI])
{
const face& f2 = patch.localFaces()[face2];
label fp2 = findIndex(f2, pointI);
label& region = pointRegions[face2][fp2];
if (region != -1)
{
FatalErrorIn
(
"createShellMesh::calcPointRegions(..)"
) << "On point " << pointI
<< " at:" << patch.localPoints()[pointI]
<< " found region:" << region
<< abort(FatalError);
}
region = nRegions;
isChangedFace[faceI] = true;
changedFaces.append(faceI);
}
}
nRegions++;
label fp1 = findIndex(f, e[1]);
if (pointGlobalRegions[faceI][fp1] > edgeData[1])
{
pointGlobalRegions[faceI][fp1] = edgeData[1];
if (!isChangedFace[faceI])
{
isChangedFace[faceI] = true;
changedFaces.append(faceI);
}
}
}
}
label nChangedFaces = returnReduce(changedFaces.size(), sumOp<label>());
if (nChangedFaces == 0)
{
break;
}
// From face to edge
// ~~~~~~~~~~~~~~~~~
isChangedEdge = false;
changedEdges.clear();
forAll(changedFaces, i)
{
label faceI = changedFaces[i];
const face& f = patch.localFaces()[faceI];
const labelList& fEdges = patch.faceEdges()[faceI];
forAll(fEdges, fp)
{
label edgeI = fEdges[fp];
if (!nonManifoldEdge[edgeI])
{
const edge& e = patch.edges()[edgeI];
label fp0 = findIndex(f, e[0]);
label region0 = pointGlobalRegions[faceI][fp0];
label fp1 = findIndex(f, e[1]);
label region1 = pointGlobalRegions[faceI][fp1];
if
(
(allEdgeData[edgeI][0] > region0)
|| (allEdgeData[edgeI][1] > region1)
)
{
allEdgeData[edgeI] = labelPair(region0, region1);
if (!isChangedEdge[edgeI])
{
changedEdges.append(edgeI);
isChangedEdge[edgeI] = true;
}
}
}
}
}
syncEdges
(
globalData,
patchEdges,
coupledEdges,
sameEdgeOrientation,
isChangedEdge,
changedEdges,
allEdgeData
);
label nChangedEdges = returnReduce(changedEdges.size(), sumOp<label>());
if (nChangedEdges == 0)
{
break;
}
}
// From region back to originating point (many to one, a point might
// have multiple regions though)
regionPoints.setSize(nRegions);
forAll(pointRegions, faceI)
// Assign local regions
// ~~~~~~~~~~~~~~~~~~~~
// Calculate addressing from global region back to local region
pointLocalRegions.setSize(patch.size());
Map<label> globalToLocalRegion(globalRegions.localSize()/4);
DynamicList<label> dynLocalToGlobalRegion(globalToLocalRegion.size());
forAll(patch.localFaces(), faceI)
{
const face& f = patch.localFaces()[faceI];
face& pRegions = pointLocalRegions[faceI];
pRegions.setSize(f.size());
forAll(f, fp)
{
regionPoints[pointRegions[faceI][fp]] = f[fp];
}
}
label globalRegionI = pointGlobalRegions[faceI][fp];
Map<label>::iterator fnd = globalToLocalRegion.find(globalRegionI);
if (debug)
{
const labelListList& pointFaces = patch.pointFaces();
forAll(pointFaces, pointI)
{
label region = -1;
const labelList& pFaces = pointFaces[pointI];
forAll(pFaces, i)
if (fnd != globalToLocalRegion.end())
{
label faceI = pFaces[i];
const face& f = patch.localFaces()[faceI];
label fp = findIndex(f, pointI);
if (region == -1)
{
region = pointRegions[faceI][fp];
}
else if (region != pointRegions[faceI][fp])
{
Pout<< "Non-manifold point:" << pointI
<< " at " << patch.localPoints()[pointI]
<< " region:" << region
<< " otherRegion:" << pointRegions[faceI][fp]
<< endl;
}
// Already encountered this global region. Assign same local one
pRegions[fp] = fnd();
}
else
{
// Region not yet seen. Create new one
label localRegionI = globalToLocalRegion.size();
pRegions[fp] = localRegionI;
globalToLocalRegion.insert(globalRegionI, localRegionI);
dynLocalToGlobalRegion.append(globalRegionI);
}
}
}
localToGlobalRegion.transfer(dynLocalToGlobalRegion);
}

View File

@ -41,6 +41,7 @@ SourceFiles
#include "primitiveFacePatch.H"
#include "PackedBoolList.H"
#include "labelPair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,6 +51,7 @@ namespace Foam
// Forward declaration of classes
class mapPolyMesh;
class polyTopoChange;
class globalMeshData;
/*---------------------------------------------------------------------------*\
Class createShellMesh Declaration
@ -80,6 +82,18 @@ class createShellMesh
// Private Member Functions
static void syncEdges
(
const globalMeshData&,
const labelList&,
const labelList&,
const PackedBoolList& sameEdgeOrientation,
PackedBoolList& isChangedEdge,
DynamicList<label>& changedEdges,
labelPairList& allEdgeData
);
//- Disallow default bitwise copy construct
createShellMesh(const createShellMesh&);
@ -142,13 +156,22 @@ public:
// Other
//- Helper: calculate point regions
//- Helper: calculate point regions. The point region is the
// same on all faces connected to a point if they can be
// reached through a face-edge-face walk without crossing
// the nonManifoldEdge.
// pointGlobalRegions : non-compact. Guaranteed to be the same
// across processors.
// pointLocalRegions : compact.
// localToGlobalRegion : local to global region.
static void calcPointRegions
(
const globalMeshData& globalData,
const primitiveFacePatch& patch,
const PackedBoolList& nonManifoldEdge,
faceList& pointRegions,
labelList& regionPoints
faceList& pointGlobalRegions,
faceList& pointLocalRegions,
labelList& localToGlobalRegion
);
//- Play commands into polyTopoChange to create layer mesh.

View File

@ -1,205 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::patchPointEdgeCirculator
Description
Walks from starting edge/face around point on patch.
-# Use in-place: \n
\code
patchPointEdgeCirculator circ(..);
// Walk
do
{
Info<< "edge:" << circ.edgeID() << endl;
++circ;
}
while (circ != circ.end());
\endcode
-# Use like STL iterator: \n
\code
patchPointEdgeCirculator circ(..);
for
(
patchPointEdgeCirculator iter = circ.begin();
iter != circ.end();
++iter
)
{
Info<< "edge:" << iter.edgeID() << endl;
}
\endcode
SourceFiles
patchPointEdgeCirculator.C
\*---------------------------------------------------------------------------*/
#ifndef patchPointEdgeCirculator_H
#define patchPointEdgeCirculator_H
#include "face.H"
#include "ListOps.H"
#include "primitiveFacePatch.H"
#include "PackedBoolList.H"
#include "InfoProxy.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class patchPointEdgeCirculator Declaration
\*---------------------------------------------------------------------------*/
class patchPointEdgeCirculator
{
// Static data members
//- end iterator
static const patchPointEdgeCirculator endConstIter;
// Private data
//- Patch
const primitiveFacePatch& patch_;
const PackedBoolList& nonManifoldEdge_;
//- Current edge
label edgeID_;
//- Current direction (face, expressed as index into edgeFaces()[edgeID]
label index_;
//- Point
label pointID_;
//- Starting edge so we know when to stop.
label startEdgeID_;
// Private Member Functions
//- Set to end() iterator
inline void setEnd();
//- Set edgeID_ to be the other edge on the face that uses the
// point.
inline void otherEdge(const label cellI);
public:
// Constructors
//- Construct from components
inline patchPointEdgeCirculator
(
const primitiveFacePatch&,
const PackedBoolList& nonManifoldEdge,
const label edgeID,
const label index,
const label pointID
);
//- Construct as copy
inline patchPointEdgeCirculator(const patchPointEdgeCirculator&);
// Member Functions
inline label edgeID() const;
inline label index() const;
inline label pointID() const;
//- Helper: get face according to the index.
// Returns -1 if on end.
inline label faceID() const;
//- Walk back until non-manifold edge (if any) or minimum edge.
inline void setCanonical();
// Member Operators
inline void operator=(const patchPointEdgeCirculator& iter);
inline bool operator==(const patchPointEdgeCirculator& iter) const;
inline bool operator!=(const patchPointEdgeCirculator& iter) const;
//- Step to next face.
inline patchPointEdgeCirculator& operator++();
//- iterator set to the beginning face. For internal edges this is
// the current face. For boundary edges this is the first boundary face
// reached from walking back (i.e. in opposite direction to ++)
inline patchPointEdgeCirculator begin() const;
inline patchPointEdgeCirculator cbegin() const;
//- iterator set to beyond the end of the walk.
inline const patchPointEdgeCirculator& end() const;
inline const patchPointEdgeCirculator& cend() const;
// Info
//- Return info proxy.
// Used to print token information to a stream
InfoProxy<patchPointEdgeCirculator> info() const
{
return *this;
}
friend Ostream& operator<<
(
Ostream&,
const InfoProxy<patchPointEdgeCirculator>&
);
};
Ostream& operator<<(Ostream&, const InfoProxy<patchPointEdgeCirculator>&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "patchPointEdgeCirculatorI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,308 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::patchPointEdgeCirculator::setEnd()
{
edgeID_ = -1;
pointID_ = -1;
}
// Cross face to other edge on point
void Foam::patchPointEdgeCirculator::otherEdge(const label faceI)
{
const labelList& fEdges = patch_.faceEdges()[faceI];
const face& f = patch_.localFaces()[faceI];
label fp = findIndex(f, pointID_);
if (fEdges[fp] == edgeID_)
{
edgeID_ = fEdges[f.rcIndex(fp)];
}
else
{
// Check for now
if (fEdges[f.rcIndex(fp)] != edgeID_)
{
FatalErrorIn("patchPointEdgeCirculator::otherEdge(const label)")
<< "face:" << faceI
<< " verts:" << f
<< " edges:" << fEdges
<< " looking for other edge than " << edgeID_
<< abort(FatalError);
}
edgeID_ = fEdges[fp];
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from components
Foam::patchPointEdgeCirculator::patchPointEdgeCirculator
(
const primitiveFacePatch& patch,
const PackedBoolList& nonManifoldEdge,
const label edgeID,
const label index,
const label pointID
)
:
patch_(patch),
nonManifoldEdge_(nonManifoldEdge),
edgeID_(edgeID),
index_(index),
pointID_(pointID),
startEdgeID_(edgeID_)
{
if (edgeID_ != -1)
{
const edge& e = patch_.edges()[edgeID_];
if (pointID_ != e[0] && pointID_ != e[1])
{
FatalErrorIn
(
"patchPointEdgeCirculator::patchPointEdgeCirculator(..)"
) << "edge " << edgeID_ << " verts " << e
<< " does not contain point " << pointID_ << abort(FatalError);
}
}
}
//- Construct copy
Foam::patchPointEdgeCirculator::patchPointEdgeCirculator
(
const patchPointEdgeCirculator& circ
)
:
patch_(circ.patch_),
nonManifoldEdge_(circ.nonManifoldEdge_),
edgeID_(circ.edgeID_),
index_(circ.index_),
pointID_(circ.pointID_),
startEdgeID_(circ.startEdgeID_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::patchPointEdgeCirculator::edgeID() const
{
return edgeID_;
}
Foam::label Foam::patchPointEdgeCirculator::index() const
{
return index_;
}
Foam::label Foam::patchPointEdgeCirculator::pointID() const
{
return pointID_;
}
Foam::label Foam::patchPointEdgeCirculator::faceID() const
{
if (edgeID_ != -1 && index_ != -1)
{
return patch_.edgeFaces()[edgeID_][index_];
}
else
{
return -1;
}
}
void Foam::patchPointEdgeCirculator::operator=
(
const patchPointEdgeCirculator& circ
)
{
edgeID_ = circ.edgeID_;
index_ = circ.index_;
pointID_ = circ.pointID_;
startEdgeID_ = circ.startEdgeID_;
}
bool Foam::patchPointEdgeCirculator::operator==
(
const patchPointEdgeCirculator& circ
) const
{
// Do just enough to have setEnd() produce an iterator equal to end().
// Could include the direction(i.e. index_) to make sure that two
// circulators around same point but in different direction are not equal.
return edgeID_ == circ.edgeID_ && pointID_ == circ.pointID_;
}
bool Foam::patchPointEdgeCirculator::operator!=
(
const patchPointEdgeCirculator& circ
) const
{
return !(*this == circ);
}
void Foam::patchPointEdgeCirculator::setCanonical()
{
if (edgeID_ == -1)
{
FatalErrorIn("patchPointEdgeCirculator::setCanonical()")
<< "Already reached end(). Cannot walk any further."
<< abort(FatalError);
}
label minEdgeID = edgeID_;
label minIndex = index_;
while (true)
{
if (nonManifoldEdge_[edgeID_])
{
break;
}
// Step back
const labelList& eFaces = patch_.edgeFaces()[edgeID_];
if (eFaces.size() != 2)
{
FatalErrorIn("patchPointEdgeCirculator::setCanonical()")
<< "problem eFaces:" << eFaces << abort(FatalError);
}
label faceI = (index_ == 0 ? eFaces[1] : eFaces[0]);
// Step to other edge on face
otherEdge(faceI);
// Update index
index_ = findIndex(patch_.edgeFaces()[edgeID_], faceI);
if (edgeID_ < minEdgeID)
{
minEdgeID = edgeID_;
minIndex = index_;
}
if (edgeID_ == startEdgeID_)
{
edgeID_ = minEdgeID;
index_ = minIndex;
break;
}
}
startEdgeID_ = edgeID_;
}
//- Step to next edge.
Foam::patchPointEdgeCirculator&
Foam::patchPointEdgeCirculator::operator++()
{
if (index_ == -1)
{
setEnd();
}
else
{
// Step to other edge on face
label faceI = patch_.edgeFaces()[edgeID_][index_];
otherEdge(faceI);
if (edgeID_ == startEdgeID_)
{
setEnd();
}
else if (nonManifoldEdge_[edgeID_])
{
// Reached non-manifold edge. Cannot walk further.
// Mark so it gets set to end next time.
index_ = -1;
}
else
{
const labelList& eFaces = patch_.edgeFaces()[edgeID_];
if (eFaces.size() != 2)
{
FatalErrorIn("patchPointEdgeCirculator:::operator++()")
<< "problem eFaces:" << eFaces << abort(FatalError);
}
// Point to the face that is not faceI
index_ = (eFaces[0] != faceI ? 0 : 1);
}
}
return *this;
}
Foam::patchPointEdgeCirculator Foam::patchPointEdgeCirculator::begin() const
{
patchPointEdgeCirculator iter(*this);
iter.setCanonical();
return iter;
}
Foam::patchPointEdgeCirculator Foam::patchPointEdgeCirculator::cbegin() const
{
patchPointEdgeCirculator iter(*this);
iter.setCanonical();
return iter;
}
const Foam::patchPointEdgeCirculator& Foam::patchPointEdgeCirculator::end()
const
{
return endConstIter;
}
const Foam::patchPointEdgeCirculator& Foam::patchPointEdgeCirculator::cend()
const
{
return endConstIter;
}
// ************************************************************************* //

View File

@ -36,7 +36,7 @@ Foam::label Foam::checkTopology
label nTotCells = returnReduce(mesh.cells().size(), sumOp<label>());
// These are actually warnings, not errors.
if (nEmpty % nTotCells)
if (nTotCells && (nEmpty % nTotCells))
{
Info<< " ***Total number of faces on empty patches"
<< " is not divisible by the number of cells in the mesh."
@ -255,7 +255,7 @@ Foam::label Foam::checkTopology
{
regionSplit rs(mesh);
if (rs.nRegions() == 1)
if (rs.nRegions() <= 1)
{
Info<< " Number of regions: " << rs.nRegions() << " (OK)."
<< endl;

View File

@ -319,7 +319,7 @@ FoamFile
// source setToFaceZone;
// sourceInfo
// {
// set f0; // name of faceSet
// faceSet f0; // name of faceSet
// }
//
// // Select based on faceSet, using cellSet to determine orientation

View File

@ -83,6 +83,21 @@ Foam::sigStopAtWriteNow::sigStopAtWriteNow
{
if (signal_ > 0)
{
// Check that the signal is different from the writeNowSignal
if (sigWriteNow::signal_ == signal_)
{
FatalErrorIn
(
"Foam::sigStopAtWriteNow::sigStopAtWriteNow"
"(const bool, const Time&)"
) << "stopAtWriteNowSignal : " << signal_
<< " cannot be the same as the writeNowSignal."
<< " Please change this in the controlDict ("
<< findEtcFile("controlDict", false) << ")."
<< exit(FatalError);
}
// Store runTime
runTimePtr_ = &runTime;

View File

@ -67,6 +67,8 @@ class sigWriteNow
public:
friend class sigStopAtWriteNow;
// Constructors
//- Construct null

View File

@ -46,6 +46,20 @@ defineTypeNameAndDebug(Foam::globalMeshData, 0);
// Geometric matching tolerance. Factor of mesh bounding box.
const Foam::scalar Foam::globalMeshData::matchTol_ = 1E-8;
namespace Foam
{
template<>
class minEqOp<labelPair>
{
public:
void operator()(labelPair& x, const labelPair& y) const
{
x[0] = min(x[0], y[0]);
x[1] = min(x[1], y[1]);
}
};
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -1063,6 +1077,128 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
}
void Foam::globalMeshData::calcGlobalEdgeOrientation() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalEdgeOrientation() :"
<< " calculating edge orientation w.r.t. master edge." << endl;
}
const globalIndex& globalPoints = globalPointNumbering();
// 1. Determine master point
labelList masterPoint;
{
const mapDistribute& map = globalPointSlavesMap();
masterPoint.setSize(map.constructSize());
masterPoint = labelMax;
for (label pointI = 0; pointI < coupledPatch().nPoints(); pointI++)
{
masterPoint[pointI] = globalPoints.toGlobal(pointI);
}
syncData
(
masterPoint,
globalPointSlaves(),
globalPointTransformedSlaves(),
map,
minEqOp<label>()
);
}
// Now all points should know who is master by comparing their global
// pointID with the masterPointID. We now can use this information
// to find the orientation of the master edge.
{
const mapDistribute& map = globalEdgeSlavesMap();
const labelListList& slaves = globalEdgeSlaves();
const labelListList& transformedSlaves = globalEdgeTransformedSlaves();
// Distribute orientation of master edge (in masterPoint numbering)
labelPairList masterEdgeVerts(map.constructSize());
masterEdgeVerts = labelPair(labelMax, labelMax);
for (label edgeI = 0; edgeI < coupledPatch().nEdges(); edgeI++)
{
if
(
(
slaves[edgeI].size()
+ transformedSlaves[edgeI].size()
)
> 0
)
{
// I am master. Fill in my masterPoint equivalent.
const edge& e = coupledPatch().edges()[edgeI];
masterEdgeVerts[edgeI] = labelPair
(
masterPoint[e[0]],
masterPoint[e[1]]
);
}
}
syncData
(
masterEdgeVerts,
slaves,
transformedSlaves,
map,
minEqOp<labelPair>()
);
// Now check my edges on how they relate to the master's edgeVerts
globalEdgeOrientationPtr_.reset
(
new PackedBoolList(coupledPatch().nEdges())
);
PackedBoolList& globalEdgeOrientation = globalEdgeOrientationPtr_();
forAll(coupledPatch().edges(), edgeI)
{
const edge& e = coupledPatch().edges()[edgeI];
const labelPair masterE
(
masterPoint[e[0]],
masterPoint[e[1]]
);
label stat = labelPair::compare
(
masterE,
masterEdgeVerts[edgeI]
);
if (stat == 0)
{
FatalErrorIn
(
"globalMeshData::calcGlobalEdgeOrientation() const"
) << "problem : my edge:" << e
<< " in master points:" << masterE
<< " v.s. masterEdgeVerts:" << masterEdgeVerts[edgeI]
<< exit(FatalError);
}
else
{
globalEdgeOrientation[edgeI] = (stat == 1);
}
}
}
if (debug)
{
Pout<< "globalMeshData::calcGlobalEdgeOrientation() :"
<< " finished calculating edge orientation."
<< endl;
}
}
// Calculate uncoupled boundary faces (without calculating
// primitiveMesh::pointFaces())
void Foam::globalMeshData::calcPointBoundaryFaces
@ -1660,6 +1796,7 @@ void Foam::globalMeshData::clearOut()
globalEdgeNumberingPtr_.clear();
globalEdgeSlavesPtr_.clear();
globalEdgeTransformedSlavesPtr_.clear();
globalEdgeOrientationPtr_.clear();
globalEdgeSlavesMapPtr_.clear();
// Face
@ -2095,6 +2232,16 @@ const
}
const Foam::PackedBoolList& Foam::globalMeshData::globalEdgeOrientation() const
{
if (!globalEdgeOrientationPtr_.valid())
{
calcGlobalEdgeOrientation();
}
return globalEdgeOrientationPtr_();
}
const Foam::mapDistribute& Foam::globalMeshData::globalEdgeSlavesMap() const
{
if (!globalEdgeSlavesMapPtr_.valid())

View File

@ -95,6 +95,7 @@ class mapDistribute;
template<class T> class EdgeMap;
class globalIndex;
class globalIndexAndTransform;
class PackedBoolList;
/*---------------------------------------------------------------------------*\
Class globalMeshData Declaration
@ -191,6 +192,7 @@ class globalMeshData
mutable autoPtr<globalIndex> globalEdgeNumberingPtr_;
mutable autoPtr<labelListList> globalEdgeSlavesPtr_;
mutable autoPtr<labelListList> globalEdgeTransformedSlavesPtr_;
mutable autoPtr<PackedBoolList> globalEdgeOrientationPtr_;
mutable autoPtr<mapDistribute> globalEdgeSlavesMapPtr_;
@ -297,6 +299,9 @@ class globalMeshData
//- Calculate global edge addressing.
void calcGlobalEdgeSlaves() const;
//- Calculate orientation w.r.t. edge master.
void calcGlobalEdgeOrientation() const;
// Global boundary face/cell addressing
@ -539,6 +544,8 @@ public:
const labelListList& globalEdgeSlaves() const;
const labelListList& globalEdgeTransformedSlaves() const;
const mapDistribute& globalEdgeSlavesMap() const;
//- Is my edge same orientation master edge
const PackedBoolList& globalEdgeOrientation() const;
// Coupled point to boundary faces. These are uncoupled boundary
// faces only but include empty patches.

View File

@ -30,6 +30,7 @@ License
#include "PatchToolsSearch.C"
#include "PatchToolsSortEdges.C"
#include "PatchToolsNormals.C"
#include "PatchToolsMatch.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -36,6 +36,7 @@ SourceFiles
PatchToolsSearch.C
PatchToolsSortEdges.C
PatchToolsNormals.C
PatchToolsMatch.C
\*---------------------------------------------------------------------------*/
@ -51,6 +52,7 @@ namespace Foam
{
class polyMesh;
class PackedBoolList;
/*---------------------------------------------------------------------------*\
Class PatchTools Declaration
@ -169,6 +171,55 @@ public:
);
//- Find corresponding points on patches sharing the same points
// p1PointLabels : points on p1 that were matched
// p2PointLabels : corresponding points on p2
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
>
static void matchPoints
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
labelList& p1PointLabels,
labelList& p2PointLabels
);
//- Find corresponding edges on patches sharing the same points
// p1EdgeLabels : edges on p1 that were matched
// p2EdgeLabels : corresponding edges on p2
// sameOrientation : same orientation?
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
>
static void matchEdges
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
labelList& p1EdgeLabels,
labelList& p2EdgeLabels,
PackedBoolList& sameOrientation
);
//- Return parallel consistent point normals for patches (on boundary faces)
// using mesh points.
template

View File

@ -0,0 +1,137 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "PatchTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
>
void Foam::PatchTools::matchPoints
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
labelList& p1PointLabels,
labelList& p2PointLabels
)
{
p1PointLabels.setSize(p1.nPoints());
p2PointLabels.setSize(p1.nPoints());
label nMatches = 0;
forAll(p1.meshPoints(), pointI)
{
label meshPointI = p1.meshPoints()[pointI];
Map<label>::const_iterator iter = p2.meshPointMap().find
(
meshPointI
);
if (iter != p2.meshPointMap().end())
{
p1PointLabels[nMatches] = pointI;
p2PointLabels[nMatches] = iter();
nMatches++;
}
}
p1PointLabels.setSize(nMatches);
p2PointLabels.setSize(nMatches);
}
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
>
void Foam::PatchTools::matchEdges
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
labelList& p1EdgeLabels,
labelList& p2EdgeLabels,
PackedBoolList& sameOrientation
)
{
p1EdgeLabels.setSize(p1.nEdges());
p2EdgeLabels.setSize(p1.nEdges());
sameOrientation.setSize(p1.nEdges());
sameOrientation = 0;
label nMatches = 0;
EdgeMap<label> edgeToIndex(2*p1.nEdges());
forAll(p1.edges(), edgeI)
{
const edge& e = p1.edges()[edgeI];
const edge meshE
(
p1.meshPoints()[e[0]],
p1.meshPoints()[e[1]]
);
edgeToIndex.insert(meshE, edgeI);
}
forAll(p2.edges(), edgeI)
{
const edge& e = p2.edges()[edgeI];
const edge meshE(p2.meshPoints()[e[0]], p2.meshPoints()[e[1]]);
EdgeMap<label>::const_iterator iter = edgeToIndex.find(meshE);
if (iter != edgeToIndex.end())
{
p1EdgeLabels[nMatches] = iter();
p2EdgeLabels[nMatches] = edgeI;
sameOrientation[nMatches] = (meshE[0] == iter.key()[0]);
nMatches++;
}
}
p1EdgeLabels.setSize(nMatches);
p2EdgeLabels.setSize(nMatches);
sameOrientation.setSize(nMatches);
}
// ************************************************************************* //

View File

@ -390,6 +390,12 @@ $(basicSource)/actuationDiskSource/actuationDiskSource.C
$(basicSource)/radialActuationDiskSource/radialActuationDiskSource.C
$(basicSource)/explicitSource/explicitSource.C
$(basicSource)/explicitSetValue/explicitSetValue.C
$(basicSource)/rotorDiskSource/rotorDiskSource.C
$(basicSource)/rotorDiskSource/bladeModel/bladeModel.C
$(basicSource)/rotorDiskSource/profileModel/profileModel.C
$(basicSource)/rotorDiskSource/profileModel/profileModelList.C
$(basicSource)/rotorDiskSource/profileModel/lookup/lookupProfile.C
$(basicSource)/rotorDiskSource/profileModel/series/seriesProfile.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume

View File

@ -75,11 +75,11 @@ Foam::actuationDiskSource::actuationDiskSource
)
:
basicSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs")),
diskDir_(dict_.lookup("diskDir")),
Cp_(readScalar(dict_.lookup("Cp"))),
Ct_(readScalar(dict_.lookup("Ct"))),
diskArea_(readScalar(dict_.lookup("diskArea")))
coeffs_(dict.subDict(modelType + "Coeffs")),
diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))),
diskArea_(readScalar(coeffs_.lookup("diskArea")))
{
Info<< " - creating actuation disk zone: "
<< this->name() << endl;
@ -132,20 +132,8 @@ void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
void Foam::actuationDiskSource::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
if (dict_.found("note"))
{
os.writeKeyword("note") << string(dict_.lookup("note"))
<< token::END_STATEMENT << nl;
}
os << indent << "actuationDisk";
os << indent << name_ << endl;
dict_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
@ -153,13 +141,11 @@ bool Foam::actuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs =
sourceDict.subDict(typeName + "Coeffs");
subDictCoeffs.readIfPresent("diskDir", diskDir_);
subDictCoeffs.readIfPresent("Cp", Cp_);
subDictCoeffs.readIfPresent("Ct", Ct_);
subDictCoeffs.readIfPresent("diskArea", diskArea_);
coeffs_ = dict.subDict(typeName + "Coeffs");
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);
coeffs_.readIfPresent("Ct", Ct_);
coeffs_.readIfPresent("diskArea", diskArea_);
checkData();

View File

@ -74,8 +74,8 @@ protected:
// Protected data
//- Sub dictionary with actuationDisk information
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffs_;
//- Disk area normal
vector diskDir_;

View File

@ -277,28 +277,20 @@ bool Foam::basicSource::isActive()
void Foam::basicSource::addSu(Foam::fvMatrix<vector>& Eqn)
{
notImplemented
(
"Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)"
);
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<vector>& Eqn)");
}
void Foam::basicSource::addSu(Foam::fvMatrix<scalar>& Eqn)
{
notImplemented
(
"Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)"
);
notImplemented("Foam::basicSource addSu(Foam::fvMatrix<scalar>& Eqn)");
}
void Foam::basicSource::setValue(Foam::fvMatrix<scalar>& Eqn)
{
notImplemented
(
"Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)"
);
notImplemented("Foam::basicSource setValue(Foam::fvMatrix<scalar>& Eqn)");
}
// ************************************************************************* //

View File

@ -202,10 +202,7 @@ public:
//- Return clone
autoPtr<basicSource> clone() const
{
notImplemented
(
"autoPtr<basicSource> clone() const"
);
notImplemented("autoPtr<basicSource> clone() const");
return autoPtr<basicSource>(NULL);
}
@ -273,7 +270,7 @@ public:
//- Return const access to the mesh database
inline const fvMesh& mesh() const;
//- Return dictionay
//- Return dictionary
inline const dictionary& dictCoeffs() const;
//- Return const access to the source active flag
@ -340,7 +337,6 @@ public:
//- Read source dictionary
virtual bool read(const dictionary& dict) = 0;
};

View File

@ -77,10 +77,9 @@ void Foam::basicSource::writeData(Ostream& os) const
bool Foam::basicSource::read(const dictionary& dict)
{
const dictionary& sourceDict = dict.subDict(name_);
active_ = readBool(sourceDict.lookup("active"));
timeStart_ = readScalar(sourceDict.lookup("timeStart"));
duration_ = readScalar(sourceDict.lookup("duration"));
active_ = readBool(dict.lookup("active"));
timeStart_ = readScalar(dict.lookup("timeStart"));
duration_ = readScalar(dict.lookup("duration"));
return true;
}

View File

@ -51,12 +51,12 @@ Foam::basicSourceList::basicSourceList
forAllConstIter(dictionary, dict, iter)
{
const word& name = iter().keyword();
const dictionary& dict = iter().dict();
const dictionary& sourceDict = iter().dict();
this->set
(
i++,
basicSource::New(name, dict, mesh)
basicSource::New(name, sourceDict, mesh)
);
}
}
@ -108,7 +108,8 @@ bool Foam::basicSourceList::read(const dictionary& dict)
bool allOk = true;
forAll(*this, i)
{
bool ok = this->operator[](i).read(dict);
basicSource& bs = this->operator[](i);
bool ok = bs.read(dict.subDict(bs.name()));
allOk = (allOk && ok);
}
return allOk;
@ -117,12 +118,6 @@ bool Foam::basicSourceList::read(const dictionary& dict)
bool Foam::basicSourceList::writeData(Ostream& os) const
{
// Write size of list
os << nl << this->size();
// Write beginning of contents
os << nl << token::BEGIN_LIST;
// Write list contents
forAll(*this, i)
{
@ -130,9 +125,6 @@ bool Foam::basicSourceList::writeData(Ostream& os) const
this->operator[](i).writeData(os);
}
// Write end of contents
os << token::END_LIST << token::END_STATEMENT << nl;
// Check state of IOstream
return os.good();
}

View File

@ -72,11 +72,9 @@ void Foam::explicitSetValue::setFieldData(const dictionary& dict)
}
else
{
FatalErrorIn
(
"explicitSetValue::setFieldData"
) << "header not OK " << io.name()
<< exit(FatalError);
FatalErrorIn("explicitSetValue::setFieldData")
<< "header not OK for field " << io.name()
<< abort(FatalError);
}
}
@ -96,9 +94,9 @@ Foam::explicitSetValue::explicitSetValue
)
:
basicSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs"))
coeffs_(dict.subDict(modelType + "Coeffs"))
{
setFieldData(dict_.subDict("fieldData"));
setFieldData(coeffs_.subDict("fieldData"));
}

View File

@ -89,8 +89,8 @@ protected:
// Protected data
//- Sub dictionary for time activated explicit sources
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffs_;
// Protected functions
@ -119,10 +119,7 @@ public:
//- Return clone
autoPtr<explicitSetValue> clone() const
{
notImplemented
(
"autoPtr<explicitSetValue> clone() const"
);
notImplemented("autoPtr<explicitSetValue> clone() const");
return autoPtr<explicitSetValue>(NULL);
}

View File

@ -29,22 +29,8 @@ License
void Foam::explicitSetValue::writeData(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
if (scalarFields_.size() > 0)
{
os.writeKeyword("scalarFields") << scalarFields_
<< token::END_STATEMENT << nl;
}
if (vectorFields_.size() > 0)
{
os.writeKeyword("vectorFields") << vectorFields_
<< token::END_STATEMENT << nl;
}
os << decrIndent << indent << token::END_BLOCK << endl;
os << indent << name_ << endl;
dict_.write(os);
}
@ -52,12 +38,8 @@ bool Foam::explicitSetValue::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs = sourceDict.subDict
(
typeName + "Coeffs"
);
setFieldData(subDictCoeffs.subDict("fieldData"));
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
return true;
}
else

View File

@ -112,8 +112,8 @@ Foam::explicitSource::explicitSource
)
:
basicSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs")),
volumeMode_(volumeModeTypeNames_.read(dict_.lookup("volumeMode")))
coeffs_(dict.subDict(modelType + "Coeffs")),
volumeMode_(volumeModeTypeNames_.read(coeffs_.lookup("volumeMode")))
{
setFieldData(dict_.subDict("fieldData"));
}

View File

@ -110,8 +110,8 @@ protected:
// Protected data
//- Sub dictionary for time activated explicit sources
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffs_;
//- Volume mode
volumeModeType volumeMode_;

View File

@ -29,25 +29,8 @@ License
void Foam::explicitSource::writeData(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("volumeMode") << volumeModeTypeNames_[volumeMode_]
<< token::END_STATEMENT << nl;
if (scalarFields_.size() > 0)
{
os.writeKeyword("scalarFields") << scalarFields_
<< token::END_STATEMENT << nl;
}
if (vectorFields_.size() > 0)
{
os.writeKeyword("vectorFields") << vectorFields_
<< token::END_STATEMENT << nl;
}
os << decrIndent << indent << token::END_BLOCK << endl;
os << indent << name_ << endl;
dict_.write(os);
}
@ -55,12 +38,8 @@ bool Foam::explicitSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs = sourceDict.subDict
(
typeName + "Coeffs"
);
setFieldData(subDictCoeffs.subDict("fieldData"));
coeffs_ = dict.subDict(typeName + "Coeffs");
setFieldData(coeffs_.subDict("fieldData"));
return true;
}
else

View File

@ -53,10 +53,10 @@ Foam::radialActuationDiskSource::radialActuationDiskSource
)
:
actuationDiskSource(name, modelType, dict, mesh),
dict_(dict.subDict(modelType + "Coeffs")),
coeffsDict_(dict.subDict(modelType + "Coeffs")),
coeffs_()
{
dict_.lookup("coeffs") >> coeffs_;
coeffsDict_.lookup("coeffs") >> coeffs_;
Info<< " - creating radial actuation disk zone: "
<< this->name() << endl;
}
@ -114,14 +114,12 @@ bool Foam::radialActuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs =
sourceDict.subDict(typeName + "Coeffs");
subDictCoeffs.readIfPresent("diskDir", diskDir_);
subDictCoeffs.readIfPresent("Cp", Cp_);
subDictCoeffs.readIfPresent("Ct", Ct_);
subDictCoeffs.readIfPresent("diskArea", diskArea_);
subDictCoeffs.lookup("coeffs") >> coeffs_;
const dictionary& coeffsDict_ = dict.subDict(typeName + "Coeffs");
coeffsDict_.readIfPresent("diskDir", diskDir_);
coeffsDict_.readIfPresent("Cp", Cp_);
coeffsDict_.readIfPresent("Ct", Ct_);
coeffsDict_.readIfPresent("diskArea", diskArea_);
coeffsDict_.lookup("coeffs") >> coeffs_;
return true;
}
else

View File

@ -62,7 +62,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class radialActuationDiskSource Declaration
Class radialActuationDiskSource Declaration
\*---------------------------------------------------------------------------*/
class radialActuationDiskSource
@ -71,8 +71,8 @@ class radialActuationDiskSource
{
// Private data
//- Sub dictionary with model information
const dictionary& dict_;
//- Coefficients dictionary
dictionary coeffsDict_;
//- Coeffcients for the radial distribution
FixedList<scalar, 3> coeffs_;
@ -123,7 +123,7 @@ public:
// Public Functions
//-Source term to fvMatrix<vector>
//- Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "bladeModel.H"
#include "unitConversion.H"
#include "Tuple2.H"
#include "vector.H"
#include "IFstream.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
bool Foam::bladeModel::readFromFile() const
{
return fName_ != fileName::null;
}
void Foam::bladeModel::interpolateWeights
(
const scalar& xIn,
const List<scalar>& values,
label& i1,
label& i2,
scalar& ddx
) const
{
scalar x = -GREAT;
label nElem = values.size();
i2 = 0;
while ((x < xIn) && (i2 < nElem))
{
x = values[i2];
i2++;
}
if (i2 == 0)
{
i1 = i2;
ddx = 0.0;
return;
}
else if (i2 == values.size())
{
i2 = values.size() - 1;
i1 = i2;
ddx = 0.0;
return;
}
else
{
i1 = i2 - 1;
ddx = (xIn - values[i1])/(values[i2] - values[i1]);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::bladeModel::bladeModel(const dictionary& dict)
:
profileName_(),
profileID_(),
radius_(),
twist_(),
chord_(),
fName_(fileName::null)
{
List<Tuple2<word, vector> > data;
if (readFromFile())
{
IFstream is(fName_);
is >> data;
}
else
{
dict.lookup("data") >> data;
}
if (data.size() > 0)
{
profileName_.setSize(data.size());
profileID_.setSize(data.size());
radius_.setSize(data.size());
twist_.setSize(data.size());
chord_.setSize(data.size());
forAll(data, i)
{
profileName_[i] = data[i].first();
profileID_[i] = -1;
radius_[i] = data[i].second()[0];
twist_[i] = degToRad(data[i].second()[1]);
chord_[i] = data[i].second()[2];
}
}
else
{
FatalErrorIn
(
"Foam::bladeModel::bladeModel"
"("
"const dictionary&, "
"const word&"
")"
) << "No blade data specified" << exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::bladeModel::~bladeModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::List<Foam::word>& Foam::bladeModel::profileName() const
{
return profileName_;
}
const Foam::List<Foam::label>& Foam::bladeModel::profileID() const
{
return profileID_;
}
const Foam::List<Foam::scalar>& Foam::bladeModel::radius() const
{
return radius_;
}
const Foam::List<Foam::scalar>& Foam::bladeModel::twist() const
{
return twist_;
}
const Foam::List<Foam::scalar>& Foam::bladeModel::chord() const
{
return chord_;
}
Foam::List<Foam::label>& Foam::bladeModel::profileID()
{
return profileID_;
}
void Foam::bladeModel::interpolate
(
const scalar radius,
scalar& twist,
scalar& chord,
label& i1,
label& i2,
scalar& invDr
) const
{
interpolateWeights(radius, radius_, i1, i2, invDr);
twist = invDr*(twist_[i2] - twist_[i1]) + twist_[i1];
chord = invDr*(chord_[i2] - chord_[i1]) + chord_[i1];
}
// ************************************************************************* //

View File

@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::bladeModel
Description
Blade model class
SourceFiles
bladeModel.C
\*---------------------------------------------------------------------------*/
#ifndef bladeModel_H
#define bladeModel_H
#include "List.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class bladeModel Declaration
\*---------------------------------------------------------------------------*/
class bladeModel
{
protected:
// Protected data
//- Corresponding profile name per section
List<word> profileName_;
//- Corresponding profile ID per section
List<label> profileID_;
//- Radius [m]
List<scalar> radius_;
//- Twist [deg] on input, converted to [rad]
List<scalar> twist_;
//- Chord [m]
List<scalar> chord_;
//- File name (optional)
fileName fName_;
// Protected Member Functions
//- Return ture if file name is set
bool readFromFile() const;
//- Return the interpolation indices and gradient
void interpolateWeights
(
const scalar& xIn,
const List<scalar>& values,
label& i1,
label& i2,
scalar& ddx
) const;
public:
//- Constructor
bladeModel(const dictionary& dict);
//- Destructor
virtual ~bladeModel();
// Member functions
// Access
//- Return const access to the profile name list
const List<word>& profileName() const;
//- Return const access to the profile ID list
const List<label>& profileID() const;
//- Return const access to the radius list
const List<scalar>& radius() const;
//- Return const access to the twist list
const List<scalar>& twist() const;
//- Return const access to the chord list
const List<scalar>& chord() const;
// Edit
//- Return non-const access to the profile ID list
List<label>& profileID();
// Evaluation
//- Return the twist and chord for a given radius
virtual void interpolate
(
const scalar radius,
scalar& twist,
scalar& chord,
label& i1,
label& i2,
scalar& invDr
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "lookupProfile.H"
#include "addToRunTimeSelectionTable.H"
#include "vector.H"
#include "unitConversion.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(lookupProfile, 0);
addToRunTimeSelectionTable(profileModel, lookupProfile, dictionary);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::lookupProfile::interpolateWeights
(
const scalar& xIn,
const List<scalar>& values,
label& i1,
label& i2,
scalar& ddx
) const
{
scalar x = -GREAT;
label nElem = values.size();
i2 = 0;
while ((x < xIn) && (i2 < nElem))
{
x = values[i2];
i2++;
}
if (i2 == 0)
{
i1 = i2;
ddx = 0.0;
return;
}
else if (i2 == values.size())
{
i2 = values.size() - 1;
i1 = i2;
ddx = 0.0;
return;
}
else
{
i1 = i2 - 1;
ddx = (xIn - values[i1])/(values[i2] - values[i1]);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::lookupProfile::lookupProfile
(
const dictionary& dict,
const word& modelName
)
:
profileModel(dict, modelName),
AOA_(),
Cd_(),
Cl_()
{
List<vector> data;
if (readFromFile())
{
IFstream is(fName_);
is >> data;
}
else
{
dict.lookup("data") >> data;
}
if (data.size() > 0)
{
AOA_.setSize(data.size());
Cd_.setSize(data.size());
Cl_.setSize(data.size());
forAll(data, i)
{
AOA_[i] = degToRad(data[i][0]);
Cd_[i] = data[i][1];
Cl_[i] = data[i][2];
}
}
else
{
FatalErrorIn
(
"Foam::lookupProfile::lookupProfile"
"("
"const dictionary&, "
"const word&"
")"
) << "No profile data specified" << exit(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::lookupProfile::Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const
{
label i1 = -1;
label i2 = -1;
scalar invAlpha = -1.0;
interpolateWeights(alpha, AOA_, i1, i2, invAlpha);
Cd = invAlpha*(Cd_[i2] - Cd_[i1]) + Cd_[i1];
Cl = invAlpha*(Cl_[i2] - Cl_[i1]) + Cl_[i1];
}
// ************************************************************************* //

View File

@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::lookupProfile
Description
Look-up based profile data - drag and lift coefficients are lineraly
interpolated based on the supplied angle of attack
Input in list format:
data
(
(AOA1 Cd1 Cl2)
(AOA2 Cd2 Cl2)
...
(AOAN CdN CdN)
);
where:
AOA = angle of attack [deg] converted to [rad] internally
Cd = drag coefficient
Cl = lift coefficient
SourceFiles
lookupProfile.C
\*---------------------------------------------------------------------------*/
#ifndef lookupProfile_H
#define lookupProfile_H
#include "profileModel.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class lookupProfile Declaration
\*---------------------------------------------------------------------------*/
class lookupProfile
:
public profileModel
{
protected:
// Protected data
//- List of angle-of-attack values [deg] on input, converted to [rad]
List<scalar> AOA_;
//- List of drag coefficient values
List<scalar> Cd_;
//- List of lift coefficient values
List<scalar> Cl_;
// Protected Member Functions
//- Return the interpolation indices and gradient
void interpolateWeights
(
const scalar& xIn,
const List<scalar>& values,
label& i1,
label& i2,
scalar& ddx
) const;
public:
//- Runtime type information
TypeName("lookup");
//- Constructor
lookupProfile(const dictionary& dict, const word& modelName);
// Member functions
// Evaluation
//- Return the Cd and Cl for a given angle-of-attack
virtual void Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "profileModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(profileModel, 0);
defineRunTimeSelectionTable(profileModel, dictionary);
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
bool Foam::profileModel::readFromFile() const
{
return fName_ != fileName::null;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::profileModel::profileModel(const dictionary& dict, const word& name)
:
dict_(dict),
name_(name),
fName_(fileName::null)
{
dict.readIfPresent("fileName", fName_);
}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::profileModel::~profileModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::profileModel::name() const
{
return name_;
}
Foam::autoPtr<Foam::profileModel> Foam::profileModel::New
(
const dictionary& dict
)
{
const word& modelName(dict.dictName());
const word modelType(dict.lookup("type"));
Info<< " - creating " << modelType << " profile " << modelName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn("profileModel::New(const dictionary&)")
<< "Unknown profile model type " << modelType
<< nl << nl
<< "Valid model types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<profileModel>(cstrIter()(dict, modelName));
}
// ************************************************************************* //

View File

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::profileModel
Description
Base class for profile models
SourceFiles
profileModel.C
\*---------------------------------------------------------------------------*/
#ifndef profileModel_H
#define profileModel_H
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class profileModel Declaration
\*---------------------------------------------------------------------------*/
class profileModel
{
protected:
// Protected data
//- Coefficients dictionary
const dictionary dict_;
//- Name of profile model
const word name_;
//- File name (optional)
fileName fName_;
// Protected Member Functions
//- Return ture if file name is set
bool readFromFile() const;
public:
//- Runtime type information
TypeName("profileModel");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
profileModel,
dictionary,
(
const dictionary& dict,
const word& modelName
),
(dict, modelName)
);
// Selectors
//- Return a reference to the selected basicSource model
static autoPtr<profileModel> New(const dictionary& dict);
//- Constructor
profileModel(const dictionary& dict, const word& modelName);
//- Destructor
virtual ~profileModel();
// Member functions
// Access
//- Return const access to the source name
const word& name() const;
// Evaluation
//- Return the Cd and Cl for a given angle-of-attack
virtual void Cdl
(
const scalar alpha,
scalar& Cd,
scalar& Cl
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,121 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "profileModelList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::profileModelList::profileModelList
(
const dictionary& dict,
const bool readFields
)
:
PtrList<profileModel>(),
dict_(dict)
{
if (readFields)
{
wordList modelNames(dict.toc());
Info<< " Constructing blade profiles:" << endl;
if (modelNames.size() > 0)
{
this->setSize(modelNames.size());
forAll(modelNames, i)
{
const word& modelName = modelNames[i];
this->set
(
i,
profileModel::New(dict.subDict(modelName))
);
}
}
else
{
Info<< " none" << endl;
}
}
}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::profileModelList::~profileModelList()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::profileModelList::connectBlades
(
const List<word>& names,
List<label>& addr
) const
{
// construct the addressing between blade sections and profiles
forAll(names, bI)
{
label index = -1;
const word& profileName = names[bI];
forAll(*this, pI)
{
const profileModel& pm = this->operator[](pI);
if (pm.name() == profileName)
{
index = pI;
break;
}
}
if (index == -1)
{
List<word> profileNames(size());
forAll(*this, i)
{
const profileModel& pm = this->operator[](i);
profileNames[i] = pm.name();
}
FatalErrorIn("void Foam::connectBlades(List<word>& names) const")
<< "Profile " << profileName << " could not be found "
<< "in profile list. Available profiles are"
<< profileNames << exit(FatalError);
}
else
{
addr[bI] = index;
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::profileModelList
Description
Base class for profile models
SourceFiles
profileModel.C
\*---------------------------------------------------------------------------*/
#ifndef profileModelList_H
#define profileModelList_H
#include "PtrList.H"
#include "profileModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class profileModelList Declaration
\*---------------------------------------------------------------------------*/
class profileModelList
:
public PtrList<profileModel>
{
protected:
// Protected data
//- Dictionary
const dictionary dict_;
public:
//- Constructor
profileModelList(const dictionary& dict, const bool readFields = true);
//- Destructor
~profileModelList();
// Member Functions
//- Set blade->profile addressing
void connectBlades
(
const List<word>& names,
List<label>& addr
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,116 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "seriesProfile.H"
#include "addToRunTimeSelectionTable.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(seriesProfile, 0);
addToRunTimeSelectionTable(profileModel, seriesProfile, dictionary);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::scalar Foam::seriesProfile::evaluate
(
const scalar& xIn,
const List<scalar>& values
) const
{
scalar result = 0.0;
forAll(values, i)
{
result += values[i]*cos((i+1)*xIn);
}
return result;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::seriesProfile::seriesProfile
(
const dictionary& dict,
const word& modelName
)
:
profileModel(dict, modelName),
CdCoeffs_(),
ClCoeffs_()
{
if (readFromFile())
{
IFstream is(fName_);
is >> CdCoeffs_ >> ClCoeffs_;
}
else
{
dict.lookup("CdCoeffs") >> CdCoeffs_;
dict.lookup("ClCoeffs") >> ClCoeffs_;
}
if (CdCoeffs_.empty())
{
FatalErrorIn
(
"Foam::seriesProfile::seriesProfile"
"("
"const dictionary&, "
"const word&"
")"
) << "CdCoeffs must be specified" << exit(FatalError);
}
if (ClCoeffs_.empty())
{
FatalErrorIn
(
"Foam::seriesProfile::seriesProfile"
"("
"const dictionary&, "
"const word&"
")"
) << "ClCoeffs must be specified" << exit(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::seriesProfile::Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const
{
Cd = evaluate(alpha, CdCoeffs_);
Cl = evaluate(alpha, ClCoeffs_);
}
// ************************************************************************* //

View File

@ -0,0 +1,116 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::seriesProfile
Description
Series-up based profile data - drag and lift coefficients computed as
sum of cosine series
Cd = sum_i(CdCoeff)*cos(i*AOA)
Cl = sum_i(ClCoeff)*cos(i*AOA)
where:
AOA = angle of attack [deg] converted to [rad] internally
Cd = drag coefficent
Cl = lift coefficent
Input in two (arbitrary length) lists:
CdCoeffs (coeff1 coeff2 ... coeffN);
ClCoeffs (coeff1 coeff2 ... coeffN);
SourceFiles
seriesProfile.C
\*---------------------------------------------------------------------------*/
#ifndef seriesProfile_H
#define seriesProfile_H
#include "profileModel.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class seriesProfile Declaration
\*---------------------------------------------------------------------------*/
class seriesProfile
:
public profileModel
{
protected:
// Protected data
//- List of drag coefficient values
List<scalar> CdCoeffs_;
//- List of lift coefficient values
List<scalar> ClCoeffs_;
// Protected Member Functions
//- Evaluate
scalar evaluate
(
const scalar& xIn,
const List<scalar>& values
) const;
public:
//- Runtime type information
TypeName("series");
//- Constructor
seriesProfile(const dictionary& dict, const word& modelName);
// Member functions
// Evaluation
//- Return the Cd and Cl for a given angle-of-attack
virtual void Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,495 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "rotorDiskSource.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"
#include "geometricOneField.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(rotorDiskSource, 0);
addToRunTimeSelectionTable(basicSource, rotorDiskSource, dictionary);
template<> const char* NamedEnum<rotorDiskSource::geometryModeType, 2>::
names[] =
{
"auto",
"specified"
};
const NamedEnum<rotorDiskSource::geometryModeType, 2>
rotorDiskSource::geometryModeTypeNames_;
template<> const char* NamedEnum<rotorDiskSource::inletFlowType, 3>::
names[] =
{
"fixed",
"surfaceNormal",
"local"
};
const NamedEnum<rotorDiskSource::inletFlowType, 3>
rotorDiskSource::inletFlowTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::rotorDiskSource::checkData()
{
switch (selectionMode())
{
case smCellSet:
case smCellZone:
case smAll:
{
// set the profile ID for each blade section
profiles_.connectBlades(blade_.profileName(), blade_.profileID());
switch (inletFlow_)
{
case ifFixed:
{
coeffs_.lookup("inletVelocity") >> inletVelocity_;
break;
}
case ifSurfaceNormal:
{
scalar UIn
(
readScalar(coeffs_.lookup("inletNormalVelocity"))
);
inletVelocity_ = -coordSys_.e3()*UIn;
break;
}
case ifLocal:
{
// do nothing
break;
}
default:
{
FatalErrorIn("void rotorDiskSource::checkData()")
<< "Unknown inlet velocity type" << abort(FatalError);
}
}
break;
}
default:
{
FatalErrorIn("void rotorDiskSource::checkData()")
<< "Source cannot be used with '"
<< selectionModeTypeNames_[selectionMode()]
<< "' mode. Please use one of: " << nl
<< selectionModeTypeNames_[smCellSet] << nl
<< selectionModeTypeNames_[smCellZone] << nl
<< selectionModeTypeNames_[smAll]
<< exit(FatalError);
}
}
}
void Foam::rotorDiskSource::setFaceArea(vector& axis, const bool correct)
{
// calculate rotor face areas
const vectorField& Sf = mesh_.Sf();
const scalarField& magSf = mesh_.magSf();
boolList selectedCells(mesh_.nCells(), false);
boolList processedFaces(mesh_.nFaces(), false);
UIndirectList<bool>(selectedCells, cells_) = boolList(cells_.size(), true);
vector n = vector::zero;
label nFace = 0;
area_ = 0.0;
forAll(cells_, i)
{
const label cellI = cells_[i];
const cell& cFaces = mesh_.cells()[cellI];
forAll(cFaces, j)
{
const label faceI = cFaces[j];
label own = mesh_.owner()[faceI];
label nbr = mesh_.neighbour()[faceI];
if
(
!processedFaces[faceI]
&& (selectedCells[own] != selectedCells[nbr])
)
{
if (selectedCells[own])
{
if (((Sf[faceI]/magSf[faceI]) & axis) > 0.8)
{
area_[i] += magSf[faceI];
n += Sf[faceI];
nFace++;
}
}
else if (selectedCells[nbr])
{
if (((-Sf[faceI]/magSf[faceI]) & axis) > 0.8)
{
area_[i] += magSf[faceI];
n -= Sf[faceI];
nFace++;
}
}
processedFaces[faceI] = true;
}
}
}
if (correct && (nFace > 0))
{
axis = n/mag(n);
}
}
void Foam::rotorDiskSource::createCoordinateSystem()
{
// construct the local rotor co-prdinate system
vector origin(vector::zero);
vector axis(vector::zero);
vector refDir(vector::zero);
geometryModeType gm =
geometryModeTypeNames_.read(coeffs_.lookup("geometryMode"));
switch (gm)
{
case gmAuto:
{
// determine rotation origin
scalar sumV = 0.0;
const scalarField& V = mesh_.V();
const vectorField& C = mesh_.C();
forAll(cells_, i)
{
const label cellI = cells_[i];
sumV += V[cellI];
origin += V[cellI]*C[cellI];
}
origin /= sumV;
// determine first radial vector
vector dx1(vector::zero);
scalar magR = -GREAT;
forAll(cells_, i)
{
const label cellI = cells_[i];
vector test = C[cellI] - origin;
if (mag(test) > magR)
{
dx1 = test;
magR = mag(test);
}
}
// determine second radial vector and cross to determine axis
forAll(cells_, i)
{
const label cellI = cells_[i];
vector dx2 = C[cellI] - origin;
if (mag(dx2) > 0.5*magR)
{
axis = dx1 ^ dx2;
if (mag(axis) > SMALL)
{
break;
}
}
}
axis /= mag(axis);
// axis direction is somewhat arbitrary - check if user needs
// needs to reverse
bool reverse(readBool(coeffs_.lookup("reverseAxis")));
if (reverse)
{
axis *= -1.0;
}
coeffs_.lookup("refDirection") >> refDir;
// set the face areas and apply correction to calculated axis
// e.g. if cellZone is more than a single layer in thickness
setFaceArea(axis, true);
break;
}
case gmSpecified:
{
coeffs_.lookup("origin") >> origin;
coeffs_.lookup("axis") >> axis;
coeffs_.lookup("refDirection") >> refDir;
setFaceArea(axis, false);
break;
}
default:
{
FatalErrorIn
(
"rotorDiskSource::createCoordinateSystem(const geometryMode&);"
) << "Unknown geometryMode " << geometryModeTypeNames_[gm]
<< ". Available geometry modes include "
<< geometryModeTypeNames_ << exit(FatalError);
}
}
coordSys_ = cylindricalCS("rotorCoordSys", origin, axis, refDir, false);
const scalar sumArea = gSum(area_);
const scalar diameter = Foam::sqrt(4.0*sumArea/mathematical::pi);
Info<< " Rotor gometry:" << nl
<< " - disk diameter = " << diameter << nl
<< " - disk area = " << sumArea << nl
<< " - origin = " << coordSys_.origin() << nl
<< " - r-axis = " << coordSys_.e1() << nl
<< " - psi-axis = " << coordSys_.e2() << nl
<< " - z-axis = " << coordSys_.e3() << endl;
}
void Foam::rotorDiskSource::constructGeometry()
{
const vectorField& C = mesh_.C();
const vector rDir = coordSys_.e1();
const vector zDir = coordSys_.e3();
forAll(cells_, i)
{
const label cellI = cells_[i];
// position in rotor co-ordinate system
x_[i] = coordSys_.localPosition(C[cellI]);
// cache max radius
rMax_ = max(rMax_, x_[i].x());
// determine swept angle relative to rDir axis
scalar psi = x_[i].y() - rDir.y();
// blade flap angle
scalar beta = flap_.beta0 - flap_.beta1*cos(psi) - flap_.beta2*sin(psi);
// determine rotation tensor to convert into the rotor cone plane
scalar c = cos(-beta);
scalar s = sin(-beta);
R_[i] = tensor(1, 0, 0, 0, c, s, 0, -s, c);
// geometric angle of attack - not including twist
alphag_[i] = trim_.alphaC - trim_.A*cos(psi) - trim_.B*sin(psi);
}
}
Foam::tmp<Foam::vectorField> Foam::rotorDiskSource::inflowVelocity
(
const volVectorField& U
) const
{
switch (inletFlow_)
{
case ifFixed:
case ifSurfaceNormal:
{
return tmp<vectorField>
(
new vectorField(mesh_.nCells(), inletVelocity_)
);
break;
}
case ifLocal:
{
return U.internalField();
break;
}
default:
{
FatalErrorIn
(
"Foam::tmp<Foam::vectorField> "
"Foam::rotorDiskSource::inflowVelocity"
"(const volVectorField&) const"
) << "Unknown inlet flow specification" << abort(FatalError);
}
}
return tmp<vectorField>(new vectorField(mesh_.nCells(), vector::zero));
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
Foam::rotorDiskSource::rotorDiskSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
coeffs_(dict_.subDict(type() + "Coeffs")),
rhoName_("none"),
omega_(0.0),
nBlades_(0),
inletFlow_(ifLocal),
inletVelocity_(vector::zero),
tipEffect_(1.0),
flap_(),
trim_(),
blade_(coeffs_.subDict("blade")),
profiles_(coeffs_.subDict("profiles")),
x_(cells_.size(), vector::zero),
R_(cells_.size(), I),
alphag_(cells_.size(), 0.0),
area_(cells_.size(), 0.0),
coordSys_(false),
rMax_(0.0)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::rotorDiskSource::~rotorDiskSource()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rotorDiskSource::addSu(fvMatrix<vector>& UEqn)
{
// add source to lhs of eqn
const volVectorField& U = UEqn.psi();
if (UEqn.dimensions() == dimForce)
{
coeffs_.lookup("rhoName") >> rhoName_;
const volScalarField& rho =
mesh_.lookupObject<volScalarField>(rhoName_);
UEqn += calculateForces
(
rho.internalField(),
inflowVelocity(U),
dimForce/dimVolume
);
}
else
{
UEqn += calculateForces
(
oneField(),
inflowVelocity(U),
dimForce/dimVolume/dimDensity
);
}
}
void Foam::rotorDiskSource::addSu(fvMatrix<scalar>& UEqn)
{
// do nothing
}
void Foam::rotorDiskSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::rotorDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_ = dict.subDict(type() + "Coeffs");
scalar rpm(readScalar(coeffs_.lookup("rpm")));
omega_ = rpm/60.0*mathematical::twoPi;
coeffs_.lookup("nBlades") >> nBlades_;
inletFlow_ = inletFlowTypeNames_.read(coeffs_.lookup("inletFlowType"));
coeffs_.lookup("tipEffect") >> tipEffect_;
const dictionary& flapCoeffs(coeffs_.subDict("flapCoeffs"));
flapCoeffs.lookup("beta0") >> flap_.beta0;
flapCoeffs.lookup("beta1") >> flap_.beta1;
flapCoeffs.lookup("beta2") >> flap_.beta2;
flap_.beta0 = degToRad(flap_.beta0);
const dictionary& trimCoeffs(coeffs_.subDict("trimCoeffs"));
trimCoeffs.lookup("alphaC") >> trim_.alphaC;
trimCoeffs.lookup("A") >> trim_.A;
trimCoeffs.lookup("B") >> trim_.B;
trim_.alphaC = degToRad(trim_.alphaC);
checkData();
createCoordinateSystem();
constructGeometry();
if (debug)
{
writeField("alphag", alphag_, true);
writeField("faceArea", area_, true);
}
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,249 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::rotorDiskSource
Description
Cell-zone based momemtum source
Source approximates the mean effects of rotor forces on a cylindrical
region within the domain
SourceFiles
rotorDiskSource.C
rotorDiskSourceTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef rotorDiskSource_H
#define rotorDiskSource_H
#include "basicSource.H"
#include "cylindricalCS.H"
#include "NamedEnum.H"
#include "bladeModel.H"
#include "profileModelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rotorDiskSource Declaration
\*---------------------------------------------------------------------------*/
class rotorDiskSource
:
public basicSource
{
public:
enum geometryModeType
{
gmAuto,
gmSpecified
};
static const NamedEnum<geometryModeType, 2> geometryModeTypeNames_;
enum inletFlowType
{
ifFixed,
ifSurfaceNormal,
ifLocal
};
static const NamedEnum<inletFlowType, 3> inletFlowTypeNames_;
protected:
// Helper structures to encapsulate flap and trim data
struct flapData
{
scalar beta0; // coning angle [deg]
scalar beta1; // lateral flapping coeff
scalar beta2; // longitudinal flapping coeff
};
struct trimData
{
scalar alphaC; // collective pitch angle [deg]
scalar A; // lateral cyclic coeff
scalar B; // longitudinal cyclic coeff
};
// Protected data
//- Coefficients dictionary
dictionary coeffs_;
//- Name of density field
word rhoName_;
//- Rotational speed [rad/s]
scalar omega_;
//- Number of blades
label nBlades_;
//- Inlet flow type
inletFlowType inletFlow_;
//- Inlet velocity for specified iinflow
vector inletVelocity_;
//- Tip effect [0-1]
// Ratio of blade radius beyond which lift=0
scalar tipEffect_;
//- Blade flap coefficients [rad/s]
flapData flap_;
//- Blad trim coefficients
trimData trim_;
//- Blade data
bladeModel blade_;
//- Profile data
profileModelList profiles_;
//- Cell centre positions in local rotor frame (Cartesian x, y, z)
List<point> x_;
//- Rotation tensor for flap angle
List<tensor> R_;
//- Geometric angle of attack [deg]
List<scalar> alphag_;
//- Area [m2]
List<scalar> area_;
//- Rotor co-ordinate system (r, theta, z)
cylindricalCS coordSys_;
//- Maximum radius
scalar rMax_;
// Protected Member Functions
//- Check data
void checkData();
//- Set the face areas per cell, and optionally correct the rotor axis
void setFaceArea(vector& axis, const bool correct);
//- Create the co-ordinate system
void createCoordinateSystem();
//- Construct geometry
void constructGeometry();
//- Return the inlet flow field
tmp<vectorField> inflowVelocity(const volVectorField& U) const;
//- Calculate forces
template<class RhoType>
tmp<volVectorField> calculateForces
(
const RhoType& rho,
const vectorField& U,
const dimensionSet& dims
);
//- Helper function to write rotor values
template<class Type>
void writeField
(
const word& name,
const List<Type>& values,
const bool writeNow = false
) const;
public:
//- Runtime type information
TypeName("rotorDisk");
// Constructors
//- Construct from components
rotorDiskSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~rotorDiskSource();
// Member Functions
// Source term addition
//- Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//- Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn);
// I-O
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read source dictionary
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "rotorDiskSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,205 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "rotorDiskSource.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"
using namespace Foam::constant;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::rotorDiskSource::writeField
(
const word& name,
const List<Type>& values,
const bool writeNow
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (mesh_.time().outputTime() || writeNow)
{
tmp<fieldType> tfld
(
new fieldType
(
IOobject
(
name,
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensioned<Type>("zero", dimless, pTraits<Type>::zero)
)
);
Field<Type>& fld = tfld().internalField();
if (cells_.size() != values.size())
{
FatalErrorIn("") << "cells_.size() != values_.size()"
<< abort(FatalError);
}
forAll(cells_, i)
{
const label cellI = cells_[i];
fld[cellI] = values[i];
}
tfld().write();
}
}
template<class RhoType>
Foam::tmp<Foam::volVectorField> Foam::rotorDiskSource::calculateForces
(
const RhoType& rho,
const vectorField& U,
const dimensionSet& dims
)
{
tmp<volVectorField> tForce
(
new volVectorField
(
IOobject
(
"rotorForce",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedVector("zero", dims, vector::zero)
)
);
vectorField& force = tForce().internalField();
const scalarField& V = mesh_.V();
// logging info
scalar dragEff = 0.0;
scalar liftEff = 0.0;
scalar AOAmin = GREAT;
scalar AOAmax = -GREAT;
forAll(cells_, i)
{
if (area_[i] > ROOTVSMALL)
{
const label cellI = cells_[i];
const scalar radius = x_[i].x();
// apply correction due to flap in cartesian frame
vector Uc = R_[i] & U[cellI];
// velocity in local reference frame
Uc = coordSys_.localVector(Uc);
// set radial component of velocity to zero
Uc.x() = 0.0;
// remove blade linear velocity from blade normal component
Uc.y() -= radius*omega_;
// velocity magnitude
scalar magUc = mag(Uc);
// determine blade data for this radius
// i1 = index of upper bound data point in blade list
scalar twist = 0.0;
scalar chord = 0.0;
label i1 = -1;
label i2 = -1;
scalar invDr = 0.0;
blade_.interpolate(radius, twist, chord, i1, i2, invDr);
// effective angle of attack
scalar alphaEff = alphag_[i] + twist - atan(Uc.z()/Uc.y());
AOAmin = min(AOAmin, alphaEff);
AOAmax = max(AOAmax, alphaEff);
// determine profile data for this radius and angle of attack
const label profile1 = blade_.profileID()[i1];
const label profile2 = blade_.profileID()[i2];
scalar Cd1 = 0.0;
scalar Cl1 = 0.0;
profiles_[profile1].Cdl(alphaEff, Cd1, Cl1);
scalar Cd2 = 0.0;
scalar Cl2 = 0.0;
profiles_[profile2].Cdl(alphaEff, Cd2, Cl2);
scalar Cd = invDr*(Cd2 - Cd1) + Cd1;
scalar Cl = invDr*(Cl2 - Cl1) + Cl1;
// apply tip effect for blade lift
scalar tipFactor = 1.0;
if (radius/rMax_ > tipEffect_)
{
tipFactor = 0.0;
}
// calculate forces
scalar pDyn = 0.5*rho[cellI]*sqr(magUc);
scalar f = pDyn*chord*nBlades_*area_[i]/(mathematical::twoPi);
vector localForce = vector(0.0, f*Cd, tipFactor*f*Cl);
// accumulate forces
dragEff += localForce.y();
liftEff += localForce.z();
// convert force to global cartesian co-ordinate system
force[cellI] = coordSys_.globalVector(localForce);
force[cellI] /= V[cellI];
}
}
Info<< type() << " output:" << nl
<< " min/max(AOA) = " << radToDeg(AOAmin) << ", "
<< radToDeg(AOAmax) << nl
<< " Effective drag = " << dragEff << nl
<< " Effective lift = " << liftEff << endl;
return tForce;
}
// ************************************************************************* //

View File

@ -134,7 +134,7 @@ Foam::fv::gradScheme<Type>::grad
regIOobject::store(tgGrad.ptr());
}
cachePrintMessage("Retreiving", name, vsf);
cachePrintMessage("Retrieving", name, vsf);
GradFieldType& gGrad = const_cast<GradFieldType&>
(
mesh().objectRegistry::template lookupObject<GradFieldType>(name)

View File

@ -239,7 +239,7 @@ void Foam::SurfaceFilmModel<CloudType>::cacheFilmFields
diameterParcelPatch_ =
filmModel.cloudDiameterTrans().boundaryField()[filmPatchI];
filmModel.toPrimary(filmPatchI, diameterParcelPatch_);
filmModel.toPrimary(filmPatchI, diameterParcelPatch_, maxOp<scalar>());
UFilmPatch_ = filmModel.Us().boundaryField()[filmPatchI];
filmModel.toPrimary(filmPatchI, UFilmPatch_);

View File

@ -1333,11 +1333,12 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
template<class SourcePatch, class TargetPatch>
template<class Type>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const Field<Type>& fld
const Field<Type>& fld,
const BinaryOp& bop
) const
{
if (fld.size() != tgtAddress_.size())
@ -1377,7 +1378,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
forAll(faces, i)
{
result[faceI] += work[faces[i]]*weights[i];
result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]);
}
}
}
@ -1390,7 +1391,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
forAll(faces, i)
{
result[faceI] += fld[faces[i]]*weights[i];
result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]);
}
}
}
@ -1400,24 +1401,26 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
template<class SourcePatch, class TargetPatch>
template<class Type>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const
{
return interpolateToSource(tFld());
return interpolateToSource(tFld(), bop);
}
template<class SourcePatch, class TargetPatch>
template<class Type>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const Field<Type>& fld
const Field<Type>& fld,
const BinaryOp& bop
) const
{
if (fld.size() != srcAddress_.size())
@ -1457,7 +1460,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
forAll(faces, i)
{
result[faceI] += work[faces[i]]*weights[i];
result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]);
}
}
}
@ -1470,7 +1473,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
forAll(faces, i)
{
result[faceI] += fld[faces[i]]*weights[i];
result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]);
}
}
}
@ -1479,6 +1482,55 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
}
template<class SourcePatch, class TargetPatch>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const
{
return interpolateToTarget(tFld(), bop);
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const Field<Type>& fld
) const
{
return interpolateToSource(fld, sumOp<Type>());
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const tmp<Field<Type> >& tFld
) const
{
return interpolateToSource(tFld, sumOp<Type>());
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const Field<Type>& fld
) const
{
return interpolateToSource(fld, sumOp<Type>());
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
@ -1487,7 +1539,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
const tmp<Field<Type> >& tFld
) const
{
return interpolateToTarget(tFld());
return interpolateToSource(tFld, sumOp<Type>());
}

View File

@ -53,6 +53,7 @@ SourceFiles
#include "treeBoundBox.H"
#include "treeBoundBoxList.H"
#include "globalIndex.H"
#include "ops.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -345,11 +346,46 @@ public:
// Evaluation
//- Interpolate from target to source with supplied op
template<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToSource
(
const Field<Type>& fld,
const BinaryOp& bop
) const;
//- Interpolate from target tmp field to source with supplied op
template<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToSource
(
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const;
//- Interpolate from source to target with supplied op
template<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToTarget
(
const Field<Type>& fld,
const BinaryOp& bop
) const;
//- Interpolate from source tmp field to target with supplied op
template<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToTarget
(
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const;
//- Interpolate from target to source
template<class Type>
tmp<Field<Type> > interpolateToSource(const Field<Type>& fld) const;
tmp<Field<Type> > interpolateToSource
(
const Field<Type>& fld
) const;
//- Interpolate from target tmp field to source
//- Interpolate from target tmp field
template<class Type>
tmp<Field<Type> > interpolateToSource
(
@ -358,9 +394,12 @@ public:
//- Interpolate from source to target
template<class Type>
tmp<Field<Type> > interpolateToTarget(const Field<Type>& fld) const;
tmp<Field<Type> > interpolateToTarget
(
const Field<Type>& fld
) const;
//- Interpolate from source tmp field to target
//- Interpolate from source tmp field
template<class Type>
tmp<Field<Type> > interpolateToTarget
(

View File

@ -30,8 +30,13 @@ meshSearch/meshSearch.C
meshTools/meshTools.C
PointEdgeWave/PointEdgeWaveName.C
PointEdgeWave/pointEdgePoint.C
pWave = PointEdgeWave
$(pWave)/PointEdgeWaveName.C
$(pWave)/pointEdgePoint.C
patchWave = PatchEdgeFaceWave
$(patchWave)/PatchEdgeFaceWaveName.C
$(patchWave)/patchEdgeFaceInfo.C
regionSplit/regionSplit.C

View File

@ -0,0 +1,681 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "PatchEdgeFaceWave.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "PatchTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::scalar Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
propagationTol_ = 0.01;
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::label
Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
dummyTrackData_ = 12345;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update info for edgeI, at position pt, with information from
// neighbouring face.
// Updates:
// - changedEdge_, changedEdges_,
// - statistics: nEvals_, nUnvisitedEdges_
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
bool Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
updateEdge
(
const label edgeI,
const label neighbourFaceI,
const Type& neighbourInfo,
Type& edgeInfo
)
{
nEvals_++;
bool wasValid = edgeInfo.valid(td_);
bool propagate =
edgeInfo.updateEdge
(
mesh_,
patch_,
edgeI,
neighbourFaceI,
neighbourInfo,
propagationTol_,
td_
);
if (propagate)
{
if (!changedEdge_[edgeI])
{
changedEdge_[edgeI] = true;
changedEdges_.append(edgeI);
}
}
if (!wasValid && edgeInfo.valid(td_))
{
--nUnvisitedEdges_;
}
return propagate;
}
// Update info for faceI, at position pt, with information from
// neighbouring edge.
// Updates:
// - changedFace_, changedFaces_,
// - statistics: nEvals_, nUnvisitedFace_
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
bool Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
updateFace
(
const label faceI,
const label neighbourEdgeI,
const Type& neighbourInfo,
Type& faceInfo
)
{
nEvals_++;
bool wasValid = faceInfo.valid(td_);
bool propagate =
faceInfo.updateFace
(
mesh_,
patch_,
faceI,
neighbourEdgeI,
neighbourInfo,
propagationTol_,
td_
);
if (propagate)
{
if (!changedFace_[faceI])
{
changedFace_[faceI] = true;
changedFaces_.append(faceI);
}
}
if (!wasValid && faceInfo.valid(td_))
{
--nUnvisitedFaces_;
}
return propagate;
}
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
void Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
syncEdges()
{
const globalMeshData& globalData = mesh_.globalData();
const mapDistribute& map = globalData.globalEdgeSlavesMap();
const PackedBoolList& cppOrientation = globalData.globalEdgeOrientation();
// Convert patch-edge data into cpp-edge data
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//- Construct with all data in consistent orientation
List<Type> cppEdgeData(map.constructSize());
forAll(patchEdges_, i)
{
label patchEdgeI = patchEdges_[i];
label coupledEdgeI = coupledEdges_[i];
if (changedEdge_[patchEdgeI])
{
const Type& data = allEdgeInfo_[patchEdgeI];
// Patch-edge data needs to be converted into coupled-edge data
// (optionally flipped) and consistent in orientation with
// master of coupled edge (optionally flipped)
bool sameOrientation =
(
sameEdgeOrientation_[i]
== cppOrientation[coupledEdgeI]
);
cppEdgeData[coupledEdgeI].updateEdge
(
mesh_,
patch_,
data,
sameOrientation,
propagationTol_,
td_
);
}
}
// Synchronise
// ~~~~~~~~~~~
globalData.syncData
(
cppEdgeData,
globalData.globalEdgeSlaves(),
globalData.globalEdgeTransformedSlaves(),
map,
globalData.globalTransforms(),
updateOp<PrimitivePatchType, Type, TrackingData>
(
mesh_,
patch_,
propagationTol_,
td_
),
transformOp<PrimitivePatchType, Type, TrackingData>
(
mesh_,
patch_,
propagationTol_,
td_
)
);
// Back from cpp-edge to patch-edge data
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAll(patchEdges_, i)
{
label patchEdgeI = patchEdges_[i];
label coupledEdgeI = coupledEdges_[i];
const Type& data = cppEdgeData[coupledEdgeI];
if (data.valid(td_))
{
bool sameOrientation =
(
sameEdgeOrientation_[i]
== cppOrientation[coupledEdgeI]
);
allEdgeInfo_[patchEdgeI].updateEdge
(
mesh_,
patch_,
data,
sameOrientation,
propagationTol_,
td_
);
if (!changedEdge_[patchEdgeI])
{
changedEdges_.append(patchEdgeI);
changedEdge_[patchEdgeI] = true;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Iterate, propagating changedEdgesInfo across patch, until no change (or
// maxIter reached). Initial edge values specified.
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
PatchEdgeFaceWave
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const labelList& changedEdges,
const List<Type>& changedEdgesInfo,
UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo,
const label maxIter,
TrackingData& td
)
:
mesh_(mesh),
patch_(patch),
allEdgeInfo_(allEdgeInfo),
allFaceInfo_(allFaceInfo),
td_(td),
changedEdge_(patch_.nEdges()),
changedEdges_(patch_.size()),
changedFace_(patch_.size()),
changedFaces_(patch_.size()),
nEvals_(0),
nUnvisitedEdges_(patch_.nEdges()),
nUnvisitedFaces_(patch_.size())
{
// Calculate addressing between patch_ and mesh.globalData().coupledPatch()
// for ease of synchronisation
PatchTools::matchEdges
(
patch_,
mesh_.globalData().coupledPatch(),
patchEdges_,
coupledEdges_,
sameEdgeOrientation_
);
if (allEdgeInfo_.size() != patch_.nEdges())
{
FatalErrorIn
(
"PatchEdgeFaceWave<Type, TrackingData>::PatchEdgeFaceWave"
"(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "size of edgeInfo work array is not equal to the number"
<< " of edges in the patch" << endl
<< " edgeInfo :" << allEdgeInfo_.size() << endl
<< " patch.nEdges:" << patch_.nEdges()
<< exit(FatalError);
}
if (allFaceInfo_.size() != patch_.size())
{
FatalErrorIn
(
"PatchEdgeFaceWave<Type, TrackingData>::PatchEdgeFaceWave"
"(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "size of edgeInfo work array is not equal to the number"
<< " of faces in the patch" << endl
<< " faceInfo :" << allFaceInfo_.size() << endl
<< " patch.size:" << patch_.size()
<< exit(FatalError);
}
// Set from initial changed edges data
setEdgeInfo(changedEdges, changedEdgesInfo);
if (debug)
{
Pout<< "Seed edges : " << changedEdges_.size() << endl;
}
// Iterate until nothing changes
label iter = iterate(maxIter);
if ((maxIter > 0) && (iter >= maxIter))
{
FatalErrorIn
(
"PatchEdgeFaceWave<Type, TrackingData>::PatchEdgeFaceWave"
"(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)"
) << "Maximum number of iterations reached. Increase maxIter." << endl
<< " maxIter:" << maxIter << endl
<< " changedEdges:" << changedEdges_.size() << endl
<< " changedFaces:" << changedFaces_.size() << endl
<< exit(FatalError);
}
}
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
PatchEdgeFaceWave
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo,
TrackingData& td
)
:
mesh_(mesh),
patch_(patch),
allEdgeInfo_(allEdgeInfo),
allFaceInfo_(allFaceInfo),
td_(td),
changedEdge_(patch_.nEdges()),
changedEdges_(patch_.nEdges()),
changedFace_(patch_.size()),
changedFaces_(patch_.size()),
nEvals_(0),
nUnvisitedEdges_(patch_.nEdges()),
nUnvisitedFaces_(patch_.size())
{
// Calculate addressing between patch_ and mesh.globalData().coupledPatch()
// for ease of synchronisation
PatchTools::matchEdges
(
patch_,
mesh_.globalData().coupledPatch(),
patchEdges_,
coupledEdges_,
sameEdgeOrientation_
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
getUnsetEdges() const
{
return nUnvisitedEdges_;
}
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
getUnsetFaces() const
{
return nUnvisitedFaces_;
}
// Copy edge information into member data
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
void Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
setEdgeInfo
(
const labelList& changedEdges,
const List<Type>& changedEdgesInfo
)
{
forAll(changedEdges, changedEdgeI)
{
label edgeI = changedEdges[changedEdgeI];
bool wasValid = allEdgeInfo_[edgeI].valid(td_);
// Copy info for edgeI
allEdgeInfo_[edgeI] = changedEdgesInfo[changedEdgeI];
// Maintain count of unset edges
if (!wasValid && allEdgeInfo_[edgeI].valid(td_))
{
--nUnvisitedEdges_;
}
// Mark edgeI as changed, both on list and on edge itself.
if (!changedEdge_[edgeI])
{
changedEdge_[edgeI] = true;
changedEdges_.append(edgeI);
}
}
}
// Propagate information from face to edge. Return number of edges changed.
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
faceToEdge()
{
changedEdges_.clear();
changedEdge_ = false;
forAll(changedFaces_, changedFaceI)
{
label faceI = changedFaces_[changedFaceI];
if (!changedFace_[faceI])
{
FatalErrorIn("PatchEdgeFaceWave<Type, TrackingData>::faceToEdge()")
<< "face " << faceI
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same"
<< " seed edge." << abort(FatalError);
}
const Type& neighbourWallInfo = allFaceInfo_[faceI];
// Evaluate all connected edges
const labelList& fEdges = patch_.faceEdges()[faceI];
forAll(fEdges, fEdgeI)
{
label edgeI = fEdges[fEdgeI];
Type& currentWallInfo = allEdgeInfo_[edgeI];
if (!currentWallInfo.equal(neighbourWallInfo, td_))
{
updateEdge
(
edgeI,
faceI,
neighbourWallInfo,
currentWallInfo
);
}
}
}
syncEdges();
if (debug)
{
Pout<< "Changed edges : " << changedEdges_.size() << endl;
}
return returnReduce(changedEdges_.size(), sumOp<label>());
}
// Propagate information from edge to face. Return number of faces changed.
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
edgeToFace()
{
changedFaces_.clear();
changedFace_ = false;
const labelListList& edgeFaces = patch_.edgeFaces();
forAll(changedEdges_, changedEdgeI)
{
label edgeI = changedEdges_[changedEdgeI];
if (!changedEdge_[edgeI])
{
FatalErrorIn("PatchEdgeFaceWave<Type, TrackingData>::edgeToFace()")
<< "edge " << edgeI
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same"
<< " seed edge." << abort(FatalError);
}
const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
// Evaluate all connected faces
const labelList& eFaces = edgeFaces[edgeI];
forAll(eFaces, eFaceI)
{
label faceI = eFaces[eFaceI];
Type& currentWallInfo = allFaceInfo_[faceI];
if (!currentWallInfo.equal(neighbourWallInfo, td_))
{
updateFace
(
faceI,
edgeI,
neighbourWallInfo,
currentWallInfo
);
}
}
}
if (debug)
{
Pout<< "Changed faces : " << changedFaces_.size() << endl;
}
return returnReduce(changedFaces_.size(), sumOp<label>());
}
// Iterate
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
iterate
(
const label maxIter
)
{
// Make sure coupled edges contain same info
syncEdges();
nEvals_ = 0;
label iter = 0;
while (iter < maxIter)
{
if (debug)
{
Pout<< "Iteration " << iter << endl;
}
label nFaces = edgeToFace();
if (debug)
{
Pout<< "Total changed faces : " << nFaces << endl;
}
if (nFaces == 0)
{
break;
}
label nEdges = faceToEdge();
if (debug)
{
Pout<< "Total changed edges : " << nEdges << nl
<< "Total evaluations : " << nEvals_ << nl
<< "Remaining unvisited edges : " << nUnvisitedEdges_ << nl
<< "Remaining unvisited faces : " << nUnvisitedFaces_ << nl
<< endl;
}
if (nEdges == 0)
{
break;
}
iter++;
}
return iter;
}
// ************************************************************************* //

View File

@ -0,0 +1,368 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::PatchEdgeFaceWave
Description
Wave propagation of information along patch. Every iteration
information goes through one layer of faces. Templated on information
that is transferred.
SourceFiles
PatchEdgeFaceWave.C
\*---------------------------------------------------------------------------*/
#ifndef PatchEdgeFaceWave_H
#define PatchEdgeFaceWave_H
#include "scalarField.H"
#include "PackedBoolList.H"
#include "PrimitivePatch.H"
#include "vectorTensorTransform.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
/*---------------------------------------------------------------------------*\
Class PatchEdgeFaceWaveName Declaration
\*---------------------------------------------------------------------------*/
TemplateName(PatchEdgeFaceWave);
/*---------------------------------------------------------------------------*\
Class PatchEdgeFaceWave Declaration
\*---------------------------------------------------------------------------*/
template
<
class PrimitivePatchType,
class Type,
class TrackingData = int
>
class PatchEdgeFaceWave
:
public PatchEdgeFaceWaveName
{
// Private static data
//- Relative tolerance. Stop propagation if relative changes
// less than this tolerance (responsability for checking this is
// up to Type implementation)
static scalar propagationTol_;
//- Used as default trackdata value to satisfy default template
// argument.
static label dummyTrackData_;
// Private data
//- Reference to mesh
const polyMesh& mesh_;
//- Reference to patch
const PrimitivePatchType& patch_;
//- Wall information for all edges
UList<Type>& allEdgeInfo_;
//- Information on all patch faces
UList<Type>& allFaceInfo_;
//- Additional data to be passed into container
TrackingData& td_;
//- Has edge changed
PackedBoolList changedEdge_;
//- List of changed edges
DynamicList<label> changedEdges_;
//- Has face changed
PackedBoolList changedFace_;
//- List of changed faces
DynamicList<label> changedFaces_;
//- Number of evaluations
label nEvals_;
//- Number of unvisited faces/edges
label nUnvisitedEdges_;
label nUnvisitedFaces_;
// Addressing between edges of patch_ and globalData.coupledPatch()
labelList patchEdges_;
labelList coupledEdges_;
PackedBoolList sameEdgeOrientation_;
// Private Member Functions
//- Updates edgeInfo with information from neighbour. Updates all
// statistics.
bool updateEdge
(
const label edgeI,
const label neighbourFaceI,
const Type& neighbourInfo,
Type& edgeInfo
);
//- Updates faceInfo with information from neighbour. Updates all
// statistics.
bool updateFace
(
const label faceI,
const label neighbourEdgeI,
const Type& neighbourInfo,
Type& faceInfo
);
//- Update coupled edges
void syncEdges();
//- Disallow default bitwise copy construct
PatchEdgeFaceWave(const PatchEdgeFaceWave&);
//- Disallow default bitwise assignment
void operator=(const PatchEdgeFaceWave&);
public:
// Static Functions
//- Access to tolerance
static scalar propagationTol()
{
return propagationTol_;
}
//- Change tolerance
static void setPropagationTol(const scalar tol)
{
propagationTol_ = tol;
}
// Constructors
//- Construct from patch, list of changed edges with the Type
// for these edges. Gets work arrays to operate on, one of size
// number of patch edges, the other number of patch faces.
// Iterates until nothing changes or maxIter reached.
// (maxIter can be 0)
PatchEdgeFaceWave
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const labelList& initialEdges,
const List<Type>& initialEdgesInfo,
UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo,
const label maxIter,
TrackingData& td = dummyTrackData_
);
//- Construct from patch. Use setEdgeInfo and iterate() to do
// actual calculation
PatchEdgeFaceWave
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo,
TrackingData& td = dummyTrackData_
);
// Member Functions
//- Access allEdgeInfo
UList<Type>& allEdgeInfo() const
{
return allEdgeInfo_;
}
//- Access allFaceInfo
UList<Type>& allFaceInfo() const
{
return allFaceInfo_;
}
//- Additional data to be passed into container
const TrackingData& data() const
{
return td_;
}
//- Get number of unvisited faces, i.e. faces that were not (yet)
// reached from walking across patch. This can happen from
// - not enough iterations done
// - a disconnected patch
// - a patch without walls in it
label getUnsetFaces() const;
label getUnsetEdges() const;
//- Copy initial data into allEdgeInfo_
void setEdgeInfo
(
const labelList& changedEdges,
const List<Type>& changedEdgesInfo
);
//- Propagate from edge to face. Returns total number of faces
// (over all processors) changed.
label edgeToFace();
//- Propagate from face to edge. Returns total number of edges
// (over all processors) changed.
label faceToEdge();
//- Iterate until no changes or maxIter reached. Returns actual
// number of iterations.
label iterate(const label maxIter);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Update operation
template
<
class PrimitivePatchType,
class Type,
class TrackingData = int
>
class updateOp
{
//- Additional data to be passed into container
const polyMesh& mesh_;
const PrimitivePatchType& patch_;
const scalar tol_;
TrackingData& td_;
public:
updateOp
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const scalar tol,
TrackingData& td
)
:
mesh_(mesh),
patch_(patch),
tol_(tol),
td_(td)
{}
void operator()(Type& x, const Type& y) const
{
if (y.valid(td_))
{
x.updateEdge(mesh_, patch_, y, true, tol_, td_);
}
}
};
//- Transform operation
template
<
class PrimitivePatchType,
class Type,
class TrackingData = int
>
class transformOp
{
//- Additional data to be passed into container
const polyMesh& mesh_;
const PrimitivePatchType& patch_;
const scalar tol_;
TrackingData& td_;
public:
transformOp
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const scalar tol,
TrackingData& td
)
:
mesh_(mesh),
patch_(patch),
tol_(tol),
td_(td)
{}
void operator()
(
const vectorTensorTransform& vt,
const bool forward,
List<Type>& fld
) const
{
if (forward)
{
forAll(fld, i)
{
fld[i].transform(mesh_, patch_, vt.R(), tol_, td_);
}
}
else
{
forAll(fld, i)
{
fld[i].transform(mesh_, patch_, vt.R().T(), tol_, td_);
}
}
}
};
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PatchEdgeFaceWave.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,32 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "PatchEdgeFaceWave.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::PatchEdgeFaceWaveName, 0);
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "patchEdgeFaceInfo.H"
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::patchEdgeFaceInfo& wDist
)
{
return os << wDist.origin() << wDist.distSqr();
}
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::patchEdgeFaceInfo& wDist
)
{
return is >> wDist.origin_ >> wDist.distSqr_;
}
// ************************************************************************* //

View File

@ -0,0 +1,212 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::patchEdgeFaceInfo
Description
SourceFiles
patchEdgeFaceInfoI.H
patchEdgeFaceInfo.C
\*---------------------------------------------------------------------------*/
#ifndef patchEdgeFaceInfo_H
#define patchEdgeFaceInfo_H
#include "point.H"
#include "label.H"
#include "scalar.H"
#include "tensor.H"
#include "pTraits.H"
#include "primitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyPatch;
class polyMesh;
/*---------------------------------------------------------------------------*\
Class patchEdgeFaceInfo Declaration
\*---------------------------------------------------------------------------*/
class patchEdgeFaceInfo
{
// Private data
//- position of nearest wall center
point origin_;
//- normal distance (squared) from point to origin
scalar distSqr_;
// Private Member Functions
//- Evaluate distance to point. Update distSqr, origin from whomever
// is nearer pt. Return true if w2 is closer to point,
// false otherwise.
template<class TrackingData>
inline bool update
(
const point&,
const patchEdgeFaceInfo& w2,
const scalar tol,
TrackingData& td
);
//- Combine current with w2. Update distSqr, origin if w2 has smaller
// quantities and returns true.
template<class TrackingData>
inline bool update
(
const patchEdgeFaceInfo& w2,
const scalar tol,
TrackingData& td
);
public:
// Constructors
//- Construct null
inline patchEdgeFaceInfo();
//- Construct from origin, distance
inline patchEdgeFaceInfo(const point&, const scalar);
//- Construct as copy
inline patchEdgeFaceInfo(const patchEdgeFaceInfo&);
// Member Functions
// Access
inline const point& origin() const;
inline scalar distSqr() const;
// Needed by meshWave
//- Check whether origin has been changed at all or
// still contains original (invalid) value.
template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Apply rotation matrix
template<class TrackingData>
inline void transform
(
const polyMesh& mesh,
const primitivePatch& patch,
const tensor& rotTensor,
const scalar tol,
TrackingData& td
);
//- Influence of face on edge
template<class TrackingData>
inline bool updateEdge
(
const polyMesh& mesh,
const primitivePatch& patch,
const label edgeI,
const label faceI,
const patchEdgeFaceInfo& faceInfo,
const scalar tol,
TrackingData& td
);
//- New information for edge (from e.g. coupled edge)
template<class TrackingData>
inline bool updateEdge
(
const polyMesh& mesh,
const primitivePatch& patch,
const patchEdgeFaceInfo& edgeInfo,
const bool sameOrientation,
const scalar tol,
TrackingData& td
);
//- Influence of edge on face.
template<class TrackingData>
inline bool updateFace
(
const polyMesh& mesh,
const primitivePatch& patch,
const label faceI,
const label edgeI,
const patchEdgeFaceInfo& edgeInfo,
const scalar tol,
TrackingData& td
);
//- Same (like operator==)
template<class TrackingData>
inline bool equal(const patchEdgeFaceInfo&, TrackingData& td) const;
// Member Operators
// Needed for List IO
inline bool operator==(const patchEdgeFaceInfo&) const;
inline bool operator!=(const patchEdgeFaceInfo&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const patchEdgeFaceInfo&);
friend Istream& operator>>(Istream&, patchEdgeFaceInfo&);
};
//- Data associated with patchEdgeFaceInfo type are contiguous
template<>
inline bool contiguous<patchEdgeFaceInfo>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "patchEdgeFaceInfoI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,268 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "polyMesh.H"
#include "transform.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update this with w2 if w2 nearer to pt.
template<class TrackingData>
inline bool Foam::patchEdgeFaceInfo::update
(
const point& pt,
const patchEdgeFaceInfo& w2,
const scalar tol,
TrackingData& td
)
{
scalar dist2 = magSqr(pt - w2.origin());
if (!valid(td))
{
// current not yet set so use any value
distSqr_ = dist2;
origin_ = w2.origin();
return true;
}
scalar diff = distSqr_ - dist2;
if (diff < 0)
{
// already nearer to pt
return false;
}
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{
// don't propagate small changes
return false;
}
else
{
// update with new values
distSqr_ = dist2;
origin_ = w2.origin();
return true;
}
}
// Update this with w2 (information on same edge)
template<class TrackingData>
inline bool Foam::patchEdgeFaceInfo::update
(
const patchEdgeFaceInfo& w2,
const scalar tol,
TrackingData& td
)
{
if (!valid(td))
{
// current not yet set so use any value
distSqr_ = w2.distSqr();
origin_ = w2.origin();
return true;
}
scalar diff = distSqr_ - w2.distSqr();
if (diff < 0)
{
// already nearer to pt
return false;
}
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{
// don't propagate small changes
return false;
}
else
{
// update with new values
distSqr_ = w2.distSqr();
origin_ = w2.origin();
return true;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
inline Foam::patchEdgeFaceInfo::patchEdgeFaceInfo()
:
origin_(point::max),
distSqr_(sqr(GREAT))
{}
// Construct from origin, distance
inline Foam::patchEdgeFaceInfo::patchEdgeFaceInfo
(
const point& origin,
const scalar distSqr
)
:
origin_(origin),
distSqr_(distSqr)
{}
// Construct as copy
inline Foam::patchEdgeFaceInfo::patchEdgeFaceInfo(const patchEdgeFaceInfo& wpt)
:
origin_(wpt.origin()),
distSqr_(wpt.distSqr())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::point& Foam::patchEdgeFaceInfo::origin() const
{
return origin_;
}
inline Foam::scalar Foam::patchEdgeFaceInfo::distSqr() const
{
return distSqr_;
}
template<class TrackingData>
inline bool Foam::patchEdgeFaceInfo::valid(TrackingData& td) const
{
return origin_ != point::max;
}
template<class TrackingData>
inline void Foam::patchEdgeFaceInfo::transform
(
const polyMesh& mesh,
const primitivePatch& patch,
const tensor& rotTensor,
const scalar tol,
TrackingData& td
)
{
origin_ = Foam::transform(rotTensor, origin_);
}
template<class TrackingData>
inline bool Foam::patchEdgeFaceInfo::updateEdge
(
const polyMesh& mesh,
const primitivePatch& patch,
const label edgeI,
const label faceI,
const patchEdgeFaceInfo& faceInfo,
const scalar tol,
TrackingData& td
)
{
const edge& e = patch.edges()[edgeI];
point eMid =
0.5
* (
patch.points()[patch.meshPoints()[e[0]]]
+ patch.points()[patch.meshPoints()[e[1]]]
);
return update(eMid, faceInfo, tol, td);
}
template<class TrackingData>
inline bool Foam::patchEdgeFaceInfo::updateEdge
(
const polyMesh& mesh,
const primitivePatch& patch,
const patchEdgeFaceInfo& edgeInfo,
const bool sameOrientation,
const scalar tol,
TrackingData& td
)
{
return update(edgeInfo, tol, td);
}
template<class TrackingData>
inline bool Foam::patchEdgeFaceInfo::updateFace
(
const polyMesh& mesh,
const primitivePatch& patch,
const label faceI,
const label edgeI,
const patchEdgeFaceInfo& edgeInfo,
const scalar tol,
TrackingData& td
)
{
return update(patch.faceCentres()[faceI], edgeInfo, tol, td);
}
template <class TrackingData>
inline bool Foam::patchEdgeFaceInfo::equal
(
const patchEdgeFaceInfo& rhs,
TrackingData& td
) const
{
return operator==(rhs);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::patchEdgeFaceInfo::operator==
(
const Foam::patchEdgeFaceInfo& rhs
) const
{
return origin() == rhs.origin();
}
inline bool Foam::patchEdgeFaceInfo::operator!=
(
const Foam::patchEdgeFaceInfo& rhs
) const
{
return !(*this == rhs);
}
// ************************************************************************* //

View File

@ -339,6 +339,39 @@ public:
}
//- Wrapper around map/interpolate data distribution with supplied op
template<class Type, class BinaryOp>
void distribute(List<Type>& lst, const BinaryOp& bop) const
{
switch (mode_)
{
case NEARESTPATCHFACEAMI:
{
lst = AMI().interpolateToSource
(
Field<Type>(lst.xfer()),
bop
);
break;
}
default:
{
map().distribute
(
Pstream::defaultCommsType,
map().schedule(),
map().constructSize(),
map().subMap(),
map().constructMap(),
lst,
bop,
pTraits<Type>::zero
);
}
}
}
//- Wrapper around map/interpolate data distribution
template<class Type>
void reverseDistribute(List<Type>& lst) const
@ -359,6 +392,40 @@ public:
}
//- Wrapper around map/interpolate data distribution with supplied op
template<class Type, class BinaryOp>
void reverseDistribute(List<Type>& lst, const BinaryOp& bop) const
{
switch (mode_)
{
case NEARESTPATCHFACEAMI:
{
lst = AMI().interpolateToTarget
(
Field<Type>(lst.xfer()),
bop
);
break;
}
default:
{
label cSize = patch_.size();
map().distribute
(
Pstream::defaultCommsType,
map().schedule(),
cSize,
map().constructMap(),
map().subMap(),
lst,
bop,
pTraits<Type>::zero
);
}
}
}
//- Return reference to the parallel distribution map
const mapDistribute& map() const
{

View File

@ -3,6 +3,9 @@ fieldAverage/fieldAverageItem/fieldAverageItem.C
fieldAverage/fieldAverageItem/fieldAverageItemIO.C
fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C
fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C
fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C
fieldMinMax/fieldMinMax.C
fieldMinMax/fieldMinMaxFunctionObject.C

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Typedef
Foam::IOfieldCoordinateSystemTransform
Description
Instance of the generic IOOutputFilter for fieldCoordinateSystemTransform.
\*---------------------------------------------------------------------------*/
#ifndef IOfieldCoordinateSystemTransform_H
#define IOfieldCoordinateSystemTransform_H
#include "fieldCoordinateSystemTransform.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<fieldCoordinateSystemTransform>
IOfieldCoordinateSystemTransform;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,118 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "fieldCoordinateSystemTransform.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::fieldCoordinateSystemTransform, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
name_(name),
obr_(obr),
active_(true),
fieldSet_(),
coordSys_(dict, obr)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"fieldCoordinateSystemTransform::fieldCoordinateSystemTransform"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "No fvMesh available, deactivating."
<< endl;
}
read(dict);
Info<< type() << ":" << nl
<< " Applying transformation from global Cartesian to local "
<< coordSys_ << nl << endl;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldCoordinateSystemTransform::~fieldCoordinateSystemTransform()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldCoordinateSystemTransform::read(const dictionary& dict)
{
if (active_)
{
dict.lookup("fields") >> fieldSet_;
}
}
void Foam::fieldCoordinateSystemTransform::execute()
{
// Do nothing
}
void Foam::fieldCoordinateSystemTransform::end()
{
// Do nothing
}
void Foam::fieldCoordinateSystemTransform::write()
{
forAll(fieldSet_, fieldI)
{
// If necessary load field
transform<scalar>(fieldSet_[fieldI]);
transform<vector>(fieldSet_[fieldI]);
transform<sphericalTensor>(fieldSet_[fieldI]);
transform<symmTensor>(fieldSet_[fieldI]);
transform<tensor>(fieldSet_[fieldI]);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,163 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::fieldCoordinateSystemTransform
Description
Transforms fields from global cartesian co-ordinates to local co-ordinate
system
SourceFiles
fieldCoordinateSystemTransform.C
IOfieldCoordinateSystemTransform.H
\*---------------------------------------------------------------------------*/
#ifndef fieldCoordinateSystemTransform_H
#define fieldCoordinateSystemTransform_H
#include "OFstream.H"
#include "pointFieldFwd.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "coordinateSystem.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class fieldCoordinateSystemTransform Declaration
\*---------------------------------------------------------------------------*/
class fieldCoordinateSystemTransform
{
protected:
// Protected data
//- Name
word name_;
const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Fields to transform
wordList fieldSet_;
//- Co-ordinate system to transform to
coordinateSystem coordSys_;
// Protected Member Functions
//- Disallow default bitwise copy construct
fieldCoordinateSystemTransform(const fieldCoordinateSystemTransform&);
//- Disallow default bitwise assignment
void operator=(const fieldCoordinateSystemTransform&);
template<class Type>
void transform(const word& fieldName) const;
template<class Type>
void transformField(const Type& field) const;
public:
//- Runtime type information
TypeName("fieldCoordinateSystemTransform");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
fieldCoordinateSystemTransform
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~fieldCoordinateSystemTransform();
// Member Functions
//- Return name of the fieldCoordinateSystemTransform object
virtual const word& name() const
{
return name_;
}
//- Read the input data
virtual void read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Write
virtual void write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh
virtual void movePoints(const pointField&)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "fieldCoordinateSystemTransformTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,45 +23,23 @@ License
\*---------------------------------------------------------------------------*/
#include "patchPointEdgeCirculator.H"
#include "fieldCoordinateSystemTransformFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::patchPointEdgeCirculator
Foam::patchPointEdgeCirculator::endConstIter
(
*reinterpret_cast<primitiveFacePatch*>(0), // primitiveFacePatch
*reinterpret_cast<PackedBoolList*>(0), // PackedBoolList
-1, // edgeID
-1, // index
-1 // pointID
);
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const InfoProxy<patchPointEdgeCirculator>& ip
)
namespace Foam
{
const patchPointEdgeCirculator& c = ip.t_;
defineNamedTemplateTypeNameAndDebug
(
fieldCoordinateSystemTransformFunctionObject, 0
);
const pointField& pts = c.patch_.localPoints();
const edge& e = c.patch_.edges()[c.edgeID_];
label faceI = c.faceID();
os << "around point:" << c.pointID_
<< " coord:" << pts[c.pointID_]
<< " at edge:" << c.edgeID_
<< " coord:" << pts[e.otherVertex(c.pointID_)]
<< " in direction of face:" << faceI;
if (faceI != -1)
{
os << " fc:" << c.patch_.localFaces()[faceI].centre(pts);
}
return os;
addToRunTimeSelectionTable
(
functionObject,
fieldCoordinateSystemTransformFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Typedef
Foam::fieldCoordinateSystemTransformFunctionObject
Description
FunctionObject wrapper around fieldCoordinateSystemTransform to allow
them to be created via the functions entry within controlDict.
SourceFiles
fieldCoordinateSystemTransformFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef fieldCoordinateSystemTransformFunctionObject_H
#define fieldCoordinateSystemTransformFunctionObject_H
#include "fieldCoordinateSystemTransform.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<fieldCoordinateSystemTransform>
fieldCoordinateSystemTransformFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "fieldCoordinateSystemTransform.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "Time.H"
#include "transformGeometricField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::fieldCoordinateSystemTransform::transformField
(
const Type& field
) const
{
const word& fieldName = field.name() + "Transformed";
dimensionedTensor R("R", field.dimensions(), coordSys_.R());
if (obr_.foundObject<Type>(fieldName))
{
Type& transField =
const_cast<Type&>(obr_.lookupObject<Type>(fieldName));
transField == field;
forAll(field, i)
{
Foam::transform(transField, R, transField);
}
transField.write();
}
else
{
Type& transField = obr_.store
(
new Type
(
IOobject
(
fieldName,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
field
)
);
forAll(field, i)
{
Foam::transform(transField, R, transField);
}
transField.write();
}
}
template<class Type>
void Foam::fieldCoordinateSystemTransform::transform
(
const word& fieldName
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
if (obr_.foundObject<vfType>(fieldName))
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " already in database"
<< endl;
}
transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
}
else if (obr_.foundObject<sfType>(fieldName))
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " already in database"
<< endl;
}
transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
}
else
{
IOobject fieldHeader
(
fieldName,
obr_.time().timeName(),
obr_,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if
(
fieldHeader.headerOk()
&& fieldHeader.headerClassName() == vfType::typeName
)
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " read from file"
<< endl;
}
transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
}
else if
(
fieldHeader.headerOk()
&& fieldHeader.headerClassName() == sfType::typeName
)
{
if (debug)
{
Info<< type() << ": Field " << fieldName << " read from file"
<< endl;
}
transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object postProcessingDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
functions
{
fieldCoordinateSystemTransform1
{
// Type of functionObject
type fieldCoordinateSystemTransform;
// Where to load it from (if not already in solver)
functionObjectLibs ("libfieldCoordinateSystemTransform.so");
// Function object enabled flag
enabled true;
// When to output the average fields
outputControl outputTime;
// Fields to be transformed - runTime modifiable
fields
(
U
UMean
UPrime2Mean
);
coordinateSystem
{
origin (0.001 0 0);
e1 (1 0.15 0);
e3 (0 0 -1);
}
}
}
// ************************************************************************* //

View File

@ -60,7 +60,7 @@ functions
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
// Velocity field to use for tracking.
U U;
UName U;
// Interpolation method. Default is cellPoint. See sampleDict.
//interpolationScheme pointMVC;

View File

@ -318,7 +318,22 @@ void Foam::streamLine::read(const dictionary& dict)
{
//dict_ = dict;
dict.lookup("fields") >> fields_;
UName_ = dict.lookupOrDefault<word>("U", "U");
if (dict.found("UName"))
{
dict.lookup("UName") >> UName_;
}
else
{
UName_ = "U";
if (dict.found("U"))
{
IOWarningIn("streamLine::read(const dictionary&)", dict)
<< "Using deprecated entry \"U\"."
<< " Please use \"UName\" instead."
<< endl;
dict.lookup("U") >> UName_;
}
}
dict.lookup("trackForward") >> trackForward_;
dict.lookup("lifeTime") >> lifeTime_;
if (lifeTime_ < 1)

View File

@ -231,6 +231,24 @@ public:
List<Type>& primaryFieldField
) const;
//- Convert a local region field to the primary region with op
template<class Type, class BinaryOp>
void toPrimary
(
const label regionPatchI,
List<Type>& regionField,
const BinaryOp& bop
) const;
//- Convert a primary region field to the local region with op
template<class Type, class BinaryOp>
void toRegion
(
const label regionPatchI,
List<Type>& primaryFieldField,
const BinaryOp& bop
) const;
// Evolution

View File

@ -77,4 +77,69 @@ void Foam::regionModels::regionModel::toRegion
}
template<class Type, class BinaryOp>
void Foam::regionModels::regionModel::toPrimary
(
const label regionPatchI,
List<Type>& regionField,
const BinaryOp& bop
) const
{
forAll(intCoupledPatchIDs_, i)
{
if (intCoupledPatchIDs_[i] == regionPatchI)
{
const mappedPatchBase& mpb =
refCast<const mappedPatchBase>
(
regionMesh().boundaryMesh()[regionPatchI]
);
mpb.reverseDistribute(regionField, bop);
return;
}
}
FatalErrorIn
(
"const void toPrimary"
"("
"const label, "
"List<Type>&, "
"const BinaryOp&"
") const"
) << "Region patch ID " << regionPatchI << " not found in region mesh"
<< abort(FatalError);
}
template<class Type, class BinaryOp>
void Foam::regionModels::regionModel::toRegion
(
const label regionPatchI,
List<Type>& primaryField,
const BinaryOp& bop
) const
{
forAll(intCoupledPatchIDs_, i)
{
if (intCoupledPatchIDs_[i] == regionPatchI)
{
const mappedPatchBase& mpb =
refCast<const mappedPatchBase>
(
regionMesh().boundaryMesh()[regionPatchI]
);
mpb.distribute(primaryField, bop);
return;
}
}
FatalErrorIn
(
"const void toRegion(const label, List<Type>&, const BinaryOp&) const"
) << "Region patch ID " << regionPatchI << " not found in region mesh"
<< abort(FatalError);
}
// ************************************************************************* //

View File

@ -54,10 +54,6 @@ externalWallHeatFluxTemperatureFvPatchScalarField::operationModeNames;
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
@ -118,7 +114,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
oldMode_ = fixedHeatFlux;
q_ = scalarField("q", dict, p.size());
}
else if(dict.found("h") && dict.found("Ta") && !dict.found("q"))
else if (dict.found("h") && dict.found("Ta") && !dict.found("q"))
{
oldMode_ = fixedHeatTransferCoeff;
h_ = scalarField("h", dict, p.size());
@ -209,7 +205,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
{
q = q_;
}
else if(oldMode_ == fixedHeatTransferCoeff)
else if (oldMode_ == fixedHeatTransferCoeff)
{
q = (Ta_ - *this)*h_;
}

View File

@ -17,7 +17,7 @@ streamLines
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
// Velocity field to use for tracking.
U U;
UName U;
// Tracked forwards (+U) or backwards (-U)
trackForward true;

View File

@ -61,7 +61,7 @@ functions
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
// Velocity field to use for tracking.
U U;
UName U;
// Tracked forwards (+U) or backwards (-U)
trackForward true;

View File

@ -61,7 +61,7 @@ functions
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
// Velocity field to use for tracking.
U U;
UName U;
// Tracked forwards (+U) or backwards (-U)
trackForward true;