Commit 5051b1b6 authored by Andrew Heather's avatar Andrew Heather
Browse files

Merge branch 'master' of /home/noisy2/OpenFOAM/OpenFOAM-dev/

parents 383ae13a 0ad4f7be
......@@ -71,8 +71,8 @@ frictionalPressure
const dimensionedScalar& eta,
const dimensionedScalar& p
) const
{
return
{
return
dimensionedScalar("1e24", dimensionSet(1, -1, -2, 0, 0), 1e24)
*pow(Foam::max(alpha - alphaMinFriction, scalar(0)), 10.0);
}
......@@ -89,7 +89,7 @@ frictionalPressurePrime
const dimensionedScalar& p
) const
{
return
return
dimensionedScalar("1e25", dimensionSet(1, -1, -2, 0, 0), 1e25)
*pow(Foam::max(alpha - alphaMinFriction, scalar(0)), 9.0);
}
......@@ -129,8 +129,8 @@ Foam::tmp<Foam::volScalarField> Foam::SchaefferFrictionalStress::muf
{
if (alpha[celli] > alphaMax.value()-5e-2)
{
muf_[celli] =
0.5*alpha[celli]*pf[celli]*sin(phi.value())
muf_[celli] =
0.5*pf[celli]*sin(phi.value())
/(
sqrt(1.0/6.0*(sqr(D[celli].xx() - D[celli].yy())
+ sqr(D[celli].yy() - D[celli].zz())
......
......@@ -105,16 +105,39 @@ int main(int argc, char *argv[])
if (writeTopo)
{
word objMeshFile(runTime.path()/"blockTopology.obj");
// Write mesh as edges.
{
fileName objMeshFile("blockTopology.obj");
Info<< nl << "Dumping block structure as Lightwave obj format"
<< " to " << objMeshFile << endl;
OFstream str(runTime.path()/objMeshFile);
// Write mesh as edges.
Info<< nl << "Dumping block structure as Lightwave obj format"
<< " to " << objMeshFile << endl;
blocks.writeTopology(str);
}
// Write centres of blocks
{
fileName objCcFile("blockCentres.obj");
OFstream objStream(objMeshFile);
OFstream str(runTime.path()/objCcFile);
blocks.writeTopology(objStream);
Info<< nl << "Dumping block centres as Lightwave obj format"
<< " to " << objCcFile << endl;
const polyMesh& topo = blocks.topology();
const pointField& cellCentres = topo.cellCentres();
forAll(cellCentres, cellI)
{
//point cc = b.blockShape().centre(b.points());
const point& cc = cellCentres[cellI];
str << "v " << cc.x() << ' ' << cc.y() << ' ' << cc.z() << nl;
}
}
Info<< nl << "end" << endl;
......
snappyHexMesh.C
EXE = $(FOAM_APPBIN)/snappyHexMesh
......@@ -23,10 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
autoHexMesh
snappyHexMesh
Description
Automatic split hex mesher.
Automatic split hex mesher. Refines and snaps to surface.
\*---------------------------------------------------------------------------*/
......@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
(
IOobject
(
"autoHexMeshDict",
"snappyHexMeshDict",
runTime.system(),
mesh,
IOobject::MUST_READ,
......
......@@ -327,7 +327,6 @@ $(polyBoundaryMesh)/polyBoundaryMesh.C
$(polyBoundaryMesh)/polyBoundaryMeshEntries.C
meshes/ProcessorTopology/commSchedule.C
meshes/ProcessorTopology/dataSchedule.C
globalMeshData = $(polyMesh)/globalMeshData
$(globalMeshData)/globalMeshData.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 "dataSchedule.H"
#include "SortableList.H"
#include "commSchedule.H"
#include "Pstream.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(dataSchedule, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from separate addressing
Foam::dataSchedule::dataSchedule
(
const labelList& sendProcs,
const labelList& receiveProcs
)
:
sendOrder_(Pstream::nProcs()),
receiveOrder_(Pstream::nProcs())
{
// Determine the schedule
// ~~~~~~~~~~~~~~~~~~~~~~
// Get all pairs of processors. Leave out local comms.
List<labelPair> allComms;
{
HashSet<labelPair, labelPair::Hash<> > commsSet(Pstream::nProcs());
forAll(receiveProcs, i)
{
if (sendProcs[i] != receiveProcs[i])
{
commsSet.insert(labelPair(sendProcs[i], receiveProcs[i]));
}
}
allComms = commsSet.toc();
}
// Determine my schedule.
labelList mySchedule
(
commSchedule
(
Pstream::nProcs(),
allComms
).procSchedule()[Pstream::myProcNo()]
);
// Processors involved in my schedule
List<labelPair>::operator=
(
IndirectList<labelPair>(allComms, mySchedule)
);
if (debug)
{
Pout<< "I need to:" << endl;
forAll(*this, i)
{
const labelPair& twoProcs = operator[](i);
label sendProc = twoProcs[0];
label recvProc = twoProcs[1];
if (recvProc == Pstream::myProcNo())
{
Pout<< " receive from " << sendProc << endl;
}
else
{
Pout<< " send to " << recvProc << endl;
}
}
}
// Determine the addressing
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Per processor the indices we have to send/receive.
List<DynamicList<label> > dynSendOrder(Pstream::nProcs());
List<DynamicList<label> > dynReceiveOrder(Pstream::nProcs());
// Estimate size
forAll(dynSendOrder, procI)
{
dynSendOrder[procI].setSize(sendProcs.size()/Pstream::nProcs());
dynReceiveOrder[procI].setSize(sendProcs.size()/Pstream::nProcs());
}
forAll(sendProcs, sampleI)
{
// Note that also need to include local communication (both receiveProc
// and sendProc on local processor)
if (Pstream::myProcNo() == sendProcs[sampleI])
{
// I am the sender
dynSendOrder[receiveProcs[sampleI]].append(sampleI);
}
if (Pstream::myProcNo() == receiveProcs[sampleI])
{
// I am the receiver
dynReceiveOrder[sendProcs[sampleI]].append(sampleI);
}
}
forAll(dynSendOrder, procI)
{
sendOrder_[procI].transfer(dynSendOrder[procI].shrink());
receiveOrder_[procI].transfer(dynReceiveOrder[procI].shrink());
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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::dataSchedule
Description
Gets for every data item the source processor and the send processor.
Determines:
- which processor do I need to send to / receive from
- what are the indices into the data I need to send / I am receiving.
Example:
- we have global sampling points
- for every sampling point we have the cell/processor containing the point
(sampleCells, sampleCellProcs)
- for every sampling point we also have the destination cell/processor
(receiveCells, receiveCellProcs)
- sampleCellProcs, receiveCellProcs have to be the same on all processors!
then we construct dataSchedule:
@code
dataSchedule mySchedule(sampleCellProcs, receiveCellProcs);
const labelListList& sendOrder = mySchedule.sendOrder();
const labelListList& receiveOrder = mySchedule.receiveOrder();
// Do all remote data
// ~~~~~~~~~~~~~~~~~~
forAll(mySchedule, commI)
{
const labelPair& twoProcs = mySchedule[i];
label sendProc = twoProcs[0];
label recvProc = twoProcs[1];
if (Pstream::myProcNo() == sendProc)
{
// I am sender. Send to recvProc.
// Labels of my cells to sample
labelList cellLabels
(
IndirectList<label>(sampleCells, sendOrder[recvProc])
);
OPstream toProc(recvProc);
toProc<< IndirectList<vector>(fld, cellLabels)();
}
else
{
// I am receiver. Receive from sendProc.
IPstream fromProc(sendProc);
vectorField fromFld(fromProc);
// Destination cells
labelList cellLabels
(
IndirectList<label>(receiveCells, receiveOrder[sendProc])
);
forAll(fromFld, i)
{
fld[cellLabels[i]] = fromFld[i];
}
}
}
// Do local data
// ~~~~~~~~~~~~~
labelList sendCells
(
IndirectList<label>(sampleCells, sendOrder[Pstream::myProcNo()])
);
vectorField toMyself(IndirectList<vector>(fld, sendCells)());
// Destination cells
labelList recvCells
(
IndirectList<label>
(
patchFaces,
receiveOrder[Pstream::myProcNo()]
)
);
forAll(toMyself, i)
{
recvCells[i] = toMySelf[i];
}
@endcode
SourceFiles
dataSchedule.C
\*---------------------------------------------------------------------------*/
#ifndef dataSchedule_H
#define dataSchedule_H
#include "commSchedule.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class dataSchedule Declaration
\*---------------------------------------------------------------------------*/
class dataSchedule
:
public List<labelPair>
{
// Private data
//- Per processor to send to the order in which the data needs to
// be packed.
labelListList sendOrder_;
//- Per processor to receive from the order how to unpack the
// received data.
labelListList receiveOrder_;
public:
ClassName("dataSchedule");
// Constructors
//- Construct from components
dataSchedule(const labelList& sendProcs, const labelList& receiveProcs);
// Member Functions
//- Send order per processor
const labelListList& sendOrder() const
{
return sendOrder_;
}
//- Receive order per processor
const labelListList& receiveOrder() const
{
return receiveOrder_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -185,6 +185,78 @@ Foam::mapDistribute::mapDistribute
{}
Foam::mapDistribute::mapDistribute
(
const labelList& sendProcs,
const labelList& recvProcs
)
:
constructSize_(sendProcs.size()),
schedulePtr_()
{
if (sendProcs.size() != recvProcs.size())
{
FatalErrorIn
(
"mapDistribute::mapDistribute(const labelList&, const labelList&)"
) << "The send and receive data is not the same length. sendProcs:"
<< sendProcs.size() << " recvProcs:" << recvProcs.size()
<< abort(FatalError);
}
// Per processor the number of samples we have to send/receive.
labelList nSend(Pstream::nProcs(), 0);
labelList nRecv(Pstream::nProcs(), 0);
forAll(sendProcs, sampleI)
{
label sendProc = sendProcs[sampleI];
label recvProc = recvProcs[sampleI];
// Note that also need to include local communication (both
// RecvProc and sendProc on local processor)
if (Pstream::myProcNo() == sendProc)
{
// I am the sender. Count destination processor.
nSend[recvProc]++;
}
if (Pstream::myProcNo() == recvProc)
{
// I am the receiver.
nRecv[sendProc]++;
}
}
subMap_.setSize(Pstream::nProcs());
constructMap_.setSize(Pstream::nProcs());
forAll(nSend, procI)
{
subMap_[procI].setSize(nSend[procI]);
constructMap_[procI].setSize(nRecv[procI]);
}
nSend = 0;
nRecv = 0;
forAll(sendProcs, sampleI)
{
label sendProc = sendProcs[sampleI];
label recvProc = recvProcs[sampleI];
if (Pstream::myProcNo() == sendProc)
{
// I am the sender. Store index I need to send.
subMap_[recvProc][nSend[recvProc]++] = sampleI;
}
if (Pstream::myProcNo() == recvProc)
{
// I am the receiver.
constructMap_[sendProc][nRecv[sendProc]++] = sampleI;
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......
......@@ -111,6 +111,14 @@ public:
const bool reUse // clone or reuse
);
//- Construct from reverse addressing: per data item the send
// processor and the receive processor. All processors get same data.
mapDistribute
(
const labelList& sendProcs,
const labelList& recvProcs
);
// Member Functions
......
......@@ -26,9 +26,9 @@ License
#include "directMappedPolyPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "polyMesh.H"
#include "ListListOps.H"
#include "meshSearch.H"
#include "mapDistribute.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -217,26 +217,22 @@ void Foam::directMappedPolyPatch::calcMapping() const
// - cell sample is in (so source when mapping)
// sampleCells, sampleCellProcs.
// Determine schedule.
mapDistribute distMap(sampleCellProcs, patchFaceProcs);
// Determine the schedule
// ~~~~~~~~~~~~~~~~~~~~~~
// Rework the schedule to cell data to send, face data to receive.
schedulePtr_.reset(new List<labelPair>(distMap.schedule()));
dataSchedule mySchedule(sampleCellProcs, patchFaceProcs);
// Extract the scedule itself (reuse storage)
schedulePtr_.reset(new List<labelPair>(mySchedule, true));
const labelListList& sendOrder = mySchedule.sendOrder();
const labelListList& receiveOrder = mySchedule.receiveOrder();
const labelListList& subMap = distMap.subMap();
const labelListList& constructMap = distMap.constructMap();
// Extract the particular data I need to send and receive.
sendCellLabelsPtr_.reset(new labelListList(sendOrder.size()));
sendCellLabelsPtr_.reset(new labelListList(subMap.size()));
labelListList& sendCellLabels = sendCellLabelsPtr_();
forAll(sendOrder, procI)
forAll(subMap, procI)
{
sendCellLabels[procI] =
IndirectList<label>(sampleCells, sendOrder[procI]);
sendCellLabels[procI] = IndirectList<label>(sampleCells, subMap[procI]);
if (debug)
{
......@@ -245,13 +241,13 @@ void Foam::directMappedPolyPatch::calcMapping() const
}