ENH: add maxMem information to profiling

- value corresponds to the max memory when the corresponding profiling
  is started.
  Only used when the top-level profiling has memInfo active.

- memInfo is disabled by default, since the new maxMem functionality
  otherwise adds overhead with every call.

tutorial:
    /lagrangian/reactingParcelFoam/verticalChannelLTS
This commit is contained in:
Mark Olesen 2016-06-20 21:21:43 +02:00
parent 37bf28c249
commit cbc4e0d96f
15 changed files with 70 additions and 514 deletions

View File

@ -171,6 +171,15 @@ Foam::profiling::Information* Foam::profiling::New
}
pool_->push(info, timer);
if (pool_->memInfo_)
{
info->maxMem_ = Foam::max
(
info->maxMem_,
pool_->memInfo_->update().size()
);
}
}
return info;
@ -243,7 +252,7 @@ Foam::profiling::profiling
),
memInfo_
(
dict.lookupOrDefault<Switch>("memInfo", true)
dict.lookupOrDefault<Switch>("memInfo", false)
? new memInfo() : 0
)
{}
@ -274,6 +283,7 @@ Foam::profiling::Information::Information
calls_(0),
totalTime_(0),
childTime_(0),
maxMem_(0),
onStack_(false)
{}
@ -509,6 +519,10 @@ Foam::Ostream& Foam::profiling::Information::write
writeEntry(os, "calls", calls() + (offset ? 1 : 0));
writeEntry(os, "totalTime", totalTime() + elapsedTime);
writeEntry(os, "childTime", childTime() + childTimes);
if (maxMem_)
{
writeEntry(os, "maxMem", maxMem_);
}
writeEntry(os, "onStack", Switch(onStack()));
os.endBlock() << nl; // FUTURE: without nl

View File

@ -27,14 +27,15 @@ Class
Description
Code profiling.
This is typically activated from within the system/controlDict as follows:
This is typically activated from within the system/controlDict as follows
(defaults shown):
\code
profiling
{
active true; // default: true
cpuInfo true; // default: true
memInfo true; // default: true
sysInfo true; // default: true
active true;
cpuInfo true;
memInfo false;
sysInfo true;
}
\endcode
or simply using all defaults:
@ -247,6 +248,10 @@ class profiling::Information
//- Time spent in children
scalar childTime_;
//- Max memory usage on call.
// Only valid when the calling profiling has memInfo active.
mutable int maxMem_;
//- Is this information currently on the stack?
mutable bool onStack_;
@ -345,6 +350,12 @@ public:
}
inline int maxMem() const
{
return maxMem_;
}
inline bool onStack() const
{
return onStack_;
@ -444,6 +455,17 @@ public:
#define addProfiling0(name) \
::Foam::Profiling::Trigger profilingTriggerFor##name(#name)
//- Define profiling with specified name and description correspond to the
// compiler-defined function name string:
// \sa addProfiling
// \sa endProfiling
#ifdef __GNUC__
#define addProfilingInFunction(name) \
::Foam::profiling::Trigger profilingTriggerFor##name(__PRETTY_FUNCTION__)
#else
#define addProfilingInFunction(name) \
::Foam::profiling::Trigger profilingTriggerFor##name(__func__)
#endif
//- Remove profiling with specified name
// \sa addProfiling

View File

@ -3751,7 +3751,10 @@ void Foam::snappyLayerDriver::addLayers
);
fvMesh& newMesh = newMeshPtr();
//?neccesary? Update fields
// get timing, but more importantly get memory information
addProfiling(grow, "snappyHexMesh::layers::updateMesh");
//?necessary? Update fields
newMesh.updateMesh(map);
newMesh.setInstance(meshRefiner_.timeName());

View File

@ -1,54 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object H2O;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0.01;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
walls
{
type zeroGradient;
}
outlet
{
type inletOutlet;
inletValue uniform 0.0;
}
inletSides
{
type fixedValue;
value uniform 0.01;
}
inletCentral
{
type fixedValue;
value uniform 0.01;
}
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 473.0;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
walls
{
type zeroGradient;
}
outlet
{
type inletOutlet;
inletValue uniform 473.0;
}
inletSides
{
type fixedValue;
value uniform 473.0;
}
inletCentral
{
type fixedValue;
value uniform 573.0;
}
}
// ************************************************************************* //

View File

@ -1,56 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
inletCentral
{
type flowRateInletVelocity;
massFlowRate constant 0.00379;
value uniform (0 14.68 0);
}
inletSides
{
type flowRateInletVelocity;
massFlowRate constant 0.00832;
value uniform (0 17.79 0);
}
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
}
walls
{
type noSlip;
}
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object air;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0.99;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
walls
{
type zeroGradient;
}
outlet
{
type inletOutlet;
inletValue uniform 1.0;
}
inletSides
{
type fixedValue;
value uniform 0.99;
}
inletCentral
{
type fixedValue;
value uniform 0.99;
}
}
// ************************************************************************* //

View File

@ -1,56 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alphat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
inletCentral
{
type calculated;
value uniform 0;
}
inletSides
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
walls
{
type compressible::alphatWallFunction;
Prt 0.85;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -1,57 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 3.75e-9;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
inletCentral
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.15;
value uniform 3.75e-9;
}
inletSides
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.16;
value uniform 3.75e-9;
}
outlet
{
type inletOutlet;
inletValue uniform 3.75e-9;
}
walls
{
type kqRWallFunction;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -1,58 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
inletCentral
{
type calculated;
value uniform 0;
}
inletSides
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
walls
{
type nutkWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -1,62 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object omega;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 -1 0 0 0 0];
internalField uniform 4.5e-3;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
inletCentral
{
type turbulentMixingLengthFrequencyInlet;
mixingLength 0.007;
k k;
value uniform 4.5e-3;
}
inletSides
{
type turbulentMixingLengthFrequencyInlet;
mixingLength 0.007;
k k;
value uniform 4.5e-3;
}
outlet
{
type inletOutlet;
inletValue uniform 4.5e-3;
}
walls
{
type omegaWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -1,52 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 100000;
boundaryField
{
back
{
type symmetryPlane;
}
front
{
type symmetryPlane;
}
inletCentral
{
type zeroGradient;
}
inletSides
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 100000;
}
walls
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -7,10 +7,6 @@ cd ${0%/*} || exit 1 # Run from this directory
# remove old time and post-processing directories
rm -rf 0 *[1-9]* processor* postProcessing
# copy 0.org to 0
cp -r 0.org 0
cleanCase
#------------------------------------------------------------------------------

View File

@ -0,0 +1,20 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
# create mesh
runApplication blockMesh
cp -r 0.org 0
# initialise with potentialFoam solution
runApplication potentialFoam
rm -f 0/phi
# run the solver
runApplication `getApplication`
#------------------------------------------------------------------------------

View File

@ -45,6 +45,10 @@ timePrecision 6;
runTimeModifiable yes;
profiling
{
memInfo true;
}
functions
{