Merge branch 'master' into dicts

This commit is contained in:
andy
2010-10-14 10:10:04 +01:00
60 changed files with 686 additions and 609 deletions

View File

@ -280,6 +280,7 @@ public:
const Xfer<pointField>& points,
const cellShapeList& shapes,
const faceListList& boundaryFaces,
const wordList& boundaryPatchNames,
const PtrList<dictionary>& boundaryDicts,
const word& defaultBoundaryPatchName,
const word& defaultBoundaryPatchType,

View File

@ -698,6 +698,7 @@ Foam::polyMesh::polyMesh
const Xfer<pointField>& points,
const cellShapeList& cellsAsShapes,
const faceListList& boundaryFaces,
const wordList& boundaryPatchNames,
const PtrList<dictionary>& boundaryDicts,
const word& defaultBoundaryPatchName,
const word& defaultBoundaryPatchType,
@ -832,12 +833,6 @@ Foam::polyMesh::polyMesh
// Remove all of the old mesh files if they exist
removeFiles(instance());
wordList boundaryPatchNames(boundaryDicts.size());
forAll(boundaryDicts, patchI)
{
boundaryDicts[patchI].lookup("name") >> boundaryPatchNames[patchI];
}
// Calculate faces and cells
labelList patchSizes;
labelList patchStarts;
@ -858,7 +853,7 @@ Foam::polyMesh::polyMesh
// Warning: Patches can only be added once the face list is
// completed, as they hold a subList of the face list
forAll(boundaryFaces, patchI)
forAll(boundaryDicts, patchI)
{
dictionary patchDict(boundaryDicts[patchI]);

View File

@ -91,44 +91,58 @@ void Foam::cyclicPolyPatch::calcTransforms()
// Half0
const cyclicPolyPatch& half0 = *this;
const pointField& half0Ctrs = half0.faceCentres();
if (debug)
{
fileName casePath(boundaryMesh().mesh().time().path());
fileName nm0(casePath/name()+"_faces.obj");
Pout<< "cyclicPolyPatch::calcTransforms : Writing " << name()
<< " faces to OBJ file " << nm0 << endl;
writeOBJ(nm0, half0, half0.points());
}
vectorField half0Areas(half0.size());
forAll(half0, facei)
{
half0Areas[facei] = half0[facei].normal(half0.points());
}
// Half1
const cyclicPolyPatch& half1 = neighbPatch();
const pointField& half1Ctrs = half1.faceCentres();
// Dump halves
if (debug)
vectorField half1Areas(half1.size());
forAll(half1, facei)
{
fileName casePath(boundaryMesh().mesh().time().path());
half1Areas[facei] = half1[facei].normal(half1.points());
}
calcTransforms
(
half0,
half0.faceCentres(),
half0Areas,
half1.faceCentres(),
half1Areas
);
}
}
void Foam::cyclicPolyPatch::calcTransforms
(
const primitivePatch& half0,
const UList<point>& half0Ctrs,
const UList<point>& half0Areas,
const UList<point>& half1Ctrs,
const UList<point>& half1Areas
)
{
if (debug && owner())
{
fileName casePath(boundaryMesh().mesh().time().path());
{
fileName nm0(casePath/name()+"_faces.obj");
Pout<< "cyclicPolyPatch::calcTransforms : Writing " << name()
<< " faces to OBJ file " << nm0 << endl;
writeOBJ(nm0, half0, half0.points());
}
const cyclicPolyPatch& half1 = neighbPatch();
{
fileName nm1(casePath/half1.name()+"_faces.obj");
Pout<< "cyclicPolyPatch::calcTransforms : Writing " << half1.name()
<< " faces to OBJ file " << nm1 << endl;
writeOBJ(nm1, half1, half1.points());
}
{
OFstream str(casePath/name()+"_to_" + half1.name() + ".obj");
label vertI = 0;
Pout<< "cyclicPolyPatch::calcTransforms :"
@ -145,35 +159,10 @@ void Foam::cyclicPolyPatch::calcTransforms()
str << "l " << vertI-1 << ' ' << vertI << nl;
}
}
vectorField half1Areas(half1.size());
forAll(half1, facei)
{
half1Areas[facei] = half1[facei].normal(half1.points());
}
calcTransforms
(
half0,
half0Ctrs,
half0Areas,
half1Ctrs,
half1Areas
);
}
}
void Foam::cyclicPolyPatch::calcTransforms
(
const primitivePatch& half0,
const UList<point>& half0Ctrs,
const UList<point>& half0Areas,
const UList<point>& half1Ctrs,
const UList<point>& half1Areas
)
{
if (half0Ctrs.size() != half1Ctrs.size())
{
FatalErrorIn

View File

@ -25,7 +25,6 @@ License
#include "preservePatchTypes.H"
#include "polyBoundaryMeshEntries.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -35,14 +34,16 @@ void Foam::preservePatchTypes
const word& meshInstance,
const fileName& meshDir,
const wordList& patchNames,
wordList& patchTypes,
PtrList<dictionary>& patchDicts,
const word& defaultFacesName,
word& defaultFacesType,
wordList& patchPhysicalTypes
word& defaultFacesType
)
{
patchDicts.setSize(patchNames.size());
dictionary patchDictionary;
// Read boundary file as single dictionary
{
IOobject patchEntriesHeader
(
@ -67,35 +68,27 @@ void Foam::preservePatchTypes
}
}
if (patchDictionary.size())
forAll(patchNames, patchi)
{
forAll(patchNames, patchi)
{
if (patchDictionary.found(patchNames[patchi]))
{
const dictionary& patchDict =
patchDictionary.subDict(patchNames[patchi]);
patchDict.lookup("type") >> patchTypes[patchi];
patchDict.readIfPresent("geometricType", patchTypes[patchi]);
patchDict.readIfPresent
(
"physicalType",
patchPhysicalTypes[patchi]
);
}
}
if (patchDictionary.found(defaultFacesName))
if (patchDictionary.found(patchNames[patchi]))
{
const dictionary& patchDict =
patchDictionary.subDict(defaultFacesName);
patchDictionary.subDict(patchNames[patchi]);
patchDict.readIfPresent("geometricType", defaultFacesType);
patchDicts.set(patchi, patchDict.clone());
patchDicts[patchi].remove("nFaces");
patchDicts[patchi].remove("startFace");
}
}
if (patchDictionary.found(defaultFacesName))
{
const dictionary& patchDict =
patchDictionary.subDict(defaultFacesName);
patchDict.readIfPresent("geometricType", defaultFacesType);
}
Info<< nl << "Default patch type set to " << defaultFacesType << endl;
}

View File

@ -37,6 +37,7 @@ SourceFiles
#include "fileName.H"
#include "wordList.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,10 +53,9 @@ void preservePatchTypes
const word& meshInstance,
const fileName& meshDir,
const wordList& patchNames,
wordList& patchTypes,
PtrList<dictionary>& patchDicts,
const word& defaultFacesName,
word& defaultFacesType,
wordList& patchPhysicalTypes
word& defaultFacesType
);
} // End namespace Foam

View File

@ -272,10 +272,10 @@ const Foam::point& Foam::plane::refPoint() const
}
// Return coefficcients for plane equation: ax + by + cz + d = 0
Foam::scalarList Foam::plane::planeCoeffs() const
// Return coefficients for plane equation: ax + by + cz + d = 0
Foam::FixedList<Foam::scalar, 4> Foam::plane::planeCoeffs() const
{
scalarList C(4);
FixedList<scalar, 4> C(4);
scalar magX = mag(unitVector_.x());
scalar magY = mag(unitVector_.y());
@ -291,8 +291,8 @@ Foam::scalarList Foam::plane::planeCoeffs() const
}
else
{
C[0] = 0;
C[1] = 0;
C[0] = unitVector_.x()/unitVector_.z();
C[1] = unitVector_.y()/unitVector_.z();
C[2] = 1;
}
}
@ -300,14 +300,14 @@ Foam::scalarList Foam::plane::planeCoeffs() const
{
if (magY > magZ)
{
C[0] = 0;
C[0] = unitVector_.x()/unitVector_.y();
C[1] = 1;
C[2] = unitVector_.z()/unitVector_.y();
}
else
{
C[0] = 0;
C[1] = 0;
C[0] = unitVector_.x()/unitVector_.z();
C[1] = unitVector_.y()/unitVector_.z();
C[2] = 1;
}
}
@ -422,19 +422,18 @@ Foam::point Foam::plane::planePlaneIntersect
const plane& plane3
) const
{
List<scalarList> pcs(3);
pcs[0]= planeCoeffs();
pcs[1]= plane2.planeCoeffs();
pcs[2]= plane3.planeCoeffs();
FixedList<scalar, 4> coeffs1(planeCoeffs());
FixedList<scalar, 4> coeffs2(plane2.planeCoeffs());
FixedList<scalar, 4> coeffs3(plane3.planeCoeffs());
tensor a
(
pcs[0][0],pcs[0][1],pcs[0][2],
pcs[1][0],pcs[1][1],pcs[1][2],
pcs[2][0],pcs[2][1],pcs[2][2]
coeffs1[0],coeffs1[1],coeffs1[2],
coeffs2[0],coeffs2[1],coeffs2[2],
coeffs3[0],coeffs3[1],coeffs3[2]
);
vector b(pcs[0][3],pcs[1][3],pcs[2][3]);
vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
return (inv(a) & (-b));
}

View File

@ -149,7 +149,7 @@ public:
//- Return coefficients for the
// plane equation: ax + by + cz + d = 0
scalarList planeCoeffs() const;
FixedList<scalar, 4> planeCoeffs() const;
//- Return nearest point in the plane for the given point
point nearestPoint(const point& p) const;

View File

@ -412,6 +412,8 @@ Foam::meshReader::polyBoundaryPatches(const polyMesh& mesh)
List<polyPatch*> p(nPatches);
// All patch dictionaries
PtrList<dictionary> patchDicts(patchNames_.size());
// Default boundary patch types
word defaultFacesType(emptyPolyPatch::typeName);
@ -422,20 +424,37 @@ Foam::meshReader::polyBoundaryPatches(const polyMesh& mesh)
mesh.instance(),
mesh.meshDir(),
patchNames_,
patchTypes_,
patchDicts,
"defaultFaces",
defaultFacesType,
patchPhysicalTypes_
defaultFacesType
);
forAll(patchDicts, patchI)
{
if (!patchDicts.set(patchI))
{
patchDicts.set(patchI, new dictionary());
}
dictionary& patchDict = patchDicts[patchI];
// add but not overwrite type
patchDict.add("type", patchTypes_[patchI], false);
if (patchPhysicalTypes_.size() && patchPhysicalTypes_[patchI].size())
{
patchDict.add("startFace", patchPhysicalTypes_[patchI], false);
}
// overwrite sizes and start
patchDict.add("nFaces", patchSizes_[patchI], true);
patchDict.add("startFace", patchStarts_[patchI], true);
}
forAll(patchStarts_, patchI)
{
p[patchI] = polyPatch::New
(
patchTypes_[patchI],
patchNames_[patchI],
patchSizes_[patchI],
patchStarts_[patchI],
patchDicts[patchI],
patchI,
mesh.boundaryMesh()
).ptr();

View File

@ -34,14 +34,13 @@ scalar meanMeshCoNum = 0.0;
if (mesh.nInternalFaces())
{
surfaceScalarField SfUfbyDelta =
mesh.surfaceInterpolation::deltaCoeffs()*mag(mesh.phi());
scalarField sumPhi =
fvc::surfaceSum(mag(mesh.phi()))().internalField();
meshCoNum = max(SfUfbyDelta/mesh.magSf())
.value()*runTime.deltaTValue();
meshCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
meanMeshCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf()))
.value()*runTime.deltaTValue();
meanMeshCoNum =
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
}
Info<< "Mesh Courant Number mean: " << meanMeshCoNum

View File

@ -38,10 +38,10 @@ if (mesh.nInternalFaces())
fvc::surfaceSum(mag(phi))().internalField()
/rho.internalField();
CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaT().value();
CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
meanCoNum =
0.5*(gSum(sumPhi)/sum(mesh.V().field()))*runTime.deltaT().value();
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
}
Info<< "Courant Number mean: " << meanCoNum

View File

@ -37,10 +37,10 @@ if (mesh.nInternalFaces())
scalarField sumPhi =
fvc::surfaceSum(mag(phi))().internalField();
CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaT().value();
CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
meanCoNum =
0.5*(gSum(sumPhi)/sum(mesh.V().field()))*runTime.deltaT().value();
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
}
Info<< "Courant Number mean: " << meanCoNum

View File

@ -260,7 +260,7 @@ void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
allValues
);
newValues = this->patch().patchSlice(allValues);
newValues.transfer(allValues);
break;
}

View File

@ -198,7 +198,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
distMap.constructMap(),
allUValues
);
newUValues = patch().patchSlice(allUValues);
newUValues.transfer(allUValues);
mapDistribute::distribute
(
@ -209,7 +209,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
distMap.constructMap(),
allPhiValues
);
newPhiValues = patch().patchSlice(allPhiValues);
newPhiValues.transfer(allPhiValues);
break;
}

View File

@ -89,7 +89,6 @@ Foam::PtrList<Foam::dictionary> Foam::blockMesh::patchDicts() const
patchTopologies[patchI].write(os);
IStringStream is(os.str());
patchDicts.set(patchI, new dictionary(is));
patchDicts[patchI].set("name", patchTopologies[patchI].name());
}
return patchDicts;
}
@ -134,12 +133,12 @@ const Foam::faceListList& Foam::blockMesh::patches() const
}
//Foam::wordList Foam::blockMesh::patchNames() const
//{
// return topology().boundaryMesh().names();
//}
//
//
Foam::wordList Foam::blockMesh::patchNames() const
{
return topology().boundaryMesh().names();
}
//Foam::wordList Foam::blockMesh::patchTypes() const
//{
// return topology().boundaryMesh().types();

View File

@ -121,6 +121,7 @@ class blockMesh
bool readBoundary
(
const dictionary& meshDescription,
wordList& patchNames,
faceListList& tmpBlocksPatches,
PtrList<dictionary>& patchDicts
);
@ -185,8 +186,8 @@ public:
//- Get patch information from the topology mesh
PtrList<dictionary> patchDicts() const;
// wordList patchNames() const;
//
wordList patchNames() const;
// wordList patchTypes() const;
//
// wordList patchPhysicalTypes() const;

View File

@ -189,6 +189,7 @@ bool Foam::blockMesh::readPatches
bool Foam::blockMesh::readBoundary
(
const dictionary& meshDescription,
wordList& patchNames,
faceListList& tmpBlocksPatches,
PtrList<dictionary>& patchDicts
)
@ -201,6 +202,7 @@ bool Foam::blockMesh::readBoundary
meshDescription.lookup("boundary")
);
patchNames.setSize(patchesInfo.size());
tmpBlocksPatches.setSize(patchesInfo.size());
patchDicts.setSize(patchesInfo.size());
@ -215,9 +217,9 @@ bool Foam::blockMesh::readBoundary
<< " valid dictionary." << exit(FatalIOError);
}
// Construct dictionary and add name
patchNames[patchI] = patchInfo.keyword();
// Construct dictionary
patchDicts.set(patchI, new dictionary(patchInfo.dict()));
patchDicts[patchI].set("name", patchInfo.keyword());
// Read block faces
patchDicts[patchI].lookup("faces") >> tmpBlocksPatches[patchI];
@ -472,7 +474,8 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
Info<< nl << "Reading physicalType from existing boundary file" << endl;
wordList patchPhysicalTypes(tmpBlocksPatches.size());
PtrList<dictionary> patchDicts(patchNames.size());
word defaultFacesType;
preservePatchTypes
(
@ -480,31 +483,29 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
meshDescription.time().constant(),
polyMesh::meshSubDir,
patchNames,
patchTypes,
patchDicts,
defaultPatchName,
defaultPatchType,
patchPhysicalTypes
defaultPatchType
);
// Convert into dictionary
PtrList<dictionary> patchDicts(patchNames.size());
// Add cyclic info (might not be present from older file)
forAll(patchDicts, patchI)
{
patchDicts.set(patchI, new dictionary());
patchDicts[patchI].set("name", patchNames[patchI]);
patchDicts[patchI].set("type", patchTypes[patchI]);
if (!patchDicts.set(patchI))
{
patchDicts.set(patchI, new dictionary());
}
dictionary& dict = patchDicts[patchI];
// Add but not override type
dict.add("type", patchTypes[patchI], false);
// Override neighbourpatch name
if (nbrPatchNames[patchI] != word::null)
{
patchDicts[patchI].set("neighbourPatch", nbrPatchNames[patchI]);
}
if (patchPhysicalTypes[patchI] != word::null)
{
patchDicts[patchI].set
(
"physicalType",
patchPhysicalTypes[patchI]
);
dict.set("neighbourPatch", nbrPatchNames[patchI]);
}
}
@ -523,6 +524,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
xferCopy(blockPointField_), // copy these points, do NOT move
tmpBlockCells,
tmpBlocksPatches,
patchNames,
patchDicts,
defaultPatchName,
defaultPatchType
@ -530,12 +532,14 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
}
else if (meshDescription.found("boundary"))
{
wordList patchNames;
faceListList tmpBlocksPatches;
PtrList<dictionary> patchDicts;
topologyOK = topologyOK && readBoundary
(
meshDescription,
patchNames,
tmpBlocksPatches,
patchDicts
);
@ -553,6 +557,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
cellShapeList tmpBlockCells(blocks.size());
createCellShapes(tmpBlockCells);
// Extract
blockMeshPtr = new polyMesh
(
@ -568,6 +573,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
xferCopy(blockPointField_), // copy these points, do NOT move
tmpBlockCells,
tmpBlocksPatches,
patchNames,
patchDicts,
defaultPatchName,
defaultPatchType

View File

@ -163,7 +163,7 @@ Foam::label Foam::probes::prepare()
if (debug)
{
Info<< "open probe stream: " << sPtr->name() << endl;
Info<< "open probe stream: " << sPtr->name() << endl;
}
probeFilePtrs_.insert(fieldName, sPtr);