mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: align constructors of geometricSurfacePatch with surfZoneIdentifier
- both classes are nearly identical and should be merged in the future.
This commit is contained in:
@ -106,48 +106,39 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
// needed for list output
|
||||
bool Foam::surfZoneIdentifier::operator!=
|
||||
(
|
||||
const surfZoneIdentifier& rhs
|
||||
) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfZoneIdentifier::operator==
|
||||
(
|
||||
const surfZoneIdentifier& rhs
|
||||
) const
|
||||
bool Foam::operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
|
||||
{
|
||||
return
|
||||
(
|
||||
(index() == rhs.index())
|
||||
&& (name() == rhs.name())
|
||||
&& (geometricType() == rhs.geometricType())
|
||||
(a.index() == b.index())
|
||||
&& (a.name() == b.name())
|
||||
&& (a.geometricType() == b.geometricType())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
|
||||
{
|
||||
is >> obj.name_ >> obj.geometricType_;
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj)
|
||||
{
|
||||
// newlines to separate, since that is what triSurface currently expects
|
||||
// Newlines to separate, since that is what triSurface currently expects
|
||||
os << nl << obj.name_ << nl << obj.geometricType_;
|
||||
|
||||
os.check("Ostream& operator<<(Ostream&, const surfZoneIdentifier&)");
|
||||
os.check(FUNCTION_NAME);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@ class dictionary;
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class surfZoneIdentifier;
|
||||
Istream& operator>>(Istream&, surfZoneIdentifier&);
|
||||
Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
|
||||
Istream& operator>>(Istream& is, surfZoneIdentifier& p);
|
||||
Ostream& operator<<(Ostream& os, const surfZoneIdentifier& p);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfZoneIdentifier Declaration
|
||||
@ -94,21 +94,20 @@ public:
|
||||
const word& name,
|
||||
const label index,
|
||||
const word& geometricType = word::null
|
||||
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfZoneIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const dictionary&,
|
||||
const dictionary& dict,
|
||||
const label index
|
||||
);
|
||||
|
||||
//- Construct from another zone identifier, resetting the index
|
||||
//- Copy construct from another zone identifier, resetting the index
|
||||
surfZoneIdentifier
|
||||
(
|
||||
const surfZoneIdentifier&,
|
||||
const surfZoneIdentifier& p,
|
||||
const label index
|
||||
);
|
||||
|
||||
@ -156,14 +155,8 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Write surfZoneIdentifier as a dictionary
|
||||
void write(Ostream&) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
bool operator!=(const surfZoneIdentifier&) const;
|
||||
bool operator==(const surfZoneIdentifier&) const;
|
||||
//- Write identifier as a dictionary
|
||||
void write(Ostream& os) const;
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
@ -171,20 +164,29 @@ public:
|
||||
//- Read name/type.
|
||||
friend Istream& operator>>
|
||||
(
|
||||
Istream&,
|
||||
surfZoneIdentifier&
|
||||
Istream& is,
|
||||
surfZoneIdentifier& ob
|
||||
);
|
||||
|
||||
//- Write name/type.
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const surfZoneIdentifier&
|
||||
Ostream& os,
|
||||
const surfZoneIdentifier& obj
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Global Operators
|
||||
|
||||
//- Compare zone indentifiers for equality
|
||||
bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
|
||||
|
||||
//- Compare zone indentifiers for inequality
|
||||
bool operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -327,9 +327,8 @@ void Foam::UnsortedMeshedSurface<Face>::setOneZone()
|
||||
zoneName = "zone0";
|
||||
}
|
||||
|
||||
// set single default zone
|
||||
zoneToc_.setSize(1);
|
||||
zoneToc_[0] = surfZoneIdentifier(zoneName, 0);
|
||||
// Set single default zone
|
||||
zoneToc_ = { surfZoneIdentifier(zoneName, 0) };
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@ bool triSurface::readAC(const fileName& ACfileName)
|
||||
);
|
||||
|
||||
// Object global values
|
||||
string patchName = string("patch") + name(patchi);
|
||||
string patchName = string("patch") + Foam::name(patchi);
|
||||
label nVerts = 0;
|
||||
tensor rot(I);
|
||||
vector loc(0, 0, 0);
|
||||
@ -319,7 +319,6 @@ bool triSurface::readAC(const fileName& ACfileName)
|
||||
patches[patchi] =
|
||||
geometricSurfacePatch
|
||||
(
|
||||
"empty",
|
||||
word(patchName),
|
||||
patchi
|
||||
);
|
||||
|
||||
@ -372,16 +372,10 @@ bool triSurface::readNAS(const fileName& fName)
|
||||
// Convert groupToPatch to patchList.
|
||||
geometricSurfacePatchList patches(nPatches);
|
||||
|
||||
forAllConstIter(Map<word>, groupToName, iter)
|
||||
forAllConstIters(groupToName, iter)
|
||||
{
|
||||
label patchi = groupToPatch[iter.key()];
|
||||
|
||||
patches[patchi] = geometricSurfacePatch
|
||||
(
|
||||
"empty",
|
||||
iter(),
|
||||
patchi
|
||||
);
|
||||
const label patchIdx = groupToPatch[iter.key()];
|
||||
patches[patchIdx] = geometricSurfacePatch(iter.object(), patchIdx);
|
||||
}
|
||||
|
||||
Info<< "patches:" << patches << endl;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
@ -172,19 +171,19 @@ bool Foam::triSurface::readOBJ(const fileName& OBJfileName)
|
||||
|
||||
if (maxGroupID == 0)
|
||||
{
|
||||
// Generate default patch
|
||||
patches.setSize(1);
|
||||
patches[0] = geometricSurfacePatch("empty", "patch0", 0);
|
||||
// Add single (default) patch
|
||||
patches = { geometricSurfacePatch("patch0", 0) };
|
||||
}
|
||||
else
|
||||
{
|
||||
forAllConstIter(HashTable<label>, groupToPatch, iter)
|
||||
forAllConstIters(groupToPatch, iter)
|
||||
{
|
||||
patches[iter()] = geometricSurfacePatch
|
||||
const label patchIdx = iter.object();
|
||||
|
||||
patches[patchIdx] = geometricSurfacePatch
|
||||
(
|
||||
"empty",
|
||||
iter.key(),
|
||||
iter()
|
||||
patchIdx
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ bool Foam::triSurface::readTRI(const fileName& TRIfileName)
|
||||
forAll(names, nameI)
|
||||
{
|
||||
patches_[nameI].name() = names[nameI];
|
||||
patches_[nameI].geometricType() = "empty";
|
||||
patches_[nameI].geometricType() = geometricSurfacePatch::emptyType;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -67,13 +67,13 @@ bool Foam::triSurface::readVTK(const fileName& fName)
|
||||
|
||||
patches[zoneI] = geometricSurfacePatch
|
||||
(
|
||||
zone.geometricType().size() ? zone.geometricType() : "empty",
|
||||
regionName,
|
||||
zoneI
|
||||
zoneI,
|
||||
zone.geometricType()
|
||||
);
|
||||
|
||||
// Set triangle regions
|
||||
for (label i = zone.start(); i < zone.start()+zone.size(); i++)
|
||||
for (label i = zone.start(); i < zone.start()+zone.size(); ++i)
|
||||
{
|
||||
tris[i].region() = zoneI;
|
||||
}
|
||||
@ -81,11 +81,9 @@ bool Foam::triSurface::readVTK(const fileName& fName)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add single patch
|
||||
patches.setSize(1);
|
||||
patches[0] = geometricSurfacePatch("empty", "patch0", 0);
|
||||
|
||||
// Add single (default) patch
|
||||
// Triangle regions already set to 0
|
||||
patches = { geometricSurfacePatch("patch0", 0) };
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,28 +26,54 @@ License
|
||||
#include "geometricSurfacePatch.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(geometricSurfacePatch, 0);
|
||||
}
|
||||
|
||||
const Foam::word Foam::geometricSurfacePatch::emptyType = "empty";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct null
|
||||
geometricSurfacePatch::geometricSurfacePatch()
|
||||
Foam::geometricSurfacePatch::geometricSurfacePatch()
|
||||
:
|
||||
geometricType_("empty"),
|
||||
geometricType_(emptyType),
|
||||
name_("patch"),
|
||||
index_(0)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from components
|
||||
geometricSurfacePatch::geometricSurfacePatch
|
||||
Foam::geometricSurfacePatch::geometricSurfacePatch(const label index)
|
||||
:
|
||||
geometricType_(emptyType),
|
||||
name_("patch"),
|
||||
index_(index)
|
||||
{}
|
||||
|
||||
|
||||
Foam::geometricSurfacePatch::geometricSurfacePatch
|
||||
(
|
||||
const word& name,
|
||||
const label index,
|
||||
const word& geometricType
|
||||
)
|
||||
:
|
||||
geometricType_(geometricType),
|
||||
name_(name),
|
||||
index_(index)
|
||||
|
||||
{
|
||||
if (geometricType_.empty())
|
||||
{
|
||||
geometricType_ = emptyType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::geometricSurfacePatch::geometricSurfacePatch
|
||||
(
|
||||
const word& geometricType,
|
||||
const word& name,
|
||||
@ -61,13 +87,16 @@ geometricSurfacePatch::geometricSurfacePatch
|
||||
{
|
||||
if (geometricType_.empty())
|
||||
{
|
||||
geometricType_ = "empty";
|
||||
geometricType_ = emptyType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from Istream
|
||||
geometricSurfacePatch::geometricSurfacePatch(Istream& is, const label index)
|
||||
Foam::geometricSurfacePatch::geometricSurfacePatch
|
||||
(
|
||||
Istream& is,
|
||||
const label index
|
||||
)
|
||||
:
|
||||
geometricType_(is),
|
||||
name_(is),
|
||||
@ -75,89 +104,82 @@ geometricSurfacePatch::geometricSurfacePatch(Istream& is, const label index)
|
||||
{
|
||||
if (geometricType_.empty())
|
||||
{
|
||||
geometricType_ = "empty";
|
||||
geometricType_ = emptyType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
geometricSurfacePatch::geometricSurfacePatch
|
||||
Foam::geometricSurfacePatch::geometricSurfacePatch
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const label index
|
||||
)
|
||||
:
|
||||
geometricType_(dict.lookup("geometricType")),
|
||||
geometricType_(emptyType),
|
||||
name_(name),
|
||||
index_(index)
|
||||
{
|
||||
if (geometricType_.empty())
|
||||
{
|
||||
geometricType_ = "empty";
|
||||
}
|
||||
dict.readIfPresent("geometricType", geometricType_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Write
|
||||
void geometricSurfacePatch::write(Ostream& os) const
|
||||
void Foam::geometricSurfacePatch::write(Ostream& os) const
|
||||
{
|
||||
os << nl << name_
|
||||
<< nl << geometricType_;
|
||||
}
|
||||
|
||||
|
||||
void geometricSurfacePatch::writeDict(Ostream& os) const
|
||||
void Foam::geometricSurfacePatch::writeDict(Ostream& os) const
|
||||
{
|
||||
os << " geometricType " << geometricType_ << ';' << nl;
|
||||
os.writeEntry("geometricType", geometricType_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::geometricSurfacePatch::operator!=(const geometricSurfacePatch& p)
|
||||
const
|
||||
{
|
||||
return !(*this == p);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::geometricSurfacePatch::operator==(const geometricSurfacePatch& p)
|
||||
const
|
||||
bool Foam::operator==
|
||||
(
|
||||
const geometricSurfacePatch& a,
|
||||
const geometricSurfacePatch& b
|
||||
)
|
||||
{
|
||||
return
|
||||
(
|
||||
(geometricType() == p.geometricType())
|
||||
&& (name() == p.name())
|
||||
(a.geometricType() == b.geometricType())
|
||||
&& (a.name() == b.name())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::operator!=
|
||||
(
|
||||
const geometricSurfacePatch& a,
|
||||
const geometricSurfacePatch& b
|
||||
)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Istream& operator>>(Istream& is, geometricSurfacePatch& gp)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, geometricSurfacePatch& p)
|
||||
{
|
||||
is >> gp.name_ >> gp.geometricType_;
|
||||
|
||||
is >> p.name_ >> p.geometricType_;
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
Ostream& operator<<(Ostream& os, const geometricSurfacePatch& gp)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const geometricSurfacePatch& p)
|
||||
{
|
||||
gp.write(os);
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream& f, const geometricSurfacePatch& gp)"
|
||||
);
|
||||
p.write(os);
|
||||
os.check(FUNCTION_NAME);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -47,8 +47,14 @@ namespace Foam
|
||||
|
||||
class dictionary;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
class geometricSurfacePatch;
|
||||
|
||||
Istream& operator>>(Istream& is, geometricSurfacePatch& p);
|
||||
Ostream& operator<<(Ostream& os, const geometricSurfacePatch& p);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class geometricSurfacePatch Declaration
|
||||
Class geometricSurfacePatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class geometricSurfacePatch
|
||||
@ -66,6 +72,12 @@ class geometricSurfacePatch
|
||||
|
||||
public:
|
||||
|
||||
// Public data
|
||||
|
||||
//- The name for an 'empty' type
|
||||
static const word emptyType;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("geometricSurfacePatch");
|
||||
|
||||
@ -75,6 +87,17 @@ public:
|
||||
//- Construct null
|
||||
geometricSurfacePatch();
|
||||
|
||||
//- Construct null with specified index
|
||||
explicit geometricSurfacePatch(const label index);
|
||||
|
||||
//- Construct from components
|
||||
geometricSurfacePatch
|
||||
(
|
||||
const word& name,
|
||||
const label index,
|
||||
const word& geometricType = word::null
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
geometricSurfacePatch
|
||||
(
|
||||
@ -83,9 +106,6 @@ public:
|
||||
const label index
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
geometricSurfacePatch(Istream&, const label index);
|
||||
|
||||
//- Construct from dictionary
|
||||
geometricSurfacePatch
|
||||
(
|
||||
@ -94,6 +114,9 @@ public:
|
||||
const label index
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
geometricSurfacePatch(Istream& is, const label index);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -109,52 +132,53 @@ public:
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return the type of the patch
|
||||
//- Return the geometric type of the patch
|
||||
const word& geometricType() const
|
||||
{
|
||||
return geometricType_;
|
||||
}
|
||||
|
||||
//- Return the type of the patch
|
||||
//- Return the geometric type of the patch for modification
|
||||
word& geometricType()
|
||||
{
|
||||
return geometricType_;
|
||||
}
|
||||
|
||||
//- Return the index of this patch in the boundaryMesh
|
||||
//- Return the index of this patch in the surface mesh
|
||||
label index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Return the index of this patch in the boundaryMesh
|
||||
//- Return the index of this patch in the surface mesh for modification
|
||||
label& index()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Write
|
||||
void write(Ostream&) const;
|
||||
void write(Ostream& os) const;
|
||||
|
||||
//- Write dictionary
|
||||
void writeDict(Ostream&) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
bool operator!=(const geometricSurfacePatch&) const;
|
||||
|
||||
//- compare.
|
||||
bool operator==(const geometricSurfacePatch&) const;
|
||||
void writeDict(Ostream& os) const;
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const geometricSurfacePatch&);
|
||||
friend Istream& operator>>(Istream&, geometricSurfacePatch&);
|
||||
friend Istream& operator>>(Istream& is, geometricSurfacePatch& p);
|
||||
friend Ostream& operator<<(Ostream& os, const geometricSurfacePatch& p);
|
||||
};
|
||||
|
||||
|
||||
// Global Operators
|
||||
|
||||
//- Compare patches for equality
|
||||
bool operator==(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
|
||||
|
||||
//- Compare patches for inequality
|
||||
bool operator!=(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -623,7 +623,7 @@ Foam::triSurface::calcPatches(labelList& faceMap) const
|
||||
}
|
||||
else
|
||||
{
|
||||
newPatch.geometricType() = "empty";
|
||||
newPatch.geometricType() = geometricSurfacePatch::emptyType;
|
||||
}
|
||||
|
||||
startFacei += newPatch.size();
|
||||
|
||||
Reference in New Issue
Block a user