Reorganisation and clean-up

This commit is contained in:
Hrvoje Jasak 2017-05-25 14:44:59 +01:00
parent 739cbbfca5
commit 41353e4dac
11 changed files with 221 additions and 211 deletions

View file

@ -166,8 +166,7 @@ public:
); );
// Destructor //- Destructor
virtual ~layerAdditionRemoval(); virtual ~layerAdditionRemoval();

View file

@ -134,8 +134,7 @@ public:
); );
// Destructor //- Destructor
virtual ~polyMeshModifier(); virtual ~polyMeshModifier();

View file

@ -120,13 +120,4 @@ void Foam::setUpdater::writeDict(Ostream& os) const
} }
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// ************************************************************************* // // ************************************************************************* //

View file

@ -25,7 +25,7 @@ Class
Foam::setUpdater Foam::setUpdater
Description Description
Keeps cell/face/vertex sets uptodate. Both the ones loaded and the ones Keeps cell/face/vertex sets up-to-date: both the ones loaded and the ones
on disk. on disk.
SourceFiles SourceFiles
@ -116,6 +116,7 @@ public:
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
# include "setUpdaterTemplates.C" # include "setUpdaterTemplates.C"
#endif #endif

View file

@ -103,6 +103,16 @@ public:
zoneID_(zoneID) zoneID_(zoneID)
{} {}
//- Construct Istream
polyAddCell(Istream& is)
:
masterPointID_(readLabel(is)),
masterEdgeID_(readLabel(is)),
masterFaceID_(readLabel(is)),
masterCellID_(readLabel(is)),
zoneID_(readLabel(is))
{}
//- Construct and return a clone //- Construct and return a clone
virtual autoPtr<topoAction> clone() const virtual autoPtr<topoAction> clone() const
{ {
@ -183,6 +193,19 @@ public:
return zoneID_; return zoneID_;
} }
// IOstream Operators
friend Ostream& operator<<(Ostream& os , const polyAddCell& pac)
{
os << pac.masterPointID_
<< pac.masterEdgeID_
<< pac.masterFaceID_
<< pac.masterCellID_
<< pac.zoneID_;
return os;
}
}; };

View file

@ -86,6 +86,104 @@ class polyAddFace
bool zoneFlip_; bool zoneFlip_;
// Private Member Functions
//- Check
void check() const
{
if (face_.size() < 3)
{
FatalErrorIn("polyAddFace::check()")
<< "Invalid face: less than 3 points. "
<< "This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (min(face_) < 0)
{
FatalErrorIn("polyAddFace::check()")
<< "Face contains invalid vertex ID: " << face_ << ". "
<< "This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_)
{
FatalErrorIn("polyAddFace::check()")
<< "Face owner and neighbour are identical. "
<< "This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (neighbour_ >= 0 && patchID_ >= 0)
{
FatalErrorIn("polyAddFace::check()")
<< "Patch face has got a neighbour. Patch ID: " << patchID_
<< ". This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (owner_ < 0 && zoneID_ < 0)
{
FatalErrorIn("polyAddFace::check()")
<< "Face has no owner and is not in a zone. "
<< "This is not allowed.\n"
<< "Face: " << face_
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (zoneID_ == -1 && zoneFlip_)
{
FatalErrorIn("polyAddFace::check()")
<< "Specified zone flip for a face that does not "
<< "belong to zone. This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
}
public: public:
// Static data members // Static data members
@ -138,174 +236,24 @@ public:
zoneID_(zoneID), zoneID_(zoneID),
zoneFlip_(zoneFlip) zoneFlip_(zoneFlip)
{ {
if (face_.size() < 3) check();
{
FatalErrorIn
(
"polyAddFace\n"
"(\n"
" const face& f,\n"
" const label owner,"
" const label neighbour,\n"
" const label masterPointID,\n"
" const label masterEdgeID,\n"
" const label masterFaceID,\n"
" const bool flipFaceFlux,\n"
" const label patchID,\n"
" const label zoneID,\n"
" const bool zoneFlip\n"
")"
) << "Invalid face: less than 3 points. "
<< "This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
} }
if (min(face_) < 0) //- Construct from Istream
polyAddFace(Istream& is)
:
face_(is),
owner_(readLabel(is)),
neighbour_(readLabel(is)),
masterPointID_(readLabel(is)),
masterEdgeID_(readLabel(is)),
masterFaceID_(readLabel(is)),
flipFaceFlux_(readBool(is)),
patchID_(readLabel(is)),
zoneID_(readLabel(is)),
zoneFlip_(readBool(is))
{ {
FatalErrorIn check();
(
"polyAddFace\n"
"(\n"
" const face& f,\n"
" const label owner,"
" const label neighbour,\n"
" const label masterPointID,\n"
" const label masterEdgeID,\n"
" const label masterFaceID,\n"
" const bool flipFaceFlux,\n"
" const label patchID,\n"
" const label zoneID,\n"
" const bool zoneFlip\n"
")"
) << "Face contains invalid vertex ID: " << face_ << ". "
<< "This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_)
{
FatalErrorIn
(
"polyAddFace\n"
"(\n"
" const face& f,\n"
" const label owner,"
" const label neighbour,\n"
" const label masterPointID,\n"
" const label masterEdgeID,\n"
" const label masterFaceID,\n"
" const bool flipFaceFlux,\n"
" const label patchID,\n"
" const label zoneID,\n"
" const bool zoneFlip\n"
")"
) << "Face owner and neighbour are identical. "
<< "This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (neighbour_ >= 0 && patchID >= 0)
{
FatalErrorIn
(
"polyAddFace\n"
"(\n"
" const face& f,\n"
" const label owner,"
" const label neighbour,\n"
" const label masterPointID,\n"
" const label masterEdgeID,\n"
" const label masterFaceID,\n"
" const bool flipFaceFlux,\n"
" const label patchID,\n"
" const label zoneID,\n"
" const bool zoneFlip\n"
")"
) << "Patch face has got a neighbour. Patch ID: " << patchID
<< ". This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (owner_ < 0 && zoneID < 0)
{
FatalErrorIn
(
"polyAddFace\n"
"(\n"
" const face& f,\n"
" const label owner,"
" const label neighbour,\n"
" const label patchID,\n"
" const label zoneID"
")"
) << "Face has no owner and is not in a zone. "
<< "This is not allowed.\n"
<< "Face: " << face_
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
if (zoneID_ == -1 && zoneFlip)
{
FatalErrorIn
(
"polyAddFace\n"
"(\n"
" const face& f,\n"
" const label owner,"
" const label neighbour,\n"
" const label masterPointID,\n"
" const label masterEdgeID,\n"
" const label masterFaceID,\n"
" const label patchID,\n"
" const label zoneID,\n"
" const bool zoneFlip\n"
")"
) << "Specified zone flip for a face that does not "
<< "belong to zone. This is not allowed.\n"
<< "Face: " << face_
<< " masterPointID:" << masterPointID_
<< " masterEdgeID:" << masterEdgeID_
<< " masterFaceID:" << masterFaceID_
<< " patchID:" << patchID_
<< " owner:" << owner_
<< " neighbour:" << neighbour_
<< abort(FatalError);
}
} }
//- Construct and return a clone //- Construct and return a clone
@ -420,6 +368,25 @@ public:
{ {
return zoneFlip_; return zoneFlip_;
} }
// IOstream Operators
friend Ostream& operator<<(Ostream& os , const polyAddFace& paf)
{
os << paf.face_
<< paf.owner_
<< paf.neighbour_
<< paf.masterPointID_
<< paf.masterEdgeID_
<< paf.masterFaceID_
<< paf.flipFaceFlux_
<< paf.patchID_
<< paf.zoneID_
<< paf.zoneFlip_;
return os;
}
}; };

View file

@ -64,6 +64,32 @@ class polyAddPoint
bool inCell_; bool inCell_;
// Private Member Functions
//- Check
void check() const
{
if (zoneID_ < 0 && !inCell_)
{
FatalErrorIn
(
"polyAddPoint\n"
"(\n"
" const point& p,\n"
" const label masterPointID,\n"
" const label zoneID,\n"
" const bool inCell\n"
")"
) << "Point is not in a cell and not in a zone. "
<< "This is not allowed.\n"
<< "point: " << p_
<< " master: " << masterPointID_
<< " zone: " << zoneID_
<< abort(FatalError);
}
}
public: public:
// Static data members // Static data members
@ -97,25 +123,18 @@ public:
zoneID_(zoneID), zoneID_(zoneID),
inCell_(inCell) inCell_(inCell)
{ {
if (zoneID_ < 0 && !inCell) check();
{
FatalErrorIn
(
"polyAddPoint\n"
"(\n"
" const point& p,\n"
" const label masterPointID,\n"
" const label zoneID,\n"
" const bool inCell\n"
")"
) << "Point is not in a cell and not in a zone. "
<< "This is not allowed.\n"
<< "point: " << p
<< " master: " << masterPointID_
<< " zone: " << zoneID_
<< abort(FatalError);
} }
//- Construct from Istream
polyAddPoint(Istream& is)
:
p_(is),
masterPointID_(readLabel(is)),
zoneID_(readLabel(is)),
inCell_(readBool(is))
{
check();
} }
//- Construct and return a clone //- Construct and return a clone
@ -165,6 +184,16 @@ public:
{ {
return inCell_; return inCell_;
} }
// IOstream Operators
friend Ostream& operator<<(Ostream& os , const polyAddPoint& pap)
{
os << pap.p_ << pap.masterPointID_ << pap.zoneID_ << pap.inCell_;
return os;
}
}; };

View file

@ -130,8 +130,7 @@ public:
polyTopoChange(const polyMesh&); polyTopoChange(const polyMesh&);
// Destructor //- Destructor
~polyTopoChange(); ~polyTopoChange();

View file

@ -124,8 +124,7 @@ public:
explicit polyTopoChanger(polyMesh&); explicit polyTopoChanger(polyMesh&);
// Destructor //- Destructor
virtual ~polyTopoChanger() virtual ~polyTopoChanger()
{} {}

View file

@ -417,7 +417,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChanger::changeMesh
if (debug) if (debug)
{ {
Pout<< "Added retired points: modified = " Pout<< " modified = "
<< nNewPoints - debugPointCounter; << nNewPoints - debugPointCounter;
debugPointCounter = nNewPoints; debugPointCounter = nNewPoints;

View file

@ -1039,6 +1039,9 @@ void lengthScaleEstimator::calculateLengthScale
// Lookup various field types, and evaluate the gradient // Lookup various field types, and evaluate the gradient
bool invalidObject = true; bool invalidObject = true;
// Evaluate using gradient scheme
word gradName("grad(" + field_ + ')');
// Register field under a name that's unique // Register field under a name that's unique
word registerName("lengthScaleGradient(" + field_ + ')'); word registerName("lengthScaleGradient(" + field_ + ')');
@ -1062,7 +1065,7 @@ void lengthScaleEstimator::calculateLengthScale
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
mag(fvc::grad(field)) mag(fvc::grad(field, gradName))
) )
); );
@ -1089,7 +1092,7 @@ void lengthScaleEstimator::calculateLengthScale
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
mag(fvc::grad(field)) mag(fvc::grad(field, gradName))
) )
); );