Merge commit 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen
2008-08-06 18:08:53 +02:00
13 changed files with 282 additions and 112 deletions

View File

@ -178,6 +178,11 @@ public:
{ {
return lambda_; return lambda_;
} }
const volScalarField& kappa() const
{
return kappa_;
}
}; };

View File

@ -89,13 +89,11 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validArgs.append("Neutral file"); argList::validArgs.append("Neutral file");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
fileName neuFile(args.additionalArgs()[0]); fileName neuFile(args.additionalArgs()[0]);
bool overwrite = args.options().found("overwrite");
IFstream str(neuFile); IFstream str(neuFile);
@ -300,11 +298,6 @@ int main(int argc, char *argv[])
} }
if (!overwrite)
{
runTime++;
}
polyMesh mesh polyMesh mesh
( (
IOobject IOobject

View File

@ -54,8 +54,9 @@ Description
NOTE: NOTE:
- for some reason boundary faces point inwards. I just reverse them - for some reason boundary faces point inwards. I just reverse them
always. Might use some geometric check instead. always. Might use some geometric check instead.
- marked faces might not actually be boundary faces of mesh. This is not handled - marked faces might not actually be boundary faces of mesh.
and you'll have to run without face file (-noFaceFile option) This is hopefully handled now by first constructing without boundaries
and then reconstructing with boundary faces.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -69,20 +70,40 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Find label of face.
label findFace(const primitiveMesh& mesh, const face& f)
{
const labelList& pFaces = mesh.pointFaces()[f[0]];
forAll(pFaces, i)
{
label faceI = pFaces[i];
if (mesh.faces()[faceI] == f)
{
return faceI;
}
}
FatalErrorIn("findFace(const primitiveMesh&, const face&)")
<< "Cannot find face " << f << " in mesh." << abort(FatalError);
return -1;
}
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validArgs.append("file prefix"); argList::validArgs.append("file prefix");
argList::validOptions.insert("noFaceFile", ""); argList::validOptions.insert("noFaceFile", "");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
bool readFaceFile = !args.options().found("noFaceFile"); bool readFaceFile = !args.options().found("noFaceFile");
bool overwrite = args.options().found("overwrite");
fileName prefix(args.additionalArgs()[0]); fileName prefix(args.additionalArgs()[0]);
@ -287,6 +308,36 @@ int main(int argc, char *argv[])
} }
//
// Construct mesh with default boundary only
//
autoPtr<polyMesh> meshPtr
(
new polyMesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.constant(),
runTime
),
points,
cells,
faceListList(0),
wordList(0), //boundaryPatchNames
wordList(0), //boundaryPatchTypes
"defaultFaces",
polyPatch::typeName,
wordList(0)
)
);
const polyMesh& mesh = meshPtr;
if (readFaceFile)
{
label nPatches = 0; label nPatches = 0;
// List of Foam vertices per boundary face // List of Foam vertices per boundary face
@ -295,8 +346,6 @@ int main(int argc, char *argv[])
// For each boundary faces the Foam patchID // For each boundary faces the Foam patchID
labelList boundaryPatch; labelList boundaryPatch;
if (readFaceFile)
{
// //
// read boundary faces // read boundary faces
// //
@ -366,6 +415,9 @@ int main(int argc, char *argv[])
f[2-i] = nodeToPoint[nodeI]; f[2-i] = nodeToPoint[nodeI];
} }
if (findFace(mesh, f) >= mesh.nInternalFaces())
{
boundaryFaces[faceI] = f; boundaryFaces[faceI] = f;
if (nFaceAttr > 0) if (nFaceAttr > 0)
@ -377,7 +429,8 @@ int main(int argc, char *argv[])
// Get Foam patchID and update region->patch table. // Get Foam patchID and update region->patch table.
label patchI = 0; label patchI = 0;
Map<label>::iterator patchFind = regionToPatch.find(region); Map<label>::iterator patchFind =
regionToPatch.find(region);
if (patchFind == regionToPatch.end()) if (patchFind == regionToPatch.end())
{ {
@ -406,6 +459,13 @@ int main(int argc, char *argv[])
faceI++; faceI++;
} }
} }
}
// Trim
boundaryFaces.setSize(faceI);
boundaryPatch.setSize(faceI);
// Print region to patch mapping // Print region to patch mapping
Info<< "Regions:" << endl; Info<< "Regions:" << endl;
@ -421,13 +481,10 @@ int main(int argc, char *argv[])
<< iter() << endl; << iter() << endl;
} }
Info<< endl; Info<< endl;
}
// Storage for boundary faces // Storage for boundary faces
faceListList patchFaces(nPatches); faceListList patchFaces(nPatches);
wordList patchNames(nPatches); wordList patchNames(nPatches);
forAll(patchNames, patchI) forAll(patchNames, patchI)
@ -441,8 +498,6 @@ int main(int argc, char *argv[])
wordList patchPhysicalTypes(nPatches, polyPatch::typeName); wordList patchPhysicalTypes(nPatches, polyPatch::typeName);
if (readFaceFile)
{
// Sort boundaryFaces by patch using boundaryPatch. // Sort boundaryFaces by patch using boundaryPatch.
List<DynamicList<face> > allPatchFaces(nPatches); List<DynamicList<face> > allPatchFaces(nPatches);
@ -464,14 +519,11 @@ int main(int argc, char *argv[])
} }
Info<< endl; Info<< endl;
}
if (!overwrite)
{
runTime++;
}
polyMesh mesh meshPtr.reset
(
new polyMesh
( (
IOobject IOobject
( (
@ -487,11 +539,14 @@ int main(int argc, char *argv[])
defaultFacesName, defaultFacesName,
defaultFacesType, defaultFacesType,
patchPhysicalTypes patchPhysicalTypes
)
); );
}
Info<< "Writing mesh to " << runTime.constant() << endl << endl; Info<< "Writing mesh to " << runTime.constant() << endl << endl;
mesh.write(); meshPtr().write();
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -485,6 +485,43 @@ void HashTable<T, Key, Hash>::operator=(const HashTable<T, Key, Hash>& ht)
} }
template<class T, class Key, class Hash>
bool HashTable<T, Key, Hash>::operator==(const HashTable<T, Key, Hash>& ht)
const
{
// Are all my elements in ht?
for (const_iterator iter = begin(); iter != end(); ++iter)
{
const_iterator fnd = ht.find(iter.key());
if (fnd == ht.end() || (fnd() != iter()))
{
return false;
}
}
// Are all ht elements in me?
for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
{
const_iterator fnd = find(iter.key());
if (fnd == end() || (fnd() != iter()))
{
return false;
}
}
return true;
}
template<class T, class Key, class Hash>
bool HashTable<T, Key, Hash>::operator!=(const HashTable<T, Key, Hash>& ht)
const
{
return !(operator==(ht));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -223,6 +223,15 @@ public:
//- Assignment //- Assignment
void operator=(const HashTable<T, Key, Hash>&); void operator=(const HashTable<T, Key, Hash>&);
//- Equality. Two hashtables are equal if all contents of first are
// also in second and vice versa. So does not depend on table size or
// order!
bool operator==(const HashTable<T, Key, Hash>&) const;
//- The opposite of the equality operation. Takes linear time.
bool operator!=(const HashTable<T, Key, Hash>&) const;
// STL type definitions // STL type definitions

View File

@ -570,7 +570,9 @@ public:
// region and split them. // region and split them.
autoPtr<mapPolyMesh> dupNonManifoldPoints(); autoPtr<mapPolyMesh> dupNonManifoldPoints();
//- Create baffle for every internal face where ownPatch != -1 //- Create baffle for every internal face where ownPatch != -1.
// External faces get repatched according to ownPatch (neiPatch
// should be -1 for these)
autoPtr<mapPolyMesh> createBaffles autoPtr<mapPolyMesh> createBaffles
( (
const labelList& ownPatch, const labelList& ownPatch,

View File

@ -236,6 +236,17 @@ void Foam::layerAdditionRemoval::removeCellLayer
]; ];
} }
label newNei;
if (curFaceID < mesh.nInternalFaces())
{
newNei = nei[curFaceID];
}
else
{
newNei = -1;
}
// Modify the face // Modify the face
ref.setAction ref.setAction
( (
@ -244,7 +255,7 @@ void Foam::layerAdditionRemoval::removeCellLayer
newFace, // modified face newFace, // modified face
curFaceID, // label of face being modified curFaceID, // label of face being modified
own[curFaceID], // owner own[curFaceID], // owner
nei[curFaceID], // neighbour newNei, // neighbour
false, // face flip false, // face flip
mesh.boundaryMesh().whichPatch(curFaceID),// patch for face mesh.boundaryMesh().whichPatch(curFaceID),// patch for face
false, // remove from zone false, // remove from zone

View File

@ -214,6 +214,18 @@ void Foam::removeCells::setRefinement
{ {
label patchI = exposedPatchIDs[i]; label patchI = exposedPatchIDs[i];
if (patchI < 0 || patchI >= patches.size())
{
FatalErrorIn
(
"removeCells::setRefinement(const labelList&"
", const labelList&, const labelList&, polyTopoChange&)"
) << "Invalid patch " << patchI
<< " for exposed face " << exposedFaceLabels[i] << endl
<< "Valid patches 0.." << patches.size()-1
<< abort(FatalError);
}
if (patches[patchI].coupled()) if (patches[patchI].coupled())
{ {
FatalErrorIn FatalErrorIn

View File

@ -35,6 +35,7 @@ License
namespace Foam namespace Foam
{ {
defineParticleTypeNameAndDebug(solidParticle, 0); defineParticleTypeNameAndDebug(solidParticle, 0);
defineTemplateTypeNameAndDebug(Cloud<solidParticle>, 0);
}; };
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -233,10 +233,9 @@ void Foam::searchableSphere::findLineAll
{ {
info.setSize(start.size()); info.setSize(start.size());
pointIndexHit near, far;
forAll(start, i) forAll(start, i)
{ {
pointIndexHit near, far;
findLineAll(start[i], end[i], near, far); findLineAll(start[i], end[i], near, far);
if (near.hit()) if (near.hit())
@ -260,6 +259,10 @@ void Foam::searchableSphere::findLineAll
info[i].setSize(1); info[i].setSize(1);
info[i][0] = far; info[i][0] = far;
} }
else
{
info[i].clear();
}
} }
} }
} }

View File

@ -206,10 +206,7 @@ void Foam::fieldToCell::applyToSet
} }
else if (fieldObject.headerClassName() == "volScalarField") else if (fieldObject.headerClassName() == "volScalarField")
{ {
IFstream str IFstream str(fieldObject.filePath());
(
mesh().time().path()/mesh().time().timeName()/fieldName_
);
// Read dictionary // Read dictionary
dictionary fieldDict(str); dictionary fieldDict(str);
@ -220,10 +217,7 @@ void Foam::fieldToCell::applyToSet
} }
else if (fieldObject.headerClassName() == "volVectorField") else if (fieldObject.headerClassName() == "volVectorField")
{ {
IFstream str IFstream str(fieldObject.filePath());
(
mesh().time().path()/mesh().time().timeName()/fieldName_
);
// Read dictionary // Read dictionary
dictionary fieldDict(str); dictionary fieldDict(str);

View File

@ -37,31 +37,23 @@ autoPtr<Foam::pdf> Foam::pdf::New
Random& rndGen Random& rndGen
) )
{ {
word pdfType word pdfType(dict.lookup("pdfType"));
(
dict.lookup("pdfType")
);
Info << "Selecting pdfType " Info<< "Selecting pdfType " << pdfType << endl;
<< pdfType << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(pdfType); dictionaryConstructorTablePtr_->find(pdfType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (cstrIter == dictionaryConstructorTablePtr_->end())
{ {
FatalError FatalErrorIn("pdf::New(const dictionary&, Random&)")
<< "pdf::New(const dictionary&, Random&) : " << endl << "unknown pdf type " << pdfType << endl << endl
<< " unknown pdfType type " << "Valid pdf types are :" << endl
<< pdfType << dictionaryConstructorTablePtr_->toc()
<< ", constructor not in hash table" << endl << endl << exit(FatalError);
<< " Valid pdf types are :" << endl;
Info<< dictionaryConstructorTablePtr_->toc() << abort(FatalError);
} }
return autoPtr<pdf>(cstrIter()(dict, rndGen)); return autoPtr<pdf>(cstrIter()(dict, rndGen));
//return autoPtr<pdf>(new pdf);
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -44,4 +44,60 @@ timePrecision 6;
runTimeModifiable yes; runTimeModifiable yes;
functions
(
//forces
//{
// type forces;
// functionObjectLibs ("libforces.so");
//
// // Patches to sample
// patches (WALL10);
// // Name of fields
// pName p;
// Uname U;
// // Dump to file
// log true;
// // Density
// rhoInf 1;
// // Centre of rotation
// CofR (0 0 0);
//}
forces
{
type forceCoeffs;
functionObjectLibs ("libforces.so");
// Patches to sample
patches (WALL10);
// Name of fields
pName p;
Uname U;
// Dump to file
log true;
// Density
rhoInf 1;
// Centre of rotation
CofR (0 0 0);
// Direction for lift
liftDir (-0.239733 0.970839 0);
// Direction for drag
dragDir ( 0.970839 0.239733 0);
// Pitching axis
pitchAxis (0 0 1);
magUInf 618.022;
lRef 1.0;
Aref 1.0;
}
);
// ************************************************************************* // // ************************************************************************* //