mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' into cvm
This commit is contained in:
@ -205,7 +205,7 @@ Foam::mapDistribute::mapDistribute
|
||||
const labelList& recvProcs
|
||||
)
|
||||
:
|
||||
constructSize_(sendProcs.size()),
|
||||
constructSize_(0),
|
||||
schedulePtr_()
|
||||
{
|
||||
if (sendProcs.size() != recvProcs.size())
|
||||
@ -266,6 +266,8 @@ Foam::mapDistribute::mapDistribute
|
||||
{
|
||||
// I am the receiver.
|
||||
constructMap_[sendProc][nRecv[sendProc]++] = sampleI;
|
||||
// Largest entry inside constructMap
|
||||
constructSize_ = sampleI+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,18 +131,36 @@ public:
|
||||
return constructSize_;
|
||||
}
|
||||
|
||||
//- Constructed data size
|
||||
label& constructSize()
|
||||
{
|
||||
return constructSize_;
|
||||
}
|
||||
|
||||
//- From subsetted data back to original data
|
||||
const labelListList& subMap() const
|
||||
{
|
||||
return subMap_;
|
||||
}
|
||||
|
||||
//- From subsetted data back to original data
|
||||
labelListList& subMap()
|
||||
{
|
||||
return subMap_;
|
||||
}
|
||||
|
||||
//- From subsetted data to new reconstructed data
|
||||
const labelListList& constructMap() const
|
||||
{
|
||||
return constructMap_;
|
||||
}
|
||||
|
||||
//- From subsetted data to new reconstructed data
|
||||
labelListList& constructMap()
|
||||
{
|
||||
return constructMap_;
|
||||
}
|
||||
|
||||
//- Calculate a schedule. See above.
|
||||
static List<labelPair> schedule
|
||||
(
|
||||
|
||||
@ -58,7 +58,13 @@ void Foam::mapDistribute::distribute
|
||||
}
|
||||
|
||||
// Subset myself
|
||||
UIndirectList<T> subField(field, subMap[Pstream::myProcNo()]);
|
||||
const labelList& mySubMap = subMap[Pstream::myProcNo()];
|
||||
|
||||
List<T> subField(mySubMap.size());
|
||||
forAll(mySubMap, i)
|
||||
{
|
||||
subField[i] = field[mySubMap[i]];
|
||||
}
|
||||
|
||||
// Receive sub field from myself (subField)
|
||||
const labelList& map = constructMap[Pstream::myProcNo()];
|
||||
@ -355,7 +361,13 @@ void Foam::mapDistribute::distribute
|
||||
}
|
||||
|
||||
// Subset myself
|
||||
UIndirectList<T> subField(field, subMap[Pstream::myProcNo()]);
|
||||
const labelList& mySubMap = subMap[Pstream::myProcNo()];
|
||||
|
||||
List<T> subField(mySubMap.size());
|
||||
forAll(mySubMap, i)
|
||||
{
|
||||
subField[i] = field[mySubMap[i]];
|
||||
}
|
||||
|
||||
// Receive sub field from myself (subField)
|
||||
const labelList& map = constructMap[Pstream::myProcNo()];
|
||||
|
||||
@ -82,10 +82,10 @@ void Foam::polyMesh::initMesh()
|
||||
);
|
||||
|
||||
string meshInfo =
|
||||
"nPoints: " + Foam::name(nPoints())
|
||||
+ " nCells: " + Foam::name(this->nCells())
|
||||
+ " nFaces: " + Foam::name(nFaces())
|
||||
+ " nInternalFaces: " + Foam::name(nInternalFaces());
|
||||
"nPoints:" + Foam::name(nPoints())
|
||||
+ " nCells:" + Foam::name(this->nCells())
|
||||
+ " nFaces:" + Foam::name(nFaces())
|
||||
+ " nInternalFaces:" + Foam::name(nInternalFaces());
|
||||
|
||||
owner_.note() = meshInfo;
|
||||
neighbour_.note() = meshInfo;
|
||||
|
||||
@ -58,7 +58,7 @@ Foam::PatchTools::checkOrientation
|
||||
{
|
||||
Info<< "Face[" << faceI << "] " << p[faceI]
|
||||
<< " has fewer than 3 edges. Edges: " << edgeLabels
|
||||
<< nl;
|
||||
<< endl;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
@ -70,10 +70,12 @@ Foam::PatchTools::checkOrientation
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
Info<< "edge number " << edgeLabels[i] << " on face " << faceI
|
||||
Info<< "edge number " << edgeLabels[i]
|
||||
<< " on face " << faceI
|
||||
<< " out-of-range\n"
|
||||
<< "This usually means the input surface has "
|
||||
<< "edges with more than 2 faces connected." << nl;
|
||||
<< "edges with more than 2 faces connected."
|
||||
<< endl;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
@ -91,9 +93,9 @@ Foam::PatchTools::checkOrientation
|
||||
//- Compute normal from 3 points, use the first as the origin
|
||||
// minor warpage should not be a problem
|
||||
const Face& f = p[faceI];
|
||||
const point p0(p.points()[f[0]]);
|
||||
const point p1(p.points()[f[1]]);
|
||||
const point p2(p.points()[f[f.size()-1]]);
|
||||
const point& p0 = p.points()[f[0]];
|
||||
const point& p1 = p.points()[f[1]];
|
||||
const point& p2 = p.points()[f[f.size()-1]];
|
||||
|
||||
const vector pointNormal((p1 - p0) ^ (p2 - p0));
|
||||
if ((pointNormal & p.faceNormals()[faceI]) < 0)
|
||||
@ -103,12 +105,12 @@ Foam::PatchTools::checkOrientation
|
||||
if (report)
|
||||
{
|
||||
Info
|
||||
<< "Normal calculated from points inconsistent with faceNormal"
|
||||
<< nl
|
||||
<< "Normal calculated from points inconsistent"
|
||||
<< " with faceNormal" << nl
|
||||
<< "face: " << f << nl
|
||||
<< "points: " << p0 << ' ' << p1 << ' ' << p2 << nl
|
||||
<< "pointNormal:" << pointNormal << nl
|
||||
<< "faceNormal:" << p.faceNormals()[faceI] << nl;
|
||||
<< "faceNormal:" << p.faceNormals()[faceI] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,10 @@ decompositionMethod/decompositionMethod.C
|
||||
geomDecomp/geomDecomp.C
|
||||
simpleGeomDecomp/simpleGeomDecomp.C
|
||||
hierarchGeomDecomp/hierarchGeomDecomp.C
|
||||
metisDecomp/metisDecomp.C
|
||||
manualDecomp/manualDecomp.C
|
||||
|
||||
scotchDecomp/scotchDecomp.C
|
||||
|
||||
metisDecomp/metisDecomp.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libdecompositionMethods
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
EXE_INC = \
|
||||
-I$(WM_THIRD_PARTY_DIR)/scotch_5.1/src/libscotch/lnInclude \
|
||||
-I$(WM_THIRD_PARTY_DIR)/metis-5.0pre2/include
|
||||
|
||||
LIB_LIBS = \
|
||||
-lscotch \
|
||||
-lmetis \
|
||||
-lGKlib
|
||||
|
||||
@ -0,0 +1,425 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
S Strat=b{job=t,map=t,poli=S,sep=(m{asc=b{bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005},org=f{move=80,pass=-1,bal=0.005},width=3},low=h{pass=10}f{move=80,pass=-1,bal=0.0005},type=h,vert=80,rat=0.8}|m{asc=b{bnd=d{pass=40,dif=1,rem=1}f{move=80,pass=-1,bal=0.005},org=f{move=80,pass=-1,bal=0.005},width=3},low=h{pass=10}f{move=80,pass=-1,bal=0.0005},type=h,vert=80,rat=0.8})}
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "scotchDecomp.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "floatScalar.H"
|
||||
#include "IFstream.H"
|
||||
#include "Time.H"
|
||||
#include "cyclicPolyPatch.H"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#define OMPI_SKIP_MPICXX
|
||||
#include "module.h"
|
||||
#include "common.h"
|
||||
#include "scotch.h"
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(scotchDecomp, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
decompositionMethod,
|
||||
scotchDecomp,
|
||||
dictionaryMesh
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::scotchDecomp::check(const int retVal, const char* str)
|
||||
{
|
||||
if (retVal)
|
||||
{
|
||||
FatalErrorIn("scotchDecomp::decompose(..)")
|
||||
<< "Called to scotch routine " << str << " failed."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Call Metis with options from dictionary.
|
||||
Foam::label Foam::scotchDecomp::decompose
|
||||
(
|
||||
const List<int>& adjncy,
|
||||
const List<int>& xadj,
|
||||
|
||||
List<int>& finalDecomp
|
||||
)
|
||||
{
|
||||
// Strategy
|
||||
// ~~~~~~~~
|
||||
// Default.
|
||||
SCOTCH_Strat stradat;
|
||||
check(SCOTCH_stratInit(&stradat), "SCOTCH_stratInit");
|
||||
//SCOTCH_stratGraphMap(&stradat, &argv[i][2]);
|
||||
//fprintf(stdout, "S\tStrat=");
|
||||
//SCOTCH_stratSave(&stradat, stdout);
|
||||
//fprintf(stdout, "\n");
|
||||
|
||||
|
||||
// Graph
|
||||
// ~~~~~
|
||||
|
||||
SCOTCH_Graph grafdat;
|
||||
check(SCOTCH_graphInit(&grafdat), "SCOTCH_graphInit");
|
||||
check
|
||||
(
|
||||
SCOTCH_graphBuild
|
||||
(
|
||||
&grafdat,
|
||||
0, // baseval, c-style numbering
|
||||
xadj.size()-1, // vertnbr, nCells
|
||||
xadj.begin(), // verttab, start index per cell into adjncy
|
||||
&xadj[1], // vendtab, end index ,,
|
||||
NULL, // velotab, vertex weights
|
||||
NULL, // vlbltab
|
||||
adjncy.size(), // edgenbr, number of arcs
|
||||
adjncy.begin(), // edgetab
|
||||
NULL // edlotab, edge weights
|
||||
),
|
||||
"SCOTCH_graphBuild"
|
||||
);
|
||||
check(SCOTCH_graphCheck(&grafdat), "SCOTCH_graphCheck");
|
||||
|
||||
|
||||
|
||||
//// Architecture
|
||||
//// ~~~~~~~~~~~~
|
||||
//// (fully connected network topology since using switch)
|
||||
//
|
||||
//SCOTCH_Arch archdat;
|
||||
//check(SCOTCH_archInit(&archdat), "SCOTCH_archInit");
|
||||
//check
|
||||
//(
|
||||
// // SCOTCH_archCmpltw for weighted.
|
||||
// SCOTCH_archCmplt(&archdat, nProcessors_),
|
||||
// "SCOTCH_archCmplt"
|
||||
//);
|
||||
|
||||
|
||||
|
||||
|
||||
//SCOTCH_Mapping mapdat;
|
||||
//SCOTCH_graphMapInit(&grafdat, &mapdat, &archdat, NULL);
|
||||
//SCOTCH_graphMapCompute(&grafdat, &mapdat, &stradat); /* Perform mapping */
|
||||
|
||||
|
||||
finalDecomp.setSize(xadj.size()-1);
|
||||
check
|
||||
(
|
||||
SCOTCH_graphPart
|
||||
(
|
||||
&grafdat,
|
||||
nProcessors_, // partnbr
|
||||
&stradat, // const SCOTCH_Strat *
|
||||
finalDecomp.begin() // parttab
|
||||
),
|
||||
"SCOTCH_graphPart"
|
||||
);
|
||||
|
||||
// Release storage for graph
|
||||
SCOTCH_graphExit(&grafdat);
|
||||
SCOTCH_stratExit(&stradat);
|
||||
//// Release storage for network topology
|
||||
//SCOTCH_archExit(&archdat);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scotchDecomp::scotchDecomp
|
||||
(
|
||||
const dictionary& decompositionDict,
|
||||
const polyMesh& mesh
|
||||
)
|
||||
:
|
||||
decompositionMethod(decompositionDict),
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelList Foam::scotchDecomp::decompose(const pointField& points)
|
||||
{
|
||||
if (points.size() != mesh_.nCells())
|
||||
{
|
||||
FatalErrorIn("scotchDecomp::decompose(const pointField&)")
|
||||
<< "Can use this decomposition method only for the whole mesh"
|
||||
<< endl
|
||||
<< "and supply one coordinate (cellCentre) for every cell." << endl
|
||||
<< "The number of coordinates " << points.size() << endl
|
||||
<< "The number of cells in the mesh " << mesh_.nCells()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Make Metis CSR (Compressed Storage Format) storage
|
||||
// adjncy : contains neighbours (= edges in graph)
|
||||
// xadj(celli) : start of information in adjncy for celli
|
||||
|
||||
List<int> xadj(mesh_.nCells()+1);
|
||||
|
||||
// Initialise the number of internal faces of the cells to twice the
|
||||
// number of internal faces
|
||||
label nInternalFaces = 2*mesh_.nInternalFaces();
|
||||
|
||||
// Check the boundary for coupled patches and add to the number of
|
||||
// internal faces
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (isA<cyclicPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
nInternalFaces += pbm[patchi].size();
|
||||
}
|
||||
}
|
||||
|
||||
// Create the adjncy array the size of the total number of internal and
|
||||
// coupled faces
|
||||
List<int> adjncy(nInternalFaces);
|
||||
|
||||
// Fill in xadj
|
||||
// ~~~~~~~~~~~~
|
||||
label freeAdj = 0;
|
||||
|
||||
for (label cellI = 0; cellI < mesh_.nCells(); cellI++)
|
||||
{
|
||||
xadj[cellI] = freeAdj;
|
||||
|
||||
const labelList& cFaces = mesh_.cells()[cellI];
|
||||
|
||||
forAll(cFaces, i)
|
||||
{
|
||||
label faceI = cFaces[i];
|
||||
|
||||
if
|
||||
(
|
||||
mesh_.isInternalFace(faceI)
|
||||
|| isA<cyclicPolyPatch>(pbm[pbm.whichPatch(faceI)])
|
||||
)
|
||||
{
|
||||
freeAdj++;
|
||||
}
|
||||
}
|
||||
}
|
||||
xadj[mesh_.nCells()] = freeAdj;
|
||||
|
||||
|
||||
// Fill in adjncy
|
||||
// ~~~~~~~~~~~~~~
|
||||
|
||||
labelList nFacesPerCell(mesh_.nCells(), 0);
|
||||
|
||||
// Internal faces
|
||||
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
|
||||
{
|
||||
label own = mesh_.faceOwner()[faceI];
|
||||
label nei = mesh_.faceNeighbour()[faceI];
|
||||
|
||||
adjncy[xadj[own] + nFacesPerCell[own]++] = nei;
|
||||
adjncy[xadj[nei] + nFacesPerCell[nei]++] = own;
|
||||
}
|
||||
|
||||
// Coupled faces. Only cyclics done.
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (isA<cyclicPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
const unallocLabelList& faceCells = pbm[patchi].faceCells();
|
||||
|
||||
label sizeby2 = faceCells.size()/2;
|
||||
|
||||
for (label facei=0; facei<sizeby2; facei++)
|
||||
{
|
||||
label own = faceCells[facei];
|
||||
label nei = faceCells[facei + sizeby2];
|
||||
|
||||
adjncy[xadj[own] + nFacesPerCell[own]++] = nei;
|
||||
adjncy[xadj[nei] + nFacesPerCell[nei]++] = own;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decompose using default weights
|
||||
List<int> finalDecomp;
|
||||
decompose(adjncy, xadj, finalDecomp);
|
||||
|
||||
// Copy back to labelList
|
||||
labelList decomp(finalDecomp.size());
|
||||
forAll(decomp, i)
|
||||
{
|
||||
decomp[i] = finalDecomp[i];
|
||||
}
|
||||
return decomp;
|
||||
}
|
||||
|
||||
|
||||
// From cell-cell connections to Metis format (like CompactListList)
|
||||
void Foam::scotchDecomp::calcMetisCSR
|
||||
(
|
||||
const labelListList& cellCells,
|
||||
List<int>& adjncy,
|
||||
List<int>& xadj
|
||||
)
|
||||
{
|
||||
// Count number of internal faces
|
||||
label nConnections = 0;
|
||||
|
||||
forAll(cellCells, coarseI)
|
||||
{
|
||||
nConnections += cellCells[coarseI].size();
|
||||
}
|
||||
|
||||
// Create the adjncy array as twice the size of the total number of
|
||||
// internal faces
|
||||
adjncy.setSize(nConnections);
|
||||
|
||||
xadj.setSize(cellCells.size()+1);
|
||||
|
||||
|
||||
// Fill in xadj
|
||||
// ~~~~~~~~~~~~
|
||||
label freeAdj = 0;
|
||||
|
||||
forAll(cellCells, coarseI)
|
||||
{
|
||||
xadj[coarseI] = freeAdj;
|
||||
|
||||
const labelList& cCells = cellCells[coarseI];
|
||||
|
||||
forAll(cCells, i)
|
||||
{
|
||||
adjncy[freeAdj++] = cCells[i];
|
||||
}
|
||||
}
|
||||
xadj[cellCells.size()] = freeAdj;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList Foam::scotchDecomp::decompose
|
||||
(
|
||||
const labelList& agglom,
|
||||
const pointField& agglomPoints
|
||||
)
|
||||
{
|
||||
if (agglom.size() != mesh_.nCells())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"parMetisDecomp::decompose(const labelList&, const pointField&)"
|
||||
) << "Size of cell-to-coarse map " << agglom.size()
|
||||
<< " differs from number of cells in mesh " << mesh_.nCells()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Make Metis CSR (Compressed Storage Format) storage
|
||||
// adjncy : contains neighbours (= edges in graph)
|
||||
// xadj(celli) : start of information in adjncy for celli
|
||||
List<int> adjncy;
|
||||
List<int> xadj;
|
||||
{
|
||||
// Get cellCells on coarse mesh.
|
||||
labelListList cellCells;
|
||||
calcCellCells
|
||||
(
|
||||
mesh_,
|
||||
agglom,
|
||||
agglomPoints.size(),
|
||||
cellCells
|
||||
);
|
||||
|
||||
calcMetisCSR(cellCells, adjncy, xadj);
|
||||
}
|
||||
|
||||
// Decompose using default weights
|
||||
List<int> finalDecomp;
|
||||
decompose(adjncy, xadj, finalDecomp);
|
||||
|
||||
|
||||
// Rework back into decomposition for original mesh_
|
||||
labelList fineDistribution(agglom.size());
|
||||
|
||||
forAll(fineDistribution, i)
|
||||
{
|
||||
fineDistribution[i] = finalDecomp[agglom[i]];
|
||||
}
|
||||
|
||||
return fineDistribution;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList Foam::scotchDecomp::decompose
|
||||
(
|
||||
const labelListList& globalCellCells,
|
||||
const pointField& cellCentres
|
||||
)
|
||||
{
|
||||
if (cellCentres.size() != globalCellCells.size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"scotchDecomp::decompose(const pointField&, const labelListList&)"
|
||||
) << "Inconsistent number of cells (" << globalCellCells.size()
|
||||
<< ") and number of cell centres (" << cellCentres.size()
|
||||
<< ")." << exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Make Metis CSR (Compressed Storage Format) storage
|
||||
// adjncy : contains neighbours (= edges in graph)
|
||||
// xadj(celli) : start of information in adjncy for celli
|
||||
|
||||
List<int> adjncy;
|
||||
List<int> xadj;
|
||||
calcMetisCSR(globalCellCells, adjncy, xadj);
|
||||
|
||||
|
||||
// Decompose using default weights
|
||||
List<int> finalDecomp;
|
||||
decompose(adjncy, xadj, finalDecomp);
|
||||
|
||||
// Copy back to labelList
|
||||
labelList decomp(finalDecomp.size());
|
||||
forAll(decomp, i)
|
||||
{
|
||||
decomp[i] = finalDecomp[i];
|
||||
}
|
||||
return decomp;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,150 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::scotchDecomp
|
||||
|
||||
Description
|
||||
Scotch domain decomposition
|
||||
|
||||
SourceFiles
|
||||
scotchDecomp.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef scotchDecomp_H
|
||||
#define scotchDecomp_H
|
||||
|
||||
#include "decompositionMethod.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class scotchDecomp Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class scotchDecomp
|
||||
:
|
||||
public decompositionMethod
|
||||
{
|
||||
// Private data
|
||||
|
||||
const polyMesh& mesh_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Check and print error message
|
||||
static void check(const int, const char*);
|
||||
|
||||
label decompose
|
||||
(
|
||||
const List<int>& adjncy,
|
||||
const List<int>& xadj,
|
||||
List<int>& finalDecomp
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
void operator=(const scotchDecomp&);
|
||||
scotchDecomp(const scotchDecomp&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("scotch");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given the decomposition dictionary and mesh
|
||||
scotchDecomp
|
||||
(
|
||||
const dictionary& decompositionDict,
|
||||
const polyMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~scotchDecomp()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual bool parallelAware() const
|
||||
{
|
||||
// Metis does not know about proc boundaries
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Use the
|
||||
// mesh connectivity (if needed)
|
||||
virtual labelList decompose(const pointField&);
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Gets
|
||||
// passed agglomeration map (from fine to coarse cells) and coarse cell
|
||||
// location. Can be overridden by decomposers that provide this
|
||||
// functionality natively.
|
||||
virtual labelList decompose
|
||||
(
|
||||
const labelList& agglom,
|
||||
const pointField&
|
||||
);
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Explicitly
|
||||
// provided mesh connectivity.
|
||||
// The connectivity is equal to mesh.cellCells() except for
|
||||
// - in parallel the cell numbers are global cell numbers (starting
|
||||
// from 0 at processor0 and then incrementing all through the
|
||||
// processors)
|
||||
// - the connections are across coupled patches
|
||||
virtual labelList decompose
|
||||
(
|
||||
const labelListList& globalCellCells,
|
||||
const pointField& cc
|
||||
);
|
||||
|
||||
//- Helper to convert cellcells into compact row storage
|
||||
static void calcMetisCSR
|
||||
(
|
||||
const labelListList& globalCellCells,
|
||||
List<int>& adjncy,
|
||||
List<int>& xadj
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,6 +24,7 @@ $(constraintFvPatches)/processor/processorFvPatch.C
|
||||
derivedFvPatches = $(fvPatches)/derived
|
||||
$(derivedFvPatches)/wall/wallFvPatch.C
|
||||
$(derivedFvPatches)/directMapped/directMappedFvPatch.C
|
||||
$(derivedFvPatches)/directMapped/directMappedWallFvPatch.C
|
||||
|
||||
wallDist = fvMesh/wallDist
|
||||
$(wallDist)/wallPointYPlus/wallPointYPlus.C
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "directMappedFixedValueFvPatchField.H"
|
||||
#include "directMappedFvPatch.H"
|
||||
#include "directMappedPatchBase.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -61,7 +61,7 @@ directMappedFixedValueFvPatchField<Type>::directMappedFixedValueFvPatchField
|
||||
setAverage_(ptf.setAverage_),
|
||||
average_(ptf.average_)
|
||||
{
|
||||
if (!isType<directMappedFvPatch>(this->patch()))
|
||||
if (!isA<directMappedPatchBase>(this->patch().patch()))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
@ -74,7 +74,7 @@ directMappedFixedValueFvPatchField<Type>::directMappedFixedValueFvPatchField
|
||||
" const fvPatchFieldMapper&\n"
|
||||
")\n"
|
||||
) << "\n patch type '" << p.type()
|
||||
<< "' not type '" << typeName << "'"
|
||||
<< "' not type '" << directMappedPatchBase::typeName << "'"
|
||||
<< "\n for patch " << p.name()
|
||||
<< " of field " << this->dimensionedInternalField().name()
|
||||
<< " in file " << this->dimensionedInternalField().objectPath()
|
||||
@ -95,7 +95,7 @@ directMappedFixedValueFvPatchField<Type>::directMappedFixedValueFvPatchField
|
||||
setAverage_(readBool(dict.lookup("setAverage"))),
|
||||
average_(pTraits<Type>(dict.lookup("average")))
|
||||
{
|
||||
if (!isType<directMappedFvPatch>(this->patch()))
|
||||
if (!isA<directMappedPatchBase>(this->patch().patch()))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
@ -107,12 +107,19 @@ directMappedFixedValueFvPatchField<Type>::directMappedFixedValueFvPatchField
|
||||
" const dictionary& dict\n"
|
||||
")\n"
|
||||
) << "\n patch type '" << p.type()
|
||||
<< "' not type '" << typeName << "'"
|
||||
<< "' not type '" << directMappedPatchBase::typeName << "'"
|
||||
<< "\n for patch " << p.name()
|
||||
<< " of field " << this->dimensionedInternalField().name()
|
||||
<< " in file " << this->dimensionedInternalField().objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Force calculation of schedule (uses parallel comms)
|
||||
const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
|
||||
(
|
||||
this->patch().patch()
|
||||
);
|
||||
(void)mpp.map().schedule();
|
||||
}
|
||||
|
||||
|
||||
@ -143,70 +150,6 @@ directMappedFixedValueFvPatchField<Type>::directMappedFixedValueFvPatchField
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void directMappedFixedValueFvPatchField<Type>::getNewValues
|
||||
(
|
||||
const directMappedPolyPatch& mpp,
|
||||
const Field<Type>& sendValues,
|
||||
Field<Type>& newValues
|
||||
) const
|
||||
{
|
||||
// Get the scheduling information
|
||||
const List<labelPair>& schedule = mpp.schedule();
|
||||
const labelListList& sendLabels = mpp.sendLabels();
|
||||
const labelListList& receiveFaceLabels = mpp.receiveFaceLabels();
|
||||
|
||||
forAll(schedule, i)
|
||||
{
|
||||
const labelPair& twoProcs = schedule[i];
|
||||
label sendProc = twoProcs[0];
|
||||
label recvProc = twoProcs[1];
|
||||
|
||||
if (Pstream::myProcNo() == sendProc)
|
||||
{
|
||||
OPstream toProc(Pstream::scheduled, recvProc);
|
||||
toProc<< UIndirectList<Type>(sendValues, sendLabels[recvProc])();
|
||||
}
|
||||
else
|
||||
{
|
||||
// I am receiver. Receive from sendProc.
|
||||
IPstream fromProc(Pstream::scheduled, sendProc);
|
||||
|
||||
Field<Type> fromFld(fromProc);
|
||||
|
||||
// Destination faces
|
||||
const labelList& faceLabels = receiveFaceLabels[sendProc];
|
||||
|
||||
forAll(fromFld, i)
|
||||
{
|
||||
label patchFaceI = faceLabels[i];
|
||||
|
||||
newValues[patchFaceI] = fromFld[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do data from myself
|
||||
{
|
||||
UIndirectList<Type> fromFld
|
||||
(
|
||||
sendValues,
|
||||
sendLabels[Pstream::myProcNo()]
|
||||
);
|
||||
|
||||
// Destination faces
|
||||
const labelList& faceLabels = receiveFaceLabels[Pstream::myProcNo()];
|
||||
|
||||
forAll(fromFld, i)
|
||||
{
|
||||
label patchFaceI = faceLabels[i];
|
||||
|
||||
newValues[patchFaceI] = fromFld[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
@ -215,65 +158,94 @@ void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the directMappedPolyPatch
|
||||
const directMappedPolyPatch& mpp = refCast<const directMappedPolyPatch>
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
// Get the scheduling information from the directMappedPatchBase
|
||||
const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
|
||||
(
|
||||
directMappedFixedValueFvPatchField<Type>::patch().patch()
|
||||
);
|
||||
const mapDistribute& distMap = mpp.map();
|
||||
const fvMesh& nbrMesh = refCast<const fvMesh>(mpp.sampleMesh());
|
||||
const word& fldName = this->dimensionedInternalField().name();
|
||||
|
||||
Field<Type> newValues(this->size());
|
||||
// Result of obtaining remote values
|
||||
Field<Type> newValues;
|
||||
|
||||
switch (mpp.mode())
|
||||
{
|
||||
case directMappedPolyPatch::NEARESTCELL:
|
||||
case directMappedPatchBase::NEARESTCELL:
|
||||
{
|
||||
getNewValues(mpp, this->internalField(), newValues);
|
||||
if (mpp.sameRegion())
|
||||
{
|
||||
newValues = this->internalField();
|
||||
}
|
||||
else
|
||||
{
|
||||
newValues = nbrMesh.lookupObject<fieldType>
|
||||
(
|
||||
fldName
|
||||
).internalField();
|
||||
}
|
||||
mapDistribute::distribute
|
||||
(
|
||||
Pstream::defaultCommsType,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
newValues
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case directMappedPolyPatch::NEARESTPATCHFACE:
|
||||
case directMappedPatchBase::NEARESTPATCHFACE:
|
||||
{
|
||||
const label patchID =
|
||||
this->patch().patch().boundaryMesh().findPatchID
|
||||
(
|
||||
mpp.samplePatch()
|
||||
);
|
||||
if (patchID < 0)
|
||||
const label nbrPatchID = nbrMesh.boundaryMesh().findPatchID
|
||||
(
|
||||
mpp.samplePatch()
|
||||
);
|
||||
if (nbrPatchID < 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"void directMappedFixedValueFvPatchField<Type>::"
|
||||
"updateCoeffs()"
|
||||
)<< "Unable to find sample patch " << mpp.samplePatch()
|
||||
<< " in region " << mpp.sampleRegion()
|
||||
<< " for patch " << this->patch().name() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
const word& fieldName = this->dimensionedInternalField().name();
|
||||
const fieldType& sendField =
|
||||
this->db().objectRegistry::lookupObject<fieldType>(fieldName);
|
||||
|
||||
getNewValues(mpp, sendField.boundaryField()[patchID], newValues);
|
||||
const fieldType& nbrField = nbrMesh.lookupObject<fieldType>
|
||||
(
|
||||
fldName
|
||||
);
|
||||
newValues = nbrField.boundaryField()[nbrPatchID];
|
||||
mapDistribute::distribute
|
||||
(
|
||||
Pstream::defaultCommsType,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
newValues
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case directMappedPolyPatch::NEARESTFACE:
|
||||
case directMappedPatchBase::NEARESTFACE:
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
const word& fieldName = this->dimensionedInternalField().name();
|
||||
const fieldType& sendField =
|
||||
this->db().objectRegistry::lookupObject<fieldType>(fieldName);
|
||||
Field<Type> allValues(nbrMesh.nFaces(), pTraits<Type>::zero);
|
||||
|
||||
Field<Type> allValues
|
||||
const fieldType& nbrField = nbrMesh.lookupObject<fieldType>
|
||||
(
|
||||
this->patch().patch().boundaryMesh().mesh().nFaces(),
|
||||
pTraits<Type>::zero
|
||||
fldName
|
||||
);
|
||||
|
||||
forAll(sendField.boundaryField(), patchI)
|
||||
forAll(nbrField.boundaryField(), patchI)
|
||||
{
|
||||
const fvPatchField<Type>& pf =
|
||||
sendField.boundaryField()[patchI];
|
||||
nbrField.boundaryField()[patchI];
|
||||
label faceStart = pf.patch().patch().start();
|
||||
|
||||
forAll(pf, faceI)
|
||||
@ -282,9 +254,17 @@ void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
}
|
||||
}
|
||||
|
||||
getNewValues(mpp, allValues, newValues);
|
||||
mapDistribute::distribute
|
||||
(
|
||||
Pstream::defaultCommsType,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
allValues
|
||||
);
|
||||
|
||||
newValues = this->patch().patchSlice(newValues);
|
||||
newValues = this->patch().patchSlice(allValues);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -316,6 +296,16 @@ void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
|
||||
this->operator==(newValues);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "directMapped on field:" << fldName
|
||||
<< " patch:" << this->patch().name()
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
fixedValueFvPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
@ -62,18 +62,6 @@ class directMappedFixedValueFvPatchField
|
||||
// setAverage_ is set true
|
||||
Type average_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
// Helper function to return the new field values
|
||||
void getNewValues
|
||||
(
|
||||
const directMappedPolyPatch& mpp,
|
||||
const Field<Type>& sendValues,
|
||||
Field<Type>& newValues
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
|
||||
#include "directMappedVelocityFluxFixedValueFvPatchField.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "directMappedFvPatch.H"
|
||||
#include "directMappedPatchBase.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
@ -62,12 +62,12 @@ directMappedVelocityFluxFixedValueFvPatchField
|
||||
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
|
||||
phiName_(ptf.phiName_)
|
||||
{
|
||||
if (!isType<directMappedFvPatch>(patch()))
|
||||
if (!isType<directMappedPatchBase>(this->patch().patch()))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedVelocityFluxFixedValueFvPatchField::"
|
||||
"directMappedFixedValueFvPatchField\n"
|
||||
"directMappedVelocityFluxFixedValueFvPatchField\n"
|
||||
"(\n"
|
||||
" const directMappedVelocityFluxFixedValueFvPatchField&,\n"
|
||||
" const fvPatch&,\n"
|
||||
@ -75,7 +75,7 @@ directMappedVelocityFluxFixedValueFvPatchField
|
||||
" const fvPatchFieldMapper&\n"
|
||||
")\n"
|
||||
) << "\n patch type '" << p.type()
|
||||
<< "' not type '" << typeName << "'"
|
||||
<< "' not type '" << directMappedPatchBase::typeName << "'"
|
||||
<< "\n for patch " << p.name()
|
||||
<< " of field " << dimensionedInternalField().name()
|
||||
<< " in file " << dimensionedInternalField().objectPath()
|
||||
@ -95,24 +95,31 @@ directMappedVelocityFluxFixedValueFvPatchField
|
||||
fixedValueFvPatchVectorField(p, iF, dict),
|
||||
phiName_(dict.lookup("phi"))
|
||||
{
|
||||
if (!isType<directMappedFvPatch>(patch()))
|
||||
if (!isType<directMappedPatchBase>(this->patch().patch()))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedVelocityFluxFixedValueFvPatchField::"
|
||||
"directMappedFixedValueFvPatchField\n"
|
||||
"directMappedVelocityFluxFixedValueFvPatchField\n"
|
||||
"(\n"
|
||||
" const fvPatch& p,\n"
|
||||
" const DimensionedField<vector, volMesh>& iF,\n"
|
||||
" const dictionary& dict\n"
|
||||
")\n"
|
||||
) << "\n patch type '" << p.type()
|
||||
<< "' not type '" << typeName << "'"
|
||||
<< "' not type '" << directMappedPatchBase::typeName << "'"
|
||||
<< "\n for patch " << p.name()
|
||||
<< " of field " << dimensionedInternalField().name()
|
||||
<< " in file " << dimensionedInternalField().objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Force calculation of schedule (uses parallel comms)
|
||||
const directMappedPolyPatch& mpp = refCast<const directMappedPolyPatch>
|
||||
(
|
||||
patch().patch()
|
||||
);
|
||||
(void)mpp.map().schedule();
|
||||
}
|
||||
|
||||
|
||||
@ -139,85 +146,6 @@ directMappedVelocityFluxFixedValueFvPatchField
|
||||
{}
|
||||
|
||||
|
||||
void directMappedVelocityFluxFixedValueFvPatchField::getNewValues
|
||||
(
|
||||
const directMappedPolyPatch& mpp,
|
||||
const vectorField& sendUValues,
|
||||
const scalarField& sendPhiValues,
|
||||
vectorField& newUValues,
|
||||
scalarField& newPhiValues
|
||||
) const
|
||||
{
|
||||
// Get the scheduling information
|
||||
const List<labelPair>& schedule = mpp.schedule();
|
||||
const labelListList& sendLabels = mpp.sendLabels();
|
||||
const labelListList& receiveFaceLabels = mpp.receiveFaceLabels();
|
||||
|
||||
forAll(schedule, i)
|
||||
{
|
||||
const labelPair& twoProcs = schedule[i];
|
||||
label sendProc = twoProcs[0];
|
||||
label recvProc = twoProcs[1];
|
||||
|
||||
if (Pstream::myProcNo() == sendProc)
|
||||
{
|
||||
OPstream toProc(Pstream::scheduled, recvProc);
|
||||
toProc<< UIndirectList<vector>(sendUValues, sendLabels[recvProc])();
|
||||
toProc<< UIndirectList<scalar>
|
||||
(
|
||||
sendPhiValues,
|
||||
sendLabels[recvProc]
|
||||
)();
|
||||
}
|
||||
else
|
||||
{
|
||||
// I am receiver. Receive from sendProc.
|
||||
IPstream fromProc(Pstream::scheduled, sendProc);
|
||||
|
||||
vectorField fromUFld(fromProc);
|
||||
scalarField fromPhiFld(fromProc);
|
||||
|
||||
// Destination faces
|
||||
const labelList& faceLabels = receiveFaceLabels[sendProc];
|
||||
|
||||
forAll(fromUFld, i)
|
||||
{
|
||||
label patchFaceI = faceLabels[i];
|
||||
|
||||
newUValues[patchFaceI] = fromUFld[i];
|
||||
newPhiValues[patchFaceI] = fromPhiFld[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do data from myself
|
||||
{
|
||||
UIndirectList<vector> fromUFld
|
||||
(
|
||||
sendUValues,
|
||||
sendLabels[Pstream::myProcNo()]
|
||||
);
|
||||
|
||||
UIndirectList<scalar> fromPhiFld
|
||||
(
|
||||
sendPhiValues,
|
||||
sendLabels[Pstream::myProcNo()]
|
||||
);
|
||||
|
||||
// Destination faces
|
||||
const labelList& faceLabels = receiveFaceLabels[Pstream::myProcNo()];
|
||||
|
||||
forAll(fromUFld, i)
|
||||
{
|
||||
label patchFaceI = faceLabels[i];
|
||||
|
||||
newUValues[patchFaceI] = fromUFld[i];
|
||||
newPhiValues[patchFaceI] = fromPhiFld[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
|
||||
@ -227,37 +155,33 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the directMappedPolyPatch
|
||||
const directMappedPolyPatch& mpp = refCast<const directMappedPolyPatch>
|
||||
// Get the directMappedPatchBase
|
||||
const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
|
||||
(
|
||||
directMappedVelocityFluxFixedValueFvPatchField::patch().patch()
|
||||
);
|
||||
|
||||
vectorField newUValues(size());
|
||||
scalarField newPhiValues(size());
|
||||
|
||||
const mapDistribute& distMap = mpp.map();
|
||||
const fvMesh& nbrMesh = refCast<const fvMesh>(mpp.sampleMesh());
|
||||
const word& fieldName = dimensionedInternalField().name();
|
||||
const volVectorField& UField = db().lookupObject<volVectorField>(fieldName);
|
||||
const volVectorField& UField = nbrMesh.lookupObject<volVectorField>
|
||||
(
|
||||
fieldName
|
||||
);
|
||||
|
||||
surfaceScalarField& phiField = const_cast<surfaceScalarField&>
|
||||
(
|
||||
db().lookupObject<surfaceScalarField>(phiName_)
|
||||
nbrMesh.lookupObject<surfaceScalarField>(phiName_)
|
||||
);
|
||||
|
||||
vectorField newUValues;
|
||||
scalarField newPhiValues;
|
||||
|
||||
switch (mpp.mode())
|
||||
{
|
||||
case directMappedPolyPatch::NEARESTFACE:
|
||||
{
|
||||
vectorField allUValues
|
||||
(
|
||||
patch().patch().boundaryMesh().mesh().nFaces(),
|
||||
vector::zero
|
||||
);
|
||||
scalarField allPhiValues
|
||||
(
|
||||
patch().patch().boundaryMesh().mesh().nFaces(),
|
||||
0.0
|
||||
);
|
||||
vectorField allUValues(nbrMesh.nFaces(), vector::zero);
|
||||
scalarField allPhiValues(nbrMesh.nFaces(), 0.0);
|
||||
|
||||
forAll(UField.boundaryField(), patchI)
|
||||
{
|
||||
@ -273,34 +197,58 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
|
||||
}
|
||||
}
|
||||
|
||||
getNewValues
|
||||
mapDistribute::distribute
|
||||
(
|
||||
mpp,
|
||||
allUValues,
|
||||
allPhiValues,
|
||||
newUValues,
|
||||
Pstream::defaultCommsType,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
allUValues
|
||||
);
|
||||
newUValues = patch().patchSlice(newUValues);
|
||||
|
||||
mapDistribute::distribute
|
||||
(
|
||||
Pstream::defaultCommsType,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
newPhiValues
|
||||
);
|
||||
|
||||
newUValues = patch().patchSlice(newUValues);
|
||||
newPhiValues = patch().patchSlice(newPhiValues);
|
||||
|
||||
break;
|
||||
}
|
||||
case directMappedPolyPatch::NEARESTPATCHFACE:
|
||||
{
|
||||
const label patchID =
|
||||
patch().patch().boundaryMesh().findPatchID
|
||||
(
|
||||
mpp.samplePatch()
|
||||
);
|
||||
|
||||
getNewValues
|
||||
const label nbrPatchID = nbrMesh.boundaryMesh().findPatchID
|
||||
(
|
||||
mpp,
|
||||
UField.boundaryField()[patchID],
|
||||
phiField.boundaryField()[patchID],
|
||||
newUValues,
|
||||
mpp.samplePatch()
|
||||
);
|
||||
|
||||
newUValues = UField.boundaryField()[nbrPatchID];
|
||||
|
||||
mapDistribute::distribute
|
||||
(
|
||||
Pstream::defaultCommsType,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
newUValues
|
||||
);
|
||||
|
||||
newPhiValues = phiField.boundaryField()[nbrPatchID];
|
||||
|
||||
mapDistribute::distribute
|
||||
(
|
||||
Pstream::defaultCommsType,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
newPhiValues
|
||||
);
|
||||
|
||||
|
||||
@ -57,20 +57,6 @@ class directMappedVelocityFluxFixedValueFvPatchField
|
||||
//- Name of flux field
|
||||
word phiName_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
// Helper function to return the new field values
|
||||
void getNewValues
|
||||
(
|
||||
const directMappedPolyPatch& mpp,
|
||||
const vectorField& sendUValues,
|
||||
const scalarField& sendPhiValues,
|
||||
vectorField& newUValues,
|
||||
scalarField& newPhiValues
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
|
||||
@ -189,7 +189,8 @@ void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
|
||||
}
|
||||
|
||||
|
||||
void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const
|
||||
void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os)
|
||||
const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
if (UName_ != "U")
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "directMappedWallFvPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(directMappedWallFvPatch, 0);
|
||||
addToRunTimeSelectionTable(fvPatch, directMappedWallFvPatch, polyPatch);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::directMappedWallFvPatch
|
||||
|
||||
Description
|
||||
Foam::directMappedWallFvPatch
|
||||
|
||||
SourceFiles
|
||||
directMappedWallFvPatch.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef directMappedWallFvPatch_H
|
||||
#define directMappedWallFvPatch_H
|
||||
|
||||
#include "fvPatch.H"
|
||||
#include "directMappedWallPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class directMappedWallFvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class directMappedWallFvPatch
|
||||
:
|
||||
public fvPatch
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName(directMappedWallPolyPatch::typeName_());
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
directMappedWallFvPatch
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const fvBoundaryMesh& bm
|
||||
)
|
||||
:
|
||||
fvPatch(patch, bm)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -142,7 +142,10 @@ triSurface/triSurfaceTools/geompack/geompack.C
|
||||
|
||||
twoDPointCorrector/twoDPointCorrector.C
|
||||
|
||||
directMapped/directMappedPolyPatch/directMappedPatchBase.C
|
||||
directMapped/directMappedPolyPatch/directMappedPolyPatch.C
|
||||
directMapped/directMappedPolyPatch/directMappedWallPolyPatch.C
|
||||
directMapped/directMappedPointPatch/directMappedPointPatch.C
|
||||
directMapped/directMappedPointPatch/directMappedWallPointPatch.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libmeshTools
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "directMappedWallPointPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(directMappedWallPointPatch, 0);
|
||||
|
||||
// Add the patch constructor functions to the hash tables
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
facePointPatch,
|
||||
directMappedWallPointPatch,
|
||||
polyPatch
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::directMappedWallPointPatch
|
||||
|
||||
Description
|
||||
DirectMapped patch.
|
||||
|
||||
SourceFiles
|
||||
directMappedWallPointPatch.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef directMappedWallPointPatch_H
|
||||
#define directMappedWallPointPatch_H
|
||||
|
||||
#include "facePointPatch.H"
|
||||
#include "directMappedWallPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class directMappedWallPointPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class directMappedWallPointPatch
|
||||
:
|
||||
public facePointPatch
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName(directMappedWallPolyPatch::typeName_());
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from polyPatch
|
||||
directMappedWallPointPatch
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const pointBoundaryMesh& bm
|
||||
)
|
||||
:
|
||||
facePointPatch(patch, bm)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,657 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "directMappedPatchBase.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "ListListOps.H"
|
||||
#include "meshSearch.H"
|
||||
#include "meshTools.H"
|
||||
#include "OFstream.H"
|
||||
#include "Random.H"
|
||||
#include "treeDataFace.H"
|
||||
#include "indexedOctree.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(directMappedPatchBase, 0);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<directMappedPatchBase::sampleMode, 3>::names[] =
|
||||
{
|
||||
"nearestCell",
|
||||
"nearestPatchFace",
|
||||
"nearestFace"
|
||||
};
|
||||
|
||||
const NamedEnum<directMappedPatchBase::sampleMode, 3>
|
||||
directMappedPatchBase::sampleModeNames_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::directMappedPatchBase::collectSamples
|
||||
(
|
||||
pointField& samples,
|
||||
labelList& patchFaceProcs,
|
||||
labelList& patchFaces,
|
||||
pointField& patchFc
|
||||
) const
|
||||
{
|
||||
|
||||
// Collect all sample points and the faces they come from.
|
||||
List<pointField> globalFc(Pstream::nProcs());
|
||||
List<pointField> globalSamples(Pstream::nProcs());
|
||||
labelListList globalFaces(Pstream::nProcs());
|
||||
|
||||
globalFc[Pstream::myProcNo()] = patch_.faceCentres();
|
||||
globalSamples[Pstream::myProcNo()] = globalFc[Pstream::myProcNo()]+offset_;
|
||||
globalFaces[Pstream::myProcNo()] = identity(patch_.size());
|
||||
|
||||
// Distribute to all processors
|
||||
Pstream::gatherList(globalSamples);
|
||||
Pstream::scatterList(globalSamples);
|
||||
Pstream::gatherList(globalFaces);
|
||||
Pstream::scatterList(globalFaces);
|
||||
Pstream::gatherList(globalFc);
|
||||
Pstream::scatterList(globalFc);
|
||||
|
||||
// Rework into straight list
|
||||
samples = ListListOps::combine<pointField>
|
||||
(
|
||||
globalSamples,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
patchFaces = ListListOps::combine<labelList>
|
||||
(
|
||||
globalFaces,
|
||||
accessOp<labelList>()
|
||||
);
|
||||
patchFc = ListListOps::combine<pointField>
|
||||
(
|
||||
globalFc,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
|
||||
patchFaceProcs.setSize(patchFaces.size());
|
||||
labelList nPerProc
|
||||
(
|
||||
ListListOps::subSizes
|
||||
(
|
||||
globalFaces,
|
||||
accessOp<labelList>()
|
||||
)
|
||||
);
|
||||
label sampleI = 0;
|
||||
forAll(nPerProc, procI)
|
||||
{
|
||||
for (label i = 0; i < nPerProc[procI]; i++)
|
||||
{
|
||||
patchFaceProcs[sampleI++] = procI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find the processor/cell containing the samples. Does not account
|
||||
// for samples being found in two processors.
|
||||
void Foam::directMappedPatchBase::findSamples
|
||||
(
|
||||
const pointField& samples,
|
||||
labelList& sampleProcs,
|
||||
labelList& sampleIndices,
|
||||
pointField& sampleLocations
|
||||
) const
|
||||
{
|
||||
// Lookup the correct region
|
||||
const polyMesh& mesh = sampleMesh();
|
||||
|
||||
// All the info for nearest. Construct to miss
|
||||
List<nearInfo> nearest(samples.size());
|
||||
|
||||
switch (mode_)
|
||||
{
|
||||
case NEARESTCELL:
|
||||
{
|
||||
if (samplePatch_.size() && samplePatch_ != "none")
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedPatchBase::findSamples(const pointField&,"
|
||||
" labelList&, labelList&, pointField&) const"
|
||||
) << "No need to supply a patch name when in "
|
||||
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
|
||||
}
|
||||
|
||||
// Octree based search engine
|
||||
meshSearch meshSearchEngine(mesh, false);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& sample = samples[sampleI];
|
||||
|
||||
label cellI = meshSearchEngine.findCell(sample);
|
||||
|
||||
if (cellI == -1)
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
else
|
||||
{
|
||||
const point& cc = mesh.cellCentres()[cellI];
|
||||
|
||||
nearest[sampleI].first() = pointIndexHit
|
||||
(
|
||||
true,
|
||||
cc,
|
||||
cellI
|
||||
);
|
||||
nearest[sampleI].second().first() = magSqr(cc-sample);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NEARESTPATCHFACE:
|
||||
{
|
||||
Random rndGen(123456);
|
||||
|
||||
const polyPatch& pp = samplePolyPatch();
|
||||
|
||||
if (pp.empty())
|
||||
{
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// patch faces
|
||||
const labelList patchFaces(identity(pp.size()) + pp.start());
|
||||
|
||||
treeBoundBox patchBb
|
||||
(
|
||||
treeBoundBox(pp.points(), pp.meshPoints()).extend
|
||||
(
|
||||
rndGen,
|
||||
1E-4
|
||||
)
|
||||
);
|
||||
patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
indexedOctree<treeDataFace> boundaryTree
|
||||
(
|
||||
treeDataFace // all information needed to search faces
|
||||
(
|
||||
false, // do not cache bb
|
||||
mesh,
|
||||
patchFaces // boundary faces only
|
||||
),
|
||||
patchBb, // overall search domain
|
||||
8, // maxLevel
|
||||
10, // leafsize
|
||||
3.0 // duplicity
|
||||
);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& sample = samples[sampleI];
|
||||
|
||||
pointIndexHit& nearInfo = nearest[sampleI].first();
|
||||
nearInfo = boundaryTree.findNearest
|
||||
(
|
||||
sample,
|
||||
magSqr(patchBb.span())
|
||||
);
|
||||
|
||||
if (!nearInfo.hit())
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() =
|
||||
Pstream::myProcNo();
|
||||
}
|
||||
else
|
||||
{
|
||||
point fc(pp[nearInfo.index()].centre(pp.points()));
|
||||
nearInfo.setPoint(fc);
|
||||
nearest[sampleI].second().first() = magSqr(fc-sample);
|
||||
nearest[sampleI].second().second() =
|
||||
Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NEARESTFACE:
|
||||
{
|
||||
if (samplePatch_.size() && samplePatch_ != "none")
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedPatchBase::findSamples(const pointField&,"
|
||||
" labelList&, labelList&, pointField&) const"
|
||||
) << "No need to supply a patch name when in "
|
||||
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
|
||||
}
|
||||
|
||||
// Octree based search engine
|
||||
meshSearch meshSearchEngine(mesh, false);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& sample = samples[sampleI];
|
||||
|
||||
label faceI = meshSearchEngine.findNearestFace(sample);
|
||||
|
||||
if (faceI == -1)
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
else
|
||||
{
|
||||
const point& fc = mesh.faceCentres()[faceI];
|
||||
|
||||
nearest[sampleI].first() = pointIndexHit
|
||||
(
|
||||
true,
|
||||
fc,
|
||||
faceI
|
||||
);
|
||||
nearest[sampleI].second().first() = magSqr(fc-sample);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("directMappedPatchBase::findSamples(..)")
|
||||
<< "problem." << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find nearest.
|
||||
Pstream::listCombineGather(nearest, nearestEqOp());
|
||||
Pstream::listCombineScatter(nearest);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "directMappedPatchBase::findSamples on mesh " << sampleRegion_
|
||||
<< " : " << endl;
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
label procI = nearest[sampleI].second().second();
|
||||
label localI = nearest[sampleI].first().index();
|
||||
|
||||
Info<< " " << sampleI << " coord:"<< samples[sampleI]
|
||||
<< " found on processor:" << procI
|
||||
<< " in local cell/face:" << localI
|
||||
<< " with cc:" << nearest[sampleI].first().rawPoint() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for samples not being found
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
if (!nearest[sampleI].first().hit())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedPatchBase::findSamples"
|
||||
"(const pointField&, labelList&"
|
||||
", labelList&, pointField&)"
|
||||
) << "Did not find sample " << samples[sampleI]
|
||||
<< " on any processor of region" << sampleRegion_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert back into proc+local index
|
||||
sampleProcs.setSize(samples.size());
|
||||
sampleIndices.setSize(samples.size());
|
||||
sampleLocations.setSize(samples.size());
|
||||
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
sampleProcs[sampleI] = nearest[sampleI].second().second();
|
||||
sampleIndices[sampleI] = nearest[sampleI].first().index();
|
||||
sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::directMappedPatchBase::calcMapping() const
|
||||
{
|
||||
if (mapPtr_.valid())
|
||||
{
|
||||
FatalErrorIn("directMappedPatchBase::calcMapping() const")
|
||||
<< "Mapping already calculated" << exit(FatalError);
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
offset_ == vector::zero
|
||||
&& sampleRegion_ == patch_.boundaryMesh().mesh().name()
|
||||
)
|
||||
{
|
||||
FatalErrorIn("directMappedPatchBase::calcMapping() const")
|
||||
<< "Invalid offset " << offset_ << endl
|
||||
<< "Offset is the vector added to the patch face centres to"
|
||||
<< " find the cell supplying the data."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Get global list of all samples and the processor and face they come from.
|
||||
pointField samples;
|
||||
labelList patchFaceProcs;
|
||||
labelList patchFaces;
|
||||
pointField patchFc;
|
||||
collectSamples(samples, patchFaceProcs, patchFaces, patchFc);
|
||||
|
||||
// Find processor and cell/face samples are in and actual location.
|
||||
labelList sampleProcs;
|
||||
labelList sampleIndices;
|
||||
pointField sampleLocations;
|
||||
findSamples(samples, sampleProcs, sampleIndices, sampleLocations);
|
||||
|
||||
|
||||
// Now we have all the data we need:
|
||||
// - where sample originates from (so destination when mapping):
|
||||
// patchFaces, patchFaceProcs.
|
||||
// - cell/face sample is in (so source when mapping)
|
||||
// sampleIndices, sampleProcs.
|
||||
|
||||
//forAll(samples, i)
|
||||
//{
|
||||
// Info<< i << " need data in region "
|
||||
// << patch_.boundaryMesh().mesh().name()
|
||||
// << " for proc:" << patchFaceProcs[i]
|
||||
// << " face:" << patchFaces[i]
|
||||
// << " at:" << patchFc[i] << endl
|
||||
// << "Found data in region " << sampleRegion_
|
||||
// << " at proc:" << sampleProcs[i]
|
||||
// << " face:" << sampleIndices[i]
|
||||
// << " at:" << sampleLocations[i]
|
||||
// << nl << endl;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
if (debug && Pstream::master())
|
||||
{
|
||||
OFstream str
|
||||
(
|
||||
patch_.boundaryMesh().mesh().time().path()
|
||||
/ patch_.name()
|
||||
+ "_directMapped.obj"
|
||||
);
|
||||
Pout<< "Dumping mapping as lines from patch faceCentres to"
|
||||
<< " sampled cellCentres to file " << str.name() << endl;
|
||||
|
||||
label vertI = 0;
|
||||
|
||||
forAll(patchFc, i)
|
||||
{
|
||||
meshTools::writeOBJ(str, patchFc[i]);
|
||||
vertI++;
|
||||
meshTools::writeOBJ(str, sampleLocations[i]);
|
||||
vertI++;
|
||||
str << "l " << vertI-1 << ' ' << vertI << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check that actual offset vector (sampleLocations - patchFc) is more or
|
||||
// less constant.
|
||||
if (Pstream::master())
|
||||
{
|
||||
const scalarField magOffset(mag(sampleLocations - patchFc));
|
||||
const scalar avgOffset(average(magOffset));
|
||||
|
||||
forAll(magOffset, sampleI)
|
||||
{
|
||||
if (mag(magOffset[sampleI]-avgOffset) > max(SMALL, 0.001*avgOffset))
|
||||
{
|
||||
WarningIn("directMappedPatchBase::calcMapping() const")
|
||||
<< "The actual cell/face centres picked up using offset "
|
||||
<< offset_ << " are not" << endl
|
||||
<< " on a single plane."
|
||||
<< " This might give numerical problems." << endl
|
||||
<< " At patchface " << patchFc[sampleI]
|
||||
<< " the sampled cell/face " << sampleLocations[sampleI]
|
||||
<< endl
|
||||
<< " is not on a plane " << avgOffset
|
||||
<< " offset from the patch." << endl
|
||||
<< " You might want to shift your plane offset."
|
||||
<< " Set the debug flag to get a dump of sampled cells."
|
||||
<< endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Determine schedule.
|
||||
mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs));
|
||||
|
||||
// Rework the schedule from indices into samples to cell data to send,
|
||||
// face data to receive.
|
||||
|
||||
labelListList& subMap = mapPtr_().subMap();
|
||||
labelListList& constructMap = mapPtr_().constructMap();
|
||||
|
||||
forAll(subMap, procI)
|
||||
{
|
||||
subMap[procI] = UIndirectList<label>
|
||||
(
|
||||
sampleIndices,
|
||||
subMap[procI]
|
||||
);
|
||||
constructMap[procI] = UIndirectList<label>
|
||||
(
|
||||
patchFaces,
|
||||
constructMap[procI]
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "To proc:" << procI << " sending values of cells/faces:"
|
||||
<< subMap[procI] << endl;
|
||||
Pout<< "From proc:" << procI << " receiving values of patch faces:"
|
||||
<< constructMap[procI] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Redo constructSize
|
||||
mapPtr_().constructSize() = patch_.size();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// Check that all elements get a value.
|
||||
PackedBoolList used(patch_.size());
|
||||
forAll(constructMap, procI)
|
||||
{
|
||||
const labelList& map = constructMap[procI];
|
||||
|
||||
forAll(map, i)
|
||||
{
|
||||
label faceI = map[i];
|
||||
|
||||
if (used[faceI] == 0)
|
||||
{
|
||||
used[faceI] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("directMappedPatchBase::calcMapping() const")
|
||||
<< "On patch " << patch_.name()
|
||||
<< " patchface " << faceI
|
||||
<< " is assigned to more than once."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
forAll(used, faceI)
|
||||
{
|
||||
if (used[faceI] == 0)
|
||||
{
|
||||
FatalErrorIn("directMappedPatchBase::calcMapping() const")
|
||||
<< "On patch " << patch_.name()
|
||||
<< " patchface " << faceI
|
||||
<< " is never assigned to."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::directMappedPatchBase::directMappedPatchBase
|
||||
(
|
||||
const polyPatch& pp
|
||||
)
|
||||
:
|
||||
patch_(pp),
|
||||
sampleRegion_(patch_.boundaryMesh().mesh().name()),
|
||||
mode_(NEARESTPATCHFACE),
|
||||
samplePatch_("none"),
|
||||
offset_(vector::zero),
|
||||
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
|
||||
mapPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::directMappedPatchBase::directMappedPatchBase
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
patch_(pp),
|
||||
sampleRegion_
|
||||
(
|
||||
dict.lookupOrDefault
|
||||
(
|
||||
"sampleRegion",
|
||||
patch_.boundaryMesh().mesh().name()
|
||||
)
|
||||
),
|
||||
mode_(sampleModeNames_.read(dict.lookup("sampleMode"))),
|
||||
samplePatch_(dict.lookup("samplePatch")),
|
||||
offset_(dict.lookup("offset")),
|
||||
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
|
||||
mapPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::directMappedPatchBase::directMappedPatchBase
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const directMappedPatchBase& dmp
|
||||
)
|
||||
:
|
||||
patch_(pp),
|
||||
sampleRegion_(dmp.sampleRegion_),
|
||||
mode_(dmp.mode_),
|
||||
samplePatch_(dmp.samplePatch_),
|
||||
offset_(dmp.offset_),
|
||||
sameRegion_(dmp.sameRegion_),
|
||||
mapPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::directMappedPatchBase::~directMappedPatchBase()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
|
||||
|
||||
void Foam::directMappedPatchBase::clearOut()
|
||||
{
|
||||
mapPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::polyMesh& Foam::directMappedPatchBase::sampleMesh() const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh().time().lookupObject<polyMesh>
|
||||
(
|
||||
sampleRegion_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const Foam::polyPatch& Foam::directMappedPatchBase::samplePolyPatch() const
|
||||
{
|
||||
const polyMesh& nbrMesh = sampleMesh();
|
||||
|
||||
label patchI = nbrMesh.boundaryMesh().findPatchID(samplePatch_);
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
FatalErrorIn("directMappedPatchBase::samplePolyPatch() ")
|
||||
<< "Cannot find patch " << samplePatch_
|
||||
<< " in region " << sampleRegion_ << endl
|
||||
<< "Valid patches are " << nbrMesh.boundaryMesh().names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return nbrMesh.boundaryMesh()[patchI];
|
||||
}
|
||||
|
||||
|
||||
void Foam::directMappedPatchBase::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("sampleMode") << sampleModeNames_[mode_]
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("sampleRegion") << sampleRegion_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("samplePatch") << samplePatch_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("offset") << offset_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,248 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::directMappedPatchBase
|
||||
|
||||
Description
|
||||
Determines a mapping between patch face centres and mesh cell or face
|
||||
centres and processors they're on.
|
||||
|
||||
Note
|
||||
Storage is not optimal. It temporary collects all (patch)face centres
|
||||
on all processors to keep the addressing calculation simple.
|
||||
|
||||
SourceFiles
|
||||
directMappedPatchBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef directMappedPatchBase_H
|
||||
#define directMappedPatchBase_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "Tuple2.H"
|
||||
#include "pointIndexHit.H"
|
||||
#include "mapDistribute.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class polyPatch;
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class directMappedPatchBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class directMappedPatchBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Mesh items to sample
|
||||
enum sampleMode
|
||||
{
|
||||
NEARESTCELL,
|
||||
NEARESTPATCHFACE,
|
||||
NEARESTFACE
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
static const NamedEnum<sampleMode, 3> sampleModeNames_;
|
||||
|
||||
//- Patch to sample
|
||||
const polyPatch& patch_;
|
||||
|
||||
//- Region to sample
|
||||
const word sampleRegion_;
|
||||
|
||||
//- What to sample
|
||||
const sampleMode mode_;
|
||||
|
||||
//- Patch (only if NEARESTBOUNDARY)
|
||||
const word samplePatch_;
|
||||
|
||||
//- Offset vector
|
||||
const vector offset_;
|
||||
|
||||
//- Same region
|
||||
const bool sameRegion_;
|
||||
|
||||
|
||||
// Derived information
|
||||
|
||||
//- Communication schedule:
|
||||
// - Cells/faces to sample per processor
|
||||
// - Patch faces to receive per processor
|
||||
// - schedule
|
||||
mutable autoPtr<mapDistribute> mapPtr_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Collect single list of samples and originating processor+face.
|
||||
void collectSamples
|
||||
(
|
||||
pointField&,
|
||||
labelList& patchFaceProcs,
|
||||
labelList& patchFaces,
|
||||
pointField& patchFc
|
||||
) const;
|
||||
|
||||
//- Find cells/faces containing samples
|
||||
void findSamples
|
||||
(
|
||||
const pointField&,
|
||||
labelList& sampleProcs, // processor containing sample
|
||||
labelList& sampleIndices, // local index of cell/face
|
||||
pointField& sampleLocations // actual representative location
|
||||
) const;
|
||||
|
||||
//- Calculate matching
|
||||
void calcMapping() const;
|
||||
|
||||
|
||||
// Private class
|
||||
|
||||
//- Private class for finding nearest
|
||||
// - point+local index
|
||||
// - sqr(distance)
|
||||
// - processor
|
||||
typedef Tuple2<pointIndexHit, Tuple2<scalar, label> > nearInfo;
|
||||
|
||||
class nearestEqOp
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void operator()(nearInfo& x, const nearInfo& y) const
|
||||
{
|
||||
if (y.first().hit())
|
||||
{
|
||||
if (!x.first().hit())
|
||||
{
|
||||
x = y;
|
||||
}
|
||||
else if (y.second().first() < x.second().first())
|
||||
{
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("directMappedPatchBase");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
directMappedPatchBase(const polyPatch&);
|
||||
|
||||
//- Construct from dictionary
|
||||
directMappedPatchBase(const polyPatch&, const dictionary&);
|
||||
|
||||
//- Construct as copy, resetting patch
|
||||
directMappedPatchBase(const polyPatch&, const directMappedPatchBase&);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~directMappedPatchBase();
|
||||
|
||||
void clearOut();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- What to sample
|
||||
const sampleMode& mode() const
|
||||
{
|
||||
return mode_;
|
||||
}
|
||||
|
||||
//- Region to sample
|
||||
const word& sampleRegion() const
|
||||
{
|
||||
return sampleRegion_;
|
||||
}
|
||||
|
||||
//- Patch (only if NEARESTBOUNDARY)
|
||||
const word& samplePatch() const
|
||||
{
|
||||
return samplePatch_;
|
||||
}
|
||||
|
||||
//- Offset vector (from patch faces to destination mesh objects)
|
||||
const vector& offset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
//- Return reference to the parallel distribution map
|
||||
const mapDistribute& map() const
|
||||
{
|
||||
if (mapPtr_.empty())
|
||||
{
|
||||
calcMapping();
|
||||
}
|
||||
return mapPtr_();
|
||||
}
|
||||
|
||||
//- Cached sampleRegion != mesh.name()
|
||||
bool sameRegion() const
|
||||
{
|
||||
return sameRegion_;
|
||||
}
|
||||
|
||||
//- Get the region mesh
|
||||
const polyMesh& sampleMesh() const;
|
||||
|
||||
//- Get the patch on the region
|
||||
const polyPatch& samplePolyPatch() const;
|
||||
|
||||
//- Write as a dictionary
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -26,14 +26,6 @@ License
|
||||
|
||||
#include "directMappedPolyPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "ListListOps.H"
|
||||
#include "meshSearch.H"
|
||||
#include "mapDistribute.H"
|
||||
#include "meshTools.H"
|
||||
#include "OFstream.H"
|
||||
#include "Random.H"
|
||||
#include "treeDataFace.H"
|
||||
#include "indexedOctree.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,469 +35,11 @@ namespace Foam
|
||||
|
||||
addToRunTimeSelectionTable(polyPatch, directMappedPolyPatch, word);
|
||||
addToRunTimeSelectionTable(polyPatch, directMappedPolyPatch, dictionary);
|
||||
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<directMappedPolyPatch::sampleMode, 3>::names[] =
|
||||
{
|
||||
"nearestCell",
|
||||
"nearestPatchFace",
|
||||
"nearestFace"
|
||||
};
|
||||
|
||||
const NamedEnum<directMappedPolyPatch::sampleMode, 3>
|
||||
directMappedPolyPatch::sampleModeNames_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::directMappedPolyPatch::collectSamples
|
||||
(
|
||||
pointField& samples,
|
||||
labelList& patchFaceProcs,
|
||||
labelList& patchFaces,
|
||||
pointField& patchFc
|
||||
) const
|
||||
{
|
||||
|
||||
// Collect all sample points and the faces they come from.
|
||||
List<pointField> globalFc(Pstream::nProcs());
|
||||
List<pointField> globalSamples(Pstream::nProcs());
|
||||
labelListList globalFaces(Pstream::nProcs());
|
||||
|
||||
globalFc[Pstream::myProcNo()] = this->faceCentres();
|
||||
globalSamples[Pstream::myProcNo()] = globalFc[Pstream::myProcNo()]+offset_;
|
||||
globalFaces[Pstream::myProcNo()] = identity(size());
|
||||
|
||||
// Distribute to all processors
|
||||
Pstream::gatherList(globalSamples);
|
||||
Pstream::scatterList(globalSamples);
|
||||
Pstream::gatherList(globalFaces);
|
||||
Pstream::scatterList(globalFaces);
|
||||
Pstream::gatherList(globalFc);
|
||||
Pstream::scatterList(globalFc);
|
||||
|
||||
// Rework into straight list
|
||||
samples = ListListOps::combine<pointField>
|
||||
(
|
||||
globalSamples,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
patchFaces = ListListOps::combine<labelList>
|
||||
(
|
||||
globalFaces,
|
||||
accessOp<labelList>()
|
||||
);
|
||||
patchFc = ListListOps::combine<pointField>
|
||||
(
|
||||
globalFc,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
|
||||
patchFaceProcs.setSize(patchFaces.size());
|
||||
labelList nPerProc
|
||||
(
|
||||
ListListOps::subSizes
|
||||
(
|
||||
globalFaces,
|
||||
accessOp<labelList>()
|
||||
)
|
||||
);
|
||||
label sampleI = 0;
|
||||
forAll(nPerProc, procI)
|
||||
{
|
||||
for (label i = 0; i < nPerProc[procI]; i++)
|
||||
{
|
||||
patchFaceProcs[sampleI++] = procI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find the processor/cell containing the samples. Does not account
|
||||
// for samples being found in two processors.
|
||||
void Foam::directMappedPolyPatch::findSamples
|
||||
(
|
||||
const pointField& samples,
|
||||
labelList& sampleProcs,
|
||||
labelList& sampleIndices,
|
||||
pointField& sampleLocations
|
||||
) const
|
||||
{
|
||||
const polyMesh& mesh = boundaryMesh().mesh();
|
||||
|
||||
// All the info for nearest. Construct to miss
|
||||
List<nearInfo> nearest(samples.size());
|
||||
|
||||
switch (mode_)
|
||||
{
|
||||
case NEARESTCELL:
|
||||
{
|
||||
if (samplePatch_.size() && samplePatch_ != "none")
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedPolyPatch::findSamples(const pointField&,"
|
||||
" labelList&, labelList&, pointField&) const"
|
||||
) << "No need to supply a patch name when in "
|
||||
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
|
||||
}
|
||||
|
||||
// Octree based search engine
|
||||
meshSearch meshSearchEngine(mesh, false);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& sample = samples[sampleI];
|
||||
|
||||
label cellI = meshSearchEngine.findCell(sample);
|
||||
|
||||
if (cellI == -1)
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
else
|
||||
{
|
||||
const point& cc = mesh.cellCentres()[cellI];
|
||||
|
||||
nearest[sampleI].first() = pointIndexHit
|
||||
(
|
||||
true,
|
||||
cc,
|
||||
cellI
|
||||
);
|
||||
nearest[sampleI].second().first() = magSqr(cc-sample);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NEARESTPATCHFACE:
|
||||
{
|
||||
label patchI = boundaryMesh().findPatchID(samplePatch_);
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
FatalErrorIn("directMappedPolyPatch::findSamples(..)")
|
||||
<< "Cannot find patch " << samplePatch_ << endl
|
||||
<< "Valid patches are " << boundaryMesh().names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Random rndGen(123456);
|
||||
|
||||
const polyPatch& pp = boundaryMesh()[patchI];
|
||||
|
||||
if (pp.empty())
|
||||
{
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// patch faces
|
||||
const labelList patchFaces(identity(pp.size()) + pp.start());
|
||||
|
||||
treeBoundBox patchBb
|
||||
(
|
||||
treeBoundBox(pp.points(), pp.meshPoints()).extend
|
||||
(
|
||||
rndGen,
|
||||
1E-4
|
||||
)
|
||||
);
|
||||
patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
autoPtr<indexedOctree<treeDataFace> > boundaryTree
|
||||
(
|
||||
new indexedOctree<treeDataFace>
|
||||
(
|
||||
treeDataFace // all information needed to search faces
|
||||
(
|
||||
false, // do not cache bb
|
||||
mesh,
|
||||
patchFaces // boundary faces only
|
||||
),
|
||||
patchBb, // overall search domain
|
||||
8, // maxLevel
|
||||
10, // leafsize
|
||||
3.0 // duplicity
|
||||
)
|
||||
);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& sample = samples[sampleI];
|
||||
|
||||
pointIndexHit& nearInfo = nearest[sampleI].first();
|
||||
nearInfo = boundaryTree().findNearest
|
||||
(
|
||||
sample,
|
||||
magSqr(patchBb.span())
|
||||
);
|
||||
|
||||
if (!nearInfo.hit())
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() =
|
||||
Pstream::myProcNo();
|
||||
}
|
||||
else
|
||||
{
|
||||
point fc(pp[nearInfo.index()].centre(pp.points()));
|
||||
nearInfo.setPoint(fc);
|
||||
nearest[sampleI].second().first() = magSqr(fc-sample);
|
||||
nearest[sampleI].second().second() =
|
||||
Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NEARESTFACE:
|
||||
{
|
||||
if (samplePatch_.size() && samplePatch_ != "none")
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedPolyPatch::findSamples(const pointField&,"
|
||||
" labelList&, labelList&, pointField&) const"
|
||||
) << "No need to supply a patch name when in "
|
||||
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
|
||||
}
|
||||
|
||||
// Octree based search engine
|
||||
meshSearch meshSearchEngine(mesh, false);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& sample = samples[sampleI];
|
||||
|
||||
label faceI = meshSearchEngine.findNearestFace(sample);
|
||||
|
||||
if (faceI == -1)
|
||||
{
|
||||
nearest[sampleI].second().first() = Foam::sqr(GREAT);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
else
|
||||
{
|
||||
const point& fc = mesh.faceCentres()[faceI];
|
||||
|
||||
nearest[sampleI].first() = pointIndexHit
|
||||
(
|
||||
true,
|
||||
fc,
|
||||
faceI
|
||||
);
|
||||
nearest[sampleI].second().first() = magSqr(fc-sample);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("directMappedPolyPatch::findSamples(..)")
|
||||
<< "problem." << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find nearest.
|
||||
Pstream::listCombineGather(nearest, nearestEqOp());
|
||||
Pstream::listCombineScatter(nearest);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "directMappedPolyPatch::findSamples : " << endl;
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
label procI = nearest[sampleI].second().second();
|
||||
label localI = nearest[sampleI].first().index();
|
||||
|
||||
Info<< " " << sampleI << " coord:"<< samples[sampleI]
|
||||
<< " found on processor:" << procI
|
||||
<< " in local cell/face:" << localI
|
||||
<< " with cc:" << nearest[sampleI].first().rawPoint() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for samples not being found
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
if (!nearest[sampleI].first().hit())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedPolyPatch::findSamples"
|
||||
"(const pointField&, labelList&"
|
||||
", labelList&, pointField&)"
|
||||
) << "Did not find sample " << samples[sampleI]
|
||||
<< " on any processor." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert back into proc+local index
|
||||
sampleProcs.setSize(samples.size());
|
||||
sampleIndices.setSize(samples.size());
|
||||
sampleLocations.setSize(samples.size());
|
||||
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
sampleProcs[sampleI] = nearest[sampleI].second().second();
|
||||
sampleIndices[sampleI] = nearest[sampleI].first().index();
|
||||
sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::directMappedPolyPatch::calcMapping() const
|
||||
{
|
||||
if (sendLabelsPtr_.valid())
|
||||
{
|
||||
FatalErrorIn("directMappedPolyPatch::calcMapping() const")
|
||||
<< "Mapping already calculated" << exit(FatalError);
|
||||
}
|
||||
|
||||
if (offset_ == vector::zero)
|
||||
{
|
||||
FatalErrorIn("directMappedPolyPatch::calcMapping() const")
|
||||
<< "Invalid offset " << offset_ << endl
|
||||
<< "Offset is the vector added to the patch face centres to"
|
||||
<< " find the cell supplying the data."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Get global list of all samples and the processor and face they come from.
|
||||
pointField samples;
|
||||
labelList patchFaceProcs;
|
||||
labelList patchFaces;
|
||||
pointField patchFc;
|
||||
collectSamples(samples, patchFaceProcs, patchFaces, patchFc);
|
||||
|
||||
// Find processor and cell/face samples are in and actual location.
|
||||
labelList sampleProcs;
|
||||
labelList sampleIndices;
|
||||
pointField sampleLocations;
|
||||
findSamples(samples, sampleProcs, sampleIndices, sampleLocations);
|
||||
|
||||
|
||||
// Now we have all the data we need:
|
||||
// - where sample originates from (so destination when mapping):
|
||||
// patchFaces, patchFaceProcs.
|
||||
// - cell/face sample is in (so source when mapping)
|
||||
// sampleIndices, sampleProcs.
|
||||
|
||||
|
||||
if (debug && Pstream::master())
|
||||
{
|
||||
OFstream str
|
||||
(
|
||||
boundaryMesh().mesh().time().path()
|
||||
/ name()
|
||||
+ "_directMapped.obj"
|
||||
);
|
||||
Pout<< "Dumping mapping as lines from patch faceCentres to"
|
||||
<< " sampled cellCentres to file " << str.name() << endl;
|
||||
|
||||
label vertI = 0;
|
||||
|
||||
forAll(patchFc, i)
|
||||
{
|
||||
meshTools::writeOBJ(str, patchFc[i]);
|
||||
vertI++;
|
||||
meshTools::writeOBJ(str, sampleLocations[i]);
|
||||
vertI++;
|
||||
str << "l " << vertI-1 << ' ' << vertI << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check that actual offset vector (sampleLocations - patchFc) is more or
|
||||
// less constant.
|
||||
if (Pstream::master())
|
||||
{
|
||||
const scalarField magOffset(mag(sampleLocations - patchFc));
|
||||
const scalar avgOffset(average(magOffset));
|
||||
|
||||
forAll(magOffset, sampleI)
|
||||
{
|
||||
if (mag(magOffset[sampleI]-avgOffset) > 0.001*avgOffset)
|
||||
{
|
||||
WarningIn("directMappedPolyPatch::calcMapping() const")
|
||||
<< "The actual cell centres picked up using offset "
|
||||
<< offset_ << " are not" << endl
|
||||
<< " on a single plane."
|
||||
<< " This might give numerical problems." << endl
|
||||
<< " At patchface " << patchFc[sampleI]
|
||||
<< " the sampled cell " << sampleLocations[sampleI] << endl
|
||||
<< " is not on a plane " << avgOffset
|
||||
<< " offset from the patch." << endl
|
||||
<< " You might want to shift your plane offset."
|
||||
<< " Set the debug flag to get a dump of sampled cells."
|
||||
<< endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Determine schedule.
|
||||
mapDistribute distMap(sampleProcs, patchFaceProcs);
|
||||
|
||||
// Rework the schedule to cell data to send, face data to receive.
|
||||
schedulePtr_.reset(new List<labelPair>(distMap.schedule()));
|
||||
|
||||
const labelListList& subMap = distMap.subMap();
|
||||
const labelListList& constructMap = distMap.constructMap();
|
||||
|
||||
// Extract the particular data I need to send and receive.
|
||||
sendLabelsPtr_.reset(new labelListList(subMap.size()));
|
||||
labelListList& sendLabels = sendLabelsPtr_();
|
||||
|
||||
forAll(subMap, procI)
|
||||
{
|
||||
sendLabels[procI] = UIndirectList<label>
|
||||
(
|
||||
sampleIndices,
|
||||
subMap[procI]
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "To proc:" << procI << " sending values of cells/faces:"
|
||||
<< sendLabels[procI] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
receiveFaceLabelsPtr_.reset(new labelListList(constructMap.size()));
|
||||
labelListList& receiveFaceLabels = receiveFaceLabelsPtr_();
|
||||
|
||||
forAll(constructMap, procI)
|
||||
{
|
||||
receiveFaceLabels[procI] =
|
||||
UIndirectList<label>(patchFaces, constructMap[procI]);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "From proc:" << procI << " receiving values of patch faces:"
|
||||
<< receiveFaceLabels[procI] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -519,12 +53,7 @@ Foam::directMappedPolyPatch::directMappedPolyPatch
|
||||
)
|
||||
:
|
||||
polyPatch(name, size, start, index, bm),
|
||||
mode_(NEARESTPATCHFACE),
|
||||
samplePatch_("none"),
|
||||
offset_(vector::zero),
|
||||
schedulePtr_(NULL),
|
||||
sendLabelsPtr_(NULL),
|
||||
receiveFaceLabelsPtr_(NULL)
|
||||
directMappedPatchBase(static_cast<const polyPatch&>(*this))
|
||||
{}
|
||||
|
||||
|
||||
@ -537,12 +66,7 @@ Foam::directMappedPolyPatch::directMappedPolyPatch
|
||||
)
|
||||
:
|
||||
polyPatch(name, dict, index, bm),
|
||||
mode_(sampleModeNames_.read(dict.lookup("sampleMode"))),
|
||||
samplePatch_(dict.lookup("samplePatch")),
|
||||
offset_(dict.lookup("offset")),
|
||||
schedulePtr_(NULL),
|
||||
sendLabelsPtr_(NULL),
|
||||
receiveFaceLabelsPtr_(NULL)
|
||||
directMappedPatchBase(*this, dict)
|
||||
{}
|
||||
|
||||
|
||||
@ -553,12 +77,7 @@ Foam::directMappedPolyPatch::directMappedPolyPatch
|
||||
)
|
||||
:
|
||||
polyPatch(pp, bm),
|
||||
mode_(pp.mode_),
|
||||
samplePatch_(pp.samplePatch_),
|
||||
offset_(pp.offset_),
|
||||
schedulePtr_(NULL),
|
||||
sendLabelsPtr_(NULL),
|
||||
receiveFaceLabelsPtr_(NULL)
|
||||
directMappedPatchBase(*this, pp)
|
||||
{}
|
||||
|
||||
|
||||
@ -572,12 +91,7 @@ Foam::directMappedPolyPatch::directMappedPolyPatch
|
||||
)
|
||||
:
|
||||
polyPatch(pp, bm, index, newSize, newStart),
|
||||
mode_(pp.mode_),
|
||||
samplePatch_(pp.samplePatch_),
|
||||
offset_(pp.offset_),
|
||||
schedulePtr_(NULL),
|
||||
sendLabelsPtr_(NULL),
|
||||
receiveFaceLabelsPtr_(NULL)
|
||||
directMappedPatchBase(*this, pp)
|
||||
{}
|
||||
|
||||
|
||||
@ -585,28 +99,59 @@ Foam::directMappedPolyPatch::directMappedPolyPatch
|
||||
|
||||
Foam::directMappedPolyPatch::~directMappedPolyPatch()
|
||||
{
|
||||
clearOut();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::directMappedPolyPatch::clearOut()
|
||||
//- Initialise the calculation of the patch geometry
|
||||
void Foam::directMappedPolyPatch::initGeometry()
|
||||
{
|
||||
schedulePtr_.clear();
|
||||
sendLabelsPtr_.clear();
|
||||
receiveFaceLabelsPtr_.clear();
|
||||
polyPatch::initGeometry();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Calculate the patch geometry
|
||||
void Foam::directMappedPolyPatch::calcGeometry()
|
||||
{
|
||||
polyPatch::calcGeometry();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Initialise the patches for moving points
|
||||
void Foam::directMappedPolyPatch::initMovePoints(const pointField& p)
|
||||
{
|
||||
polyPatch::initMovePoints(p);
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Correct patches after moving points
|
||||
void Foam::directMappedPolyPatch::movePoints(const pointField& p)
|
||||
{
|
||||
polyPatch::movePoints(p);
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Initialise the update of the patch topology
|
||||
void Foam::directMappedPolyPatch::initUpdateMesh()
|
||||
{
|
||||
polyPatch::initUpdateMesh();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Update of the patch topology
|
||||
void Foam::directMappedPolyPatch::updateMesh()
|
||||
{
|
||||
polyPatch::updateMesh();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
|
||||
void Foam::directMappedPolyPatch::write(Ostream& os) const
|
||||
{
|
||||
polyPatch::write(os);
|
||||
os.writeKeyword("sampleMode") << sampleModeNames_[mode_]
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("samplePatch") << samplePatch_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("offset") << offset_ << token::END_STATEMENT << nl;
|
||||
directMappedPatchBase::write(os);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,9 +42,7 @@ SourceFiles
|
||||
#define directMappedPolyPatch_H
|
||||
|
||||
#include "polyPatch.H"
|
||||
#include "labelPair.H"
|
||||
#include "Tuple2.H"
|
||||
#include "pointIndexHit.H"
|
||||
#include "directMappedPatchBase.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -52,148 +50,37 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class directMappedPolyPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class directMappedPolyPatch
|
||||
:
|
||||
public polyPatch
|
||||
public polyPatch,
|
||||
public directMappedPatchBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Mesh items to sample
|
||||
enum sampleMode
|
||||
{
|
||||
NEARESTCELL,
|
||||
NEARESTPATCHFACE,
|
||||
NEARESTFACE
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
static const NamedEnum<sampleMode, 3> sampleModeNames_;
|
||||
|
||||
//- What to sample
|
||||
sampleMode mode_;
|
||||
|
||||
//- Patch (only if NEARESTBOUNDARY)
|
||||
const word samplePatch_;
|
||||
|
||||
//- Offset vector
|
||||
const vector offset_;
|
||||
|
||||
|
||||
|
||||
// Derived information
|
||||
|
||||
//- Communication schedule.
|
||||
mutable autoPtr<List<labelPair> > schedulePtr_;
|
||||
|
||||
//- Cells/faces to sample per processor
|
||||
mutable autoPtr<labelListList> sendLabelsPtr_;
|
||||
|
||||
//- Patch faces to receive per processor
|
||||
mutable autoPtr<labelListList> receiveFaceLabelsPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Collect single list of samples and originating processor+face.
|
||||
void collectSamples
|
||||
(
|
||||
pointField&,
|
||||
labelList& patchFaceProcs,
|
||||
labelList& patchFaces,
|
||||
pointField& patchFc
|
||||
) const;
|
||||
|
||||
//- Find cells/faces containing samples
|
||||
void findSamples
|
||||
(
|
||||
const pointField&,
|
||||
labelList& sampleProcs, // processor containing sample
|
||||
labelList& sampleIndices, // local index of cell/face
|
||||
pointField& sampleLocations // actual representative location
|
||||
) const;
|
||||
|
||||
//- Calculate matching
|
||||
void calcMapping() const;
|
||||
|
||||
|
||||
// Private class
|
||||
|
||||
//- Private class for finding nearest
|
||||
// - point+local index
|
||||
// - sqr(distance)
|
||||
// - processor
|
||||
typedef Tuple2<pointIndexHit, Tuple2<scalar, label> > nearInfo;
|
||||
|
||||
class nearestEqOp
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void operator()(nearInfo& x, const nearInfo& y) const
|
||||
{
|
||||
if (y.first().hit())
|
||||
{
|
||||
if (!x.first().hit())
|
||||
{
|
||||
x = y;
|
||||
}
|
||||
else if (y.second().first() < x.second().first())
|
||||
{
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void clearOut();
|
||||
|
||||
//- Initialise the calculation of the patch geometry
|
||||
virtual void initGeometry()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
virtual void initGeometry();
|
||||
|
||||
//- Calculate the patch geometry
|
||||
virtual void calcGeometry()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
virtual void calcGeometry();
|
||||
|
||||
//- Initialise the patches for moving points
|
||||
virtual void initMovePoints(const pointField&)
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
virtual void initMovePoints(const pointField&);
|
||||
|
||||
//- Correct patches after moving points
|
||||
virtual void movePoints(const pointField& p)
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
virtual void movePoints(const pointField&);
|
||||
|
||||
//- Initialise the update of the patch topology
|
||||
virtual void initUpdateMesh()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
virtual void initUpdateMesh();
|
||||
|
||||
//- Update of the patch topology
|
||||
virtual void updateMesh()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
virtual void updateMesh();
|
||||
|
||||
|
||||
public:
|
||||
@ -271,72 +158,6 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- What to sample
|
||||
const sampleMode& mode() const
|
||||
{
|
||||
return mode_;
|
||||
}
|
||||
|
||||
//- Patch (only if NEARESTBOUNDARY)
|
||||
const word& samplePatch() const
|
||||
{
|
||||
return samplePatch_;
|
||||
}
|
||||
|
||||
//- Offset vector (from patch faces to destination mesh objects)
|
||||
const vector& offset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
//- Access to communication.
|
||||
const List<labelPair>& schedule() const
|
||||
{
|
||||
if (schedulePtr_.empty())
|
||||
{
|
||||
calcMapping();
|
||||
}
|
||||
return schedulePtr_();
|
||||
}
|
||||
|
||||
//- Cells/faces to sample per processor
|
||||
const labelListList& sendLabels() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Asking for sendLabels." << endl;
|
||||
}
|
||||
|
||||
if (sendLabelsPtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Calculating mapping." << endl;
|
||||
calcMapping();
|
||||
}
|
||||
}
|
||||
return sendLabelsPtr_();
|
||||
}
|
||||
|
||||
//- Patch faces to receive per processor
|
||||
const labelListList& receiveFaceLabels() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Asking for receiveFaceLabels." << endl;
|
||||
}
|
||||
|
||||
if (receiveFaceLabelsPtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Calculating mapping." << endl;
|
||||
calcMapping();
|
||||
}
|
||||
}
|
||||
return receiveFaceLabelsPtr_();
|
||||
}
|
||||
|
||||
//- Write the polyPatch data as a dictionary
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "directMappedWallPolyPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(directMappedWallPolyPatch, 0);
|
||||
|
||||
addToRunTimeSelectionTable(polyPatch, directMappedWallPolyPatch, word);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
polyPatch,
|
||||
directMappedWallPolyPatch,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
|
||||
(
|
||||
const word& name,
|
||||
const label size,
|
||||
const label start,
|
||||
const label index,
|
||||
const polyBoundaryMesh& bm
|
||||
)
|
||||
:
|
||||
wallPolyPatch(name, size, start, index, bm),
|
||||
directMappedPatchBase(static_cast<const polyPatch&>(*this))
|
||||
{}
|
||||
|
||||
|
||||
Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const label index,
|
||||
const polyBoundaryMesh& bm
|
||||
)
|
||||
:
|
||||
wallPolyPatch(name, dict, index, bm),
|
||||
directMappedPatchBase(*this, dict)
|
||||
{}
|
||||
|
||||
|
||||
Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
|
||||
(
|
||||
const directMappedWallPolyPatch& pp,
|
||||
const polyBoundaryMesh& bm
|
||||
)
|
||||
:
|
||||
wallPolyPatch(pp, bm),
|
||||
directMappedPatchBase(*this, pp)
|
||||
{}
|
||||
|
||||
|
||||
Foam::directMappedWallPolyPatch::directMappedWallPolyPatch
|
||||
(
|
||||
const directMappedWallPolyPatch& pp,
|
||||
const polyBoundaryMesh& bm,
|
||||
const label index,
|
||||
const label newSize,
|
||||
const label newStart
|
||||
)
|
||||
:
|
||||
wallPolyPatch(pp, bm, index, newSize, newStart),
|
||||
directMappedPatchBase(*this, pp)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::directMappedWallPolyPatch::~directMappedWallPolyPatch()
|
||||
{
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Initialise the calculation of the patch geometry
|
||||
void Foam::directMappedWallPolyPatch::initGeometry()
|
||||
{
|
||||
wallPolyPatch::initGeometry();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Calculate the patch geometry
|
||||
void Foam::directMappedWallPolyPatch::calcGeometry()
|
||||
{
|
||||
wallPolyPatch::calcGeometry();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Initialise the patches for moving points
|
||||
void Foam::directMappedWallPolyPatch::initMovePoints(const pointField& p)
|
||||
{
|
||||
wallPolyPatch::initMovePoints(p);
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Correct patches after moving points
|
||||
void Foam::directMappedWallPolyPatch::movePoints(const pointField& p)
|
||||
{
|
||||
wallPolyPatch::movePoints(p);
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Initialise the update of the patch topology
|
||||
void Foam::directMappedWallPolyPatch::initUpdateMesh()
|
||||
{
|
||||
wallPolyPatch::initUpdateMesh();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
//- Update of the patch topology
|
||||
void Foam::directMappedWallPolyPatch::updateMesh()
|
||||
{
|
||||
wallPolyPatch::updateMesh();
|
||||
directMappedPatchBase::clearOut();
|
||||
}
|
||||
|
||||
|
||||
void Foam::directMappedWallPolyPatch::write(Ostream& os) const
|
||||
{
|
||||
wallPolyPatch::write(os);
|
||||
directMappedPatchBase::write(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,181 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::directMappedWallPolyPatch
|
||||
|
||||
Description
|
||||
Determines a mapping between patch face centres and mesh cell or face
|
||||
centres and processors they're on.
|
||||
|
||||
Note
|
||||
Storage is not optimal. It stores all face centres and cells on all
|
||||
processors to keep the addressing calculation simple.
|
||||
|
||||
SourceFiles
|
||||
directMappedWallPolyPatch.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef directMappedWallPolyPatch_H
|
||||
#define directMappedWallPolyPatch_H
|
||||
|
||||
#include "wallPolyPatch.H"
|
||||
#include "directMappedPatchBase.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class directMappedWallPolyPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class directMappedWallPolyPatch
|
||||
:
|
||||
public wallPolyPatch,
|
||||
public directMappedPatchBase
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
//- Initialise the calculation of the patch geometry
|
||||
virtual void initGeometry();
|
||||
|
||||
//- Calculate the patch geometry
|
||||
virtual void calcGeometry();
|
||||
|
||||
//- Initialise the patches for moving points
|
||||
virtual void initMovePoints(const pointField&);
|
||||
|
||||
//- Correct patches after moving points
|
||||
virtual void movePoints(const pointField&);
|
||||
|
||||
//- Initialise the update of the patch topology
|
||||
virtual void initUpdateMesh();
|
||||
|
||||
//- Update of the patch topology
|
||||
virtual void updateMesh();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("directMappedWall");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
directMappedWallPolyPatch
|
||||
(
|
||||
const word& name,
|
||||
const label size,
|
||||
const label start,
|
||||
const label index,
|
||||
const polyBoundaryMesh& bm
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
directMappedWallPolyPatch
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const label index,
|
||||
const polyBoundaryMesh& bm
|
||||
);
|
||||
|
||||
//- Construct as copy, resetting the boundary mesh
|
||||
directMappedWallPolyPatch
|
||||
(
|
||||
const directMappedWallPolyPatch&,
|
||||
const polyBoundaryMesh&
|
||||
);
|
||||
|
||||
//- Construct given the original patch and resetting the
|
||||
// face list and boundary mesh information
|
||||
directMappedWallPolyPatch
|
||||
(
|
||||
const directMappedWallPolyPatch& pp,
|
||||
const polyBoundaryMesh& bm,
|
||||
const label index,
|
||||
const label newSize,
|
||||
const label newStart
|
||||
);
|
||||
|
||||
//- Construct and return a clone, resetting the boundary mesh
|
||||
virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
|
||||
{
|
||||
return autoPtr<polyPatch>(new directMappedWallPolyPatch(*this, bm));
|
||||
}
|
||||
|
||||
//- Construct and return a clone, resetting the face list
|
||||
// and boundary mesh
|
||||
virtual autoPtr<polyPatch> clone
|
||||
(
|
||||
const polyBoundaryMesh& bm,
|
||||
const label index,
|
||||
const label newSize,
|
||||
const label newStart
|
||||
) const
|
||||
{
|
||||
return autoPtr<polyPatch>
|
||||
(
|
||||
new directMappedWallPolyPatch
|
||||
(
|
||||
*this,
|
||||
bm,
|
||||
index,
|
||||
newSize,
|
||||
newStart
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~directMappedWallPolyPatch();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Write the polyPatch data as a dictionary
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -121,8 +121,8 @@ Foam::labelList Foam::orientedSurface::edgeToFace
|
||||
label face0 = eFaces[0];
|
||||
label face1 = eFaces[1];
|
||||
|
||||
const labelledTri& f0 = s[face0];
|
||||
const labelledTri& f1 = s[face1];
|
||||
const labelledTri& f0 = s.localFaces()[face0];
|
||||
const labelledTri& f1 = s.localFaces()[face1];
|
||||
|
||||
if (flip[face0] == UNVISITED)
|
||||
{
|
||||
@ -349,7 +349,10 @@ Foam::orientedSurface::orientedSurface
|
||||
:
|
||||
triSurface(surf)
|
||||
{
|
||||
point outsidePoint = 2 * treeBoundBox(localPoints()).span();
|
||||
// BoundBox calculation without localPoints
|
||||
treeBoundBox bb(surf.points(), surf.meshPoints());
|
||||
|
||||
point outsidePoint = bb.max() + bb.span();
|
||||
|
||||
orient(*this, outsidePoint, orientOutside);
|
||||
}
|
||||
|
||||
@ -347,127 +347,6 @@ void Foam::triSurface::checkEdges(const bool verbose)
|
||||
}
|
||||
|
||||
|
||||
// Check normals and orientation
|
||||
Foam::boolList Foam::triSurface::checkOrientation(const bool verbose)
|
||||
{
|
||||
const edgeList& es = edges();
|
||||
const labelListList& faceEs = faceEdges();
|
||||
|
||||
// Check edge normals, face normals, point normals.
|
||||
forAll(faceEs, facei)
|
||||
{
|
||||
const labelList& edgeLabels = faceEs[facei];
|
||||
|
||||
if (edgeLabels.size() != 3)
|
||||
{
|
||||
FatalErrorIn("triSurface::checkOrientation(bool)")
|
||||
<< "triangle " << (*this)[facei]
|
||||
<< " does not have 3 edges. Edges:" << edgeLabels
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
bool valid = true;
|
||||
forAll(edgeLabels, i)
|
||||
{
|
||||
if (edgeLabels[i] < 0 || edgeLabels[i] >= nEdges())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"triSurface::checkOrientation(bool)"
|
||||
) << "edge number " << edgeLabels[i] << " on face " << facei
|
||||
<< " out-of-range\n"
|
||||
<< "This usually means that the input surface has "
|
||||
<< "edges with more than 2 triangles connected.\n"
|
||||
<< endl;
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (! valid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//- Compute normal from triangle points.
|
||||
//
|
||||
|
||||
const labelledTri& tri = (*this)[facei];
|
||||
const point pa(points()[tri[0]]);
|
||||
const point pb(points()[tri[1]]);
|
||||
const point pc(points()[tri[2]]);
|
||||
|
||||
const vector pointNormal((pc - pb) ^ (pa - pb));
|
||||
if ((pointNormal & faceNormals()[facei]) < 0)
|
||||
{
|
||||
FatalErrorIn("triSurface::checkOrientation(bool)")
|
||||
<< "Normal calculated from points not consistent with"
|
||||
" faceNormal" << endl
|
||||
<< "triangle:" << tri << endl
|
||||
<< "points:" << pa << ' ' << pb << ' ' << pc << endl
|
||||
<< "pointNormal:" << pointNormal << endl
|
||||
<< "faceNormal:" << faceNormals()[facei]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const labelListList& eFaces = edgeFaces();
|
||||
|
||||
// Storage for holding status of edge. True if normal flips across this
|
||||
// edge
|
||||
boolList borderEdge(nEdges(), false);
|
||||
|
||||
forAll(es, edgeI)
|
||||
{
|
||||
const edge& e = es[edgeI];
|
||||
const labelList& neighbours = eFaces[edgeI];
|
||||
|
||||
if (neighbours.size() == 2)
|
||||
{
|
||||
const labelledTri& faceA = (*this)[neighbours[0]];
|
||||
const labelledTri& faceB = (*this)[neighbours[1]];
|
||||
|
||||
// The edge cannot be going in the same direction if both faces
|
||||
// are oriented counterclockwise.
|
||||
// Thus the next face point *must* different between the faces.
|
||||
if
|
||||
(
|
||||
faceA[faceA.fcIndex(findIndex(faceA, e.start()))]
|
||||
== faceB[faceB.fcIndex(findIndex(faceB, e.start()))]
|
||||
)
|
||||
{
|
||||
borderEdge[edgeI] = true;
|
||||
if (verbose)
|
||||
{
|
||||
WarningIn("PrimitivePatchExtra::checkOrientation(bool)")
|
||||
<< "face orientation incorrect." << nl
|
||||
<< "edge[" << edgeI << "] " << e
|
||||
<< " between faces " << neighbours << ":" << nl
|
||||
<< "face[" << neighbours[0] << "] " << faceA << nl
|
||||
<< "face[" << neighbours[1] << "] " << faceB << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (neighbours.size() != 1)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
WarningIn("triSurface::checkOrientation(bool)")
|
||||
<< "Wrong number of edge neighbours." << endl
|
||||
<< "edge[" << edgeI << "] " << e
|
||||
<< "with points:" << localPoints()[e.start()]
|
||||
<< ' ' << localPoints()[e.end()]
|
||||
<< " has neighbours:" << neighbours << endl;
|
||||
}
|
||||
borderEdge[edgeI] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return borderEdge;
|
||||
}
|
||||
|
||||
|
||||
// Read triangles, points from Istream
|
||||
bool Foam::triSurface::read(Istream& is)
|
||||
{
|
||||
|
||||
@ -326,17 +326,12 @@ public:
|
||||
//- Scale points. A non-positive factor is ignored
|
||||
virtual void scalePoints(const scalar&);
|
||||
|
||||
//- Check/fix duplicate/degenerate triangles
|
||||
//- Check/remove duplicate/degenerate triangles
|
||||
void checkTriangles(const bool verbose);
|
||||
|
||||
//- Check triply (or more) connected edges. Return list of faces
|
||||
// sharing these edges.
|
||||
//- Check triply (or more) connected edges.
|
||||
void checkEdges(const bool verbose);
|
||||
|
||||
//- Check orientation (normals) and normals of neighbouring
|
||||
// triangles
|
||||
boolList checkOrientation(const bool verbose);
|
||||
|
||||
//- Remove non-valid triangles
|
||||
void cleanup(const bool verbose);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user