Updates for topological changes in parallel

This commit is contained in:
Hrvoje Jasak 2011-02-27 02:17:43 +00:00
parent 1470c8ce25
commit bf50124638
9 changed files with 83 additions and 27 deletions

View file

@ -113,6 +113,68 @@ int main(int argc, char *argv[])
if (args.optionFound("writep"))
{
// Find reference patch
label refPatch = -1;
scalar maxMagU = 0;
// Go through all velocity patches and find the one that fixes
// velocity to the largest value
forAll (U.boundaryField(), patchI)
{
const fvPatchVectorField& Upatch = U.boundaryField()[patchI];
if (Upatch.fixesValue())
{
// Calculate mean velocity
scalar u = sum(mag(Upatch));
label patchSize = Upatch.size();
reduce(u, sumOp<scalar>());
reduce(patchSize, sumOp<label>());
if (patchSize > 0)
{
scalar curMag = u/patchSize;
if (curMag > maxMagU)
{
refPatch = patchI;
maxMagU = curMag;
}
}
}
}
if (refPatch > -1)
{
// Calculate reference pressure
const fvPatchVectorField& Upatch = U.boundaryField()[refPatch];
const fvPatchScalarField& pPatch = p.boundaryField()[refPatch];
scalar patchE = sum(mag(pPatch + 0.5*magSqr(Upatch)));
label patchSize = Upatch.size();
reduce(patchE, sumOp<scalar>());
reduce(patchSize, sumOp<label>());
scalar e = patchE/patchSize;
Info<< "Using reference patch " << refPatch
<< " with mag(U) = " << maxMagU
<< " p + 0.5*U^2 = " << e << endl;
p.internalField() = e - 0.5*magSqr(U.internalField());
p.correctBoundaryConditions();
}
else
{
Info<< "No reference patch found. Writing potential function"
<< endl;
}
p.write();
}

View file

@ -69,6 +69,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
if (meshChanged)
{

View file

@ -80,8 +80,9 @@ int main(int argc, char *argv[])
phi += meshFlux;
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
if(meshChanged)
if (meshChanged)
{
thermo.correct();

View file

@ -69,6 +69,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
if (meshChanged)
{

View file

@ -68,6 +68,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
# include "volContinuity.H"

View file

@ -69,6 +69,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
# include "volContinuity.H"

View file

@ -70,8 +70,9 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
if (correctPhi && (mesh.moving() || meshChanged))
if (correctPhi && meshChanged)
{
# include "correctPhi.H"
}
@ -79,7 +80,7 @@ int main(int argc, char *argv[])
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
if (mesh.moving() && checkMeshCourantNo)
if (checkMeshCourantNo)
{
# include "meshCourantNo.H"
}

View file

@ -82,28 +82,23 @@ int main(int argc, char *argv[])
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
// Do any mesh changes
mesh.update();
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
}
# include "volContinuity.H"
if (mesh.changing() && correctPhi)
if (correctPhi && meshChanged)
{
#include "correctPhi.H"
# include "correctPhi.H"
}
}
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
if (mesh.changing() && checkMeshCourantNo)
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
# include "meshCourantNo.H"
}
turbulence->correct();

View file

@ -75,22 +75,15 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
bool meshChanged = mesh.update();
reduce(meshChanged, orOp<bool>());
// Do any mesh changes
mesh.update();
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
}
# include "volContinuity.H"
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("ghf", g & mesh.Cf());
if (mesh.changing() && correctPhi)
if (correctPhi && meshChanged)
{
# include "correctPhi.H"
}
@ -98,7 +91,7 @@ int main(int argc, char *argv[])
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
if (mesh.changing() && checkMeshCourantNo)
if (checkMeshCourantNo)
{
# include "meshCourantNo.H"
}