mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: decomposePar: cache decomposeers if running with multiple times.
This commit is contained in:
@ -322,6 +322,23 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Caches
|
||||||
|
// ~~~~~~
|
||||||
|
// Cached processor meshes and maps. These are only preserved if running
|
||||||
|
// with multiple times.
|
||||||
|
PtrList<Time> processorDbList(mesh.nProcs());
|
||||||
|
PtrList<fvMesh> procMeshList(mesh.nProcs());
|
||||||
|
PtrList<labelIOList> faceProcAddressingList(mesh.nProcs());
|
||||||
|
PtrList<labelIOList> cellProcAddressingList(mesh.nProcs());
|
||||||
|
PtrList<labelIOList> boundaryProcAddressingList(mesh.nProcs());
|
||||||
|
PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs());
|
||||||
|
PtrList<dimFieldDecomposer> dimFieldDecomposerList(mesh.nProcs());
|
||||||
|
PtrList<labelIOList> pointProcAddressingList(mesh.nProcs());
|
||||||
|
PtrList<pointFieldDecomposer> pointFieldDecomposerList(mesh.nProcs());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Loop over all times
|
// Loop over all times
|
||||||
forAll(times, timeI)
|
forAll(times, timeI)
|
||||||
{
|
{
|
||||||
@ -674,13 +691,24 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< "Processor " << procI << ": field transfer" << endl;
|
Info<< "Processor " << procI << ": field transfer" << endl;
|
||||||
|
|
||||||
|
|
||||||
// open the database
|
// open the database
|
||||||
Time processorDb
|
if (!processorDbList.set(procI))
|
||||||
|
{
|
||||||
|
processorDbList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new Time
|
||||||
(
|
(
|
||||||
Time::controlDictName,
|
Time::controlDictName,
|
||||||
args.rootPath(),
|
args.rootPath(),
|
||||||
args.caseName()/fileName(word("processor") + name(procI))
|
args.caseName()
|
||||||
|
/fileName(word("processor") + name(procI))
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
Time& processorDb = processorDbList[procI];
|
||||||
|
|
||||||
|
|
||||||
processorDb.setTime(runTime);
|
processorDb.setTime(runTime);
|
||||||
|
|
||||||
@ -695,7 +723,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read the mesh
|
// read the mesh
|
||||||
fvMesh procMesh
|
if (!procMeshList.set(procI))
|
||||||
|
{
|
||||||
|
procMeshList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new fvMesh
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -703,9 +736,18 @@ int main(int argc, char *argv[])
|
|||||||
processorDb.timeName(),
|
processorDb.timeName(),
|
||||||
processorDb
|
processorDb
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const fvMesh& procMesh = procMeshList[procI];
|
||||||
|
|
||||||
labelIOList faceProcAddressing
|
|
||||||
|
if (!faceProcAddressingList.set(procI))
|
||||||
|
{
|
||||||
|
faceProcAddressingList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new labelIOList
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -716,9 +758,19 @@ int main(int argc, char *argv[])
|
|||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const labelIOList& faceProcAddressing =
|
||||||
|
faceProcAddressingList[procI];
|
||||||
|
|
||||||
labelIOList cellProcAddressing
|
|
||||||
|
if (!cellProcAddressingList.set(procI))
|
||||||
|
{
|
||||||
|
cellProcAddressingList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new labelIOList
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -729,9 +781,19 @@ int main(int argc, char *argv[])
|
|||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const labelIOList& cellProcAddressing =
|
||||||
|
cellProcAddressingList[procI];
|
||||||
|
|
||||||
labelIOList boundaryProcAddressing
|
|
||||||
|
if (!boundaryProcAddressingList.set(procI))
|
||||||
|
{
|
||||||
|
boundaryProcAddressingList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new labelIOList
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -742,18 +804,32 @@ int main(int argc, char *argv[])
|
|||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const labelIOList& boundaryProcAddressing =
|
||||||
|
boundaryProcAddressingList[procI];
|
||||||
|
|
||||||
|
|
||||||
// FV fields
|
// FV fields
|
||||||
{
|
{
|
||||||
fvFieldDecomposer fieldDecomposer
|
if (!fieldDecomposerList.set(procI))
|
||||||
|
{
|
||||||
|
fieldDecomposerList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new fvFieldDecomposer
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
procMesh,
|
procMesh,
|
||||||
faceProcAddressing,
|
faceProcAddressing,
|
||||||
cellProcAddressing,
|
cellProcAddressing,
|
||||||
boundaryProcAddressing
|
boundaryProcAddressing
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const fvFieldDecomposer& fieldDecomposer =
|
||||||
|
fieldDecomposerList[procI];
|
||||||
|
|
||||||
fieldDecomposer.decomposeFields(volScalarFields);
|
fieldDecomposer.decomposeFields(volScalarFields);
|
||||||
fieldDecomposer.decomposeFields(volVectorFields);
|
fieldDecomposer.decomposeFields(volVectorFields);
|
||||||
@ -766,23 +842,43 @@ int main(int argc, char *argv[])
|
|||||||
fieldDecomposer.decomposeFields(surfaceSphericalTensorFields);
|
fieldDecomposer.decomposeFields(surfaceSphericalTensorFields);
|
||||||
fieldDecomposer.decomposeFields(surfaceSymmTensorFields);
|
fieldDecomposer.decomposeFields(surfaceSymmTensorFields);
|
||||||
fieldDecomposer.decomposeFields(surfaceTensorFields);
|
fieldDecomposer.decomposeFields(surfaceTensorFields);
|
||||||
|
|
||||||
|
if (times.size() == 1)
|
||||||
|
{
|
||||||
|
// Clear cached decomposer
|
||||||
|
fieldDecomposerList.set(procI, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dimensioned fields
|
// Dimensioned fields
|
||||||
{
|
{
|
||||||
dimFieldDecomposer fieldDecomposer
|
if (!dimFieldDecomposerList.set(procI))
|
||||||
|
{
|
||||||
|
dimFieldDecomposerList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new dimFieldDecomposer
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
procMesh,
|
procMesh,
|
||||||
faceProcAddressing,
|
faceProcAddressing,
|
||||||
cellProcAddressing
|
cellProcAddressing
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const dimFieldDecomposer& dimDecomposer =
|
||||||
|
dimFieldDecomposerList[procI];
|
||||||
|
|
||||||
fieldDecomposer.decomposeFields(dimScalarFields);
|
dimDecomposer.decomposeFields(dimScalarFields);
|
||||||
fieldDecomposer.decomposeFields(dimVectorFields);
|
dimDecomposer.decomposeFields(dimVectorFields);
|
||||||
fieldDecomposer.decomposeFields(dimSphericalTensorFields);
|
dimDecomposer.decomposeFields(dimSphericalTensorFields);
|
||||||
fieldDecomposer.decomposeFields(dimSymmTensorFields);
|
dimDecomposer.decomposeFields(dimSymmTensorFields);
|
||||||
fieldDecomposer.decomposeFields(dimTensorFields);
|
dimDecomposer.decomposeFields(dimTensorFields);
|
||||||
|
|
||||||
|
if (times.size() == 1)
|
||||||
|
{
|
||||||
|
dimFieldDecomposerList.set(procI, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -796,7 +892,12 @@ int main(int argc, char *argv[])
|
|||||||
|| pointTensorFields.size()
|
|| pointTensorFields.size()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
labelIOList pointProcAddressing
|
if (!pointProcAddressingList.set(procI))
|
||||||
|
{
|
||||||
|
pointProcAddressingList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new labelIOList
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -807,23 +908,43 @@ int main(int argc, char *argv[])
|
|||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const labelIOList& pointProcAddressing =
|
||||||
|
pointProcAddressingList[procI];
|
||||||
|
|
||||||
pointMesh procPMesh(procMesh);
|
const pointMesh& procPMesh = pointMesh::New(procMesh);
|
||||||
|
|
||||||
pointFieldDecomposer fieldDecomposer
|
if (!pointFieldDecomposerList.set(procI))
|
||||||
|
{
|
||||||
|
pointFieldDecomposerList.set
|
||||||
|
(
|
||||||
|
procI,
|
||||||
|
new pointFieldDecomposer
|
||||||
(
|
(
|
||||||
pMesh,
|
pMesh,
|
||||||
procPMesh,
|
procPMesh,
|
||||||
pointProcAddressing,
|
pointProcAddressing,
|
||||||
boundaryProcAddressing
|
boundaryProcAddressing
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
const pointFieldDecomposer& pointDecomposer =
|
||||||
|
pointFieldDecomposerList[procI];
|
||||||
|
|
||||||
fieldDecomposer.decomposeFields(pointScalarFields);
|
pointDecomposer.decomposeFields(pointScalarFields);
|
||||||
fieldDecomposer.decomposeFields(pointVectorFields);
|
pointDecomposer.decomposeFields(pointVectorFields);
|
||||||
fieldDecomposer.decomposeFields(pointSphericalTensorFields);
|
pointDecomposer.decomposeFields(pointSphericalTensorFields);
|
||||||
fieldDecomposer.decomposeFields(pointSymmTensorFields);
|
pointDecomposer.decomposeFields(pointSymmTensorFields);
|
||||||
fieldDecomposer.decomposeFields(pointTensorFields);
|
pointDecomposer.decomposeFields(pointTensorFields);
|
||||||
|
|
||||||
|
|
||||||
|
if (times.size() == 1)
|
||||||
|
{
|
||||||
|
pointProcAddressingList.set(procI, NULL);
|
||||||
|
pointFieldDecomposerList.set(procI, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -938,6 +1059,20 @@ int main(int argc, char *argv[])
|
|||||||
chDir(currentDir);
|
chDir(currentDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// We have cached all the constant mesh data for the current
|
||||||
|
// processor. This is only important if running with multiple
|
||||||
|
// times, otherwise it is just extra storage.
|
||||||
|
if (times.size() == 1)
|
||||||
|
{
|
||||||
|
boundaryProcAddressingList.set(procI, NULL);
|
||||||
|
cellProcAddressingList.set(procI, NULL);
|
||||||
|
faceProcAddressingList.set(procI, NULL);
|
||||||
|
procMeshList.set(procI, NULL);
|
||||||
|
processorDbList.set(procI, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user