Updates for topological changes in parallel
This commit is contained in:
parent
1470c8ce25
commit
bf50124638
9 changed files with 83 additions and 27 deletions
|
@ -113,6 +113,68 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (args.optionFound("writep"))
|
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();
|
p.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ int main(int argc, char *argv[])
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
bool meshChanged = mesh.update();
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
if (meshChanged)
|
if (meshChanged)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,8 +80,9 @@ int main(int argc, char *argv[])
|
||||||
phi += meshFlux;
|
phi += meshFlux;
|
||||||
|
|
||||||
bool meshChanged = mesh.update();
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
if(meshChanged)
|
if (meshChanged)
|
||||||
{
|
{
|
||||||
thermo.correct();
|
thermo.correct();
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ int main(int argc, char *argv[])
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
bool meshChanged = mesh.update();
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
if (meshChanged)
|
if (meshChanged)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,6 +68,7 @@ int main(int argc, char *argv[])
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
bool meshChanged = mesh.update();
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
# include "volContinuity.H"
|
# include "volContinuity.H"
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ int main(int argc, char *argv[])
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
bool meshChanged = mesh.update();
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
# include "volContinuity.H"
|
# include "volContinuity.H"
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,9 @@ int main(int argc, char *argv[])
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
bool meshChanged = mesh.update();
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
if (correctPhi && (mesh.moving() || meshChanged))
|
if (correctPhi && meshChanged)
|
||||||
{
|
{
|
||||||
# include "correctPhi.H"
|
# include "correctPhi.H"
|
||||||
}
|
}
|
||||||
|
@ -79,7 +80,7 @@ int main(int argc, char *argv[])
|
||||||
// Make the fluxes relative to the mesh motion
|
// Make the fluxes relative to the mesh motion
|
||||||
fvc::makeRelative(phi, U);
|
fvc::makeRelative(phi, U);
|
||||||
|
|
||||||
if (mesh.moving() && checkMeshCourantNo)
|
if (checkMeshCourantNo)
|
||||||
{
|
{
|
||||||
# include "meshCourantNo.H"
|
# include "meshCourantNo.H"
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,28 +82,23 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
|
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
|
||||||
|
|
||||||
// Do any mesh changes
|
bool meshChanged = mesh.update();
|
||||||
mesh.update();
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
if (mesh.changing())
|
# include "volContinuity.H"
|
||||||
{
|
|
||||||
Info<< "Execution time for mesh.update() = "
|
|
||||||
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
|
|
||||||
<< " s" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mesh.changing() && correctPhi)
|
if (correctPhi && meshChanged)
|
||||||
{
|
{
|
||||||
#include "correctPhi.H"
|
# include "correctPhi.H"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the fluxes relative to the mesh motion
|
// Make the fluxes relative to the mesh motion
|
||||||
fvc::makeRelative(phi, U);
|
fvc::makeRelative(phi, U);
|
||||||
|
|
||||||
if (mesh.changing() && checkMeshCourantNo)
|
if (checkMeshCourantNo)
|
||||||
{
|
{
|
||||||
#include "meshCourantNo.H"
|
# include "meshCourantNo.H"
|
||||||
}
|
}
|
||||||
|
|
||||||
turbulence->correct();
|
turbulence->correct();
|
||||||
|
|
|
@ -75,22 +75,15 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
// Do any mesh changes
|
# include "volContinuity.H"
|
||||||
mesh.update();
|
|
||||||
|
|
||||||
if (mesh.changing())
|
|
||||||
{
|
|
||||||
Info<< "Execution time for mesh.update() = "
|
|
||||||
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
|
|
||||||
<< " s" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
volScalarField gh("gh", g & mesh.C());
|
volScalarField gh("gh", g & mesh.C());
|
||||||
surfaceScalarField ghf("ghf", g & mesh.Cf());
|
surfaceScalarField ghf("ghf", g & mesh.Cf());
|
||||||
|
|
||||||
if (mesh.changing() && correctPhi)
|
if (correctPhi && meshChanged)
|
||||||
{
|
{
|
||||||
# include "correctPhi.H"
|
# include "correctPhi.H"
|
||||||
}
|
}
|
||||||
|
@ -98,7 +91,7 @@ int main(int argc, char *argv[])
|
||||||
// Make the fluxes relative to the mesh motion
|
// Make the fluxes relative to the mesh motion
|
||||||
fvc::makeRelative(phi, U);
|
fvc::makeRelative(phi, U);
|
||||||
|
|
||||||
if (mesh.changing() && checkMeshCourantNo)
|
if (checkMeshCourantNo)
|
||||||
{
|
{
|
||||||
# include "meshCourantNo.H"
|
# include "meshCourantNo.H"
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue