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

This commit is contained in:
andy 2012-02-01 16:34:53 +00:00
commit c603f1602b
13 changed files with 455 additions and 31 deletions

View File

@ -29,7 +29,7 @@
rhoPhi = phiAlpha*(rho1 - rho2) + phi*rho2;
}
Info<< "Liquid phase volume fraction = "
Info<< "Phase-1 volume fraction = "
<< alpha1.weightedAverage(mesh.Vsc()).value()
<< " Min(alpha1) = " << min(alpha1).value()
<< " Max(alpha1) = " << max(alpha1).value()

View File

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

View File

View File

@ -0,0 +1,14 @@
#include "tensor2D.H"
#include "IOstreams.H"
using namespace Foam;
int main()
{
vector2D v1(1, 2), v2(3, 4);
tensor2D t = v1*v2;
Info<< "v1(1, 2)*v2(3, 4) = " << t << endl;
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,6 +36,8 @@ void Foam::processorLduInterface::send
const UList<Type>& f
) const
{
label nBytes = f.byteSize();
if (commsType == Pstream::blocking || commsType == Pstream::scheduled)
{
OPstream::write
@ -43,32 +45,32 @@ void Foam::processorLduInterface::send
commsType,
neighbProcNo(),
reinterpret_cast<const char*>(f.begin()),
f.byteSize(),
nBytes,
tag()
);
}
else if (commsType == Pstream::nonBlocking)
{
resizeBuf(receiveBuf_, f.size()*sizeof(Type));
resizeBuf(receiveBuf_, nBytes);
IPstream::read
(
commsType,
neighbProcNo(),
receiveBuf_.begin(),
receiveBuf_.size(),
nBytes,
tag()
);
resizeBuf(sendBuf_, f.byteSize());
memcpy(sendBuf_.begin(), f.begin(), f.byteSize());
resizeBuf(sendBuf_, nBytes);
memcpy(sendBuf_.begin(), f.begin(), nBytes);
OPstream::write
(
commsType,
neighbProcNo(),
sendBuf_.begin(),
f.byteSize(),
nBytes,
tag()
);
}
@ -172,7 +174,7 @@ void Foam::processorLduInterface::compressedSend
commsType,
neighbProcNo(),
receiveBuf_.begin(),
receiveBuf_.size(),
nBytes,
tag()
);

View File

@ -28,6 +28,24 @@ Description
Storage and named access for the indices of a tet which is part of
the decomposition of a cell.
Tets are designated by
- cell (of course)
- face on cell
- three points on face (faceBasePt, facePtA, facePtB)
When constructing from a mesh and index in the face (tetPtI):
- faceBasePt is the mesh.tetBasePtIs() base point
- facePtA is tetPtI away from faceBasePt
- facePtB is next one after/before facePtA
e.g.:
+---+
|2 /|
| / |
|/ 1| <- tetPt (so 1 for first triangle, 2 for second)
+---+
^
faceBasePt
SourceFiles
tetIndicesI.H
tetIndices.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -513,6 +513,14 @@ public:
};
template<class Cmpt>
class outerProduct<Vector2D<Cmpt>, Vector2D<Cmpt> >
{
public:
typedef Tensor2D<Cmpt> type;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -45,11 +45,7 @@ void processorFvPatchField<scalar>::initInterfaceMatrixUpdate
{
this->patch().patchInternalField(psiInternal, scalarSendBuf_);
if
(
Pstream::defaultCommsType == Pstream::nonBlocking
&& !Pstream::floatTransfer
)
if (commsType == Pstream::nonBlocking && !Pstream::floatTransfer)
{
// Fast path.
if (debug && !this->ready())
@ -122,6 +118,7 @@ void processorFvPatchField<scalar>::updateInterfaceMatrix
{
UPstream::waitRequest(outstandingRecvRequest_);
}
// Recv finished so assume sending finished as well.
outstandingSendRequest_ = -1;
outstandingRecvRequest_ = -1;

View File

@ -46,7 +46,8 @@ temperatureThermoBaffleFvPatchScalarField
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(p, iF),
owner_(false),
baffle_(),
solidThermoType_("undefined")
solidThermoType_("undefined"),
dict_(dictionary::null)
{}
@ -68,7 +69,8 @@ temperatureThermoBaffleFvPatchScalarField
),
owner_(ptf.owner_),
baffle_(ptf.baffle_),
solidThermoType_(ptf.solidThermoType_)
solidThermoType_(ptf.solidThermoType_),
dict_(ptf.dict_)
{}
@ -83,7 +85,8 @@ temperatureThermoBaffleFvPatchScalarField
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(p, iF, dict),
owner_(false),
baffle_(),
solidThermoType_()
solidThermoType_(),
dict_(dict)
{
if (!isA<mappedPatchBase>(patch().patch()))
{
@ -133,7 +136,8 @@ temperatureThermoBaffleFvPatchScalarField
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(ptf, iF),
owner_(ptf.owner_),
baffle_(ptf.baffle_),
solidThermoType_(ptf.solidThermoType_)
solidThermoType_(ptf.solidThermoType_),
dict_(ptf.dict_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -188,30 +192,33 @@ void temperatureThermoBaffleFvPatchScalarField::write(Ostream& os) const
if (thisMesh.name() == polyMesh::defaultRegion && owner_)
{
os.writeKeyword("thermoBaffleModel") << baffle_->modelName()
word thermoModel = dict_.lookup("thermoBaffleModel");
os.writeKeyword("thermoBaffleModel")
<< thermoModel
<< token::END_STATEMENT << nl;
os.writeKeyword("regionName") << baffle_->regionMesh().name()
word regionName = dict_.lookup("regionName");
os.writeKeyword("regionName") << regionName
<< token::END_STATEMENT << nl;
os.writeKeyword("infoOutput") << baffle_->infoOutput()
bool infoOutput = readBool(dict_.lookup("infoOutput"));
os.writeKeyword("infoOutput") << infoOutput
<< token::END_STATEMENT << nl;
os.writeKeyword("active") << baffle_->active()
bool active = readBool(dict_.lookup("active"));
os.writeKeyword("active") << active
<< token::END_STATEMENT << nl;
os.writeKeyword(word(baffle_->modelName() + "coeffs"));
os << baffle_->coeffs() << nl;
os.writeKeyword(word(thermoModel + "Coeffs"));
os << dict_.subDict(thermoModel + "Coeffs") << nl;
os.writeKeyword("thermoType") << solidThermoType_
<< token::END_STATEMENT << nl;
os.writeKeyword(word(solidThermoType_ + "Coeffs")) << nl;
os.writeKeyword(word(solidThermoType_ + "Coeffs"));
os << indent << '{' << nl
<< indent << baffle_->thermo() << nl
<< indent << '}' << nl;
os << dict_.subDict(solidThermoType_ + "Coeffs") << nl;
}
}

View File

@ -112,6 +112,9 @@ class temperatureThermoBaffleFvPatchScalarField
//- Solid thermo type
word solidThermoType_;
//- Dictionary
dictionary dict_;
public:

View File

@ -11,7 +11,7 @@ sampledSet/polyLine/polyLineSet.C
sampledSet/face/faceOnlySet.C
sampledSet/midPoint/midPointSet.C
sampledSet/midPointAndFace/midPointAndFaceSet.C
/* sampledSet/patchSeed/patchSeedSet.C */
sampledSet/patchSeed/patchSeedSet.C
sampledSet/sampledSet/sampledSet.C
sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSets/sampledSetsGrouping.C

View File

@ -0,0 +1,239 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "patchSeedSet.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "treeBoundBox.H"
#include "treeDataFace.H"
#include "Time.H"
#include "meshTools.H"
//#include "Random.H"
// For 'facePoint' helper function only
#include "mappedPatchBase.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(patchSeedSet, 0);
addToRunTimeSelectionTable(sampledSet, patchSeedSet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::patchSeedSet::calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
)
{
if (debug)
{
Info<< "patchSeedSet : sampling on patches :" << endl;
}
// Construct search tree for all patch faces.
label sz = 0;
forAllConstIter(labelHashSet, patchSet_, iter)
{
const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
sz += pp.size();
if (debug)
{
Info<< " " << pp.name() << " size " << pp.size() << endl;
}
}
labelList patchFaces(sz);
sz = 0;
forAllConstIter(labelHashSet, patchSet_, iter)
{
const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
forAll(pp, i)
{
patchFaces[sz++] = pp.start()+i;
}
}
label totalSize = returnReduce(sz, sumOp<label>());
// Shuffle and truncate if in random mode
if (maxPoints_ < totalSize)
{
// Check what fraction of maxPoints_ I need to generate locally.
label myMaxPoints = label(scalar(sz)/totalSize*maxPoints_);
rndGenPtr_.reset(new Random(123456));
Random& rndGen = rndGenPtr_();
labelList subset = identity(sz);
for (label iter = 0; iter < 4; iter++)
{
forAll(subset, i)
{
label j = rndGen.integer(0, subset.size()-1);
Swap(subset[i], subset[j]);
}
}
// Truncate
subset.setSize(myMaxPoints);
// Subset patchFaces
patchFaces = UIndirectList<label>(patchFaces, subset)();
if (debug)
{
Pout<< "In random mode : selected " << patchFaces
<< " faces out of " << sz << endl;
}
}
// Get points on patchFaces.
globalIndex globalSampleNumbers(patchFaces.size());
samplingPts.setCapacity(patchFaces.size());
samplingCells.setCapacity(patchFaces.size());
samplingFaces.setCapacity(patchFaces.size());
samplingSegments.setCapacity(patchFaces.size());
samplingCurveDist.setCapacity(patchFaces.size());
// For calculation of min-decomp tet base points
(void)mesh().tetBasePtIs();
forAll(patchFaces, i)
{
label faceI = patchFaces[i];
pointIndexHit info = mappedPatchBase::facePoint
(
mesh(),
faceI,
polyMesh::FACEDIAGTETS
);
label cellI = mesh().faceOwner()[faceI];
if (info.hit())
{
// Move the point into the cell
const point& cc = mesh().cellCentres()[cellI];
samplingPts.append
(
info.hitPoint() + 1E-1*(cc-info.hitPoint())
);
}
else
{
samplingPts.append(info.rawPoint());
}
samplingCells.append(cellI);
samplingFaces.append(faceI);
samplingSegments.append(0);
samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
}
}
void Foam::patchSeedSet::genSamples()
{
// Storage for sample points
DynamicList<point> samplingPts;
DynamicList<label> samplingCells;
DynamicList<label> samplingFaces;
DynamicList<label> samplingSegments;
DynamicList<scalar> samplingCurveDist;
calcSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
);
samplingPts.shrink();
samplingCells.shrink();
samplingFaces.shrink();
samplingSegments.shrink();
samplingCurveDist.shrink();
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchSeedSet::patchSeedSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampledSet(name, mesh, searchEngine, dict),
patchSet_
(
mesh.boundaryMesh().patchSet
(
wordReList(dict.lookup("patches"))
)
),
//searchDist_(readScalar(dict.lookup("maxDistance"))),
//offsetDist_(readScalar(dict.lookup("offsetDist"))),
maxPoints_(readLabel(dict.lookup("maxPoints")))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchSeedSet::~patchSeedSet()
{}
// ************************************************************************* //

View File

@ -0,0 +1,133 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::patchSeedSet
Description
Initialises points on or just off patch
SourceFiles
patchSeedSet.C
\*---------------------------------------------------------------------------*/
#ifndef patchSeedSet_H
#define patchSeedSet_H
#include "sampledSet.H"
#include "DynamicList.H"
#include "HashSet.H"
#include "Random.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class patchSeedSet Declaration
\*---------------------------------------------------------------------------*/
class patchSeedSet
:
public sampledSet
{
// Private data
//- Patches to sample
const labelHashSet patchSet_;
// //- Maximum distance to look for nearest
// const scalar searchDist_;
//
// //- Offset distance
// const scalar offsetDist_;
//- Maximum number of patch faces to seed
const label maxPoints_;
//- Random number generator (if maxPoints < num patch faces)
autoPtr<Random> rndGenPtr_;
// Private Member Functions
//- Samples all points in sampleCoords.
void calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
);
//- Uses calcSamples to obtain samples. Copies them into *this.
void genSamples();
public:
//- Runtime type information
TypeName("patchSeed");
// Constructors
// //- Construct from components
// patchSeedSet
// (
// const word& name,
// const polyMesh& mesh,
// meshSearch& searchEngine,
// const word& axis,
// const List<point>& sampleCoords,
// const labelHashSet& patchSet,
// const scalar searchDist
// );
//- Construct from dictionary
patchSeedSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
//- Destructor
virtual ~patchSeedSet();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //