mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge remote-tracking branch 'origin/master' into feature/procAgglom
Conflicts: src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/GAMGInterface/GAMGInterface.H src/finiteVolume/fvMesh/fvMesh.H
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -42,6 +42,7 @@ Description
|
||||
SourceFiles
|
||||
AMIInterpolation.C
|
||||
AMIInterpolationName.C
|
||||
AMIInterpolationParallelOps.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -49,14 +50,11 @@ SourceFiles
|
||||
#define AMIInterpolation_H
|
||||
|
||||
#include "className.H"
|
||||
#include "DynamicList.H"
|
||||
#include "searchableSurface.H"
|
||||
#include "treeBoundBoxList.H"
|
||||
#include "boolList.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "faceAreaIntersect.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "treeDataPrimitivePatch.H"
|
||||
#include "treeBoundBoxList.H"
|
||||
#include "globalIndex.H"
|
||||
#include "ops.H"
|
||||
|
||||
@ -81,12 +79,38 @@ class AMIInterpolation
|
||||
:
|
||||
public AMIInterpolationName
|
||||
{
|
||||
//- local typedef to octree tree-type
|
||||
typedef treeDataPrimitivePatch<TargetPatch> treeType;
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration specifying interpolation method
|
||||
enum interpolationMethod
|
||||
{
|
||||
imDirect,
|
||||
imMapNearest,
|
||||
imFaceAreaWeight
|
||||
};
|
||||
|
||||
//- Convert interpolationMethod to word representation
|
||||
static word interpolationMethodToWord
|
||||
(
|
||||
const interpolationMethod& method
|
||||
);
|
||||
|
||||
//- Convert word to interpolationMethod
|
||||
static interpolationMethod wordTointerpolationMethod
|
||||
(
|
||||
const word& method
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Interpolation method
|
||||
interpolationMethod method_;
|
||||
|
||||
//- Flag to indicate that the two patches are co-directional and
|
||||
// that the orientation of the target patch should be reversed
|
||||
const bool reverseTarget_;
|
||||
@ -95,6 +119,7 @@ class AMIInterpolation
|
||||
// cases
|
||||
label singlePatchProc_;
|
||||
|
||||
|
||||
// Source patch
|
||||
|
||||
//- Source face areas
|
||||
@ -109,10 +134,6 @@ class AMIInterpolation
|
||||
//- Sum of weights of target faces per source face
|
||||
scalarField srcWeightsSum_;
|
||||
|
||||
//- Labels of faces that are not overlapped by any target faces
|
||||
// (should be empty for correct functioning)
|
||||
labelList srcNonOverlap_;
|
||||
|
||||
|
||||
// Target patch
|
||||
|
||||
@ -129,9 +150,6 @@ class AMIInterpolation
|
||||
scalarField tgtWeightsSum_;
|
||||
|
||||
|
||||
//- Octree used to find face seeds
|
||||
autoPtr<indexedOctree<treeType> > treePtr_;
|
||||
|
||||
//- Face triangulation mode
|
||||
const faceAreaIntersect::triangulationMode triMode_;
|
||||
|
||||
@ -151,30 +169,6 @@ class AMIInterpolation
|
||||
void operator=(const AMIInterpolation&);
|
||||
|
||||
|
||||
// Helper functions
|
||||
|
||||
//- Write triangle intersection to OBJ file
|
||||
void writeIntersectionOBJ
|
||||
(
|
||||
const scalar area,
|
||||
const face& f1,
|
||||
const face& f2,
|
||||
const pointField& f1Points,
|
||||
const pointField& f2Points
|
||||
) const;
|
||||
|
||||
//- Check that patches are valid
|
||||
void checkPatches
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch
|
||||
) const;
|
||||
|
||||
//- Reset the octree for the traget patch face search
|
||||
void resetTree(const TargetPatch& tgtPatch);
|
||||
|
||||
|
||||
|
||||
// Parallel functionality
|
||||
|
||||
//- Calculate if patches are on multiple processors
|
||||
@ -228,83 +222,8 @@ class AMIInterpolation
|
||||
) const;
|
||||
|
||||
|
||||
// Marching front
|
||||
|
||||
//- Find face on target patch that overlaps source face
|
||||
label findTargetFace
|
||||
(
|
||||
const label srcFaceI,
|
||||
const SourcePatch& srcPatch
|
||||
) const;
|
||||
|
||||
//- Add faces neighbouring faceI to the ID list
|
||||
void appendNbrFaces
|
||||
(
|
||||
const label faceI,
|
||||
const TargetPatch& patch,
|
||||
const DynamicList<label>& visitedFaces,
|
||||
DynamicList<label>& faceIDs
|
||||
) const;
|
||||
|
||||
bool processSourceFace
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const label srcFaceI,
|
||||
const label tgtStartFaceI,
|
||||
|
||||
DynamicList<label>& nbrFaces,
|
||||
DynamicList<label>& visitedFaces,
|
||||
List<DynamicList<label> >& srcAddr,
|
||||
List<DynamicList<scalar> >& srcWght,
|
||||
List<DynamicList<label> >& tgtAddr,
|
||||
List<DynamicList<scalar> >& tgtWght
|
||||
);
|
||||
|
||||
void restartUncoveredSourceFace
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
List<DynamicList<label> >& srcAddr,
|
||||
List<DynamicList<scalar> >& srcWght,
|
||||
List<DynamicList<label> >& tgtAddr,
|
||||
List<DynamicList<scalar> >& tgtWght
|
||||
);
|
||||
|
||||
//- Set the source and target seed faces
|
||||
void setNextFaces
|
||||
(
|
||||
label& startSeedI,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI,
|
||||
const SourcePatch& srcPatch0,
|
||||
const TargetPatch& tgtPatch0,
|
||||
const boolList& mapFlag,
|
||||
labelList& seedFaces,
|
||||
const DynamicList<label>& visitedFaces
|
||||
) const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Area of intersection between source and target faces
|
||||
scalar interArea
|
||||
(
|
||||
const label srcFaceI,
|
||||
const label tgtFaceI,
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch
|
||||
) const;
|
||||
|
||||
//- Calculate addressing
|
||||
void calcAddressing
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
label srcFaceI = -1,
|
||||
label tgtFaceI = -1
|
||||
);
|
||||
|
||||
//- Normalise the (area) weights - suppresses numerical error in
|
||||
// weights calculation
|
||||
// NOTE: if area weights are incorrect by 'a significant amount'
|
||||
@ -351,6 +270,7 @@ public:
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const interpolationMethod& method = imFaceAreaWeight,
|
||||
const bool reverseTarget = false
|
||||
);
|
||||
|
||||
@ -361,6 +281,7 @@ public:
|
||||
const TargetPatch& tgtPatch,
|
||||
const autoPtr<searchableSurface>& surf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const interpolationMethod& method = imFaceAreaWeight,
|
||||
const bool reverseTarget = false
|
||||
);
|
||||
|
||||
@ -377,6 +298,12 @@ public:
|
||||
//- Destructor
|
||||
~AMIInterpolation();
|
||||
|
||||
// Typedef to SourcePatch type this AMIInterplation is instantiated on
|
||||
typedef SourcePatch sourcePatchType;
|
||||
|
||||
// Typedef to TargetPatch type this AMIInterplation is instantiated on
|
||||
typedef TargetPatch targetPatchType;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -402,10 +329,6 @@ public:
|
||||
// patch weights (i.e. the sum before normalisation)
|
||||
inline const scalarField& srcWeightsSum() const;
|
||||
|
||||
//- Labels of faces that are not overlapped by any target faces
|
||||
// (should be empty for correct functioning)
|
||||
inline const labelList& srcNonOverlap() const;
|
||||
|
||||
//- Source map pointer - valid only if singlePatchProc = -1
|
||||
// This gets source data into a form to be consumed by
|
||||
// tgtAddress, tgtWeights
|
||||
@ -468,7 +391,7 @@ public:
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate from target to source with supplied binary op
|
||||
//- Interpolate from target to source with supplied op
|
||||
template<class Type, class CombineOp>
|
||||
tmp<Field<Type> > interpolateToSource
|
||||
(
|
||||
@ -476,8 +399,7 @@ public:
|
||||
const CombineOp& cop
|
||||
) const;
|
||||
|
||||
//- Interpolate from target tmp field to source with supplied
|
||||
// binary op
|
||||
//- Interpolate from target tmp field to source with supplied op
|
||||
template<class Type, class CombineOp>
|
||||
tmp<Field<Type> > interpolateToSource
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -55,14 +55,6 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeights() const
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
inline const Foam::labelList&
|
||||
Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcNonOverlap() const
|
||||
{
|
||||
return srcNonOverlap_;
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
inline const Foam::scalarField&
|
||||
Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeightsSum() const
|
||||
|
||||
@ -0,0 +1,339 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "AMIMethod.H"
|
||||
#include "meshTools.H"
|
||||
#include "mapDistribute.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::AMIMethod<SourcePatch, TargetPatch>::checkPatches() const
|
||||
{
|
||||
if (debug && (!srcPatch_.size() || !tgtPatch_.size()))
|
||||
{
|
||||
Pout<< "AMI: Patches not on processor: Source faces = "
|
||||
<< srcPatch_.size() << ", target faces = " << tgtPatch_.size()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
const scalar maxBoundsError = 0.05;
|
||||
|
||||
// check bounds of source and target
|
||||
boundBox bbSrc(srcPatch_.points(), srcPatch_.meshPoints(), true);
|
||||
boundBox bbTgt(tgtPatch_.points(), tgtPatch_.meshPoints(), true);
|
||||
|
||||
boundBox bbTgtInf(bbTgt);
|
||||
bbTgtInf.inflate(maxBoundsError);
|
||||
|
||||
if (!bbTgtInf.contains(bbSrc))
|
||||
{
|
||||
WarningIn("AMIMethod<SourcePatch, TargetPatch>::checkPatches()")
|
||||
<< "Source and target patch bounding boxes are not similar" << nl
|
||||
<< " source box span : " << bbSrc.span() << nl
|
||||
<< " target box span : " << bbTgt.span() << nl
|
||||
<< " source box : " << bbSrc << nl
|
||||
<< " target box : " << bbTgt << nl
|
||||
<< " inflated target box : " << bbTgtInf << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
bool Foam::AMIMethod<SourcePatch, TargetPatch>::initialise
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
)
|
||||
{
|
||||
// set initial sizes for weights and addressing - must be done even if
|
||||
// returns false below
|
||||
srcAddress.setSize(srcPatch_.size());
|
||||
srcWeights.setSize(srcPatch_.size());
|
||||
tgtAddress.setSize(tgtPatch_.size());
|
||||
tgtWeights.setSize(tgtPatch_.size());
|
||||
|
||||
// check that patch sizes are valid
|
||||
if (!srcPatch_.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!tgtPatch_.size())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::AMIMethod<SourcePatch, TargetPatch>::initialise"
|
||||
"("
|
||||
"label&, "
|
||||
"label&"
|
||||
")"
|
||||
)
|
||||
<< srcPatch_.size() << " source faces but no target faces" << endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// reset the octree
|
||||
resetTree();
|
||||
|
||||
// find initial face match using brute force/octree search
|
||||
if ((srcFaceI == -1) || (tgtFaceI == -1))
|
||||
{
|
||||
srcFaceI = 0;
|
||||
tgtFaceI = 0;
|
||||
bool foundFace = false;
|
||||
forAll(srcPatch_, faceI)
|
||||
{
|
||||
tgtFaceI = findTargetFace(faceI);
|
||||
if (tgtFaceI >= 0)
|
||||
{
|
||||
srcFaceI = faceI;
|
||||
foundFace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundFace)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"void Foam::AMIMethod<SourcePatch, TargetPatch>::initialise"
|
||||
"("
|
||||
"label&, "
|
||||
"label&"
|
||||
")"
|
||||
) << "Unable to find initial target face" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "AMI: initial target face = " << tgtFaceI << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::AMIMethod<SourcePatch, TargetPatch>::writeIntersectionOBJ
|
||||
(
|
||||
const scalar area,
|
||||
const face& f1,
|
||||
const face& f2,
|
||||
const pointField& f1Points,
|
||||
const pointField& f2Points
|
||||
) const
|
||||
{
|
||||
static label count = 1;
|
||||
|
||||
const pointField f1pts = f1.points(f1Points);
|
||||
const pointField f2pts = f2.points(f2Points);
|
||||
|
||||
Pout<< "Face intersection area (" << count << "):" << nl
|
||||
<< " f1 face = " << f1 << nl
|
||||
<< " f1 pts = " << f1pts << nl
|
||||
<< " f2 face = " << f2 << nl
|
||||
<< " f2 pts = " << f2pts << nl
|
||||
<< " area = " << area
|
||||
<< endl;
|
||||
|
||||
OFstream os("areas" + name(count) + ".obj");
|
||||
|
||||
forAll(f1pts, i)
|
||||
{
|
||||
meshTools::writeOBJ(os, f1pts[i]);
|
||||
}
|
||||
os<< "l";
|
||||
forAll(f1pts, i)
|
||||
{
|
||||
os<< " " << i + 1;
|
||||
}
|
||||
os<< " 1" << endl;
|
||||
|
||||
|
||||
forAll(f2pts, i)
|
||||
{
|
||||
meshTools::writeOBJ(os, f2pts[i]);
|
||||
}
|
||||
os<< "l";
|
||||
forAll(f2pts, i)
|
||||
{
|
||||
os<< " " << f1pts.size() + i + 1;
|
||||
}
|
||||
os<< " " << f1pts.size() + 1 << endl;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::AMIMethod<SourcePatch, TargetPatch>::resetTree()
|
||||
{
|
||||
// Clear the old octree
|
||||
treePtr_.clear();
|
||||
|
||||
treeBoundBox bb(tgtPatch_.points());
|
||||
bb.inflate(0.01);
|
||||
|
||||
if (!treePtr_.valid())
|
||||
{
|
||||
treePtr_.reset
|
||||
(
|
||||
new indexedOctree<treeType>
|
||||
(
|
||||
treeType(false, tgtPatch_),
|
||||
bb, // overall search domain
|
||||
8, // maxLevel
|
||||
10, // leaf size
|
||||
3.0 // duplicity
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::label Foam::AMIMethod<SourcePatch, TargetPatch>::findTargetFace
|
||||
(
|
||||
const label srcFaceI
|
||||
) const
|
||||
{
|
||||
label targetFaceI = -1;
|
||||
|
||||
const pointField& srcPts = srcPatch_.points();
|
||||
const face& srcFace = srcPatch_[srcFaceI];
|
||||
const point srcPt = srcFace.centre(srcPts);
|
||||
const scalar srcFaceArea = srcMagSf_[srcFaceI];
|
||||
|
||||
pointIndexHit sample = treePtr_->findNearest(srcPt, 10.0*srcFaceArea);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Source point = " << srcPt << ", Sample point = "
|
||||
<< sample.hitPoint() << ", Sample index = " << sample.index()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (sample.hit())
|
||||
{
|
||||
targetFaceI = sample.index();
|
||||
}
|
||||
|
||||
return targetFaceI;
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::AMIMethod<SourcePatch, TargetPatch>::appendNbrFaces
|
||||
(
|
||||
const label faceI,
|
||||
const TargetPatch& patch,
|
||||
const DynamicList<label>& visitedFaces,
|
||||
DynamicList<label>& faceIDs
|
||||
) const
|
||||
{
|
||||
const labelList& nbrFaces = patch.faceFaces()[faceI];
|
||||
|
||||
// filter out faces already visited from src face neighbours
|
||||
forAll(nbrFaces, i)
|
||||
{
|
||||
label nbrFaceI = nbrFaces[i];
|
||||
bool valid = true;
|
||||
forAll(visitedFaces, j)
|
||||
{
|
||||
if (nbrFaceI == visitedFaces[j])
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
forAll(faceIDs, j)
|
||||
{
|
||||
if (nbrFaceI == faceIDs[j])
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
faceIDs.append(nbrFaceI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::AMIMethod<SourcePatch, TargetPatch>::AMIMethod
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
)
|
||||
:
|
||||
srcPatch_(srcPatch),
|
||||
tgtPatch_(tgtPatch),
|
||||
reverseTarget_(reverseTarget),
|
||||
srcMagSf_(srcMagSf),
|
||||
tgtMagSf_(tgtMagSf),
|
||||
srcNonOverlap_(),
|
||||
triMode_(triMode)
|
||||
{
|
||||
checkPatches();
|
||||
|
||||
label srcSize = returnReduce(srcPatch_.size(), sumOp<label>());
|
||||
label tgtSize = returnReduce(tgtPatch_.size(), sumOp<label>());
|
||||
|
||||
IInfo<< "AMI: Creating addressing and weights between "
|
||||
<< srcSize << " source faces and " << tgtSize << " target faces"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::AMIMethod<SourcePatch, TargetPatch>::~AMIMethod()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,268 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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::AMIMethod
|
||||
|
||||
Description
|
||||
Base class for Arbitrary Mesh Interface (AMI) methods
|
||||
|
||||
SourceFiles
|
||||
AMIMethod.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef AMIMethod_H
|
||||
#define AMIMethod_H
|
||||
|
||||
#include "className.H"
|
||||
#include "DynamicList.H"
|
||||
#include "faceAreaIntersect.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "treeDataPrimitivePatch.H"
|
||||
#include "treeBoundBoxList.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AMIMethod Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
class AMIMethod
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
AMIMethod(const AMIMethod&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const AMIMethod&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//- local typedef to octree tree-type
|
||||
typedef treeDataPrimitivePatch<TargetPatch> treeType;
|
||||
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to source patch
|
||||
const SourcePatch& srcPatch_;
|
||||
|
||||
//- Reference to target patch
|
||||
const SourcePatch& tgtPatch_;
|
||||
|
||||
//- Flag to indicate that the two patches are co-directional and
|
||||
// that the orientation of the target patch should be reversed
|
||||
const bool reverseTarget_;
|
||||
|
||||
//- Source face areas
|
||||
const scalarField& srcMagSf_;
|
||||
|
||||
//- Target face areas
|
||||
const scalarField& tgtMagSf_;
|
||||
|
||||
//- Labels of faces that are not overlapped by any target faces
|
||||
// (should be empty for correct functioning)
|
||||
labelList srcNonOverlap_;
|
||||
|
||||
//- Octree used to find face seeds
|
||||
autoPtr<indexedOctree<treeType> > treePtr_;
|
||||
|
||||
//- Face triangulation mode
|
||||
const faceAreaIntersect::triangulationMode triMode_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
// Helper functions
|
||||
|
||||
//- Check AMI patch coupling
|
||||
void checkPatches() const;
|
||||
|
||||
//- Initialise and return true if all ok
|
||||
bool initialise
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
);
|
||||
|
||||
//- Write triangle intersection to OBJ file
|
||||
void writeIntersectionOBJ
|
||||
(
|
||||
const scalar area,
|
||||
const face& f1,
|
||||
const face& f2,
|
||||
const pointField& f1Points,
|
||||
const pointField& f2Points
|
||||
) const;
|
||||
|
||||
|
||||
// Common AMI method functions
|
||||
|
||||
//- Reset the octree for the target patch face search
|
||||
void resetTree();
|
||||
|
||||
//- Find face on target patch that overlaps source face
|
||||
label findTargetFace(const label srcFaceI) const;
|
||||
|
||||
//- Add faces neighbouring faceI to the ID list
|
||||
void appendNbrFaces
|
||||
(
|
||||
const label faceI,
|
||||
const TargetPatch& patch,
|
||||
const DynamicList<label>& visitedFaces,
|
||||
DynamicList<label>& faceIDs
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("AMIMethod");
|
||||
|
||||
//- Declare runtime constructor selection table
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
AMIMethod,
|
||||
components,
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
),
|
||||
(srcPatch, tgtPatch, srcMagSf, tgtMagSf, triMode, reverseTarget)
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
AMIMethod
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
);
|
||||
|
||||
//- Selector
|
||||
static autoPtr<AMIMethod> New
|
||||
(
|
||||
const word& methodName,
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~AMIMethod();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Labels of faces that are not overlapped by any target faces
|
||||
// Note: this should be empty for correct functioning
|
||||
inline const labelList& srcNonOverlap() const;
|
||||
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Update addressing and weights
|
||||
virtual void calculate
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label srcFaceI = -1,
|
||||
label tgtFaceI = -1
|
||||
) = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define makeAMIMethod(AMIType) \
|
||||
\
|
||||
typedef AMIMethod<AMIType::sourcePatchType,AMIType::targetPatchType> \
|
||||
AMIMethod##AMIType; \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(AMIMethod##AMIType, 0); \
|
||||
defineTemplateRunTimeSelectionTable(AMIMethod##AMIType, components);
|
||||
|
||||
|
||||
#define makeAMIMethodType(AMIType, Method) \
|
||||
\
|
||||
typedef Method<AMIType::sourcePatchType,AMIType::targetPatchType> \
|
||||
Method##AMIType; \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(Method##AMIType, 0); \
|
||||
\
|
||||
AMIMethod<AMIType::sourcePatchType,AMIType::targetPatchType>:: \
|
||||
addcomponentsConstructorToTable<Method##AMIType> \
|
||||
add##Method##AMIType##ConstructorToTable_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "AMIMethodI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "AMIMethod.C"
|
||||
# include "AMIMethodNew.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
inline const Foam::labelList&
|
||||
Foam::AMIMethod<SourcePatch, TargetPatch>::srcNonOverlap() const
|
||||
{
|
||||
return srcNonOverlap_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::autoPtr<Foam::AMIMethod<SourcePatch, TargetPatch> >
|
||||
Foam::AMIMethod<SourcePatch, TargetPatch>::New
|
||||
(
|
||||
const word& methodName,
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Selecting AMIMethod " << methodName << endl;
|
||||
}
|
||||
|
||||
typename componentsConstructorTable::iterator cstrIter =
|
||||
componentsConstructorTablePtr_->find(methodName);
|
||||
|
||||
if (cstrIter == componentsConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"AMIMethod<SourcePatch, TargetPatch>::New"
|
||||
"("
|
||||
"const word&, "
|
||||
"const SourcePatch&, "
|
||||
"const TargetPatch&, "
|
||||
"const scalarField&, "
|
||||
"const scalarField&, "
|
||||
"const faceAreaIntersect::triangulationMode&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "Unknown AMIMethod type "
|
||||
<< methodName << nl << nl
|
||||
<< "Valid AMIMethod types are:" << nl
|
||||
<< componentsConstructorTablePtr_->sortedToc() << exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<AMIMethod<SourcePatch, TargetPatch> >
|
||||
(
|
||||
cstrIter()
|
||||
(
|
||||
srcPatch,
|
||||
tgtPatch,
|
||||
srcMagSf,
|
||||
tgtMagSf,
|
||||
triMode,
|
||||
reverseTarget
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,224 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "directAMI.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::directAMI<SourcePatch, TargetPatch>::appendToDirectSeeds
|
||||
(
|
||||
boolList& mapFlag,
|
||||
labelList& srcTgtSeed,
|
||||
DynamicList<label>& srcSeeds,
|
||||
DynamicList<label>& nonOverlapFaces,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
) const
|
||||
{
|
||||
const labelList& srcNbr = this->srcPatch_.faceFaces()[srcFaceI];
|
||||
const labelList& tgtNbr = this->tgtPatch_.faceFaces()[tgtFaceI];
|
||||
|
||||
const pointField& srcPoints = this->srcPatch_.points();
|
||||
const pointField& tgtPoints = this->tgtPatch_.points();
|
||||
|
||||
const vectorField& srcCf = this->srcPatch_.faceCentres();
|
||||
|
||||
forAll(srcNbr, i)
|
||||
{
|
||||
label srcI = srcNbr[i];
|
||||
|
||||
if (mapFlag[srcI] && srcTgtSeed[srcI] == -1)
|
||||
{
|
||||
const face& srcF = this->srcPatch_[srcI];
|
||||
const vector srcN = srcF.normal(srcPoints);
|
||||
|
||||
bool found = false;
|
||||
forAll(tgtNbr, j)
|
||||
{
|
||||
label tgtI = tgtNbr[j];
|
||||
const face& tgtF = this->tgtPatch_[tgtI];
|
||||
pointHit ray = tgtF.ray(srcCf[srcI], srcN, tgtPoints);
|
||||
|
||||
if (ray.hit())
|
||||
{
|
||||
// new match - append to lists
|
||||
found = true;
|
||||
|
||||
srcTgtSeed[srcI] = tgtI;
|
||||
srcSeeds.append(srcI);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
// no match available for source face srcI
|
||||
mapFlag[srcI] = false;
|
||||
nonOverlapFaces.append(srcI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (srcSeeds.size())
|
||||
{
|
||||
srcFaceI = srcSeeds.remove();
|
||||
tgtFaceI = srcTgtSeed[srcFaceI];
|
||||
}
|
||||
else
|
||||
{
|
||||
srcFaceI = -1;
|
||||
tgtFaceI = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::directAMI<SourcePatch, TargetPatch>::directAMI
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
)
|
||||
:
|
||||
AMIMethod<SourcePatch, TargetPatch>
|
||||
(
|
||||
srcPatch,
|
||||
tgtPatch,
|
||||
srcMagSf,
|
||||
tgtMagSf,
|
||||
triMode,
|
||||
reverseTarget
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::directAMI<SourcePatch, TargetPatch>::~directAMI()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::directAMI<SourcePatch, TargetPatch>::calculate
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label srcFaceI,
|
||||
label tgtFaceI
|
||||
)
|
||||
{
|
||||
bool ok =
|
||||
this->initialise
|
||||
(
|
||||
srcAddress,
|
||||
srcWeights,
|
||||
tgtAddress,
|
||||
tgtWeights,
|
||||
srcFaceI,
|
||||
tgtFaceI
|
||||
);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// temporary storage for addressing and weights
|
||||
List<DynamicList<label> > srcAddr(this->srcPatch_.size());
|
||||
List<DynamicList<label> > tgtAddr(this->tgtPatch_.size());
|
||||
|
||||
|
||||
// construct weights and addressing
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// list of faces currently visited for srcFaceI to avoid multiple hits
|
||||
DynamicList<label> srcSeeds(10);
|
||||
|
||||
// list to keep track of tgt faces used to seed src faces
|
||||
labelList srcTgtSeed(srcAddr.size(), -1);
|
||||
srcTgtSeed[srcFaceI] = tgtFaceI;
|
||||
|
||||
// list to keep track of whether src face can be mapped
|
||||
boolList mapFlag(srcAddr.size(), true);
|
||||
|
||||
DynamicList<label> nonOverlapFaces;
|
||||
do
|
||||
{
|
||||
srcAddr[srcFaceI].append(tgtFaceI);
|
||||
tgtAddr[tgtFaceI].append(srcFaceI);
|
||||
|
||||
mapFlag[srcFaceI] = false;
|
||||
|
||||
// Do advancing front starting from srcFaceI, tgtFaceI
|
||||
appendToDirectSeeds
|
||||
(
|
||||
mapFlag,
|
||||
srcTgtSeed,
|
||||
srcSeeds,
|
||||
nonOverlapFaces,
|
||||
srcFaceI,
|
||||
tgtFaceI
|
||||
);
|
||||
} while (srcFaceI >= 0);
|
||||
|
||||
if (nonOverlapFaces.size() != 0)
|
||||
{
|
||||
Pout<< " AMI: " << nonOverlapFaces.size()
|
||||
<< " non-overlap faces identified"
|
||||
<< endl;
|
||||
|
||||
this->srcNonOverlap_.transfer(nonOverlapFaces);
|
||||
}
|
||||
|
||||
// transfer data to persistent storage
|
||||
forAll(srcAddr, i)
|
||||
{
|
||||
scalar magSf = this->srcMagSf_[i];
|
||||
srcAddress[i].transfer(srcAddr[i]);
|
||||
srcWeights[i] = scalarList(1, magSf);
|
||||
}
|
||||
forAll(tgtAddr, i)
|
||||
{
|
||||
scalar magSf = this->tgtMagSf_[i];
|
||||
tgtAddress[i].transfer(tgtAddr[i]);
|
||||
tgtWeights[i] = scalarList(1, magSf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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::directAMI
|
||||
|
||||
Description
|
||||
Direct mapped Arbitrary Mesh Interface (AMI) method
|
||||
|
||||
SourceFiles
|
||||
directAMI.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef directAMI_H
|
||||
#define directAMI_H
|
||||
|
||||
#include "AMIMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class directAMI Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
class directAMI
|
||||
:
|
||||
public AMIMethod<SourcePatch, TargetPatch>
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
directAMI(const directAMI&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const directAMI&);
|
||||
|
||||
// Marching front
|
||||
|
||||
//- Append to list of src face seed indices
|
||||
void appendToDirectSeeds
|
||||
(
|
||||
boolList& mapFlag,
|
||||
labelList& srcTgtSeed,
|
||||
DynamicList<label>& srcSeeds,
|
||||
DynamicList<label>& nonOverlapFaces,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
) const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Area of intersection between source and target faces
|
||||
scalar interArea
|
||||
(
|
||||
const label srcFaceI,
|
||||
const label tgtFaceI
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("directAMI");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
directAMI
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~directAMI();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Update addressing and weights
|
||||
virtual void calculate
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label srcFaceI = -1,
|
||||
label tgtFaceI = -1
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "directAMI.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,553 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "faceAreaWeightAMI.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
bool Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::processSourceFace
|
||||
(
|
||||
const label srcFaceI,
|
||||
const label tgtStartFaceI,
|
||||
|
||||
// list of tgt face neighbour faces
|
||||
DynamicList<label>& nbrFaces,
|
||||
// list of faces currently visited for srcFaceI to avoid multiple hits
|
||||
DynamicList<label>& visitedFaces,
|
||||
|
||||
// temporary storage for addressing and weights
|
||||
List<DynamicList<label> >& srcAddr,
|
||||
List<DynamicList<scalar> >& srcWght,
|
||||
List<DynamicList<label> >& tgtAddr,
|
||||
List<DynamicList<scalar> >& tgtWght
|
||||
)
|
||||
{
|
||||
nbrFaces.clear();
|
||||
visitedFaces.clear();
|
||||
|
||||
// append initial target face and neighbours
|
||||
nbrFaces.append(tgtStartFaceI);
|
||||
this->appendNbrFaces
|
||||
(
|
||||
tgtStartFaceI,
|
||||
this->tgtPatch_,
|
||||
visitedFaces,
|
||||
nbrFaces
|
||||
);
|
||||
|
||||
bool faceProcessed = false;
|
||||
|
||||
do
|
||||
{
|
||||
// process new target face
|
||||
label tgtFaceI = nbrFaces.remove();
|
||||
visitedFaces.append(tgtFaceI);
|
||||
scalar area = interArea(srcFaceI, tgtFaceI);
|
||||
|
||||
// store when intersection area > 0
|
||||
if (area > 0)
|
||||
{
|
||||
srcAddr[srcFaceI].append(tgtFaceI);
|
||||
srcWght[srcFaceI].append(area);
|
||||
|
||||
tgtAddr[tgtFaceI].append(srcFaceI);
|
||||
tgtWght[tgtFaceI].append(area);
|
||||
|
||||
this->appendNbrFaces
|
||||
(
|
||||
tgtFaceI,
|
||||
this->tgtPatch_,
|
||||
visitedFaces,
|
||||
nbrFaces
|
||||
);
|
||||
|
||||
faceProcessed = true;
|
||||
}
|
||||
|
||||
} while (nbrFaces.size() > 0);
|
||||
|
||||
return faceProcessed;
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::setNextFaces
|
||||
(
|
||||
label& startSeedI,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI,
|
||||
const boolList& mapFlag,
|
||||
labelList& seedFaces,
|
||||
const DynamicList<label>& visitedFaces
|
||||
) const
|
||||
{
|
||||
const labelList& srcNbrFaces = this->srcPatch_.faceFaces()[srcFaceI];
|
||||
|
||||
// set possible seeds for later use
|
||||
bool valuesSet = false;
|
||||
forAll(srcNbrFaces, i)
|
||||
{
|
||||
label faceS = srcNbrFaces[i];
|
||||
|
||||
if (mapFlag[faceS] && seedFaces[faceS] == -1)
|
||||
{
|
||||
forAll(visitedFaces, j)
|
||||
{
|
||||
label faceT = visitedFaces[j];
|
||||
scalar area = interArea(faceS, faceT);
|
||||
scalar areaTotal = this->srcMagSf_[srcFaceI];
|
||||
|
||||
// Check that faces have enough overlap for robust walking
|
||||
if (area/areaTotal > faceAreaIntersect::tolerance())
|
||||
{
|
||||
// TODO - throwing area away - re-use in next iteration?
|
||||
|
||||
seedFaces[faceS] = faceT;
|
||||
|
||||
if (!valuesSet)
|
||||
{
|
||||
srcFaceI = faceS;
|
||||
tgtFaceI = faceT;
|
||||
valuesSet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set next src and tgt faces if not set above
|
||||
if (valuesSet)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// try to use existing seed
|
||||
bool foundNextSeed = false;
|
||||
for (label faceI = startSeedI; faceI < mapFlag.size(); faceI++)
|
||||
{
|
||||
if (mapFlag[faceI])
|
||||
{
|
||||
if (!foundNextSeed)
|
||||
{
|
||||
startSeedI = faceI;
|
||||
foundNextSeed = true;
|
||||
}
|
||||
|
||||
if (seedFaces[faceI] != -1)
|
||||
{
|
||||
srcFaceI = faceI;
|
||||
tgtFaceI = seedFaces[faceI];
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// perform new search to find match
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Advancing front stalled: searching for new "
|
||||
<< "target face" << endl;
|
||||
}
|
||||
|
||||
foundNextSeed = false;
|
||||
for (label faceI = startSeedI; faceI < mapFlag.size(); faceI++)
|
||||
{
|
||||
if (mapFlag[faceI])
|
||||
{
|
||||
if (!foundNextSeed)
|
||||
{
|
||||
startSeedI = faceI + 1;
|
||||
foundNextSeed = true;
|
||||
}
|
||||
|
||||
srcFaceI = faceI;
|
||||
tgtFaceI = this->findTargetFace(srcFaceI);
|
||||
|
||||
if (tgtFaceI >= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FatalErrorIn
|
||||
(
|
||||
"void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::"
|
||||
"setNextFaces"
|
||||
"("
|
||||
"label&, "
|
||||
"label&, "
|
||||
"label&, "
|
||||
"const boolList&, "
|
||||
"labelList&, "
|
||||
"const DynamicList<label>&"
|
||||
") const"
|
||||
) << "Unable to set source and target faces" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea
|
||||
(
|
||||
const label srcFaceI,
|
||||
const label tgtFaceI
|
||||
) const
|
||||
{
|
||||
const pointField& srcPoints = this->srcPatch_.points();
|
||||
const pointField& tgtPoints = this->tgtPatch_.points();
|
||||
|
||||
// references to candidate faces
|
||||
const face& src = this->srcPatch_[srcFaceI];
|
||||
const face& tgt = this->tgtPatch_[tgtFaceI];
|
||||
|
||||
// quick reject if either face has zero area
|
||||
// Note: do not used stored face areas for target patch
|
||||
if
|
||||
(
|
||||
(this->srcMagSf_[srcFaceI] < ROOTVSMALL)
|
||||
|| (tgt.mag(tgtPoints) < ROOTVSMALL)
|
||||
)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// create intersection object
|
||||
faceAreaIntersect inter(srcPoints, tgtPoints, this->reverseTarget_);
|
||||
|
||||
// crude resultant norm
|
||||
vector n(-src.normal(srcPoints));
|
||||
if (this->reverseTarget_)
|
||||
{
|
||||
n -= tgt.normal(tgtPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
n += tgt.normal(tgtPoints);
|
||||
}
|
||||
n *= 0.5;
|
||||
|
||||
scalar area = 0;
|
||||
if (mag(n) > ROOTVSMALL)
|
||||
{
|
||||
area = inter.calc(src, tgt, n, this->triMode_);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::"
|
||||
"interArea"
|
||||
"("
|
||||
"const label, "
|
||||
"const label"
|
||||
") const"
|
||||
) << "Invalid normal for source face " << srcFaceI
|
||||
<< " points " << UIndirectList<point>(srcPoints, src)
|
||||
<< " target face " << tgtFaceI
|
||||
<< " points " << UIndirectList<point>(tgtPoints, tgt)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
if ((debug > 1) && (area > 0))
|
||||
{
|
||||
this->writeIntersectionOBJ(area, src, tgt, srcPoints, tgtPoints);
|
||||
}
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::
|
||||
restartUncoveredSourceFace
|
||||
(
|
||||
List<DynamicList<label> >& srcAddr,
|
||||
List<DynamicList<scalar> >& srcWght,
|
||||
List<DynamicList<label> >& tgtAddr,
|
||||
List<DynamicList<scalar> >& tgtWght
|
||||
)
|
||||
{
|
||||
// Collect all src faces with a low weight
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
labelHashSet lowWeightFaces(100);
|
||||
forAll(srcWght, srcFaceI)
|
||||
{
|
||||
scalar s = sum(srcWght[srcFaceI]);
|
||||
scalar t = s/this->srcMagSf_[srcFaceI];
|
||||
|
||||
if (t < 0.5)
|
||||
{
|
||||
lowWeightFaces.insert(srcFaceI);
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "faceAreaWeightAMI: restarting search on "
|
||||
<< lowWeightFaces.size() << " faces since sum of weights < 0.5"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (lowWeightFaces.size() > 0)
|
||||
{
|
||||
// Erase all the lowWeight source faces from the target
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
DynamicList<label> okSrcFaces(10);
|
||||
DynamicList<scalar> okSrcWeights(10);
|
||||
forAll(tgtAddr, tgtFaceI)
|
||||
{
|
||||
okSrcFaces.clear();
|
||||
okSrcWeights.clear();
|
||||
DynamicList<label>& srcFaces = tgtAddr[tgtFaceI];
|
||||
DynamicList<scalar>& srcWeights = tgtWght[tgtFaceI];
|
||||
forAll(srcFaces, i)
|
||||
{
|
||||
if (!lowWeightFaces.found(srcFaces[i]))
|
||||
{
|
||||
okSrcFaces.append(srcFaces[i]);
|
||||
okSrcWeights.append(srcWeights[i]);
|
||||
}
|
||||
}
|
||||
if (okSrcFaces.size() < srcFaces.size())
|
||||
{
|
||||
srcFaces.transfer(okSrcFaces);
|
||||
srcWeights.transfer(okSrcWeights);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Restart search from best hit
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// list of tgt face neighbour faces
|
||||
DynamicList<label> nbrFaces(10);
|
||||
|
||||
// list of faces currently visited for srcFaceI to avoid multiple hits
|
||||
DynamicList<label> visitedFaces(10);
|
||||
|
||||
forAllConstIter(labelHashSet, lowWeightFaces, iter)
|
||||
{
|
||||
label srcFaceI = iter.key();
|
||||
label tgtFaceI = this->findTargetFace(srcFaceI);
|
||||
if (tgtFaceI != -1)
|
||||
{
|
||||
//bool faceProcessed =
|
||||
processSourceFace
|
||||
(
|
||||
srcFaceI,
|
||||
tgtFaceI,
|
||||
|
||||
nbrFaces,
|
||||
visitedFaces,
|
||||
|
||||
srcAddr,
|
||||
srcWght,
|
||||
tgtAddr,
|
||||
tgtWght
|
||||
);
|
||||
// ? Check faceProcessed to see if restarting has worked.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::faceAreaWeightAMI
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
)
|
||||
:
|
||||
AMIMethod<SourcePatch, TargetPatch>
|
||||
(
|
||||
srcPatch,
|
||||
tgtPatch,
|
||||
srcMagSf,
|
||||
tgtMagSf,
|
||||
triMode,
|
||||
reverseTarget
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::~faceAreaWeightAMI()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::calculate
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label srcFaceI,
|
||||
label tgtFaceI
|
||||
)
|
||||
{
|
||||
bool ok =
|
||||
this->initialise
|
||||
(
|
||||
srcAddress,
|
||||
srcWeights,
|
||||
tgtAddress,
|
||||
tgtWeights,
|
||||
srcFaceI,
|
||||
tgtFaceI
|
||||
);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// temporary storage for addressing and weights
|
||||
List<DynamicList<label> > srcAddr(this->srcPatch_.size());
|
||||
List<DynamicList<scalar> > srcWght(srcAddr.size());
|
||||
List<DynamicList<label> > tgtAddr(this->tgtPatch_.size());
|
||||
List<DynamicList<scalar> > tgtWght(tgtAddr.size());
|
||||
|
||||
|
||||
// construct weights and addressing
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
label nFacesRemaining = srcAddr.size();
|
||||
|
||||
// list of tgt face neighbour faces
|
||||
DynamicList<label> nbrFaces(10);
|
||||
|
||||
// list of faces currently visited for srcFaceI to avoid multiple hits
|
||||
DynamicList<label> visitedFaces(10);
|
||||
|
||||
// list to keep track of tgt faces used to seed src faces
|
||||
labelList seedFaces(nFacesRemaining, -1);
|
||||
seedFaces[srcFaceI] = tgtFaceI;
|
||||
|
||||
// list to keep track of whether src face can be mapped
|
||||
boolList mapFlag(nFacesRemaining, true);
|
||||
|
||||
// reset starting seed
|
||||
label startSeedI = 0;
|
||||
|
||||
DynamicList<label> nonOverlapFaces;
|
||||
do
|
||||
{
|
||||
// Do advancing front starting from srcFaceI,tgtFaceI
|
||||
bool faceProcessed = processSourceFace
|
||||
(
|
||||
srcFaceI,
|
||||
tgtFaceI,
|
||||
|
||||
nbrFaces,
|
||||
visitedFaces,
|
||||
|
||||
srcAddr,
|
||||
srcWght,
|
||||
tgtAddr,
|
||||
tgtWght
|
||||
);
|
||||
|
||||
mapFlag[srcFaceI] = false;
|
||||
|
||||
nFacesRemaining--;
|
||||
|
||||
if (!faceProcessed)
|
||||
{
|
||||
nonOverlapFaces.append(srcFaceI);
|
||||
}
|
||||
|
||||
// choose new src face from current src face neighbour
|
||||
if (nFacesRemaining > 0)
|
||||
{
|
||||
setNextFaces
|
||||
(
|
||||
startSeedI,
|
||||
srcFaceI,
|
||||
tgtFaceI,
|
||||
mapFlag,
|
||||
seedFaces,
|
||||
visitedFaces
|
||||
);
|
||||
}
|
||||
} while (nFacesRemaining > 0);
|
||||
|
||||
if (nonOverlapFaces.size() != 0)
|
||||
{
|
||||
Pout<< " AMI: " << nonOverlapFaces.size()
|
||||
<< " non-overlap faces identified"
|
||||
<< endl;
|
||||
|
||||
this->srcNonOverlap_.transfer(nonOverlapFaces);
|
||||
}
|
||||
|
||||
|
||||
// Check for badly covered faces
|
||||
if (debug)
|
||||
{
|
||||
restartUncoveredSourceFace
|
||||
(
|
||||
srcAddr,
|
||||
srcWght,
|
||||
tgtAddr,
|
||||
tgtWght
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// transfer data to persistent storage
|
||||
forAll(srcAddr, i)
|
||||
{
|
||||
srcAddress[i].transfer(srcAddr[i]);
|
||||
srcWeights[i].transfer(srcWght[i]);
|
||||
}
|
||||
forAll(tgtAddr, i)
|
||||
{
|
||||
tgtAddress[i].transfer(tgtAddr[i]);
|
||||
tgtWeights[i].transfer(tgtWght[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,166 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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::faceAreaWeightAMI
|
||||
|
||||
Description
|
||||
Face area weighted Arbitrary Mesh Interface (AMI) method
|
||||
|
||||
SourceFiles
|
||||
faceAreaWeightAMI.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faceAreaWeightAMI_H
|
||||
#define faceAreaWeightAMI_H
|
||||
|
||||
#include "AMIMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faceAreaWeightAMI Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
class faceAreaWeightAMI
|
||||
:
|
||||
public AMIMethod<SourcePatch, TargetPatch>
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
faceAreaWeightAMI(const faceAreaWeightAMI&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const faceAreaWeightAMI&);
|
||||
|
||||
// Marching front
|
||||
|
||||
//- Determine overlap contributions for source face srcFaceI
|
||||
bool processSourceFace
|
||||
(
|
||||
const label srcFaceI,
|
||||
const label tgtStartFaceI,
|
||||
DynamicList<label>& nbrFaces,
|
||||
DynamicList<label>& visitedFaces,
|
||||
List<DynamicList<label> >& srcAddr,
|
||||
List<DynamicList<scalar> >& srcWght,
|
||||
List<DynamicList<label> >& tgtAddr,
|
||||
List<DynamicList<scalar> >& tgtWght
|
||||
);
|
||||
|
||||
//- Attempt to re-evaluate source faces that have not been included
|
||||
void restartUncoveredSourceFace
|
||||
(
|
||||
List<DynamicList<label> >& srcAddr,
|
||||
List<DynamicList<scalar> >& srcWght,
|
||||
List<DynamicList<label> >& tgtAddr,
|
||||
List<DynamicList<scalar> >& tgtWght
|
||||
);
|
||||
|
||||
//- Set the source and target seed faces
|
||||
void setNextFaces
|
||||
(
|
||||
label& startSeedI,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI,
|
||||
const boolList& mapFlag,
|
||||
labelList& seedFaces,
|
||||
const DynamicList<label>& visitedFaces
|
||||
) const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Area of intersection between source and target faces
|
||||
scalar interArea
|
||||
(
|
||||
const label srcFaceI,
|
||||
const label tgtFaceI
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faceAreaWeightAMI");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
faceAreaWeightAMI
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~faceAreaWeightAMI();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Update addressing and weights
|
||||
virtual void calculate
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label srcFaceI = -1,
|
||||
label tgtFaceI = -1
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "faceAreaWeightAMI.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,343 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "mapNearestAMI.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::mapNearestAMI<SourcePatch, TargetPatch>::findNearestFace
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
) const
|
||||
{
|
||||
const vectorField& srcCf = srcPatch.faceCentres();
|
||||
const vectorField& tgtCf = tgtPatch.faceCentres();
|
||||
|
||||
const vector srcP = srcCf[srcFaceI];
|
||||
|
||||
DynamicList<label> tgtFaces(10);
|
||||
tgtFaces.append(tgtFaceI);
|
||||
|
||||
DynamicList<label> visitedFaces(10);
|
||||
|
||||
scalar d = GREAT;
|
||||
|
||||
do
|
||||
{
|
||||
label tgtI = tgtFaces.remove();
|
||||
visitedFaces.append(tgtI);
|
||||
|
||||
scalar dTest = magSqr(tgtCf[tgtI] - srcP);
|
||||
if (dTest < d)
|
||||
{
|
||||
tgtFaceI = tgtI;
|
||||
d = dTest;
|
||||
|
||||
this->appendNbrFaces
|
||||
(
|
||||
tgtFaceI,
|
||||
tgtPatch,
|
||||
visitedFaces,
|
||||
tgtFaces
|
||||
);
|
||||
}
|
||||
|
||||
} while (tgtFaces.size() > 0);
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::mapNearestAMI<SourcePatch, TargetPatch>::setNextNearestFaces
|
||||
(
|
||||
boolList& mapFlag,
|
||||
label& startSeedI,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
) const
|
||||
{
|
||||
const labelList& srcNbr = this->srcPatch_.faceFaces()[srcFaceI];
|
||||
|
||||
srcFaceI = -1;
|
||||
|
||||
forAll(srcNbr, i)
|
||||
{
|
||||
label faceI = srcNbr[i];
|
||||
if (mapFlag[faceI])
|
||||
{
|
||||
srcFaceI = faceI;
|
||||
startSeedI = faceI + 1;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
forAll(mapFlag, srcFaceI)
|
||||
{
|
||||
if (!mapFlag[srcFaceI])
|
||||
{
|
||||
tgtFaceI = this->findTargetFace(srcFaceI);
|
||||
if (tgtFaceI == -1)
|
||||
{
|
||||
const vectorField& srcCf = this->srcPatch_.faceCentres();
|
||||
|
||||
FatalErrorIn
|
||||
(
|
||||
"void Foam::mapNearestAMI<SourcePatch, TargetPatch>::"
|
||||
"setNextNearestFaces"
|
||||
"("
|
||||
"boolList&, "
|
||||
"label&, "
|
||||
"label&, "
|
||||
"label&"
|
||||
") const"
|
||||
)
|
||||
<< "Unable to find target face for source face "
|
||||
<< srcFaceI << " with face centre " << srcCf[srcFaceI]
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::label Foam::mapNearestAMI<SourcePatch, TargetPatch>::findMappedSrcFace
|
||||
(
|
||||
const label tgtFaceI,
|
||||
const List<DynamicList<label> >& tgtToSrc
|
||||
) const
|
||||
{
|
||||
DynamicList<label> testFaces(10);
|
||||
DynamicList<label> visitedFaces(10);
|
||||
|
||||
testFaces.append(tgtFaceI);
|
||||
|
||||
do
|
||||
{
|
||||
// search target tgtFaceI neighbours for match with source face
|
||||
label tgtI = testFaces.remove();
|
||||
|
||||
if (findIndex(visitedFaces, tgtI) == -1)
|
||||
{
|
||||
visitedFaces.append(tgtI);
|
||||
|
||||
if (tgtToSrc[tgtI].size())
|
||||
{
|
||||
return tgtToSrc[tgtI][0];
|
||||
}
|
||||
else
|
||||
{
|
||||
const labelList& nbrFaces = this->tgtPatch_.faceFaces()[tgtI];
|
||||
|
||||
forAll(nbrFaces, i)
|
||||
{
|
||||
if (findIndex(visitedFaces, nbrFaces[i]) == -1)
|
||||
{
|
||||
testFaces.append(nbrFaces[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (testFaces.size());
|
||||
|
||||
// did not find any match - should not be possible to get here!
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::mapNearestAMI<SourcePatch, TargetPatch>::mapNearestAMI
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget
|
||||
)
|
||||
:
|
||||
AMIMethod<SourcePatch, TargetPatch>
|
||||
(
|
||||
srcPatch,
|
||||
tgtPatch,
|
||||
srcMagSf,
|
||||
tgtMagSf,
|
||||
triMode,
|
||||
reverseTarget
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
Foam::mapNearestAMI<SourcePatch, TargetPatch>::~mapNearestAMI()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
void Foam::mapNearestAMI<SourcePatch, TargetPatch>::calculate
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label srcFaceI,
|
||||
label tgtFaceI
|
||||
)
|
||||
{
|
||||
bool ok =
|
||||
this->initialise
|
||||
(
|
||||
srcAddress,
|
||||
srcWeights,
|
||||
tgtAddress,
|
||||
tgtWeights,
|
||||
srcFaceI,
|
||||
tgtFaceI
|
||||
);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// temporary storage for addressing and weights
|
||||
List<DynamicList<label> > srcAddr(this->srcPatch_.size());
|
||||
List<DynamicList<label> > tgtAddr(this->tgtPatch_.size());
|
||||
|
||||
|
||||
// construct weights and addressing
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// list to keep track of whether src face can be mapped
|
||||
boolList mapFlag(srcAddr.size(), true);
|
||||
|
||||
// reset starting seed
|
||||
label startSeedI = 0;
|
||||
|
||||
DynamicList<label> nonOverlapFaces;
|
||||
do
|
||||
{
|
||||
findNearestFace(this->srcPatch_, this->tgtPatch_, srcFaceI, tgtFaceI);
|
||||
|
||||
srcAddr[srcFaceI].append(tgtFaceI);
|
||||
tgtAddr[tgtFaceI].append(srcFaceI);
|
||||
|
||||
mapFlag[srcFaceI] = false;
|
||||
|
||||
// Do advancing front starting from srcFaceI, tgtFaceI
|
||||
setNextNearestFaces
|
||||
(
|
||||
mapFlag,
|
||||
startSeedI,
|
||||
srcFaceI,
|
||||
tgtFaceI
|
||||
);
|
||||
} while (srcFaceI >= 0);
|
||||
|
||||
|
||||
// for the case of multiple source faces per target face, select the
|
||||
// nearest source face only and discard the others
|
||||
const vectorField& srcCf = this->srcPatch_.faceCentres();
|
||||
const vectorField& tgtCf = this->tgtPatch_.faceCentres();
|
||||
|
||||
forAll(tgtAddr, targetFaceI)
|
||||
{
|
||||
if (tgtAddr[targetFaceI].size() > 1)
|
||||
{
|
||||
const vector& tgtC = tgtCf[tgtFaceI];
|
||||
|
||||
DynamicList<label>& srcFaces = tgtAddr[targetFaceI];
|
||||
|
||||
label srcFaceI = srcFaces[0];
|
||||
scalar d = magSqr(tgtC - srcCf[srcFaceI]);
|
||||
|
||||
for (label i = 1; i < srcFaces.size(); i++)
|
||||
{
|
||||
label srcI = srcFaces[i];
|
||||
scalar dNew = magSqr(tgtC - srcCf[srcI]);
|
||||
if (dNew < d)
|
||||
{
|
||||
d = dNew;
|
||||
srcFaceI = srcI;
|
||||
}
|
||||
}
|
||||
|
||||
srcFaces.clear();
|
||||
srcFaces.append(srcFaceI);
|
||||
}
|
||||
}
|
||||
|
||||
// If there are more target faces than source faces, some target faces
|
||||
// might not yet be mapped
|
||||
forAll(tgtAddr, tgtFaceI)
|
||||
{
|
||||
if (tgtAddr[tgtFaceI].empty())
|
||||
{
|
||||
label srcFaceI = findMappedSrcFace(tgtFaceI, tgtAddr);
|
||||
|
||||
// note - reversed search from src->tgt to tgt->src
|
||||
findNearestFace
|
||||
(
|
||||
this->tgtPatch_,
|
||||
this->srcPatch_,
|
||||
tgtFaceI,
|
||||
srcFaceI
|
||||
);
|
||||
|
||||
tgtAddr[tgtFaceI].append(srcFaceI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// transfer data to persistent storage
|
||||
forAll(srcAddr, i)
|
||||
{
|
||||
scalar magSf = this->srcMagSf_[i];
|
||||
srcAddress[i].transfer(srcAddr[i]);
|
||||
srcWeights[i] = scalarList(1, magSf);
|
||||
}
|
||||
forAll(tgtAddr, i)
|
||||
{
|
||||
scalar magSf = this->tgtMagSf_[i];
|
||||
tgtAddress[i].transfer(tgtAddr[i]);
|
||||
tgtWeights[i] = scalarList(1, magSf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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::mapNearestAMI
|
||||
|
||||
Description
|
||||
Nearest-mapping Arbitrary Mesh Interface (AMI) method
|
||||
|
||||
SourceFiles
|
||||
mapNearestAMI.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef mapNearestAMI_H
|
||||
#define mapNearestAMI_H
|
||||
|
||||
#include "AMIMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class mapNearestAMI Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class SourcePatch, class TargetPatch>
|
||||
class mapNearestAMI
|
||||
:
|
||||
public AMIMethod<SourcePatch, TargetPatch>
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
mapNearestAMI(const mapNearestAMI&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const mapNearestAMI&);
|
||||
|
||||
// Marching front
|
||||
|
||||
//- Find nearest target face for source face srcFaceI
|
||||
void findNearestFace
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
) const;
|
||||
|
||||
//- Determine next source-target face pair
|
||||
void setNextNearestFaces
|
||||
(
|
||||
boolList& mapFlag,
|
||||
label& startSeedI,
|
||||
label& srcFaceI,
|
||||
label& tgtFaceI
|
||||
) const;
|
||||
|
||||
//- Find mapped source face
|
||||
label findMappedSrcFace
|
||||
(
|
||||
const label tgtFaceI,
|
||||
const List<DynamicList<label> >& tgtToSrc
|
||||
) const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Area of intersection between source and target faces
|
||||
scalar interArea
|
||||
(
|
||||
const label srcFaceI,
|
||||
const label tgtFaceI
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("mapNearestAMI");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
mapNearestAMI
|
||||
(
|
||||
const SourcePatch& srcPatch,
|
||||
const TargetPatch& tgtPatch,
|
||||
const scalarField& srcMagSf,
|
||||
const scalarField& tgtMagSf,
|
||||
const faceAreaIntersect::triangulationMode& triMode,
|
||||
const bool reverseTarget = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~mapNearestAMI();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Update addressing and weights
|
||||
virtual void calculate
|
||||
(
|
||||
labelListList& srcAddress,
|
||||
scalarListList& srcWeights,
|
||||
labelListList& tgtAddress,
|
||||
scalarListList& tgtWeights,
|
||||
label srcFaceI = -1,
|
||||
label tgtFaceI = -1
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "mapNearestAMI.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "AMIPatchToPatchInterpolation.H"
|
||||
#include "AMIMethod.H"
|
||||
#include "directAMI.H"
|
||||
#include "mapNearestAMI.H"
|
||||
#include "faceAreaWeightAMI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeAMIMethod(AMIPatchToPatchInterpolation);
|
||||
|
||||
makeAMIMethodType(AMIPatchToPatchInterpolation, directAMI);
|
||||
makeAMIMethodType(AMIPatchToPatchInterpolation, mapNearestAMI);
|
||||
makeAMIMethodType(AMIPatchToPatchInterpolation, faceAreaWeightAMI);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,19 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<faceAreaIntersect::triangulationMode, 2>::names[] =
|
||||
{
|
||||
"fan",
|
||||
"mesh"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::faceAreaIntersect::triangulationMode, 2>
|
||||
Foam::faceAreaIntersect::triangulationModeNames_;
|
||||
|
||||
Foam::scalar Foam::faceAreaIntersect::tol = 1e-6;
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -41,6 +41,7 @@ SourceFiles
|
||||
#include "FixedList.H"
|
||||
#include "plane.H"
|
||||
#include "face.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -63,6 +64,8 @@ public:
|
||||
tmMesh
|
||||
};
|
||||
|
||||
static const NamedEnum<triangulationMode, 2> triangulationModeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -239,7 +239,11 @@ void Foam::cyclicAMIPolyPatch::resetAMI() const
|
||||
AMIPtr_.clear();
|
||||
|
||||
const polyPatch& nbr = neighbPatch();
|
||||
pointField nbrPoints = neighbPatch().localPoints();
|
||||
pointField nbrPoints
|
||||
(
|
||||
neighbPatch().boundaryMesh().mesh().points(),
|
||||
neighbPatch().meshPoints()
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -279,6 +283,7 @@ void Foam::cyclicAMIPolyPatch::resetAMI() const
|
||||
nbrPatch0,
|
||||
surfPtr(),
|
||||
faceAreaIntersect::tmMesh,
|
||||
AMIPatchToPatchInterpolation::imFaceAreaWeight,
|
||||
AMIReverse_
|
||||
)
|
||||
);
|
||||
@ -326,6 +331,9 @@ void Foam::cyclicAMIPolyPatch::initMovePoints
|
||||
)
|
||||
{
|
||||
polyPatch::initMovePoints(pBufs, p);
|
||||
|
||||
// See below. Clear out any local geometry
|
||||
primitivePatch::movePoints(p);
|
||||
}
|
||||
|
||||
|
||||
@ -339,6 +347,10 @@ void Foam::cyclicAMIPolyPatch::movePoints
|
||||
|
||||
calcTransforms();
|
||||
|
||||
// Note: resetAMI is called whilst in geometry update. So the slave
|
||||
// side might not have reached 'movePoints'. Is explicitly handled by
|
||||
// - clearing geometry of neighbour inside initMovePoints
|
||||
// - not using localPoints() inside resetAMI
|
||||
resetAMI();
|
||||
}
|
||||
|
||||
|
||||
@ -14,12 +14,13 @@ $(csys)/coordinateSystem.C
|
||||
$(csys)/coordinateSystemNew.C
|
||||
$(csys)/coordinateSystems.C
|
||||
$(csys)/cylindricalCS.C
|
||||
$(csys)/sphericalCS.C
|
||||
$(csys)/parabolicCylindricalCS.C
|
||||
$(csys)/toroidalCS.C
|
||||
$(csys)/cartesianCS.C
|
||||
$(csys)/coordinateRotation/axesRotation.C
|
||||
$(csys)/coordinateRotation/coordinateRotation.C
|
||||
$(csys)/coordinateRotation/coordinateRotationNew.C
|
||||
$(csys)/coordinateRotation/EulerCoordinateRotation.C
|
||||
$(csys)/coordinateRotation/STARCDCoordinateRotation.C
|
||||
$(csys)/coordinateRotation/localAxesRotation.C
|
||||
|
||||
edgeFaceCirculator/edgeFaceCirculator.C
|
||||
|
||||
@ -128,6 +129,7 @@ faceZoneSources = sets/faceZoneSources
|
||||
$(faceZoneSources)/faceZoneToFaceZone/faceZoneToFaceZone.C
|
||||
$(faceZoneSources)/setsToFaceZone/setsToFaceZone.C
|
||||
$(faceZoneSources)/setToFaceZone/setToFaceZone.C
|
||||
$(faceZoneSources)/setAndNormalToFaceZone/setAndNormalToFaceZone.C
|
||||
$(faceZoneSources)/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C
|
||||
|
||||
cellZoneSources = sets/cellZoneSources
|
||||
@ -168,6 +170,7 @@ twoDPointCorrector/twoDPointCorrector.C
|
||||
|
||||
AMI=AMIInterpolation
|
||||
$(AMI)/AMIInterpolation/AMIInterpolationName.C
|
||||
$(AMI)/AMIInterpolation/AMIPatchToPatchInterpolation.C
|
||||
$(AMI)/faceAreaIntersect/faceAreaIntersect.C
|
||||
$(AMI)/GAMG/interfaces/cyclicAMIGAMGInterface/cyclicAMIGAMGInterface.C
|
||||
$(AMI)/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C
|
||||
@ -187,6 +190,9 @@ mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C
|
||||
mappedPatches/mappedPointPatch/mappedPointPatch.C
|
||||
mappedPatches/mappedPointPatch/mappedWallPointPatch.C
|
||||
|
||||
meshStructure/meshStructure.C
|
||||
meshStructure/topoDistanceData.C
|
||||
meshStructure/pointTopoDistanceData.C
|
||||
|
||||
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C
|
||||
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledPolyPatch.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -38,13 +38,13 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
const Foam::scalar Foam::FaceCellWave<Type, TrackingData>::geomTol_ = 1e-6;
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::scalar Foam::FaceCellWave<Type, TrackingData>::propagationTol_ = 0.01;
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
int Foam::FaceCellWave<Type, TrackingData>::dummyTrackData_ = 12345;
|
||||
|
||||
namespace Foam
|
||||
@ -111,7 +111,7 @@ namespace Foam
|
||||
// Updates:
|
||||
// - changedCell_, changedCells_, nChangedCells_,
|
||||
// - statistics: nEvals_, nUnvisitedCells_
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::updateCell
|
||||
(
|
||||
const label cellI,
|
||||
@ -159,7 +159,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateCell
|
||||
// Updates:
|
||||
// - changedFace_, changedFaces_, nChangedFaces_,
|
||||
// - statistics: nEvals_, nUnvisitedFaces_
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
||||
(
|
||||
const label faceI,
|
||||
@ -207,7 +207,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
||||
// Updates:
|
||||
// - changedFace_, changedFaces_, nChangedFaces_,
|
||||
// - statistics: nEvals_, nUnvisitedFaces_
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
||||
(
|
||||
const label faceI,
|
||||
@ -249,7 +249,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
||||
|
||||
|
||||
// For debugging: check status on both sides of cyclic
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::checkCyclic
|
||||
(
|
||||
const polyPatch& patch
|
||||
@ -302,8 +302,8 @@ void Foam::FaceCellWave<Type, TrackingData>::checkCyclic
|
||||
|
||||
|
||||
// Check if has cyclic patches
|
||||
template <class Type, class TrackingData>
|
||||
template <class PatchType>
|
||||
template<class Type, class TrackingData>
|
||||
template<class PatchType>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::hasPatch() const
|
||||
{
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
@ -318,7 +318,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::hasPatch() const
|
||||
|
||||
|
||||
// Copy face information into member data
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
|
||||
(
|
||||
const labelList& changedFaces,
|
||||
@ -349,7 +349,7 @@ void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
|
||||
|
||||
|
||||
// Merge face information into member data
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::mergeFaceInfo
|
||||
(
|
||||
const polyPatch& patch,
|
||||
@ -384,7 +384,7 @@ void Foam::FaceCellWave<Type, TrackingData>::mergeFaceInfo
|
||||
// Construct compact patchFace change arrays for a (slice of a) single patch.
|
||||
// changedPatchFaces in local patch numbering.
|
||||
// Return length of arrays.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getChangedPatchFaces
|
||||
(
|
||||
const polyPatch& patch,
|
||||
@ -414,7 +414,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::getChangedPatchFaces
|
||||
|
||||
|
||||
// Handle leaving domain. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
@ -436,7 +436,7 @@ void Foam::FaceCellWave<Type, TrackingData>::leaveDomain
|
||||
|
||||
|
||||
// Handle entering domain. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
@ -458,7 +458,7 @@ void Foam::FaceCellWave<Type, TrackingData>::enterDomain
|
||||
|
||||
|
||||
// Transform. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::transform
|
||||
(
|
||||
const tensorField& rotTensor,
|
||||
@ -486,7 +486,7 @@ void Foam::FaceCellWave<Type, TrackingData>::transform
|
||||
|
||||
|
||||
// Offset mesh face. Used for transferring from one cyclic half to the other.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::offset
|
||||
(
|
||||
const polyPatch&,
|
||||
@ -503,7 +503,7 @@ void Foam::FaceCellWave<Type, TrackingData>::offset
|
||||
|
||||
|
||||
// Tranfer all the information to/from neighbouring processors
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
|
||||
{
|
||||
const globalMeshData& pData = mesh_.globalData();
|
||||
@ -622,7 +622,7 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
|
||||
|
||||
|
||||
// Transfer information across cyclic halves.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
|
||||
{
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
@ -707,7 +707,7 @@ void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
|
||||
|
||||
|
||||
// Transfer information across cyclic halves.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
|
||||
{
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
@ -800,7 +800,7 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Set up only. Use setFaceInfo and iterate() to do actual calculation.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -852,7 +852,7 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
||||
|
||||
// Iterate, propagating changedFacesInfo across mesh, until no change (or
|
||||
// maxIter reached). Initial cell values specified.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -929,14 +929,14 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getUnsetCells() const
|
||||
{
|
||||
return nUnvisitedCells_;
|
||||
}
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getUnsetFaces() const
|
||||
{
|
||||
return nUnvisitedFaces_;
|
||||
@ -945,7 +945,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::getUnsetFaces() const
|
||||
|
||||
|
||||
// Propagate cell to face
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
|
||||
{
|
||||
const labelList& owner = mesh_.faceOwner();
|
||||
@ -1030,7 +1030,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
|
||||
|
||||
|
||||
// Propagate cell to face
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
||||
{
|
||||
const cellList& cells = mesh_.cells();
|
||||
@ -1112,7 +1112,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
||||
|
||||
|
||||
// Iterate
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
|
||||
{
|
||||
if (hasCyclicPatches_)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -166,7 +166,7 @@ class FaceCellWave
|
||||
void checkCyclic(const polyPatch& pPatch) const;
|
||||
|
||||
//- Has cyclic patch?
|
||||
template <class PatchType>
|
||||
template<class PatchType>
|
||||
bool hasPatch() const;
|
||||
|
||||
//- Merge received patch data into global data
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
int Foam::MeshWave<Type, TrackingData>::dummyTrackData_ = 12345;
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ int Foam::MeshWave<Type, TrackingData>::dummyTrackData_ = 12345;
|
||||
|
||||
// Iterate, propagating changedFacesInfo across mesh, until no change (or
|
||||
// maxIter reached).
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::MeshWave<Type, TrackingData>::MeshWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -64,7 +64,7 @@ Foam::MeshWave<Type, TrackingData>::MeshWave
|
||||
|
||||
// Iterate, propagating changedFacesInfo across mesh, until no change (or
|
||||
// maxIter reached). Initial cell values specified.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::MeshWave<Type, TrackingData>::MeshWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -53,7 +53,7 @@ TemplateName(MeshWave);
|
||||
Class MeshWave Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Type, class TrackingData = int>
|
||||
template<class Type, class TrackingData = int>
|
||||
class MeshWave
|
||||
:
|
||||
public MeshWaveName
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -234,7 +234,7 @@ inline bool Foam::patchEdgeFaceInfo::updateFace
|
||||
}
|
||||
|
||||
|
||||
template <class TrackingData>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::patchEdgeFaceInfo::equal
|
||||
(
|
||||
const patchEdgeFaceInfo& rhs,
|
||||
|
||||
@ -37,10 +37,10 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::scalar Foam::PointEdgeWave<Type, TrackingData>::propagationTol_ = 0.01;
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
int Foam::PointEdgeWave<Type, TrackingData>::dummyTrackData_ = 12345;
|
||||
|
||||
namespace Foam
|
||||
@ -71,7 +71,7 @@ namespace Foam
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Handle leaving domain. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::PointEdgeWave<Type, TrackingData>::leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
@ -93,7 +93,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::leaveDomain
|
||||
|
||||
|
||||
// Handle entering domain. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::PointEdgeWave<Type, TrackingData>::enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
@ -115,7 +115,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::enterDomain
|
||||
|
||||
|
||||
// Transform. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::PointEdgeWave<Type, TrackingData>::transform
|
||||
(
|
||||
const polyPatch& patch,
|
||||
@ -156,7 +156,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::transform
|
||||
// Updates:
|
||||
// - changedPoint_, changedPoints_, nChangedPoints_,
|
||||
// - statistics: nEvals_, nUnvisitedPoints_
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
|
||||
(
|
||||
const label pointI,
|
||||
@ -203,7 +203,7 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
|
||||
// Updates:
|
||||
// - changedPoint_, changedPoints_, nChangedPoints_,
|
||||
// - statistics: nEvals_, nUnvisitedPoints_
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
|
||||
(
|
||||
const label pointI,
|
||||
@ -248,7 +248,7 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
|
||||
// Updates:
|
||||
// - changedEdge_, changedEdges_, nChangedEdges_,
|
||||
// - statistics: nEvals_, nUnvisitedEdge_
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
bool Foam::PointEdgeWave<Type, TrackingData>::updateEdge
|
||||
(
|
||||
const label edgeI,
|
||||
@ -291,8 +291,8 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updateEdge
|
||||
|
||||
|
||||
// Check if patches of given type name are present
|
||||
template <class Type, class TrackingData>
|
||||
template <class PatchType>
|
||||
template<class Type, class TrackingData>
|
||||
template<class PatchType>
|
||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::countPatchType() const
|
||||
{
|
||||
label nPatches = 0;
|
||||
@ -309,7 +309,7 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::countPatchType() const
|
||||
|
||||
|
||||
// Transfer all the information to/from neighbouring processors
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
|
||||
{
|
||||
// 1. Send all point info on processor patches.
|
||||
@ -458,7 +458,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
|
||||
}
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
|
||||
{
|
||||
// 1. Send all point info on cyclic patches.
|
||||
@ -549,7 +549,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
|
||||
|
||||
// Guarantee collocated points have same information.
|
||||
// Return number of points changed.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
|
||||
{
|
||||
// Transfer onto coupled patch
|
||||
@ -643,7 +643,7 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
|
||||
|
||||
// Iterate, propagating changedPointsInfo across mesh, until no change (or
|
||||
// maxIter reached). Initial point values specified.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -728,7 +728,7 @@ Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
|
||||
}
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -756,7 +756,7 @@ Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::PointEdgeWave<Type, TrackingData>::~PointEdgeWave()
|
||||
{}
|
||||
|
||||
@ -764,14 +764,14 @@ Foam::PointEdgeWave<Type, TrackingData>::~PointEdgeWave()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::getUnsetPoints() const
|
||||
{
|
||||
return nUnvisitedPoints_;
|
||||
}
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::getUnsetEdges() const
|
||||
{
|
||||
return nUnvisitedEdges_;
|
||||
@ -779,7 +779,7 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::getUnsetEdges() const
|
||||
|
||||
|
||||
// Copy point information into member data
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
|
||||
(
|
||||
const labelList& changedPoints,
|
||||
@ -816,7 +816,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
|
||||
|
||||
|
||||
// Propagate information from edge to point. Return number of points changed.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
|
||||
{
|
||||
for
|
||||
@ -892,7 +892,7 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
|
||||
|
||||
|
||||
// Propagate information from point to edge. Return number of edges changed.
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::pointToEdge()
|
||||
{
|
||||
const labelListList& pointEdges = mesh_.pointEdges();
|
||||
@ -960,7 +960,7 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::pointToEdge()
|
||||
|
||||
|
||||
// Iterate
|
||||
template <class Type, class TrackingData>
|
||||
template<class Type, class TrackingData>
|
||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
|
||||
(
|
||||
const label maxIter
|
||||
|
||||
@ -82,7 +82,7 @@ TemplateName(PointEdgeWave);
|
||||
Class PointEdgeWave Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Type, class TrackingData = int>
|
||||
template<class Type, class TrackingData = int>
|
||||
class PointEdgeWave
|
||||
:
|
||||
public PointEdgeWaveName
|
||||
@ -196,7 +196,7 @@ class PointEdgeWave
|
||||
// Parallel, cyclic
|
||||
|
||||
//- Has patches of certain type?
|
||||
template <class PatchType>
|
||||
template<class PatchType>
|
||||
label countPatchType() const;
|
||||
|
||||
//- Merge data from across processor boundaries
|
||||
@ -323,7 +323,7 @@ public:
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- List update operation
|
||||
template <class Type, class TrackingData = int>
|
||||
template<class Type, class TrackingData = int>
|
||||
class listUpdateOp
|
||||
{
|
||||
//- Additional data to be passed into container
|
||||
|
||||
@ -296,7 +296,7 @@ inline bool Foam::pointEdgePoint::updateEdge
|
||||
}
|
||||
|
||||
|
||||
template <class TrackingData>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointEdgePoint::equal
|
||||
(
|
||||
const pointEdgePoint& rhs,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -244,7 +244,7 @@ inline bool Foam::cellInfo::updateFace
|
||||
}
|
||||
|
||||
|
||||
template <class TrackingData>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::cellInfo::equal
|
||||
(
|
||||
const cellInfo& rhs,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,7 +32,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
@ -45,7 +45,7 @@ Ostream& operator<<
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
Istream& operator>>
|
||||
(
|
||||
Istream& is,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,7 +58,7 @@ template<class Type> Ostream& operator<<(Ostream&, const wallPointData<Type>&);
|
||||
Class wallPointData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
class wallPointData
|
||||
:
|
||||
public wallPoint
|
||||
@ -163,37 +163,37 @@ public:
|
||||
//- Data associated with wallPointData type are contiguous. List the usual
|
||||
// ones.
|
||||
|
||||
template <>
|
||||
template<>
|
||||
inline bool contiguous<wallPointData<bool> >()
|
||||
{
|
||||
return contiguous<wallPoint>();
|
||||
}
|
||||
template <>
|
||||
template<>
|
||||
inline bool contiguous<wallPointData<label> >()
|
||||
{
|
||||
return contiguous<wallPoint>();
|
||||
}
|
||||
template <>
|
||||
template<>
|
||||
inline bool contiguous<wallPointData<scalar> >()
|
||||
{
|
||||
return contiguous<wallPoint>();
|
||||
}
|
||||
template <>
|
||||
template<>
|
||||
inline bool contiguous<wallPointData<vector> >()
|
||||
{
|
||||
return contiguous<wallPoint>();
|
||||
}
|
||||
template <>
|
||||
template<>
|
||||
inline bool contiguous<wallPointData<sphericalTensor> >()
|
||||
{
|
||||
return contiguous<wallPoint>();
|
||||
}
|
||||
template <>
|
||||
template<>
|
||||
inline bool contiguous<wallPointData<symmTensor> >()
|
||||
{
|
||||
return contiguous<wallPoint>();
|
||||
}
|
||||
template <>
|
||||
template<>
|
||||
inline bool contiguous<wallPointData<tensor> >()
|
||||
{
|
||||
return contiguous<wallPoint>();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,8 +31,8 @@ namespace Foam
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template <class Type>
|
||||
template <class TrackingData>
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool wallPointData<Type>::update
|
||||
(
|
||||
const point& pt,
|
||||
@ -75,7 +75,7 @@ inline bool wallPointData<Type>::update
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
inline wallPointData<Type>::wallPointData()
|
||||
:
|
||||
wallPoint(),
|
||||
@ -84,7 +84,7 @@ inline wallPointData<Type>::wallPointData()
|
||||
|
||||
|
||||
// Construct from components
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
inline wallPointData<Type>::wallPointData
|
||||
(
|
||||
const point& origin,
|
||||
@ -99,14 +99,14 @@ inline wallPointData<Type>::wallPointData
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
inline const Type& wallPointData<Type>::data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
inline Type& wallPointData<Type>::data()
|
||||
{
|
||||
return data_;
|
||||
@ -114,8 +114,8 @@ inline Type& wallPointData<Type>::data()
|
||||
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template <class Type>
|
||||
template <class TrackingData>
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool wallPointData<Type>::updateCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -139,8 +139,8 @@ inline bool wallPointData<Type>::updateCell
|
||||
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template <class Type>
|
||||
template <class TrackingData>
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool wallPointData<Type>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -164,8 +164,8 @@ inline bool wallPointData<Type>::updateFace
|
||||
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
template <class Type>
|
||||
template <class TrackingData>
|
||||
template<class Type>
|
||||
template<class TrackingData>
|
||||
inline bool wallPointData<Type>::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -277,7 +277,7 @@ inline bool Foam::wallPoint::updateFace
|
||||
}
|
||||
|
||||
|
||||
template <class TrackingData>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::wallPoint::equal
|
||||
(
|
||||
const wallPoint& rhs,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,7 +21,6 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cellQuality.H"
|
||||
|
||||
162
src/meshTools/coordinateSystems/cartesianCS.C
Normal file
162
src/meshTools/coordinateSystems/cartesianCS.C
Normal file
@ -0,0 +1,162 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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 "cartesianCS.H"
|
||||
|
||||
#include "one.H"
|
||||
#include "mathematicalConstants.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cartesianCS, 0);
|
||||
addToRunTimeSelectionTable(coordinateSystem, cartesianCS, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cartesianCS::cartesianCS()
|
||||
:
|
||||
coordinateSystem()
|
||||
{}
|
||||
|
||||
|
||||
Foam::cartesianCS::cartesianCS
|
||||
(
|
||||
const coordinateSystem& cs
|
||||
)
|
||||
:
|
||||
coordinateSystem(cs)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cartesianCS::cartesianCS
|
||||
(
|
||||
const word& name,
|
||||
const coordinateSystem& cs
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, cs)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cartesianCS::cartesianCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation& cr
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, origin, cr)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cartesianCS::cartesianCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const vector& axis,
|
||||
const vector& dirn
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, origin, axis, dirn)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cartesianCS::cartesianCS
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, dict)
|
||||
{}
|
||||
|
||||
|
||||
Foam::cartesianCS::cartesianCS
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateSystem(obr, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cartesianCS::~cartesianCS()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
Foam::vector Foam::cartesianCS::localToGlobal
|
||||
(
|
||||
const vector& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
return coordinateSystem::localToGlobal(local, translate);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::cartesianCS::localToGlobal
|
||||
(
|
||||
const vectorField& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
return coordinateSystem::localToGlobal(local, translate);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::cartesianCS::globalToLocal
|
||||
(
|
||||
const vector& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
return coordinateSystem::globalToLocal(global, translate);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::cartesianCS::globalToLocal
|
||||
(
|
||||
const vectorField& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
return coordinateSystem::globalToLocal(global, translate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,20 +22,21 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sphericalCS
|
||||
Foam::cartesianCS
|
||||
|
||||
Description
|
||||
Spherical coordinate system
|
||||
Cylindrical coordinate system
|
||||
|
||||
SourceFiles
|
||||
sphericalCS.C
|
||||
cartesianCS.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sphericalCS_H
|
||||
#define sphericalCS_H
|
||||
#ifndef cartesianCS_H
|
||||
#define cartesianCS_H
|
||||
|
||||
#include "coordinateSystem.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,23 +44,18 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sphericalCS Declaration
|
||||
Class cartesianCS Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sphericalCS
|
||||
class cartesianCS
|
||||
:
|
||||
public coordinateSystem
|
||||
{
|
||||
// Private data members
|
||||
|
||||
//- Are angles in degrees? (default = true)
|
||||
bool inDegrees_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
virtual vector localToGlobal(const vector&, bool translate) const;
|
||||
@ -88,61 +84,58 @@ protected:
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("spherical");
|
||||
TypeName("cartesian");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
sphericalCS(const bool inDegrees=true);
|
||||
cartesianCS();
|
||||
|
||||
//- Construct copy
|
||||
sphericalCS
|
||||
cartesianCS
|
||||
(
|
||||
const coordinateSystem&,
|
||||
const bool inDegrees=true
|
||||
const coordinateSystem&
|
||||
);
|
||||
|
||||
//- Construct copy with a different name
|
||||
sphericalCS
|
||||
cartesianCS
|
||||
(
|
||||
const word& name,
|
||||
const coordinateSystem&,
|
||||
const bool inDegrees=true
|
||||
const coordinateSystem&
|
||||
);
|
||||
|
||||
//- Construct from origin and rotation
|
||||
sphericalCS
|
||||
cartesianCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation&,
|
||||
const bool inDegrees=true
|
||||
const coordinateRotation&
|
||||
);
|
||||
|
||||
//- Construct from origin and 2 axes
|
||||
sphericalCS
|
||||
cartesianCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const vector& axis,
|
||||
const vector& dirn,
|
||||
const bool inDegrees=true
|
||||
const vector& dirn
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
sphericalCS(const word& name, const dictionary&);
|
||||
cartesianCS(const word&, const dictionary&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
//- Construct from dictionary and objectRegistry
|
||||
cartesianCS(const objectRegistry&, const dictionary&);
|
||||
|
||||
//- Are angles in degrees?
|
||||
bool inDegrees() const;
|
||||
|
||||
//- Non-const access to inDegrees
|
||||
bool& inDegrees();
|
||||
//- Destructor
|
||||
virtual ~cartesianCS();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,8 +39,134 @@ namespace Foam
|
||||
EulerCoordinateRotation,
|
||||
dictionary
|
||||
);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
EulerCoordinateRotation,
|
||||
objectRegistry
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::EulerCoordinateRotation::transform(const vector& st) const
|
||||
{
|
||||
return (R_ & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::EulerCoordinateRotation::invTransform
|
||||
(
|
||||
const vector& st
|
||||
) const
|
||||
{
|
||||
return (Rtr_ & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::transform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<vectorField> Foam::EulerCoordinateRotation:: "
|
||||
"transform(const vectorField& st) const"
|
||||
);
|
||||
return tmp<vectorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::invTransform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<vectorField> Foam::EulerCoordinateRotation::"
|
||||
"invTransform(const vectorField& st) const"
|
||||
);
|
||||
return tmp<vectorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
const Foam::tensorField& Foam::EulerCoordinateRotation::Tr() const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"const tensorField& EulerCoordinateRotation::Tr() const"
|
||||
);
|
||||
return *reinterpret_cast<const tensorField*>(0);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor
|
||||
(
|
||||
const tensorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"const tensorField& EulerCoordinateRotation::transformTensor() const"
|
||||
);
|
||||
return tmp<tensorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
Foam::tensor Foam::EulerCoordinateRotation::transformTensor
|
||||
(
|
||||
const tensor& st
|
||||
) const
|
||||
{
|
||||
return (R_ & st & Rtr_);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<Foam::tensorField> EulerCoordinateRotation::transformTensor "
|
||||
" const tensorField& st,"
|
||||
" const labelList& cellMap "
|
||||
") const"
|
||||
);
|
||||
return tmp<tensorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::EulerCoordinateRotation::
|
||||
transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
tmp<symmTensorField> tfld(new symmTensorField(st.size()));
|
||||
symmTensorField& fld = tfld();
|
||||
|
||||
forAll(fld, i)
|
||||
{
|
||||
fld[i] = transformPrincipal(R_, st[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
Foam::symmTensor Foam::EulerCoordinateRotation::transformVector
|
||||
(
|
||||
const vector& st
|
||||
) const
|
||||
{
|
||||
return transformPrincipal(R_, st);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::EulerCoordinateRotation::calcTransform
|
||||
@ -62,7 +188,7 @@ void Foam::EulerCoordinateRotation::calcTransform
|
||||
psi *= constant::mathematical::pi/180.0;
|
||||
}
|
||||
|
||||
tensor::operator=
|
||||
R_ =
|
||||
(
|
||||
tensor
|
||||
(
|
||||
@ -79,6 +205,8 @@ void Foam::EulerCoordinateRotation::calcTransform
|
||||
cos(theta)
|
||||
)
|
||||
);
|
||||
|
||||
Rtr_ = R_.T();
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +214,8 @@ void Foam::EulerCoordinateRotation::calcTransform
|
||||
|
||||
Foam::EulerCoordinateRotation::EulerCoordinateRotation()
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{}
|
||||
|
||||
|
||||
@ -96,7 +225,8 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
calcTransform
|
||||
(
|
||||
@ -116,7 +246,8 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees);
|
||||
}
|
||||
@ -127,7 +258,8 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
vector rotation(dict.lookup("rotation"));
|
||||
|
||||
@ -141,4 +273,32 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation
|
||||
}
|
||||
|
||||
|
||||
Foam::EulerCoordinateRotation::EulerCoordinateRotation
|
||||
(
|
||||
const dictionary& dict,
|
||||
const objectRegistry&
|
||||
)
|
||||
:
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
vector rotation(dict.lookup("rotation"));
|
||||
|
||||
calcTransform
|
||||
(
|
||||
rotation.component(vector::X),
|
||||
rotation.component(vector::Y),
|
||||
rotation.component(vector::Z),
|
||||
dict.lookupOrDefault("degrees", true)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::EulerCoordinateRotation::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -65,6 +65,16 @@ class EulerCoordinateRotation
|
||||
:
|
||||
public coordinateRotation
|
||||
{
|
||||
|
||||
// Private Member Data
|
||||
|
||||
//- Local-to-global transformation tensor
|
||||
tensor R_;
|
||||
|
||||
//- Global-to-Local transformation tensor
|
||||
tensor Rtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate transformation tensor
|
||||
@ -107,6 +117,93 @@ public:
|
||||
//- Construct from dictionary
|
||||
EulerCoordinateRotation(const dictionary&);
|
||||
|
||||
//- Construct from dictionary and mesh
|
||||
EulerCoordinateRotation(const dictionary&, const objectRegistry&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Reset rotation to an identity rotation
|
||||
virtual void clear()
|
||||
{
|
||||
R_ = sphericalTensor::I;
|
||||
Rtr_ = sphericalTensor::I;
|
||||
}
|
||||
|
||||
//- Return local-to-global transformation tensor
|
||||
virtual const tensor& R() const
|
||||
{
|
||||
return R_;
|
||||
}
|
||||
|
||||
//- Return global-to-local transformation tensor
|
||||
virtual const tensor& Rtr() const
|
||||
{
|
||||
return Rtr_;
|
||||
};
|
||||
|
||||
//- Return local Cartesian x-axis
|
||||
virtual const vector e1() const
|
||||
{
|
||||
return R_.x();
|
||||
}
|
||||
|
||||
//- Return local Cartesian y-axis
|
||||
virtual const vector e2() const
|
||||
{
|
||||
return R_.y();
|
||||
}
|
||||
|
||||
//- Return local Cartesian z-axis
|
||||
virtual const vector e3() const
|
||||
{
|
||||
return R_.z();
|
||||
}
|
||||
|
||||
//- Return transformation tensor field
|
||||
virtual const tensorField& Tr() const;
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& st) const;
|
||||
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& st) const;
|
||||
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& st) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& st) const;
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor(const tensorField& st) const;
|
||||
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& st) const;
|
||||
|
||||
//- Transform tensor sub-field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const;
|
||||
|
||||
//- Transform vectorField using transformation tensorField and return
|
||||
// symmetrical tensorField
|
||||
virtual tmp<symmTensorField> transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor
|
||||
virtual symmTensor transformVector(const vector& st) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,9 +39,134 @@ namespace Foam
|
||||
STARCDCoordinateRotation,
|
||||
dictionary
|
||||
);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
STARCDCoordinateRotation,
|
||||
objectRegistry
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::STARCDCoordinateRotation::transform(const vector& st) const
|
||||
{
|
||||
return (R_ & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::STARCDCoordinateRotation::invTransform
|
||||
(
|
||||
const vector& st
|
||||
) const
|
||||
{
|
||||
return (Rtr_ & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::transform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<vectorField> Foam::STARCDCoordinateRotation:: "
|
||||
"transform(const vectorField& st) const"
|
||||
);
|
||||
return tmp<vectorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::invTransform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<vectorField> Foam::STARCDCoordinateRotation::"
|
||||
"invTransform(const vectorField& st) const"
|
||||
);
|
||||
return tmp<vectorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
const Foam::tensorField& Foam::STARCDCoordinateRotation::Tr() const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"const tensorField& STARCDCoordinateRotatio::Tr() const"
|
||||
);
|
||||
return *reinterpret_cast<const tensorField*>(0);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor
|
||||
(
|
||||
const tensorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<Foam::tensorField> STARCDCoordinateRotation::transformTensor()"
|
||||
);
|
||||
return tmp<tensorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
Foam::tensor Foam::STARCDCoordinateRotation::transformTensor
|
||||
(
|
||||
const tensor& st
|
||||
) const
|
||||
{
|
||||
return (R_ & st & Rtr_);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<Foam::tensorField> STARCDCoordinateRotation::transformTensor "
|
||||
" const tensorField& st,"
|
||||
" const labelList& cellMap "
|
||||
") const"
|
||||
);
|
||||
return tmp<tensorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::STARCDCoordinateRotation::
|
||||
transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
tmp<symmTensorField> tfld(new symmTensorField(st.size()));
|
||||
symmTensorField& fld = tfld();
|
||||
|
||||
forAll(fld, i)
|
||||
{
|
||||
fld[i] = transformPrincipal(R_, st[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
Foam::symmTensor Foam::STARCDCoordinateRotation::transformVector
|
||||
(
|
||||
const vector& st
|
||||
) const
|
||||
{
|
||||
return transformPrincipal(R_, st);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::STARCDCoordinateRotation::calcTransform
|
||||
@ -63,7 +188,7 @@ void Foam::STARCDCoordinateRotation::calcTransform
|
||||
z *= constant::mathematical::pi/180.0;
|
||||
}
|
||||
|
||||
tensor::operator=
|
||||
R_ =
|
||||
(
|
||||
tensor
|
||||
(
|
||||
@ -80,6 +205,8 @@ void Foam::STARCDCoordinateRotation::calcTransform
|
||||
cos(x)*cos(y)
|
||||
)
|
||||
);
|
||||
|
||||
Rtr_ = R_.T();
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +214,8 @@ void Foam::STARCDCoordinateRotation::calcTransform
|
||||
|
||||
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation()
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{}
|
||||
|
||||
|
||||
@ -97,7 +225,8 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
calcTransform
|
||||
(
|
||||
@ -117,7 +246,8 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
calcTransform(rotZ, rotX, rotY, inDegrees);
|
||||
}
|
||||
@ -128,7 +258,8 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateRotation()
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
vector rotation(dict.lookup("rotation"));
|
||||
|
||||
@ -141,4 +272,30 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
|
||||
(
|
||||
const dictionary& dict,
|
||||
const objectRegistry&
|
||||
)
|
||||
{
|
||||
vector rotation(dict.lookup("rotation"));
|
||||
|
||||
calcTransform
|
||||
(
|
||||
rotation.component(vector::X),
|
||||
rotation.component(vector::Y),
|
||||
rotation.component(vector::Z),
|
||||
dict.lookupOrDefault("degrees", true)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::STARCDCoordinateRotation::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -62,6 +62,16 @@ class STARCDCoordinateRotation
|
||||
:
|
||||
public coordinateRotation
|
||||
{
|
||||
|
||||
// Private Member Data
|
||||
|
||||
//- Local-to-Global transformation tensor
|
||||
tensor R_;
|
||||
|
||||
//- Global-to-Local transformation tensor
|
||||
tensor Rtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate transformation tensor
|
||||
@ -104,6 +114,92 @@ public:
|
||||
//- Construct from dictionary
|
||||
STARCDCoordinateRotation(const dictionary&);
|
||||
|
||||
//- Construct from dictionary and mesh
|
||||
STARCDCoordinateRotation(const dictionary&, const objectRegistry&);
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Reset rotation to an identity rotation
|
||||
virtual void clear()
|
||||
{
|
||||
R_ = sphericalTensor::I;
|
||||
Rtr_ = sphericalTensor::I;
|
||||
}
|
||||
|
||||
//- Return local-to-global transformation tensor
|
||||
virtual const tensor& R() const
|
||||
{
|
||||
return R_;
|
||||
}
|
||||
|
||||
//- Return global-to-local transformation tensor
|
||||
virtual const tensor& Rtr() const
|
||||
{
|
||||
return Rtr_;
|
||||
};
|
||||
|
||||
//- Return local Cartesian x-axis
|
||||
virtual const vector e1() const
|
||||
{
|
||||
return R_.x();
|
||||
}
|
||||
|
||||
//- Return local Cartesian y-axis
|
||||
virtual const vector e2() const
|
||||
{
|
||||
return R_.y();
|
||||
}
|
||||
|
||||
//- Return local Cartesian z-axis
|
||||
virtual const vector e3() const
|
||||
{
|
||||
return R_.z();
|
||||
}
|
||||
|
||||
//- Return transformation tensor field
|
||||
virtual const tensorField& Tr() const;
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& st) const;
|
||||
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& st) const;
|
||||
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& st) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& st) const;
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor(const tensorField& st) const;
|
||||
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& st) const;
|
||||
|
||||
//- Transform tensor sub-field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const;
|
||||
|
||||
//- Transform vectorField using transformation tensorField and return
|
||||
// symmetrical tensorField
|
||||
virtual tmp<symmTensorField> transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor
|
||||
virtual symmTensor transformVector(const vector& st) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,314 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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 "axesRotation.H"
|
||||
#include "dictionary.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(axesRotation, 0);
|
||||
addToRunTimeSelectionTable(coordinateRotation, axesRotation, dictionary);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
axesRotation,
|
||||
objectRegistry
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::axesRotation::calcTransform
|
||||
(
|
||||
const vector& axis1,
|
||||
const vector& axis2,
|
||||
const axisOrder& order
|
||||
)
|
||||
{
|
||||
vector a = axis1 / mag(axis1);
|
||||
vector b = axis2;
|
||||
|
||||
// Absorb minor nonorthogonality into axis2
|
||||
b = b - (b & a)*a;
|
||||
|
||||
if (mag(b) < SMALL)
|
||||
{
|
||||
FatalErrorIn("axesRotation::calcTransform()")
|
||||
<< "axis1, axis2 appear co-linear: "
|
||||
<< axis1 << ", " << axis2 << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
b = b / mag(b);
|
||||
vector c = a ^ b;
|
||||
|
||||
tensor Rtr;
|
||||
switch (order)
|
||||
{
|
||||
case e1e2:
|
||||
Rtr = tensor(a, b, c);
|
||||
break;
|
||||
|
||||
case e2e3:
|
||||
Rtr = tensor(c, a, b);
|
||||
break;
|
||||
|
||||
case e3e1:
|
||||
Rtr = tensor(b, c, a);
|
||||
break;
|
||||
|
||||
default:
|
||||
FatalErrorIn("axesRotation::calcTransform()")
|
||||
<< "programmer error" << endl
|
||||
<< abort(FatalError);
|
||||
|
||||
Rtr = tensor::zero;
|
||||
break;
|
||||
}
|
||||
|
||||
// the global -> local transformation
|
||||
Rtr_ = Rtr;
|
||||
// the local -> global transformation
|
||||
R_ = Rtr.T();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::axesRotation::axesRotation()
|
||||
:
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::axesRotation::axesRotation
|
||||
(
|
||||
const vector& axis,
|
||||
const vector& dir
|
||||
)
|
||||
:
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
calcTransform(axis, dir, e3e1);
|
||||
}
|
||||
|
||||
|
||||
Foam::axesRotation::axesRotation
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
operator=(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::axesRotation::axesRotation
|
||||
(
|
||||
const dictionary& dict,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
:
|
||||
R_(sphericalTensor::I),
|
||||
Rtr_(R_)
|
||||
{
|
||||
operator=(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::axesRotation::axesRotation(const tensor& R)
|
||||
:
|
||||
R_(R),
|
||||
Rtr_(R_.T())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::axesRotation::transform(const vector& st) const
|
||||
{
|
||||
return (R_ & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::axesRotation::invTransform(const vector& st) const
|
||||
{
|
||||
return (Rtr_ & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::axesRotation::transform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
return (R_ & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::axesRotation::invTransform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
return (Rtr_ & st);
|
||||
}
|
||||
|
||||
|
||||
const Foam::tensorField& Foam::axesRotation::Tr() const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"const Foam::tensorField& axesRotation::Tr() const"
|
||||
);
|
||||
return *reinterpret_cast<const tensorField*>(0);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::axesRotation::transformTensor
|
||||
(
|
||||
const tensorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"const tensorField& axesRotation::transformTensor() const"
|
||||
);
|
||||
return tmp<tensorField>(NULL);
|
||||
}
|
||||
|
||||
|
||||
Foam::tensor Foam::axesRotation::transformTensor
|
||||
(
|
||||
const tensor& st
|
||||
) const
|
||||
{
|
||||
return (R_ & st & Rtr_);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::axesRotation::transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<Foam::tensorField> axesRotation::transformTensor "
|
||||
" const tensorField& st,"
|
||||
" const labelList& cellMap "
|
||||
") const"
|
||||
);
|
||||
return tmp<tensorField>(NULL);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::axesRotation::transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
tmp<symmTensorField> tfld(new symmTensorField(st.size()));
|
||||
symmTensorField& fld = tfld();
|
||||
|
||||
forAll(fld, i)
|
||||
{
|
||||
fld[i] = transformPrincipal(R_, st[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
Foam::symmTensor Foam::axesRotation::transformVector
|
||||
(
|
||||
const vector& st
|
||||
) const
|
||||
{
|
||||
return transformPrincipal(R_, st);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::axesRotation::operator=(const dictionary& dict)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "axesRotation::operator=(const dictionary&) : "
|
||||
<< "assign from " << dict << endl;
|
||||
}
|
||||
|
||||
vector axis1, axis2;
|
||||
axisOrder order(e3e1);
|
||||
|
||||
if (dict.readIfPresent("e1", axis1) && dict.readIfPresent("e2", axis2))
|
||||
{
|
||||
order = e1e2;
|
||||
}
|
||||
else if (dict.readIfPresent("e2", axis1)&& dict.readIfPresent("e3", axis2))
|
||||
{
|
||||
order = e2e3;
|
||||
}
|
||||
else if (dict.readIfPresent("e3", axis1)&& dict.readIfPresent("e1", axis2))
|
||||
{
|
||||
order = e3e1;
|
||||
}
|
||||
else if (dict.found("axis") || dict.found("direction"))
|
||||
{
|
||||
// let it bomb if only one of axis/direction is defined
|
||||
order = e3e1;
|
||||
dict.lookup("axis") >> axis1;
|
||||
dict.lookup("direction") >> axis2;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"axesRotation::operator=(const dictionary&) "
|
||||
) << "not entry of the type (e1, e2) or (e2, e3) or (e3, e1) "
|
||||
<< "found "
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
calcTransform(axis1, axis2, order);
|
||||
}
|
||||
|
||||
|
||||
void Foam::axesRotation::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,229 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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::axesRotation
|
||||
|
||||
Description
|
||||
A coordinate rotation specified using global axis
|
||||
|
||||
The rotation is defined by a combination of vectors (e1/e2), (e2/e3)
|
||||
or (e3/e1). Any nonorthogonality will be absorbed into the second vector.
|
||||
|
||||
\verbatim
|
||||
axesRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0 0);
|
||||
e2 (0 1 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef axesRotation_H
|
||||
#define axesRotation_H
|
||||
|
||||
#include "vector.H"
|
||||
#include "coordinateRotation.H"
|
||||
#include "dictionary.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class axesRotation Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class axesRotation
|
||||
:
|
||||
public coordinateRotation
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Local-to-Global transformation tensor
|
||||
tensor R_;
|
||||
|
||||
//- Global-to-Local transformation tensor
|
||||
tensor Rtr_;
|
||||
|
||||
//- the combination of local axes to be used
|
||||
enum axisOrder
|
||||
{
|
||||
e1e2,
|
||||
e2e3,
|
||||
e3e1
|
||||
};
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate transformation tensor
|
||||
void calcTransform
|
||||
(
|
||||
const vector& axis1,
|
||||
const vector& axis2,
|
||||
const axisOrder& order = e3e1
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("axesRotation");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
axesRotation();
|
||||
|
||||
//- Construct from 2 axes
|
||||
axesRotation
|
||||
(
|
||||
const vector& axis,
|
||||
const vector& dir
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
axesRotation(const dictionary&);
|
||||
|
||||
//- Construct from components
|
||||
axesRotation(const tensor& R);
|
||||
|
||||
//- Construct from dictionary and mesh
|
||||
axesRotation(const dictionary&, const objectRegistry&);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<axesRotation> clone() const
|
||||
{
|
||||
return autoPtr<axesRotation>(new axesRotation(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~axesRotation()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Reset rotation to an identity rotation
|
||||
virtual void clear()
|
||||
{
|
||||
R_ = sphericalTensor::I;
|
||||
Rtr_ = sphericalTensor::I;
|
||||
}
|
||||
|
||||
//- Return local-to-global transformation tensor
|
||||
virtual const tensor& R() const
|
||||
{
|
||||
return R_;
|
||||
}
|
||||
|
||||
//- Return global-to-local transformation tensor
|
||||
virtual const tensor& Rtr() const
|
||||
{
|
||||
return Rtr_;
|
||||
}
|
||||
|
||||
//- Return local Cartesian x-axis
|
||||
virtual const vector e1() const
|
||||
{
|
||||
return R_.x();
|
||||
}
|
||||
|
||||
//- Return local Cartesian y-axis
|
||||
virtual const vector e2() const
|
||||
{
|
||||
return R_.y();
|
||||
}
|
||||
|
||||
//- Return local Cartesian z-axis
|
||||
virtual const vector e3() const
|
||||
{
|
||||
return R_.z();
|
||||
}
|
||||
|
||||
//- Return transformation tensor field
|
||||
virtual const tensorField& Tr() const;
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& st) const;
|
||||
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& st) const;
|
||||
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& st) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& st) const;
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor(const tensorField& st) const;
|
||||
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& st) const;
|
||||
|
||||
//- Transform tensor sub-field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const;
|
||||
|
||||
//- Transform vectorField using transformation tensorField and return
|
||||
// symmetrical tensorField
|
||||
virtual tmp<symmTensorField> transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor
|
||||
virtual symmTensor transformVector(const vector& st) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- assign from dictionary
|
||||
void operator=(const dictionary&);
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -33,197 +33,45 @@ namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(coordinateRotation, 0);
|
||||
defineRunTimeSelectionTable(coordinateRotation, dictionary);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::coordinateRotation::calcTransform
|
||||
(
|
||||
const vector& axis1,
|
||||
const vector& axis2,
|
||||
const axisOrder& order
|
||||
)
|
||||
{
|
||||
vector a = axis1 / mag(axis1);
|
||||
vector b = axis2;
|
||||
|
||||
// Absorb minor nonorthogonality into axis2
|
||||
b = b - (b & a)*a;
|
||||
|
||||
if (mag(b) < SMALL)
|
||||
{
|
||||
FatalErrorIn("coordinateRotation::calcTransform()")
|
||||
<< "axis1, axis2 appear co-linear: "
|
||||
<< axis1 << ", " << axis2 << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
b = b / mag(b);
|
||||
vector c = a ^ b;
|
||||
|
||||
// the global -> local transformation
|
||||
tensor Rtr;
|
||||
switch (order)
|
||||
{
|
||||
case e1e2:
|
||||
Rtr = tensor(a, b, c);
|
||||
break;
|
||||
|
||||
case e2e3:
|
||||
Rtr = tensor(c, a, b);
|
||||
break;
|
||||
|
||||
case e3e1:
|
||||
Rtr = tensor(b, c, a);
|
||||
break;
|
||||
|
||||
default:
|
||||
FatalErrorIn("coordinateRotation::calcTransform()")
|
||||
<< "programmer error" << endl
|
||||
<< abort(FatalError);
|
||||
// To satisfy compiler warnings
|
||||
Rtr = tensor::zero;
|
||||
break;
|
||||
}
|
||||
|
||||
// the local -> global transformation
|
||||
tensor::operator=( Rtr.T() );
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::coordinateRotation::coordinateRotation()
|
||||
:
|
||||
tensor(sphericalTensor::I)
|
||||
{}
|
||||
|
||||
|
||||
Foam::coordinateRotation::coordinateRotation
|
||||
(
|
||||
const vector& axis,
|
||||
const vector& dir
|
||||
)
|
||||
:
|
||||
tensor(sphericalTensor::I)
|
||||
{
|
||||
calcTransform(axis, dir, e3e1);
|
||||
}
|
||||
|
||||
|
||||
Foam::coordinateRotation::coordinateRotation
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
tensor(sphericalTensor::I)
|
||||
{
|
||||
operator=(dict);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "coordinateRotation::New(const dictionary&) : "
|
||||
<< "constructing coordinateRotation"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// default type is self (alias: "axes")
|
||||
word rotType(typeName_());
|
||||
dict.readIfPresent("type", rotType);
|
||||
|
||||
// can (must) construct base class directly
|
||||
if (rotType == typeName_() || rotType == "axes")
|
||||
{
|
||||
return autoPtr<coordinateRotation>(new coordinateRotation(dict));
|
||||
}
|
||||
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(rotType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"coordinateRotation::New(const dictionary&)",
|
||||
dict
|
||||
) << "Unknown coordinateRotation type "
|
||||
<< rotType << nl << nl
|
||||
<< "Valid coordinateRotation types are :" << nl
|
||||
<< "[default: axes " << typeName_() << "]"
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<coordinateRotation>(cstrIter()(dict));
|
||||
defineRunTimeSelectionTable(coordinateRotation, objectRegistry);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::coordinateRotation::clear()
|
||||
Foam::symmTensor Foam::coordinateRotation::transformPrincipal
|
||||
(
|
||||
const tensor& tt,
|
||||
const vector& st
|
||||
) const
|
||||
{
|
||||
this->tensor::operator=(sphericalTensor::I);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::coordinateRotation::operator=(const dictionary& rhs)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "coordinateRotation::operator=(const dictionary&) : "
|
||||
<< "assign from " << rhs << endl;
|
||||
}
|
||||
|
||||
// allow as embedded sub-dictionary "coordinateRotation"
|
||||
const dictionary& dict =
|
||||
return symmTensor
|
||||
(
|
||||
rhs.found(typeName_())
|
||||
? rhs.subDict(typeName_())
|
||||
: rhs
|
||||
tt.xx()*st.x()*tt.xx()
|
||||
+ tt.xy()*st.y()*tt.xy()
|
||||
+ tt.xz()*st.z()*tt.xz(),
|
||||
|
||||
tt.xx()*st.x()*tt.yx()
|
||||
+ tt.xy()*st.y()*tt.yy()
|
||||
+ tt.xz()*st.z()*tt.yz(),
|
||||
|
||||
tt.xx()*st.x()*tt.zx()
|
||||
+ tt.xy()*st.y()*tt.zy()
|
||||
+ tt.xz()*st.z()*tt.zz(),
|
||||
|
||||
tt.yx()*st.x()*tt.yx()
|
||||
+ tt.yy()*st.y()*tt.yy()
|
||||
+ tt.yz()*st.z()*tt.yz(),
|
||||
|
||||
tt.yx()*st.x()*tt.zx()
|
||||
+ tt.yy()*st.y()*tt.zy()
|
||||
+ tt.yz()*st.z()*tt.zz(),
|
||||
|
||||
tt.zx()*st.x()*tt.zx()
|
||||
+ tt.zy()*st.y()*tt.zy()
|
||||
+ tt.zz()*st.z()*tt.zz()
|
||||
);
|
||||
|
||||
vector axis1, axis2;
|
||||
axisOrder order(e3e1);
|
||||
|
||||
if (dict.readIfPresent("e1", axis1) && dict.readIfPresent("e2", axis2))
|
||||
{
|
||||
order = e1e2;
|
||||
}
|
||||
else if (dict.readIfPresent("e2", axis1) && dict.readIfPresent("e3", axis2))
|
||||
{
|
||||
order = e2e3;
|
||||
}
|
||||
else if (dict.readIfPresent("e3", axis1) && dict.readIfPresent("e1", axis2))
|
||||
{
|
||||
order = e3e1;
|
||||
}
|
||||
else if (dict.found("axis") || dict.found("direction"))
|
||||
{
|
||||
// let it bomb if only one of axis/direction is defined
|
||||
order = e3e1;
|
||||
dict.lookup("axis") >> axis1;
|
||||
dict.lookup("direction") >> axis2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// unspecified axes revert to the global system
|
||||
tensor::operator=(sphericalTensor::I);
|
||||
return;
|
||||
}
|
||||
|
||||
calcTransform(axis1, axis2, order);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,46 +25,24 @@ Class
|
||||
Foam::coordinateRotation
|
||||
|
||||
Description
|
||||
A coordinate rotation specified per local axes and the base class for
|
||||
other rotation specifications
|
||||
|
||||
The rotation is defined by a combination of local vectors (e1/e2), (e2/e3)
|
||||
or (e3/e1). Any nonorthogonality will be absorbed into the second vector.
|
||||
|
||||
For convenience, the dictionary constructor forms allow a few shortcuts:
|
||||
- if the \c type is not otherwise specified, the type \c axes
|
||||
is implicit
|
||||
- if an axes specification (eg, e3/e1) is used, the coordinateRotation
|
||||
sub-dictionary can be dropped.
|
||||
|
||||
Specifying the rotation by an EulerCoordinateRotation
|
||||
(type "EulerRotation") or by a STARCDCoordinateRotation
|
||||
(type "STARCDRotation") requires the coordinateRotation sub-dictionary.
|
||||
Abstract base class for coordinate rotation
|
||||
|
||||
\verbatim
|
||||
coordinateRotation
|
||||
{
|
||||
type STARCDRotation
|
||||
rotation (0 0 90);
|
||||
type axesRotation
|
||||
e1 (1 0 0);
|
||||
e2 (0 1 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
- the rotation angles are in degrees, unless otherwise explictly specified:
|
||||
Types of coordinateRotation:
|
||||
1) axesRotation
|
||||
2) STARCDRotation
|
||||
3) localAxesRotation
|
||||
4) EulerCoordinateRotation
|
||||
|
||||
\verbatim
|
||||
coordinateRotation
|
||||
{
|
||||
type STARCDRotation
|
||||
degrees false;
|
||||
rotation (0 0 3.141592654);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Deprecated
|
||||
Specifying the local vectors as an \c axis (corresponding to e3) and a
|
||||
\c direction (corresponding to e1), is allowed for backwards
|
||||
compatibility, but this terminology is generally a bit confusing.
|
||||
(deprecated Apr 2008)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -73,8 +51,10 @@ Deprecated
|
||||
|
||||
#include "vector.H"
|
||||
#include "tensor.H"
|
||||
#include "tensorField.H"
|
||||
#include "dictionary.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -86,72 +66,59 @@ namespace Foam
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class coordinateRotation
|
||||
:
|
||||
public tensor
|
||||
{
|
||||
// Private data
|
||||
protected:
|
||||
|
||||
//- the combination of local axes to be used
|
||||
enum axisOrder
|
||||
{
|
||||
e1e2,
|
||||
e2e3,
|
||||
e3e1
|
||||
};
|
||||
// Protected member functions
|
||||
|
||||
// Private Member Functions
|
||||
//- Transform principal
|
||||
symmTensor transformPrincipal(const tensor&, const vector&) const;
|
||||
|
||||
//- Calculate transformation tensor
|
||||
void calcTransform
|
||||
(
|
||||
const vector& axis1,
|
||||
const vector& axis2,
|
||||
const axisOrder& order = e3e1
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("coordinateRotation");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
coordinateRotation();
|
||||
|
||||
//- Construct from 2 axes
|
||||
coordinateRotation
|
||||
(
|
||||
const vector& axis,
|
||||
const vector& dir
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
coordinateRotation(const dictionary&);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<coordinateRotation> clone() const
|
||||
{
|
||||
return autoPtr<coordinateRotation>(new coordinateRotation(*this));
|
||||
}
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
// for constructors with dictionary and objectRegistry
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
coordinateRotation,
|
||||
objectRegistry,
|
||||
(
|
||||
autoPtr,
|
||||
coordinateRotation,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& dict
|
||||
),
|
||||
(dict)
|
||||
);
|
||||
const dictionary& dict, const objectRegistry& obr
|
||||
),
|
||||
(dict, obr)
|
||||
);
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
// for constructors with dictionary
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
coordinateRotation,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& dict
|
||||
),
|
||||
(dict)
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from Istream
|
||||
//- Select constructed from dictionary and objectRegistry
|
||||
static autoPtr<coordinateRotation> New
|
||||
(
|
||||
const dictionary& dict, const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Select constructed from dictionary
|
||||
static autoPtr<coordinateRotation> New
|
||||
(
|
||||
const dictionary& dict
|
||||
@ -166,37 +133,76 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Reset rotation to an identity rotation
|
||||
virtual void clear();
|
||||
virtual void clear() = 0;
|
||||
|
||||
//- Return local-to-global transformation tensor
|
||||
const tensor& R() const
|
||||
{
|
||||
return (*this);
|
||||
}
|
||||
virtual const tensor& R() const = 0;
|
||||
|
||||
//- Return global-to-local transformation tensor
|
||||
virtual const tensor& Rtr() const = 0;
|
||||
|
||||
//- Return local Cartesian x-axis
|
||||
const vector e1() const
|
||||
{
|
||||
return tensor::T().x();
|
||||
}
|
||||
virtual const vector e1() const = 0;
|
||||
|
||||
//- Return local Cartesian y-axis
|
||||
const vector e2() const
|
||||
{
|
||||
return tensor::T().y();
|
||||
}
|
||||
virtual const vector e2() const = 0;
|
||||
|
||||
//- Return local Cartesian z-axis
|
||||
const vector e3() const
|
||||
virtual const vector e3() const = 0;
|
||||
|
||||
//- Return local-to-global transformation tensor
|
||||
virtual const tensorField& Tr() const = 0;
|
||||
|
||||
//- Return true if the rotation tensor is uniform
|
||||
virtual bool uniform() const
|
||||
{
|
||||
return tensor::T().z();
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& st) const = 0;
|
||||
|
||||
// Member Operators
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& st) const = 0;
|
||||
|
||||
//- assign from dictionary
|
||||
void operator=(const dictionary&);
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& st) const = 0;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& st) const = 0;
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor
|
||||
(
|
||||
const tensorField& st
|
||||
) const = 0;
|
||||
|
||||
//- Transform tensor sub-field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const = 0;
|
||||
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& st) const = 0;
|
||||
|
||||
//- Transform vectorField using transformation tensorField and return
|
||||
// symmetrical tensorField
|
||||
virtual tmp<symmTensorField> transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const = 0;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor
|
||||
virtual symmTensor transformVector(const vector& st) const = 0;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,107 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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 "coordinateRotation.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
|
||||
(
|
||||
const dictionary& dict, const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "coordinateRotation::New(const dictionary&) : "
|
||||
<< "constructing coordinateRotation"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
word rotType = dict.lookup("type");
|
||||
|
||||
objectRegistryConstructorTable::iterator cstrIter =
|
||||
objectRegistryConstructorTablePtr_->find(rotType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"coordinateRotation::New"
|
||||
"("
|
||||
" const dictionary&, "
|
||||
" const objectRegistry& "
|
||||
")",
|
||||
dict
|
||||
) << "Unknown coordinateRotation type "
|
||||
<< rotType << nl << nl
|
||||
<< "Valid coordinateRotation types are :" << nl
|
||||
<< "[default: axes ]"
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<coordinateRotation>(cstrIter()(dict, obr));
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "coordinateRotation::New(const dictionary&) : "
|
||||
<< "constructing coordinateRotation"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
word rotType = dict.lookup("type");
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(rotType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"coordinateRotation::New"
|
||||
"("
|
||||
" const dictionary&, "
|
||||
")",
|
||||
dict
|
||||
) << "Unknown coordinateRotation type "
|
||||
<< rotType << nl << nl
|
||||
<< "Valid coordinateRotation types are :" << nl
|
||||
<< "[default: axes ]"
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<coordinateRotation>(cstrIter()(dict));
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,267 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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 "localAxesRotation.H"
|
||||
#include "axesRotation.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "polyMesh.H"
|
||||
#include "tensorIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(localAxesRotation, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
localAxesRotation,
|
||||
dictionary
|
||||
);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateRotation,
|
||||
localAxesRotation,
|
||||
objectRegistry
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::localAxesRotation::localAxesRotation
|
||||
(
|
||||
const dictionary& dict, const objectRegistry& orb
|
||||
)
|
||||
:
|
||||
Rptr_(),
|
||||
origin_(point::zero),
|
||||
e3_(vector::zero)
|
||||
{
|
||||
// If origin is specified in the coordinateSystem
|
||||
if (dict.parent().found("origin"))
|
||||
{
|
||||
dict.parent().lookup("origin") >> origin_;
|
||||
}
|
||||
|
||||
// rotation axis
|
||||
dict.lookup("e3") >> e3_;
|
||||
|
||||
const polyMesh& mesh = refCast<const polyMesh>(orb);
|
||||
|
||||
Rptr_.reset
|
||||
(
|
||||
new tensorField(mesh.nCells())
|
||||
);
|
||||
init(dict, orb);
|
||||
}
|
||||
|
||||
|
||||
Foam::localAxesRotation::localAxesRotation
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Rptr_(),
|
||||
origin_(),
|
||||
e3_()
|
||||
{
|
||||
FatalErrorIn("localAxesRotation(const dictionary&)")
|
||||
<< " localAxesRotation can not be contructed from dictionary "
|
||||
<< " use the construtctor : "
|
||||
"("
|
||||
" const dictionary& dict, const objectRegistry& orb"
|
||||
")"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::localAxesRotation::clear()
|
||||
{
|
||||
if (!Rptr_.empty())
|
||||
{
|
||||
Rptr_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::localAxesRotation::transform(const vector& st) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"vector Foam::localAxesRotation::transform(const vector&) const"
|
||||
);
|
||||
return vector::zero;
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::localAxesRotation::invTransform(const vector& st) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"vector Foam::localAxesRotation::invTransform(const vector&) const"
|
||||
);
|
||||
return vector::zero;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::localAxesRotation::transform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
if (Rptr_->size() != st.size())
|
||||
{
|
||||
FatalErrorIn("localAxesRotation::transform(const vectorField&)")
|
||||
<< "vectorField st has different size to tensorField "
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return (Rptr_() & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::localAxesRotation::invTransform
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
return (Rptr_().T() & st);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
||||
(
|
||||
const tensorField& st
|
||||
) const
|
||||
{
|
||||
if (Rptr_->size() != st.size())
|
||||
{
|
||||
FatalErrorIn("localAxesRotation::transformTensor(const tensorField&)")
|
||||
<< "tensorField st has different size to tensorField Tr"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
return (Rptr_() & st & Rptr_().T());
|
||||
}
|
||||
|
||||
|
||||
Foam::tensor Foam::localAxesRotation::transformTensor
|
||||
(
|
||||
const tensor& st
|
||||
) const
|
||||
{
|
||||
notImplemented("tensor localAxesRotation::transformTensor() const");
|
||||
return tensor::zero;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const
|
||||
{
|
||||
if (cellMap.size() != st.size())
|
||||
{
|
||||
FatalErrorIn("localAxesRotation::transformTensor(const tensorField&)")
|
||||
<< "tensorField st has different size to tensorField Tr"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const tensorField Rtr(Rptr_().T());
|
||||
tmp<tensorField> tt(new tensorField(cellMap.size()));
|
||||
tensorField& t = tt();
|
||||
forAll(cellMap, i)
|
||||
{
|
||||
const label cellI = cellMap[i];
|
||||
t[i] = Rptr_()[cellI] & st[i] & Rtr[cellI];
|
||||
}
|
||||
return tt;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::localAxesRotation::transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
if (Rptr_->size() != st.size())
|
||||
{
|
||||
FatalErrorIn("localAxesRotation::transformVector(const vectorField&)")
|
||||
<< "tensorField st has different size to tensorField Tr"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
tmp<symmTensorField> tfld(new symmTensorField(Rptr_->size()));
|
||||
symmTensorField& fld = tfld();
|
||||
|
||||
forAll(fld, i)
|
||||
{
|
||||
fld[i] = transformPrincipal(Rptr_()[i], st[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
Foam::symmTensor Foam::localAxesRotation::transformVector
|
||||
(
|
||||
const vector& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tensor localAxesRotation::transformVector(const vector&) const"
|
||||
);
|
||||
return symmTensor::zero;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::localAxesRotation::init
|
||||
(
|
||||
const dictionary& dict,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
const polyMesh& mesh = refCast<const polyMesh>(obr);
|
||||
forAll(mesh.cellCentres(), cellI)
|
||||
{
|
||||
vector dir = mesh.cellCentres()[cellI] - origin_;
|
||||
dir /= mag(dir) + VSMALL;
|
||||
|
||||
Rptr_()[cellI] = axesRotation(e3_, dir).R();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::localAxesRotation::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,209 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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::localAxesRotation
|
||||
|
||||
Description
|
||||
A local coordinate rotation.
|
||||
Each rotational tensor is defined with two vectors (dir and e3)
|
||||
where dir = cellC - origin and e3 is the rotation axis.
|
||||
Per each cell an axesRotation type of rotation is created
|
||||
|
||||
\verbatim
|
||||
localAxesRotation
|
||||
{
|
||||
type localAxes;
|
||||
e3 (0 0 1);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef localAxesRotation_H
|
||||
#define localAxesRotation_H
|
||||
|
||||
#include "point.H"
|
||||
#include "vector.H"
|
||||
#include "coordinateRotation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class localAxesRotation Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class localAxesRotation
|
||||
:
|
||||
public coordinateRotation
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- AutoPtr to transformation tensor
|
||||
autoPtr<tensorField> Rptr_;
|
||||
|
||||
//- Origin of the coordinate system
|
||||
point origin_;
|
||||
|
||||
//- Rotation axis
|
||||
vector e3_;
|
||||
|
||||
|
||||
// Private members
|
||||
|
||||
//- Init transformation tensor
|
||||
void init(const dictionary& dict, const objectRegistry& obr);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("localAxesRotation");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and objectRegistry
|
||||
localAxesRotation(const dictionary&, const objectRegistry&);
|
||||
|
||||
//- Construct from dictionary
|
||||
localAxesRotation(const dictionary&);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<localAxesRotation> clone() const
|
||||
{
|
||||
return autoPtr<localAxesRotation>(new localAxesRotation(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~localAxesRotation()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Reset rotation to an identity rotation
|
||||
virtual void clear();
|
||||
|
||||
//- Return local-to-global transformation tensor
|
||||
virtual const tensor& R() const
|
||||
{
|
||||
notImplemented("const tensor& localAxesRotation::R() const");
|
||||
return tensor::zero;
|
||||
}
|
||||
|
||||
//- Return global-to-local transformation tensor
|
||||
virtual const tensor& Rtr() const
|
||||
{
|
||||
notImplemented("const tensor& localAxesRotation::Rtr() const");
|
||||
return tensor::zero;
|
||||
}
|
||||
|
||||
//- Return local Cartesian x-axis
|
||||
virtual const vector e1() const
|
||||
{
|
||||
notImplemented("const tensor& localAxesRotation::e1() const");
|
||||
return vector::zero;
|
||||
}
|
||||
|
||||
//- Return local Cartesian y-axis
|
||||
virtual const vector e2() const
|
||||
{
|
||||
notImplemented("const tensor& localAxesRotation::e2() const");
|
||||
return vector::zero;
|
||||
}
|
||||
|
||||
//- Return local Cartesian z-axis
|
||||
virtual const vector e3() const
|
||||
{
|
||||
return e3_;
|
||||
}
|
||||
|
||||
virtual const tensorField& Tr() const
|
||||
{
|
||||
return Rptr_();
|
||||
}
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& st) const;
|
||||
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& st) const;
|
||||
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& st) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& st) const;
|
||||
|
||||
//- Return if the rotation is uniform
|
||||
virtual bool uniform() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor(const tensorField& st) const;
|
||||
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& st) const;
|
||||
|
||||
//- Transform tensor sub-field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor
|
||||
(
|
||||
const tensorField& st,
|
||||
const labelList& cellMap
|
||||
) const;
|
||||
|
||||
//- Transform vectorField using transformation tensorField and return
|
||||
// symmetrical tensorField
|
||||
virtual tmp<symmTensorField> transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor (R & st & R.T())
|
||||
virtual symmTensor transformVector(const vector& st) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOstream.H"
|
||||
#include "axesRotation.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "coordinateSystems.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
@ -34,18 +35,16 @@ namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(coordinateSystem, 0);
|
||||
defineRunTimeSelectionTable(coordinateSystem, dictionary);
|
||||
defineRunTimeSelectionTable(coordinateSystem, origRotation);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::coordinateSystem::coordinateSystem()
|
||||
:
|
||||
name_(type()),
|
||||
name_(),
|
||||
note_(),
|
||||
origin_(point::zero),
|
||||
R_(),
|
||||
Rtr_(sphericalTensor::I)
|
||||
R_(new axesRotation(sphericalTensor::I))
|
||||
{}
|
||||
|
||||
|
||||
@ -58,8 +57,7 @@ Foam::coordinateSystem::coordinateSystem
|
||||
name_(name),
|
||||
note_(),
|
||||
origin_(cs.origin_),
|
||||
R_(cs.R_),
|
||||
Rtr_(R_.T())
|
||||
R_(const_cast<coordinateRotation*>(&cs.R()))
|
||||
{}
|
||||
|
||||
|
||||
@ -73,8 +71,7 @@ Foam::coordinateSystem::coordinateSystem
|
||||
name_(name),
|
||||
note_(),
|
||||
origin_(origin),
|
||||
R_(cr),
|
||||
Rtr_(R_.T())
|
||||
R_(const_cast<coordinateRotation*>(&cr))
|
||||
{}
|
||||
|
||||
|
||||
@ -89,8 +86,7 @@ Foam::coordinateSystem::coordinateSystem
|
||||
name_(name),
|
||||
note_(),
|
||||
origin_(origin),
|
||||
R_(axis, dirn),
|
||||
Rtr_(R_.T())
|
||||
R_(new axesRotation(axis, dirn))
|
||||
{}
|
||||
|
||||
|
||||
@ -103,37 +99,35 @@ Foam::coordinateSystem::coordinateSystem
|
||||
name_(name),
|
||||
note_(),
|
||||
origin_(point::zero),
|
||||
R_(),
|
||||
Rtr_(sphericalTensor::I)
|
||||
R_()
|
||||
{
|
||||
operator=(dict);
|
||||
init(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::coordinateSystem::coordinateSystem(const dictionary& dict)
|
||||
:
|
||||
name_(type()),
|
||||
name_(),
|
||||
note_(),
|
||||
origin_(point::zero),
|
||||
R_(),
|
||||
Rtr_(sphericalTensor::I)
|
||||
R_()
|
||||
{
|
||||
operator=(dict);
|
||||
init(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::coordinateSystem::coordinateSystem
|
||||
(
|
||||
const dictionary& dict,
|
||||
const objectRegistry& obr
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
name_(type()),
|
||||
name_(),
|
||||
note_(),
|
||||
origin_(point::zero),
|
||||
R_(),
|
||||
Rtr_(sphericalTensor::I)
|
||||
R_()
|
||||
{
|
||||
|
||||
const entry* entryPtr = dict.lookupEntryPtr(typeName_(), false, false);
|
||||
|
||||
// non-dictionary entry is a lookup into global coordinateSystems
|
||||
@ -170,7 +164,7 @@ Foam::coordinateSystem::coordinateSystem
|
||||
}
|
||||
else
|
||||
{
|
||||
operator=(dict);
|
||||
init(dict, obr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,11 +174,10 @@ Foam::coordinateSystem::coordinateSystem(Istream& is)
|
||||
name_(is),
|
||||
note_(),
|
||||
origin_(point::zero),
|
||||
R_(),
|
||||
Rtr_(sphericalTensor::I)
|
||||
R_()
|
||||
{
|
||||
dictionary dict(is);
|
||||
operator=(dict);
|
||||
init(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -215,8 +208,8 @@ Foam::dictionary Foam::coordinateSystem::dict(bool ignoreType) const
|
||||
}
|
||||
|
||||
dict.add("origin", origin_);
|
||||
dict.add("e1", e1());
|
||||
dict.add("e3", e3());
|
||||
dict.add("e1", R_->e1());
|
||||
dict.add("e3", R_->e3());
|
||||
|
||||
return dict;
|
||||
}
|
||||
@ -230,11 +223,11 @@ Foam::vector Foam::coordinateSystem::localToGlobal
|
||||
{
|
||||
if (translate)
|
||||
{
|
||||
return (R_ & local) + origin_;
|
||||
return (R_->transform(local)) + origin_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (R_ & local);
|
||||
return R_->transform(local);
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,11 +240,11 @@ Foam::tmp<Foam::vectorField> Foam::coordinateSystem::localToGlobal
|
||||
{
|
||||
if (translate)
|
||||
{
|
||||
return (R_ & local) + origin_;
|
||||
return (R_->transform(local)) + origin_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (R_ & local);
|
||||
return R_->transform(local);
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,11 +257,11 @@ Foam::vector Foam::coordinateSystem::globalToLocal
|
||||
{
|
||||
if (translate)
|
||||
{
|
||||
return (Rtr_ & (global - origin_));
|
||||
return R_->invTransform(global - origin_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Rtr_ & global);
|
||||
return R_->invTransform(global);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,11 +274,11 @@ Foam::tmp<Foam::vectorField> Foam::coordinateSystem::globalToLocal
|
||||
{
|
||||
if (translate)
|
||||
{
|
||||
return (Rtr_ & (global - origin_));
|
||||
return R_->invTransform(global - origin_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Rtr_ & global);
|
||||
return R_->invTransform(global);
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,15 +287,14 @@ void Foam::coordinateSystem::clear()
|
||||
{
|
||||
note_.clear();
|
||||
origin_ = point::zero;
|
||||
R_.clear();
|
||||
Rtr_ = sphericalTensor::I;
|
||||
R_->clear();
|
||||
}
|
||||
|
||||
|
||||
void Foam::coordinateSystem::write(Ostream& os) const
|
||||
{
|
||||
os << type()
|
||||
<< " origin: " << origin() << " e1: " << e1() << " e3: " << e3();
|
||||
os << type() << " origin: " << origin() << nl;
|
||||
R_->write(os);
|
||||
}
|
||||
|
||||
|
||||
@ -314,11 +306,8 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
}
|
||||
|
||||
// only write type for derived types
|
||||
if (type() != typeName_())
|
||||
{
|
||||
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
|
||||
}
|
||||
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
|
||||
|
||||
|
||||
// The note entry is optional
|
||||
if (note_.size())
|
||||
@ -327,8 +316,7 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
|
||||
}
|
||||
|
||||
os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
|
||||
R_->write(os);
|
||||
|
||||
if (subDict)
|
||||
{
|
||||
@ -339,7 +327,20 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::coordinateSystem::operator=(const dictionary& rhs)
|
||||
void Foam::coordinateSystem::init(const dictionary& rhs)
|
||||
{
|
||||
rhs.lookup("origin") >> origin_;
|
||||
note_.clear();
|
||||
rhs.readIfPresent("note", note_);
|
||||
R_.reset(coordinateRotation::New(rhs.subDict("coordinateRotation")).ptr());
|
||||
}
|
||||
|
||||
|
||||
void Foam::coordinateSystem::init
|
||||
(
|
||||
const dictionary& rhs,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -347,34 +348,16 @@ void Foam::coordinateSystem::operator=(const dictionary& rhs)
|
||||
<< "assign from " << rhs << endl;
|
||||
}
|
||||
|
||||
// allow as embedded sub-dictionary "coordinateSystem"
|
||||
const dictionary& dict =
|
||||
(
|
||||
rhs.found(typeName_())
|
||||
? rhs.subDict(typeName_())
|
||||
: rhs
|
||||
);
|
||||
|
||||
// unspecified origin is (0 0 0)
|
||||
origin_ = point::zero;
|
||||
dict.readIfPresent("origin", origin_);
|
||||
rhs.lookup("origin") >> origin_;
|
||||
|
||||
// The note entry is optional
|
||||
note_.clear();
|
||||
rhs.readIfPresent("note", note_);
|
||||
|
||||
// specify via coordinateRotation sub-dictionary
|
||||
if (dict.found("coordinateRotation"))
|
||||
{
|
||||
R_ = coordinateRotation::New(dict.subDict("coordinateRotation"))();
|
||||
}
|
||||
else
|
||||
{
|
||||
// let coordinateRotation constructor extract the axes specification
|
||||
R_ = coordinateRotation(dict);
|
||||
}
|
||||
|
||||
Rtr_ = R_.T();
|
||||
R_.reset
|
||||
(
|
||||
coordinateRotation::New(rhs.subDict("coordinateRotation"), obr).ptr()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -382,7 +365,12 @@ void Foam::coordinateSystem::operator=(const dictionary& rhs)
|
||||
|
||||
bool Foam::operator!=(const coordinateSystem& a, const coordinateSystem& b)
|
||||
{
|
||||
return (a.origin() != b.origin() || a.R() != b.R() || a.type() != b.type());
|
||||
return
|
||||
(
|
||||
a.origin() != b.origin()
|
||||
|| a.R().R() != b.R().R()
|
||||
|| a.type() != b.type()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,18 +25,15 @@ Class
|
||||
Foam::coordinateSystem
|
||||
|
||||
Description
|
||||
A cartesian coordinate system and the base class for other coordinate
|
||||
Base class for other coordinate
|
||||
system specifications.
|
||||
|
||||
All systems are defined by an origin point and a coordinateRotation.
|
||||
For convenience, the dictionary constructor forms allow a few shortcuts:
|
||||
- the default origin corresponds to <em>(0 0 0)</em>
|
||||
- if the \c type is not otherwise specified, a Cartesian coordinateSystem
|
||||
is implicit
|
||||
|
||||
\verbatim
|
||||
flipped
|
||||
coordinateSystem
|
||||
{
|
||||
type cartesian;
|
||||
origin (0 0 0);
|
||||
coordinateRotation
|
||||
{
|
||||
@ -46,79 +43,18 @@ Description
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
- if an axes specification (eg, e3/e1) is used, the coordinateRotation
|
||||
sub-dictionary can be dropped.
|
||||
Types of coordinateRotation:
|
||||
1) axesRotation
|
||||
2) STARCDRotation
|
||||
3) localAxesRotation
|
||||
4) EulerCoordinateRotation
|
||||
|
||||
\verbatim
|
||||
flipped // the same, specified as axes
|
||||
{
|
||||
origin (0 0 0);
|
||||
coordinateRotation
|
||||
{
|
||||
type axes;
|
||||
e3 (1 0 0);
|
||||
e1 (0 0 -1);
|
||||
}
|
||||
}
|
||||
flipped // the same, using all the shortcuts
|
||||
{
|
||||
e3 (1 0 0);
|
||||
e1 (0 0 -1);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
- if a sub-dictionary coordinateSystem is found within the dictionary, it
|
||||
will be used. This provides a convenient means of embedding
|
||||
coordinateSystem information in another dictionary.
|
||||
This is used, for example, in the porousZones:
|
||||
|
||||
\verbatim
|
||||
1
|
||||
(
|
||||
cat1
|
||||
{
|
||||
coordinateSystem
|
||||
{
|
||||
origin (0 0 0);
|
||||
coordinateRotation
|
||||
{
|
||||
type STARCDRotation;
|
||||
rotation (0 0 90);
|
||||
}
|
||||
}
|
||||
porosity 0.781;
|
||||
Darcy
|
||||
{
|
||||
d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08);
|
||||
f f [0 -1 0 0 0] (-1000 -1000 12.83);
|
||||
}
|
||||
}
|
||||
)
|
||||
\endverbatim
|
||||
|
||||
- additionally, if the coordinateSystem points to a plain entry,
|
||||
it can be used to reference one of the global coordinateSystems
|
||||
|
||||
\verbatim
|
||||
1
|
||||
(
|
||||
cat1
|
||||
{
|
||||
coordinateSystem system_10;
|
||||
porosity 0.781;
|
||||
Darcy
|
||||
{
|
||||
d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08);
|
||||
f f [0 -1 0 0 0] (-1000 -1000 12.83);
|
||||
}
|
||||
}
|
||||
)
|
||||
\endverbatim
|
||||
For this to work correctly, the coordinateSystem constructor must be
|
||||
supplied with both a dictionary and an objectRegistry.
|
||||
Type of coordinates:
|
||||
1) cartesian
|
||||
2) cylindricalCS
|
||||
|
||||
See Also
|
||||
coordinateSystems and coordinateSystems::New
|
||||
coordinateSystem and coordinateSystem::New
|
||||
|
||||
SourceFiles
|
||||
coordinateSystem.C
|
||||
@ -136,6 +72,7 @@ SourceFiles
|
||||
#include "tmp.H"
|
||||
#include "coordinateRotation.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "autoPtr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -151,19 +88,16 @@ class coordinateSystem
|
||||
// Private data
|
||||
|
||||
//- Name of coordinate system
|
||||
mutable word name_;
|
||||
word name_;
|
||||
|
||||
//- Optional note
|
||||
mutable string note_;
|
||||
string note_;
|
||||
|
||||
//- Origin
|
||||
mutable point origin_;
|
||||
point origin_;
|
||||
|
||||
//- Local-to-Global transformation tensor
|
||||
coordinateRotation R_;
|
||||
|
||||
//- Global-to-Local transformation tensor
|
||||
tensor Rtr_;
|
||||
autoPtr<coordinateRotation> R_;
|
||||
|
||||
|
||||
protected:
|
||||
@ -194,6 +128,12 @@ protected:
|
||||
bool translate
|
||||
) const;
|
||||
|
||||
//- Init from dict and obr
|
||||
void init(const dictionary&);
|
||||
|
||||
//- Init from dictionary
|
||||
void init(const dictionary&, const objectRegistry&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -238,63 +178,47 @@ public:
|
||||
|
||||
//- Construct from dictionary (default name)
|
||||
// With the ability to reference global coordinateSystems
|
||||
coordinateSystem(const dictionary&, const objectRegistry&);
|
||||
coordinateSystem(const objectRegistry&, const dictionary&);
|
||||
|
||||
//- Construct from Istream
|
||||
// The Istream contains a word followed by a dictionary
|
||||
coordinateSystem(Istream&);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<coordinateSystem> clone() const
|
||||
{
|
||||
return autoPtr<coordinateSystem>(new coordinateSystem(*this));
|
||||
}
|
||||
|
||||
//- Return clone
|
||||
autoPtr<coordinateSystem> clone() const
|
||||
{
|
||||
return autoPtr<coordinateSystem>(new coordinateSystem(*this));
|
||||
}
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
coordinateSystem,
|
||||
dictionary,
|
||||
(
|
||||
autoPtr,
|
||||
coordinateSystem,
|
||||
dictionary,
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
),
|
||||
(name, dict)
|
||||
);
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
coordinateSystem,
|
||||
origRotation,
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation& cr
|
||||
),
|
||||
(name, origin, cr)
|
||||
);
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
),
|
||||
(obr, dict)
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from dictionary and objectRegistry
|
||||
static autoPtr<coordinateSystem> New
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Select constructed from dictionary
|
||||
static autoPtr<coordinateSystem> New
|
||||
(
|
||||
const word& name,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Select constructed from origin and rotation
|
||||
static autoPtr<coordinateSystem> New
|
||||
(
|
||||
const word& coordType,
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation&
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Select constructed from Istream
|
||||
@ -307,6 +231,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return name
|
||||
@ -333,49 +258,18 @@ public:
|
||||
return origin_;
|
||||
}
|
||||
|
||||
//- Return coordinate rotation
|
||||
const coordinateRotation& rotation() const
|
||||
//- Return const reference to coordinate rotation
|
||||
const coordinateRotation& R() const
|
||||
{
|
||||
return R_;
|
||||
return R_();
|
||||
}
|
||||
|
||||
//- Return local-to-global transformation tensor
|
||||
const tensor& R() const
|
||||
//- Return non const reference to coordinate rotation
|
||||
coordinateRotation& R()
|
||||
{
|
||||
return R_;
|
||||
return R_();
|
||||
}
|
||||
|
||||
//- Return local Cartesian x-axis
|
||||
const vector e1() const
|
||||
{
|
||||
return Rtr_.x();
|
||||
}
|
||||
|
||||
//- Return local Cartesian y-axis
|
||||
const vector e2() const
|
||||
{
|
||||
return Rtr_.y();
|
||||
}
|
||||
|
||||
//- Return local Cartesian z-axis
|
||||
const vector e3() const
|
||||
{
|
||||
return Rtr_.z();
|
||||
}
|
||||
|
||||
//- Return axis (e3: local Cartesian z-axis)
|
||||
// \deprecated method e3 is preferred (deprecated Apr 2008)
|
||||
const vector axis() const
|
||||
{
|
||||
return Rtr_.z();
|
||||
}
|
||||
|
||||
//- Return direction (e1: local Cartesian x-axis)
|
||||
// \deprecated method e1 is preferred (deprecated Apr 2008)
|
||||
const vector direction() const
|
||||
{
|
||||
return Rtr_.x();
|
||||
}
|
||||
|
||||
//- Return as dictionary of entries
|
||||
// \param [in] ignoreType drop type (cartesian, cylindrical, etc)
|
||||
@ -386,7 +280,7 @@ public:
|
||||
// Edit
|
||||
|
||||
//- Rename
|
||||
virtual void rename(const word& newName)
|
||||
void rename(const word& newName)
|
||||
{
|
||||
name_ = newName;
|
||||
}
|
||||
@ -408,7 +302,7 @@ public:
|
||||
virtual void write(Ostream&) const;
|
||||
|
||||
//- Write dictionary
|
||||
virtual void writeDict(Ostream&, bool subDict=true) const;
|
||||
void writeDict(Ostream&, bool subDict=true) const;
|
||||
|
||||
|
||||
// Transformations
|
||||
@ -472,22 +366,18 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- assign from dictionary
|
||||
void operator=(const dictionary&);
|
||||
// friend Operators
|
||||
|
||||
friend bool operator!=
|
||||
(
|
||||
const coordinateSystem&,
|
||||
const coordinateSystem&
|
||||
);
|
||||
|
||||
|
||||
// friend Operators
|
||||
// IOstream Operators
|
||||
|
||||
friend bool operator!=
|
||||
(
|
||||
const coordinateSystem&,
|
||||
const coordinateSystem&
|
||||
);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const coordinateSystem&);
|
||||
friend Ostream& operator<<(Ostream&, const coordinateSystem&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -30,7 +30,7 @@ License
|
||||
|
||||
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
@ -41,17 +41,8 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// construct base class directly, also allow 'cartesian' as an alias
|
||||
word coordType(typeName_());
|
||||
if
|
||||
(
|
||||
!dict.readIfPresent("type", coordType)
|
||||
|| coordType == typeName_()
|
||||
|| coordType == "cartesian"
|
||||
)
|
||||
{
|
||||
return autoPtr<coordinateSystem>(new coordinateSystem(name, dict));
|
||||
}
|
||||
const dictionary& coordDict = dict.subDict(typeName_());
|
||||
word coordType = coordDict.lookup("type");
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(coordType);
|
||||
@ -60,20 +51,54 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"coordinateSystem::New(const word&, const dictionary&)",
|
||||
"coordinateSystem::New(const objectRegistry&, const dictionary&)",
|
||||
dict
|
||||
) << "Unknown coordinateSystem type "
|
||||
<< coordType << nl << nl
|
||||
<< "Valid coordinateSystem types are :" << nl
|
||||
<< "[default: " << typeName_() << "]"
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<coordinateSystem>(cstrIter()(name, dict));
|
||||
return autoPtr<coordinateSystem>(cstrIter()(obr, coordDict));
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "coordinateSystem::New(cconst dictionary&) : "
|
||||
<< "constructing coordinateSystem"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const dictionary& coordDict = dict.subDict(typeName_());
|
||||
word coordType = coordDict.lookup("type");
|
||||
/*
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(coordType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"coordinateSystem::New(const dictionary&)",
|
||||
dict
|
||||
) << "Unknown coordinateSystem type "
|
||||
<< coordType << nl << nl
|
||||
<< "Valid coordinateSystem types are :" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
*/
|
||||
return autoPtr<coordinateSystem>(new coordinateSystem(coordDict));
|
||||
}
|
||||
|
||||
/*
|
||||
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
(
|
||||
const word& coordType,
|
||||
@ -109,7 +134,7 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
|
||||
return autoPtr<coordinateSystem>(cstrIter()(name, origin, cr));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
(
|
||||
@ -119,7 +144,26 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
const word name(is);
|
||||
const dictionary dict(is);
|
||||
|
||||
return New(name, dict);
|
||||
word coordType = dict.lookup("type");
|
||||
/*
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(coordType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"coordinateSystem::New(Istream& is)",
|
||||
dict
|
||||
) << "Unknown coordinateSystem type "
|
||||
<< coordType << nl << nl
|
||||
<< "Valid coordinateSystem types are :" << nl
|
||||
<< "[default: " << typeName_() << "]"
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
*/
|
||||
return autoPtr<coordinateSystem>(new coordinateSystem(name, dict));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,6 +31,25 @@ Note
|
||||
Mixing normal constructors and the coordinateSystems::New constructor
|
||||
may yield unexpected results.
|
||||
|
||||
\verbatim
|
||||
1
|
||||
(
|
||||
cat1
|
||||
{
|
||||
coordinateSystem system_10;
|
||||
porosity 0.781;
|
||||
Darcy
|
||||
{
|
||||
d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08);
|
||||
f f [0 -1 0 0 0] (-1000 -1000 12.83);
|
||||
}
|
||||
}
|
||||
)
|
||||
\endverbatim
|
||||
|
||||
For this to work correctly, the coordinateSystem constructor must be
|
||||
supplied with both a dictionary and an objectRegistry.
|
||||
|
||||
SourceFiles
|
||||
coordinateSystems.C
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -35,7 +35,6 @@ namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cylindricalCS, 0);
|
||||
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary);
|
||||
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, origRotation);
|
||||
}
|
||||
|
||||
|
||||
@ -109,6 +108,23 @@ Foam::cylindricalCS::cylindricalCS
|
||||
{}
|
||||
|
||||
|
||||
Foam::cylindricalCS::cylindricalCS
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateSystem(obr, dict),
|
||||
inDegrees_(dict.lookupOrDefault("degrees", true))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cylindricalCS::~cylindricalCS()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::cylindricalCS::inDegrees() const
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -61,6 +61,7 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
virtual vector localToGlobal(const vector&, bool translate) const;
|
||||
@ -131,8 +132,15 @@ public:
|
||||
const bool inDegrees=true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
cylindricalCS(const word& name, const dictionary&);
|
||||
//- Construct from dictionary and name
|
||||
cylindricalCS(const word&, const dictionary&);
|
||||
|
||||
//- Construct from dictionary and objectRegistry
|
||||
cylindricalCS(const objectRegistry&, const dictionary&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cylindricalCS();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -1,177 +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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "parabolicCylindricalCS.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(parabolicCylindricalCS, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
coordinateSystem,
|
||||
parabolicCylindricalCS,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::parabolicCylindricalCS::parabolicCylindricalCS()
|
||||
:
|
||||
coordinateSystem()
|
||||
{}
|
||||
|
||||
|
||||
Foam::parabolicCylindricalCS::parabolicCylindricalCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation& cr
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, origin, cr)
|
||||
{}
|
||||
|
||||
|
||||
Foam::parabolicCylindricalCS::parabolicCylindricalCS
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::parabolicCylindricalCS::localToGlobal
|
||||
(
|
||||
const vector& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
// Notation: u = local.x() v = local.y() z = local.z();
|
||||
if (local.y() < 0.0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"parabolicCylindricalCS::localToGlobal(const vector&, bool) const"
|
||||
)
|
||||
<< "parabolic cylindrical coordinates v < 0"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return coordinateSystem::localToGlobal
|
||||
(
|
||||
vector
|
||||
(
|
||||
0.5*(sqr(local.x()) - sqr(local.y())),
|
||||
local.x()*local.y(),
|
||||
local.z()
|
||||
),
|
||||
translate
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::parabolicCylindricalCS::localToGlobal
|
||||
(
|
||||
const vectorField& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
if (min(local.component(vector::Y)) < 0.0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"parabolicCylindricalCS::localToGlobal"
|
||||
"(const vectorField&, bool) const"
|
||||
) << "parabolic cylindrical coordinates v < 0"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
vectorField lc(local.size());
|
||||
lc.replace
|
||||
(
|
||||
vector::X,
|
||||
0.5*
|
||||
(
|
||||
sqr(local.component(vector::X))
|
||||
- sqr(local.component(vector::Y))
|
||||
)
|
||||
);
|
||||
|
||||
lc.replace
|
||||
(
|
||||
vector::Y,
|
||||
local.component(vector::X) * local.component(vector::Y)
|
||||
);
|
||||
|
||||
lc.replace
|
||||
(
|
||||
vector::Z,
|
||||
local.component(vector::Z)
|
||||
);
|
||||
|
||||
return coordinateSystem::localToGlobal(lc, translate);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::parabolicCylindricalCS::globalToLocal
|
||||
(
|
||||
const vector& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"parabolicCylindricalCS::globalToLocal(const vector&, bool) const"
|
||||
);
|
||||
|
||||
return vector::zero;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::parabolicCylindricalCS::globalToLocal
|
||||
(
|
||||
const vectorField& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"parabolicCylindricalCS::globalToLocal(const vectorField&, bool) const"
|
||||
);
|
||||
|
||||
return tmp<vectorField>(vectorField::null());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,244 +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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sphericalCS.H"
|
||||
|
||||
#include "one.H"
|
||||
#include "mathematicalConstants.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sphericalCS, 0);
|
||||
addToRunTimeSelectionTable(coordinateSystem, sphericalCS, dictionary);
|
||||
addToRunTimeSelectionTable(coordinateSystem, sphericalCS, origRotation);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sphericalCS::sphericalCS(const bool inDegrees)
|
||||
:
|
||||
coordinateSystem(),
|
||||
inDegrees_(inDegrees)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sphericalCS::sphericalCS
|
||||
(
|
||||
const coordinateSystem& cs,
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateSystem(cs),
|
||||
inDegrees_(inDegrees)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sphericalCS::sphericalCS
|
||||
(
|
||||
const word& name,
|
||||
const coordinateSystem& cs,
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, cs),
|
||||
inDegrees_(inDegrees)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sphericalCS::sphericalCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation& cr,
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, origin, cr),
|
||||
inDegrees_(inDegrees)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sphericalCS::sphericalCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const vector& axis,
|
||||
const vector& dirn,
|
||||
const bool inDegrees
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, origin, axis, dirn),
|
||||
inDegrees_(inDegrees)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sphericalCS::sphericalCS
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, dict),
|
||||
inDegrees_(dict.lookupOrDefault("degrees", true))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sphericalCS::inDegrees() const
|
||||
{
|
||||
return inDegrees_;
|
||||
}
|
||||
|
||||
|
||||
bool& Foam::sphericalCS::inDegrees()
|
||||
{
|
||||
return inDegrees_;
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::sphericalCS::localToGlobal
|
||||
(
|
||||
const vector& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
scalar r = local.x();
|
||||
const scalar theta
|
||||
(
|
||||
local.y()
|
||||
*(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0)
|
||||
);
|
||||
const scalar phi
|
||||
(
|
||||
local.z()
|
||||
*(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0)
|
||||
);
|
||||
|
||||
return coordinateSystem::localToGlobal
|
||||
(
|
||||
vector(r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi)),
|
||||
translate
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sphericalCS::localToGlobal
|
||||
(
|
||||
const vectorField& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
const scalarField r(local.component(vector::X));
|
||||
const scalarField theta
|
||||
(
|
||||
local.component(vector::Y)
|
||||
*(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0)
|
||||
);
|
||||
const scalarField phi
|
||||
(
|
||||
local.component(vector::Z)
|
||||
*(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0)
|
||||
);
|
||||
|
||||
vectorField lc(local.size());
|
||||
lc.replace(vector::X, r*cos(theta)*sin(phi));
|
||||
lc.replace(vector::Y, r*sin(theta)*sin(phi));
|
||||
lc.replace(vector::Z, r*cos(phi));
|
||||
|
||||
return coordinateSystem::localToGlobal(lc, translate);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::sphericalCS::globalToLocal
|
||||
(
|
||||
const vector& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
const vector lc = coordinateSystem::globalToLocal(global, translate);
|
||||
const scalar r = mag(lc);
|
||||
|
||||
return vector
|
||||
(
|
||||
r,
|
||||
atan2
|
||||
(
|
||||
lc.y(), lc.x()
|
||||
)*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0),
|
||||
acos
|
||||
(
|
||||
lc.z()/(r + SMALL)
|
||||
)*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sphericalCS::globalToLocal
|
||||
(
|
||||
const vectorField& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
const vectorField lc(coordinateSystem::globalToLocal(global, translate));
|
||||
const scalarField r(mag(lc));
|
||||
|
||||
tmp<vectorField> tresult(new vectorField(lc.size()));
|
||||
vectorField& result = tresult();
|
||||
|
||||
result.replace
|
||||
(
|
||||
vector::X, r
|
||||
|
||||
);
|
||||
|
||||
result.replace
|
||||
(
|
||||
vector::Y,
|
||||
atan2
|
||||
(
|
||||
lc.component(vector::Y),
|
||||
lc.component(vector::X)
|
||||
)*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0)
|
||||
);
|
||||
|
||||
result.replace
|
||||
(
|
||||
vector::Z,
|
||||
acos
|
||||
(
|
||||
lc.component(vector::Z)/(r + SMALL)
|
||||
)*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0)
|
||||
);
|
||||
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,184 +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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "toroidalCS.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "unitConversion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(toroidalCS, 0);
|
||||
addToRunTimeSelectionTable(coordinateSystem, toroidalCS, dictionary);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
Foam::toroidalCS::toroidalCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation& cr,
|
||||
const scalar radius
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, origin, cr),
|
||||
radius_(radius)
|
||||
{}
|
||||
|
||||
|
||||
Foam::toroidalCS::toroidalCS
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordinateSystem(name, dict),
|
||||
radius_(readScalar(dict.lookup("radius")))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::toroidalCS::localToGlobal
|
||||
(
|
||||
const vector& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
// Notation: r = local.x()
|
||||
scalar theta = degToRad(local.y());
|
||||
scalar phi = degToRad(local.z());
|
||||
|
||||
scalar rprime = radius_ + local.x()*sin(phi);
|
||||
|
||||
if ((local.x()*sin(phi)) > (radius_))
|
||||
{
|
||||
FatalErrorIn("toroidalCS::toGlobal(vector) const")
|
||||
<< "Badly defined toroidal coordinates"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return coordinateSystem::localToGlobal
|
||||
(
|
||||
vector(rprime*cos(theta), rprime*sin(theta), local.x()*cos(phi)),
|
||||
translate
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::toroidalCS::localToGlobal
|
||||
(
|
||||
const vectorField& local,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
const scalarField r
|
||||
(
|
||||
local.component(vector::X)
|
||||
);
|
||||
|
||||
const scalarField theta
|
||||
(
|
||||
local.component(vector::Y)*constant::mathematical::pi/180.0
|
||||
);
|
||||
|
||||
const scalarField phi
|
||||
(
|
||||
local.component(vector::Z)*constant::mathematical::pi/180.0
|
||||
);
|
||||
|
||||
const scalarField rprime
|
||||
(
|
||||
radius_ + r*sin(phi)
|
||||
);
|
||||
|
||||
vectorField lc(local.size());
|
||||
lc.replace(vector::X, rprime*cos(theta));
|
||||
lc.replace(vector::Y, rprime*sin(theta));
|
||||
lc.replace(vector::Z, r*cos(phi));
|
||||
|
||||
return coordinateSystem::localToGlobal(lc, translate);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::toroidalCS::globalToLocal
|
||||
(
|
||||
const vector& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"toroidalCS::globalToLocal(const vector&, bool) const"
|
||||
);
|
||||
|
||||
return vector::zero;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::toroidalCS::globalToLocal
|
||||
(
|
||||
const vectorField& global,
|
||||
bool translate
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"toroidalCS::globalToLocal(const vectorField&, bool) const"
|
||||
);
|
||||
|
||||
return tmp<vectorField>(vectorField::null());
|
||||
}
|
||||
|
||||
|
||||
void Foam::toroidalCS::write(Ostream& os) const
|
||||
{
|
||||
coordinateSystem::write(os);
|
||||
os << "radius: " << radius() << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::toroidalCS::writeDict(Ostream& os, bool subDict) const
|
||||
{
|
||||
if (subDict)
|
||||
{
|
||||
os << indent << name() << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
}
|
||||
|
||||
coordinateSystem::writeDict(os, false);
|
||||
os.writeKeyword("radius") << radius() << token::END_STATEMENT << nl;
|
||||
|
||||
if (subDict)
|
||||
{
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,133 +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::toroidalCS
|
||||
|
||||
Description
|
||||
Toroidal coordinate system, always in degrees
|
||||
|
||||
Note
|
||||
The maintenance of this class may lag that of the main types.
|
||||
|
||||
SourceFiles
|
||||
toroidalCS.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef toroidalCS_H
|
||||
#define toroidalCS_H
|
||||
|
||||
#include "coordinateSystem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class toroidalCS Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class toroidalCS
|
||||
:
|
||||
public coordinateSystem
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Radius of the torus
|
||||
scalar radius_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
virtual vector localToGlobal(const vector&, bool translate) const;
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
virtual tmp<vectorField> localToGlobal
|
||||
(
|
||||
const vectorField&,
|
||||
bool translate
|
||||
) const;
|
||||
|
||||
//- Convert from global Cartesian system to the local coordinate system
|
||||
// with optional translation for the origin
|
||||
virtual vector globalToLocal(const vector&, bool translate) const;
|
||||
|
||||
//- Convert from global Cartesian system to the local coordinate system
|
||||
// with optional translation for the origin
|
||||
virtual tmp<vectorField> globalToLocal
|
||||
(
|
||||
const vectorField&,
|
||||
bool translate
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("toroidal");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from origin, rotation and radius
|
||||
toroidalCS
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation&,
|
||||
const scalar radius
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
toroidalCS(const word& name, const dictionary&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return radius
|
||||
scalar radius() const
|
||||
{
|
||||
return radius_;
|
||||
}
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
|
||||
//- Write dictionary
|
||||
virtual void writeDict(Ostream&, bool subDict=true) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -160,7 +160,11 @@ void Foam::treeDataPoint::findNearest
|
||||
) const
|
||||
{
|
||||
// Best so far
|
||||
scalar nearestDistSqr = magSqr(linePoint - nearestPoint);
|
||||
scalar nearestDistSqr = GREAT;
|
||||
if (minIndex >= 0)
|
||||
{
|
||||
nearestDistSqr = magSqr(linePoint - nearestPoint);
|
||||
}
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -404,11 +404,50 @@ void Foam::treeDataTriSurface::findNearest
|
||||
point& nearestPoint
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"treeDataTriSurface::findNearest(const labelUList&"
|
||||
", const linePointRef&, treeBoundBox&, label&, point&, point&) const"
|
||||
);
|
||||
// Best so far
|
||||
scalar nearestDistSqr = VGREAT;
|
||||
if (minIndex >= 0)
|
||||
{
|
||||
nearestDistSqr = magSqr(linePoint - nearestPoint);
|
||||
}
|
||||
|
||||
const pointField& points = surface_.points();
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const triSurface::FaceType& f = surface_[index];
|
||||
|
||||
triPointRef tri(f.tri(points));
|
||||
|
||||
pointHit lineInfo(point::max);
|
||||
pointHit pHit = tri.nearestPoint(ln, lineInfo);
|
||||
|
||||
scalar distSqr = sqr(pHit.distance());
|
||||
|
||||
if (distSqr < nearestDistSqr)
|
||||
{
|
||||
nearestDistSqr = distSqr;
|
||||
minIndex = index;
|
||||
linePoint = lineInfo.rawPoint();
|
||||
nearestPoint = pHit.rawPoint();
|
||||
|
||||
{
|
||||
point& minPt = tightest.min();
|
||||
minPt = min(ln.start(), ln.end());
|
||||
minPt.x() -= pHit.distance();
|
||||
minPt.y() -= pHit.distance();
|
||||
minPt.z() -= pHit.distance();
|
||||
}
|
||||
{
|
||||
point& maxPt = tightest.max();
|
||||
maxPt = max(ln.start(), ln.end());
|
||||
maxPt.x() += pHit.distance();
|
||||
maxPt.y() += pHit.distance();
|
||||
maxPt.z() += pHit.distance();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -849,6 +849,7 @@ void Foam::mappedPatchBase::calcAMI() const
|
||||
samplePolyPatch(), // nbrPatch0,
|
||||
surfPtr(),
|
||||
faceAreaIntersect::tmMesh,
|
||||
AMIPatchToPatchInterpolation::imFaceAreaWeight,
|
||||
AMIReverse_
|
||||
)
|
||||
);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -40,7 +40,12 @@ Foam::meshSearchFACECENTRETETSMeshObject::meshSearchFACECENTRETETSMeshObject
|
||||
const polyMesh& mesh
|
||||
)
|
||||
:
|
||||
MeshObject<polyMesh, meshSearchFACECENTRETETSMeshObject>(mesh),
|
||||
MeshObject
|
||||
<
|
||||
polyMesh,
|
||||
Foam::GeometricMeshObject,
|
||||
meshSearchFACECENTRETETSMeshObject
|
||||
>(mesh),
|
||||
meshSearch(mesh, polyMesh::FACECENTRETETS)
|
||||
{}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -48,7 +48,12 @@ namespace Foam
|
||||
|
||||
class meshSearchFACECENTRETETSMeshObject
|
||||
:
|
||||
public MeshObject<polyMesh, meshSearchFACECENTRETETSMeshObject>,
|
||||
public MeshObject
|
||||
<
|
||||
polyMesh,
|
||||
GeometricMeshObject,
|
||||
meshSearchFACECENTRETETSMeshObject
|
||||
>,
|
||||
public meshSearch
|
||||
{
|
||||
|
||||
@ -66,18 +71,6 @@ public:
|
||||
//- Destructor
|
||||
virtual ~meshSearchFACECENTRETETSMeshObject()
|
||||
{}
|
||||
|
||||
//
|
||||
// // Member functions
|
||||
//
|
||||
// // Edit
|
||||
//
|
||||
// //- Update mesh topology using the morph engine
|
||||
// void updateMesh();
|
||||
//
|
||||
// //- Correct weighting factors for moving mesh.
|
||||
// bool movePoints();
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,7 +37,7 @@ namespace Foam
|
||||
|
||||
Foam::meshSearchMeshObject::meshSearchMeshObject(const polyMesh& mesh)
|
||||
:
|
||||
MeshObject<polyMesh, meshSearchMeshObject>(mesh),
|
||||
MeshObject<polyMesh, Foam::GeometricMeshObject, meshSearchMeshObject>(mesh),
|
||||
meshSearch(mesh)
|
||||
{}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -48,7 +48,7 @@ namespace Foam
|
||||
|
||||
class meshSearchMeshObject
|
||||
:
|
||||
public MeshObject<polyMesh, meshSearchMeshObject>,
|
||||
public MeshObject<polyMesh, GeometricMeshObject, meshSearchMeshObject>,
|
||||
public meshSearch
|
||||
{
|
||||
|
||||
@ -66,18 +66,6 @@ public:
|
||||
//- Destructor
|
||||
virtual ~meshSearchMeshObject()
|
||||
{}
|
||||
|
||||
//
|
||||
// // Member functions
|
||||
//
|
||||
// // Edit
|
||||
//
|
||||
// //- Update mesh topology using the morph engine
|
||||
// void updateMesh();
|
||||
//
|
||||
// //- Correct weighting factors for moving mesh.
|
||||
// bool movePoints();
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
|
||||
387
src/meshTools/meshStructure/meshStructure.C
Normal file
387
src/meshTools/meshStructure/meshStructure.C
Normal file
@ -0,0 +1,387 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "meshStructure.H"
|
||||
#include "FaceCellWave.H"
|
||||
#include "topoDistanceData.H"
|
||||
#include "pointTopoDistanceData.H"
|
||||
#include "PointEdgeWave.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(meshStructure, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::meshStructure::isStructuredCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label layerI,
|
||||
const label cellI
|
||||
) const
|
||||
{
|
||||
const cell& cFaces = mesh.cells()[cellI];
|
||||
|
||||
// Count number of side faces
|
||||
label nSide = 0;
|
||||
forAll(cFaces, i)
|
||||
{
|
||||
if (faceToPatchEdgeAddressing_[cFaces[i]] != -1)
|
||||
{
|
||||
nSide++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nSide != cFaces.size()-2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that side faces have correct point layers
|
||||
forAll(cFaces, i)
|
||||
{
|
||||
if (faceToPatchEdgeAddressing_[cFaces[i]] != -1)
|
||||
{
|
||||
const face& f = mesh.faces()[cFaces[i]];
|
||||
|
||||
label nLayer = 0;
|
||||
label nLayerPlus1 = 0;
|
||||
forAll(f, fp)
|
||||
{
|
||||
label pointI = f[fp];
|
||||
if (pointLayer_[pointI] == layerI)
|
||||
{
|
||||
nLayer++;
|
||||
}
|
||||
else if (pointLayer_[pointI] == layerI+1)
|
||||
{
|
||||
nLayerPlus1++;
|
||||
}
|
||||
}
|
||||
|
||||
if (f.size() != 4 || (nLayer+nLayerPlus1 != 4))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshStructure::correct
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const uindirectPrimitivePatch& pp
|
||||
)
|
||||
{
|
||||
// Field on cells and faces.
|
||||
List<topoDistanceData> cellData(mesh.nCells());
|
||||
List<topoDistanceData> faceData(mesh.nFaces());
|
||||
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< typeName << " : seeding "
|
||||
<< returnReduce(pp.size(), sumOp<label>()) << " patch faces"
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
|
||||
// Start of changes
|
||||
labelList patchFaces(pp.size());
|
||||
List<topoDistanceData> patchData(pp.size());
|
||||
forAll(pp, patchFaceI)
|
||||
{
|
||||
patchFaces[patchFaceI] = pp.addressing()[patchFaceI];
|
||||
patchData[patchFaceI] = topoDistanceData(patchFaceI, 0);
|
||||
}
|
||||
|
||||
|
||||
// Propagate information inwards
|
||||
FaceCellWave<topoDistanceData> distanceCalc
|
||||
(
|
||||
mesh,
|
||||
patchFaces,
|
||||
patchData,
|
||||
faceData,
|
||||
cellData,
|
||||
mesh.globalData().nTotalCells()+1
|
||||
);
|
||||
|
||||
|
||||
// Determine cells from face-cell-walk
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
cellToPatchFaceAddressing_.setSize(mesh.nCells());
|
||||
cellLayer_.setSize(mesh.nCells());
|
||||
forAll(cellToPatchFaceAddressing_, cellI)
|
||||
{
|
||||
cellToPatchFaceAddressing_[cellI] = cellData[cellI].data();
|
||||
cellLayer_[cellI] = cellData[cellI].distance();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Determine faces from face-cell-walk
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
faceToPatchFaceAddressing_.setSize(mesh.nFaces());
|
||||
faceToPatchEdgeAddressing_.setSize(mesh.nFaces());
|
||||
faceToPatchEdgeAddressing_ = labelMin;
|
||||
faceLayer_.setSize(mesh.nFaces());
|
||||
|
||||
forAll(faceToPatchFaceAddressing_, faceI)
|
||||
{
|
||||
label own = mesh.faceOwner()[faceI];
|
||||
label patchFaceI = faceData[faceI].data();
|
||||
label patchDist = faceData[faceI].distance();
|
||||
|
||||
if (mesh.isInternalFace(faceI))
|
||||
{
|
||||
label nei = mesh.faceNeighbour()[faceI];
|
||||
|
||||
if (cellData[own].distance() == cellData[nei].distance())
|
||||
{
|
||||
// side face
|
||||
faceToPatchFaceAddressing_[faceI] = 0;
|
||||
faceLayer_[faceI] = cellData[own].distance();
|
||||
}
|
||||
else if (cellData[own].distance() < cellData[nei].distance())
|
||||
{
|
||||
// unturned face
|
||||
faceToPatchFaceAddressing_[faceI] = patchFaceI+1;
|
||||
faceToPatchEdgeAddressing_[faceI] = -1;
|
||||
faceLayer_[faceI] = patchDist;
|
||||
}
|
||||
else
|
||||
{
|
||||
// turned face
|
||||
faceToPatchFaceAddressing_[faceI] = -(patchFaceI+1);
|
||||
faceToPatchEdgeAddressing_[faceI] = -1;
|
||||
faceLayer_[faceI] = patchDist;
|
||||
}
|
||||
}
|
||||
else if (patchDist == cellData[own].distance())
|
||||
{
|
||||
// starting face
|
||||
faceToPatchFaceAddressing_[faceI] = -(patchFaceI+1);
|
||||
faceToPatchEdgeAddressing_[faceI] = -1;
|
||||
faceLayer_[faceI] = patchDist;
|
||||
}
|
||||
else
|
||||
{
|
||||
// unturned face or side face. Cannot be determined until
|
||||
// we determine the point layers. Problem is that both are
|
||||
// the same number of steps away from the initial seed face.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Determine points from separate walk on point-edge
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
{
|
||||
pointToPatchPointAddressing_.setSize(mesh.nPoints());
|
||||
pointLayer_.setSize(mesh.nPoints());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< typeName << " : seeding "
|
||||
<< returnReduce(pp.nPoints(), sumOp<label>()) << " patch points"
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
// Field on edges and points.
|
||||
List<pointTopoDistanceData> edgeData(mesh.nEdges());
|
||||
List<pointTopoDistanceData> pointData(mesh.nPoints());
|
||||
|
||||
// Start of changes
|
||||
labelList patchPoints(pp.nPoints());
|
||||
List<pointTopoDistanceData> patchData(pp.nPoints());
|
||||
forAll(pp.meshPoints(), patchPointI)
|
||||
{
|
||||
patchPoints[patchPointI] = pp.meshPoints()[patchPointI];
|
||||
patchData[patchPointI] = pointTopoDistanceData(patchPointI, 0);
|
||||
}
|
||||
|
||||
|
||||
// Walk
|
||||
PointEdgeWave<pointTopoDistanceData> distanceCalc
|
||||
(
|
||||
mesh,
|
||||
patchPoints,
|
||||
patchData,
|
||||
|
||||
pointData,
|
||||
edgeData,
|
||||
mesh.globalData().nTotalPoints() // max iterations
|
||||
);
|
||||
|
||||
forAll(pointData, pointI)
|
||||
{
|
||||
pointToPatchPointAddressing_[pointI] = pointData[pointI].data();
|
||||
pointLayer_[pointI] = pointData[pointI].distance();
|
||||
}
|
||||
|
||||
|
||||
// Derive from originating patch points what the patch edges were.
|
||||
EdgeMap<label> pointsToEdge(pp.nEdges());
|
||||
forAll(pp.edges(), edgeI)
|
||||
{
|
||||
pointsToEdge.insert(pp.edges()[edgeI], edgeI);
|
||||
}
|
||||
|
||||
// Look up on faces
|
||||
forAll(faceToPatchEdgeAddressing_, faceI)
|
||||
{
|
||||
if (faceToPatchEdgeAddressing_[faceI] == labelMin)
|
||||
{
|
||||
// Face not yet done. Check if all points on same level
|
||||
// or if not see what edge it originates from
|
||||
|
||||
const face& f = mesh.faces()[faceI];
|
||||
|
||||
label levelI = pointLayer_[f[0]];
|
||||
for (label fp = 1; fp < f.size(); fp++)
|
||||
{
|
||||
if (pointLayer_[f[fp]] != levelI)
|
||||
{
|
||||
levelI = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (levelI != -1)
|
||||
{
|
||||
// All same level
|
||||
//Pout<< "Horizontal boundary face " << faceI
|
||||
// << " at:" << mesh.faceCentres()[faceI]
|
||||
// << " data:" << faceData[faceI]
|
||||
// << " pointDatas:"
|
||||
// << UIndirectList<pointTopoDistanceData>(pointData, f)
|
||||
// << endl;
|
||||
|
||||
label patchFaceI = faceData[faceI].data();
|
||||
label patchDist = faceData[faceI].distance();
|
||||
|
||||
faceToPatchEdgeAddressing_[faceI] = -1;
|
||||
faceToPatchFaceAddressing_[faceI] = patchFaceI+1;
|
||||
faceLayer_[faceI] = patchDist;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Points of face on different levels
|
||||
|
||||
// See if there is any edge
|
||||
forAll(f, fp)
|
||||
{
|
||||
label pointI = f[fp];
|
||||
label nextPointI = f.nextLabel(fp);
|
||||
|
||||
EdgeMap<label>::const_iterator fnd = pointsToEdge.find
|
||||
(
|
||||
edge
|
||||
(
|
||||
pointData[pointI].data(),
|
||||
pointData[nextPointI].data()
|
||||
)
|
||||
);
|
||||
if (fnd != pointsToEdge.end())
|
||||
{
|
||||
faceToPatchEdgeAddressing_[faceI] = fnd();
|
||||
faceToPatchFaceAddressing_[faceI] = 0;
|
||||
label own = mesh.faceOwner()[faceI];
|
||||
faceLayer_[faceI] = cellData[own].distance();
|
||||
|
||||
// Note: could test whether the other edges on the
|
||||
// face are consistent
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Use maps to find out mesh structure.
|
||||
{
|
||||
label nLayers = gMax(cellLayer_)+1;
|
||||
labelListList layerToCells(invertOneToMany(nLayers, cellLayer_));
|
||||
|
||||
structured_ = true;
|
||||
forAll(layerToCells, layerI)
|
||||
{
|
||||
const labelList& lCells = layerToCells[layerI];
|
||||
|
||||
forAll(lCells, lCellI)
|
||||
{
|
||||
label cellI = lCells[lCellI];
|
||||
|
||||
structured_ = isStructuredCell
|
||||
(
|
||||
mesh,
|
||||
layerI,
|
||||
cellI
|
||||
);
|
||||
|
||||
if (!structured_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!structured_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reduce(structured_, andOp<bool>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::meshStructure::meshStructure
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const uindirectPrimitivePatch& pp
|
||||
)
|
||||
{
|
||||
correct(mesh, pp);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
175
src/meshTools/meshStructure/meshStructure.H
Normal file
175
src/meshTools/meshStructure/meshStructure.H
Normal file
@ -0,0 +1,175 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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::meshStructure
|
||||
|
||||
Description
|
||||
Detect extruded mesh structure given a set of patch faces.
|
||||
|
||||
SourceFiles
|
||||
meshStructure.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef meshStructure_H
|
||||
#define meshStructure_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
#include "className.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyMesh;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class meshStructure Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class meshStructure
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Cell to patch face
|
||||
labelList cellToPatchFaceAddressing_;
|
||||
|
||||
//- Cell to layer
|
||||
labelList cellLayer_;
|
||||
|
||||
//- Face to patch face
|
||||
labelList faceToPatchFaceAddressing_;
|
||||
|
||||
//- Face to patch edge
|
||||
labelList faceToPatchEdgeAddressing_;
|
||||
|
||||
//- Face to layer
|
||||
labelList faceLayer_;
|
||||
|
||||
//- Point to patch point
|
||||
labelList pointToPatchPointAddressing_;
|
||||
|
||||
//- Point to layer
|
||||
labelList pointLayer_;
|
||||
|
||||
//- Is mesh structured?
|
||||
bool structured_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Is cell structured
|
||||
bool isStructuredCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label layerI,
|
||||
const label cellI
|
||||
) const;
|
||||
|
||||
//- Calculate all maps.
|
||||
void correct
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const uindirectPrimitivePatch& pp
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
ClassName("meshStructure");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
meshStructure(const polyMesh& mesh, const uindirectPrimitivePatch&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Is mesh structured?
|
||||
inline bool structured() const;
|
||||
|
||||
//- Cell to patch face
|
||||
inline const labelList& cellToPatchFaceAddressing() const;
|
||||
|
||||
//- Cell to patch face
|
||||
inline labelList& cellToPatchFaceAddressing();
|
||||
|
||||
//- Cell to layer
|
||||
inline const labelList& cellLayer() const;
|
||||
|
||||
//- Cell to layer
|
||||
inline labelList& cellLayer();
|
||||
|
||||
//- Face to patch face
|
||||
inline const labelList& faceToPatchFaceAddressing() const;
|
||||
|
||||
//- Face to patch face
|
||||
inline labelList& faceToPatchFaceAddressing();
|
||||
|
||||
//- Face to patch edge
|
||||
inline const labelList& faceToPatchEdgeAddressing() const;
|
||||
|
||||
//- Face to patch edge
|
||||
inline labelList& faceToPatchEdgeAddressing();
|
||||
|
||||
//- Face to layer
|
||||
inline const labelList& faceLayer() const;
|
||||
|
||||
//- Face to layer
|
||||
inline labelList& faceLayer();
|
||||
|
||||
//- Point to patch point
|
||||
inline const labelList& pointToPatchPointAddressing() const;
|
||||
|
||||
//- Point to patch point
|
||||
inline labelList& pointToPatchPointAddressing();
|
||||
|
||||
//- Point to layer
|
||||
inline const labelList& pointLayer() const;
|
||||
|
||||
//- Point to layer
|
||||
inline labelList& pointLayer();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "meshStructureI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
120
src/meshTools/meshStructure/meshStructureI.H
Normal file
120
src/meshTools/meshStructure/meshStructureI.H
Normal file
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "meshStructure.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::meshStructure::structured() const
|
||||
{
|
||||
return structured_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::meshStructure::cellToPatchFaceAddressing() const
|
||||
{
|
||||
return cellToPatchFaceAddressing_;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList& Foam::meshStructure::cellToPatchFaceAddressing()
|
||||
{
|
||||
return cellToPatchFaceAddressing_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::meshStructure::cellLayer() const
|
||||
{
|
||||
return cellLayer_;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList& Foam::meshStructure::cellLayer()
|
||||
{
|
||||
return cellLayer_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::meshStructure::faceToPatchFaceAddressing() const
|
||||
{
|
||||
return faceToPatchFaceAddressing_;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList& Foam::meshStructure::faceToPatchFaceAddressing()
|
||||
{
|
||||
return faceToPatchFaceAddressing_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::meshStructure::faceToPatchEdgeAddressing() const
|
||||
{
|
||||
return faceToPatchEdgeAddressing_;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList& Foam::meshStructure::faceToPatchEdgeAddressing()
|
||||
{
|
||||
return faceToPatchEdgeAddressing_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::meshStructure::faceLayer() const
|
||||
{
|
||||
return faceLayer_;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList& Foam::meshStructure::faceLayer()
|
||||
{
|
||||
return faceLayer_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::meshStructure::pointToPatchPointAddressing() const
|
||||
{
|
||||
return pointToPatchPointAddressing_;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList& Foam::meshStructure::pointToPatchPointAddressing()
|
||||
{
|
||||
return pointToPatchPointAddressing_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelList& Foam::meshStructure::pointLayer() const
|
||||
{
|
||||
return pointLayer_;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList& Foam::meshStructure::pointLayer()
|
||||
{
|
||||
return pointLayer_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
50
src/meshTools/meshStructure/pointTopoDistanceData.C
Normal file
50
src/meshTools/meshStructure/pointTopoDistanceData.C
Normal file
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "pointTopoDistanceData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Foam::Ostream& os,
|
||||
const Foam::pointTopoDistanceData& wDist
|
||||
)
|
||||
{
|
||||
return os << wDist.data_ << token::SPACE << wDist.distance_;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Foam::Istream& is,
|
||||
Foam::pointTopoDistanceData& wDist
|
||||
)
|
||||
{
|
||||
return is >> wDist.data_ >> wDist.distance_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
227
src/meshTools/meshStructure/pointTopoDistanceData.H
Normal file
227
src/meshTools/meshStructure/pointTopoDistanceData.H
Normal file
@ -0,0 +1,227 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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::pointTopoDistanceData
|
||||
|
||||
Description
|
||||
For use with PointEdgeWave. Determines topological distance to
|
||||
starting points
|
||||
|
||||
SourceFiles
|
||||
pointTopoDistanceDataI.H
|
||||
pointTopoDistanceData.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pointTopoDistanceData_H
|
||||
#define pointTopoDistanceData_H
|
||||
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class polyPatch;
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pointTopoDistanceData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pointTopoDistanceData
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Starting data
|
||||
label data_;
|
||||
|
||||
//- Distance
|
||||
label distance_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline pointTopoDistanceData();
|
||||
|
||||
//- Construct from count
|
||||
inline pointTopoDistanceData
|
||||
(
|
||||
const label data,
|
||||
const label distance
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
|
||||
inline label data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
inline label distance() const
|
||||
{
|
||||
return distance_;
|
||||
}
|
||||
|
||||
|
||||
// Needed by PointEdgeWave
|
||||
|
||||
|
||||
//- Check whether origin has been changed at all or
|
||||
// still contains original (invalid) value.
|
||||
template<class TrackingData>
|
||||
inline bool valid(TrackingData& td) const;
|
||||
|
||||
//- Check for identical geometrical data. Used for cyclics checking.
|
||||
template<class TrackingData>
|
||||
inline bool sameGeometry
|
||||
(
|
||||
const pointTopoDistanceData&,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
) const;
|
||||
|
||||
//- Convert origin to relative vector to leaving point
|
||||
// (= point coordinate)
|
||||
template<class TrackingData>
|
||||
inline void leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& pos,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Convert relative origin to absolute by adding entering point
|
||||
template<class TrackingData>
|
||||
inline void enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& pos,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Apply rotation matrix to origin
|
||||
template<class TrackingData>
|
||||
inline void transform
|
||||
(
|
||||
const tensor& rotTensor,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of edge on point
|
||||
template<class TrackingData>
|
||||
inline bool updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const label edgeI,
|
||||
const pointTopoDistanceData& edgeInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same point.
|
||||
// Merge new and old info.
|
||||
template<class TrackingData>
|
||||
inline bool updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const pointTopoDistanceData& newPointInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same point.
|
||||
// No information about current position whatsoever.
|
||||
template<class TrackingData>
|
||||
inline bool updatePoint
|
||||
(
|
||||
const pointTopoDistanceData& newPointInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of point on edge.
|
||||
template<class TrackingData>
|
||||
inline bool updateEdge
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label edgeI,
|
||||
const label pointI,
|
||||
const pointTopoDistanceData& pointInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Same (like operator==)
|
||||
template<class TrackingData>
|
||||
inline bool equal(const pointTopoDistanceData&, TrackingData&)
|
||||
const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
// Needed for List IO
|
||||
inline bool operator==(const pointTopoDistanceData&) const;
|
||||
inline bool operator!=(const pointTopoDistanceData&) const;
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const pointTopoDistanceData&);
|
||||
friend Istream& operator>>(Istream&, pointTopoDistanceData&);
|
||||
};
|
||||
|
||||
|
||||
//- Data associated with pointTopoDistanceData type are contiguous
|
||||
template<>
|
||||
inline bool contiguous<pointTopoDistanceData>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "pointTopoDistanceDataI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
233
src/meshTools/meshStructure/pointTopoDistanceDataI.H
Normal file
233
src/meshTools/meshStructure/pointTopoDistanceDataI.H
Normal file
@ -0,0 +1,233 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
inline Foam::pointTopoDistanceData::pointTopoDistanceData()
|
||||
:
|
||||
data_(-1),
|
||||
distance_(-1)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from components
|
||||
inline Foam::pointTopoDistanceData::pointTopoDistanceData
|
||||
(
|
||||
const label data,
|
||||
const label distance
|
||||
)
|
||||
:
|
||||
data_(data),
|
||||
distance_(distance)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointTopoDistanceData::valid(TrackingData& td) const
|
||||
{
|
||||
return distance_ != -1;
|
||||
}
|
||||
|
||||
|
||||
// No geometric data so never any problem on cyclics
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointTopoDistanceData::sameGeometry
|
||||
(
|
||||
const pointTopoDistanceData&,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// No geometric data.
|
||||
template<class TrackingData>
|
||||
inline void Foam::pointTopoDistanceData::leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& coord,
|
||||
TrackingData& td
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// No geometric data.
|
||||
template<class TrackingData>
|
||||
inline void Foam::pointTopoDistanceData::transform
|
||||
(
|
||||
const tensor& rotTensor,
|
||||
TrackingData& td
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// No geometric data.
|
||||
template<class TrackingData>
|
||||
inline void Foam::pointTopoDistanceData::enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& coord,
|
||||
TrackingData& td
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// Update this with information from connected edge
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointTopoDistanceData::updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const label edgeI,
|
||||
const pointTopoDistanceData& edgeInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
if (distance_ == -1)
|
||||
{
|
||||
data_ = edgeInfo.data_;
|
||||
distance_ = edgeInfo.distance_ + 1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update this with new information on same point
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointTopoDistanceData::updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const pointTopoDistanceData& newPointInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
if (distance_ == -1)
|
||||
{
|
||||
operator=(newPointInfo);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update this with new information on same point. No extra information.
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointTopoDistanceData::updatePoint
|
||||
(
|
||||
const pointTopoDistanceData& newPointInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
if (distance_ == -1)
|
||||
{
|
||||
operator=(newPointInfo);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update this with information from connected point
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointTopoDistanceData::updateEdge
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label edgeI,
|
||||
const label pointI,
|
||||
const pointTopoDistanceData& pointInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
if (distance_ == -1)
|
||||
{
|
||||
operator=(pointInfo);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class TrackingData>
|
||||
inline bool Foam::pointTopoDistanceData::equal
|
||||
(
|
||||
const pointTopoDistanceData& rhs,
|
||||
TrackingData& td
|
||||
) const
|
||||
{
|
||||
return operator==(rhs);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::pointTopoDistanceData::operator==
|
||||
(
|
||||
const Foam::pointTopoDistanceData& rhs
|
||||
) const
|
||||
{
|
||||
return data() == rhs.data() && distance() == rhs.distance();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::pointTopoDistanceData::operator!=
|
||||
(
|
||||
const Foam::pointTopoDistanceData& rhs
|
||||
) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
50
src/meshTools/meshStructure/topoDistanceData.C
Normal file
50
src/meshTools/meshStructure/topoDistanceData.C
Normal file
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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 "topoDistanceData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Foam::Ostream& os,
|
||||
const Foam::topoDistanceData& wDist
|
||||
)
|
||||
{
|
||||
return os << wDist.data_ << token::SPACE << wDist.distance_;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Foam::Istream& is,
|
||||
Foam::topoDistanceData& wDist
|
||||
)
|
||||
{
|
||||
return is >> wDist.data_ >> wDist.distance_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
218
src/meshTools/meshStructure/topoDistanceData.H
Normal file
218
src/meshTools/meshStructure/topoDistanceData.H
Normal file
@ -0,0 +1,218 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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::topoDistanceData
|
||||
|
||||
Description
|
||||
For use with FaceCellWave. Determines topological distance to starting faces
|
||||
|
||||
SourceFiles
|
||||
topoDistanceDataI.H
|
||||
topoDistanceData.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef topoDistanceData_H
|
||||
#define topoDistanceData_H
|
||||
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class polyPatch;
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class topoDistanceData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class topoDistanceData
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Starting data
|
||||
label data_;
|
||||
|
||||
//- Distance
|
||||
label distance_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline topoDistanceData();
|
||||
|
||||
//- Construct from count
|
||||
inline topoDistanceData
|
||||
(
|
||||
const label data,
|
||||
const label distance
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
|
||||
inline label data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
inline label distance() const
|
||||
{
|
||||
return distance_;
|
||||
}
|
||||
|
||||
|
||||
// Needed by FaceCellWave
|
||||
|
||||
//- Check whether origin has been changed at all or
|
||||
// still contains original (invalid) value.
|
||||
template<class TrackingData>
|
||||
inline bool valid(TrackingData& td) const;
|
||||
|
||||
//- Check for identical geometrical data. Used for cyclics checking.
|
||||
template<class TrackingData>
|
||||
inline bool sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const topoDistanceData&,
|
||||
const scalar,
|
||||
TrackingData& td
|
||||
) const;
|
||||
|
||||
//- Convert any absolute coordinates into relative to (patch)face
|
||||
// centre
|
||||
template<class TrackingData>
|
||||
inline void leaveDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Reverse of leaveDomain
|
||||
template<class TrackingData>
|
||||
inline void enterDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch&,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Apply rotation matrix to any coordinates
|
||||
template<class TrackingData>
|
||||
inline void transform
|
||||
(
|
||||
const polyMesh&,
|
||||
const tensor&,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of neighbouring face.
|
||||
template<class TrackingData>
|
||||
inline bool updateCell
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisCellI,
|
||||
const label neighbourFaceI,
|
||||
const topoDistanceData& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of neighbouring cell.
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFaceI,
|
||||
const label neighbourCellI,
|
||||
const topoDistanceData& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same face.
|
||||
template<class TrackingData>
|
||||
inline bool updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFaceI,
|
||||
const topoDistanceData& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Same (like operator==)
|
||||
template<class TrackingData>
|
||||
inline bool equal(const topoDistanceData&, TrackingData& td) const;
|
||||
|
||||
// Member Operators
|
||||
|
||||
// Needed for List IO
|
||||
inline bool operator==(const topoDistanceData&) const;
|
||||
|
||||
inline bool operator!=(const topoDistanceData&) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const topoDistanceData&);
|
||||
friend Istream& operator>>(Istream&, topoDistanceData&);
|
||||
};
|
||||
|
||||
|
||||
//- Data associated with topoDistanceData type are contiguous
|
||||
template<>
|
||||
inline bool contiguous<topoDistanceData>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "topoDistanceDataI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
219
src/meshTools/meshStructure/topoDistanceDataI.H
Normal file
219
src/meshTools/meshStructure/topoDistanceDataI.H
Normal file
@ -0,0 +1,219 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
inline Foam::topoDistanceData::topoDistanceData()
|
||||
:
|
||||
data_(-1),
|
||||
distance_(-1)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from components
|
||||
inline Foam::topoDistanceData::topoDistanceData
|
||||
(
|
||||
const label data,
|
||||
const label distance
|
||||
)
|
||||
:
|
||||
data_(data),
|
||||
distance_(distance)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class TrackingData>
|
||||
inline bool Foam::topoDistanceData::valid(TrackingData& td) const
|
||||
{
|
||||
return distance_ != -1;
|
||||
}
|
||||
|
||||
|
||||
// No geometric data so never any problem on cyclics
|
||||
template<class TrackingData>
|
||||
inline bool Foam::topoDistanceData::sameGeometry
|
||||
(
|
||||
const polyMesh&,
|
||||
const topoDistanceData&,
|
||||
const scalar,
|
||||
TrackingData&
|
||||
) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// No geometric data.
|
||||
template<class TrackingData>
|
||||
inline void Foam::topoDistanceData::leaveDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch& patch,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre,
|
||||
TrackingData&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// No geometric data.
|
||||
template<class TrackingData>
|
||||
inline void Foam::topoDistanceData::transform
|
||||
(
|
||||
const polyMesh&,
|
||||
const tensor& rotTensor,
|
||||
TrackingData&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// No geometric data.
|
||||
template<class TrackingData>
|
||||
inline void Foam::topoDistanceData::enterDomain
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyPatch& patch,
|
||||
const label patchFaceI,
|
||||
const point& faceCentre,
|
||||
TrackingData&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// Update cell with neighbouring face information
|
||||
template<class TrackingData>
|
||||
inline bool Foam::topoDistanceData::updateCell
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisCellI,
|
||||
const label neighbourFaceI,
|
||||
const topoDistanceData& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData&
|
||||
)
|
||||
{
|
||||
if (distance_ == -1)
|
||||
{
|
||||
operator=(neighbourInfo);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update face with neighbouring cell information
|
||||
template<class TrackingData>
|
||||
inline bool Foam::topoDistanceData::updateFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label thisFaceI,
|
||||
const label neighbourCellI,
|
||||
const topoDistanceData& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData&
|
||||
)
|
||||
{
|
||||
// From cell to its faces.
|
||||
|
||||
if (distance_ == -1)
|
||||
{
|
||||
data_ = neighbourInfo.data_;
|
||||
distance_ = neighbourInfo.distance_ + 1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update face with coupled face information
|
||||
template<class TrackingData>
|
||||
inline bool Foam::topoDistanceData::updateFace
|
||||
(
|
||||
const polyMesh&,
|
||||
const label thisFaceI,
|
||||
const topoDistanceData& neighbourInfo,
|
||||
const scalar tol,
|
||||
TrackingData&
|
||||
)
|
||||
{
|
||||
// From face to face (e.g. coupled faces)
|
||||
if (distance_ == -1)
|
||||
{
|
||||
operator=(neighbourInfo);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class TrackingData>
|
||||
inline bool Foam::topoDistanceData::equal
|
||||
(
|
||||
const topoDistanceData& rhs,
|
||||
TrackingData& td
|
||||
) const
|
||||
{
|
||||
return operator==(rhs);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::topoDistanceData::operator==
|
||||
(
|
||||
const Foam::topoDistanceData& rhs
|
||||
) const
|
||||
{
|
||||
return data() == rhs.data() && distance() == rhs.distance();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::topoDistanceData::operator!=
|
||||
(
|
||||
const Foam::topoDistanceData& rhs
|
||||
) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -91,6 +91,7 @@ void Foam::regionCoupledBase::resetAMI() const
|
||||
nbrPatch0,
|
||||
surfPtr(),
|
||||
faceAreaIntersect::tmMesh,
|
||||
AMIPatchToPatchInterpolation::imFaceAreaWeight,
|
||||
AMIReverse_
|
||||
)
|
||||
);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -692,7 +692,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
|
||||
|
||||
Foam::regionSplit::regionSplit(const polyMesh& mesh)
|
||||
:
|
||||
MeshObject<polyMesh, regionSplit>(mesh),
|
||||
MeshObject<polyMesh, Foam::TopologicalMeshObject, regionSplit>(mesh),
|
||||
labelList(mesh.nCells(), -1)
|
||||
{
|
||||
globalNumberingPtr_ = calcRegionSplit
|
||||
@ -710,7 +710,7 @@ Foam::regionSplit::regionSplit
|
||||
const boolList& blockedFace
|
||||
)
|
||||
:
|
||||
MeshObject<polyMesh, regionSplit>(mesh),
|
||||
MeshObject<polyMesh, Foam::TopologicalMeshObject, regionSplit>(mesh),
|
||||
labelList(mesh.nCells(), -1)
|
||||
{
|
||||
globalNumberingPtr_ = calcRegionSplit
|
||||
@ -729,7 +729,7 @@ Foam::regionSplit::regionSplit
|
||||
const List<labelPair>& explicitConnections
|
||||
)
|
||||
:
|
||||
MeshObject<polyMesh, regionSplit>(mesh),
|
||||
MeshObject<polyMesh, Foam::TopologicalMeshObject, regionSplit>(mesh),
|
||||
labelList(mesh.nCells(), -1)
|
||||
{
|
||||
globalNumberingPtr_ = calcRegionSplit
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -108,12 +108,12 @@ namespace Foam
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class regionSplit Declaration
|
||||
Class regionSplit Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regionSplit
|
||||
:
|
||||
public MeshObject<polyMesh, regionSplit>,
|
||||
public MeshObject<polyMesh, TopologicalMeshObject, regionSplit>,
|
||||
public labelList
|
||||
{
|
||||
// Private data
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -203,7 +203,6 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection
|
||||
surfI,
|
||||
coordinateSystem::New
|
||||
(
|
||||
"",
|
||||
subDict.subDict("transform")
|
||||
)
|
||||
);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,7 +21,7 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "searchableSurfaces.H"
|
||||
#include "searchableSurfacesQueries.H"
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,7 +21,7 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "searchableSurfacesQueries.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -139,7 +139,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
const boundBox& bb = mesh_.bounds();
|
||||
pointField points(bb.points());
|
||||
|
||||
label minPointI = -1;
|
||||
//label minPointI = -1;
|
||||
label maxPointI = -1;
|
||||
forAll(points, pointI)
|
||||
{
|
||||
@ -152,7 +152,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
else if (c < minComp)
|
||||
{
|
||||
minComp = c;
|
||||
minPointI = pointI;
|
||||
//minPointI = pointI;
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
PackedBoolList selected(mesh_.nCells());
|
||||
label nSelected = -1;
|
||||
scalar selectedVol = 0.0;
|
||||
scalar selectedComp = 0.0;
|
||||
//scalar selectedComp = 0.0;
|
||||
|
||||
|
||||
scalar low = minComp;
|
||||
@ -228,7 +228,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
selectedComp = high;
|
||||
//selectedComp = high;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -237,7 +237,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
selectedComp = low;
|
||||
//selectedComp = low;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -163,7 +163,7 @@ inline bool Foam::patchEdgeFaceRegion::updateFace
|
||||
}
|
||||
|
||||
|
||||
template <class TrackingData>
|
||||
template<class TrackingData>
|
||||
inline bool Foam::patchEdgeFaceRegion::equal
|
||||
(
|
||||
const patchEdgeFaceRegion& rhs,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "faceZoneSet.H"
|
||||
#include "searchableSurface.H"
|
||||
#include "syncTools.H"
|
||||
#include "Time.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -69,7 +70,15 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
|
||||
searchableSurface::New
|
||||
(
|
||||
word(dict.lookup("surface")),
|
||||
mesh.objectRegistry::db(),
|
||||
IOobject
|
||||
(
|
||||
dict.lookupOrDefault("name", mesh.objectRegistry::db().name()),
|
||||
mesh.time().constant(),
|
||||
"triSurface",
|
||||
mesh.objectRegistry::db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dict
|
||||
)
|
||||
)
|
||||
@ -120,7 +129,7 @@ void Foam::searchableSurfaceToFaceZone::applyToSet
|
||||
|
||||
// Boundary faces
|
||||
vectorField nbrCellCentres;
|
||||
syncTools::swapBoundaryCellList(mesh_, cc, nbrCellCentres);
|
||||
syncTools::swapBoundaryCellPositions(mesh_, cc, nbrCellCentres);
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
|
||||
@ -0,0 +1,189 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "setAndNormalToFaceZone.H"
|
||||
#include "polyMesh.H"
|
||||
#include "faceZoneSet.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(setAndNormalToFaceZone, 0);
|
||||
|
||||
addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, word);
|
||||
|
||||
addToRunTimeSelectionTable(topoSetSource, setAndNormalToFaceZone, istream);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Foam::topoSetSource::addToUsageTable Foam::setAndNormalToFaceZone::usage_
|
||||
(
|
||||
setAndNormalToFaceZone::typeName,
|
||||
"\n Usage: setAndNormalToFaceZone <faceSet> <normal>\n\n"
|
||||
" Select all faces in the faceSet and orient using normal.\n\n"
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::setAndNormalToFaceZone::setAndNormalToFaceZone
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& setName,
|
||||
const vector& normal
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
setName_(setName),
|
||||
normal_(normal)
|
||||
{}
|
||||
|
||||
|
||||
Foam::setAndNormalToFaceZone::setAndNormalToFaceZone
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
setName_(dict.lookup("faceSet")),
|
||||
normal_(dict.lookup("normal"))
|
||||
{}
|
||||
|
||||
|
||||
Foam::setAndNormalToFaceZone::setAndNormalToFaceZone
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
setName_(checkIs(is)),
|
||||
normal_(checkIs(is))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::setAndNormalToFaceZone::~setAndNormalToFaceZone()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::setAndNormalToFaceZone::applyToSet
|
||||
(
|
||||
const topoSetSource::setAction action,
|
||||
topoSet& set
|
||||
) const
|
||||
{
|
||||
if (!isA<faceZoneSet>(set))
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"setAndNormalToFaceZone::applyToSet"
|
||||
"("
|
||||
"const topoSetSource::setAction, "
|
||||
"topoSet&"
|
||||
")"
|
||||
) << "Operation only allowed on a faceZoneSet." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
faceZoneSet& fzSet = refCast<faceZoneSet>(set);
|
||||
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||
{
|
||||
Info<< " Adding all faces from faceSet " << setName_
|
||||
<< " ..." << endl;
|
||||
|
||||
// Load the sets
|
||||
faceSet fSet(mesh_, setName_);
|
||||
|
||||
// Start off from copy
|
||||
DynamicList<label> newAddressing(fzSet.addressing());
|
||||
DynamicList<bool> newFlipMap(fzSet.flipMap());
|
||||
|
||||
const faceList& faces = mesh_.faces();
|
||||
const pointField& points = mesh_.points();
|
||||
|
||||
forAllConstIter(faceSet, fSet, iter)
|
||||
{
|
||||
label faceI = iter.key();
|
||||
|
||||
if (!fzSet.found(faceI))
|
||||
{
|
||||
newAddressing.append(faceI);
|
||||
|
||||
vector n = faces[faceI].normal(points);
|
||||
if ((n & normal_) > 0)
|
||||
{
|
||||
newFlipMap.append(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
newFlipMap.append(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fzSet.addressing().transfer(newAddressing);
|
||||
fzSet.flipMap().transfer(newFlipMap);
|
||||
fzSet.updateSet();
|
||||
}
|
||||
else if (action == topoSetSource::DELETE)
|
||||
{
|
||||
Info<< " Removing all faces from faceSet " << setName_
|
||||
<< " ..." << endl;
|
||||
|
||||
// Load the set
|
||||
faceSet loadedSet(mesh_, setName_);
|
||||
|
||||
// Start off empty
|
||||
DynamicList<label> newAddressing(fzSet.addressing().size());
|
||||
DynamicList<bool> newFlipMap(fzSet.flipMap().size());
|
||||
|
||||
forAll(fzSet.addressing(), i)
|
||||
{
|
||||
if (!loadedSet.found(fzSet.addressing()[i]))
|
||||
{
|
||||
newAddressing.append(fzSet.addressing()[i]);
|
||||
newFlipMap.append(fzSet.flipMap()[i]);
|
||||
}
|
||||
}
|
||||
fzSet.addressing().transfer(newAddressing);
|
||||
fzSet.flipMap().transfer(newFlipMap);
|
||||
fzSet.updateSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,25 +22,21 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::parabolicCylindricalCS
|
||||
Foam::setAndNormalToFaceZone
|
||||
|
||||
Description
|
||||
Parabolic cylindrical coordinate system.
|
||||
|
||||
Notation: u = a.x() v = a.y() z = a.z();
|
||||
|
||||
Note
|
||||
The maintenance of this class may lag that of the main types.
|
||||
A topoSetSource to select faces based on usage in a faceSet, where the
|
||||
normal vector is used to orient the faces.
|
||||
|
||||
SourceFiles
|
||||
parabolicCylindricalCS.C
|
||||
setAndNormalToFaceZone.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef parabolicCylindricalCS_H
|
||||
#define parabolicCylindricalCS_H
|
||||
#ifndef setAndNormalToFaceZone_H
|
||||
#define setAndNormalToFaceZone_H
|
||||
|
||||
#include "coordinateSystem.H"
|
||||
#include "topoSetSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -48,64 +44,72 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class parabolicCylindricalCS Declaration
|
||||
Class setAndNormalToFaceZone Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class parabolicCylindricalCS
|
||||
class setAndNormalToFaceZone
|
||||
:
|
||||
public coordinateSystem
|
||||
public topoSetSource
|
||||
{
|
||||
// Private data
|
||||
|
||||
protected:
|
||||
//- Add usage string
|
||||
static addToUsageTable usage_;
|
||||
|
||||
// Protected Member Functions
|
||||
//- Name of set to use
|
||||
word setName_;
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
virtual vector localToGlobal(const vector&, bool translate) const;
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
virtual tmp<vectorField> localToGlobal
|
||||
(
|
||||
const vectorField&,
|
||||
bool translate
|
||||
) const;
|
||||
|
||||
//- Convert from global Cartesian system to the local coordinate system
|
||||
// with optional translation for the origin
|
||||
virtual vector globalToLocal(const vector&, bool translate) const;
|
||||
|
||||
//- Convert from global Cartesian system to the local coordinate system
|
||||
// with optional translation for the origin
|
||||
virtual tmp<vectorField> globalToLocal
|
||||
(
|
||||
const vectorField&,
|
||||
bool translate
|
||||
) const;
|
||||
//- Normal used to orient the faces
|
||||
vector normal_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("parabolicCylindrical");
|
||||
|
||||
TypeName("setAndNormalToFaceZone");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
parabolicCylindricalCS();
|
||||
|
||||
//- Construct from origin and rotation
|
||||
parabolicCylindricalCS
|
||||
//- Construct from components
|
||||
setAndNormalToFaceZone
|
||||
(
|
||||
const word& name,
|
||||
const point& origin,
|
||||
const coordinateRotation&
|
||||
const polyMesh& mesh,
|
||||
const word& setName,
|
||||
const vector& normal
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
parabolicCylindricalCS(const word&, const dictionary&);
|
||||
setAndNormalToFaceZone
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
setAndNormalToFaceZone
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~setAndNormalToFaceZone();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual sourceType setType() const
|
||||
{
|
||||
return FACEZONESOURCE;
|
||||
}
|
||||
|
||||
virtual void applyToSet
|
||||
(
|
||||
const topoSetSource::setAction action,
|
||||
topoSet&
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -49,8 +49,8 @@ void faceZoneSet::updateSet()
|
||||
{
|
||||
labelList order;
|
||||
sortedOrder(addressing_, order);
|
||||
inplaceReorder(order, addressing_);
|
||||
inplaceReorder(order, flipMap_);
|
||||
addressing_ = UIndirectList<label>(addressing_, order)();
|
||||
flipMap_ = UIndirectList<bool>(flipMap_, order)();
|
||||
|
||||
faceSet::clearStorage();
|
||||
faceSet::resize(2*addressing_.size());
|
||||
|
||||
@ -21,7 +21,6 @@ License
|
||||
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::tetOverlapVolume
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,7 +21,7 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceLocation.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -222,7 +222,8 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
|
||||
)
|
||||
:
|
||||
perturb_(perturb),
|
||||
referenceCS_(calcCoordinateSystem(sourcePoints))
|
||||
referenceCS_(calcCoordinateSystem(sourcePoints)),
|
||||
nPoints_(sourcePoints.size())
|
||||
|
||||
{
|
||||
calcWeights(sourcePoints, destPoints);
|
||||
@ -238,7 +239,8 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
|
||||
)
|
||||
:
|
||||
perturb_(perturb),
|
||||
referenceCS_(referenceCS)
|
||||
referenceCS_(referenceCS),
|
||||
nPoints_(sourcePoints.size())
|
||||
{
|
||||
calcWeights(sourcePoints, destPoints);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,6 +59,9 @@ class pointToPointPlanarInterpolation
|
||||
//- Coordinate system
|
||||
coordinateSystem referenceCS_;
|
||||
|
||||
//- Number of source points (for checking)
|
||||
label nPoints_;
|
||||
|
||||
//- Current interpolation addressing to face centres of underlying
|
||||
// patch
|
||||
List<FixedList<label, 3> > nearestVertex_;
|
||||
@ -114,6 +117,12 @@ public:
|
||||
return referenceCS_;
|
||||
}
|
||||
|
||||
//- Number of source points
|
||||
label sourceSize() const
|
||||
{
|
||||
return nPoints_;
|
||||
}
|
||||
|
||||
// patch
|
||||
const List<FixedList<label, 3> >& nearestVertex() const
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -33,6 +33,17 @@ Foam::tmp<Foam::Field<Type> > Foam::pointToPointPlanarInterpolation::interpolate
|
||||
const Field<Type>& sourceFld
|
||||
) const
|
||||
{
|
||||
if (nPoints_ != sourceFld.size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"pointToPointPlanarInterpolation::interpolate"
|
||||
"(const Field<Type>&) const"
|
||||
) << "Number of source points = " << nPoints_
|
||||
<< " number of values = " << sourceFld.size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user