Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2009-11-24 14:45:05 +00:00
107 changed files with 1947 additions and 1480 deletions

View File

@ -1,162 +0,0 @@
Info<< nl << "Reading field boundaryT" << endl;
volScalarField boundaryT
(
IOobject
(
"boundaryT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field boundaryU" << endl;
volVectorField boundaryU
(
IOobject
(
"boundaryU",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field rhoN (number density)" << endl;
volScalarField rhoN
(
IOobject
(
"rhoN",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field rhoM (mass density)" << endl;
volScalarField rhoM
(
IOobject
(
"rhoM",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field rhoNdsmc (dsmc particle density)" << endl;
volScalarField dsmcRhoN
(
IOobject
(
"dsmcRhoN",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field momentum (momentum density)" << endl;
volVectorField momentum
(
IOobject
(
"momentum",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field linearKE (linear kinetic energy density)"
<< endl;
volScalarField linearKE
(
IOobject
(
"linearKE",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field internalE (internal energy density)" << endl;
volScalarField internalE
(
IOobject
(
"internalE",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field iDof (internal degree of freedom density)"
<< endl;
volScalarField iDof
(
IOobject
(
"iDof",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field q (surface heat transfer)" << endl;
volScalarField q
(
IOobject
(
"q",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Reading field fD (surface force density)" << endl;
volVectorField fD
(
IOobject
(
"fD",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< nl << "Constructing dsmcCloud " << endl;
dsmcCloud dsmc("dsmc", boundaryT, boundaryU);

View File

@ -41,53 +41,21 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "createMesh.H" #include "createMesh.H"
#include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< nl << "Constructing dsmcCloud " << endl;
dsmcCloud dsmc("dsmc", mesh);
Info<< "\nStarting time loop\n" << endl; Info<< "\nStarting time loop\n" << endl;
while (runTime.run()) while (runTime.loop())
{ {
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
// Carry out dsmcCloud timestep
dsmc.evolve(); dsmc.evolve();
// Retrieve flow field data from dsmcCloud
rhoN = dsmc.rhoN();
rhoN.correctBoundaryConditions();
rhoM = dsmc.rhoM();
rhoM.correctBoundaryConditions();
dsmcRhoN = dsmc.dsmcRhoN();
dsmcRhoN.correctBoundaryConditions();
momentum = dsmc.momentum();
momentum.correctBoundaryConditions();
linearKE = dsmc.linearKE();
linearKE.correctBoundaryConditions();
internalE = dsmc.internalE();
internalE.correctBoundaryConditions();
iDof = dsmc.iDof();
iDof.correctBoundaryConditions();
// Retrieve surface field data from dsmcCloud
q = dsmc.q();
fD = dsmc.fD();
// Print status of dsmcCloud
dsmc.info(); dsmc.info();
runTime.write(); runTime.write();

View File

@ -1,133 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "argList.H"
#include "Time.H"
#include "DimensionedFields.H"
#include "DimensionedSphericalTensorField.H"
#include "vector.H"
#include "tensor.H"
#include "GeoMesh.H"
using namespace Foam;
namespace Foam
{
class vMesh
{
public:
vMesh()
{}
label size() const
{
return 10;
}
};
};
template<>
const word Foam::DimensionedField<scalar, GeoMesh<vMesh> >::typeName
(
"dimenionedScalarField"
);
template<>
const word Foam::DimensionedField<vector, GeoMesh<vMesh> >::typeName
(
"dimenionedVectorField"
);
template<>
const word Foam::DimensionedField<tensor, GeoMesh<vMesh> >::typeName
(
"dimenionedTensorField"
);
template<>
const word Foam::DimensionedField<sphericalTensor, GeoMesh<vMesh> >::typeName
(
"dimenionedSphericalTensorField"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
vMesh vm;
DimensionedField<scalar, GeoMesh<vMesh> > dsf
(
IOobject
(
"dsf",
runTime.timeName(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
vm
);
Info<< dsf << endl;
dsf += dsf;
dsf -= dimensionedScalar("5", dsf.dimensions(), 5.0);
Info<< dsf << endl;
Info<< sqr(dsf + dsf) - sqr(dsf + dsf) << endl;
DimensionedField<vector, GeoMesh<vMesh> > dvf
(
IOobject
(
"dvf",
runTime.timeName(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
vm
);
Info<< (dvf ^ (dvf ^ dvf)) << endl;
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -1,2 +0,0 @@
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */

View File

@ -33,7 +33,6 @@ Description
#include "HashPtrTable.H" #include "HashPtrTable.H"
#include "Map.H" #include "Map.H"
#include "StaticHashTable.H" #include "StaticHashTable.H"
#include "HashTbl.H"
#include "cpuTime.H" #include "cpuTime.H"
using namespace Foam; using namespace Foam;
@ -53,7 +52,7 @@ int main(int argc, char *argv[])
// Map<label> map(2 * nSize); // Map<label> map(2 * nSize);
// HashTable<label, label, Hash<label> > map(2 * nSize); // HashTable<label, label, Hash<label> > map(2 * nSize);
// StaticHashTable<label, label, Hash<label> > map(2 * nSize); // StaticHashTable<label, label, Hash<label> > map(2 * nSize);
HashTbl<label, label, Hash<label> > map(2 * nSize); HashTable<label, label, Hash<label> > map(2 * nSize);
Info<< "Constructed map of size: " << nSize Info<< "Constructed map of size: " << nSize
<< " (size " << map.size() << " capacity " << map.capacity() << ") " << " (size " << map.size() << " capacity " << map.capacity() << ") "

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "Matrix.H" #include "SquareMatrix.H"
#include "vector.H" #include "vector.H"
using namespace Foam; using namespace Foam;
@ -34,7 +34,7 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Matrix<scalar> hmm(3, 3); SquareMatrix<scalar> hmm(3);
hmm[0][0] = -3.0; hmm[0][0] = -3.0;
hmm[0][1] = 10.0; hmm[0][1] = 10.0;
@ -46,27 +46,27 @@ int main(int argc, char *argv[])
hmm[2][1] = 6.0; hmm[2][1] = 6.0;
hmm[2][2] = 1.0; hmm[2][2] = 1.0;
Info<< hmm << endl << hmm - 2.0*(-hmm) << endl; //Info<< hmm << endl << hmm - 2.0*(-hmm) << endl;
Info<< max(hmm) << endl; Info<< max(hmm) << endl;
Info<< min(hmm) << endl; Info<< min(hmm) << endl;
Matrix<scalar> hmm2(3, 3, 1.0); SquareMatrix<scalar> hmm2(3, 1.0);
hmm = hmm2; hmm = hmm2;
Info<< hmm << endl; Info<< hmm << endl;
Matrix<scalar> hmm3(Sin); SquareMatrix<scalar> hmm3(Sin);
Info<< hmm3 << endl; Info<< hmm3 << endl;
Matrix<scalar> hmm4; SquareMatrix<scalar> hmm4;
hmm4 = hmm2; hmm4 = hmm2;
Info<< hmm4 << endl; Info<< hmm4 << endl;
Matrix<scalar> hmm5; SquareMatrix<scalar> hmm5;
hmm4 = hmm5; hmm4 = hmm5;
Info<< hmm5 << endl; Info<< hmm5 << endl;

View File

@ -69,7 +69,7 @@ public:
const scalar x, const scalar x,
const scalarField& y, const scalarField& y,
scalarField& dfdx, scalarField& dfdx,
Matrix<scalar>& dfdy scalarSquareMatrix& dfdy
) const ) const
{ {
dfdx[0] = 0.0; dfdx[0] = 0.0;

View File

@ -57,6 +57,8 @@ public:
Info <<"delete Scalar: " << data_ << endl; Info <<"delete Scalar: " << data_ << endl;
} }
autoPtr<Scalar> clone() const;
friend Ostream& operator<<(Ostream& os, const Scalar& val) friend Ostream& operator<<(Ostream& os, const Scalar& val)
{ {
os << val.data_; os << val.data_;

View File

@ -84,11 +84,11 @@ int main(int argc, char *argv[])
// test List operations // test List operations
List<double> flatList = UIndirectList<double>(completeList, addresses); List<double> flatList(UIndirectList<double>(completeList, addresses));
Info<< "List assigned from UIndirectList: " << flatList << endl; Info<< "List constructed from UIndirectList: " << flatList << endl;
List<double> flatList2(UIndirectList<double>(completeList, addresses)); flatList = UIndirectList<double>(completeList, addresses);
Info<< "List constructed from UIndirectList: " << flatList2 << endl; Info<< "List assigned from UIndirectList: " << flatList << endl;
flatList.append(UIndirectList<double>(completeList, addresses)); flatList.append(UIndirectList<double>(completeList, addresses));
Info<< "List::append(UIndirectList): " << flatList << endl; Info<< "List::append(UIndirectList): " << flatList << endl;

View File

@ -84,7 +84,7 @@ int main(int argc, char *argv[])
// Sync how many to send // Sync how many to send
labelListList allNTrans(Pstream::nProcs()); labelListList allNTrans(Pstream::nProcs());
allNTrans[Pstream::myProcNo()] = nSend; allNTrans[Pstream::myProcNo()] = nSend;
combineReduce(allNTrans, mapDistribute::listEq()); combineReduce(allNTrans, UPstream::listEq());
// Collect items to be sent // Collect items to be sent
labelListList sendMap(Pstream::nProcs()); labelListList sendMap(Pstream::nProcs());
@ -161,7 +161,7 @@ int main(int argc, char *argv[])
toMaster << data; toMaster << data;
} }
Perr<< "slave receiving from master " Perr<< "slave receiving from master "
<< Pstream::masterNo() << endl; << Pstream::masterNo() << endl;
IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); IPstream fromMaster(Pstream::blocking, Pstream::masterNo());
fromMaster >> data; fromMaster >> data;

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application Application
volField slicedFieldTest
Description Description
@ -32,16 +32,16 @@ Description
#include "fvCFD.H" #include "fvCFD.H"
#include "SlicedGeometricField.H" #include "SlicedGeometricField.H"
#include "slicedFvPatchFields.H" #include "slicedFvPatchFields.H"
#include "slicedSurfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "setRootCase.H"
# include "setRootCase.H" #include "createTime.H"
#include "createMesh.H"
# include "createTime.H"
# include "createMesh.H"
Info<< "Reading field p\n" << endl; Info<< "Reading field p\n" << endl;
volScalarField p volScalarField p
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
Info<< C << endl; Info<< C << endl;
Info<< (C & U) << endl; Info<< (C & U) << endl;
SlicedGeometricField<vector, fvPatchField, slicedFvPatchField, surfaceMesh> SlicedGeometricField<vector, fvsPatchField, slicedFvsPatchField, surfaceMesh>
Sf Sf
( (
IOobject IOobject
@ -105,7 +105,7 @@ int main(int argc, char *argv[])
mesh.faceAreas() mesh.faceAreas()
); );
Info<< Sf << endl; //Info<< Sf << endl;
return 0; return 0;
} }

View File

@ -48,8 +48,6 @@ int main(int argc, char *argv[])
# include "createTime.H" # include "createTime.H"
# include "createPolyMesh.H" # include "createPolyMesh.H"
pointMesh pMesh(mesh);
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Get name of patch // Get name of patch
@ -99,7 +97,7 @@ int main(int argc, char *argv[])
PointEdgeWave<pointEdgePoint> wallCalc PointEdgeWave<pointEdgePoint> wallCalc
( (
pMesh, mesh,
wallPoints, wallPoints,
wallInfo, wallInfo,
@ -119,7 +117,7 @@ int main(int argc, char *argv[])
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
pMesh, pointMesh::New(mesh),
dimensionedScalar("wallDist", dimLength, 0.0) dimensionedScalar("wallDist", dimLength, 0.0)
); );

View File

@ -34,11 +34,10 @@ Application
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "setRootCase.H"
# include "setRootCase.H" #include "createTime.H"
#include "createMesh.H"
# include "createTime.H"
# include "createMesh.H"
Info<< "Reading field p\n" << endl; Info<< "Reading field p\n" << endl;
volScalarField p volScalarField p
@ -70,12 +69,9 @@ int main(int argc, char *argv[])
mesh mesh
); );
# include "createPhi.H" #include "createPhi.H"
//Info<< transform(dimensionedTensor("I", dimless, 0.1*I), U) << endl; GeometricField<symmTensor, fvPatchField, volMesh> st
GeometricField<sphericalTensor, fvPatchField, volMesh> st
( (
IOobject IOobject
( (
@ -86,8 +82,8 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh,
dimensioned<sphericalTensor>("st", dimless, sphericalTensor::I), dimensioned<symmTensor>("st", dimless, symmTensor::one),
zeroGradientFvPatchSphericalTensorField::typeName zeroGradientFvPatchSymmTensorField::typeName
); );
//Info<< fvc::div(st) << endl; //Info<< fvc::div(st) << endl;

View File

@ -45,7 +45,7 @@ Description
so cannot have any cells in any other zone. so cannot have any cells in any other zone.
- useCellZonesOnly does not do a walk and uses the cellZones only. Use - useCellZonesOnly does not do a walk and uses the cellZones only. Use
this if you don't mind having disconnected domains in a single region. this if you don't mind having disconnected domains in a single region.
This option requires all cells to be in one (and one only) region. This option requires all cells to be in one (and one only) cellZone.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -113,7 +113,16 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
return; return;
} }
wordList extensiveVVFNames(IStringStream ("(momentumMean)")()); wordList extensiveVVFNames
(
IStringStream
(
"( \
momentumMean \
fDMean \
)"
)()
);
PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size()); PtrList<volVectorField> extensiveVVFs(extensiveVVFNames.size());

View File

@ -44,9 +44,21 @@ int main(int argc, char *argv[])
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
IOdictionary dsmcInitialiseDict
(
IOobject
(
"dsmcInitialiseDict",
mesh.time().system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
Info<< "Initialising dsmc for Time = " << runTime.timeName() << nl << endl; Info<< "Initialising dsmc for Time = " << runTime.timeName() << nl << endl;
dsmcCloud dsmc("dsmc", mesh); dsmcCloud dsmc("dsmc", mesh, dsmcInitialiseDict);
label totalMolecules = dsmc.size(); label totalMolecules = dsmc.size();

View File

@ -206,6 +206,21 @@ done
cmd="" cmd=""
if [ .$WM_MPLIB = .OPENMPI ]; then if [ .$WM_MPLIB = .OPENMPI ]; then
cmd="mpirun -app $PWD/mpirun.schema </dev/null" cmd="mpirun -app $PWD/mpirun.schema </dev/null"
elif [ .$WM_MPLIB = .MPICH ]; then
cmd="mpiexec"
for ((proc=0; proc<$nProcs; proc++))
do
read procCmd
procXtermCmdFile="$PWD/processor${proc}Xterm.sh"
echo "#!/bin/sh" > $procXtermCmdFile
echo "$procCmd" >> $procXtermCmdFile
chmod +x $procXtermCmdFile
if [ $proc -ne 0 ]; then
cmd="${cmd} :"
fi
cmd="${cmd} -n 1 ${procXtermCmdFile}"
done < $PWD/mpirun.schema
fi fi
echo "Constructed $PWD/mpirun.schema file." echo "Constructed $PWD/mpirun.schema file."

View File

@ -377,6 +377,7 @@ DebugSwitches
displacementLaplacian 0; displacementLaplacian 0;
displacementSBRStress 0; displacementSBRStress 0;
distanceSurface 0; distanceSurface 0;
distribution 0;
downwind 0; downwind 0;
dragModel 0; dragModel 0;
duplicatePoints 0; duplicatePoints 0;

View File

@ -105,7 +105,7 @@ template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs) void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs)
{ {
// Remove elements not also found in rhs // Remove elements not also found in rhs
for (iterator iter = this->cbegin(); iter != this->cend(); ++iter) for (iterator iter = this->begin(); iter != this->end(); ++iter)
{ {
if (!rhs.found(iter.key())) if (!rhs.found(iter.key()))
{ {
@ -145,8 +145,6 @@ void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
} }
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
/* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
template<class Key, class Hash> template<class Key, class Hash>

View File

@ -184,6 +184,12 @@ public:
// an out-of-range element returns false without any ill-effects // an out-of-range element returns false without any ill-effects
inline const T& operator[](const label) const; inline const T& operator[](const label) const;
//- Return last element of UList.
inline T& last();
//- Return last element of UList.
inline const T& last() const;
//- Allow cast to a const List<T>& //- Allow cast to a const List<T>&
inline operator const Foam::List<T>&() const; inline operator const Foam::List<T>&() const;

View File

@ -114,6 +114,20 @@ inline void Foam::UList<T>::checkIndex(const label i) const
} }
template<class T>
inline T& Foam::UList<T>::last()
{
return this->operator[](this->size()-1);
}
template<class T>
inline const T& Foam::UList<T>::last() const
{
return this->operator[](this->size()-1);
}
template<class T> template<class T>
inline const T* Foam::UList<T>::cdata() const inline const T* Foam::UList<T>::cdata() const
{ {

View File

@ -82,9 +82,6 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block)
if (commsType_ == UPstream::nonBlocking) if (commsType_ == UPstream::nonBlocking)
{ {
labelListList sizes;
labelListList send,recv;
Pstream::exchange<DynamicList<char>, char> Pstream::exchange<DynamicList<char>, char>
( (
sendBuf_, sendBuf_,
@ -96,20 +93,30 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block)
} }
else else
{ {
sizes.setSize(UPstream::nProcs()); FatalErrorIn
labelList& nsTransPs = sizes[UPstream::myProcNo()]; (
nsTransPs.setSize(UPstream::nProcs()); "PstreamBuffers::finishedSends(labelListList&, const bool)"
) << "Obtaining sizes not supported in "
<< UPstream::commsTypeNames[commsType_] << endl
<< " since transfers already in progress. Use non-blocking instead."
<< exit(FatalError);
forAll(sendBuf_, procI) // Note: possible only if using different tag from write started
{ // by ~UOPstream. Needs some work.
nsTransPs[procI] = sendBuf_[procI].size(); //sizes.setSize(UPstream::nProcs());
} //labelList& nsTransPs = sizes[UPstream::myProcNo()];
//nsTransPs.setSize(UPstream::nProcs());
// Send sizes across. //
int oldTag = UPstream::msgType(); //forAll(sendBuf_, procI)
UPstream::msgType() = tag_; //{
combineReduce(sizes, UPstream::listEq()); // nsTransPs[procI] = sendBuf_[procI].size();
UPstream::msgType() = oldTag; //}
//
//// Send sizes across.
//int oldTag = UPstream::msgType();
//UPstream::msgType() = tag_;
//combineReduce(sizes, UPstream::listEq());
//UPstream::msgType() = oldTag;
} }
} }

View File

@ -138,7 +138,8 @@ public:
void finishedSends(const bool block = true); void finishedSends(const bool block = true);
//- Mark all sends as having been done. Same as above but also returns //- Mark all sends as having been done. Same as above but also returns
// sizes (bytes) transferred. // sizes (bytes) transferred. Note:currently only valid for
// non-blocking.
void finishedSends(labelListList& sizes, const bool block = true); void finishedSends(labelListList& sizes, const bool block = true);
}; };

View File

@ -50,43 +50,42 @@ void Pstream::exchange
const bool block const bool block
) )
{ {
if (UPstream::parRun()) if (!contiguous<T>())
{ {
if (!contiguous<T>()) FatalErrorIn
{ (
FatalErrorIn "Pstream::exchange(..)"
( ) << "Continuous data only." << Foam::abort(FatalError);
"Pstream::exchange(..)" }
) << "Continuous data only." << Foam::abort(FatalError);
}
if (sendBufs.size() != UPstream::nProcs()) if (sendBufs.size() != UPstream::nProcs())
{ {
FatalErrorIn FatalErrorIn
( (
"Pstream::exchange(..)" "Pstream::exchange(..)"
) << "Size of list:" << sendBufs.size() ) << "Size of list:" << sendBufs.size()
<< " does not equal the number of processors:" << " does not equal the number of processors:"
<< UPstream::nProcs() << UPstream::nProcs()
<< Foam::abort(FatalError); << Foam::abort(FatalError);
} }
sizes.setSize(UPstream::nProcs()); sizes.setSize(UPstream::nProcs());
labelList& nsTransPs = sizes[UPstream::myProcNo()]; labelList& nsTransPs = sizes[UPstream::myProcNo()];
nsTransPs.setSize(UPstream::nProcs()); nsTransPs.setSize(UPstream::nProcs());
forAll(sendBufs, procI) forAll(sendBufs, procI)
{ {
nsTransPs[procI] = sendBufs[procI].size(); nsTransPs[procI] = sendBufs[procI].size();
} }
// Send sizes across.
int oldTag = UPstream::msgType();
UPstream::msgType() = tag;
combineReduce(sizes, UPstream::listEq());
UPstream::msgType() = oldTag;
// Send sizes across.
int oldTag = UPstream::msgType();
UPstream::msgType() = tag;
combineReduce(sizes, UPstream::listEq());
UPstream::msgType() = oldTag;
if (Pstream::parRun())
{
// Set up receives // Set up receives
// ~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~

View File

@ -37,8 +37,43 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
dict_.readIfPresent("region", regionName_); dict_.readIfPresent("region", regionName_);
dict_.readIfPresent("dictionary", dictName_); dict_.readIfPresent("dictionary", dictName_);
dict_.readIfPresent("enabled", enabled_); dict_.readIfPresent("enabled", enabled_);
dict_.readIfPresent("storeFilter", storeFilter_);
} }
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
{
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::destroyFilter()
{
ptr_.reset();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -56,6 +91,7 @@ Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
regionName_(polyMesh::defaultRegion), regionName_(polyMesh::defaultRegion),
dictName_(), dictName_(),
enabled_(true), enabled_(true),
storeFilter_(true),
outputControl_(t, dict) outputControl_(t, dict)
{ {
readDict(); readDict();
@ -83,32 +119,9 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::start()
{ {
readDict(); readDict();
if (enabled_) if (enabled_&&storeFilter_)
{ {
if (dictName_.size()) allocateFilter();
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
} }
return true; return true;
@ -120,12 +133,22 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::execute()
{ {
if (enabled_) if (enabled_)
{ {
if (!storeFilter_)
{
allocateFilter();
}
ptr_->execute(); ptr_->execute();
if (outputControl_.output()) if (outputControl_.output())
{ {
ptr_->write(); ptr_->write();
} }
if (!storeFilter_)
{
destroyFilter();
}
} }
return true; return true;
@ -137,12 +160,22 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::end()
{ {
if (enabled_) if (enabled_)
{ {
if (!storeFilter_)
{
allocateFilter();
}
ptr_->end(); ptr_->end();
if (outputControl_.output()) if (outputControl_.output())
{ {
ptr_->write(); ptr_->write();
} }
if (!storeFilter_)
{
destroyFilter();
}
} }
return true; return true;

View File

@ -78,6 +78,10 @@ class OutputFilterFunctionObject
//- Switch for the execution of the functionObject //- Switch for the execution of the functionObject
bool enabled_; bool enabled_;
//- Switch to store filter in between writes or use on-the-fly
// construction
bool storeFilter_;
//- Output controls //- Output controls
outputFilterOutputControl outputControl_; outputFilterOutputControl outputControl_;
@ -89,6 +93,12 @@ class OutputFilterFunctionObject
//- Read relevant dictionary entries //- Read relevant dictionary entries
void readDict(); void readDict();
//- Creates most of the data associated with this object.
void allocateFilter();
//- Destroys most of the data associated with this object.
void destroyFilter();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
OutputFilterFunctionObject(const OutputFilterFunctionObject&); OutputFilterFunctionObject(const OutputFilterFunctionObject&);

View File

@ -235,12 +235,12 @@ void Foam::Matrix<Form, Type>::operator=(const Matrix<Form, Type>& a)
template<class Form, class Type> template<class Form, class Type>
const Type& Foam::max(const Matrix<Form, Type>& a) const Type& Foam::max(const Matrix<Form, Type>& a)
{ {
label nm = a.n_*a.m_; label nm = a.n()*a.m();
if (nm) if (nm)
{ {
label curMaxI = 0; label curMaxI = 0;
const Type* v = a.v_[0]; const Type* v = a[0];
for (register label i=1; i<nm; i++) for (register label i=1; i<nm; i++)
{ {
@ -267,12 +267,12 @@ const Type& Foam::max(const Matrix<Form, Type>& a)
template<class Form, class Type> template<class Form, class Type>
const Type& Foam::min(const Matrix<Form, Type>& a) const Type& Foam::min(const Matrix<Form, Type>& a)
{ {
label nm = a.n_*a.m_; label nm = a.n()*a.m();
if (nm) if (nm)
{ {
label curMinI = 0; label curMinI = 0;
const Type* v = a.v_[0]; const Type* v = a[0];
for (register label i=1; i<nm; i++) for (register label i=1; i<nm; i++)
{ {
@ -301,14 +301,14 @@ const Type& Foam::min(const Matrix<Form, Type>& a)
template<class Form, class Type> template<class Form, class Type>
Form Foam::operator-(const Matrix<Form, Type>& a) Form Foam::operator-(const Matrix<Form, Type>& a)
{ {
Form na(a.n_, a.m_); Form na(a.n(), a.m());
if (a.n_ && a.m_) if (a.n() && a.m())
{ {
Type* nav = na.v_[0]; Type* nav = na[0];
const Type* av = a.v_[0]; const Type* av = a[0];
label nm = a.n_*a.m_; label nm = a.n()*a.m();
for (register label i=0; i<nm; i++) for (register label i=0; i<nm; i++)
{ {
nav[i] = -av[i]; nav[i] = -av[i];
@ -322,33 +322,33 @@ Form Foam::operator-(const Matrix<Form, Type>& a)
template<class Form, class Type> template<class Form, class Type>
Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b) Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
{ {
if (a.n_ != b.n_) if (a.n() != b.n())
{ {
FatalErrorIn FatalErrorIn
( (
"Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" "Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
) << "attempted add matrices with different number of rows: " ) << "attempted add matrices with different number of rows: "
<< a.n_ << ", " << b.n_ << a.n() << ", " << b.n()
<< abort(FatalError); << abort(FatalError);
} }
if (a.m_ != b.m_) if (a.m() != b.m())
{ {
FatalErrorIn FatalErrorIn
( (
"Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" "Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
) << "attempted add matrices with different number of columns: " ) << "attempted add matrices with different number of columns: "
<< a.m_ << ", " << b.m_ << a.m() << ", " << b.m()
<< abort(FatalError); << abort(FatalError);
} }
Form ab(a.n_, a.m_); Form ab(a.n(), a.m());
Type* abv = ab.v_[0]; Type* abv = ab[0];
const Type* av = a.v_[0]; const Type* av = a[0];
const Type* bv = b.v_[0]; const Type* bv = b[0];
label nm = a.n_*a.m_; label nm = a.n()*a.m();
for (register label i=0; i<nm; i++) for (register label i=0; i<nm; i++)
{ {
abv[i] = av[i] + bv[i]; abv[i] = av[i] + bv[i];
@ -361,33 +361,33 @@ Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
template<class Form, class Type> template<class Form, class Type>
Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b) Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
{ {
if (a.n_ != b.n_) if (a.n() != b.n())
{ {
FatalErrorIn FatalErrorIn
( (
"Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" "Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
) << "attempted add matrices with different number of rows: " ) << "attempted add matrices with different number of rows: "
<< a.n_ << ", " << b.n_ << a.n() << ", " << b.n()
<< abort(FatalError); << abort(FatalError);
} }
if (a.m_ != b.m_) if (a.m() != b.m())
{ {
FatalErrorIn FatalErrorIn
( (
"Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)" "Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
) << "attempted add matrices with different number of columns: " ) << "attempted add matrices with different number of columns: "
<< a.m_ << ", " << b.m_ << a.m() << ", " << b.m()
<< abort(FatalError); << abort(FatalError);
} }
Form ab(a.n_, a.m_); Form ab(a.n(), a.m());
Type* abv = ab.v_[0]; Type* abv = ab[0];
const Type* av = a.v_[0]; const Type* av = a[0];
const Type* bv = b.v_[0]; const Type* bv = b[0];
label nm = a.n_*a.m_; label nm = a.n()*a.m();
for (register label i=0; i<nm; i++) for (register label i=0; i<nm; i++)
{ {
abv[i] = av[i] - bv[i]; abv[i] = av[i] - bv[i];
@ -400,14 +400,14 @@ Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
template<class Form, class Type> template<class Form, class Type>
Form Foam::operator*(const scalar s, const Matrix<Form, Type>& a) Form Foam::operator*(const scalar s, const Matrix<Form, Type>& a)
{ {
Form sa(a.n_, a.m_); Form sa(a.n(), a.m());
if (a.n_ && a.m_) if (a.n() && a.m())
{ {
Type* sav = sa.v_[0]; Type* sav = sa[0];
const Type* av = a.v_[0]; const Type* av = a[0];
label nm = a.n_*a.m_; label nm = a.n()*a.m();
for (register label i=0; i<nm; i++) for (register label i=0; i<nm; i++)
{ {
sav[i] = s*av[i]; sav[i] = s*av[i];

View File

@ -161,10 +161,10 @@ public:
// Member operators // Member operators
//- Return subscript-checked element of Matrix. //- Return subscript-checked row of Matrix.
inline Type* operator[](const label); inline Type* operator[](const label);
//- Return subscript-checked element of constant Matrix. //- Return subscript-checked row of constant Matrix.
inline const Type* operator[](const label) const; inline const Type* operator[](const label) const;
//- Assignment operator. Takes linear time. //- Assignment operator. Takes linear time.

View File

@ -28,6 +28,9 @@ License
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
#include "facePointPatch.H" #include "facePointPatch.H"
#include "globalPointPatch.H" #include "globalPointPatch.H"
#include "PstreamBuffers.H"
#include "lduSchedule.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -58,14 +61,46 @@ Foam::pointBoundaryMesh::pointBoundaryMesh
void Foam::pointBoundaryMesh::calcGeometry() void Foam::pointBoundaryMesh::calcGeometry()
{ {
forAll(*this, patchi) PstreamBuffers pBufs(Pstream::defaultCommsType);
{
operator[](patchi).initGeometry();
}
forAll(*this, patchi) if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{ {
operator[](patchi).calcGeometry(); forAll(*this, patchi)
{
operator[](patchi).initGeometry(pBufs);
}
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).calcGeometry(pBufs);
}
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initGeometry(pBufs);
}
else
{
operator[](patchi).calcGeometry(pBufs);
}
}
} }
} }
@ -97,32 +132,92 @@ Foam::pointBoundaryMesh::globalPatch() const
void Foam::pointBoundaryMesh::movePoints(const pointField& p) void Foam::pointBoundaryMesh::movePoints(const pointField& p)
{ {
pointPatchList& patches = *this; PstreamBuffers pBufs(Pstream::defaultCommsType);
forAll(patches, patchi) if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{ {
patches[patchi].initMovePoints(p); forAll(*this, patchi)
{
operator[](patchi).initMovePoints(pBufs, p);
}
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).movePoints(pBufs, p);
}
} }
else if (Pstream::defaultCommsType == Pstream::scheduled)
forAll(patches, patchi)
{ {
patches[patchi].movePoints(p); const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initMovePoints(pBufs, p);
}
else
{
operator[](patchi).movePoints(pBufs, p);
}
}
} }
} }
void Foam::pointBoundaryMesh::updateMesh() void Foam::pointBoundaryMesh::updateMesh()
{ {
pointPatchList& patches = *this; PstreamBuffers pBufs(Pstream::defaultCommsType);
forAll(patches, patchi) if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{ {
patches[patchi].initUpdateMesh(); forAll(*this, patchi)
{
operator[](patchi).initUpdateMesh(pBufs);
}
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).updateMesh(pBufs);
}
} }
else if (Pstream::defaultCommsType == Pstream::scheduled)
forAll(patches, patchi)
{ {
patches[patchi].updateMesh(); const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initUpdateMesh(pBufs);
}
else
{
operator[](patchi).updateMesh(pBufs);
}
}
} }
} }

View File

@ -66,22 +66,22 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry() = 0; virtual void initGeometry(PstreamBuffers&) = 0;
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry() = 0; virtual void calcGeometry(PstreamBuffers&) = 0;
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) = 0; virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&) = 0; virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh() = 0; virtual void initUpdateMesh(PstreamBuffers&) = 0;
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh() = 0; virtual void updateMesh(PstreamBuffers&) = 0;
public: public:

View File

@ -50,13 +50,13 @@ addToRunTimeSelectionTable
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::cyclicPointPatch::initGeometry() void Foam::cyclicPointPatch::initGeometry(PstreamBuffers&)
{ {
transformPairs_.setSize(0); transformPairs_.setSize(0);
} }
void Foam::cyclicPointPatch::calcGeometry() void Foam::cyclicPointPatch::calcGeometry(PstreamBuffers&)
{ {
const edgeList& cp = cyclicPolyPatch_.coupledPoints(); const edgeList& cp = cyclicPolyPatch_.coupledPoints();
const labelList& mp = cyclicPolyPatch_.meshPoints(); const labelList& mp = cyclicPolyPatch_.meshPoints();
@ -128,16 +128,20 @@ void Foam::cyclicPointPatch::calcGeometry()
} }
else if (pointMap[cp[i][0]] == -1 && pointMap[cp[i][1]] != -1) else if (pointMap[cp[i][0]] == -1 && pointMap[cp[i][1]] != -1)
{ {
FatalErrorIn("cyclicPointPatch::calcGeometry() const") FatalErrorIn
<< "Point " << cp[i][0] << "of point-pair " << i (
"cyclicPointPatch::calcGeometry(PstreamBuffers&) const"
) << "Point " << cp[i][0] << "of point-pair " << i
<< " is a global point but the other point " << " is a global point but the other point "
<< cp[i][1] << " is not" << cp[i][1] << " is not"
<< exit(FatalError); << exit(FatalError);
} }
else if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] == -1) else if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] == -1)
{ {
FatalErrorIn("cyclicPointPatch::calcGeometry() const") FatalErrorIn
<< "Point " << cp[i][1] << "of point-pair " << i (
"cyclicPointPatch::calcGeometry(PstreamBuffers&) const"
) << "Point " << cp[i][1] << "of point-pair " << i
<< " is a global point but the other point " << " is a global point but the other point "
<< cp[i][0] << " is not" << cp[i][0] << " is not"
<< exit(FatalError); << exit(FatalError);
@ -149,25 +153,25 @@ void Foam::cyclicPointPatch::calcGeometry()
} }
void cyclicPointPatch::initMovePoints(const pointField&) void cyclicPointPatch::initMovePoints(PstreamBuffers&, const pointField&)
{} {}
void cyclicPointPatch::movePoints(const pointField&) void cyclicPointPatch::movePoints(PstreamBuffers&, const pointField&)
{} {}
void cyclicPointPatch::initUpdateMesh() void cyclicPointPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
facePointPatch::initUpdateMesh(); facePointPatch::initUpdateMesh(pBufs);
cyclicPointPatch::initGeometry(); cyclicPointPatch::initGeometry(pBufs);
} }
void cyclicPointPatch::updateMesh() void cyclicPointPatch::updateMesh(PstreamBuffers& pBufs)
{ {
facePointPatch::updateMesh(); facePointPatch::updateMesh(pBufs);
cyclicPointPatch::calcGeometry(); cyclicPointPatch::calcGeometry(pBufs);
} }

View File

@ -74,22 +74,22 @@ class cyclicPointPatch
edgeList transformPairs_; edgeList transformPairs_;
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry(); virtual void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&); virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
public: public:

View File

@ -52,7 +52,7 @@ addToRunTimeSelectionTable
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::processorPointPatch::initGeometry() void Foam::processorPointPatch::initGeometry(PstreamBuffers& pBufs)
{ {
// Algorithm: // Algorithm:
// Depending on whether the patch is a master or a slave, get the primitive // Depending on whether the patch is a master or a slave, get the primitive
@ -84,16 +84,16 @@ void Foam::processorPointPatch::initGeometry()
if (Pstream::parRun()) if (Pstream::parRun())
{ {
initPatchPatchPoints(); initPatchPatchPoints(pBufs);
} }
} }
void Foam::processorPointPatch::calcGeometry() void Foam::processorPointPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
if (Pstream::parRun()) if (Pstream::parRun())
{ {
calcPatchPatchPoints(); calcPatchPatchPoints(pBufs);
} }
// If it is not runing parallel or there are no global points // If it is not runing parallel or there are no global points
@ -149,11 +149,11 @@ void Foam::processorPointPatch::calcGeometry()
} }
void processorPointPatch::initPatchPatchPoints() void processorPointPatch::initPatchPatchPoints(PstreamBuffers& pBufs)
{ {
if (debug) if (debug)
{ {
Info<< "processorPointPatch::calcPatchPatchPoints() : " Info<< "processorPointPatch::initPatchPatchPoints(PstreamBuffers&) : "
<< "constructing patch-patch points" << "constructing patch-patch points"
<< endl; << endl;
} }
@ -229,7 +229,7 @@ void processorPointPatch::initPatchPatchPoints()
// Send the patchPatchPoints to the neighbouring processor // Send the patchPatchPoints to the neighbouring processor
OPstream toNeighbProc(Pstream::blocking, neighbProcNo()); UOPstream toNeighbProc(neighbProcNo(), pBufs);
toNeighbProc toNeighbProc
<< ppmp.size() // number of points for checking << ppmp.size() // number of points for checking
@ -238,17 +238,17 @@ void processorPointPatch::initPatchPatchPoints()
if (debug) if (debug)
{ {
Info<< "processorPointPatch::calcPatchPatchPoints() : " Info<< "processorPointPatch::initPatchPatchPoints() : "
<< "constructed patch-patch points" << "constructed patch-patch points"
<< endl; << endl;
} }
} }
void Foam::processorPointPatch::calcPatchPatchPoints() void Foam::processorPointPatch::calcPatchPatchPoints(PstreamBuffers& pBufs)
{ {
// Get the patchPatchPoints from the neighbouring processor // Get the patchPatchPoints from the neighbouring processor
IPstream fromNeighbProc(Pstream::blocking, neighbProcNo()); UIPstream fromNeighbProc(neighbProcNo(), pBufs);
label nbrNPoints(readLabel(fromNeighbProc)); label nbrNPoints(readLabel(fromNeighbProc));
labelListList patchPatchPoints(fromNeighbProc); labelListList patchPatchPoints(fromNeighbProc);
@ -265,7 +265,7 @@ void Foam::processorPointPatch::calcPatchPatchPoints()
// separate. // separate.
if (nbrNPoints != ppmp.size()) if (nbrNPoints != ppmp.size())
{ {
WarningIn("processorPointPatch::calcPatchPatchPoints()") WarningIn("processorPointPatch::calcPatchPatchPoints(PstreamBuffers&)")
<< "Processor patch " << name() << "Processor patch " << name()
<< " has " << ppmp.size() << " points; coupled patch has " << " has " << ppmp.size() << " points; coupled patch has "
<< nbrNPoints << " points." << endl << nbrNPoints << " points." << endl
@ -352,25 +352,25 @@ void Foam::processorPointPatch::calcPatchPatchPoints()
} }
void processorPointPatch::initMovePoints(const pointField&) void processorPointPatch::initMovePoints(PstreamBuffers&, const pointField&)
{} {}
void processorPointPatch::movePoints(const pointField&) void processorPointPatch::movePoints(PstreamBuffers&, const pointField&)
{} {}
void processorPointPatch::initUpdateMesh() void processorPointPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
facePointPatch::initUpdateMesh(); facePointPatch::initUpdateMesh(pBufs);
processorPointPatch::initGeometry(); processorPointPatch::initGeometry(pBufs);
} }
void processorPointPatch::updateMesh() void processorPointPatch::updateMesh(PstreamBuffers& pBufs)
{ {
facePointPatch::updateMesh(); facePointPatch::updateMesh(pBufs);
processorPointPatch::calcGeometry(); processorPointPatch::calcGeometry(pBufs);
} }

View File

@ -68,30 +68,30 @@ class processorPointPatch
// Private Member Functions // Private Member Functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry(); virtual void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the points on this patch which are should also be //- Initialise the points on this patch which are should also be
// on a neighbouring patch but are not part of faces of that patch // on a neighbouring patch but are not part of faces of that patch
void initPatchPatchPoints(); void initPatchPatchPoints(PstreamBuffers&);
//- Calculate the points on this patch which are should also be //- Calculate the points on this patch which are should also be
// on a neighbouring patch but are not part of faces of that patch // on a neighbouring patch but are not part of faces of that patch
void calcPatchPatchPoints(); void calcPatchPatchPoints(PstreamBuffers&);
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&); virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
//- Disallow default construct as copy //- Disallow default construct as copy

View File

@ -86,7 +86,7 @@ protected:
// Construction of demand-driven data // Construction of demand-driven data
//- Calculate mesh points //- Calculate mesh points
virtual void calcGeometry() = 0; virtual void calcGeometry(PstreamBuffers&) = 0;
public: public:

View File

@ -67,27 +67,27 @@ class globalPointPatch
// Protected Member Functions // Protected Member Functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry() virtual void initGeometry(PstreamBuffers&)
{} {}
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry() virtual void calcGeometry(PstreamBuffers&)
{} {}
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) virtual void initMovePoints(PstreamBuffers&, const pointField&)
{} {}
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&) virtual void movePoints(PstreamBuffers&, const pointField&)
{} {}
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh() virtual void initUpdateMesh(PstreamBuffers&)
{} {}
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh() virtual void updateMesh(PstreamBuffers&)
{} {}

View File

@ -51,7 +51,7 @@ addToRunTimeSelectionTable
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void facePointPatch::initGeometry() void facePointPatch::initGeometry(PstreamBuffers&)
{ {
meshPoints_.setSize(0); meshPoints_.setSize(0);
localPoints_.setSize(0); localPoints_.setSize(0);
@ -59,25 +59,25 @@ void facePointPatch::initGeometry()
} }
void facePointPatch::calcGeometry() void facePointPatch::calcGeometry(PstreamBuffers&)
{} {}
void facePointPatch::initMovePoints(const pointField&) void facePointPatch::initMovePoints(PstreamBuffers&, const pointField&)
{} {}
void facePointPatch::movePoints(const pointField&) void facePointPatch::movePoints(PstreamBuffers&, const pointField&)
{} {}
void facePointPatch::initUpdateMesh() void facePointPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
facePointPatch::initGeometry(); facePointPatch::initGeometry(pBufs);
} }
void facePointPatch::updateMesh() void facePointPatch::updateMesh(PstreamBuffers&)
{} {}

View File

@ -76,22 +76,22 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry(); virtual void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&); virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
private: private:

View File

@ -49,6 +49,7 @@ namespace Foam
class pointBoundaryMesh; class pointBoundaryMesh;
class pointConstraint; class pointConstraint;
class PstreamBuffers;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class pointPatch Declaration Class pointPatch Declaration
@ -79,27 +80,27 @@ protected:
friend class pointBoundaryMesh; friend class pointBoundaryMesh;
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry() virtual void initGeometry(PstreamBuffers&)
{} {}
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry() virtual void calcGeometry(PstreamBuffers&)
{} {}
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) virtual void initMovePoints(PstreamBuffers&, const pointField&)
{} {}
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&) virtual void movePoints(PstreamBuffers&, const pointField&)
{} {}
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh() virtual void initUpdateMesh(PstreamBuffers&)
{} {}
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh() virtual void updateMesh(PstreamBuffers&)
{} {}

View File

@ -29,6 +29,9 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "stringListOps.H" #include "stringListOps.H"
#include "PstreamBuffers.H"
#include "lduSchedule.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -144,14 +147,46 @@ void Foam::polyBoundaryMesh::clearAddressing()
void Foam::polyBoundaryMesh::calcGeometry() void Foam::polyBoundaryMesh::calcGeometry()
{ {
forAll(*this, patchi) PstreamBuffers pBufs(Pstream::defaultCommsType);
{
operator[](patchi).initGeometry();
}
forAll(*this, patchi) if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{ {
operator[](patchi).calcGeometry(); forAll(*this, patchi)
{
operator[](patchi).initGeometry(pBufs);
}
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).calcGeometry(pBufs);
}
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initGeometry(pBufs);
}
else
{
operator[](patchi).calcGeometry(pBufs);
}
}
} }
} }
@ -573,16 +608,46 @@ bool Foam::polyBoundaryMesh::checkDefinition(const bool report) const
void Foam::polyBoundaryMesh::movePoints(const pointField& p) void Foam::polyBoundaryMesh::movePoints(const pointField& p)
{ {
polyPatchList& patches = *this; PstreamBuffers pBufs(Pstream::defaultCommsType);
forAll(patches, patchi) if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{ {
patches[patchi].initMovePoints(p); forAll(*this, patchi)
{
operator[](patchi).initMovePoints(pBufs, p);
}
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).movePoints(pBufs, p);
}
} }
else if (Pstream::defaultCommsType == Pstream::scheduled)
forAll(patches, patchi)
{ {
patches[patchi].movePoints(p); const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initMovePoints(pBufs, p);
}
else
{
operator[](patchi).movePoints(pBufs, p);
}
}
} }
} }
@ -591,16 +656,46 @@ void Foam::polyBoundaryMesh::updateMesh()
{ {
deleteDemandDrivenData(neighbourEdgesPtr_); deleteDemandDrivenData(neighbourEdgesPtr_);
polyPatchList& patches = *this; PstreamBuffers pBufs(Pstream::defaultCommsType);
forAll(patches, patchi) if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{ {
patches[patchi].initUpdateMesh(); forAll(*this, patchi)
{
operator[](patchi).initUpdateMesh(pBufs);
}
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).updateMesh(pBufs);
}
} }
else if (Pstream::defaultCommsType == Pstream::scheduled)
forAll(patches, patchi)
{ {
patches[patchi].updateMesh(); const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initUpdateMesh(pBufs);
}
else
{
operator[](patchi).updateMesh(pBufs);
}
}
} }
} }

View File

@ -50,8 +50,6 @@ class polyMesh;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class polyBoundaryMesh;
Ostream& operator<<(Ostream&, const polyBoundaryMesh&); Ostream& operator<<(Ostream&, const polyBoundaryMesh&);

View File

@ -90,22 +90,22 @@ protected:
) const; ) const;
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry() = 0; virtual void initGeometry(PstreamBuffers&) = 0;
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry() = 0; virtual void calcGeometry(PstreamBuffers&) = 0;
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) = 0; virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&) = 0; virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh() = 0; virtual void initUpdateMesh(PstreamBuffers&) = 0;
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh() = 0; virtual void updateMesh(PstreamBuffers&) = 0;
//- Write point in OBJ format //- Write point in OBJ format
@ -283,7 +283,11 @@ public:
//- Initialize ordering for primitivePatch. Does not //- Initialize ordering for primitivePatch. Does not
// refer to *this (except for name() and type() etc.) // refer to *this (except for name() and type() etc.)
virtual void initOrder(const primitivePatch&) const = 0; virtual void initOrder
(
PstreamBuffers&,
const primitivePatch&
) const = 0;
//- Return new ordering for primitivePatch. //- Return new ordering for primitivePatch.
// Ordering is -faceMap: for every face // Ordering is -faceMap: for every face
@ -292,6 +296,7 @@ public:
// (faceMap is identity, rotation is 0), true otherwise. // (faceMap is identity, rotation is 0), true otherwise.
virtual bool order virtual bool order
( (
PstreamBuffers&,
const primitivePatch&, const primitivePatch&,
labelList& faceMap, labelList& faceMap,
labelList& rotation labelList& rotation

View File

@ -516,7 +516,8 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
// if (debug) // if (debug)
// { // {
// Pout<< "cyclicPolyPatch::getCentresAndAnchors :" // Pout<< "cyclicPolyPatch::getCentresAndAnchors :"
// << "Specified translation : " << separationVector_ << endl; // << "Specified translation : " << separationVector_
// << endl;
// } // }
// //
// half0Ctrs += separationVector_; // half0Ctrs += separationVector_;
@ -858,36 +859,44 @@ Foam::cyclicPolyPatch::~cyclicPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cyclicPolyPatch::initGeometry() void Foam::cyclicPolyPatch::initGeometry(PstreamBuffers& pBufs)
{ {
polyPatch::initGeometry(); polyPatch::initGeometry(pBufs);
} }
void Foam::cyclicPolyPatch::calcGeometry() void Foam::cyclicPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
polyPatch::calcGeometry(); polyPatch::calcGeometry(pBufs);
calcTransforms(); calcTransforms();
} }
void Foam::cyclicPolyPatch::initMovePoints(const pointField& p) void Foam::cyclicPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{ {
polyPatch::initMovePoints(p); polyPatch::initMovePoints(pBufs, p);
} }
void Foam::cyclicPolyPatch::movePoints(const pointField& p) void Foam::cyclicPolyPatch::movePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{ {
polyPatch::movePoints(p); polyPatch::movePoints(pBufs, p);
calcTransforms(); calcTransforms();
} }
void Foam::cyclicPolyPatch::initUpdateMesh() void Foam::cyclicPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
polyPatch::initUpdateMesh(); polyPatch::initUpdateMesh(pBufs);
} }
void Foam::cyclicPolyPatch::updateMesh() void Foam::cyclicPolyPatch::updateMesh(PstreamBuffers& pBufs)
{ {
polyPatch::updateMesh(); polyPatch::updateMesh(pBufs);
deleteDemandDrivenData(coupledPointsPtr_); deleteDemandDrivenData(coupledPointsPtr_);
deleteDemandDrivenData(coupledEdgesPtr_); deleteDemandDrivenData(coupledEdgesPtr_);
} }
@ -1105,7 +1114,11 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const
} }
void Foam::cyclicPolyPatch::initOrder(const primitivePatch& pp) const void Foam::cyclicPolyPatch::initOrder
(
PstreamBuffers&,
const primitivePatch& pp
) const
{} {}
@ -1115,6 +1128,7 @@ void Foam::cyclicPolyPatch::initOrder(const primitivePatch& pp) const
// is identity, rotation is 0) // is identity, rotation is 0)
bool Foam::cyclicPolyPatch::order bool Foam::cyclicPolyPatch::order
( (
PstreamBuffers& pBufs,
const primitivePatch& pp, const primitivePatch& pp,
labelList& faceMap, labelList& faceMap,
labelList& rotation labelList& rotation
@ -1300,7 +1314,8 @@ bool Foam::cyclicPolyPatch::order
<< endl; << endl;
// Recalculate untransformed face centres // Recalculate untransformed face centres
//pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points()); //pointField rawHalf0Ctrs =
// calcFaceCentres(half0Faces, pp.points());
label vertI = 0; label vertI = 0;
forAll(half1Ctrs, i) forAll(half1Ctrs, i)
@ -1413,7 +1428,8 @@ bool Foam::cyclicPolyPatch::order
<< endl; << endl;
// Recalculate untransformed face centres // Recalculate untransformed face centres
//pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points()); //pointField rawHalf0Ctrs =
// calcFaceCentres(half0Faces, pp.points());
label vertI = 0; label vertI = 0;
forAll(half1Ctrs, i) forAll(half1Ctrs, i)
@ -1499,7 +1515,8 @@ bool Foam::cyclicPolyPatch::order
<< endl; << endl;
// Recalculate untransformed face centres // Recalculate untransformed face centres
//pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points()); //pointField rawHalf0Ctrs =
// calcFaceCentres(half0Faces, pp.points());
label vertI = 0; label vertI = 0;
forAll(half1Ctrs, i) forAll(half1Ctrs, i)

View File

@ -176,22 +176,22 @@ protected:
// Protected Member functions // Protected Member functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry(); virtual void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&); virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
public: public:
@ -391,7 +391,7 @@ public:
//- Initialize ordering for primitivePatch. Does not //- Initialize ordering for primitivePatch. Does not
// refer to *this (except for name() and type() etc.) // refer to *this (except for name() and type() etc.)
virtual void initOrder(const primitivePatch&) const; virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
//- Return new ordering for primitivePatch. //- Return new ordering for primitivePatch.
// Ordering is -faceMap: for every face // Ordering is -faceMap: for every face
@ -400,6 +400,7 @@ public:
// (faceMap is identity, rotation is 0), true otherwise. // (faceMap is identity, rotation is 0), true otherwise.
virtual bool order virtual bool order
( (
PstreamBuffers&,
const primitivePatch&, const primitivePatch&,
labelList& faceMap, labelList& faceMap,
labelList& rotation labelList& rotation

View File

@ -34,6 +34,7 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "Time.H" #include "Time.H"
#include "transformList.H" #include "transformList.H"
#include "PstreamBuffers.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -155,16 +156,11 @@ Foam::processorPolyPatch::~processorPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::processorPolyPatch::initGeometry() void Foam::processorPolyPatch::initGeometry(PstreamBuffers& pBufs)
{ {
if (Pstream::parRun()) if (Pstream::parRun())
{ {
OPstream toNeighbProc UOPstream toNeighbProc(neighbProcNo(), pBufs);
(
Pstream::blocking,
neighbProcNo(),
3*(sizeof(label) + size()*sizeof(vector) + sizeof(scalar))
);
toNeighbProc toNeighbProc
<< faceCentres() << faceCentres()
@ -174,17 +170,13 @@ void Foam::processorPolyPatch::initGeometry()
} }
void Foam::processorPolyPatch::calcGeometry() void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
if (Pstream::parRun()) if (Pstream::parRun())
{ {
{ {
IPstream fromNeighbProc UIPstream fromNeighbProc(neighbProcNo(), pBufs);
(
Pstream::blocking,
neighbProcNo(),
3*(sizeof(label) + size()*sizeof(vector) + sizeof(scalar))
);
fromNeighbProc fromNeighbProc
>> neighbFaceCentres_ >> neighbFaceCentres_
>> neighbFaceAreas_ >> neighbFaceAreas_
@ -251,22 +243,30 @@ void Foam::processorPolyPatch::calcGeometry()
} }
void Foam::processorPolyPatch::initMovePoints(const pointField& p) void Foam::processorPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{ {
polyPatch::movePoints(p); polyPatch::movePoints(pBufs, p);
processorPolyPatch::initGeometry(); processorPolyPatch::initGeometry(pBufs);
} }
void Foam::processorPolyPatch::movePoints(const pointField&) void Foam::processorPolyPatch::movePoints
(
PstreamBuffers& pBufs,
const pointField&
)
{ {
processorPolyPatch::calcGeometry(); processorPolyPatch::calcGeometry(pBufs);
} }
void Foam::processorPolyPatch::initUpdateMesh() void Foam::processorPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
polyPatch::initUpdateMesh(); polyPatch::initUpdateMesh(pBufs);
deleteDemandDrivenData(neighbPointsPtr_); deleteDemandDrivenData(neighbPointsPtr_);
deleteDemandDrivenData(neighbEdgesPtr_); deleteDemandDrivenData(neighbEdgesPtr_);
@ -303,14 +303,7 @@ void Foam::processorPolyPatch::initUpdateMesh()
edgeIndex[patchEdgeI] = findIndex(fEdges, patchEdgeI); edgeIndex[patchEdgeI] = findIndex(fEdges, patchEdgeI);
} }
OPstream toNeighbProc UOPstream toNeighbProc(neighbProcNo(), pBufs);
(
Pstream::blocking,
neighbProcNo(),
8*sizeof(label) // four headers of labelList
+ 2*nPoints()*sizeof(label) // two point-based labellists
+ 2*nEdges()*sizeof(label) // two edge-based labelLists
);
toNeighbProc toNeighbProc
<< pointFace << pointFace
@ -321,10 +314,10 @@ void Foam::processorPolyPatch::initUpdateMesh()
} }
void Foam::processorPolyPatch::updateMesh() void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs)
{ {
// For completeness // For completeness
polyPatch::updateMesh(); polyPatch::updateMesh(pBufs);
if (Pstream::parRun()) if (Pstream::parRun())
{ {
@ -336,7 +329,7 @@ void Foam::processorPolyPatch::updateMesh()
{ {
// Note cannot predict exact size since opposite nPoints might // Note cannot predict exact size since opposite nPoints might
// be different from one over here. // be different from one over here.
IPstream fromNeighbProc(Pstream::blocking, neighbProcNo()); UIPstream fromNeighbProc(neighbProcNo(), pBufs);
fromNeighbProc fromNeighbProc
>> nbrPointFace >> nbrPointFace
@ -446,7 +439,11 @@ const Foam::labelList& Foam::processorPolyPatch::neighbEdges() const
} }
void Foam::processorPolyPatch::initOrder(const primitivePatch& pp) const void Foam::processorPolyPatch::initOrder
(
PstreamBuffers& pBufs,
const primitivePatch& pp
) const
{ {
if (!Pstream::parRun()) if (!Pstream::parRun())
{ {
@ -491,7 +488,7 @@ void Foam::processorPolyPatch::initOrder(const primitivePatch& pp) const
pointField anchors(getAnchorPoints(pp, pp.points())); pointField anchors(getAnchorPoints(pp, pp.points()));
// Now send all info over to the neighbour // Now send all info over to the neighbour
OPstream toNeighbour(Pstream::blocking, neighbProcNo()); UOPstream toNeighbour(neighbProcNo(), pBufs);
toNeighbour << ctrs << anchors; toNeighbour << ctrs << anchors;
} }
} }
@ -503,6 +500,7 @@ void Foam::processorPolyPatch::initOrder(const primitivePatch& pp) const
// is identity, rotation is 0) // is identity, rotation is 0)
bool Foam::processorPolyPatch::order bool Foam::processorPolyPatch::order
( (
PstreamBuffers& pBufs,
const primitivePatch& pp, const primitivePatch& pp,
labelList& faceMap, labelList& faceMap,
labelList& rotation labelList& rotation
@ -539,7 +537,7 @@ bool Foam::processorPolyPatch::order
// Receive data from neighbour // Receive data from neighbour
{ {
IPstream fromNeighbour(Pstream::blocking, neighbProcNo()); UIPstream fromNeighbour(neighbProcNo(), pBufs);
fromNeighbour >> masterCtrs >> masterAnchors; fromNeighbour >> masterCtrs >> masterAnchors;
} }

View File

@ -28,11 +28,9 @@ Class
Description Description
Neighbour processor patch. Neighbour processor patch.
Note: morph patch face ordering comes geometric or topological. Note: morph patch face ordering tries to do a geometric ordering.
Geometric: no cyclics allowed (assumes faces coincident) (assumes faces coincident) Hence will have problems when cyclics
Topological: needs unmodified faces on both sides to correspond. Also are present.
needs at least one per connected patch area (so all patch faces can be
visited from an unmodified face)
SourceFiles SourceFiles
processorPolyPatch.C processorPolyPatch.C
@ -97,22 +95,22 @@ protected:
// Protected Member functions // Protected Member functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
void initGeometry(); void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
void calcGeometry(); void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points //- Initialise the patches for moving points
void initMovePoints(const pointField&); void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
void movePoints(const pointField&); void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
public: public:
@ -283,7 +281,7 @@ public:
//- Initialize ordering for primitivePatch. Does not //- Initialize ordering for primitivePatch. Does not
// refer to *this (except for name() and type() etc.) // refer to *this (except for name() and type() etc.)
virtual void initOrder(const primitivePatch&) const; virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
//- Return new ordering for primitivePatch. //- Return new ordering for primitivePatch.
// Ordering is -faceMap: for every face // Ordering is -faceMap: for every face
@ -292,6 +290,7 @@ public:
// (faceMap is identity, rotation is 0), true otherwise. // (faceMap is identity, rotation is 0), true otherwise.
virtual bool order virtual bool order
( (
PstreamBuffers&,
const primitivePatch&, const primitivePatch&,
labelList& faceMap, labelList& faceMap,
labelList& rotation labelList& rotation

View File

@ -55,12 +55,12 @@ namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::polyPatch::movePoints(const pointField& p) void Foam::polyPatch::movePoints(PstreamBuffers&, const pointField& p)
{ {
primitivePatch::movePoints(p); primitivePatch::movePoints(p);
} }
void Foam::polyPatch::updateMesh() void Foam::polyPatch::updateMesh(PstreamBuffers&)
{ {
clearAddressing(); clearAddressing();
} }
@ -334,12 +334,13 @@ void Foam::polyPatch::write(Ostream& os) const
} }
void Foam::polyPatch::initOrder(const primitivePatch&) const void Foam::polyPatch::initOrder(PstreamBuffers&, const primitivePatch&) const
{} {}
bool Foam::polyPatch::order bool Foam::polyPatch::order
( (
PstreamBuffers&,
const primitivePatch&, const primitivePatch&,
labelList& faceMap, labelList& faceMap,
labelList& rotation labelList& rotation

View File

@ -56,6 +56,7 @@ namespace Foam
class polyBoundaryMesh; class polyBoundaryMesh;
class polyPatch; class polyPatch;
class PstreamBuffers;
Ostream& operator<<(Ostream&, const polyPatch&); Ostream& operator<<(Ostream&, const polyPatch&);
@ -101,26 +102,26 @@ protected:
friend class polyBoundaryMesh; friend class polyBoundaryMesh;
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry() virtual void initGeometry(PstreamBuffers&)
{} {}
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry() virtual void calcGeometry(PstreamBuffers&)
{} {}
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) virtual void initMovePoints(PstreamBuffers&, const pointField&)
{} {}
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField& p); virtual void movePoints(PstreamBuffers&, const pointField& p);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh() virtual void initUpdateMesh(PstreamBuffers&)
{} {}
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
public: public:
@ -358,7 +359,7 @@ public:
//- Initialize ordering for primitivePatch. Does not //- Initialize ordering for primitivePatch. Does not
// refer to *this (except for name() and type() etc.) // refer to *this (except for name() and type() etc.)
virtual void initOrder(const primitivePatch&) const; virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
//- Return new ordering for primitivePatch. //- Return new ordering for primitivePatch.
// Ordering is -faceMap: for every face // Ordering is -faceMap: for every face
@ -367,6 +368,7 @@ public:
// (faceMap is identity, rotation is 0), true otherwise. // (faceMap is identity, rotation is 0), true otherwise.
virtual bool order virtual bool order
( (
PstreamBuffers&,
const primitivePatch&, const primitivePatch&,
labelList& faceMap, labelList& faceMap,
labelList& rotation labelList& rotation

View File

@ -28,7 +28,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template template
< <
class Face, class Face,
@ -36,7 +35,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch PrimitivePatch
( (
@ -60,12 +58,12 @@ PrimitivePatch
edgeLoopsPtr_(NULL), edgeLoopsPtr_(NULL),
localPointsPtr_(NULL), localPointsPtr_(NULL),
localPointOrderPtr_(NULL), localPointOrderPtr_(NULL),
faceCentresPtr_(NULL),
faceNormalsPtr_(NULL), faceNormalsPtr_(NULL),
pointNormalsPtr_(NULL) pointNormalsPtr_(NULL)
{} {}
// Construct from components
template template
< <
class Face, class Face,
@ -73,7 +71,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch PrimitivePatch
( (
@ -98,12 +95,12 @@ PrimitivePatch
edgeLoopsPtr_(NULL), edgeLoopsPtr_(NULL),
localPointsPtr_(NULL), localPointsPtr_(NULL),
localPointOrderPtr_(NULL), localPointOrderPtr_(NULL),
faceCentresPtr_(NULL),
faceNormalsPtr_(NULL), faceNormalsPtr_(NULL),
pointNormalsPtr_(NULL) pointNormalsPtr_(NULL)
{} {}
// Construct as copy
template template
< <
class Face, class Face,
@ -111,7 +108,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch PrimitivePatch
( (
@ -135,6 +131,7 @@ PrimitivePatch
edgeLoopsPtr_(NULL), edgeLoopsPtr_(NULL),
localPointsPtr_(NULL), localPointsPtr_(NULL),
localPointOrderPtr_(NULL), localPointOrderPtr_(NULL),
faceCentresPtr_(NULL),
faceNormalsPtr_(NULL), faceNormalsPtr_(NULL),
pointNormalsPtr_(NULL) pointNormalsPtr_(NULL)
{} {}
@ -149,8 +146,8 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch() ~PrimitivePatch()
{ {
clearOut(); clearOut();
} }
@ -158,7 +155,6 @@ Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Correct patch after moving points
template template
< <
class Face, class Face,
@ -166,7 +162,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
movePoints movePoints
@ -193,7 +188,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::edgeList& const Foam::edgeList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edges() const edges() const
@ -214,7 +208,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::label Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
nInternalEdges() const nInternalEdges() const
@ -235,7 +228,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelList& const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
boundaryPoints() const boundaryPoints() const
@ -256,7 +248,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelListList& const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceFaces() const faceFaces() const
@ -277,7 +268,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelListList& const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edgeFaces() const edgeFaces() const
@ -298,7 +288,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelListList& const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceEdges() const faceEdges() const
@ -319,7 +308,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelListList& const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointEdges() const pointEdges() const
@ -340,7 +328,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelListList& const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointFaces() const pointFaces() const
@ -361,7 +348,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::List<Face>& const Foam::List<Face>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localFaces() const localFaces() const
@ -382,7 +368,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelList& const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshPoints() const meshPoints() const
@ -403,7 +388,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::Map<Foam::label>& const Foam::Map<Foam::label>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshPointMap() const meshPointMap() const
@ -424,7 +408,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::Field<PointType>& const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localPoints() const localPoints() const
@ -445,7 +428,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelList& const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localPointOrder() const localPointOrder() const
@ -466,7 +448,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::label Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
whichPoint whichPoint
@ -495,7 +476,26 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceCentres() const
{
if (!faceCentresPtr_)
{
calcFaceCentres();
}
return *faceCentresPtr_;
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::Field<PointType>& const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceNormals() const faceNormals() const
@ -516,7 +516,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::Field<PointType>& const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointNormals() const pointNormals() const
@ -539,7 +538,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
operator= operator=
@ -552,6 +550,7 @@ operator=
FaceList<Face>::operator=(pp); FaceList<Face>::operator=(pp);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "PrimitivePatchAddressing.C" #include "PrimitivePatchAddressing.C"

View File

@ -166,6 +166,9 @@ private:
//- Local point order for most efficient search //- Local point order for most efficient search
mutable labelList* localPointOrderPtr_; mutable labelList* localPointOrderPtr_;
//- Face centres
mutable Field<PointType>* faceCentresPtr_;
//- Face unit normals //- Face unit normals
mutable Field<PointType>* faceNormalsPtr_; mutable Field<PointType>* faceNormalsPtr_;
@ -205,6 +208,9 @@ private:
//- Calculate local point order //- Calculate local point order
void calcLocalPointOrder() const; void calcLocalPointOrder() const;
//- Calculate face centres
void calcFaceCentres() const;
//- Calculate unit face normals //- Calculate unit face normals
void calcFaceNormals() const; void calcFaceNormals() const;
@ -370,6 +376,9 @@ public:
const labelListList& pointEdges const labelListList& pointEdges
) const; ) const;
//- Return face centres for patch
const Field<PointType>& faceCentres() const;
//- Return face normals for patch //- Return face normals for patch
const Field<PointType>& faceNormals() const; const Field<PointType>& faceNormals() const;

View File

@ -48,7 +48,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcAddressing() const calcAddressing() const

View File

@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
@ -39,7 +37,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcBdryPoints() const calcBdryPoints() const

View File

@ -41,7 +41,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
visitPointRegion visitPointRegion
@ -120,7 +119,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
typename Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo typename Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
surfaceType() const surfaceType() const
@ -174,7 +172,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
bool bool
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
checkTopology checkTopology
@ -245,7 +242,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
bool bool
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
checkPointManifold checkPointManifold

View File

@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
@ -39,7 +37,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearGeom() clearGeom()
@ -52,6 +49,7 @@ clearGeom()
} }
deleteDemandDrivenData(localPointsPtr_); deleteDemandDrivenData(localPointsPtr_);
deleteDemandDrivenData(faceCentresPtr_);
deleteDemandDrivenData(faceNormalsPtr_); deleteDemandDrivenData(faceNormalsPtr_);
deleteDemandDrivenData(pointNormalsPtr_); deleteDemandDrivenData(pointNormalsPtr_);
} }
@ -64,7 +62,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearTopology() clearTopology()
@ -106,7 +103,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearPatchMeshAddr() clearPatchMeshAddr()
@ -132,7 +128,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearOut() clearOut()

View File

@ -31,7 +31,6 @@ Description
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template template
@ -41,7 +40,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcEdgeLoops() const calcEdgeLoops() const
@ -174,7 +172,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelListList& const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edgeLoops() const edgeLoops() const

View File

@ -39,14 +39,13 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcLocalPointOrder() const calcLocalPointOrder() const
{ {
// Note: Cannot use bandCompressing as point-point addressing does // Note: Cannot use bandCompressing as point-point addressing does
// not exist and is not considered generally useful. // not exist and is not considered generally useful.
// //
if (debug) if (debug)
{ {
@ -137,4 +136,5 @@ calcLocalPointOrder() const
} }
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,8 +27,6 @@ License
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "Map.H" #include "Map.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template template
@ -38,7 +36,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcMeshData() const calcMeshData() const
@ -76,13 +73,13 @@ calcMeshData() const
////- 1.5 code: ////- 1.5 code:
//// if the point is used, set the mark to 1 //// if the point is used, set the mark to 1
//forAll (*this, faceI) //forAll(*this, facei)
//{ //{
// const Face& curPoints = this->operator[](faceI); // const Face& curPoints = this->operator[](facei);
// //
// forAll (curPoints, pointI) // forAll(curPoints, pointi)
// { // {
// markedPoints.insert(curPoints[pointI], -1); // markedPoints.insert(curPoints[pointi], -1);
// } // }
//} //}
// //
@ -95,22 +92,22 @@ calcMeshData() const
//sort(pointPatch); //sort(pointPatch);
// //
//// For every point in map give it its label in mesh points //// For every point in map give it its label in mesh points
//forAll (pointPatch, pointI) //forAll(pointPatch, pointi)
//{ //{
// markedPoints.find(pointPatch[pointI])() = pointI; // markedPoints.find(pointPatch[pointi])() = pointi;
//} //}
//- Unsorted version: //- Unsorted version:
DynamicList<label> meshPoints(2*this->size()); DynamicList<label> meshPoints(2*this->size());
forAll (*this, faceI) forAll(*this, facei)
{ {
const Face& curPoints = this->operator[](faceI); const Face& curPoints = this->operator[](facei);
forAll (curPoints, pointI) forAll(curPoints, pointi)
{ {
if (markedPoints.insert(curPoints[pointI], meshPoints.size())) if (markedPoints.insert(curPoints[pointi], meshPoints.size()))
{ {
meshPoints.append(curPoints[pointI]); meshPoints.append(curPoints[pointi]);
} }
} }
} }
@ -124,14 +121,14 @@ calcMeshData() const
localFacesPtr_ = new List<Face>(*this); localFacesPtr_ = new List<Face>(*this);
List<Face>& lf = *localFacesPtr_; List<Face>& lf = *localFacesPtr_;
forAll (*this, faceI) forAll(*this, facei)
{ {
const Face& curFace = this->operator[](faceI); const Face& curFace = this->operator[](facei);
lf[faceI].setSize(curFace.size()); lf[facei].setSize(curFace.size());
forAll (curFace, labelI) forAll(curFace, labelI)
{ {
lf[faceI][labelI] = markedPoints.find(curFace[labelI])(); lf[facei][labelI] = markedPoints.find(curFace[labelI])();
} }
} }
@ -152,7 +149,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcMeshPointMap() const calcMeshPointMap() const
@ -182,7 +178,7 @@ calcMeshPointMap() const
meshPointMapPtr_ = new Map<label>(2*mp.size()); meshPointMapPtr_ = new Map<label>(2*mp.size());
Map<label>& mpMap = *meshPointMapPtr_; Map<label>& mpMap = *meshPointMapPtr_;
forAll (mp, i) forAll(mp, i)
{ {
mpMap.insert(mp[i], i); mpMap.insert(mp[i], i);
} }
@ -204,7 +200,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcLocalPoints() const calcLocalPoints() const
@ -235,9 +230,9 @@ calcLocalPoints() const
Field<PointType>& locPts = *localPointsPtr_; Field<PointType>& locPts = *localPointsPtr_;
forAll (meshPts, pointI) forAll(meshPts, pointi)
{ {
locPts[pointI] = points_[meshPts[pointI]]; locPts[pointi] = points_[meshPts[pointi]];
} }
if (debug) if (debug)
@ -257,7 +252,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointNormals() const calcPointNormals() const
@ -294,15 +288,15 @@ calcPointNormals() const
Field<PointType>& n = *pointNormalsPtr_; Field<PointType>& n = *pointNormalsPtr_;
forAll (pf, pointI) forAll(pf, pointi)
{ {
PointType& curNormal = n[pointI]; PointType& curNormal = n[pointi];
const labelList& curFaces = pf[pointI]; const labelList& curFaces = pf[pointi];
forAll (curFaces, faceI) forAll(curFaces, facei)
{ {
curNormal += faceUnitNormals[curFaces[faceI]]; curNormal += faceUnitNormals[curFaces[facei]];
} }
curNormal /= mag(curNormal) + VSMALL; curNormal /= mag(curNormal) + VSMALL;
@ -325,7 +319,56 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcFaceCentres() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
"calcFaceCentres() : "
"calculating faceCentres in PrimitivePatch"
<< endl;
}
// It is considered an error to attempt to recalculate faceCentres
// if they have already been calculated.
if (faceCentresPtr_)
{
FatalErrorIn
(
"PrimitivePatch<Face, FaceList, PointField, PointType>::"
"calcFaceCentres()"
) << "faceCentresPtr_already allocated"
<< abort(FatalError);
}
faceCentresPtr_ = new Field<PointType>(this->size());
Field<PointType>& c = *faceCentresPtr_;
forAll(c, facei)
{
c[facei] = this->operator[](facei).centre(points_);
}
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
"calcFaceCentres() : "
"finished calculating faceCentres in PrimitivePatch"
<< endl;
}
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcFaceNormals() const calcFaceNormals() const
@ -354,10 +397,10 @@ calcFaceNormals() const
Field<PointType>& n = *faceNormalsPtr_; Field<PointType>& n = *faceNormalsPtr_;
forAll (n, faceI) forAll(n, facei)
{ {
n[faceI] = this->operator[](faceI).normal(points_); n[facei] = this->operator[](facei).normal(points_);
n[faceI] /= mag(n[faceI]) + VSMALL; n[facei] /= mag(n[facei]) + VSMALL;
} }
if (debug) if (debug)

View File

@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
@ -38,7 +36,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::labelList Foam::labelList
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshEdges meshEdges
@ -116,7 +113,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::labelList Foam::labelList
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshEdges meshEdges
@ -174,7 +170,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
Foam::label Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
whichEdge whichEdge

View File

@ -40,7 +40,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointEdges() const calcPointEdges() const
@ -112,7 +111,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointFaces() const calcPointFaces() const

View File

@ -42,7 +42,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
template <class ToPatch> template <class ToPatch>
Foam::List<Foam::objectHit> Foam::List<Foam::objectHit>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
@ -290,7 +289,6 @@ template
class PointField, class PointField,
class PointType class PointType
> >
template <class ToPatch> template <class ToPatch>
Foam::List<Foam::objectHit> Foam::List<Foam::objectHit>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::

View File

@ -1844,6 +1844,8 @@ void Foam::polyTopoChange::reorderCoupledFaces
// Rotation on new faces. // Rotation on new faces.
labelList rotation(faces_.size(), 0); labelList rotation(faces_.size(), 0);
PstreamBuffers pBufs(Pstream::nonBlocking);
// Send ordering // Send ordering
forAll(boundary, patchI) forAll(boundary, patchI)
{ {
@ -1851,6 +1853,7 @@ void Foam::polyTopoChange::reorderCoupledFaces
{ {
boundary[patchI].initOrder boundary[patchI].initOrder
( (
pBufs,
primitivePatch primitivePatch
( (
SubList<face> SubList<face>
@ -1865,6 +1868,8 @@ void Foam::polyTopoChange::reorderCoupledFaces
} }
} }
pBufs.finishedSends();
// Receive and calculate ordering // Receive and calculate ordering
bool anyChanged = false; bool anyChanged = false;
@ -1878,6 +1883,7 @@ void Foam::polyTopoChange::reorderCoupledFaces
bool changed = boundary[patchI].order bool changed = boundary[patchI].order
( (
pBufs,
primitivePatch primitivePatch
( (
SubList<face> SubList<face>

View File

@ -100,7 +100,7 @@ angularOscillatingDisplacementPointPatchVectorField
angle0_(ptf.angle0_), angle0_(ptf.angle0_),
amplitude_(ptf.amplitude_), amplitude_(ptf.amplitude_),
omega_(ptf.omega_), omega_(ptf.omega_),
p0_(ptf.p0_) p0_(ptf.p0_, mapper)
{} {}

View File

@ -91,7 +91,7 @@ oscillatingVelocityPointPatchVectorField
fixedValuePointPatchField<vector>(ptf, p, iF, mapper), fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
amplitude_(ptf.amplitude_), amplitude_(ptf.amplitude_),
omega_(ptf.omega_), omega_(ptf.omega_),
p0_(ptf.p0_) p0_(ptf.p0_, mapper)
{} {}

View File

@ -93,7 +93,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
: :
fixedValuePointPatchField<vector>(ptf, p, iF, mapper), fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
motion_(ptf.motion_), motion_(ptf.motion_),
p0_(ptf.p0_), p0_(ptf.p0_, mapper),
rhoInf_(ptf.rhoInf_) rhoInf_(ptf.rhoInf_)
{} {}

View File

@ -105,20 +105,15 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
const globalMeshData& pData = polyMesh_.globalData(); const globalMeshData& pData = polyMesh_.globalData();
const labelList& processorPatches = pData.processorPatches(); const labelList& processorPatches = pData.processorPatches();
const labelList& processorPatchIndices = pData.processorPatchIndices(); const labelList& processorPatchIndices = pData.processorPatchIndices();
const labelList& processorPatchNeighbours =
pData.processorPatchNeighbours();
// Initialise the setpFraction moved for the particles // Initialise the stepFraction moved for the particles
forAllIter(typename Cloud<ParticleType>, *this, pIter) forAllIter(typename Cloud<ParticleType>, *this, pIter)
{ {
pIter().stepFraction() = 0; pIter().stepFraction() = 0;
} }
// Assume there will be particles to transfer
bool transfered = true;
// While there are particles to transfer // While there are particles to transfer
while (transfered) while (true)
{ {
// List of lists of particles to be transfered for all the processor // List of lists of particles to be transfered for all the processor
// patches // patches
@ -158,104 +153,93 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td)
} }
} }
if (Pstream::parRun()) if (!Pstream::parRun())
{ {
// List of the numbers of particles to be transfered across the break;
// processor patches }
labelList nsTransPs(transferList.size());
forAll(transferList, i)
// Allocate transfer buffers
PstreamBuffers pBufs(Pstream::nonBlocking);
// Stream into send buffers
forAll(transferList, i)
{
if (transferList[i].size())
{ {
nsTransPs[i] = transferList[i].size(); UOPstream particleStream
} (
// List of the numbers of particles to be transfered across the
// processor patches for all the processors
labelListList allNTrans(Pstream::nProcs());
allNTrans[Pstream::myProcNo()] = nsTransPs;
combineReduce(allNTrans, UPstream::listEq());
transfered = false;
forAll(allNTrans, i)
{
forAll(allNTrans[i], j)
{
if (allNTrans[i][j])
{
transfered = true;
break;
}
}
}
if (!transfered)
{
break;
}
forAll(transferList, i)
{
if (transferList[i].size())
{
OPstream particleStream
(
Pstream::blocking,
refCast<const processorPolyPatch>
(
pMesh().boundaryMesh()[processorPatches[i]]
).neighbProcNo()
);
particleStream << transferList[i];
}
}
forAll(processorPatches, i)
{
label patchi = processorPatches[i];
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch> refCast<const processorPolyPatch>
(pMesh().boundaryMesh()[patchi]); (
pMesh().boundaryMesh()[processorPatches[i]]
).neighbProcNo(),
pBufs
);
label neighbProci = particleStream << transferList[i];
procPatch.neighbProcNo() - Pstream::masterNo(); }
}
label neighbProcPatchi = processorPatchNeighbours[patchi]; // Set up transfers when in non-blocking mode. Returns sizes (in bytes)
// to be sent/received.
labelListList allNTrans(Pstream::nProcs());
pBufs.finishedSends(allNTrans);
label nRecPs = allNTrans[neighbProci][neighbProcPatchi]; bool transfered = false;
if (nRecPs) forAll(allNTrans, i)
{
forAll(allNTrans[i], j)
{
if (allNTrans[i][j])
{ {
IPstream particleStream transfered = true;
( break;
Pstream::blocking,
procPatch.neighbProcNo()
);
IDLList<ParticleType> newParticles
(
particleStream,
typename ParticleType::iNew(*this)
);
forAllIter
(
typename Cloud<ParticleType>,
newParticles,
newpIter
)
{
ParticleType& newp = newpIter();
newp.correctAfterParallelTransfer(patchi, td);
addParticle(newParticles.remove(&newp));
}
} }
} }
} }
else
if (!transfered)
{ {
transfered = false; break;
}
// Retrieve from receive buffers
forAll(processorPatches, i)
{
label patchi = processorPatches[i];
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>
(pMesh().boundaryMesh()[patchi]);
label neighbProci = procPatch.neighbProcNo();
label nRecPs = allNTrans[neighbProci][Pstream::myProcNo()];
if (nRecPs)
{
UIPstream particleStream(neighbProci, pBufs);
IDLList<ParticleType> newParticles
(
particleStream,
typename ParticleType::iNew(*this)
);
forAllIter
(
typename Cloud<ParticleType>,
newParticles,
newpIter
)
{
ParticleType& newp = newpIter();
newp.correctAfterParallelTransfer(patchi, td);
addParticle(newParticles.remove(&newp));
}
}
} }
} }
} }

View File

@ -4,9 +4,6 @@ parcels/derived/dsmcParcel/dsmcParcel.C
/* Cloud base classes */ /* Cloud base classes */
clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.C clouds/baseClasses/DsmcBaseCloud/DsmcBaseCloud.C
/* Clouds */
clouds/derived/dsmcCloud/dsmcCloud.C
/* submodels */ /* submodels */
parcels/derived/dsmcParcel/defineDsmcParcel.C parcels/derived/dsmcParcel/defineDsmcParcel.C
parcels/derived/dsmcParcel/makeDsmcParcelBinaryCollisionModels.C parcels/derived/dsmcParcel/makeDsmcParcelBinaryCollisionModels.C

View File

@ -1,7 +1,9 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \ LIB_LIBS = \
-llagrangian \ -llagrangian \
-lfiniteVolume -lfiniteVolume \
-lmeshTools

View File

@ -297,7 +297,7 @@ void Foam::DsmcCloud<ParcelType>::collisions()
// Temporary storage for subCells // Temporary storage for subCells
List<DynamicList<label> > subCells(8); List<DynamicList<label> > subCells(8);
scalar deltaT = cachedDeltaT(); scalar deltaT = mesh().time().deltaTValue();
label collisionCandidates = 0; label collisionCandidates = 0;
@ -473,21 +473,92 @@ void Foam::DsmcCloud<ParcelType>::collisions()
template<class ParcelType> template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::resetSurfaceDataFields() void Foam::DsmcCloud<ParcelType>::resetFields()
{ {
volScalarField::GeometricBoundaryField& qBF(q_.boundaryField()); q_ = dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0);
forAll(qBF, p) fD_ = dimensionedVector
(
"zero",
dimensionSet(1, -1, -2, 0, 0),
vector::zero
);
rhoN_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL);
rhoM_ = dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL);
dsmcRhoN_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0);
linearKE_ = dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0);
internalE_ = dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0);
iDof_ = dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL);
momentum_ = dimensionedVector
(
"zero",
dimensionSet(1, -2, -1, 0, 0),
vector::zero
);
}
template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::calculateFields()
{
scalarField& rhoN = rhoN_.internalField();
scalarField& rhoM = rhoM_.internalField();
scalarField& dsmcRhoN = dsmcRhoN_.internalField();
scalarField& linearKE = linearKE_.internalField();
scalarField& internalE = internalE_.internalField();
scalarField& iDof = iDof_.internalField();
vectorField& momentum = momentum_.internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{ {
qBF[p] = 0.0; const ParcelType& p = iter();
const label cellI = p.cell();
rhoN[cellI]++;
rhoM[cellI] += constProps(p.typeId()).mass();
dsmcRhoN[cellI]++;
linearKE[cellI] += 0.5*constProps(p.typeId()).mass()*(p.U() & p.U());
internalE[cellI] += p.Ei();
iDof[cellI] += constProps(p.typeId()).internalDegreesOfFreedom();
momentum[cellI] += constProps(p.typeId()).mass()*p.U();
} }
volVectorField::GeometricBoundaryField& fDBF(fD_.boundaryField()); rhoN *= nParticle_/mesh().cellVolumes();
rhoN_.correctBoundaryConditions();
forAll(fDBF, p) rhoM *= nParticle_/mesh().cellVolumes();
{ rhoM_.correctBoundaryConditions();
fDBF[p] = vector::zero;
} linearKE *= nParticle_/mesh().cellVolumes();
linearKE_.correctBoundaryConditions();
internalE *= nParticle_/mesh().cellVolumes();
internalE_.correctBoundaryConditions();
iDof *= nParticle_/mesh().cellVolumes();
iDof_.correctBoundaryConditions();
momentum *= nParticle_/mesh().cellVolumes();
momentum_.correctBoundaryConditions();
} }
@ -523,15 +594,14 @@ template<class ParcelType>
Foam::DsmcCloud<ParcelType>::DsmcCloud Foam::DsmcCloud<ParcelType>::DsmcCloud
( (
const word& cloudName, const word& cloudName,
const volScalarField& T, const fvMesh& mesh,
const volVectorField& U,
bool readFields bool readFields
) )
: :
Cloud<ParcelType>(T.mesh(), cloudName, false), Cloud<ParcelType>(mesh, cloudName, false),
DsmcBaseCloud(), DsmcBaseCloud(),
cloudName_(cloudName), cloudName_(cloudName),
mesh_(T.mesh()), mesh_(mesh),
particleProperties_ particleProperties_
( (
IOobject IOobject
@ -563,37 +633,142 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
( (
IOobject IOobject
( (
this->name() + "q_", "q",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::AUTO_WRITE
), ),
mesh_, mesh_
dimensionedScalar("zero", dimensionSet(1, 0, -3, 0, 0), 0.0)
), ),
fD_ fD_
( (
IOobject IOobject
( (
this->name() + "fD_", "fD",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::AUTO_WRITE
), ),
mesh_, mesh_
dimensionedVector ),
rhoN_
(
IOobject
( (
"zero", "rhoN",
dimensionSet(1, -1, -2, 0, 0), mesh_.time().timeName(),
vector::zero mesh_,
) IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
rhoM_
(
IOobject
(
"rhoM",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
dsmcRhoN_
(
IOobject
(
"dsmcRhoN",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
linearKE_
(
IOobject
(
"linearKE",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
internalE_
(
IOobject
(
"internalE",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
iDof_
(
IOobject
(
"iDof",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
momentum_
(
IOobject
(
"momentum",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
), ),
constProps_(), constProps_(),
rndGen_(label(149382906) + 7183*Pstream::myProcNo()), rndGen_(label(149382906) + 7183*Pstream::myProcNo()),
T_(T), boundaryT_
U_(U), (
volScalarField
(
IOobject
(
"boundaryT",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
),
boundaryU_
(
volVectorField
(
IOobject
(
"boundaryU",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
),
binaryCollisionModel_ binaryCollisionModel_
( (
BinaryCollisionModel<DsmcCloud<ParcelType> >::New BinaryCollisionModel<DsmcCloud<ParcelType> >::New
@ -641,7 +816,8 @@ template<class ParcelType>
Foam::DsmcCloud<ParcelType>::DsmcCloud Foam::DsmcCloud<ParcelType>::DsmcCloud
( (
const word& cloudName, const word& cloudName,
const fvMesh& mesh const fvMesh& mesh,
const IOdictionary& dsmcInitialiseDict
) )
: :
Cloud<ParcelType>(mesh, cloudName, false), Cloud<ParcelType>(mesh, cloudName, false),
@ -707,15 +883,111 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
vector::zero vector::zero
) )
), ),
rhoN_
(
IOobject
(
this->name() + "rhoN_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
),
rhoM_
(
IOobject
(
this->name() + "rhoM_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL)
),
dsmcRhoN_
(
IOobject
(
this->name() + "dsmcRhoN_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0)
),
linearKE_
(
IOobject
(
this->name() + "linearKE_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
),
internalE_
(
IOobject
(
this->name() + "internalE_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
),
iDof_
(
IOobject
(
this->name() + "iDof_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
),
momentum_
(
IOobject
(
this->name() + "momentum_",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedVector
(
"zero",
dimensionSet(1, -2, -1, 0, 0),
vector::zero
)
),
constProps_(), constProps_(),
rndGen_(label(971501) + 1526*Pstream::myProcNo()), rndGen_(label(971501) + 1526*Pstream::myProcNo()),
T_ boundaryT_
( (
volScalarField volScalarField
( (
IOobject IOobject
( (
"T", "boundaryT",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
@ -725,13 +997,13 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
dimensionedScalar("zero", dimensionSet(0, 0, 0, 1, 0), 0.0) dimensionedScalar("zero", dimensionSet(0, 0, 0, 1, 0), 0.0)
) )
), ),
U_ boundaryU_
( (
volVectorField volVectorField
( (
IOobject IOobject
( (
"U", "boundaryU",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
@ -754,18 +1026,6 @@ Foam::DsmcCloud<ParcelType>::DsmcCloud
buildConstProps(); buildConstProps();
IOdictionary dsmcInitialiseDict
(
IOobject
(
"dsmcInitialiseDict",
mesh_.time().system(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
initialise(dsmcInitialiseDict); initialise(dsmcInitialiseDict);
} }
@ -782,13 +1042,10 @@ Foam::DsmcCloud<ParcelType>::~DsmcCloud()
template<class ParcelType> template<class ParcelType>
void Foam::DsmcCloud<ParcelType>::evolve() void Foam::DsmcCloud<ParcelType>::evolve()
{ {
// cache the value of deltaT for this timestep
storeDeltaT();
typename ParcelType::trackData td(*this); typename ParcelType::trackData td(*this);
// Reset the surface data collection fields // Reset the data collection fields
resetSurfaceDataFields(); resetFields();
if (debug) if (debug)
{ {
@ -803,6 +1060,9 @@ void Foam::DsmcCloud<ParcelType>::evolve()
// Calculate new velocities via stochastic collisions // Calculate new velocities via stochastic collisions
collisions(); collisions();
// Calculate the volume field data
calculateFields();
} }

View File

@ -110,24 +110,41 @@ class DsmcCloud
//- Force density at surface field //- Force density at surface field
volVectorField fD_; volVectorField fD_;
//- number density field
volScalarField rhoN_;
//- Mass density field
volScalarField rhoM_;
//- dsmc particle density field
volScalarField dsmcRhoN_;
//- linear kinetic energy density field
volScalarField linearKE_;
//- Internal energy density field
volScalarField internalE_;
// Internal degree of freedom density field
volScalarField iDof_;
//- Momentum density field
volVectorField momentum_;
//- Parcel constant properties - one for each type //- Parcel constant properties - one for each type
List<typename ParcelType::constantProperties> constProps_; List<typename ParcelType::constantProperties> constProps_;
//- Random number generator //- Random number generator
Random rndGen_; Random rndGen_;
//- In-cloud cache of deltaT, lookup in submodels and parcel is
// expensive
scalar cachedDeltaT_;
// boundary value fields
// References to the macroscopic fields //- boundary temperature
volScalarField boundaryT_;
//- Temperature //- boundary velocity
const volScalarField& T_; volVectorField boundaryU_;
//- Velocity
const volVectorField& U_;
// References to the cloud sub-models // References to the cloud sub-models
@ -159,8 +176,11 @@ class DsmcCloud
//- Calculate collisions between molecules //- Calculate collisions between molecules
void collisions(); void collisions();
//- Reset the surface data accumulation field values //- Reset the data accumulation field values to zero
void resetSurfaceDataFields(); void resetFields();
//- Calculate the volume field data
void calculateFields();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
DsmcCloud(const DsmcCloud&); DsmcCloud(const DsmcCloud&);
@ -173,20 +193,21 @@ public:
// Constructors // Constructors
//- Construct given name and mesh, will read Parcels from file //- Construct given name and mesh, will read Parcels and fields from
// file
DsmcCloud DsmcCloud
( (
const word& cloudName, const word& cloudName,
const volScalarField& T, const fvMesh& mesh,
const volVectorField& U,
bool readFields = true bool readFields = true
); );
//- Construct given name and mesh. Used to initialise. //- Construct given name, mesh and initialisation dictionary.
DsmcCloud DsmcCloud
( (
const word& cloudName, const word& cloudName,
const fvMesh& mesh const fvMesh& mesh,
const IOdictionary& dsmcInitialiseDict
); );
@ -242,35 +263,72 @@ public:
//- Return refernce to the random object //- Return refernce to the random object
inline Random& rndGen(); inline Random& rndGen();
//- Store (cache) the current value of deltaT
inline void storeDeltaT();
//- Return the cached value of deltaT // References to the boundary fields for surface data collection
inline scalar cachedDeltaT() const;
//- Return non-const heat flux boundary field reference
inline volScalarField::GeometricBoundaryField& qBF();
// References to the surface data collection fields //- Return non-const force density at boundary field reference
inline volVectorField::GeometricBoundaryField& fDBF();
//- Return heat flux at surface field //- Return non-const number density boundary field reference
inline const volScalarField& q() const; inline volScalarField::GeometricBoundaryField& rhoNBF();
//- Return non-const heat flux at surface field //- Return non-const mass density boundary field reference
inline volScalarField& q(); inline volScalarField::GeometricBoundaryField& rhoMBF();
//- Return force density at surface field //- Return non-const linear kinetic energy density boundary
inline const volVectorField& fD() const; // field reference
inline volScalarField::GeometricBoundaryField& linearKEBF();
//- Return non-const force density at surface field //- Return non-const internal energy density boundary field
inline volVectorField& fD(); // reference
inline volScalarField::GeometricBoundaryField& internalEBF();
//- Return non-const internal degree of freedom density boundary
// field reference
inline volScalarField::GeometricBoundaryField& iDofBF();
//- Return non-const momentum density boundary field reference
inline volVectorField::GeometricBoundaryField& momentumBF();
// References to the macroscopic fields // References to the macroscopic fields
//- Return macroscopic temperature //- Return macroscopic temperature
inline const volScalarField& T() const; inline const volScalarField& boundaryT() const;
//- Return macroscopic velocity //- Return macroscopic velocity
inline const volVectorField& U() const; inline const volVectorField& boundaryU() const;
//- Return heat flux at surface field
inline const volScalarField& q() const;
//- Return force density at surface field
inline const volVectorField& fD() const;
//- Return the real particle number density field
inline const volScalarField& rhoN() const;
//- Return the particle mass density field
inline const volScalarField& rhoM() const;
//- Return the field of number of DSMC particles
inline const volScalarField& dsmcRhoN() const;
//- Return the total linear kinetic energy (translational and
// thermal density field
inline const volScalarField& linearKE() const;
//- Return the internal energy density field
inline const volScalarField& internalE() const;
//- Return the average internal degrees of freedom field
inline const volScalarField& iDof() const;
//- Return the momentum density field
inline const volVectorField& momentum() const;
// Kinetic theory helper functions // Kinetic theory helper functions
@ -385,29 +443,6 @@ public:
void dumpParticlePositions() const; void dumpParticlePositions() const;
// Fields
//- Return the real particle number density field
inline const tmp<volScalarField> rhoN() const;
//- Return the particle mass density field
inline const tmp<volScalarField> rhoM() const;
//- Return the field of number of DSMC particles
inline const tmp<volScalarField> dsmcRhoN() const;
//- Return the momentum density field
inline const tmp<volVectorField> momentum() const;
//- Return the total linear kinetic energy (translational and
// thermal density field
inline const tmp<volScalarField> linearKE() const;
//- Return the internal energy density field
inline const tmp<volScalarField> internalE() const;
//- Return the average internal degrees of freedom field
inline const tmp<volScalarField> iDof() const;
// Cloud evolution functions // Cloud evolution functions

View File

@ -126,58 +126,82 @@ inline Foam::Random& Foam::DsmcCloud<ParcelType>::rndGen()
template<class ParcelType> template<class ParcelType>
inline void Foam::DsmcCloud<ParcelType>::storeDeltaT() inline Foam::volScalarField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::qBF()
{ {
cachedDeltaT_ = mesh().time().deltaTValue(); return q_.boundaryField();
} }
template<class ParcelType> template<class ParcelType>
inline Foam::scalar Foam::DsmcCloud<ParcelType>::cachedDeltaT() const inline Foam::volVectorField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::fDBF()
{ {
return cachedDeltaT_; return fD_.boundaryField();
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() const inline Foam::volScalarField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::rhoNBF()
{ {
return q_; return rhoN_.boundaryField();
} }
template<class ParcelType> template<class ParcelType>
inline Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() inline Foam::volScalarField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::rhoMBF()
{ {
return q_; return rhoM_.boundaryField();
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() const inline Foam::volScalarField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::linearKEBF()
{ {
return fD_; return linearKE_.boundaryField();
} }
template<class ParcelType> template<class ParcelType>
inline Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() inline Foam::volScalarField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::internalEBF()
{ {
return fD_; return internalE_.boundaryField();
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::T() const inline Foam::volScalarField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::iDofBF()
{ {
return T_; return iDof_.boundaryField();
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::U() const inline Foam::volVectorField::GeometricBoundaryField&
Foam::DsmcCloud<ParcelType>::momentumBF()
{ {
return U_; return momentum_.boundaryField();
}
template<class ParcelType>
inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::boundaryT() const
{
return boundaryT_;
}
template<class ParcelType>
inline const Foam::volVectorField&
Foam::DsmcCloud<ParcelType>::boundaryU() const
{
return boundaryU_;
} }
@ -381,265 +405,70 @@ Foam::DsmcCloud<ParcelType>::maxwellianMostProbableSpeed
template<class ParcelType> template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField> inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::q() const
{
return q_;
}
template<class ParcelType>
inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::fD() const
{
return fD_;
}
template<class ParcelType>
inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::rhoN() const Foam::DsmcCloud<ParcelType>::rhoN() const
{ {
tmp<volScalarField> trhoN return rhoN_;
(
new volScalarField
(
IOobject
(
this->name() + "rhoN",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
)
);
scalarField& rhoN = trhoN().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
rhoN[cellI]++;
}
rhoN *= nParticle_/mesh().cellVolumes();
return trhoN;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField> inline const Foam::volScalarField& Foam::DsmcCloud<ParcelType>::rhoM() const
Foam::DsmcCloud<ParcelType>::rhoM() const
{ {
tmp<volScalarField> trhoM return rhoM_;
(
new volScalarField
(
IOobject
(
this->name() + "rhoM",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0), VSMALL)
)
);
scalarField& rhoM = trhoM().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
rhoM[cellI] += constProps(p.typeId()).mass();
}
rhoM *= nParticle_/mesh().cellVolumes();
return trhoM;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField> inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::dsmcRhoN() const Foam::DsmcCloud<ParcelType>::dsmcRhoN() const
{ {
tmp<volScalarField> tdsmcRhoN return dsmcRhoN_;
(
new volScalarField
(
IOobject
(
this->name() + "dsmcRhoN",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), 0.0)
)
);
scalarField& dsmcRhoN = tdsmcRhoN().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
dsmcRhoN[cellI]++;
}
return tdsmcRhoN;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::tmp<Foam::volVectorField> inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::momentum() const
{
tmp<volVectorField> tmomentum
(
new volVectorField
(
IOobject
(
this->name() + "momentum",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedVector
(
"zero",
dimensionSet(1, -2, -1, 0, 0),
vector::zero
)
)
);
vectorField& momentum = tmomentum().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
momentum[cellI] += constProps(p.typeId()).mass()*p.U();
}
momentum *= nParticle_/mesh().cellVolumes();
return tmomentum;
}
template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField>
Foam::DsmcCloud<ParcelType>::linearKE() const Foam::DsmcCloud<ParcelType>::linearKE() const
{ {
tmp<volScalarField> tlinearKE return linearKE_;
(
new volScalarField
(
IOobject
(
this->name() + "linearKE",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
)
);
scalarField& linearKE = tlinearKE().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
linearKE[cellI] += 0.5*constProps(p.typeId()).mass()*(p.U() & p.U());
}
linearKE *= nParticle_/mesh().cellVolumes();
return tlinearKE;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField> inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::internalE() const Foam::DsmcCloud<ParcelType>::internalE() const
{ {
tmp<volScalarField> tinternalE return internalE_;
(
new volScalarField
(
IOobject
(
this->name() + "internalE",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(1, -1, -2, 0, 0), 0.0)
)
);
scalarField& internalE = tinternalE().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter)
{
const ParcelType& p = iter();
const label cellI = p.cell();
internalE[cellI] += p.Ei();
}
internalE *= nParticle_/mesh().cellVolumes();
return tinternalE;
} }
template<class ParcelType> template<class ParcelType>
inline const Foam::tmp<Foam::volScalarField> inline const Foam::volScalarField&
Foam::DsmcCloud<ParcelType>::iDof() const Foam::DsmcCloud<ParcelType>::iDof() const
{ {
tmp<volScalarField> tiDof return iDof_;
( }
new volScalarField
(
IOobject
(
this->name() + "iDof",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimensionSet(0, -3, 0, 0, 0), VSMALL)
)
);
scalarField& iDof = tiDof().internalField();
forAllConstIter(typename DsmcCloud<ParcelType>, *this, iter) template<class ParcelType>
{ inline const Foam::volVectorField& Foam::DsmcCloud<ParcelType>::momentum() const
const ParcelType& p = iter(); {
const label cellI = p.cell(); return momentum_;
iDof[cellI] += constProps(p.typeId()).internalDegreesOfFreedom();
}
iDof *= nParticle_/mesh().cellVolumes();
return tiDof;
} }

View File

@ -1,66 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-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 "dsmcCloud.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(dsmcCloud, 0);
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dsmcCloud::dsmcCloud
(
const word& cloudName,
const volScalarField& T,
const volVectorField& U
)
:
DsmcCloud<dsmcParcel>(cloudName, T, U)
{}
Foam::dsmcCloud::dsmcCloud
(
const word& cloudName,
const fvMesh& mesh
)
:
DsmcCloud<dsmcParcel>(cloudName, mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::dsmcCloud::~dsmcCloud()
{}
// ************************************************************************* //

View File

@ -43,54 +43,8 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef DsmcCloud<dsmcParcel> dsmcCloud;
/*---------------------------------------------------------------------------*\ }
Class dsmcCloud Declaration
\*---------------------------------------------------------------------------*/
class dsmcCloud
:
public DsmcCloud<dsmcParcel>
{
// Private member functions
//- Disallow default bitwise copy construct
dsmcCloud(const dsmcCloud&);
//- Disallow default bitwise assignment
void operator=(const dsmcCloud&);
public:
//- Runtime type information
TypeName("dsmcCloud");
// Constructors
//- Construct from components
dsmcCloud
(
const word& cloudName,
const volScalarField& T,
const volVectorField& U
);
//- Construct from name and mesh, used to initialise.
dsmcCloud
(
const word& cloudName,
const fvMesh& mesh
);
//- Destructor
~dsmcCloud();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,6 +25,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "DsmcParcel.H" #include "DsmcParcel.H"
#include "meshTools.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -43,16 +44,31 @@ bool Foam::DsmcParcel<ParcelType>::move
const polyMesh& mesh = td.cloud().pMesh(); const polyMesh& mesh = td.cloud().pMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
const scalar deltaT = td.cloud().cachedDeltaT(); const scalar deltaT = mesh.time().deltaTValue();
scalar tEnd = (1.0 - p.stepFraction())*deltaT; scalar tEnd = (1.0 - p.stepFraction())*deltaT;
const scalar dtMax = tEnd; const scalar dtMax = tEnd;
// For reduced-D cases, the velocity used to track needs to be
// constrained, but the actual U_ of the parcel must not be
// altered or used, as it is altered by patch interactions an
// needs to retain its 3D value for collision purposes.
vector Utracking = U_;
while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL) while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL)
{ {
// Apply correction to position for reduced-D cases
meshTools::constrainToMeshCentre(mesh, p.position());
Utracking = U_;
// Apply correction to velocity to constrain tracking for
// reduced-D cases
meshTools::constrainDirection(mesh, mesh.solutionD(), Utracking);
// Set the Lagrangian time-step // Set the Lagrangian time-step
scalar dt = min(dtMax, tEnd); scalar dt = min(dtMax, tEnd);
dt *= p.trackToFace(p.position() + dt*U_, td); dt *= p.trackToFace(p.position() + dt*Utracking, td);
tEnd -= dt; tEnd -= dt;
@ -113,10 +129,41 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch
TrackData& td TrackData& td
) )
{ {
label wppIndex = wpp.index();
label wppLocalFace = wpp.whichFace(this->face());
const scalar fA = mag(wpp.faceAreas()[wppLocalFace]);
const scalar deltaT = td.cloud().pMesh().time().deltaTValue();
const constantProperties& constProps(td.cloud().constProps(typeId_)); const constantProperties& constProps(td.cloud().constProps(typeId_));
scalar m = constProps.mass(); scalar m = constProps.mass();
vector nw = wpp.faceAreas()[wppLocalFace];
nw /= mag(nw);
scalar U_dot_nw = U_ & nw;
vector Ut = U_ - U_dot_nw*nw;
scalar invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL);
td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
td.cloud().linearKEBF()[wppIndex][wppLocalFace] +=
0.5*m*(U_ & U_)*invMagUnfA;
td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
td.cloud().iDofBF()[wppIndex][wppLocalFace] +=
constProps.internalDegreesOfFreedom()*invMagUnfA;
td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
// pre-interaction energy // pre-interaction energy
scalar preIE = 0.5*m*(U_ & U_) + Ei_; scalar preIE = 0.5*m*(U_ & U_) + Ei_;
@ -132,27 +179,40 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch
typeId_ typeId_
); );
U_dot_nw = U_ & nw;
Ut = U_ - U_dot_nw*nw;
invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL);
td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
td.cloud().linearKEBF()[wppIndex][wppLocalFace] +=
0.5*m*(U_ & U_)*invMagUnfA;
td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
td.cloud().iDofBF()[wppIndex][wppLocalFace] +=
constProps.internalDegreesOfFreedom()*invMagUnfA;
td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
// post-interaction energy // post-interaction energy
scalar postIE = 0.5*m*(U_ & U_) + Ei_; scalar postIE = 0.5*m*(U_ & U_) + Ei_;
// post-interaction momentum // post-interaction momentum
vector postIMom = m*U_; vector postIMom = m*U_;
label wppIndex = wpp.index();
label wppLocalFace = wpp.whichFace(this->face());
const scalar fA = mag(wpp.faceAreas()[wppLocalFace]);
const scalar deltaT = td.cloud().cachedDeltaT();
scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA); scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA);
vector deltaFD = td.cloud().nParticle()*(preIMom - postIMom)/(deltaT*fA); vector deltaFD = td.cloud().nParticle()*(preIMom - postIMom)/(deltaT*fA);
td.cloud().q().boundaryField()[wppIndex][wppLocalFace] += deltaQ; td.cloud().qBF()[wppIndex][wppLocalFace] += deltaQ;
td.cloud().fDBF()[wppIndex][wppLocalFace] += deltaFD;
td.cloud().fD().boundaryField()[wppIndex][wppLocalFace] += deltaFD;
} }
@ -212,4 +272,3 @@ void Foam::DsmcParcel<ParcelType>::transformProperties
#include "DsmcParcelIO.C" #include "DsmcParcelIO.C"
// ************************************************************************* // // ************************************************************************* //

View File

@ -28,6 +28,7 @@ License
#include "DsmcCloud.H" #include "DsmcCloud.H"
#include "MaxwellianThermal.H" #include "MaxwellianThermal.H"
#include "SpecularReflection.H" #include "SpecularReflection.H"
#include "MixedDiffuseSpecular.H"
namespace Foam namespace Foam
{ {
@ -46,6 +47,12 @@ namespace Foam
DsmcCloud, DsmcCloud,
dsmcParcel dsmcParcel
); );
makeWallInteractionModelType
(
MixedDiffuseSpecular,
DsmcCloud,
dsmcParcel
);
}; };

View File

@ -129,7 +129,7 @@ void Foam::FreeStream<CloudType>::inflow()
const polyMesh& mesh(cloud.mesh()); const polyMesh& mesh(cloud.mesh());
const scalar deltaT = cloud.cachedDeltaT(); const scalar deltaT = mesh.time().deltaTValue();
Random& rndGen(cloud.rndGen()); Random& rndGen(cloud.rndGen());
@ -139,12 +139,12 @@ void Foam::FreeStream<CloudType>::inflow()
const volScalarField::GeometricBoundaryField& boundaryT const volScalarField::GeometricBoundaryField& boundaryT
( (
cloud.T().boundaryField() cloud.boundaryT().boundaryField()
); );
const volVectorField::GeometricBoundaryField& boundaryU const volVectorField::GeometricBoundaryField& boundaryU
( (
cloud.U().boundaryField() cloud.boundaryU().boundaryField()
); );
forAll(patches_, p) forAll(patches_, p)
@ -168,7 +168,8 @@ void Foam::FreeStream<CloudType>::inflow()
if (min(boundaryT[patchI]) < SMALL) if (min(boundaryT[patchI]) < SMALL)
{ {
FatalErrorIn ("Foam::FreeStream<CloudType>::inflow()") FatalErrorIn ("Foam::FreeStream<CloudType>::inflow()")
<< "Zero boundary temperature detected, check boundaryT condition." << nl << "Zero boundary temperature detected, check boundaryT "
<< "condition." << nl
<< nl << abort(FatalError); << nl << abort(FatalError);
} }

View File

@ -71,10 +71,10 @@ void Foam::MaxwellianThermal<CloudType>::correct
nw /= mag(nw); nw /= mag(nw);
// Normal velocity magnitude // Normal velocity magnitude
scalar magUn = U & nw; scalar U_dot_nw = U & nw;
// Wall tangential velocity (flow direction) // Wall tangential velocity (flow direction)
vector Ut = U - magUn*nw; vector Ut = U - U_dot_nw*nw;
CloudType& cloud(this->owner()); CloudType& cloud(this->owner());
@ -93,9 +93,9 @@ void Foam::MaxwellianThermal<CloudType>::correct
U.z()*(0.8 + 0.2*rndGen.scalar01()) U.z()*(0.8 + 0.2*rndGen.scalar01())
); );
magUn = U & nw; U_dot_nw = U & nw;
Ut = U - magUn*nw; Ut = U - U_dot_nw*nw;
} }
// Wall tangential unit vector // Wall tangential unit vector
@ -104,7 +104,7 @@ void Foam::MaxwellianThermal<CloudType>::correct
// Other tangential unit vector // Other tangential unit vector
vector tw2 = nw^tw1; vector tw2 = nw^tw1;
scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace]; scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace];
scalar mass = cloud.constProps(typeId).mass(); scalar mass = cloud.constProps(typeId).mass();
@ -118,7 +118,7 @@ void Foam::MaxwellianThermal<CloudType>::correct
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
); );
U += cloud.U().boundaryField()[wppIndex][wppLocalFace]; U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
Ei = cloud.equipartitionInternalEnergy(T, iDof); Ei = cloud.equipartitionInternalEnergy(T, iDof);
} }

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-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 "MixedDiffuseSpecular.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template <class CloudType>
Foam::MixedDiffuseSpecular<CloudType>::MixedDiffuseSpecular
(
const dictionary& dict,
CloudType& cloud
)
:
WallInteractionModel<CloudType>(dict, cloud, typeName),
diffuseFraction_(readScalar(this->coeffDict().lookup("diffuseFraction")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template <class CloudType>
Foam::MixedDiffuseSpecular<CloudType>::~MixedDiffuseSpecular()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class CloudType>
void Foam::MixedDiffuseSpecular<CloudType>::correct
(
const wallPolyPatch& wpp,
const label faceId,
vector& U,
scalar& Ei,
label typeId
)
{
label wppIndex = wpp.index();
label wppLocalFace = wpp.whichFace(faceId);
vector nw = wpp.faceAreas()[wppLocalFace];
// Normal unit vector
nw /= mag(nw);
// Normal velocity magnitude
scalar U_dot_nw = U & nw;
CloudType& cloud(this->owner());
Random& rndGen(cloud.rndGen());
if (diffuseFraction_ > rndGen.scalar01())
{
// Diffuse reflection
// Wall tangential velocity (flow direction)
vector Ut = U - U_dot_nw*nw;
while (mag(Ut) < SMALL)
{
// If the incident velocity is parallel to the face normal, no
// tangential direction can be chosen. Add a perturbation to the
// incoming velocity and recalculate.
U = vector
(
U.x()*(0.8 + 0.2*rndGen.scalar01()),
U.y()*(0.8 + 0.2*rndGen.scalar01()),
U.z()*(0.8 + 0.2*rndGen.scalar01())
);
U_dot_nw = U & nw;
Ut = U - U_dot_nw*nw;
}
// Wall tangential unit vector
vector tw1 = Ut/mag(Ut);
// Other tangential unit vector
vector tw2 = nw^tw1;
scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace];
scalar mass = cloud.constProps(typeId).mass();
scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom();
U =
sqrt(physicoChemical::k.value()*T/mass)
*(
rndGen.GaussNormal()*tw1
+ rndGen.GaussNormal()*tw2
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
);
U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
Ei = cloud.equipartitionInternalEnergy(T, iDof);
}
else
{
// Specular reflection
if (U_dot_nw > 0.0)
{
U -= 2.0*U_dot_nw*nw;
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-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::MixedDiffuseSpecular
Description
Wall interaction setting microscopic velocity to a random one drawn from a
Maxwellian distribution corresponding to a specified temperature
\*---------------------------------------------------------------------------*/
#ifndef MixedDiffuseSpecular_H
#define MixedDiffuseSpecular_H
#include "WallInteractionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class MixedDiffuseSpecular Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class MixedDiffuseSpecular
:
public WallInteractionModel<CloudType>
{
// Private data
//- Fraction of wall interactions that are diffuse
scalar diffuseFraction_;
public:
//- Runtime type information
TypeName("MixedDiffuseSpecular");
// Constructors
//- Construct from dictionary
MixedDiffuseSpecular
(
const dictionary& dict,
CloudType& cloud
);
// Destructor
virtual ~MixedDiffuseSpecular();
// Member Functions
//- Apply wall correction
virtual void correct
(
const wallPolyPatch& wpp,
const label faceId,
vector& U,
scalar& Ei,
label typeId
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "MixedDiffuseSpecular.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -63,11 +63,11 @@ void Foam::SpecularReflection<CloudType>::correct
vector nw = wpp.faceAreas()[wpp.whichFace(faceId)]; vector nw = wpp.faceAreas()[wpp.whichFace(faceId)];
nw /= mag(nw); nw /= mag(nw);
scalar magUn = U & nw; scalar U_dot_nw = U & nw;
if (magUn > 0.0) if (U_dot_nw > 0.0)
{ {
U -= 2.0*magUn*nw; U -= 2.0*U_dot_nw*nw;
} }
} }

View File

@ -25,27 +25,49 @@ License
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
#include "distribution.H" #include "distribution.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(distribution, 0);
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void Foam::distribution::write
(
const fileName& file,
const List<Pair<scalar> >& pairs
)
{
OFstream os(file);
forAll(pairs, i)
{
os << pairs[i].first() << ' ' << pairs[i].second() << nl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
distribution::distribution() Foam::distribution::distribution()
: :
Map<label>(), Map<label>(),
binWidth_(1) binWidth_(1)
{} {}
distribution::distribution(const scalar binWidth) Foam::distribution::distribution(const scalar binWidth)
: :
Map<label>(), Map<label>(),
binWidth_(binWidth) binWidth_(binWidth)
{} {}
distribution::distribution(const distribution& d) Foam::distribution::distribution(const distribution& d)
: :
Map<label>(static_cast< Map<label> >(d)), Map<label>(static_cast< Map<label> >(d)),
binWidth_(d.binWidth()) binWidth_(d.binWidth())
@ -54,13 +76,13 @@ distribution::distribution(const distribution& d)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
distribution::~distribution() Foam::distribution::~distribution()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
label distribution::totalEntries() const Foam::label Foam::distribution::totalEntries() const
{ {
label sumOfEntries = 0; label sumOfEntries = 0;
@ -88,7 +110,7 @@ label distribution::totalEntries() const
} }
scalar distribution::approxTotalEntries() const Foam::scalar Foam::distribution::approxTotalEntries() const
{ {
scalar sumOfEntries = 0; scalar sumOfEntries = 0;
@ -101,7 +123,7 @@ scalar distribution::approxTotalEntries() const
} }
scalar distribution::mean() const Foam::scalar Foam::distribution::mean() const
{ {
scalar runningSum = 0; scalar runningSum = 0;
@ -124,7 +146,7 @@ scalar distribution::mean() const
} }
scalar distribution::median() Foam::scalar Foam::distribution::median()
{ {
// From: // From:
// http://mathworld.wolfram.com/StatisticalMedian.html // http://mathworld.wolfram.com/StatisticalMedian.html
@ -188,7 +210,7 @@ scalar distribution::median()
} }
void distribution::add(const scalar valueToAdd) void Foam::distribution::add(const scalar valueToAdd)
{ {
iterator iter(this->begin()); iterator iter(this->begin());
@ -218,13 +240,13 @@ void distribution::add(const scalar valueToAdd)
} }
void distribution::add(const label valueToAdd) void Foam::distribution::add(const label valueToAdd)
{ {
add(scalar(valueToAdd)); add(scalar(valueToAdd));
} }
void distribution::insertMissingKeys() void Foam::distribution::insertMissingKeys()
{ {
iterator iter(this->begin()); iterator iter(this->begin());
@ -247,7 +269,7 @@ void distribution::insertMissingKeys()
} }
List< Pair<scalar> > distribution::normalised() Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalised()
{ {
scalar totEnt = approxTotalEntries(); scalar totEnt = approxTotalEntries();
@ -268,17 +290,25 @@ List< Pair<scalar> > distribution::normalised()
normDist[k].second() = scalar((*this)[key])/totEnt/binWidth_; normDist[k].second() = scalar((*this)[key])/totEnt/binWidth_;
} }
if (debug)
{
Info<< "totEnt: " << totEnt << endl;
}
return normDist; return normDist;
} }
List< Pair<scalar> > distribution::normalisedMinusMean() Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalisedMinusMean()
{ {
return normalisedShifted(mean()); return normalisedShifted(mean());
} }
List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue) Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalisedShifted
(
scalar shiftValue
)
{ {
List<Pair<scalar> > oldDist(normalised()); List<Pair<scalar> > oldDist(normalised());
@ -301,20 +331,23 @@ List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue)
label newKey = lowestNewKey; label newKey = lowestNewKey;
// Info << shiftValue if (debug)
// << nl << lowestOldBin {
// << nl << lowestNewKey Info<< shiftValue
// << nl << interpolationStartDirection << nl << lowestOldBin
// << endl; << nl << lowestNewKey
<< nl << interpolationStartDirection
<< endl;
// scalar checkNormalisation = 0; scalar checkNormalisation = 0;
// forAll (oldDist, oD) forAll (oldDist, oD)
// { {
// checkNormalisation += oldDist[oD].second()*binWidth_; checkNormalisation += oldDist[oD].second()*binWidth_;
// } }
// Info << "Initial normalisation = " << checkNormalisation << endl; Info<< "Initial normalisation = " << checkNormalisation << endl;
}
forAll(oldDist,u) forAll(oldDist,u)
{ {
@ -368,20 +401,23 @@ List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue)
newKey++; newKey++;
} }
// checkNormalisation = 0; if (debug)
{
scalar checkNormalisation = 0;
// forAll (newDist, nD) forAll (newDist, nD)
// { {
// checkNormalisation += newDist[nD].second()*binWidth_; checkNormalisation += newDist[nD].second()*binWidth_;
// } }
// Info << "Shifted normalisation = " << checkNormalisation << endl; Info<< "Shifted normalisation = " << checkNormalisation << endl;
}
return newDist; return newDist;
} }
List<Pair<scalar> > distribution::raw() Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::raw()
{ {
insertMissingKeys(); insertMissingKeys();
@ -406,7 +442,7 @@ List<Pair<scalar> > distribution::raw()
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void distribution::operator=(const distribution& rhs) void Foam::distribution::operator=(const distribution& rhs)
{ {
// Check for assignment to self // Check for assignment to self
if (this == &rhs) if (this == &rhs)
@ -424,7 +460,7 @@ void distribution::operator=(const distribution& rhs)
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const distribution& d) Foam::Ostream& Foam::operator<<(Ostream& os, const distribution& d)
{ {
os << d.binWidth_ os << d.binWidth_
<< static_cast<const Map<label>&>(d); << static_cast<const Map<label>&>(d);
@ -440,8 +476,4 @@ Ostream& operator<<(Ostream& os, const distribution& d)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,6 +26,8 @@ Class
Foam::distribution Foam::distribution
Description Description
Accumulating histogram of values. Specified bin resolution
automatic generation of bins.
SourceFiles SourceFiles
distributionI.H distributionI.H
@ -59,6 +61,21 @@ class distribution
public: public:
//- Runtime type information
TypeName("distribution");
// Static functions
//- write to file
static void write
(
const fileName& file,
const List<Pair<scalar> >& pairs
);
// Constructors // Constructors
//- Construct null //- Construct null
@ -73,7 +90,7 @@ public:
// Destructor // Destructor
~distribution(); virtual ~distribution();
// Member Functions // Member Functions
@ -97,7 +114,7 @@ public:
List<Pair<scalar> > normalisedMinusMean(); List<Pair<scalar> > normalisedMinusMean();
List<Pair<scalar> > normalisedShifted(const scalar shiftValue); List<Pair<scalar> > normalisedShifted(scalar shiftValue);
List<Pair<scalar> > raw(); List<Pair<scalar> > raw();

View File

@ -2411,6 +2411,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
} }
syncTools::swapBoundaryFaceList(mesh_, neiCellZone, false); syncTools::swapBoundaryFaceList(mesh_, neiCellZone, false);
// Get per face whether is it master (of a coupled set of faces)
PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh_));
// Set owner as no-flip // Set owner as no-flip
forAll(patches, patchI) forAll(patches, patchI)
{ {
@ -2428,14 +2431,27 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()]; label neiZone = neiCellZone[faceI-mesh_.nInternalFaces()];
bool flip; bool flip;
if (ownZone == max(ownZone, neiZone))
label maxZone = max(ownZone, neiZone);
if (maxZone == -1)
{ {
flip = false; flip = false;
} }
else else if (ownZone == neiZone)
{
// Can only happen for coupled boundaries. Keep master
// face unflipped.
flip = !isMasterFace[faceI];
}
else if (neiZone == maxZone)
{ {
flip = true; flip = true;
} }
else
{
flip = false;
}
meshMod.setAction meshMod.setAction
( (

View File

@ -145,44 +145,49 @@ Foam::directMappedPolyPatch::~directMappedPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
void Foam::directMappedPolyPatch::initGeometry() void Foam::directMappedPolyPatch::initGeometry(PstreamBuffers& pBufs)
{ {
polyPatch::initGeometry(); polyPatch::initGeometry(pBufs);
directMappedPatchBase::clearOut();
} }
//- Calculate the patch geometry //- Calculate the patch geometry
void Foam::directMappedPolyPatch::calcGeometry() void Foam::directMappedPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
polyPatch::calcGeometry(); polyPatch::calcGeometry(pBufs);
directMappedPatchBase::clearOut(); directMappedPatchBase::clearOut();
} }
//- Initialise the patches for moving points //- Initialise the patches for moving points
void Foam::directMappedPolyPatch::initMovePoints(const pointField& p) void Foam::directMappedPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{ {
polyPatch::initMovePoints(p); polyPatch::initMovePoints(pBufs, p);
directMappedPatchBase::clearOut();
} }
//- Correct patches after moving points //- Correct patches after moving points
void Foam::directMappedPolyPatch::movePoints(const pointField& p) void Foam::directMappedPolyPatch::movePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{ {
polyPatch::movePoints(p); polyPatch::movePoints(pBufs, p);
directMappedPatchBase::clearOut(); directMappedPatchBase::clearOut();
} }
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
void Foam::directMappedPolyPatch::initUpdateMesh() void Foam::directMappedPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
polyPatch::initUpdateMesh(); polyPatch::initUpdateMesh(pBufs);
directMappedPatchBase::clearOut();
} }
//- Update of the patch topology //- Update of the patch topology
void Foam::directMappedPolyPatch::updateMesh() void Foam::directMappedPolyPatch::updateMesh(PstreamBuffers& pBufs)
{ {
polyPatch::updateMesh(); polyPatch::updateMesh(pBufs);
directMappedPatchBase::clearOut(); directMappedPatchBase::clearOut();
} }

View File

@ -65,22 +65,22 @@ class directMappedPolyPatch
protected: protected:
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry(); virtual void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&); virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
public: public:

View File

@ -150,44 +150,49 @@ Foam::directMappedWallPolyPatch::~directMappedWallPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
void Foam::directMappedWallPolyPatch::initGeometry() void Foam::directMappedWallPolyPatch::initGeometry(PstreamBuffers& pBufs)
{ {
wallPolyPatch::initGeometry(); wallPolyPatch::initGeometry(pBufs);
directMappedPatchBase::clearOut();
} }
//- Calculate the patch geometry //- Calculate the patch geometry
void Foam::directMappedWallPolyPatch::calcGeometry() void Foam::directMappedWallPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
wallPolyPatch::calcGeometry(); wallPolyPatch::calcGeometry(pBufs);
directMappedPatchBase::clearOut(); directMappedPatchBase::clearOut();
} }
//- Initialise the patches for moving points //- Initialise the patches for moving points
void Foam::directMappedWallPolyPatch::initMovePoints(const pointField& p) void Foam::directMappedWallPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{ {
wallPolyPatch::initMovePoints(p); wallPolyPatch::initMovePoints(pBufs, p);
directMappedPatchBase::clearOut();
} }
//- Correct patches after moving points //- Correct patches after moving points
void Foam::directMappedWallPolyPatch::movePoints(const pointField& p) void Foam::directMappedWallPolyPatch::movePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{ {
wallPolyPatch::movePoints(p); wallPolyPatch::movePoints(pBufs, p);
directMappedPatchBase::clearOut(); directMappedPatchBase::clearOut();
} }
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
void Foam::directMappedWallPolyPatch::initUpdateMesh() void Foam::directMappedWallPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
wallPolyPatch::initUpdateMesh(); wallPolyPatch::initUpdateMesh(pBufs);
directMappedPatchBase::clearOut();
} }
//- Update of the patch topology //- Update of the patch topology
void Foam::directMappedWallPolyPatch::updateMesh() void Foam::directMappedWallPolyPatch::updateMesh(PstreamBuffers& pBufs)
{ {
wallPolyPatch::updateMesh(); wallPolyPatch::updateMesh(pBufs);
directMappedPatchBase::clearOut(); directMappedPatchBase::clearOut();
} }

View File

@ -65,22 +65,22 @@ class directMappedWallPolyPatch
protected: protected:
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry(); virtual void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry //- Calculate the patch geometry
virtual void calcGeometry(); virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points //- Initialise the patches for moving points
virtual void initMovePoints(const pointField&); virtual void initMovePoints(PstreamBuffers&, const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
virtual void movePoints(const pointField&); virtual void movePoints(PstreamBuffers&, const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology //- Update of the patch topology
virtual void updateMesh(); virtual void updateMesh(PstreamBuffers&);
public: public:

View File

@ -160,6 +160,9 @@ protected:
//- If the forces file has not been created create it //- If the forces file has not been created create it
void makeFile(); void makeFile();
//- Output file header information
virtual void writeFileHeader();
//- Return the effective viscous stress (laminar + turbulent). //- Return the effective viscous stress (laminar + turbulent).
tmp<volSymmTensorField> devRhoReff() const; tmp<volSymmTensorField> devRhoReff() const;
@ -176,9 +179,6 @@ protected:
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const forces&); void operator=(const forces&);
//- Output file header information
virtual void writeFileHeader();
public: public:

View File

@ -115,6 +115,7 @@ void Foam::dsmcFields::write()
word linearKEMeanName = "linearKEMean"; word linearKEMeanName = "linearKEMean";
word internalEMeanName = "internalEMean"; word internalEMeanName = "internalEMean";
word iDofMeanName = "iDofMean"; word iDofMeanName = "iDofMean";
word fDMeanName = "fDMean";
const volScalarField& rhoNMean = obr_.lookupObject<volScalarField> const volScalarField& rhoNMean = obr_.lookupObject<volScalarField>
( (
@ -146,6 +147,11 @@ void Foam::dsmcFields::write()
iDofMeanName iDofMeanName
); );
volVectorField fDMean = obr_.lookupObject<volVectorField>
(
fDMeanName
);
if (min(mag(rhoNMean)).value() > VSMALL) if (min(mag(rhoNMean)).value() > VSMALL)
{ {
Info<< "Calculating dsmcFields." << endl; Info<< "Calculating dsmcFields." << endl;
@ -173,8 +179,9 @@ void Foam::dsmcFields::write()
obr_, obr_,
IOobject::NO_READ IOobject::NO_READ
), ),
2.0/(3.0*physicoChemical::k.value()*rhoNMean) 2.0/(3.0*physicoChemical::k.value()*rhoNMean)
*(linearKEMean - 0.5*rhoMMean*(UMean & UMean)) *(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
); );
Info<< " Calculating internalT field." << endl; Info<< " Calculating internalT field." << endl;
@ -187,7 +194,7 @@ void Foam::dsmcFields::write()
obr_, obr_,
IOobject::NO_READ IOobject::NO_READ
), ),
2.0/(physicoChemical::k.value()*iDofMean)*internalEMean (2.0/physicoChemical::k.value())*(internalEMean/iDofMean)
); );
Info<< " Calculating overallT field." << endl; Info<< " Calculating overallT field." << endl;
@ -201,9 +208,36 @@ void Foam::dsmcFields::write()
IOobject::NO_READ IOobject::NO_READ
), ),
2.0/(physicoChemical::k.value()*(3.0*rhoNMean + iDofMean)) 2.0/(physicoChemical::k.value()*(3.0*rhoNMean + iDofMean))
*(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean) *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
); );
Info<< " Calculating pressure field." << endl;
volScalarField p
(
IOobject
(
"p",
obr_.time().timeName(),
obr_,
IOobject::NO_READ
),
physicoChemical::k.value()*rhoNMean*translationalT
);
const fvMesh& mesh = fDMean.mesh();
forAll(mesh.boundaryMesh(), i)
{
const polyPatch& patch = mesh.boundaryMesh()[i];
if (isA<wallPolyPatch>(patch))
{
p.boundaryField()[i] =
fDMean.boundaryField()[i]
& (patch.faceAreas()/mag(patch.faceAreas()));
}
}
Info<< " mag(UMean) max/min : " Info<< " mag(UMean) max/min : "
<< max(mag(UMean)).value() << " " << max(mag(UMean)).value() << " "
<< min(mag(UMean)).value() << endl; << min(mag(UMean)).value() << endl;
@ -220,6 +254,10 @@ void Foam::dsmcFields::write()
<< max(overallT).value() << " " << max(overallT).value() << " "
<< min(overallT).value() << endl; << min(overallT).value() << endl;
Info<< " p max/min : "
<< max(p).value() << " "
<< min(p).value() << endl;
UMean.write(); UMean.write();
translationalT.write(); translationalT.write();
@ -228,6 +266,8 @@ void Foam::dsmcFields::write()
overallT.write(); overallT.write();
p.write();
Info<< "dsmcFields written." << nl << endl; Info<< "dsmcFields written." << nl << endl;
} }
else else

View File

@ -258,6 +258,7 @@ bool Foam::cuttingPlane::walkCell
void Foam::cuttingPlane::walkCellCuts void Foam::cuttingPlane::walkCellCuts
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
const bool triangulate,
const UList<label>& edgePoint const UList<label>& edgePoint
) )
{ {
@ -293,7 +294,7 @@ void Foam::cuttingPlane::walkCellCuts
// Check for the unexpected ... // Check for the unexpected ...
if (startEdgeI == -1) if (startEdgeI == -1)
{ {
FatalErrorIn("Foam::cuttingPlane::walkCellCuts") FatalErrorIn("Foam::cuttingPlane::walkCellCuts(..)")
<< "Cannot find cut edge for cut cell " << cellI << "Cannot find cut edge for cut cell " << cellI
<< abort(FatalError); << abort(FatalError);
} }
@ -318,10 +319,18 @@ void Foam::cuttingPlane::walkCellCuts
f = f.reverseFace(); f = f.reverseFace();
} }
// the cut faces are usually quite ugly, so always triangulate // the cut faces are usually quite ugly, so optionally triangulate
label nTri = f.triangles(cutPoints, dynCutFaces); if (triangulate)
while (nTri--)
{ {
label nTri = f.triangles(cutPoints, dynCutFaces);
while (nTri--)
{
dynCutCells.append(cellI);
}
}
else
{
dynCutFaces.append(f);
dynCutCells.append(cellI); dynCutCells.append(cellI);
} }
} }
@ -346,12 +355,13 @@ Foam::cuttingPlane::cuttingPlane
( (
const plane& pln, const plane& pln,
const primitiveMesh& mesh, const primitiveMesh& mesh,
const bool triangulate,
const UList<label>& cellIdLabels const UList<label>& cellIdLabels
) )
: :
plane(pln) plane(pln)
{ {
reCut(mesh, cellIdLabels); reCut(mesh, triangulate, cellIdLabels);
} }
@ -362,6 +372,7 @@ Foam::cuttingPlane::cuttingPlane
void Foam::cuttingPlane::reCut void Foam::cuttingPlane::reCut
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
const bool triangulate,
const UList<label>& cellIdLabels const UList<label>& cellIdLabels
) )
{ {
@ -379,7 +390,7 @@ void Foam::cuttingPlane::reCut
intersectEdges(mesh, dotProducts, edgePoint); intersectEdges(mesh, dotProducts, edgePoint);
// Do topological walk around cell to find closed loop. // Do topological walk around cell to find closed loop.
walkCellCuts(mesh, edgePoint); walkCellCuts(mesh, triangulate, edgePoint);
} }

View File

@ -105,6 +105,7 @@ class cuttingPlane
void walkCellCuts void walkCellCuts
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
const bool triangulate,
const UList<label>& edgePoint const UList<label>& edgePoint
); );
@ -122,6 +123,7 @@ protected:
void reCut void reCut
( (
const primitiveMesh&, const primitiveMesh&,
const bool triangulate,
const UList<label>& cellIdLabels = UList<label>::null() const UList<label>& cellIdLabels = UList<label>::null()
); );
@ -138,6 +140,7 @@ public:
( (
const plane&, const plane&,
const primitiveMesh&, const primitiveMesh&,
const bool triangulate,
const UList<label>& cellIdLabels = UList<label>::null() const UList<label>& cellIdLabels = UList<label>::null()
); );

View File

@ -150,11 +150,11 @@ bool Foam::sampledPlane::update()
if (zoneId < 0) if (zoneId < 0)
{ {
reCut(mesh()); reCut(mesh(), true); // always triangulate. Note:Make option?
} }
else else
{ {
reCut(mesh(), mesh().cellZones()[zoneId]); reCut(mesh(), true, mesh().cellZones()[zoneId]);
} }
if (debug) if (debug)

View File

@ -97,7 +97,7 @@ class turbulentTemperatureCoupledBaffleFvPatchScalarField
public: public:
//- Runtime type information //- Runtime type information
TypeName("turbulentTemperatureCoupledBaffle"); TypeName("compressible::turbulentTemperatureCoupledBaffle");
// Constructors // Constructors

View File

@ -73,6 +73,8 @@ Smagorinsky::Smagorinsky
) )
{ {
updateSubGridScaleFields(fvc::grad(U)); updateSubGridScaleFields(fvc::grad(U));
printCoeffs();
} }

View File

@ -32,7 +32,8 @@ boundaryField
walls walls
{ {
type zeroGradient; type calculated;
value uniform 0;
} }
} }

View File

@ -32,7 +32,8 @@ boundaryField
walls walls
{ {
type zeroGradient; type calculated;
value uniform 0;
} }
} }

View File

@ -32,7 +32,8 @@ boundaryField
walls walls
{ {
type zeroGradient; type calculated;
value uniform 0;
} }
} }

View File

@ -32,7 +32,8 @@ boundaryField
walls walls
{ {
type zeroGradient; type calculated;
value uniform (0 0 0);
} }
} }

View File

@ -32,7 +32,8 @@ boundaryField
walls walls
{ {
type zeroGradient; type calculated;
value uniform 0;
} }
} }

View File

@ -32,7 +32,8 @@ boundaryField
walls walls
{ {
type zeroGradient; type calculated;
value uniform 0;
} }
} }

Some files were not shown because too many files have changed in this diff Show More