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

Merge commit 'OpenCFD/master' into olesenm

parents 48247a3d 0b1b0c29
......@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
......
EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \
-I../XiFoam \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
......
......@@ -70,11 +70,12 @@ int main(int argc, char *argv[])
#include "UEqn.H"
#include "hEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "hEqn.H"
#include "pEqn.H"
}
......
......@@ -53,12 +53,15 @@
);
Info<< "Creating field DpDt\n" << endl;
volScalarField DpDt =
fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
volScalarField DpDt
(
"DpDt",
fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p)
);
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
surfaceScalarField ghf("ghf", g & mesh.Cf());
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));
......
......@@ -12,8 +12,8 @@
(
fvc::interpolate(rho)
*(
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
)
);
......
......@@ -53,7 +53,7 @@
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
surfaceScalarField ghf("ghf", g & mesh.Cf());
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));
......
......@@ -103,8 +103,8 @@ public:
const dictionary&
);
//- Construct by mapping given solidWallMixedTemperatureCoupledFvPatchScalarField
// onto a new patch
//- Construct by mapping given
// solidWallMixedTemperatureCoupledFvPatchScalarField onto a new patch
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const solidWallMixedTemperatureCoupledFvPatchScalarField&,
......
......@@ -4,7 +4,7 @@
volScalarField& rho = rhoFluid[i];
volScalarField& K = KFluid[i];
volVectorField& U = UFluid[i];
surfaceScalarField phi = phiFluid[i];
surfaceScalarField& phi = phiFluid[i];
compressible::turbulenceModel& turb = turbulence[i];
volScalarField& DpDt = DpDtFluid[i];
const volScalarField& gh = ghFluid[i];
......
......@@ -85,7 +85,7 @@
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
surfaceScalarField ghf("ghf", g & mesh.Cf());
volScalarField p
......
......@@ -47,7 +47,7 @@
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
surfaceScalarField ghf("ghf", g & mesh.Cf());
volScalarField p
......
......@@ -339,4 +339,4 @@
);
Info<< "Calculating field (g.h)f\n" << endl;
surfaceScalarField ghf = surfaceScalarField("gh", g & mesh.Cf());
surfaceScalarField ghf = surfaceScalarField("ghf", g & mesh.Cf());
......@@ -344,6 +344,7 @@ int main(int argc, char *argv[])
argList::validOptions.insert("point", "pointI");
argList::validOptions.insert("cellSet", "setName");
argList::validOptions.insert("faceSet", "setName");
# include "addRegionOption.H"
# include "setRootCase.H"
# include "createTime.H"
......@@ -364,7 +365,7 @@ int main(int argc, char *argv[])
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createPolyMesh.H"
# include "createNamedPolyMesh.H"
forAll(timeDirs, timeI)
{
......
......@@ -48,12 +48,164 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void createBaffles
(
const polyMesh& mesh,
const label faceI,
const label oldPatchI,
const labelList& newPatches,
PackedBoolList& doneFace,
polyTopoChange& meshMod
)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const faceZoneMesh& faceZones = mesh.faceZones();
const face& f = mesh.faces()[faceI];
label zoneID = faceZones.whichZone(faceI);
bool zoneFlip = false;
if (zoneID >= 0)
{
const faceZone& fZone = faceZones[zoneID];
zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
}
label nei = -1;
if (oldPatchI == -1)
{
nei = mesh.faceNeighbour()[faceI];
}
face revFace(f.reverseFace());
forAll(newPatches, i)
{
if (oldPatchI == -1)
{
// Internal face
if (doneFace.set(faceI))
{
// First usage of face. Modify.
meshMod.setAction
(
polyModifyFace
(
f, // modified face
faceI, // label of face
mesh.faceOwner()[faceI], // owner
-1, // neighbour
false, // face flip
newPatches[i], // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
}
else
{
// Second or more usage of face. Add.
meshMod.setAction
(
polyAddFace
(
f, // modified face
mesh.faceOwner()[faceI], // owner
-1, // neighbour
-1, // master point
-1, // master edge
faceI, // master face
false, // face flip
newPatches[i], // patch for face
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
}
meshMod.setAction
(
polyAddFace
(
revFace, // modified face
nei, // owner
-1, // neighbour
-1, // masterPointID
-1, // masterEdgeID
faceI, // masterFaceID,
true, // face flip
newPatches[i], // patch for face
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
}
else if
(
patches[oldPatchI].coupled()
&& patches[newPatches[i]].coupled()
)
{
// Do not allow coupled patches to be moved to different coupled
// patches.
//WarningIn("createBaffles()")
// << "Not moving face from coupled patch "
// << patches[oldPatchI].name()
// << " to another coupled patch " << patches[newPatches[i]]
// << endl;
}
else
{
if (doneFace.set(faceI))
{
meshMod.setAction
(
polyModifyFace
(
f, // modified face
faceI, // label of face
mesh.faceOwner()[faceI], // owner
-1, // neighbour
false, // face flip
newPatches[i], // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
}
else
{
meshMod.setAction
(
polyAddFace
(
f, // modified face
mesh.faceOwner()[faceI], // owner
-1, // neighbour
-1, // master point
-1, // master edge
faceI, // master face
false, // face flip
newPatches[i], // patch for face
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
}
}
}
}
// Main program:
int main(int argc, char *argv[])
{
argList::validArgs.append("set");
argList::validArgs.append("patch");
argList::validOptions.insert("additionalPatches", "(patch2 .. patchN)");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
......@@ -63,29 +215,64 @@ int main(int argc, char *argv[])
const word oldInstance = mesh.pointsInstance();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const faceZoneMesh& faceZones = mesh.faceZones();
// Faces to baffle
word setName(args.additionalArgs()[0]);
Pout<< "Reading faceSet from " << setName << nl << endl;
faceSet facesToSplit(mesh, setName);
// Make sure set is synchronised across couples
facesToSplit.sync(mesh);
Pout<< "Read " << facesToSplit.size() << " faces from " << setName
<< nl << endl;
// Patch to put them into
word patchName(args.additionalArgs()[1]);
label wantedPatchI = patches.findPatchID(patchName);
Pout<< "Using patch " << patchName << " at index " << wantedPatchI << endl;
// Patches to put baffles into
labelList newPatches(1);
if (wantedPatchI == -1)
word patchName(args.additionalArgs()[1]);
newPatches[0] = patches.findPatchID(patchName);
Pout<< "Using patch " << patchName
<< " at index " << newPatches[0] << endl;
if (newPatches[0] == -1)
{
FatalErrorIn(args.executable())
<< "Cannot find patch " << patchName << exit(FatalError);
<< "Cannot find patch " << patchName << endl
<< "Valid patches are " << patches.names() << exit(FatalError);
}
// Additional patches
if (args.options().found("additionalPatches"))
{
const wordList patchNames
(
IStringStream(args.options()["additionalPatches"])()
);
forAll(patchNames, i)
{
label patchI = patches.findPatchID(patchNames[i]);
Info<< "Using additional patch " << patchNames[i]
<< " at index " << patchI << endl;
if (patchI == -1)
{
FatalErrorIn(args.executable())
<< "Cannot find patch " << patchNames[i] << endl
<< "Valid patches are " << patches.names()
<< exit(FatalError);
}
newPatches.append(patchI);
}
}
bool overwrite = args.options().found("overwrite");
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
......@@ -128,107 +315,53 @@ int main(int argc, char *argv[])
polyTopoChange meshMod(mesh);
// Creating baffles:
// - coupled boundary faces : become the patch specified
// - non-coupled ,, : illegal
// - internal faces : converted into boundary faces.
// Do the actual changes
labelList newPatch(mesh.nFaces(), -1);
label nBaffled = 0;
PackedBoolList doneFace(mesh.nFaces());
forAllConstIter(faceSet, facesToSplit, iter)
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
{
label faceI = iter.key();
label patchI = patches.whichPatch(faceI);
if (patchI == -1)
if (facesToSplit.found(faceI))
{
newPatch[faceI] = wantedPatchI;
}
else
{
if (patches[patchI].coupled())
{
if (patchI != wantedPatchI)
{
newPatch[faceI] = wantedPatchI;
}
}
else
{
FatalErrorIn(args.executable())
<< "Can only create baffles from internal faces"
<< " or coupled boundary faces." << endl
<< "Face " << faceI << " is a boundary face on patch "
<< patches[patchI].name() << exit(FatalError);
}
createBaffles
(
mesh,
faceI,
-1, // oldPatchI,
newPatches,
doneFace,
meshMod
);
nBaffled++;
}
}
// If one side of a coupled boundary is marked for baffling, make sure to
// also do the other side.
syncTools::syncFaceList(mesh, newPatch, maxEqOp<label>(), false);
label nBaffled = 0;
forAll(newPatch, faceI)
forAll(patches, patchI)
{
if (newPatch[faceI] != -1)
{
const face& f = mesh.faces()[faceI];
label zoneID = faceZones.whichZone(faceI);
bool zoneFlip = false;
if (zoneID >= 0)
{
const faceZone& fZone = faceZones[zoneID];
zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
}
const polyPatch& pp = patches[patchI];
meshMod.setAction
(
polyModifyFace
(
f, // modified face
faceI, // label of face
mesh.faceOwner()[faceI], // owner
-1, // neighbour
false, // face flip
newPatch[faceI], // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
forAll(pp, i)
{
label faceI = pp.start()+i;
if (mesh.isInternalFace(faceI))
if (facesToSplit.found(faceI))
{
meshMod.setAction
createBaffles
(
polyAddFace
(
f.reverseFace(), // modified face
mesh.faceNeighbour()[faceI],// owner
-1, // neighbour
-1, // masterPointID
-1, // masterEdgeID
faceI, // masterFaceID,
false, // face flip
newPatch[faceI], // patch for face
zoneID, // zone for face
zoneFlip // face flip in zone
)
mesh,
faceI,
patchI, // oldPatchI,
newPatches,
doneFace,
meshMod
);
nBaffled++;
}
nBaffled++;
}
}
Pout<< "Converted locally " << nBaffled
Info<< "Converted " << returnReduce(nBaffled, sumOp<label>())
<< " faces into boundary faces on patch " << patchName << nl << endl;
if (!overwrite)
......@@ -252,7 +385,7 @@ int main(int argc, char *argv[])
{
mesh.setInstance(oldInstance);
}
Pout<< "Writing mesh to " << runTime.timeName() << endl;
Info<< "Writing mesh to " << runTime.timeName() << endl;
mesh.write();
......
......@@ -57,6 +57,7 @@ Description
#include "EdgeMap.H"
#include "syncTools.H"
#include "ReadFields.H"
#include "directMappedWallPolyPatch.H"
using namespace Foam;
......@@ -1022,13 +1023,13 @@ EdgeMap<label> addRegionPatches
(
mesh,
regionNames[e[0]] + "_to_" + regionNames[e[1]],
polyPatch::typeName
directMappedWallPolyPatch::typeName
);
addPatch
(
mesh,
regionNames[e[1]] + "_to_" + regionNames[e[0]],
polyPatch::typeName
directMappedWallPolyPatch::typeName
);
Info<< "For interface between region " << e[0]
......@@ -1100,7 +1101,6 @@ EdgeMap<label> addRegionPatches
//}
//XXXXXXXXX
// Find region that covers most of cell zone
label findCorrespondingRegion
(
......@@ -1152,7 +1152,6 @@ label findCorrespondingRegion
return regionI;
}
//XXXXXXXXX
//// Checks if cellZone has corresponding cellRegion.
......
......@@ -83,6 +83,7 @@ Usage
int main(int argc, char *argv[])
{
argList::noParallel();
# include "addRegionOption.H"
argList::validOptions.insert("cellDist", "");
argList::validOptions.insert("copyUniform", "");
argList::validOptions.insert("fields", "");
......@@ -92,6 +93,17 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
word regionName = fvMesh::defaultRegion;
word regionDir = word::null;
if (args.options().found("region"))
{
regionName = args.options()["region"];
regionDir = regionName;
Info<< "Decomposing mesh " << regionName << nl << endl;
}
bool writeCellDist(args.options().found("cellDist"));