mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge remote-tracking branch 'origin/develop' into develop-pre-release
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,16 +34,16 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
const word rotType = dict.lookup("type");
|
||||
const word modelType(dict.get<word>("type"));
|
||||
|
||||
auto cstrIter = objectRegistryConstructorTablePtr_->cfind(rotType);
|
||||
auto cstrIter = objectRegistryConstructorTablePtr_->cfind(modelType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Unknown coordinateRotation type " << rotType << nl << nl
|
||||
<< "Valid coordinateRotation types :" << nl
|
||||
<< objectRegistryConstructorTablePtr_->sortedToc()
|
||||
<< "Unknown coordinateRotation type " << modelType << nl << nl
|
||||
<< "Valid types: "
|
||||
<< flatOutput(objectRegistryConstructorTablePtr_->sortedToc())
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -56,16 +56,16 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
const word rotType = dict.lookup("type");
|
||||
const word modelType(dict.get<word>("type"));
|
||||
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(rotType);
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Unknown coordinateRotation type " << rotType << nl << nl
|
||||
<< "Valid coordinateRotation types :" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< "Unknown coordinateRotation type " << modelType << nl << nl
|
||||
<< "Valid types: "
|
||||
<< flatOutput(dictionaryConstructorTablePtr_->sortedToc())
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -147,9 +147,21 @@ Foam::coordinateSystem::coordinateSystem
|
||||
{
|
||||
const entry* entryPtr = dict.lookupEntryPtr(typeName_(), false, false);
|
||||
|
||||
// non-dictionary entry is a lookup into global coordinateSystems
|
||||
if (entryPtr && !entryPtr->isDict())
|
||||
if (!entryPtr)
|
||||
{
|
||||
// No 'coordinateSystem' entry
|
||||
init(dict, obr);
|
||||
}
|
||||
else if (entryPtr->isDict())
|
||||
{
|
||||
// 'coordinateSystem' as dictionary entry - use it
|
||||
init(entryPtr->dict(), obr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'coordinateSystem' as non-dictionary entry
|
||||
// - this is a lookup into global coordinateSystems
|
||||
|
||||
keyType key(entryPtr->stream());
|
||||
|
||||
const coordinateSystems& lst = coordinateSystems::New(obr);
|
||||
@ -170,15 +182,11 @@ Foam::coordinateSystem::coordinateSystem
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// copy coordinateSystem, but assign the name as the typeName
|
||||
// Copy from coordinateSystem, but assign the name as the typeName
|
||||
// to avoid strange things in writeDict()
|
||||
operator=(lst[index]);
|
||||
name_ = typeName_();
|
||||
}
|
||||
else
|
||||
{
|
||||
init(dict, obr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -202,7 +210,7 @@ Foam::dictionary Foam::coordinateSystem::dict(bool ignoreType) const
|
||||
|
||||
dict.add("name", name_);
|
||||
|
||||
// only write type for derived types
|
||||
// Only write type for derived types
|
||||
if (!ignoreType && type() != typeName_())
|
||||
{
|
||||
dict.add("type", type());
|
||||
@ -296,8 +304,6 @@ void Foam::coordinateSystem::transfer(coordinateSystem& cs)
|
||||
note_ = std::move(cs.note_);
|
||||
origin_ = std::move(cs.origin_);
|
||||
R_ = std::move(cs.R_);
|
||||
|
||||
cs.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -340,7 +346,16 @@ void Foam::coordinateSystem::operator=(const coordinateSystem& cs)
|
||||
name_ = cs.name_;
|
||||
note_ = cs.note_;
|
||||
origin_ = cs.origin_;
|
||||
R_ = cs.R_.clone();
|
||||
|
||||
// Some extra safety
|
||||
if (cs.R_.valid())
|
||||
{
|
||||
R_ = cs.R_.clone();
|
||||
}
|
||||
else
|
||||
{
|
||||
R_.reset(new axesRotation(sphericalTensor::I));
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::coordinateSystem::operator=(coordinateSystem&& cs)
|
||||
@ -349,38 +364,27 @@ void Foam::coordinateSystem::operator=(coordinateSystem&& cs)
|
||||
}
|
||||
|
||||
|
||||
void Foam::coordinateSystem::init(const dictionary& rhs)
|
||||
void Foam::coordinateSystem::init(const dictionary& dict)
|
||||
{
|
||||
rhs.lookup("origin") >> origin_;
|
||||
dict.lookup("origin") >> origin_;
|
||||
note_.clear();
|
||||
rhs.readIfPresent("note", note_);
|
||||
R_ = coordinateRotation::New(rhs.subDict("coordinateRotation"));
|
||||
dict.readIfPresent("note", note_);
|
||||
R_ = coordinateRotation::New(dict.subDict("coordinateRotation"));
|
||||
}
|
||||
|
||||
|
||||
void Foam::coordinateSystem::init
|
||||
(
|
||||
const dictionary& rhs,
|
||||
const dictionary& dict,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "coordinateSystem::operator="
|
||||
"("
|
||||
"const dictionary&, "
|
||||
"const objectRegistry&"
|
||||
") : "
|
||||
<< "assign from " << rhs << endl;
|
||||
}
|
||||
|
||||
rhs.lookup("origin") >> origin_;
|
||||
dict.lookup("origin") >> origin_;
|
||||
|
||||
// The 'note' entry is optional
|
||||
note_.clear();
|
||||
rhs.readIfPresent("note", note_);
|
||||
|
||||
R_ = coordinateRotation::New(rhs.subDict("coordinateRotation"), obr);
|
||||
dict.readIfPresent("note", note_);
|
||||
R_ = coordinateRotation::New(dict.subDict("coordinateRotation"), obr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
// Forward declarations
|
||||
|
||||
class coordinateSystem;
|
||||
|
||||
@ -101,7 +101,8 @@ class coordinateSystem
|
||||
//- Origin
|
||||
point origin_;
|
||||
|
||||
//- Local-to-Global transformation tensor
|
||||
//- Local-to-Global transformation tensor.
|
||||
// May be invalid after a move assignment or transfer
|
||||
autoPtr<coordinateRotation> R_;
|
||||
|
||||
|
||||
@ -110,11 +111,11 @@ protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
//- with optional translation for the origin
|
||||
virtual vector localToGlobal(const vector&, bool translate) const;
|
||||
|
||||
//- Convert from local coordinate system to the global Cartesian system
|
||||
// with optional translation for the origin
|
||||
//- with optional translation for the origin
|
||||
virtual tmp<vectorField> localToGlobal
|
||||
(
|
||||
const vectorField&,
|
||||
@ -122,11 +123,11 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Convert from global Cartesian system to the local coordinate system
|
||||
// with optional translation for the origin
|
||||
//- with optional translation for the origin
|
||||
virtual vector globalToLocal(const vector&, bool translate) const;
|
||||
|
||||
//- Convert from global Cartesian system to the local coordinate system
|
||||
// with optional translation for the origin
|
||||
//- with optional translation for the origin
|
||||
virtual tmp<vectorField> globalToLocal
|
||||
(
|
||||
const vectorField&,
|
||||
@ -134,10 +135,10 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Init from dict and obr
|
||||
void init(const dictionary&);
|
||||
void init(const dictionary& dict);
|
||||
|
||||
//- Init from dictionary
|
||||
void init(const dictionary&, const objectRegistry&);
|
||||
void init(const dictionary& dict, const objectRegistry& obr);
|
||||
|
||||
|
||||
public:
|
||||
@ -182,18 +183,18 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from dictionary with a given name
|
||||
coordinateSystem(const word& name, const dictionary&);
|
||||
coordinateSystem(const word& name, const dictionary& dict);
|
||||
|
||||
//- Construct from dictionary with default name
|
||||
coordinateSystem(const dictionary&);
|
||||
explicit coordinateSystem(const dictionary& dict);
|
||||
|
||||
//- Construct from dictionary (default name)
|
||||
// With the ability to reference global coordinateSystems
|
||||
coordinateSystem(const objectRegistry&, const dictionary&);
|
||||
coordinateSystem(const objectRegistry& obr, const dictionary& dict);
|
||||
|
||||
//- Construct from Istream
|
||||
// The Istream contains a word followed by a dictionary
|
||||
coordinateSystem(Istream&);
|
||||
coordinateSystem(Istream& is);
|
||||
|
||||
|
||||
//- Return clone
|
||||
@ -322,10 +323,10 @@ public:
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
virtual void write(Ostream& os) const;
|
||||
|
||||
//- Write dictionary
|
||||
void writeDict(Ostream&, bool subDict=true) const;
|
||||
void writeDict(Ostream& os, bool subDict=true) const;
|
||||
|
||||
|
||||
// Transformations
|
||||
@ -396,7 +397,7 @@ public:
|
||||
void operator=(coordinateSystem&& cs);
|
||||
|
||||
|
||||
// friend Operators
|
||||
// Friend Operators
|
||||
|
||||
friend bool operator!=
|
||||
(
|
||||
@ -407,7 +408,11 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const coordinateSystem&);
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const coordinateSystem& cs
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -35,9 +35,9 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
)
|
||||
{
|
||||
const dictionary& coordDict = dict.subDict(typeName_());
|
||||
const word coordType = coordDict.lookup("type");
|
||||
const word modelType(coordDict.get<word>("type"));
|
||||
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(coordType);
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
@ -45,9 +45,9 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
|
||||
(
|
||||
dict
|
||||
) << "Unknown coordinateSystem type "
|
||||
<< coordType << nl << nl
|
||||
<< "Valid coordinateSystem types :" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< modelType << nl << nl
|
||||
<< "Valid types: "
|
||||
<< flatOutput(dictionaryConstructorTablePtr_->sortedToc())
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user