From ac709da3acde6f39cc0a9d0ecf3d3d78fa3820d0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 14 Feb 2020 15:24:41 +0100 Subject: [PATCH] STYLE: FatalError instead of warning for handling deprecated field format - The warning in Field.C has been emitted since 2005. - The warning in mappedPatchBase.C has been emitted since 2012. --- src/OpenFOAM/fields/Fields/Field/Field.C | 17 +---- .../mappedPolyPatch/mappedPatchBase.C | 75 ++----------------- .../mappedPolyPatch/mappedPatchBase.H | 10 +-- 3 files changed, 11 insertions(+), 91 deletions(-) diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index ec5e891691..45bc05f2a8 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -234,23 +234,12 @@ Foam::Field::Field << exit(FatalIOError); } } - else if (is.version() == IOstream::versionNumber(2,0)) - { - IOWarningInFunction(dict) - << "Expected keyword 'uniform' or 'nonuniform', " - "assuming deprecated Field format from " - "Foam version 2.0." << endl; - - this->setSize(len); - - is.putBack(firstToken); - operator=(pTraits(is)); - } else { FatalIOErrorInFunction(dict) << "Expected keyword 'uniform' or 'nonuniform', found " - << firstToken.info() << exit(FatalIOError); + << firstToken.info() << nl + << exit(FatalIOError); } } } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 1a07f5c800..af6b90cf2e 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2018 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -846,67 +846,6 @@ void Foam::mappedPatchBase::calcAMI() const } -// Hack to read old (List-based) format. See Field.C. The difference -// is only that in case of falling back to old format it expects a non-uniform -// list instead of a single vector. -Foam::tmp Foam::mappedPatchBase::readListOrField -( - const word& keyword, - const dictionary& dict, - const label size -) -{ - tmp tfld(new pointField()); - pointField& fld = tfld.ref(); - - if (size) - { - ITstream& is = dict.lookup(keyword); - - // Read first token - token firstToken(is); - - if (firstToken.isWord()) - { - if (firstToken.wordToken() == "uniform") - { - fld.setSize(size); - fld = pTraits(is); - } - else if (firstToken.wordToken() == "nonuniform") - { - is >> static_cast&>(fld); - if (fld.size() != size) - { - FatalIOErrorInFunction(dict) - << "size " << fld.size() - << " is not equal to the given value of " << size - << exit(FatalIOError); - } - } - else - { - FatalIOErrorInFunction(dict) - << "Expected keyword 'uniform' or 'nonuniform', found " - << firstToken.wordToken() - << exit(FatalIOError); - } - } - else if (is.version() == IOstream::versionNumber(2,0)) - { - IOWarningInFunction(dict) - << "Expected keyword 'uniform' or 'nonuniform', " - "assuming List format for backwards compatibility." - "Foam version 2.0." << endl; - - is.putBack(firstToken); - is >> static_cast&>(fld); - } - } - return tfld; -} - - // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * // Foam::mappedPatchBase::mappedPatchBase @@ -1026,8 +965,8 @@ Foam::mappedPatchBase::mappedPatchBase coupleGroup_(dict), offsetMode_(UNIFORM), offset_(Zero), - offsets_(0), - distance_(0.0), + offsets_(), + distance_(0), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), mapPtr_(nullptr), AMIPtr_(nullptr), @@ -1057,7 +996,7 @@ Foam::mappedPatchBase::mappedPatchBase case NONUNIFORM: { - offsets_ = readListOrField("offsets", dict, patch_.size()); + offsets_ = pointField("offsets", dict, patch_.size()); } break; @@ -1075,7 +1014,7 @@ Foam::mappedPatchBase::mappedPatchBase else if (dict.found("offsets")) { offsetMode_ = NONUNIFORM; - offsets_ = readListOrField("offsets", dict, patch_.size()); + offsets_ = pointField("offsets", dict, patch_.size()); } else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI) { @@ -1102,7 +1041,7 @@ Foam::mappedPatchBase::mappedPatchBase offsetMode_(UNIFORM), offset_(Zero), offsets_(0), - distance_(0.0), + distance_(0), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), mapPtr_(nullptr), AMIPtr_(nullptr), @@ -1175,7 +1114,7 @@ Foam::mappedPatchBase::mappedPatchBase ( offsetMode_ == NONUNIFORM ? vectorField(mpb.offsets_, mapAddressing) - : vectorField(0) + : vectorField() ), distance_(mpb.distance_), sameRegion_(mpb.sameRegion_), diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H index 9e4f788c0a..ac4f6c7fb5 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +72,6 @@ Description Note: if offsetMode is \c normal it uses outwards pointing normals. So supply a negative distance if sampling inside the domain. - Note Storage is not optimal. It temporary collects all (patch)face centres on all processors to keep the addressing calculation simple. @@ -279,14 +279,6 @@ protected: //- Calculate AMI interpolator void calcAMI() const; - //- Helper to read field or non-uniform list from dictionary - static tmp readListOrField - ( - const word& keyword, - const dictionary& dict, - const label size - ); - public: