Commit 84be998e authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge commit 'OpenCFD/master' into olesenm

parents 5e852915 d2b1861c
......@@ -41,24 +41,6 @@
)
);
Info<< " Adding to KFluid\n" << endl;
KFluid.set
(
i,
new volScalarField
(
IOobject
(
"K",
runTime.timeName(),
fluidRegions[i],
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermoFluid[i].Cp()*thermoFluid[i].alpha()
)
);
Info<< " Adding to UFluid\n" << endl;
UFluid.set
(
......@@ -129,6 +111,24 @@
).ptr()
);
Info<< " Adding to KFluid\n" << endl;
KFluid.set
(
i,
new volScalarField
(
IOobject
(
"K",
runTime.timeName(),
fluidRegions[i],
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermoFluid[i].Cp()*turbulence[i].alphaEff()
)
);
Info<< " Adding to DpDtFluid\n" << endl;
DpDtFluid.set
(
......
......@@ -37,37 +37,6 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Copy set
void backup
(
const polyMesh& mesh,
const word& fromName,
const topoSet& fromSet,
const word& toName
)
{
Info<< "Backing up " << fromName << " into " << toName << endl;
topoSet backupSet(mesh, toName, fromSet);
backupSet.write();
}
// Read and copy set
void backup
(
const polyMesh& mesh,
const word& fromName,
const word& toName
)
{
topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT);
backup(mesh, fromName, fromSet, toName);
}
// Main program:
int main(int argc, char *argv[])
......@@ -114,8 +83,6 @@ int main(int argc, char *argv[])
{
r = IOobject::NO_READ;
backup(mesh, setName, setName + "_old");
currentSetPtr.reset
(
new cellSet
......@@ -151,7 +118,7 @@ int main(int argc, char *argv[])
if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
{
// currentSet has been read so can make copy.
backup(mesh, setName, currentSet, setName + "_old");
//backup(mesh, setName, currentSet, setName + "_old");
}
if (action == topoSetSource::CLEAR)
......@@ -173,7 +140,16 @@ int main(int argc, char *argv[])
forAll(topoSetSources, topoSetSourceI)
{
// Backup current set.
topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet);
autoPtr<topoSet> oldSet
(
topoSet::New
(
currentSet.type(),
mesh,
currentSet.name() + "_old2",
currentSet
)
);
currentSet.clear();
......
......@@ -47,7 +47,7 @@ using namespace Foam;
int main(int argc, char *argv[])
{
timeSelector::addOptions(false); // no constant
timeSelector::addOptions();
# include "addRegionOption.H"
argList::validOptions.insert("noTopology", "");
argList::validOptions.insert("allGeometry", "");
......
......@@ -37,37 +37,6 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Copy set
void backup
(
const polyMesh& mesh,
const word& fromName,
const topoSet& fromSet,
const word& toName
)
{
Info<< "Backing up " << fromName << " into " << toName << endl;
topoSet backupSet(mesh, toName, fromSet);
backupSet.write();
}
// Read and copy set
void backup
(
const polyMesh& mesh,
const word& fromName,
const word& toName
)
{
topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT);
backup(mesh, fromName, fromSet, toName);
}
// Main program:
int main(int argc, char *argv[])
......@@ -114,8 +83,6 @@ int main(int argc, char *argv[])
{
r = IOobject::NO_READ;
backup(mesh, setName, setName + "_old");
currentSetPtr.reset
(
new faceSet
......@@ -151,7 +118,7 @@ int main(int argc, char *argv[])
if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
{
// currentSet has been read so can make copy.
backup(mesh, setName, currentSet, setName + "_old");
//backup(mesh, setName, currentSet, setName + "_old");
}
if (action == topoSetSource::CLEAR)
......@@ -173,7 +140,16 @@ int main(int argc, char *argv[])
forAll(topoSetSources, topoSetSourceI)
{
// Backup current set.
topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet);
autoPtr<topoSet> oldSet
(
topoSet::New
(
currentSet.type(),
mesh,
currentSet.name() + "_old2",
currentSet
)
);
currentSet.clear();
......
......@@ -37,37 +37,6 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Copy set
void backup
(
const polyMesh& mesh,
const word& fromName,
const topoSet& fromSet,
const word& toName
)
{
Info<< "Backing up " << fromName << " into " << toName << endl;
topoSet backupSet(mesh, toName, fromSet);
backupSet.write();
}
// Read and copy set
void backup
(
const polyMesh& mesh,
const word& fromName,
const word& toName
)
{
topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT);
backup(mesh, fromName, fromSet, toName);
}
// Main program:
int main(int argc, char *argv[])
......@@ -114,8 +83,6 @@ int main(int argc, char *argv[])
{
r = IOobject::NO_READ;
backup(mesh, setName, setName + "_old");
currentSetPtr.reset
(
new pointSet
......@@ -151,7 +118,7 @@ int main(int argc, char *argv[])
if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
{
// currentSet has been read so can make copy.
backup(mesh, setName, currentSet, setName + "_old");
//backup(mesh, setName, currentSet, setName + "_old");
}
if (action == topoSetSource::CLEAR)
......@@ -173,7 +140,16 @@ int main(int argc, char *argv[])
forAll(topoSetSources, topoSetSourceI)
{
// Backup current set.
topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet);
autoPtr<topoSet> oldSet
(
topoSet::New
(
currentSet.type(),
mesh,
currentSet.name() + "_old2",
currentSet
)
);
currentSet.clear();
......
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Manipulate a cell/face/point set interactively.
Manipulate a cell/face/point/ set or zone interactively.
\*---------------------------------------------------------------------------*/
......@@ -42,6 +42,9 @@ Description
#include "writePatch.H"
#include "writePointSet.H"
#include "IOobjectList.H"
#include "cellZoneSet.H"
#include "faceZoneSet.H"
#include "pointZoneSet.H"
#include <stdio.h>
......@@ -82,6 +85,7 @@ Istream& selectStream(Istream* is0Ptr, Istream* is1Ptr)
// Copy set
void backup
(
const word& setType,
const polyMesh& mesh,
const word& fromName,
const topoSet& fromSet,
......@@ -92,9 +96,7 @@ void backup
{
Pout<< " Backing up " << fromName << " into " << toName << endl;
topoSet backupSet(mesh, toName, fromSet);
backupSet.write();
topoSet::New(setType, mesh, toName, fromSet)().write();
}
}
......@@ -102,14 +104,21 @@ void backup
// Read and copy set
void backup
(
const word& setType,
const polyMesh& mesh,
const word& fromName,
const word& toName
)
{
topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT);
autoPtr<topoSet> fromSet = topoSet::New
(
setType,
mesh,
fromName,
IOobject::READ_IF_PRESENT
);
backup(mesh, fromName, fromSet, toName);
backup(setType, mesh, fromName, fromSet(), toName);
}
......@@ -241,11 +250,13 @@ void printHelp(Ostream& os)
<< "A set command should be of the following form" << endl
<< endl
<< " cellSet|faceSet|pointSet <setName> <action> <source>"
<< endl << endl
<< endl
<< endl
<< "The <action> is one of" << endl
<< " list - prints the contents of the set" << endl
<< " clear - clears the set" << endl
<< " invert - inverts the set" << endl
<< " remove - remove the set" << endl
<< " new <source> - sets to set to the source set" << endl
<< " add <source> - adds all elements from the source set" << endl
<< " delete <source> - deletes ,," << endl
......@@ -270,6 +281,20 @@ void printHelp(Ostream& os)
<< " cellSet c0 add pointToCell p0 any" << endl
<< "List set:" << endl
<< " cellSet c0 list" << endl
<< endl
<< "Zones can be set using zoneSets from corresponding sets:" << endl
<< " cellZoneSet c0Zone new setToZone c0" << endl
<< " faceZoneSet f0Zone new setToZone f0" << endl
<< endl
<< "or if orientation is important:" << endl
<< " faceZoneSet f0Zone new setsToZone f0 c0" << endl
<< endl
<< "ZoneSets can be manipulated using the general actions:" << endl
<< " list - prints the contents of the set" << endl
<< " clear - clears the set" << endl
<< " invert - inverts the set (undefined orientation)"
<< endl
<< " remove - remove the set" << endl
<< endl;
}
......@@ -312,10 +337,126 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
os << '\t' << set.name() << "\tsize:" << set.size() << endl;
}
}
const cellZoneMesh& cellZones = mesh.cellZones();
if (cellZones.size())
{
os << "cellZones:" << endl;
forAll(cellZones, i)
{
const cellZone& zone = cellZones[i];
os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
}
}
const faceZoneMesh& faceZones = mesh.faceZones();
if (faceZones.size())
{
os << "faceZones:" << endl;
forAll(faceZones, i)
{
const faceZone& zone = faceZones[i];
os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
}
}
const pointZoneMesh& pointZones = mesh.pointZones();
if (pointZones.size())
{
os << "pointZones:" << endl;
forAll(pointZones, i)
{
const pointZone& zone = pointZones[i];
os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
}
}
os << endl;
}
template<class ZoneType>
void removeZone
(
ZoneMesh<ZoneType, polyMesh>& zones,
const word& setName
)
{
label zoneID = zones.findZoneID(setName);
if (zoneID != -1)
{
Info<< "Removing zone " << setName << " at index " << zoneID << endl;
// Shuffle to last position
labelList oldToNew(zones.size());
label newI = 0;
forAll(oldToNew, i)
{
if (i != zoneID)
{
oldToNew[i] = newI++;
}
}
oldToNew[zoneID] = newI;
zones.reorder(oldToNew);
// Remove last element
zones.setSize(zones.size()-1);
zones.clearAddressing();
zones.write();
}
}
// Physically remove a set
void removeSet
(
const polyMesh& mesh,
const word& setType,
const word& setName
)
{
// Remove the file
IOobjectList objects
(
mesh,
mesh.pointsInstance(),
polyMesh::meshSubDir/"sets"
);
if (objects.found(setName))
{
// Remove file
fileName object = objects[setName]->objectPath();
Info<< "Removing file " << object << endl;
rm(object);
}
// See if zone
if (setType == cellZoneSet::typeName)
{
removeZone
(
const_cast<cellZoneMesh&>(mesh.cellZones()),
setName
);
}
else if (setType == faceZoneSet::typeName)
{
removeZone
(
const_cast<faceZoneMesh&>(mesh.faceZones()),
setName
);
}
else if (setType == pointZoneSet::typeName)
{
removeZone
(
const_cast<pointZoneMesh&>(mesh.pointZones()),
setName
);
}
}
// Read command and execute. Return true if ok, false otherwise.
bool doCommand
(
......@@ -358,38 +499,29 @@ bool doCommand
IOobject::readOption r;
if
if (action == topoSetSource::REMOVE)
{
removeSet(mesh, setType, setName);
}
else if
(
(action == topoSetSource::NEW)
|| (action == topoSetSource::CLEAR)
)
{
r = IOobject::NO_READ;
//backup(mesh, setName, setName + "_old");
currentSetPtr = topoSet::New(setType, mesh, setName, typSize);
}
else
{
r = IOobject::MUST_READ;
currentSetPtr = topoSet::New(setType, mesh, setName, r);
topoSet& currentSet = currentSetPtr();
// Presize it according to current mesh data.
currentSet.resize(max(currentSet.size(), typSize));
}
if (currentSetPtr.empty())
{
Pout<< " Cannot construct/load set "
<< topoSet::localPath(mesh, setName) << endl;
ok = false;
}
else
if (currentSetPtr.valid())
{
topoSet& currentSet = currentSetPtr();
......@@ -398,12 +530,6 @@ bool doCommand
<< " Action:" << actionName
<< endl;
//if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
//{
// // currentSet has been read so can make copy.
// backup(mesh, setName, currentSet, setName + "_old");
//}
switch (action)
{
case topoSetSource::CLEAR:
......@@ -437,15 +563,18 @@ bool doCommand
);
// Backup current set.
topoSet oldSet
autoPtr<topoSet> oldSet
(
mesh,
currentSet.name() + "_old2",
currentSet
topoSet::New
(
setType,
mesh,
currentSet.name() + "_old2",
currentSet
)
);
currentSet.clear();
currentSet.resize(oldSet.size());
setSource().applyToSet(topoSetSource::NEW, currentSet);
// Combine new value of currentSet with old one.
......@@ -547,7 +676,8 @@ enum commandStatus
{
QUIT, // quit program
INVALID, // token is not a valid set manipulation command
VALID // ,, is a valid ,,
VALIDSETCMD, // ,, is a valid ,,
VALIDZONECMD // ,, is a valid zone ,,
};
......@@ -654,7 +784,16 @@ commandStatus parseType
|| setType == "pointSet"
)
{
return VALID;
return VALIDSETCMD;
}
else if
(
setType == "cellZoneSet"
|| setType == "faceZoneSet"
|| setType == "pointZoneSet"
)
{
return VALIDZONECMD;
}
else
{
......@@ -664,7 +803,7 @@ commandStatus parseType