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.
This commit is contained in:
Mark Olesen
2020-02-14 15:24:41 +01:00
parent 2834193c27
commit ac709da3ac
3 changed files with 11 additions and 91 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -234,23 +234,12 @@ Foam::Field<Type>::Field
<< exit(FatalIOError); << 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<Type>(is));
}
else else
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "Expected keyword 'uniform' or 'nonuniform', found " << "Expected keyword 'uniform' or 'nonuniform', found "
<< firstToken.info() << exit(FatalIOError); << firstToken.info() << nl
<< exit(FatalIOError);
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. 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::pointField> Foam::mappedPatchBase::readListOrField
(
const word& keyword,
const dictionary& dict,
const label size
)
{
tmp<pointField> 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<vector>(is);
}
else if (firstToken.wordToken() == "nonuniform")
{
is >> static_cast<List<vector>&>(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<List<vector>&>(fld);
}
}
return tfld;
}
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
Foam::mappedPatchBase::mappedPatchBase Foam::mappedPatchBase::mappedPatchBase
@ -1026,8 +965,8 @@ Foam::mappedPatchBase::mappedPatchBase
coupleGroup_(dict), coupleGroup_(dict),
offsetMode_(UNIFORM), offsetMode_(UNIFORM),
offset_(Zero), offset_(Zero),
offsets_(0), offsets_(),
distance_(0.0), distance_(0),
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(nullptr), mapPtr_(nullptr),
AMIPtr_(nullptr), AMIPtr_(nullptr),
@ -1057,7 +996,7 @@ Foam::mappedPatchBase::mappedPatchBase
case NONUNIFORM: case NONUNIFORM:
{ {
offsets_ = readListOrField("offsets", dict, patch_.size()); offsets_ = pointField("offsets", dict, patch_.size());
} }
break; break;
@ -1075,7 +1014,7 @@ Foam::mappedPatchBase::mappedPatchBase
else if (dict.found("offsets")) else if (dict.found("offsets"))
{ {
offsetMode_ = NONUNIFORM; offsetMode_ = NONUNIFORM;
offsets_ = readListOrField("offsets", dict, patch_.size()); offsets_ = pointField("offsets", dict, patch_.size());
} }
else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI) else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
{ {
@ -1102,7 +1041,7 @@ Foam::mappedPatchBase::mappedPatchBase
offsetMode_(UNIFORM), offsetMode_(UNIFORM),
offset_(Zero), offset_(Zero),
offsets_(0), offsets_(0),
distance_(0.0), distance_(0),
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(nullptr), mapPtr_(nullptr),
AMIPtr_(nullptr), AMIPtr_(nullptr),
@ -1175,7 +1114,7 @@ Foam::mappedPatchBase::mappedPatchBase
( (
offsetMode_ == NONUNIFORM offsetMode_ == NONUNIFORM
? vectorField(mpb.offsets_, mapAddressing) ? vectorField(mpb.offsets_, mapAddressing)
: vectorField(0) : vectorField()
), ),
distance_(mpb.distance_), distance_(mpb.distance_),
sameRegion_(mpb.sameRegion_), sameRegion_(mpb.sameRegion_),

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -71,7 +72,6 @@ Description
Note: if offsetMode is \c normal it uses outwards pointing normals. So Note: if offsetMode is \c normal it uses outwards pointing normals. So
supply a negative distance if sampling inside the domain. supply a negative distance if sampling inside the domain.
Note Note
Storage is not optimal. It temporary collects all (patch)face centres Storage is not optimal. It temporary collects all (patch)face centres
on all processors to keep the addressing calculation simple. on all processors to keep the addressing calculation simple.
@ -279,14 +279,6 @@ protected:
//- Calculate AMI interpolator //- Calculate AMI interpolator
void calcAMI() const; void calcAMI() const;
//- Helper to read field or non-uniform list from dictionary
static tmp<pointField> readListOrField
(
const word& keyword,
const dictionary& dict,
const label size
);
public: public: