diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H index 35881bb544..602a04a6e5 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H @@ -4,7 +4,8 @@ fvm::ddt(rho, U) + fvm::div(phi, U) + turb.divDevRhoReff(U) - + fvOptions(rho, U) + == + fvOptions(rho, U) ); UEqn().relax(); diff --git a/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C b/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C index e9aa9fb9b9..494acaf05f 100644 --- a/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C +++ b/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C @@ -77,8 +77,6 @@ int main(int argc, char *argv[]) #include "setrDeltaT.H" - tmp tphiAlpha; - // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { @@ -91,8 +89,6 @@ int main(int argc, char *argv[]) #define LTSSOLVE #include "alphaEqnSubCycle.H" #undef LTSSOLVE - - interface.correct(); } turbulence->correct(); diff --git a/applications/solvers/multiphase/interFoam/MRFInterFoam/MRFInterFoam.C b/applications/solvers/multiphase/interFoam/MRFInterFoam/MRFInterFoam.C index 56527781a2..ccf89e5467 100644 --- a/applications/solvers/multiphase/interFoam/MRFInterFoam/MRFInterFoam.C +++ b/applications/solvers/multiphase/interFoam/MRFInterFoam/MRFInterFoam.C @@ -81,8 +81,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - tmp tphiAlpha; - // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { diff --git a/applications/solvers/multiphase/interFoam/alphaEqn.H b/applications/solvers/multiphase/interFoam/alphaEqn.H index f0e9dab403..d7dddd4fa7 100644 --- a/applications/solvers/multiphase/interFoam/alphaEqn.H +++ b/applications/solvers/multiphase/interFoam/alphaEqn.H @@ -2,11 +2,30 @@ word alphaScheme("div(phi,alpha)"); word alpharScheme("div(phirb,alpha)"); - surfaceScalarField phic(mag(phi/mesh.magSf())); - phic = min(interface.cAlpha()*phic, max(phic)); - surfaceScalarField phir(phic*interface.nHatf()); + // Standard face-flux compression coefficient + surfaceScalarField phic(interface.cAlpha()*mag(phi/mesh.magSf())); + + // Add the optional isotropic compression contribution + if (icAlpha > 0) + { + phic *= (1.0 - icAlpha); + phic += (interface.cAlpha()*icAlpha)*fvc::interpolate(mag(U)); + } + + // Do not compress interface at non-coupled boundary faces + // (inlets, outlets etc.) + forAll(phic.boundaryField(), patchi) + { + fvsPatchScalarField& phicp = phic.boundaryField()[patchi]; + + if (!phicp.coupled()) + { + phicp == 0; + } + } + + tmp tphiAlpha; - //***HGW if (pimple.firstIter() && MULESCorr) if (MULESCorr) { fvScalarMatrix alpha1Eqn @@ -32,12 +51,37 @@ << " Max(alpha1) = " << max(alpha1).value() << endl; - tphiAlpha = alpha1Eqn.flux(); + tmp tphiAlphaUD(alpha1Eqn.flux()); + tphiAlpha = tmp + ( + new surfaceScalarField(tphiAlphaUD()) + ); + + if (alphaApplyPrevCorr && tphiAlphaCorr0.valid()) + { + Info<< "Applying the previous iteration compression flux" << endl; + #ifdef LTSSOLVE + MULES::LTScorrect(alpha1, tphiAlpha(), tphiAlphaCorr0(), 1, 0); + #else + MULES::correct(alpha1, tphiAlpha(), tphiAlphaCorr0(), 1, 0); + #endif + + tphiAlpha() += tphiAlphaCorr0(); + } + + // Cache the upwind-flux + tphiAlphaCorr0 = tphiAlphaUD; + + alpha2 = 1.0 - alpha1; + + interface.correct(); } for (int aCorr=0; aCorr tphiAlpha0 + surfaceScalarField phir(phic*interface.nHatf()); + + tmp tphiAlphaUn ( fvc::flux ( @@ -47,7 +91,7 @@ ) + fvc::flux ( - -fvc::flux(-phir, alpha2, alpharScheme), + -fvc::flux(-phir, alpha2, alpharScheme), alpha1, alpharScheme ) @@ -55,17 +99,29 @@ if (MULESCorr) { - tphiAlpha0() -= tphiAlpha(); + tmp tphiAlphaCorr(tphiAlphaUn() - tphiAlpha()); + volScalarField alpha10(alpha1); + #ifdef LTSSOLVE - MULES::LTScorrect(alpha1, tphiAlpha0(), 1, 0); + MULES::LTScorrect(alpha1, tphiAlphaUn(), tphiAlphaCorr(), 1, 0); #else - MULES::correct(alpha1, tphiAlpha0(), 1, 0); + MULES::correct(alpha1, tphiAlphaUn(), tphiAlphaCorr(), 1, 0); #endif - tphiAlpha() += tphiAlpha0(); + + // Under-relax the correction for more than 3 correctors + if (aCorr < 3) + { + tphiAlpha() += tphiAlphaCorr(); + } + else + { + alpha1 = 0.5*alpha1 + 0.5*alpha10; + tphiAlpha() += 0.5*tphiAlphaCorr(); + } } else { - tphiAlpha = tphiAlpha0; + tphiAlpha = tphiAlphaUn; #ifdef LTSSOLVE MULES::explicitLTSSolve(alpha1, phi, tphiAlpha(), 1, 0); @@ -75,10 +131,17 @@ } alpha2 = 1.0 - alpha1; + + interface.correct(); } rhoPhi = tphiAlpha()*(rho1 - rho2) + phi*rho2; + if (alphaApplyPrevCorr && MULESCorr) + { + tphiAlphaCorr0 = tphiAlpha() - tphiAlphaCorr0; + } + Info<< "Phase-1 volume fraction = " << alpha1.weightedAverage(mesh.Vsc()).value() << " Min(alpha1) = " << min(alpha1).value() diff --git a/applications/solvers/multiphase/interFoam/createFields.H b/applications/solvers/multiphase/interFoam/createFields.H index 3039171f77..00a7d12db6 100644 --- a/applications/solvers/multiphase/interFoam/createFields.H +++ b/applications/solvers/multiphase/interFoam/createFields.H @@ -135,3 +135,6 @@ } fv::IOoptionList fvOptions(mesh); + + + tmp tphiAlphaCorr0; diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C index d56e300581..0a3d7ed11e 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C @@ -77,8 +77,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - tmp tphiAlpha; - // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { diff --git a/applications/solvers/multiphase/interFoam/interFoam.C b/applications/solvers/multiphase/interFoam/interFoam.C index 0ddfed5039..f221ff9ad3 100644 --- a/applications/solvers/multiphase/interFoam/interFoam.C +++ b/applications/solvers/multiphase/interFoam/interFoam.C @@ -80,8 +80,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - tmp tphiAlpha; - // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { diff --git a/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C b/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C index 3321da57f9..fad2224461 100644 --- a/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C +++ b/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C @@ -74,8 +74,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - tmp tphiAlpha; - // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { diff --git a/applications/solvers/multiphase/interFoam/porousInterFoam/porousInterFoam.C b/applications/solvers/multiphase/interFoam/porousInterFoam/porousInterFoam.C index 15b4439220..d81f5c93d3 100644 --- a/applications/solvers/multiphase/interFoam/porousInterFoam/porousInterFoam.C +++ b/applications/solvers/multiphase/interFoam/porousInterFoam/porousInterFoam.C @@ -83,8 +83,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - tmp tphiAlpha; - // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H index 45cba01d5b..fb38fed37e 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqn.H @@ -71,6 +71,7 @@ ( geometricOneField(), alpha1, + tphiAlpha(), tphiAlphaCorr(), vDotvmcAlphal, ( diff --git a/doc/Doxygen/css/doxygen.css b/doc/Doxygen/css/doxygen.css index aeed6d325c..f7c4231bef 100644 --- a/doc/Doxygen/css/doxygen.css +++ b/doc/Doxygen/css/doxygen.css @@ -11,49 +11,49 @@ body, table, div, p, dl { /* @group Heading Levels */ h1 { - text-align: center; - font-size: 150%; + text-align: center; + font-size: 150%; } h2 { - font-size: 120%; + font-size: 120%; } h3 { - font-size: 100%; + font-size: 100%; } dt { - font-weight: bold; + font-weight: bold; } div.multicol { - -moz-column-gap: 1em; - -webkit-column-gap: 1em; - -moz-column-count: 3; - -webkit-column-count: 3; + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; } p.startli, p.startdd, p.starttd { - margin-top: 2px; + margin-top: 2px; } p.endli { - margin-bottom: 0px; + margin-bottom: 0px; } p.enddd { - margin-bottom: 4px; + margin-bottom: 4px; } p.endtd { - margin-bottom: 2px; + margin-bottom: 2px; } /* @end */ caption { - font-weight: bold; + font-weight: bold; } span.legend { @@ -67,47 +67,47 @@ h3.version { } div.qindex, div.navtab{ - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + padding: 2px; } div.qindex, div.navpath { - width: 100%; - line-height: 140%; + width: 100%; + line-height: 140%; } div.navtab { - margin-right: 15px; + margin-right: 15px; } /* @group Link Styling */ a { - color: #153788; - font-weight: normal; - text-decoration: none; + color: #153788; + font-weight: normal; + text-decoration: none; } .contents a:visited { - color: #1b77c5; + color: #1b77c5; } a:hover { - text-decoration: underline; + text-decoration: underline; } a.qindex { - font-weight: bold; + font-weight: bold; } a.qindexHL { - font-weight: bold; - background-color: #6666cc; - color: #ffffff; - border: 1px double #9295C2; + font-weight: bold; + background-color: #6666cc; + color: #ffffff; + border: 1px double #9295C2; } .contents a.qindexHL:visited { @@ -115,7 +115,7 @@ a.qindexHL { } a.el { - font-weight: bold; + font-weight: bold; } a.elRef { @@ -134,7 +134,7 @@ a.codeRef { /* @end */ dl.el { - margin-left: -1cm; + margin-left: -1cm; } .fragment { @@ -143,64 +143,64 @@ dl.el { } pre.fragment { - border: 1px solid #CCCCCC; - background-color: #f5f5f5; - padding: 4px 6px; - margin: 4px 8px 4px 2px; - overflow: auto; - word-wrap: break-word; - font-size: 9pt; - line-height: 125%; + border: 1px solid #CCCCCC; + background-color: #f5f5f5; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; } div.ah { - background-color: black; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px } div.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; + margin-left: 16px; + margin-top: 12px; + margin-bottom: 6px; + font-weight: bold; } div.groupText { - margin-left: 16px; - font-style: italic; + margin-left: 16px; + font-style: italic; } body { - background: white; - color: black; - margin-right: 20px; - margin-left: 20px; + background: white; + color: black; + margin-right: 20px; + margin-left: 20px; } td.indexkey { - background-color: #e8eef2; - font-weight: bold; - border: 1px solid #CCCCCC; - margin: 2px 0px 2px 0; - padding: 2px 10px; + background-color: #e8eef2; + font-weight: bold; + border: 1px solid #CCCCCC; + margin: 2px 0px 2px 0; + padding: 2px 10px; } td.indexvalue { - background-color: #e8eef2; - border: 1px solid #CCCCCC; - padding: 2px 10px; - margin: 2px 0px; + background-color: #e8eef2; + border: 1px solid #CCCCCC; + padding: 2px 10px; + margin: 2px 0px; } tr.memlist { - background-color: #f0f0f0; + background-color: #f0f0f0; } p.formulaDsp { - text-align: center; + text-align: center; } img.formulaDsp { @@ -208,23 +208,23 @@ img.formulaDsp { } img.formulaInl { - vertical-align: middle; + vertical-align: middle; } div.center { - text-align: center; + text-align: center; margin-top: 0px; margin-bottom: 0px; padding: 0px; } div.center img { - border: 0px; + border: 0px; } img.footer { - border: 0px; - vertical-align: middle; + border: 0px; + vertical-align: middle; } /* @group Code Colorization */ @@ -287,45 +287,45 @@ span.vhdllogic { /* @end */ .search { - color: #003399; - font-weight: bold; + color: #003399; + font-weight: bold; } form.search { - margin-bottom: 0px; - margin-top: 0px; + margin-bottom: 0px; + margin-top: 0px; } input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; } td.tiny { - font-size: 75%; + font-size: 75%; } .dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #84b0c7; + padding: 4px; + border-collapse: collapse; + border: 1px solid #84b0c7; } th.dirtab { - background: #e8eef2; - font-weight: bold; + background: #e8eef2; + font-weight: bold; } hr { - height: 0px; - border: none; - border-top: 1px solid #666; + height: 0px; + border: none; + border-top: 1px solid #666; } hr.footer { - height: 1px; + height: 1px; } /* @group Member Descriptions */ @@ -333,19 +333,19 @@ hr.footer { .mdescLeft, .mdescRight, .memItemLeft, .memItemRight, .memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; + background-color: #FAFAFA; + border: none; + margin: 4px; + padding: 1px 0 0 8px; } .mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; + padding: 0px 8px 4px 8px; + color: #555; } .memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #ccc; + border-top: 1px solid #ccc; } .memItemLeft, .memTemplItemLeft { @@ -353,7 +353,7 @@ hr.footer { } .memTemplParams { - color: #606060; + color: #606060; white-space: nowrap; } @@ -364,24 +364,24 @@ hr.footer { /* Styles for detailed member documentation */ .memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; - margin-left: 3px; + font-size: 80%; + color: #606060; + font-weight: normal; + margin-left: 3px; } .memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; } .memitem { - padding: 0; - margin-bottom: 10px; + padding: 0; + margin-bottom: 10px; } .memname { @@ -428,19 +428,19 @@ hr.footer { } .paramkey { - text-align: right; + text-align: right; } .paramtype { - white-space: nowrap; + white-space: nowrap; } .paramname { - color: #602020; - white-space: nowrap; + color: #602020; + white-space: nowrap; } .paramname em { - font-style: normal; + font-style: normal; } /* @end */ @@ -450,21 +450,21 @@ hr.footer { /* for the tree view */ .ftvtree { - font-family: sans-serif; - margin: 0.5em; + font-family: sans-serif; + margin: 0.5em; } /* these are for tree view when used as main index */ .directory { - font-size: 9pt; - font-weight: bold; + font-size: 9pt; + font-weight: bold; } .directory h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; + margin: 0px; + margin-top: 1em; + font-size: 11pt; } /* @@ -476,86 +476,86 @@ proper pixel height of your image. /* .directory h3.swap { - height: 61px; - background-repeat: no-repeat; - background-image: url("yourimage.gif"); + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); } .directory h3.swap span { - display: none; + display: none; } */ .directory > h3 { - margin-top: 0; + margin-top: 0; } .directory p { - margin: 0px; - white-space: nowrap; + margin: 0px; + white-space: nowrap; } .directory div { - display: none; - margin: 0px; + display: none; + margin: 0px; } .directory img { - vertical-align: -30%; + vertical-align: -30%; } /* these are for tree view when not used as main index */ .directory-alt { - font-size: 100%; - font-weight: bold; + font-size: 100%; + font-weight: bold; } .directory-alt h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; + margin: 0px; + margin-top: 1em; + font-size: 11pt; } .directory-alt > h3 { - margin-top: 0; + margin-top: 0; } .directory-alt p { - margin: 0px; - white-space: nowrap; + margin: 0px; + white-space: nowrap; } .directory-alt div { - display: none; - margin: 0px; + display: none; + margin: 0px; } .directory-alt img { - vertical-align: -30%; + vertical-align: -30%; } /* @end */ address { - font-style: normal; - color: #333; + font-style: normal; + color: #333; } table.doxtable { - border-collapse:collapse; + border-collapse:collapse; } table.doxtable td, table.doxtable th { - border: 1px solid #153788; - padding: 3px 7px 2px; + border: 1px solid #153788; + padding: 3px 7px 2px; } table.doxtable th { - background-color: #254798; - color: #FFFFFF; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; - text-align:left; + background-color: #254798; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; } diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C index a9049b07bc..056c55c606 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -110,7 +110,8 @@ Foam::OutputFilterFunctionObject::OutputFilterFunctionObject storeFilter_(true), timeStart_(-VGREAT), timeEnd_(VGREAT), - outputControl_(t, dict) + outputControl_(t, dict, "output"), + evaluateControl_(t, dict, "evaluate") { readDict(); } @@ -159,7 +160,10 @@ bool Foam::OutputFilterFunctionObject::execute allocateFilter(); } - ptr_->execute(); + if (evaluateControl_.output()) + { + ptr_->execute(); + } if (forceWrite || outputControl_.output()) { @@ -241,14 +245,14 @@ bool Foam::OutputFilterFunctionObject::adjustTimeStep() // function objects modify deltaT inside nStepsToStartTimeChange range // NOTE: Potential problem if two function objects dump inside the same - //interval + // interval if (nSteps < nStepsToStartTimeChange_) { label nStepsToNextWrite = label(nSteps) + 1; scalar newDeltaT = timeToNextWrite/nStepsToNextWrite; - //Adjust time step + // Adjust time step if (newDeltaT < deltaT) { deltaT = max(newDeltaT, 0.2*deltaT); diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index c9cc34c8ce..6e874dc52a 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -98,6 +98,9 @@ class OutputFilterFunctionObject //- Output controls outputFilterOutputControl outputControl_; + //- Evaluate controls + outputFilterOutputControl evaluateControl_; + //- Pointer to the output filter autoPtr ptr_; diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C index b711b2d17f..f2bab5983a 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C @@ -31,9 +31,18 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const Foam::word Foam::functionObjectFile::outputPrefix = "postProcessing"; +Foam::label Foam::functionObjectFile::addChars = 7; // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +void Foam::functionObjectFile::initStream(Ostream& os) const +{ + os.setf(ios_base::scientific, ios_base::floatfield); +// os.precision(IOstream::defaultPrecision()); + os.width(charWidth()); +} + + Foam::fileName Foam::functionObjectFile::baseFileDir() const { fileName baseDir = obr_.time().path(); @@ -96,6 +105,8 @@ void Foam::functionObjectFile::createFiles() filePtrs_.set(i, new OFstream(outputDir/(fName + ".dat"))); + initStream(filePtrs_[i]); + writeFileHeader(i); i++; @@ -147,6 +158,12 @@ void Foam::functionObjectFile::resetName(const word& name) } +Foam::Omanip Foam::functionObjectFile::valueWidth(const label offset) const +{ + return setw(IOstream::defaultPrecision() + addChars + offset); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjectFile::functionObjectFile @@ -289,4 +306,42 @@ Foam::OFstream& Foam::functionObjectFile::file(const label i) } +Foam::label Foam::functionObjectFile::charWidth() const +{ + return IOstream::defaultPrecision() + addChars; +} + + +void Foam::functionObjectFile::writeCommented +( + Ostream& os, + const string& str +) const +{ + os << setw(1) << "#" << setw(1) << ' ' + << setw(charWidth() - 2) << str.c_str(); +} + + +void Foam::functionObjectFile::writeTabbed +( + Ostream& os, + const string& str +) const +{ + os << tab << setw(charWidth()) << str.c_str(); +} + + +void Foam::functionObjectFile::writeHeader +( + Ostream& os, + const string& str +) const +{ + os << setw(1) << "#" << setw(1) << ' ' + << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str() << nl; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H index f4c0ab1178..5488da6e58 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,6 +43,7 @@ SourceFiles #include "OFstream.H" #include "PtrList.H" #include "HashSet.H" +#include "IOmanip.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -77,6 +78,9 @@ protected: // Protected Member Functions + //- Initialise the output stream for writing + virtual void initStream(Ostream& os) const; + //- Return the base directory for output virtual fileName baseFileDir() const; @@ -98,6 +102,9 @@ protected: //- Reset the list of names to a single name entry virtual void resetName(const word& name); + //- Return the value width when writing to stream with optional offset + virtual Omanip valueWidth(const label offset = 0) const; + //- Disallow default bitwise copy construct functionObjectFile(const functionObjectFile&); @@ -110,6 +117,9 @@ public: //- Folder prefix static const word outputPrefix; + //- Additional characters for writing + static label addChars; + // Constructors //- Construct null @@ -149,6 +159,39 @@ public: //- Return file 'i' OFstream& file(const label i); + + //- Write a commented string to stream + void writeCommented + ( + Ostream& os, + const string& str + ) const; + + //- Write a tabbed string to stream + void writeTabbed + ( + Ostream& os, + const string& str + ) const; + + //- Write a commented header to stream + void writeHeader + ( + Ostream& os, + const string& str + ) const; + + //- Write a (commented) header property and value pair + template + void writeHeaderValue + ( + Ostream& os, + const string& property, + const Type& value + ) const; + + //- Return width of character stream output + label charWidth() const; }; @@ -158,6 +201,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository + #include "functionObjectFileTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C new file mode 100644 index 0000000000..a9180e1fee --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "OStringStream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +void Foam::functionObjectFile::writeHeaderValue +( + Ostream& os, + const string& property, + const Type& value +) const +{ + os << setw(1) << '#' << setw(1) << ' ' + << setw(charWidth() - 2) << setf(ios_base::left) << property.c_str() + << setw(1) << ':' << setw(1) << ' ' << value << nl; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C index 6865b31fb9..5ddb9d564b 100644 --- a/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C +++ b/src/OpenFOAM/db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C @@ -31,7 +31,7 @@ License namespace Foam { template<> - const char* NamedEnum:: + const char* NamedEnum:: names[] = { "timeStep", @@ -39,11 +39,12 @@ namespace Foam "adjustableTime", "runTime", "clockTime", - "cpuTime" + "cpuTime", + "none" }; } -const Foam::NamedEnum +const Foam::NamedEnum Foam::outputFilterOutputControl::outputControlNames_; @@ -52,10 +53,12 @@ const Foam::NamedEnum Foam::outputFilterOutputControl::outputFilterOutputControl ( const Time& t, - const dictionary& dict + const dictionary& dict, + const word& prefix ) : time_(t), + prefix_(prefix), outputControl_(ocTimeStep), outputInterval_(0), outputTimeLastDump_(0), @@ -75,9 +78,12 @@ Foam::outputFilterOutputControl::~outputFilterOutputControl() void Foam::outputFilterOutputControl::read(const dictionary& dict) { - if (dict.found("outputControl")) + const word controlName(prefix_ + "Control"); + const word intervalName(prefix_ + "Interval"); + + if (dict.found(controlName)) { - outputControl_ = outputControlNames_.read(dict.lookup("outputControl")); + outputControl_ = outputControlNames_.read(dict.lookup(controlName)); } else { @@ -88,13 +94,13 @@ void Foam::outputFilterOutputControl::read(const dictionary& dict) { case ocTimeStep: { - outputInterval_ = dict.lookupOrDefault