Commit c4caef3a authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: nicer indentation of inGroups patch entry (issue #474)

- The inGroups is a wordList.
  It can be flattened on output to make files more readable.
parent f0fcfce6
......@@ -134,16 +134,18 @@ Foam::coupleGroupIdentifier::coupleGroupIdentifier()
{}
Foam::coupleGroupIdentifier::coupleGroupIdentifier(const word& name)
Foam::coupleGroupIdentifier::coupleGroupIdentifier(const word& patchGroupName)
:
name_(name)
name_(patchGroupName)
{}
Foam::coupleGroupIdentifier::coupleGroupIdentifier(const dictionary& dict)
:
name_(dict.lookupOrDefault<word>("coupleGroup", ""))
{}
name_()
{
dict.readIfPresent("coupleGroup", name_);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
......@@ -222,7 +224,7 @@ void Foam::coupleGroupIdentifier::write(Ostream& os) const
{
if (valid())
{
os.writeKeyword("coupleGroup") << name() << token::END_STATEMENT << nl;
os.writeEntry("coupleGroup", name());
}
}
......@@ -232,7 +234,7 @@ void Foam::coupleGroupIdentifier::write(Ostream& os) const
Foam::Ostream& Foam::operator<<(Ostream& os, const coupleGroupIdentifier& p)
{
p.write(os);
os.check("Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p");
os.check(FUNCTION_NAME);
return os;
}
......
......@@ -53,11 +53,11 @@ class Ostream;
// Forward declaration of friend functions and operators
class coupleGroupIdentifier;
Ostream& operator<<(Ostream&, const coupleGroupIdentifier&);
Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p);
/*---------------------------------------------------------------------------*\
Class coupleGroupIdentifier Declaration
Class coupleGroupIdentifier Declaration
\*---------------------------------------------------------------------------*/
class coupleGroupIdentifier
......@@ -71,7 +71,11 @@ class coupleGroupIdentifier
// Private Member Functions
//- Find other patch in specified mesh. Returns index of patch or -1.
label findOtherPatchID(const polyMesh&, const polyPatch&) const;
label findOtherPatchID
(
const polyMesh& mesh,
const polyPatch& thisPatch
) const;
public:
......@@ -85,7 +89,7 @@ public:
coupleGroupIdentifier(const word& patchGroupName);
//- Construct from dictionary
coupleGroupIdentifier(const dictionary&);
coupleGroupIdentifier(const dictionary& dict);
// Member Functions
......@@ -97,19 +101,27 @@ public:
inline bool valid() const;
//- Find other patch in same region. Returns index of patch or -1.
label findOtherPatchID(const polyPatch&) const;
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
label findOtherPatchID(const polyPatch&, word&) const;
label findOtherPatchID
(
const polyPatch& thisPatch,
word& otherRegion
) const;
//- Write the data as a dictionary
void write(Ostream&) const;
void write(Ostream& os) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const coupleGroupIdentifier&);
friend Ostream& operator<<
(
Ostream& os,
const coupleGroupIdentifier& p
);
};
......
......@@ -82,7 +82,7 @@ Foam::patchIdentifier::~patchIdentifier()
bool Foam::patchIdentifier::inGroup(const word& name) const
{
return findIndex(inGroups_, name) != -1;
return inGroups_.size() && findIndex(inGroups_, name) != -1;
}
......@@ -90,23 +90,23 @@ void Foam::patchIdentifier::write(Ostream& os) const
{
if (physicalType_.size())
{
os.writeKeyword("physicalType") << physicalType_
<< token::END_STATEMENT << nl;
os.writeEntry("physicalType", physicalType_);
}
if (inGroups_.size())
{
os.writeKeyword("inGroups") << inGroups_
<< token::END_STATEMENT << nl;
os.writeKeyword("inGroups");
// Write list with flatOutput
inGroups_.writeList(os, 0) << token::END_STATEMENT << nl;
}
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const patchIdentifier& pi)
Foam::Ostream& Foam::operator<<(Ostream& os, const patchIdentifier& p)
{
pi.write(os);
os.check("Ostream& operator<<(Ostream&, const patchIdentifier&)");
p.write(os);
os.check(FUNCTION_NAME);
return os;
}
......
......@@ -25,7 +25,7 @@ Class
Foam::patchIdentifier
Description
Identifies patch by name, patch index and physical type
Identifies a patch by name, patch index and physical type
SourceFiles
patchIdentifier.C
......@@ -48,11 +48,11 @@ class dictionary;
// Forward declaration of friend functions and operators
class patchIdentifier;
Ostream& operator<<(Ostream&, const patchIdentifier&);
Ostream& operator<<(Ostream& os, const patchIdentifier& p);
/*---------------------------------------------------------------------------*\
Class patchIdentifier Declaration
Class patchIdentifier Declaration
\*---------------------------------------------------------------------------*/
class patchIdentifier
......@@ -68,7 +68,7 @@ class patchIdentifier
//- Optional physical type
mutable word physicalType_;
//- Optional groups patch belongs to
//- Optional groups to which the patch belongs
wordList inGroups_;
public:
......@@ -88,14 +88,14 @@ public:
patchIdentifier
(
const word& name,
const dictionary&,
const dictionary& dict,
const label index
);
//- Construct from geometric patch, resetting the index
//- Copy construct from geometric patch, resetting the index
patchIdentifier
(
const patchIdentifier&,
const patchIdentifier& p,
const label index
);
......@@ -106,64 +106,64 @@ public:
// Member Functions
//- Return name
//- Return the patch name
const word& name() const
{
return name_;
}
//- Return name for modification
//- Modifiable patch name
word& name()
{
return name_;
}
//- Return the optional physical type of the patch
//- The optional physical type of the patch
const word& physicalType() const
{
return physicalType_;
}
//- Return the optional physical type of the patch for modification
//- Modifiable optional physical type of the patch
word& physicalType()
{
return physicalType_;
}
//- Return the index of this patch in the boundaryMesh
//- The index of this patch in the boundaryMesh
label index() const
{
return index_;
}
//- Return the index of this patch in the boundaryMesh for modification
//- Modifiable the index of this patch in the boundaryMesh
label& index()
{
return index_;
}
//- Return the optional groups patch belongs to
//- The optional groups that the patch belongs to
const wordList& inGroups() const
{
return inGroups_;
}
//- Return the optional groups patch belongs to for modification
//- Modifiable optional groups that the patch belongs to
wordList& inGroups()
{
return inGroups_;
}
//- Test if in group
bool inGroup(const word&) const;
//- Check if the patch is in named group
bool inGroup(const word& name) const;
//- Write patchIdentifier as a dictionary
void write(Ostream&) const;
void write(Ostream& os) const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const patchIdentifier&);
friend Ostream& operator<<(Ostream& os, const patchIdentifier& p);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment