From 21bc7a0c397ebee050f8b9b7477f64e463ddea21 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 28 Jan 2016 15:36:42 +0000 Subject: [PATCH 1/2] ENH: utilities: small merge of dev functionality --- .../mesh/conversion/star3ToFoam/readPoints.C | 11 ++++--- .../foamFormatConvert/foamFormatConvert.C | 32 ++++++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/applications/utilities/mesh/conversion/star3ToFoam/readPoints.C b/applications/utilities/mesh/conversion/star3ToFoam/readPoints.C index 3965e6e94b..818befe4a5 100644 --- a/applications/utilities/mesh/conversion/star3ToFoam/readPoints.C +++ b/applications/utilities/mesh/conversion/star3ToFoam/readPoints.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,6 +37,11 @@ Foam::label Foam::starMesh::readVtxLabel(IFstream& is) for (int i=0; i<15; i++) { + if (!is.good()) + { + return -1; + } + is.get(lcs[i]); } @@ -85,12 +90,10 @@ void Foam::starMesh::readPoints(const scalar scaleFactor) if (pointsFile.good()) { - label pointLabel; - maxLabel = -1; while (pointsFile) { - pointLabel = readVtxLabel(pointsFile); + label pointLabel = readVtxLabel(pointsFile); if (!pointsFile) break; diff --git a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C index 62bb65f89f..32054b8310 100644 --- a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C +++ b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,6 +38,16 @@ Description we detect the keywords in zones and redo the dictionary entries to be labelLists. +Usage + + - foamFormatConvert [OPTION] + + \param -noConstant \n + Exclude the constant/ directory from the times list + + \param -enableFunctionEntries \n + By default all dictionary preprocessing of fields is disabled + \*---------------------------------------------------------------------------*/ #include "argList.H" @@ -148,6 +158,11 @@ int main(int argc, char *argv[]) "noConstant", "exclude the 'constant/' dir in the times list" ); + argList::addBoolOption + ( + "enableFunctionEntries", + "enable expansion of dictionary directives - #include, #codeStream etc" + ); #include "addRegionOption.H" #include "setRootCase.H" @@ -166,6 +181,19 @@ int main(int argc, char *argv[]) #include "createTime.H" + const bool enableEntries = args.optionFound("enableFunctionEntries"); + if (enableEntries) + { + Info<< "Allowing dictionary preprocessing ('#include', '#codeStream')." + << endl; + } + + int oldFlag = entry::disableFunctionEntries; + if (!enableEntries) + { + // By default disable dictionary expansion for fields + entry::disableFunctionEntries = 1; + } // Make sure we do not use the master-only reading since we read // fields (different per processor) as dictionaries. @@ -267,6 +295,8 @@ int main(int argc, char *argv[]) Info<< endl; } + entry::disableFunctionEntries = oldFlag; + Info<< "End\n" << endl; return 0; From 427b3704b4f8ee83386f864b810aa5b2bac4dd7e Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 4 Feb 2016 14:57:44 +0000 Subject: [PATCH 2/2] BUG: fixedFluxPressure: map if no internal field. Fixes #61 --- .../fixedFluxPressureFvPatchScalarField.C | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index 0b330ec9cd..7c2da576c9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -86,15 +86,26 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField gradient().map(ptf.gradient(), mapper); // Evaluate the value field from the gradient if the internal field is valid - if (notNull(iF) && iF.size()) + if (notNull(iF)) { - scalarField::operator= - ( - //patchInternalField() + gradient()/patch().deltaCoeffs() - // ***HGW Hack to avoid the construction of mesh.deltaCoeffs - // which fails for AMI patches for some mapping operations - patchInternalField() + gradient()*(patch().nf() & patch().delta()) - ); + if (iF.size()) + { + // Note: cannot ask for nf() if zero faces + + scalarField::operator= + ( + //patchInternalField() + gradient()/patch().deltaCoeffs() + // ***HGW Hack to avoid the construction of mesh.deltaCoeffs + // which fails for AMI patches for some mapping operations + patchInternalField() + + gradient()*(patch().nf() & patch().delta()) + ); + } + } + else + { + // Enforce mapping of values so we have a valid starting value + this->map(ptf, mapper); } }