From ba5ecbaf67ca94b633450d8f3d9e281c50b1b4c3 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 18 Aug 2009 12:20:14 +0100 Subject: [PATCH 01/30] removed reference to libfoamUtil in error message --- src/genericPatchFields/genericFvPatchField/genericFvPatchField.C | 1 - 1 file changed, 1 deletion(-) diff --git a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C index 058021f612..ec4c323a91 100644 --- a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C +++ b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C @@ -79,7 +79,6 @@ Foam::genericFvPatchField::genericFvPatchField << " (Actual type " << actualTypeName_ << ")" << nl << "\n Please add the 'value' entry to the write function " "of the user-defined boundary-condition\n" - " or link the boundary-condition into libfoamUtil.so" << exit(FatalIOError); } From 0d343e4d890c150119f477c8252037b4a6fc91d6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 18 Aug 2009 22:10:41 +0100 Subject: [PATCH 02/30] indexing error --- .../polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 0b9c08b39e..265b61cc4b 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -1305,7 +1305,7 @@ bool Foam::cyclicPolyPatch::order { label baffleI = 0; - forAll(*this, faceI) + forAll(pp, faceI) { const face& f = pp.localFaces()[faceI]; const labelList& pFaces = pp.pointFaces()[f[0]]; From ddfe6c39e956ecf409f0240b6c08b2a911e972cd Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 18 Aug 2009 22:12:06 +0100 Subject: [PATCH 03/30] user overrideable tolerances --- .../mesh/manipulation/stitchMesh/stitchMesh.C | 23 +++++ .../slidingInterface/coupleSlidingInterface.C | 2 +- .../slidingInterface/slidingInterface.C | 87 ++++++++++++++++++- .../slidingInterface/slidingInterface.H | 44 ++++++++-- .../slidingInterfaceProjectPoints.C | 17 ++-- 5 files changed, 152 insertions(+), 21 deletions(-) diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index 859ddf20a2..a5adac74e8 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -105,6 +105,8 @@ int main(int argc, char *argv[]) Foam::argList::validOptions.insert("overwrite", ""); + Foam::argList::validOptions.insert("toleranceDict", "file with tolerances"); + # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); @@ -168,6 +170,22 @@ int main(int argc, char *argv[]) << "If this is not the case use the -partial option" << nl << endl; } + // set up the tolerances for the sliding mesh + dictionary slidingTolerances; + if (args.options().found("toleranceDict")) + { + IOdictionary toleranceFile( + IOobject( + args.options()["toleranceDict"], + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + slidingTolerances += toleranceFile; + } + // Check for non-empty master and slave patches checkPatch(mesh.boundaryMesh(), masterPatchName); checkPatch(mesh.boundaryMesh(), slavePatchName); @@ -320,6 +338,11 @@ int main(int argc, char *argv[]) true // couple/decouple mode ) ); + static_cast(stitcher[0]).setTolerances + ( + slidingTolerances, + true + ); } diff --git a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C index 18d1170c00..f90e9a036b 100644 --- a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C @@ -43,7 +43,7 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::scalar Foam::slidingInterface::edgeCoPlanarTol_ = 0.8; +const Foam::scalar Foam::slidingInterface::edgeCoPlanarTolDefault_ = 0.8; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/dynamicMesh/slidingInterface/slidingInterface.C b/src/dynamicMesh/slidingInterface/slidingInterface.C index 80d68749e8..316dd389b6 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterface.C +++ b/src/dynamicMesh/slidingInterface/slidingInterface.C @@ -27,10 +27,8 @@ License #include "slidingInterface.H" #include "polyTopoChanger.H" #include "polyMesh.H" -#include "primitiveMesh.H" #include "polyTopoChange.H" #include "addToRunTimeSelectionTable.H" -#include "triPointRef.H" #include "plane.H" // Index of debug signs: @@ -173,6 +171,14 @@ Foam::slidingInterface::slidingInterface attached_(false), projectionAlgo_(algo), trigger_(false), + pointMergeTol_(pointMergeTolDefault_), + edgeMergeTol_(edgeMergeTolDefault_), + nFacesPerSlaveEdge_(nFacesPerSlaveEdgeDefault_), + edgeFaceEscapeLimit_(edgeFaceEscapeLimitDefault_), + integralAdjTol_(integralAdjTolDefault_), + edgeMasterCatchFraction_(edgeMasterCatchFractionDefault_), + edgeCoPlanarTol_(edgeCoPlanarTolDefault_), + edgeEndCutoffTol_(edgeEndCutoffTolDefault_), cutFaceMasterPtr_(NULL), cutFaceSlavePtr_(NULL), masterFaceCellsPtr_(NULL), @@ -280,6 +286,9 @@ Foam::slidingInterface::slidingInterface masterPointEdgeHitsPtr_(NULL), projectedSlavePointsPtr_(NULL) { + // Optionally default tolerances from dictionary + setTolerances(dict); + checkDefinition(); // If the interface is attached, the master and slave face zone addressing @@ -686,6 +695,63 @@ const Foam::pointField& Foam::slidingInterface::pointProjection() const return *projectedSlavePointsPtr_; } +void Foam::slidingInterface::setTolerances(const dictionary&dict, bool report) +{ + pointMergeTol_ = dict.lookupOrDefault + ( + "pointMergeTol", + pointMergeTol_ + ); + edgeMergeTol_ = dict.lookupOrDefault + ( + "edgeMergeTol", + edgeMergeTol_ + ); + nFacesPerSlaveEdge_ = dict.lookupOrDefault + ( + "nFacesPerSlaveEdge", + nFacesPerSlaveEdge_ + ); + edgeFaceEscapeLimit_ = dict.lookupOrDefault + ( + "edgeFaceEscapeLimit", + edgeFaceEscapeLimit_ + ); + integralAdjTol_ = dict.lookupOrDefault + ( + "integralAdjTol", + integralAdjTol_ + ); + edgeMasterCatchFraction_ = dict.lookupOrDefault + ( + "edgeMasterCatchFraction", + edgeMasterCatchFraction_ + ); + edgeCoPlanarTol_ = dict.lookupOrDefault + ( + "edgeCoPlanarTol", + edgeCoPlanarTol_ + ); + edgeEndCutoffTol_ = dict.lookupOrDefault + ( + "edgeEndCutoffTol", + edgeEndCutoffTol_ + ); + + if (report) + { + Info<< "Sliding interface parameters:" << nl + << "pointMergeTol : " << pointMergeTol_ << nl + << "edgeMergeTol : " << edgeMergeTol_ << nl + << "nFacesPerSlaveEdge : " << nFacesPerSlaveEdge_ << nl + << "edgeFaceEscapeLimit : " << edgeFaceEscapeLimit_ << nl + << "integralAdjTol : " << integralAdjTol_ << nl + << "edgeMasterCatchFraction : " << edgeMasterCatchFraction_ << nl + << "edgeCoPlanarTol : " << edgeCoPlanarTol_ << nl + << "edgeEndCutoffTol : " << edgeEndCutoffTol_ << endl; + } +} + void Foam::slidingInterface::write(Ostream& os) const { @@ -703,6 +769,14 @@ void Foam::slidingInterface::write(Ostream& os) const } +// To write out all those tolerances +#define WRITE_NON_DEFAULT(name) \ + if( name ## _ != name ## Default_ )\ + { \ + os << " " #name " " << name ## _ << token::END_STATEMENT << nl; \ + } + + void Foam::slidingInterface::writeDict(Ostream& os) const { os << nl << name() << nl << token::BEGIN_BLOCK << nl @@ -743,6 +817,15 @@ void Foam::slidingInterface::writeDict(Ostream& os) const << token::END_STATEMENT << nl; } + WRITE_NON_DEFAULT(pointMergeTol) + WRITE_NON_DEFAULT(edgeMergeTol) + WRITE_NON_DEFAULT(nFacesPerSlaveEdge) + WRITE_NON_DEFAULT(edgeFaceEscapeLimit) + WRITE_NON_DEFAULT(integralAdjTol) + WRITE_NON_DEFAULT(edgeMasterCatchFraction) + WRITE_NON_DEFAULT(edgeCoPlanarTol) + WRITE_NON_DEFAULT(edgeEndCutoffTol) + os << token::END_BLOCK << endl; } diff --git a/src/dynamicMesh/slidingInterface/slidingInterface.H b/src/dynamicMesh/slidingInterface/slidingInterface.H index 376c969e38..f86e423c65 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterface.H +++ b/src/dynamicMesh/slidingInterface/slidingInterface.H @@ -129,6 +129,32 @@ private: //- Trigger topological change mutable bool trigger_; + // Tolerances. Initialised to static ones below. + + //- Point merge tolerance + scalar pointMergeTol_; + + //- Edge merge tolerance + scalar edgeMergeTol_; + + //- Estimated number of faces an edge goes through + label nFacesPerSlaveEdge_; + + //- Edge-face interaction escape limit + label edgeFaceEscapeLimit_; + + //- Integral match point adjustment tolerance + scalar integralAdjTol_; + + //- Edge intersection master catch fraction + scalar edgeMasterCatchFraction_; + + //- Edge intersection co-planar tolerance + scalar edgeCoPlanarTol_; + + //- Edge end cut-off tolerance + scalar edgeEndCutoffTol_; + // Private addressing data. @@ -256,28 +282,28 @@ private: // Static data members //- Point merge tolerance - static const scalar pointMergeTol_; + static const scalar pointMergeTolDefault_; //- Edge merge tolerance - static const scalar edgeMergeTol_; + static const scalar edgeMergeTolDefault_; //- Estimated number of faces an edge goes through - static const label nFacesPerSlaveEdge_; + static const label nFacesPerSlaveEdgeDefault_; //- Edge-face interaction escape limit - static const label edgeFaceEscapeLimit_; + static const label edgeFaceEscapeLimitDefault_; //- Integral match point adjustment tolerance - static const scalar integralAdjTol_; + static const scalar integralAdjTolDefault_; //- Edge intersection master catch fraction - static const scalar edgeMasterCatchFraction_; + static const scalar edgeMasterCatchFractionDefault_; //- Edge intersection co-planar tolerance - static const scalar edgeCoPlanarTol_; + static const scalar edgeCoPlanarTolDefault_; //- Edge end cut-off tolerance - static const scalar edgeEndCutoffTol_; + static const scalar edgeEndCutoffTolDefault_; public: @@ -350,6 +376,8 @@ public: //- Return projected points for a slave patch const pointField& pointProjection() const; + //- Set the tolerances from the values in a dictionary + void setTolerances(const dictionary&, bool report=false); //- Write virtual void write(Ostream&) const; diff --git a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C index a34fd0f7b9..cc4643bcde 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C +++ b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C @@ -26,22 +26,19 @@ License #include "slidingInterface.H" #include "polyMesh.H" -#include "primitiveMesh.H" #include "line.H" -#include "triPointRef.H" -#include "plane.H" #include "polyTopoChanger.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::scalar Foam::slidingInterface::pointMergeTol_ = 0.05; -const Foam::scalar Foam::slidingInterface::edgeMergeTol_ = 0.01; -const Foam::label Foam::slidingInterface::nFacesPerSlaveEdge_ = 5; -const Foam::label Foam::slidingInterface::edgeFaceEscapeLimit_ = 10; +const Foam::scalar Foam::slidingInterface::pointMergeTolDefault_ = 0.05; +const Foam::scalar Foam::slidingInterface::edgeMergeTolDefault_ = 0.01; +const Foam::label Foam::slidingInterface::nFacesPerSlaveEdgeDefault_ = 5; +const Foam::label Foam::slidingInterface::edgeFaceEscapeLimitDefault_ = 10; -const Foam::scalar Foam::slidingInterface::integralAdjTol_ = 0.05; -const Foam::scalar Foam::slidingInterface::edgeMasterCatchFraction_ = 0.4; -const Foam::scalar Foam::slidingInterface::edgeEndCutoffTol_ = 0.0001; +const Foam::scalar Foam::slidingInterface::integralAdjTolDefault_ = 0.05; +const Foam::scalar Foam::slidingInterface::edgeMasterCatchFractionDefault_ = 0.4; +const Foam::scalar Foam::slidingInterface::edgeEndCutoffTolDefault_ = 0.0001; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // From 71b7f8932973ef61e48cc3f613a4f19e14c58678 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 19 Aug 2009 11:47:52 +0100 Subject: [PATCH 04/30] more sensible variable names --- .../faceZonesIntegration.C | 39 +++++++++---------- .../faceZonesIntegration.H | 6 +-- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C index 36740cbf11..2899224d29 100644 --- a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C +++ b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C @@ -55,8 +55,8 @@ Foam::faceZonesIntegration::faceZonesIntegration obr_(obr), active_(true), log_(false), - faceZonesSet_(), - fItems_(), + zoneNames_(), + fieldNames_(), filePtr_(NULL) { // Check if the available mesh is an fvMesh otherise deactivate @@ -94,9 +94,9 @@ void Foam::faceZonesIntegration::read(const dictionary& dict) { log_ = dict.lookupOrDefault("log", false); - dict.lookup("fields") >> fItems_; + dict.lookup("fields") >> fieldNames_; - dict.lookup("faceZones") >> faceZonesSet_; + dict.lookup("faceZones") >> zoneNames_; } } @@ -132,11 +132,11 @@ void Foam::faceZonesIntegration::makeFile() mkDir(faceZonesIntegrationDir); // Open new file at start up - filePtr_.resize(fItems_.size()); + filePtr_.resize(fieldNames_.size()); - forAll(fItems_, Ifields) + forAll(fieldNames_, fieldI) { - const word& fieldName = fItems_[Ifields]; + const word& fieldName = fieldNames_[fieldI]; OFstream* sPtr = new OFstream ( @@ -163,10 +163,9 @@ void Foam::faceZonesIntegration::writeFileHeader() os << "#Time " << setw(w); - forAll (faceZonesSet_, zoneI) + forAll (zoneNames_, zoneI) { - const word name = faceZonesSet_[zoneI]; - os << name << setw(w); + os << zoneNames_[zoneI] << setw(w); } os << nl << endl; @@ -192,9 +191,9 @@ void Foam::faceZonesIntegration::write() { makeFile(); - forAll(fItems_, fieldI) + forAll(fieldNames_, fieldI) { - const word& fieldName = fItems_[fieldI]; + const word& fieldName = fieldNames_[fieldI]; const surfaceScalarField& sField = obr_.lookupObject(fieldName); @@ -203,17 +202,17 @@ void Foam::faceZonesIntegration::write() // 1. integrate over all face zones - scalarField integralVals(faceZonesSet_.size()); + scalarField integralVals(zoneNames_.size()); - forAll(faceZonesSet_, setI) + forAll(integralVals, zoneI) { - const word name = faceZonesSet_[setI]; + const word& name = zoneNames_[zoneI]; label zoneID = mesh.faceZones().findZoneID(name); const faceZone& fZone = mesh.faceZones()[zoneID]; - integralVals[setI] = returnReduce + integralVals[zoneI] = returnReduce ( calcIntegral(sField, fZone), sumOp() @@ -231,15 +230,15 @@ void Foam::faceZonesIntegration::write() os << obr_.time().value(); - forAll(integralVals, setI) + forAll(integralVals, zoneI) { - os << ' ' << setw(w) << integralVals[setI]; + os << ' ' << setw(w) << integralVals[zoneI]; if (log_) { Info<< "faceZonesIntegration output:" << nl - << " Integration[" << setI << "] " - << integralVals[setI] << endl; + << " Integration[" << zoneI << "] " + << integralVals[zoneI] << endl; } } diff --git a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H index c2f3ad9d4b..d1a1bacfd2 100644 --- a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H +++ b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H @@ -82,11 +82,11 @@ protected: //- Switch to send output to Info as well as to file Switch log_; - //- faceZones to integrate over - wordList faceZonesSet_; + //- List of face zone names to integrate over + wordList zoneNames_; //- Names of the surface fields - wordList fItems_; + wordList fieldNames_; //- Current open files From 61b29463d101de475d108029424c634bfadafdcd Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 19 Aug 2009 15:19:02 +0100 Subject: [PATCH 05/30] renamed patches to patchInfo --- .../mesh/manipulation/createPatch/createPatch.C | 10 +++++----- .../mesh/manipulation/createPatch/createPatchDict | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C index 7d74e7208c..40ba0efade 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C +++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.C @@ -208,8 +208,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh) // Dump halves { OFstream str(prefix+cycPatch.name()+"_half0.obj"); - Pout<< "Dumping cycPatch.name() half0 faces to " << str.name() - << endl; + Pout<< "Dumping " << cycPatch.name() + << " half0 faces to " << str.name() << endl; meshTools::writeOBJ ( str, @@ -226,8 +226,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh) } { OFstream str(prefix+cycPatch.name()+"_half1.obj"); - Pout<< "Dumping cycPatch.name() half1 faces to " << str.name() - << endl; + Pout<< "Dumping " << cycPatch.name() + << " half1 faces to " << str.name() << endl; meshTools::writeOBJ ( str, @@ -563,7 +563,7 @@ int main(int argc, char *argv[]) dumpCyclicMatch("initial_", mesh); // Read patch construct info from dictionary - PtrList patchSources(dict.lookup("patches")); + PtrList patchSources(dict.lookup("patchInfo")); diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatchDict b/applications/utilities/mesh/manipulation/createPatch/createPatchDict index 9704392a10..b8676f134d 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatchDict +++ b/applications/utilities/mesh/manipulation/createPatch/createPatchDict @@ -46,7 +46,7 @@ matchTolerance 1E-3; pointSync true; // Patches to create. -patches +patchInfo ( { // Name of new patch From 4f85f763091367b0a1f7ddb5a526ebe5e8cf1fea Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 19 Aug 2009 15:23:24 +0100 Subject: [PATCH 06/30] allow stand-alone extrusion --- .../polyTopoChange/addPatchCellLayer.C | 215 ++++++++++++++---- .../polyTopoChange/addPatchCellLayer.H | 8 +- 2 files changed, 171 insertions(+), 52 deletions(-) diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index 2f842e6d66..c3b104134c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -335,17 +335,19 @@ Foam::label Foam::addPatchCellLayer::addSideFace label inflateEdgeI = -1; // Check mesh faces using edge - forAll(meshFaces, i) + if (addToMesh_) { - if (mesh_.isInternalFace(meshFaces[i])) + forAll(meshFaces, i) { - // meshEdge uses internal faces so ok to inflate from it - inflateEdgeI = meshEdgeI; - break; + if (mesh_.isInternalFace(meshFaces[i])) + { + // meshEdge uses internal faces so ok to inflate from it + inflateEdgeI = meshEdgeI; + break; + } } } - // Get my mesh face and its zone. label meshFaceI = pp.addressing()[ownFaceI]; label zoneI = mesh_.faceZones().whichZone(meshFaceI); @@ -504,9 +506,14 @@ Foam::label Foam::addPatchCellLayer::addSideFace // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from mesh -Foam::addPatchCellLayer::addPatchCellLayer(const polyMesh& mesh) +Foam::addPatchCellLayer::addPatchCellLayer +( + const polyMesh& mesh, + const bool addToMesh +) : mesh_(mesh), + addToMesh_(addToMesh), addedPoints_(0), layerFaces_(0) {} @@ -827,6 +834,19 @@ void Foam::addPatchCellLayer::setRefinement } + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + // Precalculated patchID for each patch face + labelList patchID(pp.size()); + + forAll(pp, patchFaceI) + { + label meshFaceI = pp.addressing()[patchFaceI]; + + patchID[patchFaceI] = patches.whichPatch(meshFaceI); + } + + // From master point (in patch point label) to added points (in mesh point // label) addedPoints_.setSize(pp.nPoints()); @@ -857,6 +877,33 @@ void Foam::addPatchCellLayer::setRefinement // Create new points // + // If creating new mesh: copy existing patch points + labelList copiedPatchPoints; + if (!addToMesh_) + { + copiedPatchPoints.setSize(firstLayerDisp.size()); + forAll(firstLayerDisp, patchPointI) + { + if (addedPoints_[patchPointI].size()) + { + label meshPointI = meshPoints[patchPointI]; + label zoneI = mesh_.pointZones().whichZone(meshPointI); + copiedPatchPoints[patchPointI] = meshMod.setAction + ( + polyAddPoint + ( + mesh_.points()[meshPointI], // point + -1, // master point + zoneI, // zone for point + true // supports a cell + ) + ); + } + } + } + + + // Create points for additional layers forAll(firstLayerDisp, patchPointI) { if (addedPoints_[patchPointI].size()) @@ -878,7 +925,7 @@ void Foam::addPatchCellLayer::setRefinement polyAddPoint ( pt, // point - meshPointI, // master point + (addToMesh_ ? meshPointI : -1), // master point zoneI, // zone for point true // supports a cell ) @@ -922,7 +969,7 @@ void Foam::addPatchCellLayer::setRefinement -1, // master point -1, // master edge -1, // master face - mesh_.faceOwner()[meshFaceI], // master cell id + (addToMesh_ ? mesh_.faceOwner()[meshFaceI] : -1),//master ownZoneI // zone for cell ) ); @@ -930,26 +977,12 @@ void Foam::addPatchCellLayer::setRefinement //Pout<< "For patchFace:" << patchFaceI // << " meshFace:" << pp.addressing()[patchFaceI] // << " layer:" << i << " added cell:" - // << addedCells[patchFaceI][i] - // << endl; + // << addedCells[patchFaceI][i] << endl; } } } - const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - - // Precalculated patchID for each patch face - labelList patchID(pp.size()); - - forAll(pp, patchFaceI) - { - label meshFaceI = pp.addressing()[patchFaceI]; - - patchID[patchFaceI] = patches.whichPatch(meshFaceI); - } - - // Create faces on top of the original patch faces. // These faces are created from original patch faces outwards so in order @@ -981,7 +1014,12 @@ void Foam::addPatchCellLayer::setRefinement if (addedPoints_[f[fp]].empty()) { // Keep original point - newFace[fp] = meshPoints[f[fp]]; + newFace[fp] = + ( + addToMesh_ + ? meshPoints[f[fp]] + : copiedPatchPoints[f[fp]] + ); } else { @@ -1040,35 +1078,85 @@ void Foam::addPatchCellLayer::setRefinement // // Modify old patch faces to be on the inside // - forAll(pp, patchFaceI) + + labelList copiedPatchFaces; + if (addToMesh_) { - if (addedCells[patchFaceI].size()) + forAll(pp, patchFaceI) { - label meshFaceI = pp.addressing()[patchFaceI]; + if (addedCells[patchFaceI].size()) + { + label meshFaceI = pp.addressing()[patchFaceI]; - label zoneI = mesh_.faceZones().whichZone(meshFaceI); + label zoneI = mesh_.faceZones().whichZone(meshFaceI); - meshMod.setAction - ( - polyModifyFace + meshMod.setAction ( - pp[patchFaceI], // modified face - meshFaceI, // label of face - mesh_.faceOwner()[meshFaceI], // owner - addedCells[patchFaceI][0], // neighbour - false, // face flip - -1, // patch for face - false, // remove from zone - zoneI, // zone for face - false // face flip in zone - ) - ); - //Pout<< "Modified old patch face " << meshFaceI - // << " own:" << mesh_.faceOwner()[meshFaceI] - // << " nei:" << addedCells[patchFaceI][0] - // << endl; + polyModifyFace + ( + pp[patchFaceI], // modified face + meshFaceI, // label of face + mesh_.faceOwner()[meshFaceI], // owner + addedCells[patchFaceI][0], // neighbour + false, // face flip + -1, // patch for face + false, // remove from zone + zoneI, // zone for face + false // face flip in zone + ) + ); + //Pout<< "Modified old patch face " << meshFaceI + // << " own:" << mesh_.faceOwner()[meshFaceI] + // << " nei:" << addedCells[patchFaceI][0] + // << endl; + } } } + else + { + // If creating new mesh: copy existing patch points + copiedPatchFaces.setSize(pp.size()); + forAll(pp, patchFaceI) + { + if (nFaceLayers[patchFaceI] > 0) + { + label meshFaceI = pp.addressing()[patchFaceI]; + label zoneI = mesh_.faceZones().whichZone(meshFaceI); + bool zoneFlip = false; + if (zoneI != -1) + { + const faceZone& fz = mesh_.faceZones()[zoneI]; + zoneFlip = !fz.flipMap()[fz.whichFace(meshFaceI)]; + } + + // Reverse and renumber old patch face. + face f(pp.localFaces()[patchFaceI].reverseFace()); + forAll(f, fp) + { + f[fp] = copiedPatchPoints[f[fp]]; + } + + copiedPatchFaces[patchFaceI] = meshMod.setAction + ( + polyAddFace + ( + f, // modified face + addedCells[patchFaceI][0], // owner + -1, // neighbour + -1, // masterPoint + -1, // masterEdge + -1, // masterFace + true, // face flip + patchID[patchFaceI], // patch for face + zoneI, // zone for face + zoneFlip // face flip in zone + ) + ); + } + } + } + + // @@ -1255,7 +1343,16 @@ void Foam::addPatchCellLayer::setRefinement forAll(stringedVerts, stringedI) { label v = stringedVerts[stringedI]; - addVertex(meshPoints[v], newFace, newFp); + addVertex + ( + ( + addToMesh_ + ? meshPoints[v] + : copiedPatchPoints[v] + ), + newFace, + newFp + ); } } else @@ -1276,7 +1373,16 @@ void Foam::addPatchCellLayer::setRefinement } else { - addVertex(meshPoints[v], newFace, newFp); + addVertex + ( + ( + addToMesh_ + ? meshPoints[v] + : copiedPatchPoints[v] + ), + newFace, + newFp + ); } } } @@ -1316,7 +1422,16 @@ void Foam::addPatchCellLayer::setRefinement } else { - addVertex(meshPoints[v], newFace, newFp); + addVertex + ( + ( + addToMesh_ + ? meshPoints[v] + : copiedPatchPoints[v] + ), + newFace, + newFp + ); } } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H index f03d23e214..f950ca2619 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H @@ -26,7 +26,8 @@ Class Foam::addPatchCellLayer Description - Adds layers of cells to outside of polyPatch. + Adds layers of cells to outside of polyPatch. Can optionally create + stand-alone extruded mesh (addToMesh=false). Call setRefinement with offset vector for every patch point and number of layers per patch face and number of layers per patch point. @@ -164,6 +165,9 @@ class addPatchCellLayer //- Reference to mesh const polyMesh& mesh_; + //- Add layers to existing mesh or create new mesh + const bool addToMesh_; + //- For all patchpoints: list of added points (size 0 or nLayers) // First point in list is one nearest to original point in patch, // last one is the new point on the surface. @@ -253,7 +257,7 @@ public: // Constructors //- Construct from mesh. - addPatchCellLayer(const polyMesh& mesh); + addPatchCellLayer(const polyMesh& mesh, const bool addToMesh = true); // Member Functions From 98bd768d50f4dadcf0f240a8335caa8e37fe97ed Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 19 Aug 2009 16:43:29 +0100 Subject: [PATCH 07/30] adding counterFlowFlame2D tutorial case for reactingFoam --- .../reactingFoam/ras/counterFlowFlame2D/0/CH4 | 48 +++++++++++++ .../reactingFoam/ras/counterFlowFlame2D/0/N2 | 48 +++++++++++++ .../reactingFoam/ras/counterFlowFlame2D/0/O2 | 47 ++++++++++++ .../reactingFoam/ras/counterFlowFlame2D/0/T | 48 +++++++++++++ .../reactingFoam/ras/counterFlowFlame2D/0/U | 45 ++++++++++++ .../ras/counterFlowFlame2D/0/Ydefault | 48 +++++++++++++ .../ras/counterFlowFlame2D/0/alphat | 45 ++++++++++++ .../ras/counterFlowFlame2D/0/epsilon | 45 ++++++++++++ .../reactingFoam/ras/counterFlowFlame2D/0/k | 45 ++++++++++++ .../reactingFoam/ras/counterFlowFlame2D/0/mut | 45 ++++++++++++ .../reactingFoam/ras/counterFlowFlame2D/0/p | 49 +++++++++++++ .../counterFlowFlame2D/constant/RASProperties | 25 +++++++ .../constant/chemistryProperties | 48 +++++++++++++ .../ras/counterFlowFlame2D/constant/g | 22 ++++++ .../constant/polyMesh/blockMeshDict | 66 +++++++++++++++++ .../constant/polyMesh/boundary | 46 ++++++++++++ .../ras/counterFlowFlame2D/constant/reactions | 15 ++++ .../constant/thermo.compressibleGas | 28 ++++++++ .../constant/thermophysicalProperties | 29 ++++++++ .../constant/turbulenceProperties | 21 ++++++ .../ras/counterFlowFlame2D/system/controlDict | 53 ++++++++++++++ .../ras/counterFlowFlame2D/system/fvSchemes | 71 +++++++++++++++++++ .../ras/counterFlowFlame2D/system/fvSolution | 51 +++++++++++++ 23 files changed, 988 insertions(+) create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/CH4 create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/N2 create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/O2 create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/T create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/U create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/Ydefault create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/alphat create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/epsilon create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/k create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/mut create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/p create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/RASProperties create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/g create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/blockMeshDict create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/boundary create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/reactions create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermo.compressibleGas create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermophysicalProperties create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/turbulenceProperties create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/controlDict create mode 100644 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSchemes create mode 100755 tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSolution diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/CH4 b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/CH4 new file mode 100644 index 0000000000..dcdd095f09 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/CH4 @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object CH4; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 1.0; + } + air + { + type fixedValue; + value uniform 0.0; + } + outlet + { + type inletOutlet; + inletValue uniform 0.0; + value uniform 0.0; + + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/N2 b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/N2 new file mode 100644 index 0000000000..3a0de95a3c --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/N2 @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object O2; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.77; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 0.0; + } + air + { + type fixedValue; + value uniform 0.77; + } + outlet + { + type inletOutlet; + inletValue uniform 0.77; + value uniform 0.77; + + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/O2 b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/O2 new file mode 100644 index 0000000000..3a038966c2 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/O2 @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object O2; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.23; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 0.0; + } + air + { + type fixedValue; + value uniform 0.23; + } + outlet + { + type inletOutlet; + inletValue uniform 0.23; + value uniform 0.23; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/T b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/T new file mode 100644 index 0000000000..254322f38e --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/T @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 293; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 800; + } + air + { + type fixedValue; + value uniform 800; + } + outlet + { + type inletOutlet; + inletValue uniform 293; + value uniform 293; + + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/U b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/U new file mode 100644 index 0000000000..56b91756dc --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/U @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + fuel + { + type fixedValue; + value uniform (0.1 0 0); + } + air + { + type fixedValue; + value uniform (-0.1 0 0); + } + outlet + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/Ydefault b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/Ydefault new file mode 100644 index 0000000000..da2957b4c8 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/Ydefault @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object Ydefault; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 0.0; + } + air + { + type fixedValue; + value uniform 0.0; + } + outlet + { + type inletOutlet; + inletValue uniform 0.0; + value uniform 0.0; + + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/alphat b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/alphat new file mode 100644 index 0000000000..cf60ba7894 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/alphat @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object alphat; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 0.0; + } + air + { + type fixedValue; + value uniform 0.0; + } + outlet + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/epsilon b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/epsilon new file mode 100644 index 0000000000..52209c27a3 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/epsilon @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform 50; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 1.e-5; + } + air + { + type fixedValue; + value uniform 1.e-5; + } + outlet + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/k b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/k new file mode 100644 index 0000000000..6b2458ec76 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/k @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 3.75e-5; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 3.75e-5; + } + air + { + type fixedValue; + value uniform 3.75e-5; + } + outlet + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/mut b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/mut new file mode 100644 index 0000000000..3fd75130c2 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/mut @@ -0,0 +1,45 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object mut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + fuel + { + type fixedValue; + value uniform 0.0; + } + air + { + type fixedValue; + value uniform 0.0; + } + outlet + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/p b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/p new file mode 100644 index 0000000000..bb7898548f --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/p @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 1e5; + +boundaryField +{ + fuel + { + type zeroGradient; + } + air + { + type zeroGradient; + } + inlet2 + { + type zeroGradient; + } + outlet + { + type fixedValue; + value uniform 1e5; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/RASProperties b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/RASProperties new file mode 100644 index 0000000000..81b1ec9115 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/RASProperties @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel kEpsilon; + +turbulence on; + +printCoeffs on; + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties new file mode 100644 index 0000000000..fd8ff1453a --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "constant"; + object chemistryProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +psiChemistryModel ODEChemistryModel; + +chemistry on; + +chemistrySolver ode; + +initialChemicalTimeStep 1e-07; + +turbulentReaction on; + +sequentialCoeffs +{ + cTauChem 0.001; +} + +EulerImplicitCoeffs +{ + cTauChem 0.05; + equilibriumRateLimiter off; +} + +odeCoeffs +{ + ODESolver SIBS; + eps 0.05; + scale 1; +} + +Cmix Cmix [ 0 0 0 0 0 0 0 ] 0.1; + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/g b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/g new file mode 100644 index 0000000000..c0436c9ba0 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 0 0 ); + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/blockMeshDict b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000..0befc6212d --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/blockMeshDict @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (0.0 -0.01 -0.01) + (0.02 -0.01 -0.01) + (0.02 0.01 -0.01) + (0.0 0.01 -0.01) + (0.0 -0.01 0.01) + (0.02 -0.01 0.01) + (0.02 0.01 0.01) + (0.0 0.01 0.01) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (100 40 1) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + patch fuel + ( + (0 4 7 3) + ) + patch air + ( + (1 2 6 5) + ) + patch outlet + ( + (0 1 5 4) + (7 6 2 3) + ) + empty frontAndBack + ( + (4 5 6 7) + (0 3 2 1) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/boundary b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/boundary new file mode 100644 index 0000000000..dca33da1db --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/polyMesh/boundary @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +4 +( + fuel + { + type patch; + nFaces 40; + startFace 7860; + } + air + { + type patch; + nFaces 40; + startFace 7900; + } + outlet + { + type patch; + nFaces 200; + startFace 7940; + } + frontAndBack + { + type empty; + nFaces 8000; + startFace 8140; + } +) + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/reactions b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/reactions new file mode 100644 index 0000000000..e9a256e2da --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/reactions @@ -0,0 +1,15 @@ +species +( + O2 + H2O + CH4 + CO2 + N2 +); + +reactions +( + irreversibleArrheniusReaction + CH4 + 2O2 = CO2 + 2H2O + (5.2e16 0 14906) +); \ No newline at end of file diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermo.compressibleGas b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermo.compressibleGas new file mode 100644 index 0000000000..9b202c3435 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermo.compressibleGas @@ -0,0 +1,28 @@ +( +O2 O2 1 31.9988 + 200 5000 1000 + 3.69758 0.00061352 -1.25884e-07 1.77528e-11 -1.13644e-15 -1233.93 3.18917 + 3.21294 0.00112749 -5.75615e-07 1.31388e-09 -8.76855e-13 -1005.25 6.03474 + 1.67212e-06 170.672 +H2O H2O 1 18.0153 + 200 5000 1000 + 2.67215 0.00305629 -8.73026e-07 1.201e-10 -6.39162e-15 -29899.2 6.86282 + 3.38684 0.00347498 -6.3547e-06 6.96858e-09 -2.50659e-12 -30208.1 2.59023 + 1.67212e-06 170.672 +CH4 CH4 1 16.0428 + 200 6000 1000 + 1.63543 0.0100844 -3.36924e-06 5.34973e-10 -3.15528e-14 -10005.6 9.9937 + 5.14988 -0.013671 4.91801e-05 -4.84744e-08 1.66694e-11 -10246.6 -4.64132 + 1.67212e-06 170.672 +CO2 CO2 1 44.01 + 200 5000 1000 + 4.45362 0.00314017 -1.27841e-06 2.394e-10 -1.66903e-14 -48967 -0.955396 + 2.27572 0.00992207 -1.04091e-05 6.86669e-09 -2.11728e-12 -48373.1 10.1885 + 1.67212e-06 170.672 +N2 N2 1 28.0134 + 200 5000 1000 + 2.92664 0.00148798 -5.68476e-07 1.0097e-10 -6.75335e-15 -922.798 5.98053 + 3.29868 0.00140824 -3.96322e-06 5.64152e-09 -2.44486e-12 -1020.9 3.95037 + 1.67212e-06 170.672 +) + diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermophysicalProperties b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermophysicalProperties new file mode 100644 index 0000000000..1586cb545c --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/thermophysicalProperties @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType hPsiMixtureThermo>; + +inertSpecie N2; + +chemistryReader foamChemistryReader; + +foamChemistryFile "$FOAM_CASE/constant/reactions"; + +foamChemistryThermoFile "$FOAM_CASE/constant/thermo.compressibleGas"; + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/turbulenceProperties b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/turbulenceProperties new file mode 100644 index 0000000000..f1f4b717d0 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/turbulenceProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RASModel; + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/controlDict b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/controlDict new file mode 100644 index 0000000000..d8eadc979c --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/controlDict @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application reactingFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 1.0; + +deltaT 1e-6; + +writeControl adjustableRunTime; + +writeInterval 0.1; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.4; + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSchemes b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSchemes new file mode 100644 index 0000000000..b961fdc745 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSchemes @@ -0,0 +1,71 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + grad(p) Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss limitedLinearV 1; + div(phi,Yi_h) Gauss limitedLinear01 1; + div(phi,h) Gauss limitedLinear 1; + div(phiU,p) Gauss limitedLinear 1; + div(phid,p) Gauss limitedLinear 1; + div(phi,epsilon) Gauss limitedLinear 1; + div(phi,k) Gauss limitedLinear 1; + div((muEff*dev2(grad(U).T()))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear uncorrected; + laplacian(muEff,U) Gauss linear uncorrected; + laplacian(mut,U) Gauss linear uncorrected; + laplacian(DkEff,k) Gauss linear uncorrected; + laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; + laplacian((rho*(1|A(U))),p) Gauss linear uncorrected; + laplacian(alphaEff,h) Gauss linear uncorrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +fluxRequired +{ + default no; + p; +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSolution b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSolution new file mode 100755 index 0000000000..16e36d1356 --- /dev/null +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/system/fvSolution @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0; + } + p + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0.0; + } + + "(U|Yi|h|k|epsilon)" + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-06; + relTol 0; + } +} + +PISO +{ + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // From 46419a5917c55299f71472cca15c24b34ca5235c Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 20 Aug 2009 12:34:07 +0100 Subject: [PATCH 08/30] construct from polyMesh --- src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C | 2 +- src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index f6c397640f..849481c2eb 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -3176,7 +3176,7 @@ Foam::autoPtr Foam::polyTopoChange::makeMesh ( autoPtr& newMeshPtr, const IOobject& io, - const fvMesh& mesh, + const polyMesh& mesh, const bool syncParallel, const bool orderCells, const bool orderPoints diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H index 77801e21f0..e7a0ba8fb3 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -585,7 +585,7 @@ public: ( autoPtr& newMesh, const IOobject& io, - const fvMesh& mesh, + const polyMesh& mesh, const bool syncParallel = true, const bool orderCells = false, const bool orderPoints = false From 0708fbbba91bcc619d82f07cd5798306c6b6ffa6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 20 Aug 2009 12:34:22 +0100 Subject: [PATCH 09/30] reference to temporary --- src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C index 887fed0fd9..a089b502e3 100644 --- a/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C +++ b/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatCore.C @@ -48,7 +48,8 @@ int Foam::fileFormats::STLsurfaceFormatCore::detectBINARY { off_t dataFileSize = Foam::fileSize(filename); - istream& is = IFstream(filename, IOstream::BINARY)().stdStream(); + IFstream str(filename, IOstream::BINARY); + istream& is = str().stdStream(); // Read the STL header char header[headerSize]; From 65e925f1fef7a39aaf1f296c96b7fb2018c3bfad Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 21 Aug 2009 17:36:27 +0100 Subject: [PATCH 10/30] extrudeMesh does extrusion from existing mesh --- .../mesh/generation/extrudeMesh/Make/options | 4 + .../mesh/generation/extrudeMesh/extrudeMesh.C | 548 ++++++++++++++--- .../extrudeModel/extrudeModel/extrudeModel.C | 24 + .../extrudeModel/extrudeModel/extrudeModel.H | 8 + .../extrudeModel/linearNormal/linearNormal.C | 3 +- .../extrudeModel/linearNormal/linearNormal.H | 2 +- .../extrudeModel/linearRadial/linearRadial.C | 3 +- .../extrudeModel/linearRadial/linearRadial.H | 2 +- .../extrudeModel/sigmaRadial/sigmaRadial.C | 8 +- .../extrudeModel/sigmaRadial/sigmaRadial.H | 2 +- .../extrudeMesh/extrudeModel/wedge/wedge.C | 4 +- .../extrudeMesh/extrudeModel/wedge/wedge.H | 2 +- .../generation/extrudeMesh/extrudeProperties | 39 +- .../perfectInterface/perfectInterface.C | 577 +++++++++--------- .../perfectInterface/perfectInterface.H | 14 +- .../polyTopoChange/addPatchCellLayer.C | 30 +- .../polyTopoChange/addPatchCellLayer.H | 24 +- .../polyTopoChange/polyTopoChange.C | 5 + 18 files changed, 870 insertions(+), 429 deletions(-) diff --git a/applications/utilities/mesh/generation/extrudeMesh/Make/options b/applications/utilities/mesh/generation/extrudeMesh/Make/options index ce0e27f401..1cdc68a2c7 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/Make/options +++ b/applications/utilities/mesh/generation/extrudeMesh/Make/options @@ -1,10 +1,14 @@ EXE_INC = \ -IextrudedMesh \ -IextrudeModel/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ + -lfiniteVolume \ + -lsurfMesh \ -lmeshTools \ -ldynamicMesh \ -lextrudeModel diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C index d149f85923..4d5bca0e82 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C @@ -36,13 +36,15 @@ Description #include "Time.H" #include "dimensionedTypes.H" #include "IFstream.H" -#include "faceMesh.H" #include "polyTopoChange.H" #include "polyTopoChanger.H" #include "edgeCollapser.H" #include "mathematicalConstants.H" #include "globalMeshData.H" #include "perfectInterface.H" +#include "addPatchCellLayer.H" +#include "fvMesh.H" +#include "MeshedSurfaces.H" #include "extrudedMesh.H" #include "extrudeModel.H" @@ -50,14 +52,148 @@ Description using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +enum ExtrudeMode +{ + MESH, + PATCH, + SURFACE +}; + +template<> +const char* NamedEnum::names[] = +{ + "mesh", + "patch", + "surface" +}; +static const NamedEnum ExtrudeModeNames; + + +void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName) +{ + // Create dummy system/fv* + { + IOobject io + ( + "fvSchemes", + mesh.time().system(), + regionName, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ); + + Info<< "Testing:" << io.objectPath() << endl; + + if (!io.headerOk()) + { + Info<< "Writing dummy " << regionName/io.name() << endl; + dictionary dummyDict; + dictionary divDict; + dummyDict.add("divSchemes", divDict); + dictionary gradDict; + dummyDict.add("gradSchemes", gradDict); + dictionary laplDict; + dummyDict.add("laplacianSchemes", laplDict); + + IOdictionary(io, dummyDict).regIOobject::write(); + } + } + { + IOobject io + ( + "fvSolution", + mesh.time().system(), + regionName, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ); + + if (!io.headerOk()) + { + Info<< "Writing dummy " << regionName/io.name() << endl; + dictionary dummyDict; + IOdictionary(io, dummyDict).regIOobject::write(); + } + } +} + + +label findPatchID(const polyBoundaryMesh& patches, const word& name) +{ + label patchID = patches.findPatchID(name); + + if (patchID == -1) + { + FatalErrorIn("findPatchID(const polyBoundaryMesh&, const word&)") + << "Cannot find patch " << name + << " in the source mesh.\n" + << "Valid patch names are " << patches.names() + << exit(FatalError); + } + return patchID; +} + + +labelList patchFaces(const polyBoundaryMesh& patches, const word& name) +{ + label patchID = findPatchID(patches, name); + const polyPatch& pp = patches[patchID]; + + return identity(pp.size()) + pp.start(); +} + + +void updateFaceLabels(const mapPolyMesh& map, labelList& faceLabels) +{ + const labelList& reverseMap = map.reverseFaceMap(); + + labelList newFaceLabels(faceLabels.size()); + label newI = 0; + + forAll(faceLabels, i) + { + label oldFaceI = faceLabels[i]; + + if (reverseMap[oldFaceI] >= 0) + { + newFaceLabels[newI++] = reverseMap[oldFaceI]; + } + } + newFaceLabels.setSize(newI); + faceLabels.transfer(newFaceLabels); +} + + + // Main program: int main(int argc, char *argv[]) { + #include "addRegionOption.H" #include "setRootCase.H" #include "createTimeExtruded.H" - autoPtr meshPtr(NULL); + // Get optional regionName + word regionName; + word regionDir; + if (args.optionReadIfPresent("region", regionName)) + { + regionDir = regionName; + Info<< "Create mesh " << regionName << " for time = " + << runTimeExtruded.timeName() << nl << endl; + } + else + { + regionName = fvMesh::defaultRegion; + Info<< "Create mesh for time = " + << runTimeExtruded.timeName() << nl << endl; + } + IOdictionary dict ( @@ -65,26 +201,44 @@ int main(int argc, char *argv[]) ( "extrudeProperties", runTimeExtruded.constant(), + regionDir, runTimeExtruded, IOobject::MUST_READ ) ); + // Point generator autoPtr model(extrudeModel::New(dict)); - const word sourceType(dict.lookup("constructFrom")); + // Whether to flip normals + const Switch flipNormals(dict.lookup("flipNormals")); - autoPtr fMesh; + // What to extrude + const ExtrudeMode mode = ExtrudeModeNames.read + ( + dict.lookup("constructFrom") + ); - if (sourceType == "patch") + + // Generated mesh (one of either) + autoPtr meshFromMesh; + autoPtr meshFromSurface; + + // Faces on front and back for stitching (in case of mergeFaces) + word frontPatchName; + labelList frontPatchFaces; + word backPatchName; + labelList backPatchFaces; + + if (mode == PATCH || mode == MESH) { fileName sourceCasePath(dict.lookup("sourceCase")); sourceCasePath.expand(); fileName sourceRootDir = sourceCasePath.path(); fileName sourceCaseDir = sourceCasePath.name(); - word patchName(dict.lookup("sourcePatch")); + dict.lookup("sourcePatch") >> frontPatchName; - Info<< "Extruding patch " << patchName + Info<< "Extruding patch " << frontPatchName << " on mesh " << sourceCasePath << nl << endl; @@ -94,31 +248,183 @@ int main(int argc, char *argv[]) sourceRootDir, sourceCaseDir ); - #include "createPolyMesh.H" + #include "createMesh.H" - label patchID = mesh.boundaryMesh().findPatchID(patchName); + const polyBoundaryMesh& patches = mesh.boundaryMesh(); - if (patchID == -1) + + // Topo change container. Either copy an existing mesh or start + // with empty storage (number of patches only needed for checking) + autoPtr meshMod + ( + ( + mode == MESH + ? new polyTopoChange(mesh) + : new polyTopoChange(patches.size()) + ) + ); + + // Extrusion engine. Either adding to existing mesh or + // creating separate mesh. + addPatchCellLayer layerExtrude(mesh, (mode == MESH)); + + indirectPrimitivePatch extrudePatch + ( + IndirectList + ( + mesh.faces(), + patchFaces(patches, frontPatchName) + ), + mesh.points() + ); + + // Only used for addPatchCellLayer into new mesh + labelList exposedPatchIDs; + if (mode == PATCH) { - FatalErrorIn(args.executable()) - << "Cannot find patch " << patchName - << " in the source mesh.\n" - << "Valid patch names are " << mesh.boundaryMesh().names() - << exit(FatalError); + dict.lookup("exposedPatchName") >> backPatchName; + exposedPatchIDs.setSize + ( + extrudePatch.size(), + findPatchID(patches, backPatchName) + ); } - const polyPatch& pp = mesh.boundaryMesh()[patchID]; - fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints())); + pointField layer0Points(extrudePatch.nPoints()); + pointField displacement(extrudePatch.nPoints()); + forAll(displacement, pointI) { - fileName surfName(runTime.path()/patchName + ".sMesh"); - Info<< "Writing patch as surfaceMesh to " - << surfName << nl << endl; - OFstream os(surfName); - os << fMesh() << nl; + const vector& patchNormal = extrudePatch.pointNormals()[pointI]; + + // layer0 point + layer0Points[pointI] = model() + ( + extrudePatch.localPoints()[pointI], + patchNormal, + 0 + ); + // layerN point + point extrudePt = model() + ( + extrudePatch.localPoints()[pointI], + patchNormal, + model().nLayers() + ); + displacement[pointI] = extrudePt - layer0Points[pointI]; } + + if (flipNormals) + { + Info<< "Flipping faces." << nl << endl; + displacement = -displacement; + } + + // Check if wedge (has layer0 different from original patch points) + // If so move the mesh to starting position. + if (gMax(mag(layer0Points-extrudePatch.localPoints())) > SMALL) + { + Info<< "Moving mesh to layer0 points since differ from original" + << " points - this can happen for wedge extrusions." << nl + << endl; + + pointField newPoints(mesh.points()); + forAll(extrudePatch.meshPoints(), i) + { + newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i]; + } + mesh.movePoints(newPoints); + } + + + // Layers per face + labelList nFaceLayers(extrudePatch.size(), model().nLayers()); + // Layers per point + labelList nPointLayers(extrudePatch.nPoints(), model().nLayers()); + // Displacement for first layer + vectorField firstLayerDisp = displacement*model().sumThickness(1); + // Expansion ratio not used. + scalarField ratio(extrudePatch.nPoints(), 1.0); + + layerExtrude.setRefinement + ( + ratio, // expansion ratio + extrudePatch, // patch faces to extrude + exposedPatchIDs, // if new mesh: patches for exposed faces + nFaceLayers, + nPointLayers, + firstLayerDisp, + meshMod() + ); + + // Reset points according to extrusion model + forAll(layerExtrude.addedPoints(), pointI) + { + const labelList& pPoints = layerExtrude.addedPoints()[pointI]; + forAll(pPoints, pPointI) + { + label meshPointI = pPoints[pPointI]; + + point modelPt + ( + model() + ( + extrudePatch.localPoints()[pointI], + extrudePatch.pointNormals()[pointI], + pPointI+1 // layer + ) + ); + + const_cast&> + ( + meshMod().points() + )[meshPointI] = modelPt; + } + } + + // Store faces on front and exposed patch (if mode=patch there are + // only added faces so cannot used map to old faces) + const labelListList& layerFaces = layerExtrude.layerFaces(); + backPatchFaces.setSize(layerFaces.size()); + frontPatchFaces.setSize(layerFaces.size()); + forAll(backPatchFaces, i) + { + backPatchFaces[i] = layerFaces[i][0]; + frontPatchFaces[i] = layerFaces[i][layerFaces[i].size()-1]; + } + + // Create dummy fvSchemes, fvSolution + createDummyFvMeshFiles(mesh, regionDir); + + // Create actual mesh from polyTopoChange container + autoPtr map = meshMod().makeMesh + ( + meshFromMesh, + IOobject + ( + regionName, + runTimeExtruded.constant(), + runTimeExtruded, + IOobject::NO_READ, + IOobject::AUTO_WRITE, + false + ), + mesh + ); + + // Calculate face labels for front and back. + frontPatchFaces = renumber + ( + map().reverseFaceMap(), + frontPatchFaces + ); + backPatchFaces = renumber + ( + map().reverseFaceMap(), + backPatchFaces + ); } - else if (sourceType == "surface") + else { // Read from surface fileName surfName(dict.lookup("surface")); @@ -126,52 +432,62 @@ int main(int argc, char *argv[]) Info<< "Extruding surfaceMesh read from file " << surfName << nl << endl; - IFstream is(surfName); + MeshedSurface fMesh(surfName); - fMesh.reset(new faceMesh(is)); - - Info<< "Read patch from file " << surfName << nl - << endl; - } - else - { - FatalErrorIn(args.executable()) - << "Illegal 'constructFrom' specification. Should either be " - << "patch or surface." << exit(FatalError); - } - - Switch flipNormals(dict.lookup("flipNormals")); - - if (flipNormals) - { - Info<< "Flipping faces." << nl << endl; - - faceList faces(fMesh().size()); - forAll(faces, i) + if (flipNormals) { - faces[i] = fMesh()[i].reverseFace(); + Info<< "Flipping faces." << nl << endl; + faceList& faces = const_cast(fMesh.faces()); + forAll(faces, i) + { + faces[i] = fMesh[i].reverseFace(); + } } - fMesh.reset(new faceMesh(faces, fMesh().localPoints())); + + Info<< "Extruding surface with :" << nl + << " points : " << fMesh.points().size() << nl + << " faces : " << fMesh.size() << nl + << " normals[0] : " << fMesh.faceNormals()[0] + << nl + << endl; + + meshFromSurface.reset + ( + new extrudedMesh + ( + IOobject + ( + extrudedMesh::defaultRegion, + runTimeExtruded.constant(), + runTimeExtruded + ), + fMesh, + model() + ) + ); + + + // Get the faces on front and back + frontPatchName = "originalPatch"; + frontPatchFaces = patchFaces + ( + meshFromSurface().boundaryMesh(), + frontPatchName + ); + backPatchName = "otherSide"; + backPatchFaces = patchFaces + ( + meshFromSurface().boundaryMesh(), + backPatchName + ); } - Info<< "Extruding patch with :" << nl - << " points : " << fMesh().points().size() << nl - << " faces : " << fMesh().size() << nl - << " normals[0] : " << fMesh().faceNormals()[0] - << nl - << endl; - - extrudedMesh mesh + polyMesh& mesh = ( - IOobject - ( - extrudedMesh::defaultRegion, - runTimeExtruded.constant(), - runTimeExtruded - ), - fMesh(), - model() + meshFromMesh.valid() + ? meshFromMesh() + : meshFromSurface() ); @@ -184,17 +500,6 @@ int main(int argc, char *argv[]) << "Merge distance : " << mergeDim << nl << endl; - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - const label origPatchID = patches.findPatchID("originalPatch"); - const label otherPatchID = patches.findPatchID("otherSide"); - - if (origPatchID == -1 || otherPatchID == -1) - { - FatalErrorIn(args.executable()) - << "Cannot find patch originalPatch or otherSide." << nl - << "Valid patches are " << patches.names() << exit(FatalError); - } // Collapse edges // ~~~~~~~~~~~~~~ @@ -237,6 +542,10 @@ int main(int argc, char *argv[]) // Update fields mesh.updateMesh(map); + // Update stored data + updateFaceLabels(map(), frontPatchFaces); + updateFaceLabels(map(), backPatchFaces); + // Move mesh (if inflation used) if (map().hasMotionPoints()) { @@ -252,22 +561,33 @@ int main(int argc, char *argv[]) Switch mergeFaces(dict.lookup("mergeFaces")); if (mergeFaces) { + if (mode == MESH) + { + FatalErrorIn(args.executable()) + << "Cannot stitch front and back of extrusion since" + << " in 'mesh' mode (extrusion appended to mesh)." + << exit(FatalError); + } + Info<< "Assuming full 360 degree axisymmetric case;" << " stitching faces on patches " - << patches[origPatchID].name() << " and " - << patches[otherPatchID].name() << " together ..." << nl << endl; + << frontPatchName << " and " + << backPatchName << " together ..." << nl << endl; + + if (frontPatchFaces.size() != backPatchFaces.size()) + { + FatalErrorIn(args.executable()) + << "Differing number of faces on front (" + << frontPatchFaces.size() << ") and back (" + << backPatchFaces.size() << ")" + << exit(FatalError); + } + + polyTopoChanger stitcher(mesh); stitcher.setSize(1); - // Make list of masterPatch faces - labelList isf(patches[origPatchID].size()); - - forAll (isf, i) - { - isf[i] = patches[origPatchID].start() + i; - } - const word cutZoneName("originalCutFaceZone"); List fz @@ -276,8 +596,8 @@ int main(int argc, char *argv[]) new faceZone ( cutZoneName, - isf, - boolList(isf.size(), false), + frontPatchFaces, + boolList(frontPatchFaces.size(), false), 0, mesh.faceZones() ) @@ -286,26 +606,58 @@ int main(int argc, char *argv[]) mesh.addZones(List(0), fz, List(0)); // Add the perfect interface mesh modifier - stitcher.set + perfectInterface perfectStitcher ( + "couple", 0, - new perfectInterface - ( - "couple", - 0, - stitcher, - cutZoneName, - patches[origPatchID].name(), - patches[otherPatchID].name() - ) + stitcher, + cutZoneName, + word::null, // dummy patch name + word::null // dummy patch name ); - // Execute all polyMeshModifiers - autoPtr morphMap = stitcher.changeMesh(true); + // Topo change container + polyTopoChange meshMod(mesh); - mesh.movePoints(morphMap->preMotionPoints()); + perfectStitcher.setRefinement + ( + indirectPrimitivePatch + ( + IndirectList + ( + mesh.faces(), + frontPatchFaces + ), + mesh.points() + ), + indirectPrimitivePatch + ( + IndirectList + ( + mesh.faces(), + backPatchFaces + ), + mesh.points() + ), + meshMod + ); + + // Construct new mesh from polyTopoChange. + autoPtr map = meshMod.changeMesh(mesh, false); + + // Update fields + mesh.updateMesh(map); + + // Move mesh (if inflation used) + if (map().hasMotionPoints()) + { + mesh.movePoints(map().preMotionPoints()); + } } + mesh.setInstance(runTimeExtruded.constant()); + Info<< "Writing mesh to " << mesh.objectPath() << nl << endl; + if (!mesh.write()) { FatalErrorIn(args.executable()) << "Failed writing mesh" diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C index 7305431b96..5550c56b15 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C @@ -43,6 +43,7 @@ Foam::extrudeModel::extrudeModel ) : nLayers_(readLabel(dict.lookup("nLayers"))), + expansionRatio_(readScalar(dict.lookup("expansionRatio"))), dict_(dict), coeffDict_(dict.subDict(modelType + "Coeffs")) {} @@ -62,5 +63,28 @@ Foam::label Foam::extrudeModel::nLayers() const } +Foam::scalar Foam::extrudeModel::expansionRatio() const +{ + return expansionRatio_; +} + + +Foam::scalar Foam::extrudeModel::sumThickness(const label layer) const +{ + // 1+r+r^2+ .. +r^(n-1) = (1-r^n)/(1-r) + + if (mag(1.0-expansionRatio_) < SMALL) + { + return scalar(layer)/nLayers_; + } + else + { + return + (1.0-pow(expansionRatio_, layer)) + / (1.0-pow(expansionRatio_, nLayers_)); + } +} + + // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H index d8f3699fd5..ac96bbeea6 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H @@ -58,6 +58,8 @@ protected: const label nLayers_; + const scalar expansionRatio_; + const dictionary& dict_; const dictionary& coeffDict_; @@ -113,9 +115,15 @@ public: label nLayers() const; + scalar expansionRatio() const; + // Member Operators + //- Helper: calculate cumulative relative thickness for layer. + // (layer=0 -> 0; layer=nLayers -> 1) + scalar sumThickness(const label layer) const; + virtual point operator() ( const point& surfacePoint, diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C index c36098ab1e..cd42e91816 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C @@ -72,7 +72,8 @@ point linearNormal::operator() const label layer ) const { - scalar d = thickness_*layer/nLayers_; + //scalar d = thickness_*layer/nLayers_; + scalar d = thickness_*sumThickness(layer); return surfacePoint + d*surfaceNormal; } diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H index 949547311b..2dbcdccb16 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H @@ -64,7 +64,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary linearNormal(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C index e8d406b110..7d4fcff9ba 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C @@ -67,8 +67,7 @@ point linearRadial::operator() scalar rs = mag(surfacePoint); vector rsHat = surfacePoint/rs; - scalar delta = (R_ - rs)/nLayers_; - scalar r = rs + layer*delta; + scalar r = rs + (R_ - rs)*sumThickness(layer); return r*rsHat; } diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H index 0fda12e1b1..66758c1b12 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H @@ -61,7 +61,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary linearRadial(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C index fc6f040305..d35ad4e539 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C @@ -49,7 +49,13 @@ sigmaRadial::sigmaRadial(const dictionary& dict) RTbyg_(readScalar(coeffDict_.lookup("RTbyg"))), pRef_(readScalar(coeffDict_.lookup("pRef"))), pStrat_(readScalar(coeffDict_.lookup("pStrat"))) -{} +{ + if (mag(expansionRatio() - 1.0) > SMALL) + { + WarningIn("sigmaRadial::sigmaRadial(const dictionary&)") + << "Ignoring expansionRatio setting." << endl; + } +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H index 525e89d11c..c74ad02457 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H @@ -63,7 +63,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary sigmaRadial(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C index 3d2c883ea1..5d0a3621b4 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C @@ -88,8 +88,8 @@ point wedge::operator() } else { - //sliceAngle = angle_*(layer + 1)/nLayers_; - sliceAngle = angle_*layer/nLayers_; + //sliceAngle = angle_*layer/nLayers_; + sliceAngle = angle_*sumThickness(layer); } // Find projection onto axis (or rather decompose surfacePoint diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H index 39c4b4a2d3..18707c32d1 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H @@ -77,7 +77,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary wedge(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties b/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties index 45618034de..e1283ab8b5 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties @@ -14,24 +14,28 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Where to get surface from: either from surface ('surface') or -// from (flipped) patch of existing case ('patch') -constructFrom patch; //surface; +// What to extrude: +// patch : from patch of another case ('sourceCase') +// mesh : as above but with original case included +// surface : from externally read surface -// If construct from (flipped) patch -sourceCase "$FOAM_RUN/icoFoam/cavity"; +//constructFrom mesh; +constructFrom patch; +//constructFrom surface; + +// If construct from patch/mesh: +sourceCase "../cavity"; sourcePatch movingWall; +// If construct from patch: patch to use for back (can be same as sourcePatch) +exposedPatchName movingWall; +// If construct from surface: +surface "movingWall.stl"; + + // Flip surface normals before usage. flipNormals false; -// If construct from surface -surface "movingWall.sMesh"; - - -// Do front and back need to be merged? Usually only makes sense for 360 -// degree wedges. -mergeFaces true; //- Linear extrusion in point-normal direction @@ -46,11 +50,13 @@ extrudeModel wedge; //- Extrudes into sphere with grading according to pressure (atmospherics) //extrudeModel sigmaRadial; -nLayers 20; +nLayers 10; + +expansionRatio 1.0; //0.9; wedgeCoeffs { - axisPt (0 0.1 0); + axisPt (0 0.1 -0.05); axis (-1 0 0); angle 360; // For nLayers=1 assume symmetry so angle/2 on each side } @@ -73,5 +79,10 @@ sigmaRadialCoeffs } +// Do front and back need to be merged? Usually only makes sense for 360 +// degree wedges. +mergeFaces true; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/dynamicMesh/perfectInterface/perfectInterface.C b/src/dynamicMesh/perfectInterface/perfectInterface.C index 80c9ed6583..ee892b7e87 100644 --- a/src/dynamicMesh/perfectInterface/perfectInterface.C +++ b/src/dynamicMesh/perfectInterface/perfectInterface.C @@ -38,6 +38,7 @@ Description #include "polyModifyFace.H" #include "polyRemovePoint.H" #include "polyRemoveFace.H" +#include "indirectPrimitivePatch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -61,7 +62,7 @@ const Foam::scalar Foam::perfectInterface::tol_ = 1E-3; Foam::pointField Foam::perfectInterface::calcFaceCentres ( - const primitivePatch& pp + const indirectPrimitivePatch& pp ) { const pointField& points = pp.points(); @@ -155,6 +156,295 @@ bool Foam::perfectInterface::changeTopology() const } +void Foam::perfectInterface::setRefinement +( + const indirectPrimitivePatch& pp0, + const indirectPrimitivePatch& pp1, + polyTopoChange& ref +) const +{ + const polyMesh& mesh = topoChanger().mesh(); + + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + // Some aliases + const edgeList& edges0 = pp0.edges(); + const pointField& pts0 = pp0.localPoints(); + const pointField& pts1 = pp1.localPoints(); + const labelList& meshPts0 = pp0.meshPoints(); + const labelList& meshPts1 = pp1.meshPoints(); + + + // Get local dimension as fraction of minimum edge length + + scalar minLen = GREAT; + + forAll(edges0, edgeI) + { + minLen = min(minLen, edges0[edgeI].mag(pts0)); + } + scalar typDim = tol_*minLen; + + if (debug) + { + Pout<< "typDim:" << typDim << " edges0:" << edges0.size() + << " pts0:" << pts0.size() << " pts1:" << pts1.size() + << " pp0:" << pp0.size() << " pp1:" << pp1.size() << endl; + } + + + // Determine pointMapping in mesh point labels. Uses geometric + // comparison to find correspondence between patch points. + + labelList renumberPoints(mesh.points().size()); + forAll(renumberPoints, i) + { + renumberPoints[i] = i; + } + { + labelList from1To0Points(pts1.size()); + + bool matchOk = matchPoints + ( + pts1, + pts0, + scalarField(pts1.size(), typDim), // tolerance + true, // verbose + from1To0Points + ); + + if (!matchOk) + { + FatalErrorIn + ( + "perfectInterface::setRefinement(polyTopoChange& ref) const" + ) << "Points on patch sides do not match to within tolerance " + << typDim << exit(FatalError); + } + + forAll(pts1, i) + { + renumberPoints[meshPts1[i]] = meshPts0[from1To0Points[i]]; + } + } + + + + // Calculate correspondence between patch faces + + labelList from0To1Faces(pp1.size()); + + bool matchOk = matchPoints + ( + calcFaceCentres(pp0), + calcFaceCentres(pp1), + scalarField(pp0.size(), typDim), // tolerance + true, // verbose + from0To1Faces + ); + + if (!matchOk) + { + FatalErrorIn + ( + "perfectInterface::setRefinement(polyTopoChange& ref) const" + ) << "Face centres of patch sides do not match to within tolerance " + << typDim << exit(FatalError); + } + + + + // Now + // - renumber faces using pts1 (except patch1 faces) + // - remove patch1 faces. Remember cell label on owner side. + // - modify patch0 faces to be internal. + + // 1. Get faces to be renumbered + labelHashSet affectedFaces(2*pp1.size()); + forAll(meshPts1, i) + { + label meshPointI = meshPts1[i]; + + if (meshPointI != renumberPoints[meshPointI]) + { + const labelList& pFaces = mesh.pointFaces()[meshPointI]; + + forAll(pFaces, pFaceI) + { + affectedFaces.insert(pFaces[pFaceI]); + } + } + } + forAll(pp1, i) + { + affectedFaces.erase(pp1.addressing()[i]); + } + // Remove patch0 from renumbered faces. Should not be nessecary since + // patch0 and 1 should not share any point (if created by mergeMeshing) + // so affectedFaces should not contain any patch0 faces but you can + // never be sure what the user is doing. + forAll(pp0, i) + { + label faceI = pp0.addressing()[i]; + + if (affectedFaces.erase(faceI)) + { + WarningIn + ( + "perfectInterface::setRefinement(polyTopoChange&) const" + ) << "Found face " << faceI << " vertices " + << mesh.faces()[faceI] << " whose points are" + << " used both by master patch and slave patch" << endl; + } + } + + + // 2. Renumber (non patch0/1) faces. + for + ( + labelHashSet::const_iterator iter = affectedFaces.begin(); + iter != affectedFaces.end(); + ++iter + ) + { + label faceI = iter.key(); + + const face& f = mesh.faces()[faceI]; + + face newFace(f.size()); + + forAll(newFace, fp) + { + newFace[fp] = renumberPoints[f[fp]]; + } + + label nbr = -1; + + label patchI = -1; + + if (mesh.isInternalFace(faceI)) + { + nbr = mesh.faceNeighbour()[faceI]; + } + else + { + patchI = patches.whichPatch(faceI); + } + + label zoneID = mesh.faceZones().whichZone(faceI); + + bool zoneFlip = false; + + if (zoneID >= 0) + { + const faceZone& fZone = mesh.faceZones()[zoneID]; + + zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)]; + } + + ref.setAction + ( + polyModifyFace + ( + newFace, // modified face + faceI, // label of face being modified + mesh.faceOwner()[faceI], // owner + nbr, // neighbour + false, // face flip + patchI, // patch for face + false, // remove from zone + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + } + + + // 3. Remove patch1 points + forAll(meshPts1, i) + { + label meshPointI = meshPts1[i]; + + if (meshPointI != renumberPoints[meshPointI]) + { + ref.setAction(polyRemovePoint(meshPointI)); + } + } + + + // 4. Remove patch1 faces + forAll(pp1, i) + { + label faceI = pp1.addressing()[i]; + ref.setAction(polyRemoveFace(faceI)); + } + + + // 5. Modify patch0 faces for new points (not really nessecary; see + // comment above about patch1 and patch0 never sharing points) and + // becoming internal. + const boolList& mfFlip = + mesh.faceZones()[faceZoneID_.index()].flipMap(); + + forAll(pp0, i) + { + label faceI = pp0.addressing()[i]; + + const face& f = mesh.faces()[faceI]; + + face newFace(f.size()); + + forAll(newFace, fp) + { + newFace[fp] = renumberPoints[f[fp]]; + } + + label own = mesh.faceOwner()[faceI]; + + label pp1FaceI = pp1.addressing()[from0To1Faces[i]]; + + label nbr = mesh.faceOwner()[pp1FaceI]; + + if (own < nbr) + { + ref.setAction + ( + polyModifyFace + ( + newFace, // modified face + faceI, // label of face being modified + own, // owner + nbr, // neighbour + false, // face flip + -1, // patch for face + false, // remove from zone + faceZoneID_.index(), // zone for face + mfFlip[i] // face flip in zone + ) + ); + } + else + { + ref.setAction + ( + polyModifyFace + ( + newFace.reverseFace(), // modified face + faceI, // label of face being modified + nbr, // owner + own, // neighbour + true, // face flip + -1, // patch for face + false, // remove from zone + faceZoneID_.index(), // zone for face + !mfFlip[i] // face flip in zone + ) + ); + } + } +} + + void Foam::perfectInterface::setRefinement(polyTopoChange& ref) const { if (debug) @@ -176,286 +466,25 @@ void Foam::perfectInterface::setRefinement(polyTopoChange& ref) const const polyMesh& mesh = topoChanger().mesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - const polyPatch& pp0 = patches[masterPatchID_.index()]; - const polyPatch& pp1 = patches[slavePatchID_.index()]; - - // Some aliases - const edgeList& edges0 = pp0.edges(); - const pointField& pts0 = pp0.localPoints(); - const pointField& pts1 = pp1.localPoints(); - const labelList& meshPts0 = pp0.meshPoints(); - const labelList& meshPts1 = pp1.meshPoints(); - - - // Get local dimension as fraction of minimum edge length - - scalar minLen = GREAT; - - forAll(edges0, edgeI) - { - minLen = min(minLen, edges0[edgeI].mag(pts0)); - } - scalar typDim = tol_*minLen; - - if (debug) - { - Pout<< "typDim:" << typDim << " edges0:" << edges0.size() - << " pts0:" << pts0.size() << " pts1:" << pts1.size() - << " pp0:" << pp0.size() << " pp1:" << pp1.size() << endl; - } + const polyPatch& patch0 = patches[masterPatchID_.index()]; + const polyPatch& patch1 = patches[slavePatchID_.index()]; - // Determine pointMapping in mesh point labels. Uses geometric - // comparison to find correspondence between patch points. - - labelList renumberPoints(mesh.points().size()); - forAll(renumberPoints, i) - { - renumberPoints[i] = i; - } - { - labelList from1To0Points(pts1.size()); - - bool matchOk = matchPoints - ( - pts1, - pts0, - scalarField(pts1.size(), typDim), // tolerance - true, // verbose - from1To0Points - ); - - if (!matchOk) - { - FatalErrorIn - ( - "perfectInterface::setRefinement(polyTopoChange& ref) const" - ) << "Points on patches " << pp0.name() << " and " - << pp1.name() << " do not match to within tolerance " - << typDim << exit(FatalError); - } - - forAll(pts1, i) - { - renumberPoints[meshPts1[i]] = meshPts0[from1To0Points[i]]; - } - } - - - - // Calculate correspondence between patch faces - - labelList from0To1Faces(pp1.size()); - - bool matchOk = matchPoints + labelList pp0Labels(identity(patch0.size())+patch0.start()); + indirectPrimitivePatch pp0 ( - calcFaceCentres(pp0), - calcFaceCentres(pp1), - scalarField(pp0.size(), typDim), // tolerance - true, // verbose - from0To1Faces + IndirectList(mesh.faces(), pp0Labels), + mesh.points() ); - if (!matchOk) - { - FatalErrorIn - ( - "perfectInterface::setRefinement(polyTopoChange& ref) const" - ) << "Face centres of patches " << pp0.name() << " and " - << pp1.name() << " do not match to within tolerance " << typDim - << exit(FatalError); - } - - - - // Now - // - renumber faces using pts1 (except patch1 faces) - // - remove patch1 faces. Remember cell label on owner side. - // - modify patch0 faces to be internal. - - // 1. Get faces to be renumbered - labelHashSet affectedFaces(2*pp1.size()); - forAll(meshPts1, i) - { - label meshPointI = meshPts1[i]; - - if (meshPointI != renumberPoints[meshPointI]) - { - const labelList& pFaces = mesh.pointFaces()[meshPointI]; - - forAll(pFaces, pFaceI) - { - affectedFaces.insert(pFaces[pFaceI]); - } - } - } - forAll(pp1, i) - { - affectedFaces.erase(pp1.start() + i); - } - // Remove patch0 from renumbered faces. Should not be nessecary since - // patch0 and 1 should not share any point (if created by mergeMeshing) - // so affectedFaces should not contain any patch0 faces but you can - // never be sure what the user is doing. - forAll(pp0, i) - { - if (affectedFaces.erase(pp0.start() + i)) - { - WarningIn - ( - "perfectInterface::setRefinement(polyTopoChange&) const" - ) << "Found face " << pp0.start() + i << " vertices " - << mesh.faces()[pp0.start() + i] << " whose points are" - << " used both by master patch " << pp0.name() - << " and slave patch " << pp1.name() - << endl; - } - } - - - // 2. Renumber (non patch0/1) faces. - for + labelList pp1Labels(identity(patch1.size())+patch1.start()); + indirectPrimitivePatch pp1 ( - labelHashSet::const_iterator iter = affectedFaces.begin(); - iter != affectedFaces.end(); - ++iter - ) - { - label faceI = iter.key(); + IndirectList(mesh.faces(), pp1Labels), + mesh.points() + ); - const face& f = mesh.faces()[faceI]; - - face newFace(f.size()); - - forAll(newFace, fp) - { - newFace[fp] = renumberPoints[f[fp]]; - } - - label nbr = -1; - - label patchI = -1; - - if (mesh.isInternalFace(faceI)) - { - nbr = mesh.faceNeighbour()[faceI]; - } - else - { - patchI = patches.whichPatch(faceI); - } - - label zoneID = mesh.faceZones().whichZone(faceI); - - bool zoneFlip = false; - - if (zoneID >= 0) - { - const faceZone& fZone = mesh.faceZones()[zoneID]; - - zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)]; - } - - ref.setAction - ( - polyModifyFace - ( - newFace, // modified face - faceI, // label of face being modified - mesh.faceOwner()[faceI], // owner - nbr, // neighbour - false, // face flip - patchI, // patch for face - false, // remove from zone - zoneID, // zone for face - zoneFlip // face flip in zone - ) - ); - } - - - // 3. Remove patch1 points - forAll(meshPts1, i) - { - label meshPointI = meshPts1[i]; - - if (meshPointI != renumberPoints[meshPointI]) - { - ref.setAction(polyRemovePoint(meshPointI)); - } - } - - - // 4. Remove patch1 faces - forAll(pp1, i) - { - ref.setAction(polyRemoveFace(pp1.start() + i)); - } - - - // 5. Modify patch0 faces for new points (not really nessecary; see - // comment above about patch1 and patch0 never sharing points) and - // becoming internal. - const boolList& mfFlip = - mesh.faceZones()[faceZoneID_.index()].flipMap(); - - forAll(pp0, i) - { - label faceI = pp0.start() + i; - - const face& f = mesh.faces()[faceI]; - - face newFace(f.size()); - - forAll(newFace, fp) - { - newFace[fp] = renumberPoints[f[fp]]; - } - - label own = mesh.faceOwner()[faceI]; - - label pp1FaceI = pp1.start() + from0To1Faces[i]; - - label nbr = mesh.faceOwner()[pp1FaceI]; - - if (own < nbr) - { - ref.setAction - ( - polyModifyFace - ( - newFace, // modified face - faceI, // label of face being modified - own, // owner - nbr, // neighbour - false, // face flip - -1, // patch for face - false, // remove from zone - faceZoneID_.index(), // zone for face - mfFlip[i] // face flip in zone - ) - ); - } - else - { - ref.setAction - ( - polyModifyFace - ( - newFace.reverseFace(), // modified face - faceI, // label of face being modified - nbr, // owner - own, // neighbour - false, // face flip - -1, // patch for face - false, // remove from zone - faceZoneID_.index(), // zone for face - !mfFlip[i] // face flip in zone - ) - ); - } - } + setRefinement(pp0, pp1, ref); } } diff --git a/src/dynamicMesh/perfectInterface/perfectInterface.H b/src/dynamicMesh/perfectInterface/perfectInterface.H index 3916bb3e74..dec4f6a48d 100644 --- a/src/dynamicMesh/perfectInterface/perfectInterface.H +++ b/src/dynamicMesh/perfectInterface/perfectInterface.H @@ -40,6 +40,7 @@ SourceFiles #include "polyMeshModifier.H" #include "polyPatchID.H" #include "ZoneIDs.H" +#include "indirectPrimitivePatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,7 +76,7 @@ class perfectInterface // Private Member Functions //- Calculate face centres on patch - static pointField calcFaceCentres(const primitivePatch&); + static pointField calcFaceCentres(const indirectPrimitivePatch&); //- Disallow default bitwise copy construct @@ -128,6 +129,17 @@ public: // into the topological change virtual void setRefinement(polyTopoChange&) const; + //- Insert the layer addition/removal instructions + // into the topological change. Uses only mesh, not any of the + // patch and zone indices. Bit of a workaround - used in extruding + // a mesh. + virtual void setRefinement + ( + const indirectPrimitivePatch& pp0, + const indirectPrimitivePatch& pp1, + polyTopoChange& + ) const; + //- Modify motion points to comply with the topological change virtual void modifyMotionPoints(pointField& motionPoints) const; diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index c3b104134c..1a725f0ebf 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -558,6 +558,7 @@ void Foam::addPatchCellLayer::setRefinement ( const scalarField& expansionRatio, const indirectPrimitivePatch& pp, + const labelList& exposedPatchID, const labelList& nFaceLayers, const labelList& nPointLayers, const vectorField& firstLayerDisp, @@ -973,11 +974,6 @@ void Foam::addPatchCellLayer::setRefinement ownZoneI // zone for cell ) ); - - //Pout<< "For patchFace:" << patchFaceI - // << " meshFace:" << pp.addressing()[patchFaceI] - // << " layer:" << i << " added cell:" - // << addedCells[patchFaceI][i] << endl; } } } @@ -998,7 +994,6 @@ void Foam::addPatchCellLayer::setRefinement if (addedCells[patchFaceI].size()) { layerFaces_[patchFaceI].setSize(addedCells[patchFaceI].size() + 1); - layerFaces_[patchFaceI][0] = meshFaceI; label zoneI = mesh_.faceZones().whichZone(meshFaceI); @@ -1059,18 +1054,13 @@ void Foam::addPatchCellLayer::setRefinement nei, // neighbour -1, // master point -1, // master edge - meshFaceI, // master face for addition + (addToMesh_ ? meshFaceI : -1), // master face false, // flux flip patchI, // patch for face zoneI, // zone for face false // face zone flip ) ); - //Pout<< "Added inbetween face " << newFace - // << " own:" << addedCells[patchFaceI][i] - // << " nei:" << nei - // << " patch:" << patchI - // << endl; } } } @@ -1079,7 +1069,6 @@ void Foam::addPatchCellLayer::setRefinement // Modify old patch faces to be on the inside // - labelList copiedPatchFaces; if (addToMesh_) { forAll(pp, patchFaceI) @@ -1088,6 +1077,8 @@ void Foam::addPatchCellLayer::setRefinement { label meshFaceI = pp.addressing()[patchFaceI]; + layerFaces_[patchFaceI][0] = meshFaceI; + label zoneI = mesh_.faceZones().whichZone(meshFaceI); meshMod.setAction @@ -1105,17 +1096,13 @@ void Foam::addPatchCellLayer::setRefinement false // face flip in zone ) ); - //Pout<< "Modified old patch face " << meshFaceI - // << " own:" << mesh_.faceOwner()[meshFaceI] - // << " nei:" << addedCells[patchFaceI][0] - // << endl; } } } else { - // If creating new mesh: copy existing patch points - copiedPatchFaces.setSize(pp.size()); + // If creating new mesh: reverse original faces and put them + // in the exposed patch ID. forAll(pp, patchFaceI) { if (nFaceLayers[patchFaceI] > 0) @@ -1136,7 +1123,7 @@ void Foam::addPatchCellLayer::setRefinement f[fp] = copiedPatchPoints[f[fp]]; } - copiedPatchFaces[patchFaceI] = meshMod.setAction + layerFaces_[patchFaceI][0] = meshMod.setAction ( polyAddFace ( @@ -1147,7 +1134,7 @@ void Foam::addPatchCellLayer::setRefinement -1, // masterEdge -1, // masterFace true, // face flip - patchID[patchFaceI], // patch for face + exposedPatchID[patchFaceI], // patch for face zoneI, // zone for face zoneFlip // face flip in zone ) @@ -1158,7 +1145,6 @@ void Foam::addPatchCellLayer::setRefinement - // // Create 'side' faces, one per edge that is being extended. // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H index f950ca2619..f4b5bb2e79 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H @@ -295,8 +295,10 @@ public: //- Play commands into polyTopoChange to create layers on top // of indirectPrimitivePatch (have to be outside faces). // Gets displacement per patch point. - // - nPointLayers : number of layers per (patch)point - // - nFaceLayers : number of layers per (patch) face + // - exposedPatchID : only used if creating a new mesh (addToMesh=false) + // gives per pp face the patch the exposed face should get. + // - nPointLayers : number of layers per (patch)point. + // - nFaceLayers : number of layers per (patch) face. // - firstDisplacement : displacement per point for first // layer of points (i.e. nearest to original mesh). If zero // do not add point. @@ -309,14 +311,15 @@ public: // get a cell should firstDisplacement be <> 0 // Note: cells get added from owner cells of patch faces // (instead of e.g. from patch faces) - void setRefinement - ( - const scalarField& expansionRatio, - const indirectPrimitivePatch& pp, - const labelList& nFaceLayers, - const labelList& nPointLayers, - const vectorField& firstLayerDisp, - polyTopoChange& meshMod + void setRefinement + ( + const scalarField& expansionRatio, + const indirectPrimitivePatch& pp, + const labelList& exposedPatchID, + const labelList& nFaceLayers, + const labelList& nPointLayers, + const vectorField& firstLayerDisp, + polyTopoChange& meshMod ); @@ -333,6 +336,7 @@ public: ( scalarField(pp.nPoints(), 1.0), // expansion ration pp, + labelList(0), labelList(pp.size(), nLayers), labelList(pp.nPoints(), nLayers), overallDisplacement / nLayers, diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 849481c2eb..6b1874dc4b 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -749,6 +749,11 @@ void Foam::polyTopoChange::getFaceOrder " const" ) << "Did not determine new position" << " for face " << faceI + << " owner " << faceOwner_[faceI] + << " neighbour " << faceNeighbour_[faceI] + << " region " << region_[faceI] << endl + << "This is usually caused by not specifying a patch for" + << " a boundary face." << abort(FatalError); } } From 77a08ec13187b4de3244149634a002d7c7864795 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 24 Aug 2009 16:20:31 +0100 Subject: [PATCH 11/30] added field face/cell values function objects --- .../field/fieldValues/Make/files | 9 + .../field/fieldValues/Make/options | 9 + .../field/fieldValues/cell/IOcellSource.H | 51 +++ .../field/fieldValues/cell/cellSource.C | 257 ++++++++++++ .../field/fieldValues/cell/cellSource.H | 227 +++++++++++ .../cell/cellSourceFunctionObject.C | 47 +++ .../cell/cellSourceFunctionObject.H | 55 +++ .../field/fieldValues/cell/cellSourceI.H | 46 +++ .../fieldValues/cell/cellSourceTemplates.C | 175 +++++++++ .../field/fieldValues/controlDict | 108 +++++ .../field/fieldValues/face/IOfaceSource.H | 51 +++ .../field/fieldValues/face/faceSource.C | 368 ++++++++++++++++++ .../field/fieldValues/face/faceSource.H | 252 ++++++++++++ .../face/faceSourceFunctionObject.C | 47 +++ .../face/faceSourceFunctionObject.H | 55 +++ .../field/fieldValues/face/faceSourceI.H | 60 +++ .../fieldValues/face/faceSourceTemplates.C | 269 +++++++++++++ .../field/fieldValues/fieldValue/fieldValue.C | 177 +++++++++ .../field/fieldValues/fieldValue/fieldValue.H | 165 ++++++++ 19 files changed, 2428 insertions(+) create mode 100644 src/postProcessing/functionObjects/field/fieldValues/Make/files create mode 100644 src/postProcessing/functionObjects/field/fieldValues/Make/options create mode 100644 src/postProcessing/functionObjects/field/fieldValues/cell/IOcellSource.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceI.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/controlDict create mode 100644 src/postProcessing/functionObjects/field/fieldValues/face/IOfaceSource.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/face/faceSource.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/face/faceSource.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/face/faceSourceI.H create mode 100644 src/postProcessing/functionObjects/field/fieldValues/face/faceSourceTemplates.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C create mode 100644 src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/Make/files b/src/postProcessing/functionObjects/field/fieldValues/Make/files new file mode 100644 index 0000000000..66028b4812 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/Make/files @@ -0,0 +1,9 @@ +fieldValue/fieldValue.C + +face/faceSource.C +face/faceSourceFunctionObject.C + +cell/cellSource.C +cell/cellSourceFunctionObject.C + +LIB = $(FOAM_LIBBIN)/libfieldValueFunctionObjects diff --git a/src/postProcessing/functionObjects/field/fieldValues/Make/options b/src/postProcessing/functionObjects/field/fieldValues/Make/options new file mode 100644 index 0000000000..5166bcc9e3 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -lsampling diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/IOcellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cell/IOcellSource.H new file mode 100644 index 0000000000..b116bb96fd --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/IOcellSource.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Typedef + Foam::IOcellSource + + +Description + Instance of the generic IOOutputFilter for cellSource. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOcellSource_H +#define IOcellSource_H + +#include "cellSource.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter IOcellSource; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.C new file mode 100644 index 0000000000..5e63d1287a --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.C @@ -0,0 +1,257 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cellSource.H" +#include "fvMesh.H" +#include "volFields.H" +#include "IOList.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace fieldValues + { + defineTypeNameAndDebug(cellSource, 0); + } + + template<> + const char* NamedEnum:: + names[] = {"cellZone"}; + + const NamedEnum + fieldValues::cellSource::sourceTypeNames_; + + template<> + const char* NamedEnum:: + names[] = {"none", "sum", "volAverage", "volIntegrate"}; + + const NamedEnum + fieldValues::cellSource::operationTypeNames_; + +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::fieldValues::cellSource::setCellZoneCells() +{ + label zoneId = mesh().cellZones().findZoneID(sourceName_); + + if (zoneId < 0) + { + FatalErrorIn("cellSource::cellSource::setCellZoneCells()") + << "Unknown cell zone name: " << sourceName_ + << ". Valid cell zones are: " << mesh().cellZones().names() + << nl << exit(FatalError); + } + + const cellZone& cZone = mesh().cellZones()[zoneId]; + + cellId_.setSize(cZone.size()); + + label count = 0; + forAll(cZone, i) + { + label cellI = cZone[i]; + cellId_[count] = cellI; + count++; + } + + cellId_.setSize(count); + + if (debug) + { + Info<< "Original cell zone size = " << cZone.size() + << ", new size = " << count << endl; + } +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::fieldValues::cellSource::initialise() +{ + switch (source_) + { + case stCellZone: + { + setCellZoneCells(); + break; + } + default: + { + FatalErrorIn("cellSource::constructCellAddressing()") + << "Unknown source type. Valid source types are:" + << sourceTypeNames_ << nl << exit(FatalError); + } + } + + Info<< type() << " " << name_ << ":" << nl + << " total cells = " << cellId_.size() << nl + << " total volume = " << sum(filterField(mesh().V())) + << nl << endl; +} + + +void Foam::fieldValues::cellSource::makeFile() +{ + // Create the forces file if not already created + if (outputFilePtr_.empty()) + { + if (debug) + { + Info<< "Creating output file." << endl; + } + + // File update + if (Pstream::master()) + { + fileName outputDir; + if (Pstream::parRun()) + { + // Put in undecomposed case (Note: gives problems for + // distributed data running) + outputDir = + obr_.time().path()/".."/name_/obr_.time().timeName(); + } + else + { + outputDir = obr_.time().path()/name_/obr_.time().timeName(); + } + + // Create directory if does not exist + mkDir(outputDir); + + // Open new file at start up + outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat"))); + + // Add headers to output data + writeFileHeader(); + } + } +} + + +void Foam::fieldValues::cellSource::writeFileHeader() +{ + if (outputFilePtr_.valid()) + { + outputFilePtr_() + << "# Source : " << sourceTypeNames_[source_] << " " + << sourceName_ << nl << "# Cells : " << cellId_.size() << nl + << "# Time" << tab << "sum(V)"; + + forAll(fields_, i) + { + outputFilePtr_() + << tab << operationTypeNames_[operation_] + << "(" << fields_[i] << ")"; + } + + outputFilePtr_() << endl; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldValues::cellSource::cellSource +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + fieldValue(name, obr, dict, loadFromFiles), + source_(sourceTypeNames_.read(dict.lookup("source"))), + operation_(operationTypeNames_.read(dict.lookup("operation"))), + cellId_(), + outputFilePtr_(NULL) +{ + initialise(); + + if (active_) + { + // Create the output file if not already created + makeFile(); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fieldValues::cellSource::~cellSource() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fieldValues::cellSource::read(const dictionary& dict) +{ + if (active_) + { + fieldValue::read(dict); + initialise(); + } +} + + +void Foam::fieldValues::cellSource::write() +{ + if (active_) + { + if (log_) + { + Info<< type() << " " << name_ << " output:" << nl; + } + + outputFilePtr_() + << obr_.time().value() << tab + << sum(filterField(mesh().V())); + + forAll(fields_, i) + { + writeValues(fields_[i]); + writeValues(fields_[i]); + writeValues(fields_[i]); + writeValues(fields_[i]); + writeValues(fields_[i]); + } + + outputFilePtr_()<< endl; + + if (log_) + { + Info<< endl; + } + } +} + + +// ************************************************************************* // + diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.H new file mode 100644 index 0000000000..d1d08cdbd9 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.H @@ -0,0 +1,227 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::fieldValues::cellSource + +Description + Cell source variant of field value function object. Values of user- + specified fields reported for collections of cells. + + cellObj1 // Name also used to identify output folder + { + type cellSource; + functionObjectLibs ("libfieldValueFunctionObjects.so"); + enabled true; + outputControl outputTime; + log true; // log to screen? + valueOutput true; // Write values at run-time output times? + source cellZone; // Type of cell source + sourceName c0; + operation volAverage; // none, sum, volAverage, volIntegrate + fields + ( + p + U + ); + } + +SourceFiles + cellSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cellSource_H +#define cellSource_H + +#include "NamedEnum.H" +#include "fieldValue.H" +#include "labelList.H" +#include "OFstream.H" +#include "volFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fieldValues +{ + +/*---------------------------------------------------------------------------*\ + Class cellSource Declaration +\*---------------------------------------------------------------------------*/ + +class cellSource +: + public fieldValue +{ + +public: + + // Public data types + + //- Source type enumeration + enum sourceType + { + stCellZone + }; + + //- Source type names + static const NamedEnum sourceTypeNames_; + + + //- Operation type enumeration + enum operationType + { + opNone, + opSum, + opVolAverage, + opVolIntegrate + }; + + //- Operation type names + static const NamedEnum operationTypeNames_; + + +private: + + // Private member functions + + //- Set cells to evaluate based on a cell zone + void setCellZoneCells(); + + //- Set cells to evaluate based on a patch + void setPatchCells(); + + //- Create the output file if not already created + void makeFile(); + + +protected: + + // Protected data + + //- Source type + sourceType source_; + + //- Operation to apply to values + operationType operation_; + + //- Local list of cell IDs + labelList cellId_; + + //- Output file pointer + autoPtr outputFilePtr_; + + + // Protected member functions + + //- Initialise, e.g. cell addressing + void initialise(); + + //- Insert field values into values list + template + bool setFieldValues + ( + const word& fieldName, + List& values + ) const; + + //- Apply the 'operation' to the values + template + Type processValues(const List& values) const; + + //- Output file header information + virtual void writeFileHeader(); + + +public: + + //- Run-time type information + TypeName("cellSource"); + + + //- Construct from components + cellSource + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~cellSource(); + + + // Public member functions + + // Access + + //- Return the source type + inline const sourceType& source() const; + + //- Return the local list of cell IDs + inline const labelList& cellId() const; + + + // Function object functions + + //- Read from dictionary + virtual void read(const dictionary&); + + //- Calculate and write + virtual void write(); + + //- Templated helper function to output field values + template + bool writeValues(const word& fieldName); + + //- Filter a field according to cellIds + template + tmp > filterField(const Field& field) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fieldValues +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "cellSourceI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "cellSourceTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.C new file mode 100644 index 0000000000..24f4b7bbb8 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.C @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cellSourceFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug + ( + cellSourceFunctionObject, + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + cellSourceFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.H new file mode 100644 index 0000000000..eca172a58d --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.H @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Typedef + Foam::cellSourceFunctionObject + +Description + FunctionObject wrapper around cellSource to allow it to be + created via the functions list within controlDict. + +SourceFiles + cellSourceFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cellSourceFunctionObject_H +#define cellSourceFunctionObject_H + +#include "cellSource.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject + cellSourceFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceI.H b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceI.H new file mode 100644 index 0000000000..b86462d2cc --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceI.H @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cellSource.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::fieldValues::cellSource::sourceType& +Foam::fieldValues::cellSource::source() const +{ + return source_; +} + + +inline const Foam::labelList& +Foam::fieldValues::cellSource::cellId() const +{ + return cellId_; +} + + +// ************************************************************************* // + diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C new file mode 100644 index 0000000000..0b6fa1ff03 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cellSource.H" +#include "volFields.H" +#include "IOList.H" +#include "ListListOps.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +bool Foam::fieldValues::cellSource::setFieldValues +( + const word& fieldName, + List& values +) const +{ + values.setSize(cellId_.size(), pTraits::zero); + + typedef GeometricField vf; + + if (obr_.foundObject(fieldName)) + { + const vf& field = obr_.lookupObject(fieldName); + + forAll(values, i) + { + label cellI = cellId_[i]; + values[i] = field[cellI]; + } + + return true; + } + + return false; +} + + +template +Type Foam::fieldValues::cellSource::processValues +( + const List& values +) const +{ + Type result = pTraits::zero; + switch (operation_) + { + case opSum: + { + result = sum(values); + break; + } + case opVolAverage: + { + tmp V = filterField(mesh().V()); + result = sum(values*V())/sum(V()); + break; + } + case opVolIntegrate: + { + result = sum(values*filterField(mesh().V())); + break; + } + default: + { + // Do nothing + } + } + + return result; +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::fieldValues::cellSource::writeValues(const word& fieldName) +{ + List > allValues(Pstream::nProcs()); + + bool validField = + setFieldValues(fieldName, allValues[Pstream::myProcNo()]); + + if (validField) + { + Pstream::gatherList(allValues); + + if (Pstream::master()) + { + List values = + ListListOps::combine > + ( + allValues, + accessOp >() + ); + + Type result = processValues(values); + + if (valueOutput_) + { + IOList + ( + IOobject + ( + fieldName + "_" + sourceTypeNames_[source_] + "-" + + sourceName_, + obr_.time().timeName(), + obr_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + values + ).write(); + } + + + outputFilePtr_()<< tab << result; + + if (log_) + { + Info<< " " << operationTypeNames_[operation_] + << "(" << sourceName_ << ") for " << fieldName + << " = " << result << endl; + } + } + } + + return validField; +} + + +template +Foam::tmp > Foam::fieldValues::cellSource::filterField +( + const Field& field +) const +{ + tmp > tvalues(new Field(cellId_.size())); + Field& values = tvalues(); + + forAll(values, i) + { + label cellI = cellId_[i]; + values[i] = field[cellI]; + } + + return tvalues; +} + + +// ************************************************************************* // + diff --git a/src/postProcessing/functionObjects/field/fieldValues/controlDict b/src/postProcessing/functionObjects/field/fieldValues/controlDict new file mode 100644 index 0000000000..88ea120317 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/controlDict @@ -0,0 +1,108 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application icoFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.5; + +deltaT 0.005; + +writeControl timeStep; + +writeInterval 20; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +functions +( + faceObj1 + { + type faceSource; + functionObjectLibs ("libfieldValueFunctionObjects.so"); + enabled true; + outputControl outputTime; + log true; + valueOutput true; + source patch; + sourceName movingWall; +// source faceZone; +// sourceName f0; + operation areaAverage; + fields + ( + p + phi + U + ); + } + + faceObj2 + { + type faceSource; + functionObjectLibs ("libfieldValueFunctionObjects.so"); + enabled true; + outputControl outputTime; + log true; + valueOutput true; + source faceZone; + sourceName f0; + operation sum; + fields + ( + phi + ); + } + + cellObj1 + { + type cellSource; + functionObjectLibs ("libfieldValueFunctionObjects.so"); + enabled true; + outputControl outputTime; + log true; + valueOutput true; + source cellZone; + sourceName c0; + operation volAverage; + fields + ( + p + U + ); + } +); + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/IOfaceSource.H b/src/postProcessing/functionObjects/field/fieldValues/face/IOfaceSource.H new file mode 100644 index 0000000000..caca9968c6 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/face/IOfaceSource.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Typedef + Foam::IOfaceSource + + +Description + Instance of the generic IOOutputFilter for faceSource. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOfaceSource_H +#define IOfaceSource_H + +#include "faceSource.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter IOfaceSource; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.C new file mode 100644 index 0000000000..76c1ac9515 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.C @@ -0,0 +1,368 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "faceSource.H" +#include "fvMesh.H" +#include "cyclicPolyPatch.H" +#include "emptyPolyPatch.H" +#include "processorPolyPatch.H" +#include "surfaceFields.H" +#include "volFields.H" +#include "IOList.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace fieldValues + { + defineTypeNameAndDebug(faceSource, 0); + } + + template<> + const char* NamedEnum:: + names[] = {"faceZone", "patch"}; + + const NamedEnum + fieldValues::faceSource::sourceTypeNames_; + + template<> + const char* NamedEnum:: + names[] = {"none", "sum", "areaAverage", "areaIntegrate"}; + + const NamedEnum + fieldValues::faceSource::operationTypeNames_; + +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::fieldValues::faceSource::setFaceZoneFaces() +{ + label zoneId = mesh().faceZones().findZoneID(sourceName_); + + if (zoneId < 0) + { + FatalErrorIn("faceSource::faceSource::setFaceZoneFaces()") + << "Unknown face zone name: " << sourceName_ + << ". Valid face zones are: " << mesh().faceZones().names() + << nl << exit(FatalError); + } + + const faceZone& fZone = mesh().faceZones()[zoneId]; + + faceId_.setSize(fZone.size()); + facePatchId_.setSize(fZone.size()); + flipMap_.setSize(fZone.size()); + + label count = 0; + forAll(fZone, i) + { + label faceI = fZone[i]; + + label faceId = -1; + label facePatchId = -1; + if (mesh().isInternalFace(faceI)) + { + faceId = faceI; + facePatchId = -1; + } + else + { + facePatchId = mesh().boundaryMesh().whichPatch(faceI); + const polyPatch& pp = mesh().boundaryMesh()[facePatchId]; + if (isA(pp)) + { + if (refCast(pp).owner()) + { + faceId = pp.whichFace(faceI); + } + else + { + faceId = -1; + } + } + else if (isA(pp)) + { + label patchFaceI = faceI - pp.start(); + if (patchFaceI < pp.size()/2) + { + faceId = patchFaceI; + } + else + { + faceId = -1; + } + } + else if (!isA(pp)) + { + faceId = faceI - pp.start(); + } + else + { + faceId = -1; + facePatchId = -1; + } + } + + if (faceId >= 0) + { + if (fZone.flipMap()[i]) + { + flipMap_[count] = -1; + } + else + { + flipMap_[count] = 1; + } + faceId_[count] = faceId; + facePatchId_[count] = facePatchId; + count++; + } + } + + faceId_.setSize(count); + facePatchId_.setSize(count); + flipMap_.setSize(count); + + if (debug) + { + Info<< "Original face zone size = " << fZone.size() + << ", new size = " << count << endl; + } +} + + +void Foam::fieldValues::faceSource::setPatchFaces() +{ + label patchId = mesh().boundaryMesh().findPatchID(sourceName_); + + if (patchId < 0) + { + FatalErrorIn("faceSource::constructFaceAddressing()") + << "Unknown patch name: " << sourceName_ + << ". Valid patch names are: " + << mesh().boundaryMesh().names() << nl + << exit(FatalError); + } + + const polyPatch& pp = mesh().boundaryMesh()[patchId]; + + label nFaces = pp.size(); + if (isA(pp)) + { + nFaces /= 2; + } + else if (isA(pp)) + { + nFaces = 0; + } + + faceId_.setSize(nFaces); + facePatchId_.setSize(nFaces); + flipMap_.setSize(nFaces); + + forAll(faceId_, faceI) + { + faceId_[faceI] = faceI; + facePatchId_[faceI] = patchId; + flipMap_[faceI] = 1; + } +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::fieldValues::faceSource::initialise() +{ + switch (source_) + { + case stFaceZone: + { + setFaceZoneFaces(); + break; + } + case stPatch: + { + setPatchFaces(); + break; + } + default: + { + FatalErrorIn("faceSource::constructFaceAddressing()") + << "Unknown source type. Valid source types are:" + << sourceTypeNames_ << nl << exit(FatalError); + } + } + + Info<< type() << " " << name_ << ":" << nl + << " total faces = " << faceId_.size() << nl + << " total area = " << sum(filterField(mesh().magSf())) + << nl << endl; +} + + +void Foam::fieldValues::faceSource::makeFile() +{ + // Create the forces file if not already created + if (outputFilePtr_.empty()) + { + if (debug) + { + Info<< "Creating output file." << endl; + } + + // File update + if (Pstream::master()) + { + fileName outputDir; + if (Pstream::parRun()) + { + // Put in undecomposed case (Note: gives problems for + // distributed data running) + outputDir = + obr_.time().path()/".."/name_/obr_.time().timeName(); + } + else + { + outputDir = obr_.time().path()/name_/obr_.time().timeName(); + } + + // Create directory if does not exist + mkDir(outputDir); + + // Open new file at start up + outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat"))); + + // Add headers to output data + writeFileHeader(); + } + } +} + + +void Foam::fieldValues::faceSource::writeFileHeader() +{ + if (outputFilePtr_.valid()) + { + outputFilePtr_() + << "# Source : " << sourceTypeNames_[source_] << " " + << sourceName_ << nl << "# Faces : " << faceId_.size() << nl + << "# Time" << tab << "sum(magSf)"; + + forAll(fields_, i) + { + outputFilePtr_() + << tab << operationTypeNames_[operation_] + << "(" << fields_[i] << ")"; + } + + outputFilePtr_() << endl; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldValues::faceSource::faceSource +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + fieldValue(name, obr, dict, loadFromFiles), + source_(sourceTypeNames_.read(dict.lookup("source"))), + operation_(operationTypeNames_.read(dict.lookup("operation"))), + faceId_(), + facePatchId_(), + flipMap_(), + outputFilePtr_(NULL) +{ + initialise(); + + if (active_) + { + // Create the output file if not already created + makeFile(); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fieldValues::faceSource::~faceSource() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fieldValues::faceSource::read(const dictionary& dict) +{ + if (active_) + { + fieldValue::read(dict); + initialise(); + } +} + + +void Foam::fieldValues::faceSource::write() +{ + if (active_) + { + if (log_) + { + Info<< type() << " " << name_ << " output:" << nl; + } + + outputFilePtr_() + << obr_.time().value() << tab + << sum(filterField(mesh().magSf())); + + forAll(fields_, i) + { + writeValues(fields_[i]); + writeValues(fields_[i]); + writeValues(fields_[i]); + writeValues(fields_[i]); + writeValues(fields_[i]); + } + + outputFilePtr_()<< endl; + + if (log_) + { + Info<< endl; + } + } +} + + +// ************************************************************************* // + diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.H new file mode 100644 index 0000000000..fa89fcdd6c --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.H @@ -0,0 +1,252 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::fieldValues::faceSource + +Description + Face source variant of field value function object. Values of user- + specified fields reported for collections of faces. + + cellObj1 // Name also used to identify output folder + { + type cellSource; + functionObjectLibs ("libfieldValueFunctionObjects.so"); + enabled true; + outputControl outputTime; + log true; // log to screen? + valueOutput true; // Write values at run-time output times? + source faceZone; // Type of face source: faceZone, patch + sourceName f0; + operation sum; // none, sum, areaAverage, areaIntegrate + fields + ( + p + phi + U + ); + } + +SourceFiles + faceSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceSource_H +#define faceSource_H + +#include "NamedEnum.H" +#include "fieldValue.H" +#include "labelList.H" +#include "OFstream.H" +#include "surfaceFieldsFwd.H" +#include "volFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fieldValues +{ + +/*---------------------------------------------------------------------------*\ + Class faceSource Declaration +\*---------------------------------------------------------------------------*/ + +class faceSource +: + public fieldValue +{ + +public: + + // Public data types + + //- Source type enumeration + enum sourceType + { + stFaceZone, + stPatch + }; + + //- Source type names + static const NamedEnum sourceTypeNames_; + + + //- Operation type enumeration + enum operationType + { + opNone, + opSum, + opAreaAverage, + opAreaIntegrate + }; + + //- Operation type names + static const NamedEnum operationTypeNames_; + + +private: + + // Private member functions + + //- Set faces to evaluate based on a face zone + void setFaceZoneFaces(); + + //- Set faces to evaluate based on a patch + void setPatchFaces(); + + //- Create the output file if not already created + void makeFile(); + + +protected: + + // Protected data + + //- Source type + sourceType source_; + + //- Operation to apply to values + operationType operation_; + + //- Local list of face IDs + labelList faceId_; + + //- Local list of patch ID per face + labelList facePatchId_; + + //- List of +1/-1 representing face flip map + labelList flipMap_; + + //- Output file pointer + autoPtr outputFilePtr_; + + + // Protected member functions + + //- Initialise, e.g. face addressing + void initialise(); + + //- Insert field values into values list + template + bool setFieldValues + ( + const word& fieldName, + List& values + ) const; + + //- Apply the 'operation' to the values + template + Type processValues(const List& values) const; + + //- Output file header information + virtual void writeFileHeader(); + + +public: + + //- Run-time type information + TypeName("faceSource"); + + + //- Construct from components + faceSource + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~faceSource(); + + + // Public member functions + + // Access + + //- Return the source type + inline const sourceType& source() const; + + //- Return the local list of face IDs + inline const labelList& faceId() const; + + //- Return the local list of patch ID per face + inline const labelList& facePatch() const; + + //- Return the list of +1/-1 representing face flip map + inline const labelList& flipMap() const; + + + // Function object functions + + //- Read from dictionary + virtual void read(const dictionary&); + + //- Calculate and write + virtual void write(); + + //- Templated helper function to output field values + template + bool writeValues(const word& fieldName); + + //- Filter a surface field according to faceIds + template + tmp > filterField + ( + const GeometricField& field + ) const; + + //- Filter a volume field according to faceIds + template + tmp > filterField + ( + const GeometricField& field + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fieldValues +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "faceSourceI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "faceSourceTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.C new file mode 100644 index 0000000000..12019c86c2 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.C @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "faceSourceFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug + ( + faceSourceFunctionObject, + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + faceSourceFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.H new file mode 100644 index 0000000000..54d717f870 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.H @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Typedef + Foam::faceSourceFunctionObject + +Description + FunctionObject wrapper around faceSource to allow it to be + created via the functions list within controlDict. + +SourceFiles + faceSourceFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceSourceFunctionObject_H +#define faceSourceFunctionObject_H + +#include "faceSource.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject + faceSourceFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceI.H b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceI.H new file mode 100644 index 0000000000..9d86255c36 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceI.H @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "faceSource.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::fieldValues::faceSource::sourceType& +Foam::fieldValues::faceSource::source() const +{ + return source_; +} + + +inline const Foam::labelList& +Foam::fieldValues::faceSource::faceId() const +{ + return faceId_; +} + + +inline const Foam::labelList& +Foam::fieldValues::faceSource::facePatch() const +{ + return facePatchId_; +} + + +inline const Foam::labelList& +Foam::fieldValues::faceSource::flipMap() const +{ + return flipMap_; +} + + +// ************************************************************************* // + diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceTemplates.C new file mode 100644 index 0000000000..ced2ee82ee --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceTemplates.C @@ -0,0 +1,269 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "faceSource.H" +#include "surfaceFields.H" +#include "volFields.H" +#include "IOList.H" +#include "ListListOps.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +bool Foam::fieldValues::faceSource::setFieldValues +( + const word& fieldName, + List& values +) const +{ + values.setSize(faceId_.size(), pTraits::zero); + + typedef GeometricField sf; + typedef GeometricField vf; + + if (obr_.foundObject(fieldName)) + { + const sf& field = obr_.lookupObject(fieldName); + + forAll(values, i) + { + label faceI = faceId_[i]; + label patchI = facePatchId_[i]; + if (patchI >= 0) + { + values[i] = field.boundaryField()[patchI][faceI]; + } + else + { + values[i] = field[faceI]; + } + + values[i] *= flipMap_[i]; + } + + return true; + } + else if (obr_.foundObject(fieldName)) + { + const vf& field = obr_.lookupObject(fieldName); + + forAll(values, i) + { + label faceI = faceId_[i]; + label patchI = facePatchId_[i]; + if (patchI >= 0) + { + values[i] = field.boundaryField()[patchI][faceI]; + } + else + { + FatalErrorIn + ( + "fieldValues::faceSource::setFieldValues" + "(" + "const word&, " + "List&" + ") const" + ) << type() << " " << name_ << ": " + << sourceTypeNames_[source_] << "(" << sourceName_ << "):" + << nl + << " Unable to process internal faces for volume field " + << fieldName << nl << abort(FatalError); + } + + values[i] *= flipMap_[i]; + } + + return true; + } + + return false; +} + + +template +Type Foam::fieldValues::faceSource::processValues +( + const List& values +) const +{ + Type result = pTraits::zero; + switch (operation_) + { + case opSum: + { + result = sum(values); + break; + } + case opAreaAverage: + { + tmp magSf = filterField(mesh().magSf()); + result = sum(values*magSf())/sum(magSf()); + break; + } + case opAreaIntegrate: + { + result = sum(values*filterField(mesh().magSf())); + break; + } + default: + { + // Do nothing + } + } + + return result; +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::fieldValues::faceSource::writeValues(const word& fieldName) +{ + List > allValues(Pstream::nProcs()); + + bool validField = + setFieldValues(fieldName, allValues[Pstream::myProcNo()]); + + if (validField) + { + Pstream::gatherList(allValues); + + if (Pstream::master()) + { + List values = + ListListOps::combine > + ( + allValues, + accessOp >() + ); + + Type result = processValues(values); + + if (valueOutput_) + { + IOList + ( + IOobject + ( + fieldName + "_" + sourceTypeNames_[source_] + "-" + + sourceName_, + obr_.time().timeName(), + obr_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + values + ).write(); + } + + + outputFilePtr_()<< tab << result; + + if (log_) + { + Info<< " " << operationTypeNames_[operation_] + << "(" << sourceName_ << ") for " << fieldName + << " = " << result << endl; + } + } + } + + return validField; +} + + +template +Foam::tmp > Foam::fieldValues::faceSource::filterField +( + const GeometricField& field +) const +{ + tmp > tvalues(new Field(faceId_.size())); + Field& values = tvalues(); + + forAll(values, i) + { + label faceI = faceId_[i]; + label patchI = facePatchId_[i]; + if (patchI >= 0) + { + values[i] = field.boundaryField()[patchI][faceI]; + } + else + { + FatalErrorIn + ( + "fieldValues::faceSource::filterField" + "(" + "const GeometricField&" + ") const" + ) << type() << " " << name_ << ": " + << sourceTypeNames_[source_] << "(" << sourceName_ << "):" + << nl + << " Unable to process internal faces for volume field " + << field.name() << nl << abort(FatalError); + } + + values[i] *= flipMap_[i]; + } + + return tvalues; +} + + +template +Foam::tmp > Foam::fieldValues::faceSource::filterField +( + const GeometricField& field +) const +{ + tmp > tvalues(new Field(faceId_.size())); + Field& values = tvalues(); + + forAll(values, i) + { + label faceI = faceId_[i]; + label patchI = facePatchId_[i]; + if (patchI >= 0) + { + values[i] = field.boundaryField()[patchI][faceI]; + } + else + { + values[i] = field[faceI]; + } + + values[i] *= flipMap_[i]; + } + + return tvalues; +} + + +// ************************************************************************* // + diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C new file mode 100644 index 0000000000..36b88d5e81 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "fieldValue.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(fieldValue, 0); + + defineTemplateTypeNameAndDebug(IOList, 0); + defineTemplateTypeNameAndDebug(IOList, 0); + defineTemplateTypeNameAndDebug(IOList, 0); + defineTemplateTypeNameAndDebug(IOList, 0); +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::fieldValue::updateMesh(const mapPolyMesh&) +{ + // Do nothing +} + + +void Foam::fieldValue::movePoints(const Field&) +{ + // Do nothing +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldValue::fieldValue +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + log_(false), + sourceName_(dict.lookup("sourceName")), + fields_(dict.lookup("fields")), + valueOutput_(dict.lookup("valueOutput")) +{ + // Only active if obr is an fvMesh + if (isA(obr_)) + { + read(dict); + } + else + { + WarningIn + ( + "fieldValue::fieldValue" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." + << nl << endl; + active_ = false; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fieldValue::~fieldValue() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::word& Foam::fieldValue::name() const +{ + return name_; +} + + +const Foam::objectRegistry& Foam::fieldValue::obr() const +{ + return obr_; +} + + +bool Foam::fieldValue::active() const +{ + return active_; +} + + +const Foam::Switch& Foam::fieldValue::log() const +{ + return log_; +} + + +const Foam::word& Foam::fieldValue::sourceName() const +{ + return sourceName_; +} + + +const Foam::wordList& Foam::fieldValue::fields() const +{ + return fields_; +} + + +const Foam::Switch& Foam::fieldValue::valueOutput() const +{ + return valueOutput_; +} + + +const Foam::fvMesh& Foam::fieldValue::mesh() const +{ + return refCast(obr_); +} + + +void Foam::fieldValue::read(const dictionary& dict) +{ + if (active_) + { + log_ = dict.lookupOrDefault("log", false); + dict.lookup("fields") >> fields_; + dict.lookup("valueOutput") >> valueOutput_; + } +} + + +void Foam::fieldValue::execute() +{ + // Do nothing +} + + +void Foam::fieldValue::end() +{ + // Do nothing +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H new file mode 100644 index 0000000000..cdedaae131 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -0,0 +1,165 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::fieldValue + +Description + Base class for field value -based function objects. + +SourceFiles + fieldValue.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fieldValue_H +#define fieldValue_H + +#include "Switch.H" +#include "pointFieldFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class dictionary; +class objectRegistry; +class fvMesh; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class fieldValue Declaration +\*---------------------------------------------------------------------------*/ + +class fieldValue +{ + +protected: + + // Protected data + + //- Name of this fieldValue object + word name_; + + //- Database this class is registered to + const objectRegistry& obr_; + + //- Active flag + bool active_; + + //- Switch to send output to Info as well as to file + Switch log_; + + //- Name of source object + word sourceName_; + + //- List of field names to operate on + wordList fields_; + + //- Output field values flag + Switch valueOutput_; + + + // Functions to be over-ridden from IOoutputFilter class + + //- Update mesh + virtual void updateMesh(const mapPolyMesh&); + + //- Move points + virtual void movePoints(const Field&); + + +public: + + //- Run-time type information + TypeName("fieldValue"); + + + //- Construct from components + fieldValue + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~fieldValue(); + + + // Public member functions + + // Access + + //- Return the name of the geometric source + const word& name() const; + + //- Return the reference to the object registry + const objectRegistry& obr() const; + + //- Return the active flag + bool active() const; + + //- Return the switch to send output to Info as well as to file + const Switch& log() const; + + //- Return the source name + const word& sourceName() const; + + //- Return the list of field names + const wordList& fields() const; + + //- Return the output field values flag + const Switch& valueOutput() const; + + //- Helper funvction to return the reference to the mesh + const fvMesh& mesh() const; + + + // Function object functions + + //- Read from dictionary + virtual void read(const dictionary& dict); + + //- Execute + virtual void execute(); + + //- Execute the at the final time-loop, currently does nothing + virtual void end(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From cf25c46400f38574ed2eab3c60b619a9bed98f75 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 24 Aug 2009 16:23:05 +0100 Subject: [PATCH 12/30] added RAS variant of the Jayatilleke thermal wall function --- .../compressible/RAS/Make/files | 1 + ...ayatillekeWallFunctionFvPatchScalarField.C | 316 ++++++++++++++++++ ...ayatillekeWallFunctionFvPatchScalarField.H | 195 +++++++++++ 3 files changed, 512 insertions(+) create mode 100644 src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.H diff --git a/src/turbulenceModels/compressible/RAS/Make/files b/src/turbulenceModels/compressible/RAS/Make/files index 1329745581..ed01f0592e 100644 --- a/src/turbulenceModels/compressible/RAS/Make/files +++ b/src/turbulenceModels/compressible/RAS/Make/files @@ -15,6 +15,7 @@ wallFunctions = derivedFvPatchFields/wallFunctions alphatWallFunctions = $(wallFunctions)/alphatWallFunctions $(alphatWallFunctions)/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C +$(alphatWallFunctions)/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C mutWallFunctions = $(wallFunctions)/mutWallFunctions $(mutWallFunctions)/mutkRoughWallFunction/mutkRoughWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..e8fdf3edd5 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C @@ -0,0 +1,316 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-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 "alphatJayatillekeWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +scalar alphatJayatillekeWallFunctionFvPatchScalarField::maxExp_ = 50.0; +scalar alphatJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01; +label alphatJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10; + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void alphatJayatillekeWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn + ( + "alphatJayatillekeWallFunctionFvPatchScalarField::checkType()" + ) + << "Patch type for patch " << patch().name() << " must be wall\n" + << "Current patch type is " << patch().type() << nl + << exit(FatalError); + } +} + + +scalar alphatJayatillekeWallFunctionFvPatchScalarField::Psmooth +( + const scalar Prat +) const +{ + return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat)); +} + + +scalar alphatJayatillekeWallFunctionFvPatchScalarField::yPlusTherm +( + const scalar P, + const scalar Prat +) const +{ + scalar ypt = 11.0; + + for (int i=0; i& iF +) +: + fixedValueFvPatchScalarField(p, iF), + Prt_(0.85), + Cmu_(0.09), + kappa_(0.41), + E_(9.8) +{ + checkType(); +} + + +alphatJayatillekeWallFunctionFvPatchScalarField:: +alphatJayatillekeWallFunctionFvPatchScalarField +( + const alphatJayatillekeWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + Prt_(ptf.Prt_), + Cmu_(ptf.Cmu_), + kappa_(ptf.kappa_), + E_(ptf.E_) +{} + + +alphatJayatillekeWallFunctionFvPatchScalarField:: +alphatJayatillekeWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + Prt_(dict.lookupOrDefault("Prt", 0.85)), + Cmu_(dict.lookupOrDefault("Cmu", 0.09)), + kappa_(dict.lookupOrDefault("kappa", 0.41)), + E_(dict.lookupOrDefault("E", 9.8)) +{ + checkType(); +} + + +alphatJayatillekeWallFunctionFvPatchScalarField:: +alphatJayatillekeWallFunctionFvPatchScalarField +( + const alphatJayatillekeWallFunctionFvPatchScalarField& awfpsf +) +: + fixedValueFvPatchScalarField(awfpsf), + Prt_(awfpsf.Prt_), + Cmu_(awfpsf.Cmu_), + kappa_(awfpsf.kappa_), + E_(awfpsf.E_) +{ + checkType(); +} + + +alphatJayatillekeWallFunctionFvPatchScalarField:: +alphatJayatillekeWallFunctionFvPatchScalarField +( + const alphatJayatillekeWallFunctionFvPatchScalarField& awfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(awfpsf, iF), + Prt_(awfpsf.Prt_), + Cmu_(awfpsf.Cmu_), + kappa_(awfpsf.kappa_), + E_(awfpsf.E_) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void alphatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + + const scalar Cmu25 = pow(Cmu_, 0.25); + + const scalarField& y = rasModel.y()[patchI]; + + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; + + const scalarField& alphaw = rasModel.alpha().boundaryField()[patchI]; + scalarField& alphatw = *this; + + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); + + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + const scalarField magGradUw = mag(Uw.snGrad()); + + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; + const fvPatchScalarField& hw = + patch().lookupPatchField("h"); + + // Heat flux [W/m2] - lagging alphatw + const scalarField qDot = (alphaw + alphatw)*hw.snGrad(); + + // Populate boundary values + forAll(alphatw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar uTau = Cmu25*sqrt(k[faceCellI]); + + scalar yPlus = uTau*y[faceI]/(muw[faceI]/rhow[faceI]); + + // Molecular Prandtl number + scalar Pr = muw[faceI]/alphaw[faceI]; + + // Molecular-to-turbulenbt Prandtl number ratio + scalar Prat = Pr/Prt_; + + // Thermal sublayer thickness + scalar P = Psmooth(Prat); + scalar yPlusTherm = this->yPlusTherm(P, Prat); + + // Evaluate new effective thermal diffusivity + scalar alphaEff = 0.0; + if (yPlus < yPlusTherm) + { + scalar A = qDot[faceI]*rhow[faceI]*uTau*y[faceI]; + scalar B = qDot[faceI]*Pr*yPlus; + scalar C = Pr*0.5*rhow[faceI]*uTau*sqr(magUp[faceI]); + alphaEff = A/(B + C + VSMALL); + } + else + { + scalar A = qDot[faceI]*rhow[faceI]*uTau*y[faceI]; + scalar B = qDot[faceI]*Prt_*(1.0/kappa_*log(E_*yPlus) + P); + scalar magUc = uTau/kappa_*log(E_*yPlusTherm) - mag(Uw[faceI]); + scalar C = + 0.5*rhow[faceI]*uTau + *(Prt_*sqr(magUp[faceI]) + (Pr - Prt_)*sqr(magUc)); + alphaEff = A/(B + C + VSMALL); + } + + // Update turbulent thermal diffusivity + alphatw[faceI] = max(0.0, alphaEff - alphaw[faceI]); + + if (debug) + { + Info<< " uTau = " << uTau << nl + << " Pr = " << Pr << nl + << " Prt = " << Prt_ << nl + << " qDot = " << qDot[faceI] << nl + << " yPlus = " << yPlus << nl + << " yPlusTherm = " << yPlusTherm << nl + << " alphaEff = " << alphaEff << nl + << " alphaw = " << alphaw[faceI] << nl + << " alphatw = " << alphatw[faceI] << nl + << endl; + } + } + + fixedValueFvPatchField::updateCoeffs(); +} + + +void alphatJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl; + os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; + os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + alphatJayatillekeWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..6b5ce3bd72 --- /dev/null +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.H @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-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 + alphatJayatillekeWallFunctionFvPatchScalarField + +Description + Thermal wall function for turbulent thermal diffusivity based on the + Jayatilleke thermal wall function + +SourceFiles + alphatJayatillekeWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef alphatJayatillekeWallFunctionFvPatchScalarField_H +#define alphatJayatillekeWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class alphatJayatillekeWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class alphatJayatillekeWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Turbulent Prandtl number + scalar Prt_; + + //- Cmu coefficient + scalar Cmu_; + + //- Von Karman constant + scalar kappa_; + + //- E coefficient + scalar E_; + + + // Solution parameters + + static scalar maxExp_; + static scalar tolerance_; + static label maxIters_; + + + // Private member functions + + //- Check the type of the patch + void checkType(); + + //- `P' function + scalar Psmooth(const scalar Prat) const; + + //- Calculate y+ at the edge of the thermal laminar sublayer + scalar yPlusTherm + ( + const scalar P, + const scalar Prat + ) const; + + +public: + + //- Runtime type information + TypeName("alphatJayatillekeWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + alphatJayatillekeWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + alphatJayatillekeWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given an + // alphatJayatillekeWallFunctionFvPatchScalarField + // onto a new patch + alphatJayatillekeWallFunctionFvPatchScalarField + ( + const alphatJayatillekeWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + alphatJayatillekeWallFunctionFvPatchScalarField + ( + const alphatJayatillekeWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new alphatJayatillekeWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + alphatJayatillekeWallFunctionFvPatchScalarField + ( + const alphatJayatillekeWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new alphatJayatillekeWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From c58af4fcceb74a0c5c433ef5fdd4bdf670441e3d Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Aug 2009 16:55:35 +0100 Subject: [PATCH 13/30] empty file --- tutorials/mesh/snappyHexMesh/Allrun | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 tutorials/mesh/snappyHexMesh/Allrun diff --git a/tutorials/mesh/snappyHexMesh/Allrun b/tutorials/mesh/snappyHexMesh/Allrun deleted file mode 100755 index e69de29bb2..0000000000 From 5623ba449a8e25eaf12ed35bb4e92c9c11f75b8c Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 24 Aug 2009 17:10:53 +0100 Subject: [PATCH 14/30] added fieldValues to field function objects library --- src/postProcessing/functionObjects/field/Make/files | 6 ++++++ .../functionObjects/field/fieldValues/Make/files | 9 --------- .../functionObjects/field/fieldValues/Make/options | 9 --------- .../functionObjects/field/fieldValues/controlDict | 6 +++--- 4 files changed, 9 insertions(+), 21 deletions(-) delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/Make/files delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/Make/options diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index e300214731..3766cb0ba8 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -6,4 +6,10 @@ fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C fieldMinMax/fieldMinMax.C fieldMinMax/fieldMinMaxFunctionObject.C +fieldValues/fieldValue/fieldValue.C +fieldValues/face/faceSource.C +fieldValues/face/faceSourceFunctionObject.C +fieldValues/cell/cellSource.C +fieldValues/cell/cellSourceFunctionObject.C + LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects diff --git a/src/postProcessing/functionObjects/field/fieldValues/Make/files b/src/postProcessing/functionObjects/field/fieldValues/Make/files deleted file mode 100644 index 66028b4812..0000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/Make/files +++ /dev/null @@ -1,9 +0,0 @@ -fieldValue/fieldValue.C - -face/faceSource.C -face/faceSourceFunctionObject.C - -cell/cellSource.C -cell/cellSourceFunctionObject.C - -LIB = $(FOAM_LIBBIN)/libfieldValueFunctionObjects diff --git a/src/postProcessing/functionObjects/field/fieldValues/Make/options b/src/postProcessing/functionObjects/field/fieldValues/Make/options deleted file mode 100644 index 5166bcc9e3..0000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/Make/options +++ /dev/null @@ -1,9 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/sampling/lnInclude - -LIB_LIBS = \ - -lfiniteVolume \ - -lmeshTools \ - -lsampling diff --git a/src/postProcessing/functionObjects/field/fieldValues/controlDict b/src/postProcessing/functionObjects/field/fieldValues/controlDict index 88ea120317..7d9ab1f656 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/controlDict +++ b/src/postProcessing/functionObjects/field/fieldValues/controlDict @@ -50,7 +50,7 @@ functions faceObj1 { type faceSource; - functionObjectLibs ("libfieldValueFunctionObjects.so"); + functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; outputControl outputTime; log true; @@ -71,7 +71,7 @@ functions faceObj2 { type faceSource; - functionObjectLibs ("libfieldValueFunctionObjects.so"); + functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; outputControl outputTime; log true; @@ -88,7 +88,7 @@ functions cellObj1 { type cellSource; - functionObjectLibs ("libfieldValueFunctionObjects.so"); + functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; outputControl outputTime; log true; From e7b3ede72e49657cba202924d153425da2337791 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Aug 2009 17:41:20 +0100 Subject: [PATCH 15/30] multiple line writing; vtk output --- .../postProcessing/sampling/sample/sampleDict | 1 + src/sampling/Make/files | 1 + .../writers/gnuplot/gnuplotSetWriter.C | 62 +++++- .../writers/gnuplot/gnuplotSetWriter.H | 11 +- .../sampledSet/writers/jplot/jplotSetWriter.C | 6 +- .../sampledSet/writers/jplot/jplotSetWriter.H | 24 ++- .../sampledSet/writers/raw/rawSetWriter.C | 34 +++ .../sampledSet/writers/raw/rawSetWriter.H | 9 + .../sampledSet/writers/vtk/vtkSetWriter.C | 196 ++++++++++++++++++ .../sampledSet/writers/vtk/vtkSetWriter.H | 112 ++++++++++ .../writers/vtk/vtkSetWriterRunTime.C | 38 ++++ src/sampling/sampledSet/writers/writer.C | 6 +- src/sampling/sampledSet/writers/writer.H | 13 ++ .../writers/xmgrace/xmgraceSetWriter.C | 59 +++++- .../writers/xmgrace/xmgraceSetWriter.H | 11 +- 15 files changed, 558 insertions(+), 25 deletions(-) create mode 100644 src/sampling/sampledSet/writers/vtk/vtkSetWriter.C create mode 100644 src/sampling/sampledSet/writers/vtk/vtkSetWriter.H create mode 100644 src/sampling/sampledSet/writers/vtk/vtkSetWriterRunTime.C diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index f3659e728a..4571c924df 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -22,6 +22,7 @@ FoamFile // jplot // gnuplot // raw +// vtk setFormat raw; // Surface output format. Choice of diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 57306e542b..a6d16a0f1e 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -18,6 +18,7 @@ $(setWriters)/writers.C $(setWriters)/gnuplot/gnuplotSetWriterRunTime.C $(setWriters)/jplot/jplotSetWriterRunTime.C $(setWriters)/raw/rawSetWriterRunTime.C +$(setWriters)/vtk/vtkSetWriterRunTime.C $(setWriters)/xmgrace/xmgraceSetWriterRunTime.C cuttingPlane/cuttingPlane.C diff --git a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.C b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.C index 9905d54411..9f34a59197 100644 --- a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.C +++ b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.C @@ -69,29 +69,73 @@ void Foam::gnuplotSetWriter::write Ostream& os ) const { - os << "set term postscript color" << endl - << "set output \"" << points.name() << ".ps\"" << endl + os << "set term postscript color" << nl + << "set output \"" << points.name() << ".ps\"" << nl << "plot"; - bool firstField = true; - forAll(valueSets, i) { - if (!firstField) + if (i != 0) { os << ','; } - firstField = false; - os << "'-' title \"" << valueSetNames[i] << "\" with lines"; + os << " \"-\" title \"" << valueSetNames[i] << "\" with lines"; } - os << endl; + os << nl; forAll(valueSets, i) { - os << endl; writeTable(points, *valueSets[i], os); + os << "e" << nl; + } +} + + +template +void Foam::gnuplotSetWriter::write +( + const bool writeTracks, + const PtrList& trackPoints, + const wordList& valueSetNames, + const List > >& valueSets, + Ostream& os +) const +{ + if (valueSets.size() != valueSetNames.size()) + { + FatalErrorIn("gnuplotSetWriter::write(..)") + << "Number of variables:" << valueSetNames.size() << endl + << "Number of valueSets:" << valueSets.size() + << exit(FatalError); + } + if (trackPoints.size() > 0) + { + os << "set term postscript color" << nl + << "set output \"" << trackPoints[0].name() << ".ps\"" << nl; + + forAll(trackPoints, trackI) + { + os << "plot"; + + forAll(valueSets, i) + { + if (i != 0) + { + os << ','; + } + + os << " \"-\" title \"" << valueSetNames[i] << "\" with lines"; + } + os << nl; + + forAll(valueSets, i) + { + writeTable(trackPoints[trackI], valueSets[i][trackI], os); + os << "e" << nl; + } + } } } diff --git a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H index 1096f64519..6d575b8aa2 100644 --- a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H +++ b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H @@ -76,13 +76,22 @@ public: const wordList& ) const; - void write + virtual void write ( const coordSet&, const wordList&, const List*>&, Ostream& ) const; + + virtual void write + ( + const bool writeTracks, + const PtrList&, + const wordList& valueSetNames, + const List > >&, + Ostream& + ) const; }; diff --git a/src/sampling/sampledSet/writers/jplot/jplotSetWriter.C b/src/sampling/sampledSet/writers/jplot/jplotSetWriter.C index 53b0d5e08b..560f626c1e 100644 --- a/src/sampling/sampledSet/writers/jplot/jplotSetWriter.C +++ b/src/sampling/sampledSet/writers/jplot/jplotSetWriter.C @@ -39,7 +39,7 @@ Foam::Ostream& Foam::jplotSetWriter::writeHeader(Ostream& os) const return os << "# JPlot input file" << nl << "#" << nl << nl - << "# Generated by sample on " << clock::date().c_str() << endl; + << "# Generated by sample on " << clock::date().c_str() << nl; } @@ -82,11 +82,11 @@ void Foam::jplotSetWriter::write ) const { os << "# JPlot file" << nl - << "# column 1: " << points.name() << endl; + << "# column 1: " << points.name() << nl; forAll(valueSets, i) { - os << "# column " << i + 2 << ": " << valueSetNames[i] << endl; + os << "# column " << i + 2 << ": " << valueSetNames[i] << nl; } // Collect sets into columns diff --git a/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H b/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H index 940dec2abe..d9f6f1bf76 100644 --- a/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H +++ b/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H @@ -80,13 +80,35 @@ public: const wordList& ) const; - void write + virtual void write ( const coordSet&, const wordList&, const List*>&, Ostream& ) const; + + virtual void write + ( + const bool writeTracks, + const PtrList&, + const wordList& valueSetNames, + const List > >&, + Ostream& + ) const + { + notImplemented + ( + "jplotSetWriter::write\n" + "(\n" + " const bool,\n" + " const PtrList&,\n" + " const wordList&,\n" + " const List > >&,\n" + " Ostream&\n" + ") const" + ); + } }; diff --git a/src/sampling/sampledSet/writers/raw/rawSetWriter.C b/src/sampling/sampledSet/writers/raw/rawSetWriter.C index a3b42d6da0..1934071aec 100644 --- a/src/sampling/sampledSet/writers/raw/rawSetWriter.C +++ b/src/sampling/sampledSet/writers/raw/rawSetWriter.C @@ -79,4 +79,38 @@ void Foam::rawSetWriter::write } +template +void Foam::rawSetWriter::write +( + const bool writeTracks, + const PtrList& points, + const wordList& valueSetNames, + const List > >& valueSets, + Ostream& os +) const +{ + if (valueSets.size() != valueSetNames.size()) + { + FatalErrorIn("rawSetWriter::write(..)") + << "Number of variables:" << valueSetNames.size() << endl + << "Number of valueSets:" << valueSets.size() + << exit(FatalError); + } + + List*> columns(valueSets.size()); + + forAll(points, trackI) + { + // Collect sets into columns + forAll(valueSets, i) + { + columns[i] = &valueSets[i][trackI]; + } + + writeTable(points[trackI], columns, os); + os << nl << nl; + } +} + + // ************************************************************************* // diff --git a/src/sampling/sampledSet/writers/raw/rawSetWriter.H b/src/sampling/sampledSet/writers/raw/rawSetWriter.H index 346813d941..b2852b5a0d 100644 --- a/src/sampling/sampledSet/writers/raw/rawSetWriter.H +++ b/src/sampling/sampledSet/writers/raw/rawSetWriter.H @@ -83,6 +83,15 @@ public: const List*>&, Ostream& ) const; + + virtual void write + ( + const bool writeTracks, + const PtrList&, + const wordList& valueSetNames, + const List > >&, + Ostream& + ) const; }; diff --git a/src/sampling/sampledSet/writers/vtk/vtkSetWriter.C b/src/sampling/sampledSet/writers/vtk/vtkSetWriter.C new file mode 100644 index 0000000000..f8172ea5b3 --- /dev/null +++ b/src/sampling/sampledSet/writers/vtk/vtkSetWriter.C @@ -0,0 +1,196 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "vtkSetWriter.H" +#include "coordSet.H" +#include "fileName.H" +#include "OFstream.H" +#include "addToRunTimeSelectionTable.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::vtkSetWriter::vtkSetWriter() +: + writer() +{} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::vtkSetWriter::~vtkSetWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::fileName Foam::vtkSetWriter::getFileName +( + const coordSet& points, + const wordList& valueSetNames +) const +{ + return this->getBaseName(points, valueSetNames) + ".vtk"; +} + + +template +void Foam::vtkSetWriter::write +( + const coordSet& points, + const wordList& valueSetNames, + const List*>& valueSets, + Ostream& os +) const +{ + os << "# vtk DataFile Version 2.0" << nl + << points.name() << nl + << "ASCII" << nl + << "DATASET POLYDATA" << nl + << "POINTS " << points.size() << " float" << nl; + + forAll(points, i) + { + const vector& pt = points[i]; + os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl; + } + + + os << "POINT_DATA " << points.size() << nl + << " FIELD attributes " << valueSetNames.size() << nl; + + forAll(valueSetNames, setI) + { + os << valueSetNames[setI] << ' ' << pTraits::nComponents << ' ' + << points.size() << " float" << nl; + + const Field& fld = *valueSets[setI]; + + forAll(fld, pointI) + { + if (pointI != 0) + { + os << ' '; + } + writer::write(fld[pointI], os); + } + os << nl; + } +} + + +template +void Foam::vtkSetWriter::write +( + const bool writeTracks, + const PtrList& tracks, + const wordList& valueSetNames, + const List > >& valueSets, + Ostream& os +) const +{ + if (valueSets.size() != valueSetNames.size()) + { + FatalErrorIn("vtkSetWriter::write(..)") + << "Number of variables:" << valueSetNames.size() << endl + << "Number of valueSets:" << valueSets.size() + << exit(FatalError); + } + + label nTracks = tracks.size(); + label nPoints = 0; + forAll(tracks, i) + { + nPoints += tracks[i].size(); + } + + os << "# vtk DataFile Version 2.0" << nl + << tracks[0].name() << nl + << "ASCII" << nl + << "DATASET POLYDATA" << nl + << "POINTS " << nPoints << " float" << nl; + + forAll(tracks, trackI) + { + const coordSet& points = tracks[trackI]; + forAll(points, i) + { + const vector& pt = points[i]; + os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl; + } + } + + if (writeTracks) + { + os << "LINES " << nTracks << ' ' << nPoints+nTracks << nl; + + // Write ids of track points to file + label globalPtI = 0; + forAll(tracks, trackI) + { + const coordSet& points = tracks[trackI]; + + os << points.size(); + forAll(points, i) + { + os << ' ' << globalPtI; + globalPtI++; + } + os << nl; + } + } + + os << "POINT_DATA " << nPoints << nl + << " FIELD attributes " << valueSetNames.size() << nl; + + forAll(valueSetNames, setI) + { + os << valueSetNames[setI] << ' ' << pTraits::nComponents << ' ' + << nPoints << " float" << nl; + + const List >& fieldVals = valueSets[setI]; + + forAll(fieldVals, i) + { + const Field& vals = fieldVals[i]; + + forAll(vals, j) + { + if (j != 0) + { + os << ' '; + } + writer::write(vals[j], os); + } + os << nl; + } + } +} + + +// ************************************************************************* // diff --git a/src/sampling/sampledSet/writers/vtk/vtkSetWriter.H b/src/sampling/sampledSet/writers/vtk/vtkSetWriter.H new file mode 100644 index 0000000000..59401c1e03 --- /dev/null +++ b/src/sampling/sampledSet/writers/vtk/vtkSetWriter.H @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::vtkSetWriter + +Description + +SourceFiles + vtkSetWriter.C + +\*---------------------------------------------------------------------------*/ + +#ifndef vtkSetWriter_H +#define vtkSetWriter_H + +#include "writer.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class vtkSetWriter Declaration +\*---------------------------------------------------------------------------*/ + +template +class vtkSetWriter +: + public writer +{ + +public: + + //- Runtime type information + TypeName("vtk"); + + + // Constructors + + //- Construct null + vtkSetWriter(); + + + //- Destructor + virtual ~vtkSetWriter(); + + + // Member Functions + + virtual fileName getFileName + ( + const coordSet&, + const wordList& + ) const; + + virtual void write + ( + const coordSet&, + const wordList&, + const List*>&, + Ostream& + ) const; + + virtual void write + ( + const bool writeTracks, + const PtrList&, + const wordList& valueSetNames, + const List > >&, + Ostream& + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "vtkSetWriter.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSet/writers/vtk/vtkSetWriterRunTime.C b/src/sampling/sampledSet/writers/vtk/vtkSetWriterRunTime.C new file mode 100644 index 0000000000..bb180036f8 --- /dev/null +++ b/src/sampling/sampledSet/writers/vtk/vtkSetWriterRunTime.C @@ -0,0 +1,38 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "vtkSetWriter.H" +#include "writers.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makeSetWriters(vtkSetWriter); +} + +// ************************************************************************* // diff --git a/src/sampling/sampledSet/writers/writer.C b/src/sampling/sampledSet/writers/writer.C index b16966d3a1..cde178041d 100644 --- a/src/sampling/sampledSet/writers/writer.C +++ b/src/sampling/sampledSet/writers/writer.C @@ -110,7 +110,7 @@ void Foam::writer::writeTable os << token::SPACE; write(values[pointI], os); - os << endl; + os << nl; } } @@ -133,7 +133,7 @@ void Foam::writer::writeTable const List& values = *valuesPtrList[i]; write(values[pointI], os); } - os << endl; + os << nl; } } @@ -179,7 +179,7 @@ Foam::Ostream& Foam::writer::writeVS if (d <= VSType::nComponents-1) { - os << token::TAB; + os << ' ' << token::TAB; } } return os; diff --git a/src/sampling/sampledSet/writers/writer.H b/src/sampling/sampledSet/writers/writer.H index e450d07c32..52cf03482a 100644 --- a/src/sampling/sampledSet/writers/writer.H +++ b/src/sampling/sampledSet/writers/writer.H @@ -162,6 +162,19 @@ public: Ostream& ) const = 0; + //- General entry point for writing of multiple coordSets. + // Each coordSet (track) has same data variables. + // The data is per variable, per track, per point of track. + // If writeTracks adds connecting lines (wherever applicable) + virtual void write + ( + const bool writeTracks, + const PtrList&, + const wordList& valueSetNames, + const List > >&, + Ostream& + ) const = 0; + //- Write scalar as ascii virtual Ostream& write(const scalar, Ostream&) const; diff --git a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.C b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.C index b1da1cb651..1ddeda9c3f 100644 --- a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.C +++ b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.C @@ -68,19 +68,64 @@ void Foam::xmgraceSetWriter::write Ostream& os ) const { - os << "@title \"" << points.name() << '"' << endl - << "@xaxis label " << '"' << points.axis() << '"' << endl; + os << "@g0 on" << nl + << "@with g0" << nl + << "@ title \"" << points.name() << '"' << nl + << "@ xaxis label " << '"' << points.axis() << '"' << nl; forAll(valueSets, i) { - os << "@s" << i << " legend " << '"' - << valueSetNames[i] << '"' << endl - << "@target G0.S" << i << endl - << "@type xy" << endl; + os << "@ s" << i << " legend " << '"' + << valueSetNames[i] << '"' << nl + << "@target G0.S" << i << nl; writeTable(points, *valueSets[i], os); - os << endl; + os << '&' << nl; + } +} + + +template +void Foam::xmgraceSetWriter::write +( + const bool writeTracks, + const PtrList& trackPoints, + const wordList& valueSetNames, + const List > >& valueSets, + Ostream& os +) const +{ + if (valueSets.size() != valueSetNames.size()) + { + FatalErrorIn("gnuplotSetWriter::write(..)") + << "Number of variables:" << valueSetNames.size() << endl + << "Number of valueSets:" << valueSets.size() + << exit(FatalError); + } + if (trackPoints.size() > 0) + { + os << "@g0 on" << nl + << "@with g0" << nl + << "@ title \"" << trackPoints[0].name() << '"' << nl + << "@ xaxis label " << '"' << trackPoints[0].axis() << '"' << nl; + + // Data index. + label sI = 0; + + forAll(trackPoints, trackI) + { + forAll(valueSets, i) + { + os << "@ s" << sI << " legend " << '"' + << valueSetNames[i] << "_track" << i << '"' << nl + << "@target G0.S" << sI << nl; + writeTable(trackPoints[trackI], valueSets[i][trackI], os); + os << '&' << nl; + + sI++; + } + } } } diff --git a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H index b5abab73b5..e959121d99 100644 --- a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H +++ b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H @@ -76,13 +76,22 @@ public: const wordList& ) const; - void write + virtual void write ( const coordSet&, const wordList&, const List*>&, Ostream& ) const; + + virtual void write + ( + const bool writeTracks, + const PtrList&, + const wordList& valueSetNames, + const List > >&, + Ostream& + ) const; }; From 3355c8d9eb2823c9420bfb3213a5394592e15329 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Aug 2009 12:35:48 +0100 Subject: [PATCH 16/30] initial streamlines functionobject --- .../postProcessing/sampling/sample/sampleDict | 1 + bin/tools/CleanFunctions | 1 + .../functionObjects/field/Make/files | 6 + .../functionObjects/field/Make/options | 2 + .../fieldValues/cell/cellSourceTemplates.C | 17 +- .../field/streamLine/streamLine.C | 620 ++++++++++++++++++ .../field/streamLine/streamLine.H | 219 +++++++ .../streamLine/streamLineFunctionObject.C | 43 ++ .../streamLine/streamLineFunctionObject.H | 55 ++ .../field/streamLine/streamLineParticle.C | 479 ++++++++++++++ .../field/streamLine/streamLineParticle.H | 300 +++++++++ .../streamLine/streamLineParticleCloud.C | 79 +++ .../streamLine/streamLineParticleCloud.H | 105 +++ src/sampling/Make/files | 9 +- .../triSurfaceMeshPointSet.C | 177 +++++ .../triSurfaceMeshPointSet.H | 119 ++++ .../simpleFoam/pitzDaily/system/controlDict | 62 ++ 17 files changed, 2275 insertions(+), 19 deletions(-) create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLine.C create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLine.H create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineParticle.C create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineParticle.H create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineParticleCloud.C create mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineParticleCloud.H create mode 100644 src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C create mode 100644 src/sampling/sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.H diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index 4571c924df..9c288d7cbf 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -63,6 +63,7 @@ fields // curve specified points, not nessecary on line, uses // tracking // cloud specified points, uses findCell +// triSurfaceMeshPointSet points of triSurface // // axis: how to write point coordinate. Choice of // - x/y/z: x/y/z coordinate only diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 4a2015febf..5e0ea64c5e 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -72,6 +72,7 @@ cleanCase () constant/{cellToRegion,cellLevel*,pointLevel*} \ constant/polyMesh/sets/ \ VTK \ + sets/streamLines \ > /dev/null 2>&1 for f in `find . -name "*Dict"` diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index 3766cb0ba8..e950e4d4d5 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -12,4 +12,10 @@ fieldValues/face/faceSourceFunctionObject.C fieldValues/cell/cellSource.C fieldValues/cell/cellSourceFunctionObject.C +streamLine/streamLine.C +streamLine/streamLineParticle.C +streamLine/streamLineParticleCloud.C +streamLine/streamLineFunctionObject.C + + LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects diff --git a/src/postProcessing/functionObjects/field/Make/options b/src/postProcessing/functionObjects/field/Make/options index 5166bcc9e3..1e254fd4bb 100644 --- a/src/postProcessing/functionObjects/field/Make/options +++ b/src/postProcessing/functionObjects/field/Make/options @@ -1,9 +1,11 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude LIB_LIBS = \ -lfiniteVolume \ -lmeshTools \ + -llagrangian \ -lsampling diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C index 0b6fa1ff03..fe495fcca6 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C @@ -46,11 +46,7 @@ bool Foam::fieldValues::cellSource::setFieldValues { const vf& field = obr_.lookupObject(fieldName); - forAll(values, i) - { - label cellI = cellId_[i]; - values[i] = field[cellI]; - } + values = UIndirectList(field, cellId_); return true; } @@ -158,16 +154,7 @@ Foam::tmp > Foam::fieldValues::cellSource::filterField const Field& field ) const { - tmp > tvalues(new Field(cellId_.size())); - Field& values = tvalues(); - - forAll(values, i) - { - label cellI = cellId_[i]; - values[i] = field[cellI]; - } - - return tvalues; + return tmp >(new Field(field, cellId_)); } diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLine.C b/src/postProcessing/functionObjects/field/streamLine/streamLine.C new file mode 100644 index 0000000000..b82041966f --- /dev/null +++ b/src/postProcessing/functionObjects/field/streamLine/streamLine.C @@ -0,0 +1,620 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "Pstream.H" +#include "functionObjectList.H" +#include "streamLine.H" +#include "fvMesh.H" +#include "streamLineParticleCloud.H" +#include "ReadFields.H" +#include "meshSearch.H" +#include "sampledSet.H" +#include "globalIndex.H" +#include "mapDistribute.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::streamLine, 0); + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::streamLine::track() +{ + const Time& runTime = const_cast(obr_.time()); + const fvMesh& mesh = dynamic_cast(obr_); + + IDLList initialParticles; + streamLineParticleCloud particles + ( + mesh, + cloudName_, + initialParticles + ); + + //Pout<< "Seeding particles." << endl; + + const sampledSet& seedPoints = sampledSetPtr_(); + forAll(seedPoints, i) + { + //Pout<< "Seeded particle at " << seedPoints[i] + // << " at cell:" << seedPoints.cells()[i] + // << endl; + + particles.addParticle + ( + new streamLineParticle + ( + particles, + seedPoints[i], + seedPoints.cells()[i], + lifeTime_ // lifetime + ) + ); + } + label nSeeds = returnReduce(particles.size(), sumOp