ENH: consistency improvements for surface patch handling (fixes #483)

- remove (unused) Istream constructors, prune some unused methods,
  rationalize write() vs writeDict().
  Deprecate inconsistent construction order.

- handle empty names for ".ftr" surface patches (for plain triSurface
  format) with double-quoted strings for more reliable streaming.
  Written on a single line.

  This is _backward_ compatible, but if users have been parsing these
  files manually, they will need to adjust their code.

Previously:
```
  (
  frt-fairing:001%1
  empty

  windshield:002%2
  empty
  ...
  )
```

Updated (with example handling of empty name):
```
  (
  frt-fairing:001%1 empty

  windshield:002%2 ""
  ...
  )
```
This commit is contained in:
Mark Olesen
2020-01-16 10:07:26 +01:00
parent 9dbf94777c
commit 2a98c4e665
29 changed files with 625 additions and 567 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -550,9 +550,9 @@ int main(int argc, char *argv[])
{
patches[nRegions] = geometricSurfacePatch
(
"patch",
geometry[surfaces[i]].name() + "_" + regions[regionI],
nRegions
nRegions,
"patch"
);
nRegions++;
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -262,9 +263,9 @@ int main(int argc, char *argv[])
{
patches[nRegions] = geometricSurfacePatch
(
"patch",
geometry[surfaces[i]].name() + "_" + regions[regionI],
nRegions
nRegions,
"patch"
);
nRegions++;
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -121,9 +122,9 @@ bool Foam::searchableSurfaceModifiers::autoPatch::modify
{
geometricSurfacePatch patch
(
surf.patches()[regionI].geometricType(),
surf.patches()[regionI].name() + Foam::name(subI),
surf.patches().size()
surf.patches().size(),
surf.patches()[regionI].geometricType()
);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,13 +74,12 @@ void Foam::searchableSurfaceModifiers::cut::triangulate
}
}
geometricSurfacePatchList patches(fcs.size());
forAll(patches, patchI)
forAll(patches, patchi)
{
patches[patchI] = geometricSurfacePatch
patches[patchi] = geometricSurfacePatch
(
"",
"patch" + Foam::name(patchI),
patchI
"patch" + Foam::name(patchi),
patchi
);
}
cutSurf = triSurface(tris, patches, pts, true);
@ -345,9 +345,9 @@ bool Foam::searchableSurfaceModifiers::cut::modify
newPatches.setSize(sz+1);
newPatches[sz] = geometricSurfacePatch
(
newPatches[sz-1].geometricType(),
newPatches[sz-1].name() + "_inside",
newPatches[sz-1].index()
newPatches[sz-1].index(),
newPatches[sz-1].geometricType()
);
Info<< "Moving " << nInside << " out of " << surf3.size()

View File

@ -588,7 +588,6 @@ DebugSwitches
generic 0;
genericPatch 0;
geomCellLooper 0;
geometricSurfacePatch 0;
global 0;
globalIndexAndTransform 0;
globalMeshData 0;
@ -880,7 +879,6 @@ DebugSwitches
surfaceInterpolationScheme 0;
surfaceIntersection 0;
surfaceNormalFixedValue 0;
surfacePatch 0;
surfaceScalarField 0;
surfaceScalarField::Internal 0;
surfaceSlipDisplacement 0;

View File

@ -49,8 +49,7 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
<< exit(FatalError);
}
HashTable<labelList>::const_iterator fnd =
pbm.groupPatchIDs().find(name());
const auto fnd = pbm.groupPatchIDs().cfind(name());
if (!fnd.found())
{
@ -131,18 +130,6 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::coupleGroupIdentifier::coupleGroupIdentifier()
:
name_()
{}
Foam::coupleGroupIdentifier::coupleGroupIdentifier(const word& patchGroupName)
:
name_(patchGroupName)
{}
Foam::coupleGroupIdentifier::coupleGroupIdentifier(const dictionary& dict)
:
name_()
@ -232,7 +219,7 @@ void Foam::coupleGroupIdentifier::write(Ostream& os) const
}
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const coupleGroupIdentifier& p)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,12 +28,11 @@ Class
Foam::coupleGroupIdentifier
Description
Encapsulates using patchGroups to specify coupled patch
Encapsulates using "patchGroups" to specify coupled patch
SourceFiles
coupleGroupIdentifierI.H
coupleGroupIdentifier.C
coupleGroupIdentifierIO.C
\*---------------------------------------------------------------------------*/
@ -47,16 +47,10 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
class dictionary;
class polyMesh;
class polyPatch;
class Ostream;
// Forward declaration of friend functions and operators
class coupleGroupIdentifier;
Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p);
/*---------------------------------------------------------------------------*\
Class coupleGroupIdentifier Declaration
@ -64,7 +58,7 @@ Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p);
class coupleGroupIdentifier
{
// Private data
// Private Data
//- Name of patchGroup
word name_;
@ -72,7 +66,8 @@ class coupleGroupIdentifier
// Private Member Functions
//- Find other patch in specified mesh. Returns index of patch or -1.
//- Find other patch in specified mesh.
// \return index of patch or -1
label findOtherPatchID
(
const polyMesh& mesh,
@ -82,16 +77,19 @@ class coupleGroupIdentifier
public:
// Generated Methods
//- Default construct
coupleGroupIdentifier() = default;
// Constructors
//- Construct null
coupleGroupIdentifier();
//- Construct from components
coupleGroupIdentifier(const word& patchGroupName);
inline explicit coupleGroupIdentifier(const word& patchGroupName);
//- Construct from dictionary
coupleGroupIdentifier(const dictionary& dict);
explicit coupleGroupIdentifier(const dictionary& dict);
// Member Functions
@ -102,31 +100,30 @@ public:
//- Is a valid patchGroup
inline bool valid() const;
//- Find other patch in same region. Returns index of patch or -1.
//- Find other patch in same region.
// \return index of patch or -1.
label findOtherPatchID(const polyPatch& thisPatch) const;
//- Find other patch and region. Returns index of patch and sets
// otherRegion to name of region. Fatal error if patch not found
//- Find other patch and region.
// Returns index of patch and sets otherRegion to name of region.
// FatalError if patch not found
label findOtherPatchID
(
const polyPatch& thisPatch,
word& otherRegion
) const;
//- Write the data as a dictionary
//- Write the coupleGroup dictionary entry
void write(Ostream& os) const;
// IOstream Operators
friend Ostream& operator<<
(
Ostream& os,
const coupleGroupIdentifier& p
);
};
// Global Operators
//- Write the coupleGroup dictionary entry
Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -25,7 +25,16 @@ License
\*---------------------------------------------------------------------------*/
#include "coupleGroupIdentifier.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::coupleGroupIdentifier::coupleGroupIdentifier
(
const word& patchGroupName
)
:
name_(patchGroupName)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,10 +28,27 @@ License
#include "patchIdentifier.H"
#include "dictionary.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchIdentifier::patchIdentifier()
:
name_(),
index_(0)
{}
Foam::patchIdentifier::patchIdentifier
(
const word& name,
const label index
)
:
name_(name),
index_(index)
{}
Foam::patchIdentifier::patchIdentifier
(
const word& name,
@ -53,8 +71,7 @@ Foam::patchIdentifier::patchIdentifier
const label index
)
:
name_(name),
index_(index)
patchIdentifier(name, index)
{
dict.readIfPresent("physicalType", physicalType_);
dict.readIfPresent("inGroups", inGroups_);
@ -76,18 +93,13 @@ Foam::patchIdentifier::patchIdentifier
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::patchIdentifier::inGroup(const word& name) const
{
return inGroups_.found(name);
}
void Foam::patchIdentifier::write(Ostream& os) const
{
if (physicalType_.size())
{
os.writeEntry("physicalType", physicalType_);
}
if (inGroups_.size())
{
os.writeKeyword("inGroups");
@ -97,7 +109,7 @@ void Foam::patchIdentifier::write(Ostream& os) const
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const patchIdentifier& p)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,18 +39,14 @@ SourceFiles
#define patchIdentifier_H
#include "wordList.H"
#include "label.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
// Forward Declarations
class dictionary;
class patchIdentifier;
Ostream& operator<<(Ostream& os, const patchIdentifier& p);
/*---------------------------------------------------------------------------*\
Class patchIdentifier Declaration
@ -57,7 +54,7 @@ Ostream& operator<<(Ostream& os, const patchIdentifier& p);
class patchIdentifier
{
// Private data
// Private Data
//- Name of patch
word name_;
@ -73,14 +70,32 @@ class patchIdentifier
public:
// Generated Methods
//- Copy construct
patchIdentifier(const patchIdentifier&) = default;
//- Copy assignment
patchIdentifier& operator=(const patchIdentifier&) = default;
//- Destructor
virtual ~patchIdentifier() = default;
// Constructors
//- Default construct, with index zero
patchIdentifier();
//- Construct from mandatory components
patchIdentifier(const word& name, const label index);
//- Construct from components
patchIdentifier
(
const word& name,
const label index,
const word& physicalType = word::null,
const word& physicalType,
const wordList& inGroups = wordList()
);
@ -100,13 +115,9 @@ public:
);
//- Destructor
virtual ~patchIdentifier() = default;
// Member Functions
//- Return the patch name
//- The patch name
const word& name() const
{
return name_;
@ -118,13 +129,13 @@ public:
return name_;
}
//- The optional physical type of the patch
//- The (optional) physical type of the patch
const word& physicalType() const
{
return physicalType_;
}
//- Modifiable optional physical type of the patch
//- Modifiable (optional) physical type of the patch
word& physicalType()
{
return physicalType_;
@ -136,37 +147,43 @@ public:
return index_;
}
//- Modifiable the index of this patch in the boundaryMesh
//- Modifiable index of this patch in the boundaryMesh
label& index()
{
return index_;
}
//- The optional groups that the patch belongs to
//- The (optional) groups that the patch belongs to
const wordList& inGroups() const
{
return inGroups_;
}
//- Modifiable optional groups that the patch belongs to
//- Modifiable (optional) groups that the patch belongs to
wordList& inGroups()
{
return inGroups_;
}
//- Check if the patch is in named group
bool inGroup(const word& name) const;
//- True if the patch is in named group
bool inGroup(const word& name) const
{
return inGroups_.found(name);
}
//- Write patchIdentifier as a dictionary
//- Write (physicalType, inGroups) dictionary entries
//- (without surrounding braces)
void write(Ostream& os) const;
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const patchIdentifier& p);
};
// Global Operators
//- Write (physicalType, inGroups) dictionary entries
//- (without surrounding braces)
Ostream& operator<<(Ostream& os, const patchIdentifier& p);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,31 +29,54 @@ License
#include "geometricSurfacePatch.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(geometricSurfacePatch, 0);
static inline word readOptionalWord(Istream& is)
{
token tok(is);
if (tok.isWord())
{
return tok.wordToken();
}
else
{
// Allow empty words
return word::validate(tok.stringToken());
}
}
const Foam::word Foam::geometricSurfacePatch::emptyType = "empty";
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::geometricSurfacePatch::geometricSurfacePatch()
:
geometricType_(emptyType),
name_("patch"),
index_(0)
geometricSurfacePatch(0)
{}
Foam::geometricSurfacePatch::geometricSurfacePatch(const label index)
:
geometricType_(emptyType),
name_("patch"),
index_(index)
index_(index),
geometricType_(emptyType)
{}
Foam::geometricSurfacePatch::geometricSurfacePatch
(
const word& name,
const label index
)
:
name_(name),
index_(index),
geometricType_()
{}
@ -64,66 +87,10 @@ Foam::geometricSurfacePatch::geometricSurfacePatch
const word& geometricType
)
:
geometricType_(geometricType),
name_(name),
index_(index)
{
if (geometricType_.empty())
{
geometricType_ = emptyType;
}
}
Foam::geometricSurfacePatch::geometricSurfacePatch
(
const word& geometricType,
const word& name,
const label index
)
:
geometricType_(geometricType),
name_(name),
index_(index)
{
if (geometricType_.empty())
{
geometricType_ = emptyType;
}
}
Foam::geometricSurfacePatch::geometricSurfacePatch
(
const surfZoneIdentifier& ident
)
:
geometricType_(ident.geometricType()),
name_(ident.name()),
index_(ident.index())
{
if (geometricType_.empty())
{
geometricType_ = emptyType;
}
}
Foam::geometricSurfacePatch::geometricSurfacePatch
(
Istream& is,
const label index
)
:
geometricType_(is),
name_(is),
index_(index)
{
if (geometricType_.empty())
{
geometricType_ = emptyType;
}
}
index_(index),
geometricType_(geometricType)
{}
Foam::geometricSurfacePatch::geometricSurfacePatch
@ -133,26 +100,31 @@ Foam::geometricSurfacePatch::geometricSurfacePatch
const label index
)
:
geometricType_(emptyType),
name_(name),
index_(index)
index_(index),
geometricType_()
{
dict.readIfPresent("geometricType", geometricType_);
}
Foam::geometricSurfacePatch::geometricSurfacePatch
(
const surfZoneIdentifier& ident
)
:
geometricSurfacePatch(ident.name(), ident.index(), ident.geometricType())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::geometricSurfacePatch::write(Ostream& os) const
{
os << nl << name_
<< nl << geometricType_;
}
void Foam::geometricSurfacePatch::writeDict(Ostream& os) const
{
os.writeEntry("geometricType", geometricType_);
if (geometricType_.size())
{
os.writeEntry("geometricType", geometricType_);
}
}
@ -182,21 +154,54 @@ bool Foam::operator!=
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, geometricSurfacePatch& p)
Foam::Istream& Foam::operator>>(Istream& is, geometricSurfacePatch& obj)
{
is >> p.name_ >> p.geometricType_;
obj.name() = readOptionalWord(is);
obj.geometricType() = readOptionalWord(is);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const geometricSurfacePatch& p)
Foam::Ostream& Foam::operator<<(Ostream& os, const geometricSurfacePatch& obj)
{
p.write(os);
// Force unconditional line-breaks on list output.
// We otherwise risk extremely unreadable entries
os << nl;
// Empty words are double-quoted so they are treated as 'string'
os.writeQuoted(obj.name(), obj.name().empty()) << token::SPACE;
os.writeQuoted(obj.geometricType(), obj.geometricType().empty());
// Equivalent for OpenFOAM-1912 and earlier:
// if (obj.geometricType().empty())
// {
// os << emptyType;
// }
// else
// {
// os << obj.geometricType();
// }
os.check(FUNCTION_NAME);
return os;
}
// * * * * * * * * * * * * * * * Housekeeping * * * * * * * * * * * * * * * //
Foam::geometricSurfacePatch::geometricSurfacePatch
(
const word& geometricType,
const word& name,
const label index
)
:
geometricSurfacePatch(name, index, geometricType)
{}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,7 +39,6 @@ SourceFiles
#ifndef geometricSurfacePatch_H
#define geometricSurfacePatch_H
#include "typeInfo.H"
#include "surfZoneIdentifier.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,13 +46,6 @@ SourceFiles
namespace Foam
{
// Forward declarations
class dictionary;
class geometricSurfacePatch;
Istream& operator>>(Istream& is, geometricSurfacePatch& p);
Ostream& operator<<(Ostream& os, const geometricSurfacePatch& p);
/*---------------------------------------------------------------------------*\
Class geometricSurfacePatch Declaration
\*---------------------------------------------------------------------------*/
@ -62,65 +54,65 @@ class geometricSurfacePatch
{
// Private Data
//- Type name of patch
word geometricType_;
//- Name of patch
word name_;
//- Index of patch in boundary
label index_;
//- Type name of patch
word geometricType_;
public:
// Public Data
//- The name for an 'empty' type
static const word emptyType;
static constexpr const char* const emptyType = "empty";
// Public Classes
//- Helper to convert identifier types as an operation
struct fromIdentifier
{
geometricSurfacePatch operator()(const surfZoneIdentifier& ident)
const
geometricSurfacePatch
operator()(const surfZoneIdentifier& ident) const
{
return geometricSurfacePatch(ident);
}
};
//- Runtime type information
ClassName("geometricSurfacePatch");
// Generated Methods
//- Copy construct
geometricSurfacePatch(const geometricSurfacePatch&) = default;
//- Copy assignment
geometricSurfacePatch&
operator=(const geometricSurfacePatch&) = default;
// Constructors
//- Construct null
//- Default construct, use index=0, name="patch"
geometricSurfacePatch();
//- Construct null with specified index
explicit geometricSurfacePatch(const label index);
//- Construct from mandatory components
geometricSurfacePatch(const word& name, const label index);
//- Construct from components
geometricSurfacePatch
(
const word& name,
const label index,
const word& geometricType = word::null
const word& geometricType
);
//- Construct from components
geometricSurfacePatch
(
const word& geometricType,
const word& name,
const label index
);
//- Implicit conversion from surfZoneIdentifier, which has similar
//- information but in a different order
geometricSurfacePatch(const surfZoneIdentifier& ident);
//- Construct from dictionary
geometricSurfacePatch
(
@ -129,59 +121,76 @@ public:
const label index
);
//- Construct from Istream
geometricSurfacePatch(Istream& is, const label index);
//- Implicit conversion from surfZoneIdentifier
geometricSurfacePatch(const surfZoneIdentifier& ident);
// Member Functions
//- Return name
//- The patch/zone name
const word& name() const
{
return name_;
}
//- Return name
//- Modifiable patch/zone name
word& name()
{
return name_;
}
//- Return the geometric type of the patch
//- The geometric type of the patch/zone
const word& geometricType() const
{
return geometricType_;
}
//- Return the geometric type of the patch for modification
//- Modifiable geometric type of the patch/zone
word& geometricType()
{
return geometricType_;
}
//- Return the index of this patch in the surface mesh
//- The index of this patch/zone in the surface mesh
label index() const
{
return index_;
}
//- Return the index of this patch in the surface mesh for modification
//- Modifiable index of this patch/zone in the surface mesh
label& index()
{
return index_;
}
//- Write
//- Write (geometricType) dictionary entry
//- (without surrounding braces)
// \warning Prior to 2020-01 was identical to operator<< output
void write(Ostream& os) const;
//- Write dictionary
void writeDict(Ostream& os) const;
// Housekeeping
// Ostream Operator
//- Removed(2020-01) Construct from Istream
// \deprecated(2020-01) - unused, inconsistent
geometricSurfacePatch(Istream& is, const label index) = delete;
friend Istream& operator>>(Istream& is, geometricSurfacePatch& p);
friend Ostream& operator<<(Ostream& os, const geometricSurfacePatch& p);
//- Deprecated(2020-01) Construct from components
// \deprecated(2020-01) - order inconsistent with other identifiers
geometricSurfacePatch
(
const word& geometricType,
const word& name,
const label index
) FOAM_DEPRECATED(2020-01);
//- Deprecated(2020-01) Write dictionary
// \deprecated(2020-01) - Write dictionary
void FOAM_DEPRECATED_FOR(2020-01, "write() or operator<<")
writeDict(Ostream& os) const
{
write(os);
}
};
@ -194,6 +203,13 @@ bool operator==(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
bool operator!=(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
//- Read name, geometricType
Istream& operator>>(Istream& is, geometricSurfacePatch& obj);
//- Write name, geometricType. Entries are quoted to support empty words.
Ostream& operator<<(Ostream& os, const geometricSurfacePatch& obj);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -27,6 +27,7 @@ Typedef
Foam::geometricSurfacePatchList
Description
A List of geometricSurfacePatch.
\*---------------------------------------------------------------------------*/
@ -43,7 +44,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<geometricSurfacePatch> geometricSurfacePatchList;
typedef List<geometricSurfacePatch> geometricSurfacePatchList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,9 +29,27 @@ License
#include "surfZoneIdentifier.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
const Foam::word Foam::surfZoneIdentifier::emptyType = "empty";
namespace Foam
{
static inline word readOptionalWord(Istream& is)
{
token tok(is);
if (tok.isWord())
{
return tok.wordToken();
}
else
{
// Allow empty words
return word::validate(tok.stringToken());
}
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -52,6 +70,18 @@ Foam::surfZoneIdentifier::surfZoneIdentifier(const label index)
{}
Foam::surfZoneIdentifier::surfZoneIdentifier
(
const word& name,
const label index
)
:
name_(name),
index_(index),
geometricType_()
{}
Foam::surfZoneIdentifier::surfZoneIdentifier
(
const word& name,
@ -105,7 +135,11 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
bool Foam::operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
bool Foam::operator==
(
const surfZoneIdentifier& a,
const surfZoneIdentifier& b
)
{
return
(
@ -116,7 +150,11 @@ bool Foam::operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
}
bool Foam::operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
bool Foam::operator!=
(
const surfZoneIdentifier& a,
const surfZoneIdentifier& b
)
{
return !(a == b);
}
@ -126,15 +164,24 @@ bool Foam::operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
{
is >> obj.name() >> obj.geometricType();
obj.name() = readOptionalWord(is);
obj.geometricType() = readOptionalWord(is);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj)
{
// Newlines to separate, since that is what triSurface currently expects
os << nl << obj.name() << nl << obj.geometricType();
// Force unconditional line-breaks on list output.
// We otherwise risk extremely unreadable entries
os << nl;
// Empty words are double-quoted so they are treated as 'string'
os.writeQuoted(obj.name(), obj.name().empty()) << token::SPACE;
os.writeQuoted(obj.geometricType(), obj.geometricType().empty());
os.check(FUNCTION_NAME);
return os;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,13 +43,14 @@ SourceFiles
#include "word.H"
#include "label.H"
#include "stdFoam.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
// Forward Declarations
class dictionary;
/*---------------------------------------------------------------------------*\
@ -58,7 +59,7 @@ class dictionary;
class surfZoneIdentifier
{
// Private data
// Private Data
//- Name of zone
word name_;
@ -69,29 +70,40 @@ class surfZoneIdentifier
//- Type name of zone
mutable word geometricType_;
public:
// Public data
// Public Data
//- The name for an 'empty' type
static const word emptyType;
static constexpr const char* const emptyType = "empty";
// Generated Methods
//- Copy construct
surfZoneIdentifier(const surfZoneIdentifier&) = default;
//- Copy assignment
surfZoneIdentifier& operator=(const surfZoneIdentifier&) = default;
// Constructors
//- Construct null, with index zero
//- Default construct, with index zero
surfZoneIdentifier();
//- Construct null with specified index
explicit surfZoneIdentifier(const label index);
//- Construct from mandatory components
surfZoneIdentifier(const word& name, const label index);
//- Construct from components
surfZoneIdentifier
(
const word& name,
const label index,
const word& geometricType = word::null
const word& geometricType
);
//- Construct from dictionary
@ -102,7 +114,7 @@ public:
const label index
);
//- Copy construct from another zone identifier, resetting the index
//- Copy construct, resetting the index
surfZoneIdentifier
(
const surfZoneIdentifier& p,
@ -110,64 +122,52 @@ public:
);
//- Destructor
virtual ~surfZoneIdentifier() = default;
// Member Functions
//- Return name
//- The patch/zone name
const word& name() const
{
return name_;
}
//- Return name for modification
//- Modifiable patch/zone name
word& name()
{
return name_;
}
//- Return the geometric type of the patch/zone
//- The geometric type of the patch/zone
const word& geometricType() const
{
return geometricType_;
}
//- Return the geometric type of the patch/zone for modification
//- Modifiable geometric type of the patch/zone
word& geometricType()
{
return geometricType_;
}
//- Return the index of this patch/zone in the surface mesh
//- The index of this patch/zone in the surface mesh
label index() const
{
return index_;
}
//- Return the index of this patch/zone for modification
//- Modifiable index of this patch/zone in the surface mesh
label& index()
{
return index_;
}
//- Write identifier as a dictionary
//- Write (geometricType) dictionary entry
//- (without surrounding braces)
void write(Ostream& os) const;
};
// Global Operators
// Ostream Operator
//- Read name/type
Istream& operator>>(Istream& is, surfZoneIdentifier& obj);
//- Write name/type
Ostream& operator<<(Ostream& os, const surfZoneIdentifier& obj);
//- Compare zone indentifiers for equality
bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
@ -175,6 +175,13 @@ bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
bool operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
//- Read name, geometricType
Istream& operator>>(Istream& is, surfZoneIdentifier& obj);
//- Write name, geometricType. Entries are quoted to support empty words.
Ostream& operator<<(Ostream& os, const surfZoneIdentifier& obj);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -27,6 +27,7 @@ Typedef
Foam::surfZoneIdentifierList
Description
A List of surfZoneIdentifier.
\*---------------------------------------------------------------------------*/
@ -43,7 +44,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfZoneIdentifier> surfZoneIdentifierList;
typedef List<surfZoneIdentifier> surfZoneIdentifierList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -781,9 +782,9 @@ void Foam::boundaryMesh::writeTriSurface(const fileName& fName) const
surfPatches[patchi] =
geometricSurfacePatch
(
bp.physicalType(),
bp.name(),
patchi
patchi,
bp.physicalType()
);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,34 +60,14 @@ Foam::boundaryPatch::boundaryPatch
{}
Foam::boundaryPatch::boundaryPatch(const boundaryPatch& p)
:
patchIdentifier(p.name(), p.index(), p.physicalType()),
size_(p.size()),
start_(p.start())
{}
Foam::boundaryPatch::boundaryPatch(const boundaryPatch& p, const label index)
:
patchIdentifier(p.name(), index, p.physicalType()),
size_(p.size()),
start_(p.start())
{}
Foam::autoPtr<Foam::boundaryPatch> Foam::boundaryPatch::clone() const
boundaryPatch(p)
{
return autoPtr<boundaryPatch>::New(*this);
patchIdentifier::index() = index;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::boundaryPatch::~boundaryPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::boundaryPatch::write(Ostream& os) const
@ -97,7 +78,7 @@ void Foam::boundaryPatch::write(Ostream& os) const
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const boundaryPatch& p)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,8 +28,9 @@ Class
Foam::boundaryPatch
Description
Like polyPatch but without reference to mesh. patchIdentifier::index
is not used. Used in boundaryMesh to hold data on patches.
Like polyPatch but without reference to mesh.
Used in boundaryMesh to hold data on patches.
The patchIdentifier::index is set, but not used.
SourceFiles
boundaryPatch.C
@ -46,28 +48,25 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
class boundaryPatch;
Ostream& operator<<(Ostream&, const boundaryPatch&);
/*---------------------------------------------------------------------------*\
Class boundaryPatch Declaration
Class boundaryPatch Declaration
\*---------------------------------------------------------------------------*/
class boundaryPatch
:
public patchIdentifier
{
// Private data
// Private Data
label size_;
label start_;
public:
// Generated Methods: copy construct, copy assignment
// Constructors
//- Construct from components
@ -88,18 +87,15 @@ public:
const label index
);
//- Construct as copy
boundaryPatch(const boundaryPatch&);
//- Copy construct, resetting the index
boundaryPatch(const boundaryPatch& p, const label index);
//- Construct as copy, resetting the index
boundaryPatch(const boundaryPatch&, const label index);
//- Clone
autoPtr<boundaryPatch> clone() const;
//- Destructor
~boundaryPatch();
autoPtr<boundaryPatch> clone() const
{
return autoPtr<boundaryPatch>::New(*this);
}
// Member Functions
@ -125,16 +121,17 @@ public:
}
//- Write dictionary
virtual void write(Ostream&) const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const boundaryPatch&);
//- Write dictionary entries (without surrounding braces)
virtual void write(Ostream& os) const;
};
// Global Operators
//- Write boundaryPatch as dictionary entries (without surrounding braces)
Ostream& operator<<(Ostream&, const boundaryPatch& p);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -1019,7 +1019,7 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
if (debug)
{
triSurface surf(tris, geometricSurfacePatchList(0), newPoints);
triSurface surf(tris, geometricSurfacePatchList(), newPoints);
forAll(surf, facei)
{
@ -1054,7 +1054,7 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
}
}
return triSurface(tris, geometricSurfacePatchList(0), newPoints, true);
return triSurface(tris, geometricSurfacePatchList(), newPoints, true);
}

View File

@ -340,7 +340,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface
triSurface surf
(
localTris,
geometricSurfacePatchList(0),
geometricSurfacePatchList(),
localPoints,
true
);
@ -1053,7 +1053,7 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints
}
}
return triSurface(tris, geometricSurfacePatchList(0), newPoints, true);
return triSurface(tris, geometricSurfacePatchList(), newPoints, true);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,15 +28,6 @@ License
#include "surfZone.H"
#include "dictionary.H"
#include "word.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfZone, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -71,19 +62,6 @@ Foam::surfZone::surfZone
{}
Foam::surfZone::surfZone(Istream& is, const label index)
:
surfZoneIdentifier(),
size_(0),
start_(0)
{
word name(is);
dictionary dict(is);
operator=(surfZone(name, dict, index));
}
Foam::surfZone::surfZone
(
const word& name,
@ -97,31 +75,17 @@ Foam::surfZone::surfZone
{}
Foam::surfZone::surfZone(const surfZone& zone)
:
surfZoneIdentifier(zone, zone.index()),
size_(zone.size()),
start_(zone.start())
{}
Foam::surfZone::surfZone(const surfZone& zone, const label index)
:
surfZoneIdentifier(zone, index),
size_(zone.size()),
start_(zone.start())
{}
surfZone(zone)
{
surfZoneIdentifier::index() = index;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfZone::write(Ostream& os) const
{
writeDict(os);
}
void Foam::surfZone::writeDict(Ostream& os) const
{
os.beginBlock(name());
@ -133,39 +97,44 @@ void Foam::surfZone::writeDict(Ostream& os) const
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
bool Foam::surfZone::operator!=(const surfZone& rhs) const
{
return !(*this == rhs);
}
bool Foam::surfZone::operator==(const surfZone& rhs) const
bool Foam::operator==(const surfZone& a, const surfZone& b)
{
return
(
size() == rhs.size()
&& start() == rhs.start()
&& geometricType() == rhs.geometricType()
a.size() == b.size()
&& a.start() == b.start()
&& a.geometricType() == b.geometricType()
);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, surfZone& zone)
bool Foam::operator!=(const surfZone& a, const surfZone& b)
{
zone = surfZone(is, 0);
return !(a == b);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, surfZone& obj)
{
const word name(is);
const dictionary dict(is);
// Could also leave index untouched?
obj = surfZone(name, dict, 0);
is.check(FUNCTION_NAME);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& zone)
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& obj)
{
zone.write(os);
obj.write(os);
os.check(FUNCTION_NAME);
return os;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,9 +40,6 @@ SourceFiles
#ifndef surfZone_H
#define surfZone_H
#include "word.H"
#include "label.H"
#include "className.H"
#include "surfZoneIdentifier.H"
#include "labelRange.H"
#include "autoPtr.H"
@ -53,12 +50,6 @@ SourceFiles
namespace Foam
{
// Forward declarations
class surfZone;
Istream& operator>>(Istream&, surfZone&);
Ostream& operator<<(Ostream&, const surfZone&);
/*---------------------------------------------------------------------------*\
Class surfZone Declaration
\*---------------------------------------------------------------------------*/
@ -67,7 +58,7 @@ class surfZone
:
public surfZoneIdentifier
{
// Private data
// Private Data
//- Size of this group in the face list
label size_;
@ -78,13 +69,18 @@ class surfZone
public:
//- Runtime type information
ClassName("surfZone");
// Generated Methods
//- Copy construct
surfZone(const surfZone&) = default;
//- Copy assignment
surfZone& operator=(const surfZone&) = default;
// Constructors
//- Construct null with zero start, size, index
//- Default construct, with zero start, size, index
surfZone();
//- Construct with name, size. With zero start, index
@ -100,9 +96,6 @@ public:
const word& geometricType = word::null
);
//- Construct from Istream
surfZone(Istream& is, const label index);
//- Construct from dictionary
surfZone
(
@ -111,10 +104,7 @@ public:
const label index
);
//- Construct as copy
surfZone(const surfZone&);
//- Construct from another zone, resetting the index
//- Copy construct, resetting the index
surfZone(const surfZone&, const label index);
//- Return clone
@ -126,8 +116,8 @@ public:
static autoPtr<surfZone> New(Istream& is)
{
word name(is);
dictionary dict(is);
const word name(is);
const dictionary dict(is);
return autoPtr<surfZone>::New(name, dict, 0);
}
@ -135,58 +125,73 @@ public:
// Member Functions
//- Return start label of this zone in the face list
//- The start label of this zone in the face list
label start() const
{
return start_;
}
//- Return start label of this zone in the face list
//- Modifiable start label of this zone in the face list
label& start()
{
return start_;
}
//- Return size of this zone in the face list
//- The size of this zone in the face list
label size() const
{
return size_;
}
//- Return size of this zone in the face list
//- Modifiable size of this zone in the face list
label& size()
{
return size_;
}
//- Return start/size range of this zone
//- The start/size range of this zone
labelRange range() const
{
return labelRange(start_, size_);
}
//- Write
void write(Ostream&) const;
//- Write dictionary
void writeDict(Ostream&) const;
//- Write dictionary, includes surrounding braces
// \warning Prior to 2020-01 was identical to operator<< output
void write(Ostream& os) const;
// Member Operators
// Housekeeping
bool operator!=(const surfZone&) const;
//- Removed(2020-01) Construct from Istream
// \deprecated(2020-01) - unused, inconsistent
surfZone(Istream& is, const label index) = delete;
//- compare.
bool operator==(const surfZone&) const;
// IOstream Operators
friend Istream& operator>>(Istream&, surfZone&);
friend Ostream& operator<<(Ostream&, const surfZone&);
//- Deprecated(2020-01) Write dictionary
// \deprecated(2020-01) - Write dictionary
void FOAM_DEPRECATED_FOR(2020-01, "write() or operator<<")
writeDict(Ostream& os) const
{
write(os);
}
};
// Global Operators
//- Compare surfZones for equality
bool operator==(const surfZone& a, const surfZone& b);
//- Compare surfZones for inequality
bool operator!=(const surfZone& a, const surfZone& b);
//- Read as dictionary
Istream& operator>>(Istream& is, surfZone& obj);
//- Write as dictionary
Ostream& operator<<(Ostream&, const surfZone& obj);
// Global Functions
//- The labelRange of a surfZone

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +32,7 @@ License
namespace Foam
{
defineTypeNameAndDebug(surfZoneIOList, 0);
defineTypeName(surfZoneIOList);
}
@ -57,40 +57,28 @@ Foam::surfZoneIOList::surfZoneIOList
Istream& is = readStream(typeName);
PtrList<entry> dictEntries(is);
zones.setSize(dictEntries.size());
zones.resize(dictEntries.size());
label facei = 0;
forAll(zones, zoneI)
forAll(zones, zonei)
{
const dictionary& dict = dictEntries[zoneI].dict();
const label zoneSize = dict.get<label>("nFaces");
const label startFacei = dict.get<label>("startFace");
zones[zoneI] = surfZone
zones[zonei] = surfZone
(
dictEntries[zoneI].keyword(),
zoneSize,
startFacei,
zoneI
dictEntries[zonei].keyword(),
dictEntries[zonei].dict(),
zonei
);
word geoType;
if (dict.readIfPresent("geometricType", geoType))
{
zones[zoneI].geometricType() = geoType;
}
if (startFacei != facei)
if (zones[zonei].start() != facei)
{
FatalErrorInFunction
<< "surfZones are not ordered. Start of zone " << zoneI
<< "surfZones are not ordered. Start of zone " << zonei
<< " does not correspond to sum of preceding zones." << nl
<< "while reading " << io.objectPath() << endl
<< exit(FatalError);
}
facei += zoneSize;
facei += zones[zonei].size();
}
is.check(FUNCTION_NAME);
@ -125,7 +113,26 @@ Foam::surfZoneIOList::surfZoneIOList
bool Foam::surfZoneIOList::writeData(Ostream& os) const
{
return (os << *this).good();
const surfZoneList& zones = *this;
const label sz = zones.size();
if (sz)
{
os << sz << nl << token::BEGIN_LIST << incrIndent << nl;
for (const surfZone& zn : zones)
{
zn.write(os);
}
os << decrIndent << token::END_LIST;
}
else
{
os << sz << token::BEGIN_LIST << token::END_LIST;
}
return os.good();
}
@ -137,18 +144,11 @@ void Foam::surfZoneIOList::operator=(const surfZoneIOList& rhs)
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& list)
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& zones)
{
os << list.size() << nl << token::BEGIN_LIST << incrIndent << nl;
for (const surfZone& item : list)
{
item.writeDict(os);
}
os << decrIndent << token::END_LIST;
zones.writeData(os);
return os;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,21 +40,13 @@ SourceFiles
#include "surfZoneList.H"
#include "regIOobject.H"
#include "faceList.H"
#include "className.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class surfZoneIOList;
Ostream& operator<<(Ostream&, const surfZoneIOList&);
/*---------------------------------------------------------------------------*\
Class surfZoneIOList Declaration
\*---------------------------------------------------------------------------*/
@ -67,7 +59,7 @@ class surfZoneIOList
public:
//- Runtime type information
TypeName("surfZoneList");
TypeNameNoDebug("surfZoneList");
// Constructors
@ -88,7 +80,7 @@ public:
// Member Functions
//- The writeData function for regIOobject
//- The writeData function - required by regIOobject
bool writeData(Ostream& os) const;
@ -99,14 +91,15 @@ public:
//- Copy or move assignment of entries
using surfZoneList::operator=;
// IOstream Operators
friend Ostream& operator<<(Ostream& os, const surfZoneIOList& list);
};
// Global Operators
//- Write surfZone list using its writeData() method
Ostream& operator<<(Ostream& os, const surfZoneIOList& zones);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,28 +29,18 @@ License
#include "surfacePatch.H"
#include "surfZone.H"
#include "dictionary.H"
#include "word.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfacePatch, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfacePatch::surfacePatch()
:
geometricSurfacePatch(word::null, word::null, -1),
size_(0),
start_(0)
surfacePatch(-1)
{}
Foam::surfacePatch::surfacePatch(const label index)
:
geometricSurfacePatch(word::null, word::null, index),
geometricSurfacePatch(word::null, index, word::null),
size_(0),
start_(0)
{}
@ -58,29 +48,19 @@ Foam::surfacePatch::surfacePatch(const label index)
Foam::surfacePatch::surfacePatch
(
const word& geometricType,
const word& name,
const label size,
const label start,
const label index
const label index,
const word& geometricType
)
:
geometricSurfacePatch(geometricType, name, index),
geometricSurfacePatch(name, index, geometricType),
size_(size),
start_(start)
{}
Foam::surfacePatch::surfacePatch(Istream& is, const label index)
:
geometricSurfacePatch(is, index),
size_(0),
start_(0)
{
is >> size_ >> start_;
}
Foam::surfacePatch::surfacePatch
(
const word& name,
@ -94,32 +74,18 @@ Foam::surfacePatch::surfacePatch
{}
Foam::surfacePatch::surfacePatch(const surfacePatch& sp)
:
geometricSurfacePatch(sp),
size_(sp.size()),
start_(sp.start())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfacePatch::write(Ostream& os) const
{
os << nl
<< static_cast<const geometricSurfacePatch&>(*this) << endl
<< size() << tab << start();
}
os.beginBlock(name());
void Foam::surfacePatch::writeDict(Ostream& os) const
{
os << nl << name() << nl << token::BEGIN_BLOCK << nl;
geometricSurfacePatch::write(os);
geometricSurfacePatch::writeDict(os);
os.writeEntry("nFaces", size());
os.writeEntry("startFace", start());
os << " nFaces " << size() << ';' << nl
<< " startFace " << start() << ';' << nl
<< token::END_BLOCK << endl;
os.endBlock();
}
@ -138,31 +104,59 @@ Foam::surfacePatch::operator Foam::surfZone() const
}
bool Foam::surfacePatch::operator!=(const surfacePatch& p) const
{
return !(*this == p);
}
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
bool Foam::surfacePatch::operator==(const surfacePatch& p) const
bool Foam::operator==
(
const surfacePatch& a,
const surfacePatch& b
)
{
return
(
(geometricType() == p.geometricType())
&& (size() == p.size())
&& (start() == p.start())
(a.geometricType() == b.geometricType())
&& (a.size() == b.size())
&& (a.start() == b.start())
);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatch& p)
bool Foam::operator!=
(
const surfacePatch& a,
const surfacePatch& b
)
{
p.write(os);
return !(a == b);
}
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatch& obj)
{
os << static_cast<const geometricSurfacePatch&>(obj) << token::SPACE
<< obj.size() << token::SPACE
<< obj.start();
os.check(FUNCTION_NAME);
return os;
}
// * * * * * * * * * * * * * * * Housekeeping * * * * * * * * * * * * * * * //
Foam::surfacePatch::surfacePatch
(
const word& geometricType,
const word& name,
const label size,
const label start,
const label index
)
:
surfacePatch(name, size, start, index, geometricType)
{}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,7 @@ Class
Foam::surfacePatch
Description
'Patch' on surface as subset of triSurface.
A 'patch' on surface as subset of triSurface.
SourceFiles
surfacePatch.C
@ -39,21 +39,15 @@ SourceFiles
#define surfacePatch_H
#include "geometricSurfacePatch.H"
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class surfacePatch;
// Forward Declarations
class surfZone;
Ostream& operator<<(Ostream&, const surfacePatch&);
/*---------------------------------------------------------------------------*\
Class surfacePatch Declaration
\*---------------------------------------------------------------------------*/
@ -62,23 +56,29 @@ class surfacePatch
:
public geometricSurfacePatch
{
// Private data
// Private Data
//- Size of this patch in the triSurface face list
//- Size of this patch in the face list
label size_;
//- Start label of this patch in the triSurface face list
//- Start label of this patch in the face list
label start_;
public:
//- Runtime type information
ClassName("surfacePatch");
// Generated Methods
//- Copy construct
surfacePatch(const surfacePatch&) = default;
//- Copy assignment
surfacePatch& operator=(const surfacePatch&) = default;
// Constructors
//- Construct null
//- Default construct, with zero start, size, index=-1
surfacePatch();
//- Construct null with specified index
@ -87,16 +87,13 @@ public:
//- Construct from components
surfacePatch
(
const word& geometricType,
const word& name,
const label size,
const label start,
const label index
const label index,
const word& geometricType = word::null
);
//- Construct from Istream
surfacePatch(Istream& is, const label index);
//- Construct from dictionary
surfacePatch
(
@ -105,9 +102,6 @@ public:
const label index
);
//- Construct as copy
surfacePatch(const surfacePatch&);
// Member Functions
@ -135,11 +129,9 @@ public:
return size_;
}
//- Write
void write(Ostream&) const;
//- Write dictionary
void writeDict(Ostream&) const;
//- Write dictionary, includes surrounding braces
// \warning Prior to 2020-01 was identical to operator<< output
void write(Ostream& os) const;
// Member Operators
@ -148,19 +140,45 @@ public:
explicit operator surfZone() const;
//- Compare.
bool operator!=(const surfacePatch&) const;
// Housekeeping
//- Compare.
bool operator==(const surfacePatch&) const;
//- Removed(2020-01) Construct from Istream
// \deprecated(2020-01) - unused, inconsistent
surfacePatch(Istream& is, const label index) = delete;
//- Deprecated(2020-01) Construct from components
// \deprecated(2020-01) - order inconsistent with other identifiers
surfacePatch
(
const word& geometricType,
const word& name,
const label size,
const label start,
const label index
) FOAM_DEPRECATED(2020-01);
// IOstream Operators
friend Ostream& operator<<(Ostream&, const surfacePatch&);
//- Deprecated(2020-01) Ostream output
// \deprecated(2020-01) - Ostream output
void FOAM_DEPRECATED_FOR(2020-01, "write() or operator<<")
writeDict(Ostream& os) const
{
write(os);
}
};
// Global Operators
//- Compare patches for equality
bool operator==(const surfacePatch& a, const surfacePatch& b);
//- Compare patches for inequality
bool operator!=(const surfacePatch& a, const surfacePatch& b);
//- Write name, geometricType, size, start
Ostream& operator<<(Ostream& os, const surfacePatch& obj);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -27,6 +27,7 @@ Typedef
Foam::surfacePatchList
Description
A List of surfacePatch.
\*---------------------------------------------------------------------------*/
@ -43,7 +44,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfacePatch> surfacePatchList;
typedef List<surfacePatch> surfacePatchList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -371,7 +371,7 @@ Foam::triSurface::calcPatches(labelList& faceMap) const
}
else
{
newPatch.geometricType() = geometricSurfacePatch::emptyType;
newPatch.geometricType() = surfacePatch::emptyType;
}
startFacei += newPatch.size();