mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
GIT: Initial state after latest Foundation merge
This commit is contained in:
16
src/functionObjects/Allwmake
Executable file
16
src/functionObjects/Allwmake
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
set -x
|
||||
|
||||
wmake $targetType field
|
||||
wmake $targetType forces
|
||||
wmake $targetType lagrangian
|
||||
wmake $targetType utilities
|
||||
wmake $targetType solvers
|
||||
|
||||
./graphics/Allwmake
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
167
src/functionObjects/field/CourantNo/CourantNo.C
Normal file
167
src/functionObjects/field/CourantNo/CourantNo.C
Normal file
@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CourantNo.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "fvcSurfaceIntegrate.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(CourantNo, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
CourantNo,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::volScalarField::Internal>
|
||||
Foam::functionObjects::CourantNo::byRho
|
||||
(
|
||||
const tmp<volScalarField::Internal>& Co
|
||||
) const
|
||||
{
|
||||
if (Co().dimensions() == dimDensity)
|
||||
{
|
||||
return Co/obr_.lookupObject<volScalarField>(rhoName_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Co;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::CourantNo::calc()
|
||||
{
|
||||
if (foundObject<surfaceScalarField>(fieldName_))
|
||||
{
|
||||
const surfaceScalarField& phi =
|
||||
lookupObject<surfaceScalarField>(fieldName_);
|
||||
|
||||
tmp<volScalarField::Internal> Coi
|
||||
(
|
||||
byRho
|
||||
(
|
||||
(0.5*mesh_.time().deltaT())
|
||||
*fvc::surfaceSum(mag(phi))()()
|
||||
/mesh_.V()
|
||||
)
|
||||
);
|
||||
|
||||
if (foundObject<volScalarField>(resultName_))
|
||||
{
|
||||
volScalarField& Co
|
||||
(
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
lookupObject<volScalarField>(resultName_)
|
||||
)
|
||||
);
|
||||
|
||||
Co.ref() = Coi();
|
||||
Co.correctBoundaryConditions();
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp<volScalarField> tCo
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("0", dimless, 0.0),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
)
|
||||
);
|
||||
tCo.ref().ref() = Coi();
|
||||
tCo.ref().correctBoundaryConditions();
|
||||
mesh_.objectRegistry::store(tCo.ptr());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::CourantNo::CourantNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi"),
|
||||
rhoName_("rho")
|
||||
{
|
||||
setResultName("Co", "phi");
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::CourantNo::~CourantNo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::CourantNo::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
141
src/functionObjects/field/CourantNo/CourantNo.H
Normal file
141
src/functionObjects/field/CourantNo/CourantNo.H
Normal file
@ -0,0 +1,141 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::CourantNo
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates and outputs the Courant number as a
|
||||
volScalarField. The field is stored on the mesh database so that it can
|
||||
be retrieved and used for other applications.
|
||||
|
||||
Usage
|
||||
Example of function object specification to calculate the Courant number:
|
||||
\verbatim
|
||||
CourantNo1
|
||||
{
|
||||
type CourantNo;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: CourantNo | yes |
|
||||
rho | Name of density field | no | rho
|
||||
field | Name of flux field | no | phi
|
||||
result | Name of Courant number field | no | <function name>
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
CourantNo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_CourantNo_H
|
||||
#define functionObjects_CourantNo_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class CourantNo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class CourantNo
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of density field (optional)
|
||||
word rhoName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Divide the Courant number by rho if required
|
||||
tmp<volScalarField::Internal> byRho
|
||||
(
|
||||
const tmp<volScalarField::Internal>& Co
|
||||
) const;
|
||||
|
||||
//- Calculate the Courant number field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("CourantNo");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
CourantNo
|
||||
(
|
||||
const word& name,
|
||||
const Time&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~CourantNo();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the CourantNo data
|
||||
virtual bool read(const dictionary&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
98
src/functionObjects/field/Lambda2/Lambda2.C
Normal file
98
src/functionObjects/field/Lambda2/Lambda2.C
Normal file
@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Lambda2.H"
|
||||
#include "fvcGrad.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(Lambda2, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
Lambda2,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::Lambda2::calc()
|
||||
{
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
const tmp<volTensorField> tgradU(fvc::grad(U));
|
||||
const volTensorField& gradU = tgradU();
|
||||
|
||||
const volTensorField SSplusWW
|
||||
(
|
||||
(symm(gradU) & symm(gradU))
|
||||
+ (skew(gradU) & skew(gradU))
|
||||
);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
-eigenValues(SSplusWW)().component(vector::Y)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Lambda2::Lambda2
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Lambda2::~Lambda2()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
101
src/functionObjects/field/Lambda2/Lambda2.H
Normal file
101
src/functionObjects/field/Lambda2/Lambda2.H
Normal file
@ -0,0 +1,101 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::Lambda2
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates and outputs the second largest eigenvalue of the sum of the
|
||||
square of the symmetrical and anti-symmetrical parts of the velocity
|
||||
gradient tensor.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
Lambda2.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_Lambda2_H
|
||||
#define functionObjects_Lambda2_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Lambda2 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class Lambda2
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Lambda2 field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Lambda2");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
Lambda2
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Lambda2();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
97
src/functionObjects/field/MachNo/MachNo.C
Normal file
97
src/functionObjects/field/MachNo/MachNo.C
Normal file
@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "MachNo.H"
|
||||
#include "fluidThermo.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(MachNo, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
MachNo,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::MachNo::calc()
|
||||
{
|
||||
if
|
||||
(
|
||||
foundObject<volVectorField>(fieldName_)
|
||||
&& mesh_.foundObject<fluidThermo>(fluidThermo::dictName)
|
||||
)
|
||||
{
|
||||
const fluidThermo& thermo =
|
||||
mesh_.lookupObject<fluidThermo>(fluidThermo::dictName);
|
||||
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
mag(U)/sqrt(thermo.gamma()*thermo.p()/thermo.rho())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::MachNo::MachNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName("Ma", "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::MachNo::~MachNo()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
100
src/functionObjects/field/MachNo/MachNo.H
Normal file
100
src/functionObjects/field/MachNo/MachNo.H
Normal file
@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::MachNo
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates and writes the Mach number as a volScalarField.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
MachNo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_MachNo_H
|
||||
#define functionObjects_MachNo_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class MachNo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class MachNo
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Mach number field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("MachNo");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
MachNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~MachNo();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
74
src/functionObjects/field/Make/files
Normal file
74
src/functionObjects/field/Make/files
Normal file
@ -0,0 +1,74 @@
|
||||
fieldAverage/fieldAverage.C
|
||||
fieldAverage/fieldAverageItem/fieldAverageItem.C
|
||||
fieldAverage/fieldAverageItem/fieldAverageItemIO.C
|
||||
|
||||
fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C
|
||||
fieldMinMax/fieldMinMax.C
|
||||
|
||||
fieldValues/fieldValue/fieldValue.C
|
||||
fieldValues/fieldValue/fieldValueNew.C
|
||||
fieldValues/fieldValueDelta/fieldValueDelta.C
|
||||
fieldValues/volFieldValue/volFieldValue.C
|
||||
fieldValues/surfaceFieldValue/surfaceFieldValue.C
|
||||
|
||||
nearWallFields/nearWallFields.C
|
||||
nearWallFields/findCellParticle.C
|
||||
nearWallFields/findCellParticleCloud.C
|
||||
|
||||
processorField/processorField.C
|
||||
readFields/readFields.C
|
||||
|
||||
streamLine/streamLine.C
|
||||
streamLine/streamLineBase.C
|
||||
streamLine/streamLineParticle.C
|
||||
streamLine/streamLineParticleCloud.C
|
||||
|
||||
wallBoundedStreamLine/wallBoundedStreamLine.C
|
||||
wallBoundedStreamLine/wallBoundedStreamLineParticle.C
|
||||
wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.C
|
||||
wallBoundedStreamLine/wallBoundedParticle.C
|
||||
|
||||
surfaceInterpolate/surfaceInterpolate.C
|
||||
|
||||
regionSizeDistribution/regionSizeDistribution.C
|
||||
histogram/histogram.C
|
||||
|
||||
fieldExpression/fieldExpression.C
|
||||
components/components.C
|
||||
randomise/randomise.C
|
||||
div/div.C
|
||||
grad/grad.C
|
||||
mag/mag.C
|
||||
magSqr/magSqr.C
|
||||
vorticity/vorticity.C
|
||||
enstrophy/enstrophy.C
|
||||
Q/Q.C
|
||||
Lambda2/Lambda2.C
|
||||
flowType/flowType.C
|
||||
CourantNo/CourantNo.C
|
||||
PecletNo/PecletNo.C
|
||||
blendingFactor/blendingFactor.C
|
||||
pressure/pressure.C
|
||||
MachNo/MachNo.C
|
||||
|
||||
turbulenceFields/turbulenceFields.C
|
||||
yPlus/yPlus.C
|
||||
wallShearStress/wallShearStress.C
|
||||
wallHeatFlux/wallHeatFlux.C
|
||||
|
||||
writeCellCentres/writeCellCentres.C
|
||||
writeCellVolumes/writeCellVolumes.C
|
||||
|
||||
XiReactionRate/XiReactionRate.C
|
||||
streamFunction/streamFunction.C
|
||||
|
||||
valueAverage/valueAverage.C
|
||||
valueAverage/valueAverageFunctionObject.C
|
||||
|
||||
wallBoundedStreamLine/wallBoundedStreamLine.C
|
||||
wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C
|
||||
wallBoundedStreamLine/wallBoundedStreamLineParticle.C
|
||||
wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.C
|
||||
wallBoundedStreamLine/wallBoundedParticle.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
|
||||
36
src/functionObjects/field/Make/options
Normal file
36
src/functionObjects/field/Make/options
Normal file
@ -0,0 +1,36 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfluidThermophysicalModels \
|
||||
-lincompressibleTransportModels \
|
||||
-lturbulenceModels \
|
||||
-lcompressibleTransportModels \
|
||||
-lincompressibleTurbulenceModels \
|
||||
-lcompressibleTurbulenceModels \
|
||||
-lmeshTools \
|
||||
-lsampling \
|
||||
-lsurfMesh \
|
||||
-lchemistryModel \
|
||||
-lreactionThermophysicalModels
|
||||
157
src/functionObjects/field/PecletNo/PecletNo.C
Normal file
157
src/functionObjects/field/PecletNo/PecletNo.C
Normal file
@ -0,0 +1,157 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PecletNo.H"
|
||||
#include "turbulentTransportModel.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "surfaceInterpolate.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(PecletNo, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
PecletNo,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::PecletNo::calc()
|
||||
{
|
||||
if (foundObject<surfaceScalarField>(fieldName_))
|
||||
{
|
||||
// Obtain nuEff of muEff. Assumes that a compressible flux is present
|
||||
// when using a compressible turbulence model, and an incompressible
|
||||
// flux when using an incompressible turbulence model
|
||||
|
||||
tmp<volScalarField> nuOrMuEff;
|
||||
if (mesh_.foundObject<cmpTurbModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
const cmpTurbModel& model =
|
||||
mesh_.lookupObject<cmpTurbModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
nuOrMuEff = model.muEff();
|
||||
}
|
||||
else if
|
||||
(
|
||||
mesh_.foundObject<icoTurbModel>(turbulenceModel::propertiesName)
|
||||
)
|
||||
{
|
||||
const icoTurbModel& model =
|
||||
mesh_.lookupObject<icoTurbModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
nuOrMuEff = model.nuEff();
|
||||
}
|
||||
else if (mesh_.foundObject<dictionary>("transportProperties"))
|
||||
{
|
||||
const dictionary& model =
|
||||
mesh_.lookupObject<dictionary>("transportProperties");
|
||||
|
||||
nuOrMuEff =
|
||||
tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"nuEff",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(model.lookup("nu"))
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to determine the viscosity"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh_.lookupObject<surfaceScalarField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
mag(phi)
|
||||
/(
|
||||
mesh_.magSf()
|
||||
*mesh_.surfaceInterpolation::deltaCoeffs()
|
||||
*fvc::interpolate(nuOrMuEff)
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::PecletNo::PecletNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi")
|
||||
{
|
||||
setResultName("Pe", "phi");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::PecletNo::~PecletNo()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
116
src/functionObjects/field/PecletNo/PecletNo.H
Normal file
116
src/functionObjects/field/PecletNo/PecletNo.H
Normal file
@ -0,0 +1,116 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::PecletNo
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates and outputs the Peclet number as a surfaceScalarField.
|
||||
|
||||
Usage
|
||||
Example of function object specification to calculate the Peclet number:
|
||||
\verbatim
|
||||
Peclet1
|
||||
{
|
||||
type Peclet;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: Peclet | yes |
|
||||
phi | Name of flux field | no | phi
|
||||
result | Name of Peclet field | no | <function name>
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
PecletNo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_PecletNo_H
|
||||
#define functionObjects_PecletNo_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PecletNo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class PecletNo
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Peclet number field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("PecletNo");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
PecletNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~PecletNo();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
92
src/functionObjects/field/Q/Q.C
Normal file
92
src/functionObjects/field/Q/Q.C
Normal file
@ -0,0 +1,92 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Q.H"
|
||||
#include "fvcGrad.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(Q, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
Q,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::Q::calc()
|
||||
{
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
const tmp<volTensorField> tgradU(fvc::grad(U));
|
||||
const volTensorField& gradU = tgradU();
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU))))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Q::Q
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Q::~Q()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
129
src/functionObjects/field/Q/Q.H
Normal file
129
src/functionObjects/field/Q/Q.H
Normal file
@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::Q
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates and outputs the second invariant of the velocity gradient tensor
|
||||
[1/s^2].
|
||||
|
||||
\f[
|
||||
Q = 0.5(sqr(tr(\nabla U)) - tr(((\nabla U) \cdot (\nabla U))))
|
||||
\f]
|
||||
|
||||
where
|
||||
\vartable
|
||||
U | velocity [m/s]
|
||||
\endvartable
|
||||
|
||||
Usage
|
||||
Example of function object specification to calculate Q:
|
||||
\verbatim
|
||||
Q1
|
||||
{
|
||||
type Q;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: Q | yes |
|
||||
U | Name of velocity field | no | U
|
||||
result | Name of Q field | no | <function name>
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
Q.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_Q_H
|
||||
#define functionObjects_Q_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Q Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class Q
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Q field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Q");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
Q
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Q();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
119
src/functionObjects/field/XiReactionRate/XiReactionRate.C
Normal file
119
src/functionObjects/field/XiReactionRate/XiReactionRate.C
Normal file
@ -0,0 +1,119 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "XiReactionRate.H"
|
||||
#include "volFields.H"
|
||||
#include "fvcGrad.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(XiReactionRate, 0);
|
||||
addToRunTimeSelectionTable(functionObject, XiReactionRate, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::XiReactionRate::XiReactionRate
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::XiReactionRate::~XiReactionRate()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::XiReactionRate::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::XiReactionRate::write()
|
||||
{
|
||||
const volScalarField& b =
|
||||
mesh_.lookupObject<volScalarField>("b");
|
||||
|
||||
const volScalarField& Su =
|
||||
mesh_.lookupObject<volScalarField>("Su");
|
||||
|
||||
const volScalarField& Xi =
|
||||
mesh_.lookupObject<volScalarField>("Xi");
|
||||
|
||||
volScalarField St
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"St",
|
||||
time_.timeName(),
|
||||
mesh_
|
||||
),
|
||||
Xi*Su
|
||||
);
|
||||
|
||||
Log << " Writing turbulent flame-speed field " << St.name()
|
||||
<< " to " << time_.timeName() << endl;
|
||||
|
||||
St.write();
|
||||
|
||||
volScalarField wdot
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"wdot",
|
||||
time_.timeName(),
|
||||
mesh_
|
||||
),
|
||||
St*mag(fvc::grad(b))
|
||||
);
|
||||
|
||||
Log << " Writing reaction-rate field " << wdot.name()
|
||||
<< " to " << time_.timeName() << endl;
|
||||
|
||||
wdot.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
127
src/functionObjects/field/XiReactionRate/XiReactionRate.H
Normal file
127
src/functionObjects/field/XiReactionRate/XiReactionRate.H
Normal file
@ -0,0 +1,127 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::XiReactionRate
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Writes the turbulent flame-speed and reaction-rate volScalarFields for the
|
||||
Xi-based combustion models.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
XiReactionRate
|
||||
{
|
||||
type XiReactionRate;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: XiReactionRate | yes |
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
XiReactionRate.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_XiReactionRate_H
|
||||
#define functionObjects_XiReactionRate_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class XiReactionRate Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class XiReactionRate
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
XiReactionRate(const XiReactionRate&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const XiReactionRate&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("XiReactionRate");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
XiReactionRate
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~XiReactionRate();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Do nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the cell-centre fields
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
173
src/functionObjects/field/blendingFactor/blendingFactor.C
Normal file
173
src/functionObjects/field/blendingFactor/blendingFactor.C
Normal file
@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "blendingFactor.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(blendingFactor, 0);
|
||||
addToRunTimeSelectionTable(functionObject, blendingFactor, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::blendingFactor::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "Blending factor");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "Scheme1");
|
||||
writeTabbed(os, "Scheme2");
|
||||
writeTabbed(os, "Blended");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::blendingFactor::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcBF<scalar>();
|
||||
processed = processed || calcBF<vector>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::blendingFactor::blendingFactor
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict),
|
||||
writeFile(obr, name)
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
|
||||
tmp<volScalarField> indicatorPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
resultName_,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
)
|
||||
);
|
||||
|
||||
store(indicatorPtr, resultName_);
|
||||
|
||||
setResultName(typeName, fieldName_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::blendingFactor::~blendingFactor()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::forces::write()
|
||||
{
|
||||
if (fieldExpression::write())
|
||||
{
|
||||
const volScalarField& indictator =
|
||||
lookupObject<volScalarField>(resultName_);
|
||||
|
||||
// Generate scheme statistics
|
||||
label nCellsScheme1 = 0;
|
||||
label nCellsScheme2 = 0;
|
||||
label nCellsBlended = 0;
|
||||
forAll(indicator, celli)
|
||||
{
|
||||
scalar i = indicator[celli];
|
||||
|
||||
if (i < tolerance_)
|
||||
{
|
||||
nCellsScheme1++;
|
||||
}
|
||||
else if (i > (1 - tolerance_))
|
||||
{
|
||||
nCellsScheme2++;
|
||||
}
|
||||
else
|
||||
{
|
||||
nCellsBlended++;
|
||||
}
|
||||
}
|
||||
|
||||
reduce(nCellsScheme1, sumOp<label>());
|
||||
reduce(nCellsScheme2, sumOp<label>());
|
||||
reduce(nCellsBlended, sumOp<label>());
|
||||
|
||||
Log << type() << " " << name_ << " write:" << nl
|
||||
<< " scheme 1 cells : " << nCellsScheme1 << nl
|
||||
<< " scheme 2 cells : " << nCellsScheme2 << nl
|
||||
<< " blended cells : " << nCellsBlended << nl
|
||||
<< endl;
|
||||
|
||||
file()
|
||||
<< mesh_.time().time().value()
|
||||
<< token::TAB << nCellsScheme1
|
||||
<< token::TAB << nCellsScheme2
|
||||
<< token::TAB << nCellsBlended
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
167
src/functionObjects/field/blendingFactor/blendingFactor.H
Normal file
167
src/functionObjects/field/blendingFactor/blendingFactor.H
Normal file
@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::blendingFactor
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates and outputs the blendingFactor as used by the bended convection
|
||||
schemes. The output is a volume field (cells) whose value is calculated via
|
||||
the maximum blending factor for any cell face.
|
||||
|
||||
The weight of a blended scheme is given by a function of the blending
|
||||
factor, f:
|
||||
|
||||
weight = f*scheme1 + (1 - f)*scheme2
|
||||
|
||||
The factor is a face-based quantity, which is converted to a cell-based
|
||||
quantity by assigning the minimum blending factor for any cell face.
|
||||
|
||||
An indicator (volume) field, named <functionObjectName>:<fieldName>, is
|
||||
generated that is set to (1 - f), i.e. values of:
|
||||
- 0 represent scheme1 as active, and
|
||||
- 1 represent scheme2 as active.
|
||||
- intermediate values show the contribution to scheme2
|
||||
|
||||
Additional reporting is written to the standard output, providing
|
||||
statistics as to the number of cells used by each scheme.
|
||||
|
||||
Example of function object specification to calculate the blending factor:
|
||||
\verbatim
|
||||
blendingFactor1
|
||||
{
|
||||
type blendingFactor;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
|
||||
...
|
||||
|
||||
// Name of field
|
||||
fieldName U;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: blendingFactor | yes |
|
||||
phi | Name of flux field | no | phi
|
||||
field | Name of field to evaluate | yes |
|
||||
tolerance | Tolerance for number of blended cells | no | 0.001
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
blendingFactor.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_blendingFactor_H
|
||||
#define functionObjects_blendingFactor_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class blendingFactor Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class blendingFactor
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private member data
|
||||
|
||||
//- Name of flux field, default is "phi"
|
||||
word phiName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the blending factor field
|
||||
template<class Type>
|
||||
bool calcBF();
|
||||
|
||||
//- Calculate the blending factor field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("blendingFactor");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
blendingFactor
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~blendingFactor();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the blendingFactor data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Write the blendingFactor
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "blendingFactorTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "gaussConvectionScheme.H"
|
||||
#include "blendedSchemeBase.H"
|
||||
#include "fvcCellReduce.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::blendingFactor::calcScheme
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const typename fv::convectionScheme<Type>& cs
|
||||
)
|
||||
{
|
||||
if (!isA<fv::gaussConvectionScheme<Type>>(cs))
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Scheme for field " << field.name() << " is not a "
|
||||
<< fv::gaussConvectionScheme<Type>::typeName
|
||||
<< " scheme. Not calculating " << resultName_ << endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const fv::gaussConvectionScheme<Type>& gcs =
|
||||
refCast<const fv::gaussConvectionScheme<Type>>(cs);
|
||||
|
||||
|
||||
const surfaceInterpolationScheme<Type>& interpScheme = gcs.interpScheme();
|
||||
|
||||
if (!isA<blendedSchemeBase<Type>>(interpScheme))
|
||||
{
|
||||
WarningInFunction
|
||||
<< interpScheme.type() << " is not a blended scheme"
|
||||
<< ". Not calculating " << resultName_ << endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the face-based blending factor
|
||||
const blendedSchemeBase<Type>& blendedScheme =
|
||||
refCast<const blendedSchemeBase<Type>>(interpScheme);
|
||||
const surfaceScalarField factorf(blendedScheme.blendingFactor(field));
|
||||
|
||||
// Convert into vol field whose values represent the local face minima
|
||||
// Note: factor applied to 1st scheme, and (1-factor) to 2nd scheme
|
||||
volScalarField& indicator =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
obr_.lookupObject<volScalarField>(resultName_)
|
||||
);
|
||||
indicator = 1 - fvc::cellReduce(factorf, minEqOp<scalar>(), GREAT);
|
||||
indicator.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::blendingFactor::calcBF()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
|
||||
if (!foundObject<FieldType>(fieldName_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FieldType& field = lookupObject<FieldType>(fieldName_);
|
||||
|
||||
const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')');
|
||||
ITstream& its = mesh_.divScheme(divScheme);
|
||||
|
||||
const surfaceScalarField& phi = lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
tmp<fv::convectionScheme<Type>> cs =
|
||||
fv::convectionScheme<Type>::New(mesh_, phi, its);
|
||||
|
||||
if (isA<fv::boundedConvectionScheme<Type>>(cs))
|
||||
{
|
||||
const fv::boundedConvectionScheme<Type>& bcs =
|
||||
refCast<const fv::boundedConvectionScheme<Type>>(cs);
|
||||
|
||||
calcScheme(field, bcs.scheme());
|
||||
}
|
||||
else
|
||||
{
|
||||
const fv::gaussConvectionScheme<Type>& gcs =
|
||||
refCast<const fv::gaussConvectionScheme<Type>>(cs);
|
||||
|
||||
calcScheme(field, gcs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
105
src/functionObjects/field/components/components.C
Normal file
105
src/functionObjects/field/components/components.C
Normal file
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "components.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(components, 0);
|
||||
addToRunTimeSelectionTable(functionObject, components, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::components::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcComponents<vector>();
|
||||
processed = processed || calcComponents<sphericalTensor>();
|
||||
processed = processed || calcComponents<symmTensor>();
|
||||
processed = processed || calcComponents<tensor>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::components::components
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::components::~components()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::components::write()
|
||||
{
|
||||
bool written = true;
|
||||
|
||||
forAll(resultNames_, i)
|
||||
{
|
||||
written = written && writeObject(resultNames_[i]);
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::components::clear()
|
||||
{
|
||||
bool cleared = true;
|
||||
|
||||
forAll(resultNames_, i)
|
||||
{
|
||||
cleared = cleared && clearObject(resultNames_[i]);
|
||||
}
|
||||
|
||||
return cleared;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
132
src/functionObjects/field/components/components.H
Normal file
132
src/functionObjects/field/components/components.H
Normal file
@ -0,0 +1,132 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::components
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the components of a field.
|
||||
|
||||
The operation can be applied to any volume or surface fields generating a
|
||||
volume or surface scalar fields for each component.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
components.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_components_H
|
||||
#define functionObjects_components_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class components Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class components
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private member data
|
||||
|
||||
//- List of the component field names
|
||||
wordList resultNames_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the components of the field with the specified type
|
||||
// and register the result
|
||||
template<class GeoFieldType>
|
||||
bool calcFieldComponents();
|
||||
|
||||
//- Calculate the components of the field with the specified
|
||||
// element type and register the result
|
||||
template<class Type>
|
||||
bool calcComponents();
|
||||
|
||||
//- Calculate the components of the field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("components");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
components
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~components();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Write the component fields
|
||||
virtual bool write();
|
||||
|
||||
//- Clear the component fields from the objectRegistry
|
||||
virtual bool clear();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "componentsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
75
src/functionObjects/field/components/componentsTemplates.C
Normal file
75
src/functionObjects/field/components/componentsTemplates.C
Normal file
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class GeoFieldType>
|
||||
bool Foam::functionObjects::components::calcFieldComponents()
|
||||
{
|
||||
typedef typename GeoFieldType::value_type Type;
|
||||
|
||||
const GeoFieldType& field(lookupObject<GeoFieldType>(fieldName_));
|
||||
|
||||
resultNames_.setSize(Type::nComponents);
|
||||
|
||||
bool stored = true;
|
||||
|
||||
for (direction i=0; i<Type::nComponents; i++)
|
||||
{
|
||||
resultName_ = fieldName_ + word(Type::componentNames[i]);
|
||||
resultNames_[i] = resultName_;
|
||||
|
||||
stored = stored && store(resultName_, field.component(i));
|
||||
}
|
||||
|
||||
return stored;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::components::calcComponents()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
return calcFieldComponents<VolFieldType>();
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
{
|
||||
return calcFieldComponents<SurfaceFieldType>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
75
src/functionObjects/field/div/div.C
Normal file
75
src/functionObjects/field/div/div.C
Normal file
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "div.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(div, 0);
|
||||
addToRunTimeSelectionTable(functionObject, div, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::div::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcDiv<surfaceScalarField>();
|
||||
processed = processed || calcDiv<volVectorField>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::div::div
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::div::~div()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
111
src/functionObjects/field/div/div.H
Normal file
111
src/functionObjects/field/div/div.H
Normal file
@ -0,0 +1,111 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::div
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the divergence of a field. The operation is limited to
|
||||
surfaceScalarFields and volVectorFields, and the output is a volScalarField.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
div.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_div_H
|
||||
#define functionObjects_div_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class div Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class div
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the divergence of either a
|
||||
// volScalarField or a surfaceScalarField and register the result
|
||||
template<class FieldType>
|
||||
bool calcDiv();
|
||||
|
||||
//- Calculate the divergence field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("div");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
div
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~div();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "divTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
48
src/functionObjects/field/div/divTemplates.C
Normal file
48
src/functionObjects/field/div/divTemplates.C
Normal file
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvcDiv.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class FieldType>
|
||||
bool Foam::functionObjects::div::calcDiv()
|
||||
{
|
||||
if (foundObject<FieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::div(lookupObject<FieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
33
src/functionObjects/field/doc/fieldFunctionObjectsDoc.H
Normal file
33
src/functionObjects/field/doc/fieldFunctionObjectsDoc.H
Normal file
@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\defgroup grpFieldFunctionObjects Field function objects
|
||||
@{
|
||||
\ingroup grpFunctionObjects
|
||||
This group contains field-based function objects
|
||||
|
||||
Function objects in this group are packaged into the
|
||||
libfieldFunctionObjects.so library.
|
||||
@}
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
90
src/functionObjects/field/enstrophy/enstrophy.C
Normal file
90
src/functionObjects/field/enstrophy/enstrophy.C
Normal file
@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "enstrophy.H"
|
||||
#include "fvcCurl.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(enstrophy, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
enstrophy,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::enstrophy::calc()
|
||||
{
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
0.5*magSqr(fvc::curl(lookupObject<volVectorField>(fieldName_)))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::enstrophy::enstrophy
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::enstrophy::~enstrophy()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
99
src/functionObjects/field/enstrophy/enstrophy.H
Normal file
99
src/functionObjects/field/enstrophy/enstrophy.H
Normal file
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::enstrophy
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the enstrophy of the velocity.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
enstrophy.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_enstrophy_H
|
||||
#define functionObjects_enstrophy_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class enstrophy Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class enstrophy
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the enstrophy field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("enstrophy");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
enstrophy
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~enstrophy();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
331
src/functionObjects/field/fieldAverage/fieldAverage.C
Normal file
331
src/functionObjects/field/fieldAverage/fieldAverage.C
Normal file
@ -0,0 +1,331 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldAverage.H"
|
||||
#include "volFields.H"
|
||||
#include "fieldAverageItem.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(fieldAverage, 0);
|
||||
addToRunTimeSelectionTable(functionObject, fieldAverage, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldAverage::resetFields()
|
||||
{
|
||||
forAll(faItems_, i)
|
||||
{
|
||||
if (faItems_[i].mean())
|
||||
{
|
||||
if (obr_.found(faItems_[i].meanFieldName()))
|
||||
{
|
||||
obr_.checkOut(*obr_[faItems_[i].meanFieldName()]);
|
||||
}
|
||||
}
|
||||
|
||||
if (faItems_[i].prime2Mean())
|
||||
{
|
||||
if (obr_.found(faItems_[i].prime2MeanFieldName()))
|
||||
{
|
||||
obr_.checkOut(*obr_[faItems_[i].prime2MeanFieldName()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldAverage::initialize()
|
||||
{
|
||||
resetFields();
|
||||
|
||||
Log << type() << " " << name_ << ":" << nl;
|
||||
|
||||
// Add mean fields to the field lists
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
addMeanField<scalar>(fieldi);
|
||||
addMeanField<vector>(fieldi);
|
||||
addMeanField<sphericalTensor>(fieldi);
|
||||
addMeanField<symmTensor>(fieldi);
|
||||
addMeanField<tensor>(fieldi);
|
||||
}
|
||||
|
||||
// Add prime-squared mean fields to the field lists
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
addPrime2MeanField<scalar, scalar>(fieldi);
|
||||
addPrime2MeanField<vector, symmTensor>(fieldi);
|
||||
}
|
||||
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
if (!faItems_[fieldi].active())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Field " << faItems_[fieldi].fieldName()
|
||||
<< " not found in database for averaging";
|
||||
}
|
||||
}
|
||||
|
||||
// ensure first averaging works unconditionally
|
||||
prevTimeIndex_ = -1;
|
||||
|
||||
Log << endl;
|
||||
initialised_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldAverage::restart()
|
||||
{
|
||||
Log
|
||||
<< " Restarting averaging at time " << obr_.time().timeName()
|
||||
<< nl << endl;
|
||||
|
||||
totalIter_.clear();
|
||||
totalIter_.setSize(faItems_.size(), 1);
|
||||
|
||||
totalTime_.clear();
|
||||
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldAverage::calcAverages()
|
||||
{
|
||||
if (!initialised_)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
const label currentTimeIndex = obr_.time().timeIndex();
|
||||
const scalar currentTime = obr_.time().value();
|
||||
|
||||
if (prevTimeIndex_ == currentTimeIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevTimeIndex_ = currentTimeIndex;
|
||||
}
|
||||
|
||||
if (periodicRestart_ && currentTime > restartPeriod_*periodIndex_)
|
||||
{
|
||||
restart();
|
||||
periodIndex_++;
|
||||
}
|
||||
|
||||
Log
|
||||
<< type() << " " << name() << " write:" << nl
|
||||
<< " Calculating averages" << nl;
|
||||
|
||||
addMeanSqrToPrime2Mean<scalar, scalar>();
|
||||
addMeanSqrToPrime2Mean<vector, symmTensor>();
|
||||
|
||||
calculateMeanFields<scalar>();
|
||||
calculateMeanFields<vector>();
|
||||
calculateMeanFields<sphericalTensor>();
|
||||
calculateMeanFields<symmTensor>();
|
||||
calculateMeanFields<tensor>();
|
||||
|
||||
calculatePrime2MeanFields<scalar, scalar>();
|
||||
calculatePrime2MeanFields<vector, symmTensor>();
|
||||
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
totalIter_[fieldi]++;
|
||||
totalTime_[fieldi] += obr_.time().deltaTValue();
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldAverage::writeAverages() const
|
||||
{
|
||||
Log << " Writing average fields" << endl;
|
||||
|
||||
writeFields<scalar>();
|
||||
writeFields<vector>();
|
||||
writeFields<sphericalTensor>();
|
||||
writeFields<symmTensor>();
|
||||
writeFields<tensor>();
|
||||
|
||||
Log << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::writeAveragingProperties()
|
||||
{
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
|
||||
dictionary propsDict;
|
||||
propsDict.add("totalIter", totalIter_[fieldi]);
|
||||
propsDict.add("totalTime", totalTime_[fieldi]);
|
||||
setProperty(fieldName, propsDict);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
{
|
||||
totalIter_.clear();
|
||||
totalIter_.setSize(faItems_.size(), 1);
|
||||
|
||||
totalTime_.clear();
|
||||
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
|
||||
|
||||
if ((restartOnRestart_ || restartOnOutput_) && log)
|
||||
{
|
||||
Info<< " Starting averaging at time " << obr_.time().timeName()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log << " Restarting averaging for fields:" << nl;
|
||||
|
||||
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
if (foundProperty(fieldName))
|
||||
{
|
||||
dictionary fieldDict;
|
||||
getProperty(fieldName, fieldDict);
|
||||
|
||||
totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
|
||||
|
||||
Log
|
||||
<< " " << fieldName
|
||||
<< " iters = " << totalIter_[fieldi]
|
||||
<< " time = " << totalTime_[fieldi] << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log
|
||||
<< " " << fieldName
|
||||
<< ": starting averaging at time "
|
||||
<< obr_.time().timeName() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldAverage::fieldAverage
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
prevTimeIndex_(-1),
|
||||
restartOnRestart_(false),
|
||||
restartOnOutput_(false),
|
||||
periodicRestart_(false),
|
||||
restartPeriod_(GREAT),
|
||||
initialised_(false),
|
||||
faItems_(),
|
||||
totalIter_(),
|
||||
totalTime_(),
|
||||
periodIndex_(1)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldAverage::~fieldAverage()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
initialised_ = false;
|
||||
|
||||
Log << type() << " " << name() << ":" << nl;
|
||||
|
||||
dict.readIfPresent("restartOnRestart", restartOnRestart_);
|
||||
dict.readIfPresent("restartOnOutput", restartOnOutput_);
|
||||
dict.readIfPresent("periodicRestart", periodicRestart_);
|
||||
dict.lookup("fields") >> faItems_;
|
||||
|
||||
if (periodicRestart_)
|
||||
{
|
||||
dict.lookup("restartPeriod") >> restartPeriod_;
|
||||
}
|
||||
|
||||
readAveragingProperties();
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldAverage::execute()
|
||||
{
|
||||
calcAverages();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldAverage::write()
|
||||
{
|
||||
writeAverages();
|
||||
writeAveragingProperties();
|
||||
|
||||
if (restartOnOutput_)
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
326
src/functionObjects/field/fieldAverage/fieldAverage.H
Normal file
326
src/functionObjects/field/fieldAverage/fieldAverage.H
Normal file
@ -0,0 +1,326 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldAverage
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates average quantities for a user-specified selection of volumetric
|
||||
and surface fields.
|
||||
|
||||
Fields are entered as a list of sub-dictionaries, which indicate the type of
|
||||
averages to perform, and can be updated during the calculation. The current
|
||||
options include:
|
||||
- \c mean: arithmetic mean:
|
||||
\f[
|
||||
\overline{x} = \frac{1}{N}\displaystyle\sum\limits_{i=0}^N x_i
|
||||
\f]
|
||||
- \c prime2Mean: prime-squared mean
|
||||
\f[
|
||||
\overline{x'}^2 = \frac{1}{N}\displaystyle\sum\limits_{i=0}^N
|
||||
(x_i - \overline{x})^2
|
||||
\f]
|
||||
- base: average over 'time', or 'iteration' (\f$N\f$ in the above)
|
||||
- window: optional averaging window, specified in 'base' units
|
||||
|
||||
Average field names are constructed by concatenating the base field with
|
||||
the averaging type, e.g. when averaging field 'U', the resultant fields
|
||||
are:
|
||||
- arithmetic mean field, UMean
|
||||
- prime-squared field, UPrime2Mean
|
||||
|
||||
Information regarding the number of averaging steps, and total averaging
|
||||
time are written on a per-field basis to the
|
||||
\c "<functionObject name>Properties" dictionary, located in \<time\>/uniform
|
||||
|
||||
When restarting form a previous calculation, the averaging is continuous or
|
||||
may be restarted using the \c restartOnRestart option.
|
||||
|
||||
The averaging process may be restarted after each calculation output time
|
||||
using the \c restartOnOutput option or restarted periodically using the \c
|
||||
periodicRestart option and setting \c restartPeriod to the required
|
||||
averaging period.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
fieldAverage1
|
||||
{
|
||||
type fieldAverage;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
writeControl writeTime;
|
||||
|
||||
restartOnRestart false;
|
||||
restartOnOutput false;
|
||||
periodicRestart false;
|
||||
restartPeriod 0.002;
|
||||
|
||||
fields
|
||||
(
|
||||
U
|
||||
{
|
||||
mean on;
|
||||
prime2Mean on;
|
||||
base time;
|
||||
window 10.0;
|
||||
windowName w1;
|
||||
}
|
||||
p
|
||||
{
|
||||
mean on;
|
||||
prime2Mean on;
|
||||
base time;
|
||||
}
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldAverage | yes |
|
||||
restartOnRestart| Restart the averaging on restart | no | no
|
||||
restartOnOutput | Restart the averaging on output | no | no
|
||||
periodicRestart | Periodically restart the averaging | no | no
|
||||
restartPeriod | Periodic restart period | conditional |
|
||||
fields | list of fields and averaging options | yes |
|
||||
\endtable
|
||||
|
||||
|
||||
Note
|
||||
To employ the \c prime2Mean option, the \c mean option must be selecetd.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObject
|
||||
|
||||
SourceFiles
|
||||
fieldAverage.C
|
||||
fieldAverageTemplates.C
|
||||
fieldAverageItem.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldAverage_H
|
||||
#define functionObjects_fieldAverage_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class fieldAverageItem;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldAverage Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldAverage
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Time at last call, prevents repeated averaging
|
||||
label prevTimeIndex_;
|
||||
|
||||
//- Restart the averaging process on restart
|
||||
Switch restartOnRestart_;
|
||||
|
||||
//- Restart the averaging process on output
|
||||
Switch restartOnOutput_;
|
||||
|
||||
//- Periodically restart the averaging process
|
||||
Switch periodicRestart_;
|
||||
|
||||
//- Restart period
|
||||
scalar restartPeriod_;
|
||||
|
||||
//- Initialised flag
|
||||
bool initialised_;
|
||||
|
||||
//- List of field average items, describing what averages to be
|
||||
// calculated and output
|
||||
List<fieldAverageItem> faItems_;
|
||||
|
||||
// Counters
|
||||
|
||||
//- Iteration steps counter
|
||||
List<label> totalIter_;
|
||||
|
||||
//- Total time counter
|
||||
List<scalar> totalTime_;
|
||||
|
||||
//- Index for periodic restart
|
||||
label periodIndex_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
// Initialisation routines
|
||||
|
||||
//- Checkout fields (causes deletion) from the database
|
||||
// and reset lists
|
||||
void resetFields();
|
||||
|
||||
//- Reset lists (clear existing values) and initialize averaging.
|
||||
// Check requested field averages are valid, populate field lists
|
||||
void initialize();
|
||||
|
||||
//- Restart averaging for restartOnOutput
|
||||
void restart();
|
||||
|
||||
//- Add mean average field to database
|
||||
template<class Type>
|
||||
void addMeanFieldType(const label fieldi);
|
||||
|
||||
//- Add mean average field to database
|
||||
template<class Type>
|
||||
void addMeanField(const label fieldi);
|
||||
|
||||
//- Add prime-squared average field to database
|
||||
template<class Type1, class Type2>
|
||||
void addPrime2MeanFieldType(const label fieldi);
|
||||
|
||||
//- Add prime-squared average field to database
|
||||
template<class Type1, class Type2>
|
||||
void addPrime2MeanField(const label fieldi);
|
||||
|
||||
|
||||
// Calculation functions
|
||||
|
||||
//- Main calculation routine
|
||||
virtual void calcAverages();
|
||||
|
||||
//- Calculate mean average fields
|
||||
template<class Type>
|
||||
void calculateMeanFieldType(const label fieldi) const;
|
||||
|
||||
//- Calculate mean average fields
|
||||
template<class Type>
|
||||
void calculateMeanFields() const;
|
||||
|
||||
//- Calculate prime-squared average fields
|
||||
template<class Type1, class Type2>
|
||||
void calculatePrime2MeanFieldType(const label fieldi) const;
|
||||
|
||||
//- Calculate prime-squared average fields
|
||||
template<class Type1, class Type2>
|
||||
void calculatePrime2MeanFields() const;
|
||||
|
||||
//- Add mean-squared field value to prime-squared mean field
|
||||
template<class Type1, class Type2>
|
||||
void addMeanSqrToPrime2MeanType(const label fieldi) const;
|
||||
|
||||
//- Add mean-squared field value to prime-squared mean field
|
||||
template<class Type1, class Type2>
|
||||
void addMeanSqrToPrime2Mean() const;
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write averages
|
||||
virtual void writeAverages() const;
|
||||
|
||||
//- Write fields
|
||||
template<class Type>
|
||||
void writeFieldType(const word& fieldName) const;
|
||||
|
||||
//- Write fields
|
||||
template<class Type>
|
||||
void writeFields() const;
|
||||
|
||||
//- Write averaging properties - steps and time
|
||||
void writeAveragingProperties();
|
||||
|
||||
//- Read averaging properties - steps and time
|
||||
void readAveragingProperties();
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldAverage(const fieldAverage&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldAverage&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fieldAverage");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldAverage
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldAverage();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field average data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the field averages
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the field averages
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldAverageTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldAverageItem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word Foam::functionObjects::fieldAverageItem::EXT_MEAN
|
||||
(
|
||||
"Mean"
|
||||
);
|
||||
|
||||
const Foam::word Foam::functionObjects::fieldAverageItem::EXT_PRIME2MEAN
|
||||
(
|
||||
"Prime2Mean"
|
||||
);
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldAverageItem::baseType,
|
||||
2
|
||||
>::names[] = { "iteration", "time"};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldAverageItem::baseType,
|
||||
2
|
||||
> Foam::functionObjects::fieldAverageItem::baseTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldAverageItem::fieldAverageItem()
|
||||
:
|
||||
fieldName_("unknown"),
|
||||
mean_(0),
|
||||
meanFieldName_("unknown"),
|
||||
prime2Mean_(0),
|
||||
prime2MeanFieldName_("unknown"),
|
||||
base_(ITER),
|
||||
window_(-1.0),
|
||||
windowName_("")
|
||||
{}
|
||||
|
||||
|
||||
Foam::functionObjects::fieldAverageItem::fieldAverageItem
|
||||
(
|
||||
const fieldAverageItem& faItem
|
||||
)
|
||||
:
|
||||
fieldName_(faItem.fieldName_),
|
||||
mean_(faItem.mean_),
|
||||
meanFieldName_(faItem.meanFieldName_),
|
||||
prime2Mean_(faItem.prime2Mean_),
|
||||
prime2MeanFieldName_(faItem.prime2MeanFieldName_),
|
||||
base_(faItem.base_),
|
||||
window_(faItem.window_),
|
||||
windowName_(faItem.windowName_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldAverageItem::~fieldAverageItem()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldAverageItem::operator=
|
||||
(
|
||||
const fieldAverageItem& rhs
|
||||
)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &rhs)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted assignment to self" << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Set updated values
|
||||
fieldName_ = rhs.fieldName_;
|
||||
mean_ = rhs.mean_;
|
||||
meanFieldName_ = rhs.meanFieldName_;
|
||||
prime2Mean_ = rhs.prime2Mean_;
|
||||
prime2MeanFieldName_ = rhs.prime2MeanFieldName_;
|
||||
base_ = rhs.base_;
|
||||
window_ = rhs.window_;
|
||||
windowName_ = rhs.windowName_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,274 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldAverageItem
|
||||
|
||||
Description
|
||||
Helper class to describe what form of averaging to apply. A set will be
|
||||
applied to each base field in Foam::fieldAverage, of the form:
|
||||
|
||||
\verbatim
|
||||
{
|
||||
mean on;
|
||||
prime2Mean on;
|
||||
base time; // iteration
|
||||
window 200; // optional averaging window
|
||||
windowName w1; // optional window name (default = "")
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
The averaging window corresponds to the averaging interval (iters or time)
|
||||
If not specified, the averaging is over 'all iters/time'
|
||||
|
||||
SourceFiles
|
||||
fieldAverageItem.C
|
||||
fieldAverageItemIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fieldAverageItem_H
|
||||
#define fieldAverageItem_H
|
||||
|
||||
#include "NamedEnum.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
class fieldAverageItem;
|
||||
Istream& operator>>(Istream&, fieldAverageItem&);
|
||||
Ostream& operator<<(Ostream&, const fieldAverageItem&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldAverageItem Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldAverageItem
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data
|
||||
|
||||
// File and field name extensions
|
||||
|
||||
//- Mean average
|
||||
static const word EXT_MEAN;
|
||||
|
||||
//- Prime-squared average
|
||||
static const word EXT_PRIME2MEAN;
|
||||
|
||||
//- Enumeration defining the averaging base type
|
||||
enum baseType
|
||||
{
|
||||
ITER,
|
||||
TIME
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Field name
|
||||
word fieldName_;
|
||||
|
||||
//- Compute mean flag
|
||||
Switch mean_;
|
||||
|
||||
//- Name of mean field
|
||||
word meanFieldName_;
|
||||
|
||||
//- Compute prime-squared mean flag
|
||||
Switch prime2Mean_;
|
||||
|
||||
//- Name of prime-squared mean field
|
||||
word prime2MeanFieldName_;
|
||||
|
||||
//- Averaging base type names
|
||||
static const NamedEnum<baseType, 2> baseTypeNames_;
|
||||
|
||||
//- Averaging base type
|
||||
baseType base_;
|
||||
|
||||
//- Averaging window - defaults to -1 for 'all iters/time'
|
||||
scalar window_;
|
||||
|
||||
//- Averaging window name - defaults to 'window'
|
||||
word windowName_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
fieldAverageItem();
|
||||
|
||||
//- Construct from Istream
|
||||
fieldAverageItem(Istream&);
|
||||
|
||||
//- Construct as copy
|
||||
fieldAverageItem(const fieldAverageItem&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~fieldAverageItem();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to the field name
|
||||
const word& fieldName() const
|
||||
{
|
||||
return fieldName_;
|
||||
}
|
||||
|
||||
//- Return const access to the mean flag
|
||||
const Switch& mean() const
|
||||
{
|
||||
return mean_;
|
||||
}
|
||||
|
||||
//- Return non-const access to the mean flag
|
||||
Switch& mean()
|
||||
{
|
||||
return mean_;
|
||||
}
|
||||
|
||||
//- Return const access to the mean field name
|
||||
const word& meanFieldName() const
|
||||
{
|
||||
return meanFieldName_;
|
||||
}
|
||||
|
||||
//- Return const access to the prime-squared mean flag
|
||||
const Switch& prime2Mean() const
|
||||
{
|
||||
return prime2Mean_;
|
||||
}
|
||||
|
||||
//- Return non-const access to the prime-squared mean flag
|
||||
Switch& prime2Mean()
|
||||
{
|
||||
return prime2Mean_;
|
||||
}
|
||||
|
||||
//- Return const access to the prime-squared mean field name
|
||||
const word& prime2MeanFieldName() const
|
||||
{
|
||||
return prime2MeanFieldName_;
|
||||
}
|
||||
|
||||
//- Return averaging base type name
|
||||
const word base() const
|
||||
{
|
||||
return baseTypeNames_[base_];
|
||||
}
|
||||
|
||||
//- Return true if base is ITER
|
||||
Switch iterBase() const
|
||||
{
|
||||
return base_ == ITER;
|
||||
}
|
||||
|
||||
//- Return true if base is time
|
||||
Switch timeBase() const
|
||||
{
|
||||
return base_ == TIME;
|
||||
}
|
||||
|
||||
scalar window() const
|
||||
{
|
||||
return window_;
|
||||
}
|
||||
|
||||
const word& windowName() const
|
||||
{
|
||||
return windowName_;
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const fieldAverageItem&);
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
friend bool operator==
|
||||
(
|
||||
const fieldAverageItem& a,
|
||||
const fieldAverageItem& b
|
||||
)
|
||||
{
|
||||
return
|
||||
a.fieldName_ == b.fieldName_
|
||||
&& a.mean_ == b.mean_
|
||||
&& a.meanFieldName_ == b.meanFieldName_
|
||||
&& a.prime2Mean_ == b.prime2Mean_
|
||||
&& a.prime2MeanFieldName_ == b.prime2MeanFieldName_
|
||||
&& a.base_ == b.base_
|
||||
&& a.window_ == b.window_
|
||||
&& a.windowName_ == b.windowName_;
|
||||
}
|
||||
|
||||
friend bool operator!=
|
||||
(
|
||||
const fieldAverageItem& a,
|
||||
const fieldAverageItem& b
|
||||
)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream&, fieldAverageItem&);
|
||||
friend Ostream& operator<<(Ostream&, const fieldAverageItem&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,149 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldAverageItem.H"
|
||||
#include "IOstreams.H"
|
||||
#include "dictionaryEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is)
|
||||
:
|
||||
fieldName_("unknown"),
|
||||
mean_(0),
|
||||
meanFieldName_("unknown"),
|
||||
prime2Mean_(0),
|
||||
prime2MeanFieldName_("unknown"),
|
||||
base_(ITER),
|
||||
window_(-1.0)
|
||||
{
|
||||
is.check
|
||||
(
|
||||
"Foam::functionObjects::fieldAverageItem::fieldAverageItem"
|
||||
"(Foam::Istream&)"
|
||||
);
|
||||
|
||||
const dictionaryEntry entry(dictionary::null, is);
|
||||
|
||||
fieldName_ = entry.keyword();
|
||||
entry.lookup("mean") >> mean_;
|
||||
entry.lookup("prime2Mean") >> prime2Mean_;
|
||||
base_ = baseTypeNames_[entry.lookup("base")];
|
||||
window_ = entry.lookupOrDefault<scalar>("window", -1.0);
|
||||
windowName_ = entry.lookupOrDefault<word>("windowName", "");
|
||||
|
||||
meanFieldName_ = fieldName_ + EXT_MEAN;
|
||||
prime2MeanFieldName_ = fieldName_ + EXT_PRIME2MEAN;
|
||||
if ((window_ > 0) && (windowName_ != ""))
|
||||
{
|
||||
meanFieldName_ = meanFieldName_ + "_" + windowName_;
|
||||
prime2MeanFieldName_ = prime2MeanFieldName_ + "_" + windowName_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::functionObjects::operator>>
|
||||
(
|
||||
Istream& is,
|
||||
fieldAverageItem& faItem
|
||||
)
|
||||
{
|
||||
is.check
|
||||
(
|
||||
"Foam::Istream& Foam::operator>>"
|
||||
"(Foam::Istream&, Foam::functionObjects::fieldAverageItem&)"
|
||||
);
|
||||
|
||||
const dictionaryEntry entry(dictionary::null, is);
|
||||
|
||||
faItem.fieldName_ = entry.keyword();
|
||||
entry.lookup("mean") >> faItem.mean_;
|
||||
entry.lookup("prime2Mean") >> faItem.prime2Mean_;
|
||||
faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")];
|
||||
faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0);
|
||||
faItem.windowName_ = entry.lookupOrDefault<word>("windowName", "");
|
||||
|
||||
faItem.meanFieldName_ = faItem.fieldName_ + fieldAverageItem::EXT_MEAN;
|
||||
faItem.prime2MeanFieldName_ =
|
||||
faItem.fieldName_ + fieldAverageItem::EXT_PRIME2MEAN;
|
||||
|
||||
if ((faItem.window_ > 0) && (faItem.windowName_ != ""))
|
||||
{
|
||||
faItem.meanFieldName_ =
|
||||
faItem.meanFieldName_ + "_" + faItem.windowName_;
|
||||
|
||||
faItem.prime2MeanFieldName_ =
|
||||
faItem.prime2MeanFieldName_ + "_" + faItem.windowName_;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::functionObjects::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const fieldAverageItem& faItem
|
||||
)
|
||||
{
|
||||
os.check
|
||||
(
|
||||
"Foam::Ostream& Foam::operator<<"
|
||||
"(Foam::Ostream&, const Foam::functionObjects::fieldAverageItem&)"
|
||||
);
|
||||
|
||||
os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl;
|
||||
os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("prime2Mean") << faItem.prime2Mean_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_]
|
||||
<< token::END_STATEMENT << nl;
|
||||
|
||||
if (faItem.window_ > 0)
|
||||
{
|
||||
os.writeKeyword("window") << faItem.window_
|
||||
<< token::END_STATEMENT << nl;
|
||||
|
||||
if (faItem.windowName_ != "")
|
||||
{
|
||||
os.writeKeyword("windowName") << faItem.windowName_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
}
|
||||
|
||||
os << token::END_BLOCK << nl;
|
||||
|
||||
os.check
|
||||
(
|
||||
"Foam::Ostream& Foam::operator<<"
|
||||
"(Foam::Ostream&, const Foam::functionObjects::fieldAverageItem&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
411
src/functionObjects/field/fieldAverage/fieldAverageTemplates.C
Normal file
411
src/functionObjects/field/fieldAverage/fieldAverageTemplates.C
Normal file
@ -0,0 +1,411 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldAverageItem.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
const word& meanFieldName = faItems_[fieldi].meanFieldName();
|
||||
|
||||
Log << " Reading/initialising field " << meanFieldName << endl;
|
||||
|
||||
if (obr_.foundObject<Type>(meanFieldName))
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else if (obr_.found(meanFieldName))
|
||||
{
|
||||
Log << " Cannot allocate average field " << meanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << endl;
|
||||
|
||||
faItems_[fieldi].mean() = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Type& baseField = obr_.lookupObject<Type>(fieldName);
|
||||
|
||||
// Store on registry
|
||||
obr_.store
|
||||
(
|
||||
new Type
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
meanFieldName,
|
||||
obr_.time().timeName(obr_.time().startTime().value()),
|
||||
obr_,
|
||||
restartOnOutput_
|
||||
? IOobject::NO_READ
|
||||
: IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
1*baseField
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldAverage::addMeanField(const label fieldi)
|
||||
{
|
||||
if (faItems_[fieldi].mean())
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh>
|
||||
VolFieldType;
|
||||
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh>
|
||||
SurfaceFieldType;
|
||||
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
|
||||
if (obr_.foundObject<VolFieldType>(fieldName))
|
||||
{
|
||||
addMeanFieldType<VolFieldType>(fieldi);
|
||||
}
|
||||
else if (obr_.foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
addMeanFieldType<SurfaceFieldType>(fieldi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type1, class Type2>
|
||||
void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
|
||||
(
|
||||
const label fieldi
|
||||
)
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
const word& meanFieldName = faItems_[fieldi].meanFieldName();
|
||||
const word& prime2MeanFieldName = faItems_[fieldi].prime2MeanFieldName();
|
||||
|
||||
Log << " Reading/initialising field " << prime2MeanFieldName << nl;
|
||||
|
||||
if (obr_.foundObject<Type2>(prime2MeanFieldName))
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else if (obr_.found(prime2MeanFieldName))
|
||||
{
|
||||
Log << " Cannot allocate average field " << prime2MeanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << endl;
|
||||
|
||||
faItems_[fieldi].prime2Mean() = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Type1& baseField = obr_.lookupObject<Type1>(fieldName);
|
||||
const Type1& meanField = obr_.lookupObject<Type1>(meanFieldName);
|
||||
|
||||
// Store on registry
|
||||
obr_.store
|
||||
(
|
||||
new Type2
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
prime2MeanFieldName,
|
||||
obr_.time().timeName(obr_.time().startTime().value()),
|
||||
obr_,
|
||||
restartOnOutput_
|
||||
? IOobject::NO_READ
|
||||
: IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
sqr(baseField) - sqr(meanField)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type1, class Type2>
|
||||
void Foam::functionObjects::fieldAverage::addPrime2MeanField(const label fieldi)
|
||||
{
|
||||
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
||||
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
||||
|
||||
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
||||
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
||||
|
||||
if (faItems_[fieldi].prime2Mean())
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
|
||||
if (!faItems_[fieldi].mean())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "To calculate the prime-squared average, the "
|
||||
<< "mean average must also be selected for field "
|
||||
<< fieldName << nl << exit(FatalError);
|
||||
}
|
||||
|
||||
if (obr_.foundObject<VolFieldType1>(fieldName))
|
||||
{
|
||||
addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(fieldi);
|
||||
}
|
||||
else if (obr_.foundObject<SurfaceFieldType1>(fieldName))
|
||||
{
|
||||
addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>
|
||||
(
|
||||
fieldi
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldAverage::calculateMeanFieldType
|
||||
(
|
||||
const label fieldi
|
||||
) const
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
|
||||
if (obr_.foundObject<Type>(fieldName))
|
||||
{
|
||||
const Type& baseField = obr_.lookupObject<Type>(fieldName);
|
||||
|
||||
Type& meanField = const_cast<Type&>
|
||||
(
|
||||
obr_.lookupObject<Type>(faItems_[fieldi].meanFieldName())
|
||||
);
|
||||
|
||||
scalar dt = obr_.time().deltaTValue();
|
||||
scalar Dt = totalTime_[fieldi];
|
||||
|
||||
if (faItems_[fieldi].iterBase())
|
||||
{
|
||||
dt = 1.0;
|
||||
Dt = scalar(totalIter_[fieldi]);
|
||||
}
|
||||
|
||||
scalar alpha = (Dt - dt)/Dt;
|
||||
scalar beta = dt/Dt;
|
||||
|
||||
if (faItems_[fieldi].window() > 0)
|
||||
{
|
||||
const scalar w = faItems_[fieldi].window();
|
||||
|
||||
if (Dt - dt >= w)
|
||||
{
|
||||
alpha = (w - dt)/w;
|
||||
beta = dt/w;
|
||||
}
|
||||
}
|
||||
|
||||
meanField = alpha*meanField + beta*baseField;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldAverage::calculateMeanFields() const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
forAll(faItems_, i)
|
||||
{
|
||||
if (faItems_[i].mean())
|
||||
{
|
||||
calculateMeanFieldType<VolFieldType>(i);
|
||||
calculateMeanFieldType<SurfaceFieldType>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type1, class Type2>
|
||||
void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType
|
||||
(
|
||||
const label fieldi
|
||||
) const
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
|
||||
if (obr_.foundObject<Type1>(fieldName))
|
||||
{
|
||||
const Type1& baseField = obr_.lookupObject<Type1>(fieldName);
|
||||
const Type1& meanField =
|
||||
obr_.lookupObject<Type1>(faItems_[fieldi].meanFieldName());
|
||||
|
||||
Type2& prime2MeanField = const_cast<Type2&>
|
||||
(
|
||||
obr_.lookupObject<Type2>(faItems_[fieldi].prime2MeanFieldName())
|
||||
);
|
||||
|
||||
scalar dt = obr_.time().deltaTValue();
|
||||
scalar Dt = totalTime_[fieldi];
|
||||
|
||||
if (faItems_[fieldi].iterBase())
|
||||
{
|
||||
dt = 1.0;
|
||||
Dt = scalar(totalIter_[fieldi]);
|
||||
}
|
||||
|
||||
scalar alpha = (Dt - dt)/Dt;
|
||||
scalar beta = dt/Dt;
|
||||
|
||||
if (faItems_[fieldi].window() > 0)
|
||||
{
|
||||
const scalar w = faItems_[fieldi].window();
|
||||
|
||||
if (Dt - dt >= w)
|
||||
{
|
||||
alpha = (w - dt)/w;
|
||||
beta = dt/w;
|
||||
}
|
||||
}
|
||||
|
||||
prime2MeanField =
|
||||
alpha*prime2MeanField
|
||||
+ beta*sqr(baseField)
|
||||
- sqr(meanField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type1, class Type2>
|
||||
void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const
|
||||
{
|
||||
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
||||
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
||||
|
||||
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
||||
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
||||
|
||||
forAll(faItems_, i)
|
||||
{
|
||||
if (faItems_[i].prime2Mean())
|
||||
{
|
||||
calculatePrime2MeanFieldType<VolFieldType1, VolFieldType2>
|
||||
(
|
||||
i
|
||||
);
|
||||
|
||||
calculatePrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>
|
||||
(
|
||||
i
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type1, class Type2>
|
||||
void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType
|
||||
(
|
||||
const label fieldi
|
||||
) const
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
|
||||
if (obr_.foundObject<Type1>(fieldName))
|
||||
{
|
||||
const Type1& meanField =
|
||||
obr_.lookupObject<Type1>(faItems_[fieldi].meanFieldName());
|
||||
|
||||
Type2& prime2MeanField = const_cast<Type2&>
|
||||
(
|
||||
obr_.lookupObject<Type2>(faItems_[fieldi].prime2MeanFieldName())
|
||||
);
|
||||
|
||||
prime2MeanField += sqr(meanField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type1, class Type2>
|
||||
void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const
|
||||
{
|
||||
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
||||
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
||||
|
||||
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
||||
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
||||
|
||||
forAll(faItems_, i)
|
||||
{
|
||||
if (faItems_[i].prime2Mean())
|
||||
{
|
||||
addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(i);
|
||||
addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldAverage::writeFieldType
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
if (obr_.foundObject<Type>(fieldName))
|
||||
{
|
||||
const Type& f = obr_.lookupObject<Type>(fieldName);
|
||||
f.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldAverage::writeFields() const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
forAll(faItems_, i)
|
||||
{
|
||||
if (faItems_[i].mean())
|
||||
{
|
||||
const word& fieldName = faItems_[i].meanFieldName();
|
||||
writeFieldType<VolFieldType>(fieldName);
|
||||
writeFieldType<SurfaceFieldType>(fieldName);
|
||||
}
|
||||
if (faItems_[i].prime2Mean())
|
||||
{
|
||||
const word& fieldName = faItems_[i].prime2MeanFieldName();
|
||||
writeFieldType<VolFieldType>(fieldName);
|
||||
writeFieldType<SurfaceFieldType>(fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,127 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldCoordinateSystemTransform.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(fieldCoordinateSystemTransform, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
fieldCoordinateSystemTransform,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::
|
||||
fieldCoordinateSystemTransform
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_(),
|
||||
coordSys_(mesh_, dict)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
Log << type() << " " << name << ":" << nl
|
||||
<< " Applying transformation from global Cartesian to local "
|
||||
<< coordSys_ << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::
|
||||
~fieldCoordinateSystemTransform()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::transformFieldName
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return fieldName + ":Transformed";
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
transform<scalar>(fieldSet_[fieldi]);
|
||||
transform<vector>(fieldSet_[fieldi]);
|
||||
transform<sphericalTensor>(fieldSet_[fieldi]);
|
||||
transform<symmTensor>(fieldSet_[fieldi]);
|
||||
transform<tensor>(fieldSet_[fieldi]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::write()
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
writeObject(transformFieldName(fieldSet_[fieldi]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,177 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Transforms a user-specified selection of fields from global Cartesian
|
||||
co-ordinates to a local co-ordinate system. The fields are run-time
|
||||
modifiable.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
fieldCoordinateSystemTransform1
|
||||
{
|
||||
type fieldCoordinateSystemTransform;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
fields
|
||||
(
|
||||
U
|
||||
UMean
|
||||
UPrime2Mean
|
||||
);
|
||||
origin (0.001 0 0);
|
||||
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0.15 0);
|
||||
e3 (0 0 -1);
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldCoordinateSystemTransform | yes |
|
||||
fields | list of fields to be transformed |yes |
|
||||
origin | origin of local co-ordinate system | yes |
|
||||
coordinateRotation | orientation of local co-ordinate system | yes |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::coordinateSystem
|
||||
|
||||
SourceFiles
|
||||
fieldCoordinateSystemTransform.C
|
||||
fieldCoordinateSystemTransformTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldCoordinateSystemTransform_H
|
||||
#define functionObjects_fieldCoordinateSystemTransform_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "coordinateSystem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldCoordinateSystemTransform Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldCoordinateSystemTransform
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Fields to transform
|
||||
wordList fieldSet_;
|
||||
|
||||
//- Co-ordinate system to transform to
|
||||
coordinateSystem coordSys_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return the name of the transformed field
|
||||
word transformFieldName(const word& fieldName) const;
|
||||
|
||||
//- Transform the given field
|
||||
template<class FieldType>
|
||||
void transformField(const FieldType& field);
|
||||
|
||||
//- Transform the given field if has the specified element type
|
||||
template<class Type>
|
||||
void transform(const word& fieldName);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fieldCoordinateSystemTransform");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldCoordinateSystemTransform
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldCoordinateSystemTransform();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the input data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the transformed fields
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the transformed fields
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldCoordinateSystemTransformTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldCoordinateSystemTransform.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "transformGeometricField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class FieldType>
|
||||
void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
|
||||
(
|
||||
const FieldType& field
|
||||
)
|
||||
{
|
||||
word transFieldName(transformFieldName(field.name()));
|
||||
|
||||
store
|
||||
(
|
||||
transFieldName,
|
||||
Foam::transform(dimensionedTensor(coordSys_.R().R()), field)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (mesh_.foundObject<VolFieldType>(fieldName))
|
||||
{
|
||||
DebugInfo
|
||||
<< type() << ": Field " << fieldName << " already in database"
|
||||
<< endl;
|
||||
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
mesh_.lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else if (mesh_.foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
DebugInfo
|
||||
<< type() << ": Field " << fieldName << " already in database"
|
||||
<< endl;
|
||||
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
mesh_.lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
fieldHeader.headerOk()
|
||||
&& fieldHeader.headerClassName() == VolFieldType::typeName
|
||||
)
|
||||
{
|
||||
DebugInfo
|
||||
<< type() << ": Field " << fieldName << " read from file"
|
||||
<< endl;
|
||||
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
mesh_.lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerOk()
|
||||
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName
|
||||
)
|
||||
{
|
||||
DebugInfo
|
||||
<< type() << ": Field " << fieldName << " read from file"
|
||||
<< endl;
|
||||
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
mesh_.lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,52 @@
|
||||
/*--------------------------------*- 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 dictionary;
|
||||
object postProcessingDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
functions
|
||||
{
|
||||
fieldCoordinateSystemTransform1
|
||||
{
|
||||
// Type of functionObject
|
||||
type fieldCoordinateSystemTransform;
|
||||
|
||||
// Where to load it from (if not already in solver)
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
// Function object enabled flag
|
||||
enabled true;
|
||||
|
||||
// When to output the average fields
|
||||
writeControl writeTime;
|
||||
|
||||
// Fields to be transformed - runTime modifiable
|
||||
fields
|
||||
(
|
||||
U
|
||||
UMean
|
||||
UPrime2Mean
|
||||
);
|
||||
|
||||
origin (0.001 0 0);
|
||||
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0.15 0);
|
||||
e3 (0 0 -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
151
src/functionObjects/field/fieldExpression/fieldExpression.C
Normal file
151
src/functionObjects/field/fieldExpression/fieldExpression.C
Normal file
@ -0,0 +1,151 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldExpression.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(fieldExpression, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::calc()
|
||||
{
|
||||
NotImplemented;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldExpression::setResultName
|
||||
(
|
||||
const word& typeName,
|
||||
const word& defaultArg
|
||||
)
|
||||
{
|
||||
if (fieldName_.empty())
|
||||
{
|
||||
fieldName_ = defaultArg;
|
||||
}
|
||||
|
||||
if (resultName_.empty())
|
||||
{
|
||||
if (fieldName_ != defaultArg)
|
||||
{
|
||||
resultName_ = typeName + '(' + fieldName_ + ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
resultName_ = typeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldExpression::fieldExpression
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const word& fieldName,
|
||||
const word& resultName
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldName_(fieldName),
|
||||
resultName_(resultName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldExpression::~fieldExpression()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
if (fieldName_.empty() || dict.found("field"))
|
||||
{
|
||||
dict.lookup("field") >> fieldName_;
|
||||
}
|
||||
|
||||
if (dict.found("result"))
|
||||
{
|
||||
dict.lookup("result") >> resultName_;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::execute()
|
||||
{
|
||||
if (!calc())
|
||||
{
|
||||
Warning
|
||||
<< " functionObjects::" << type() << " " << name()
|
||||
<< " cannot find required field " << fieldName_ << endl;
|
||||
|
||||
// Clear the result field from the objectRegistry if present
|
||||
clear();
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::write()
|
||||
{
|
||||
return writeObject(resultName_);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::clear()
|
||||
{
|
||||
return clearObject(resultName_);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
138
src/functionObjects/field/fieldExpression/fieldExpression.H
Normal file
138
src/functionObjects/field/fieldExpression/fieldExpression.H
Normal file
@ -0,0 +1,138 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldExpression
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
fieldExpression.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldExpression_H
|
||||
#define functionObjects_fieldExpression_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldExpression Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldExpression
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected member data
|
||||
|
||||
//- Name of field to process
|
||||
word fieldName_;
|
||||
|
||||
//- Name of result field
|
||||
word resultName_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
virtual bool calc();
|
||||
|
||||
void setResultName(const word& typeName, const word& defaultArg);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldExpression(const fieldExpression&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldExpression&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fieldExpression");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldExpression
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const word& fieldName = word::null,
|
||||
const word& resultName = word::null
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldExpression();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the fieldExpression data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the result field
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the result field
|
||||
virtual bool write();
|
||||
|
||||
//- Clear the result field from the objectRegistry
|
||||
virtual bool clear();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
163
src/functionObjects/field/fieldMinMax/fieldMinMax.C
Normal file
163
src/functionObjects/field/fieldMinMax/fieldMinMax.C
Normal file
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldMinMax.H"
|
||||
#include "fieldTypes.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(fieldMinMax, 0);
|
||||
addToRunTimeSelectionTable(functionObject, fieldMinMax, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldMinMax::modeType,
|
||||
2
|
||||
>::names[] = {"magnitude", "component"};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldMinMax::modeType,
|
||||
2
|
||||
> Foam::functionObjects::fieldMinMax::modeTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldMinMax::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "Field minima and maxima");
|
||||
writeCommented(os, "Time");
|
||||
|
||||
if (writeLocation_)
|
||||
{
|
||||
writeTabbed(os, "field");
|
||||
writeTabbed(os, "min");
|
||||
writeTabbed(os, "location(min)");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(os, "processor");
|
||||
}
|
||||
|
||||
writeTabbed(os, "max");
|
||||
writeTabbed(os, "location(max)");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(os, "processor");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
writeTabbed(os, "min(" + fieldSet_[fieldi] + ')');
|
||||
writeTabbed(os, "max(" + fieldSet_[fieldi] + ')');
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldMinMax::fieldMinMax
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name, typeName, dict),
|
||||
location_(true),
|
||||
mode_(mdMag),
|
||||
fieldSet_()
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldMinMax::~fieldMinMax()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
location_ = dict.lookupOrDefault<Switch>("location", true);
|
||||
|
||||
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::write()
|
||||
{
|
||||
if (!location_) writeTime(file());
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
calcMinMaxFields<scalar>(fieldSet_[fieldi], mdCmpt);
|
||||
calcMinMaxFields<vector>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<symmTensor>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<tensor>(fieldSet_[fieldi], mode_);
|
||||
}
|
||||
|
||||
if (!location_) file()<< endl;
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
213
src/functionObjects/field/fieldMinMax/fieldMinMax.H
Normal file
213
src/functionObjects/field/fieldMinMax/fieldMinMax.H
Normal file
@ -0,0 +1,213 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldMinMax
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the value and location of scalar minimim and maximum for a list
|
||||
of user-specified fields.
|
||||
|
||||
For variables with a rank greater than zero, either the min/max of a
|
||||
component value or the magnitude is reported. When operating in parallel,
|
||||
the processor owning the value is also given.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
fieldMinMax1
|
||||
{
|
||||
type fieldMinMax;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
writeToFile yes;
|
||||
log yes;
|
||||
writeLocation yes;
|
||||
mode magnitude;
|
||||
fields (U p);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldMinMax | yes |
|
||||
writeToFile | write min/max data to file | no | yes
|
||||
log | write min/max data to standard output | no | yes
|
||||
writeLocation | write location of the min/max value | no | yes
|
||||
mode | calculation mode: magnitude or component | no | magnitude
|
||||
fields | list of fields to process | yes |
|
||||
\endtable
|
||||
|
||||
Output data is written to the file \<timeDir\>/fieldMinMax.dat
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
fieldMinMax.C
|
||||
fieldMinMaxTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldMinMax_H
|
||||
#define functionObjects_fieldMinMax_H
|
||||
|
||||
#include "Switch.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "vector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldMinMax Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldMinMax
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public writeFile
|
||||
{
|
||||
public:
|
||||
|
||||
// Public enumerations
|
||||
|
||||
enum modeType
|
||||
{
|
||||
mdMag, //!< magnitude
|
||||
mdCmpt //!< component
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Mode type names
|
||||
static const NamedEnum<modeType, 2> modeTypeNames_;
|
||||
|
||||
//- Switch to write location of min/max values
|
||||
Switch writeLocation_;
|
||||
|
||||
//- Mode for min/max - only applicable for ranks > 0
|
||||
modeType mode_;
|
||||
|
||||
//- Fields to assess min/max
|
||||
wordList fieldSet_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Helper function to write the output
|
||||
template<class Type>
|
||||
void output
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& outputName,
|
||||
const vector& minC,
|
||||
const vector& maxC,
|
||||
const label minProci,
|
||||
const label maxProci,
|
||||
const Type& minValue,
|
||||
const Type& maxValue
|
||||
);
|
||||
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldMinMax(const fieldMinMax&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldMinMax&) = delete;
|
||||
|
||||
//- Calculate the field min/max
|
||||
template<class Type>
|
||||
void calcMinMaxFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const modeType& mode
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fieldMinMax");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldMinMax
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldMinMax();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field min/max data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the fieldMinMax
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldMinMaxTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
286
src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C
Normal file
286
src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C
Normal file
@ -0,0 +1,286 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldMinMax.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldMinMax::output
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& outputName,
|
||||
const vector& minC,
|
||||
const vector& maxC,
|
||||
const label minProci,
|
||||
const label maxProci,
|
||||
const Type& minValue,
|
||||
const Type& maxValue
|
||||
)
|
||||
{
|
||||
OFstream& file = this->file();
|
||||
|
||||
if (writeLocation_)
|
||||
{
|
||||
writeTime(file());
|
||||
|
||||
writeTabbed(file, fieldName);
|
||||
|
||||
file<< token::TAB << minValue
|
||||
<< token::TAB << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file<< token::TAB << minProci;
|
||||
}
|
||||
|
||||
file<< token::TAB << maxValue
|
||||
<< token::TAB << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file<< token::TAB << maxProci;
|
||||
}
|
||||
|
||||
file<< endl;
|
||||
|
||||
Log << " min(" << outputName << ") = " << minValue
|
||||
<< " at location " << minC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Log << " on processor " << minProci;
|
||||
}
|
||||
|
||||
Log << nl << " max(" << outputName << ") = " << maxValue
|
||||
<< " at location " << maxC;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Log << " on processor " << maxProci;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file<< token::TAB << minValue << token::TAB << maxValue;
|
||||
|
||||
Log << " min/max(" << outputName << ") = "
|
||||
<< minValue << ' ' << maxValue;
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
// Write state/results information
|
||||
word nameStr('(' + outputName + ')');
|
||||
this->setResult("min" + nameStr, minValue);
|
||||
this->setResult("min" + nameStr + "_position", minC);
|
||||
this->setResult("min" + nameStr + "_processor", minProcI);
|
||||
this->setResult("max" + nameStr, maxValue);
|
||||
this->setResult("max" + nameStr + "_position", maxC);
|
||||
this->setResult("max" + nameStr + "_processor", maxProcI);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldMinMax::calcMinMaxFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const modeType& mode
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (obr_.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const label proci = Pstream::myProcNo();
|
||||
|
||||
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
|
||||
|
||||
const volVectorField::Boundary& CfBoundary =
|
||||
mesh_.C().boundaryField();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case mdMag:
|
||||
{
|
||||
const volScalarField magField(mag(field));
|
||||
const volScalarField::Boundary& magFieldBoundary =
|
||||
magField.boundaryField();
|
||||
|
||||
scalarList minVs(Pstream::nProcs());
|
||||
List<vector> minCs(Pstream::nProcs());
|
||||
label minProci = findMin(magField);
|
||||
minVs[proci] = magField[minProci];
|
||||
minCs[proci] = mesh_.C()[minProci];
|
||||
|
||||
|
||||
labelList maxIs(Pstream::nProcs());
|
||||
scalarList maxVs(Pstream::nProcs());
|
||||
List<vector> maxCs(Pstream::nProcs());
|
||||
label maxProci = findMax(magField);
|
||||
maxVs[proci] = magField[maxProci];
|
||||
maxCs[proci] = mesh_.C()[maxProci];
|
||||
|
||||
forAll(magFieldBoundary, patchi)
|
||||
{
|
||||
const scalarField& mfp = magFieldBoundary[patchi];
|
||||
if (mfp.size())
|
||||
{
|
||||
const vectorField& Cfp = CfBoundary[patchi];
|
||||
|
||||
label minPI = findMin(mfp);
|
||||
if (mfp[minPI] < minVs[proci])
|
||||
{
|
||||
minVs[proci] = mfp[minPI];
|
||||
minCs[proci] = Cfp[minPI];
|
||||
}
|
||||
|
||||
label maxPI = findMax(mfp);
|
||||
if (mfp[maxPI] > maxVs[proci])
|
||||
{
|
||||
maxVs[proci] = mfp[maxPI];
|
||||
maxCs[proci] = Cfp[maxPI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::scatterList(minVs);
|
||||
Pstream::gatherList(minCs);
|
||||
Pstream::scatterList(minCs);
|
||||
|
||||
Pstream::gatherList(maxVs);
|
||||
Pstream::scatterList(maxVs);
|
||||
Pstream::gatherList(maxCs);
|
||||
Pstream::scatterList(maxCs);
|
||||
|
||||
label minI = findMin(minVs);
|
||||
scalar minValue = minVs[minI];
|
||||
const vector& minC = minCs[minI];
|
||||
|
||||
label maxI = findMax(maxVs);
|
||||
scalar maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
output
|
||||
(
|
||||
fieldName,
|
||||
word("mag(" + fieldName + ")"),
|
||||
minC,
|
||||
maxC,
|
||||
minI,
|
||||
maxI,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
break;
|
||||
}
|
||||
case mdCmpt:
|
||||
{
|
||||
const typename fieldType::Boundary&
|
||||
fieldBoundary = field.boundaryField();
|
||||
|
||||
List<Type> minVs(Pstream::nProcs());
|
||||
List<vector> minCs(Pstream::nProcs());
|
||||
label minProci = findMin(field);
|
||||
minVs[proci] = field[minProci];
|
||||
minCs[proci] = mesh_.C()[minProci];
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::gatherList(minCs);
|
||||
|
||||
List<Type> maxVs(Pstream::nProcs());
|
||||
List<vector> maxCs(Pstream::nProcs());
|
||||
label maxProci = findMax(field);
|
||||
maxVs[proci] = field[maxProci];
|
||||
maxCs[proci] = mesh_.C()[maxProci];
|
||||
|
||||
forAll(fieldBoundary, patchi)
|
||||
{
|
||||
const Field<Type>& fp = fieldBoundary[patchi];
|
||||
if (fp.size())
|
||||
{
|
||||
const vectorField& Cfp = CfBoundary[patchi];
|
||||
|
||||
label minPI = findMin(fp);
|
||||
if (fp[minPI] < minVs[proci])
|
||||
{
|
||||
minVs[proci] = fp[minPI];
|
||||
minCs[proci] = Cfp[minPI];
|
||||
}
|
||||
|
||||
label maxPI = findMax(fp);
|
||||
if (fp[maxPI] > maxVs[proci])
|
||||
{
|
||||
maxVs[proci] = fp[maxPI];
|
||||
maxCs[proci] = Cfp[maxPI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::gatherList(minVs);
|
||||
Pstream::scatterList(minVs);
|
||||
Pstream::gatherList(minCs);
|
||||
Pstream::scatterList(minCs);
|
||||
|
||||
Pstream::gatherList(maxVs);
|
||||
Pstream::scatterList(maxVs);
|
||||
Pstream::gatherList(maxCs);
|
||||
Pstream::scatterList(maxCs);
|
||||
|
||||
label minI = findMin(minVs);
|
||||
Type minValue = minVs[minI];
|
||||
const vector& minC = minCs[minI];
|
||||
|
||||
label maxI = findMax(maxVs);
|
||||
Type maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
output
|
||||
(
|
||||
fieldName,
|
||||
fieldName,
|
||||
minC,
|
||||
maxC,
|
||||
minI,
|
||||
maxI,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown min/max mode: " << modeTypeNames_[mode_]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
119
src/functionObjects/field/fieldValues/fieldValue/fieldValue.C
Normal file
119
src/functionObjects/field/fieldValues/fieldValue/fieldValue.C
Normal file
@ -0,0 +1,119 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldValue.H"
|
||||
#include "Time.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(fieldValue, 0);
|
||||
defineRunTimeSelectionTable(fieldValue, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValue::fieldValue
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const word& valueType
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name, valueType, dict),
|
||||
scaleFactor_(1.0),
|
||||
dict_(dict),
|
||||
regionName_(word::null)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::functionObjects::fieldValue::fieldValue
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const word& valueType
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, obr, dict),
|
||||
writeFile(obr_, name, valueType, dict),
|
||||
scaleFactor_(1.0),
|
||||
dict_(dict),
|
||||
regionName_(word::null)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValue::~fieldValue()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
|
||||
{
|
||||
if (dict != dict_)
|
||||
{
|
||||
dict_ = dict;
|
||||
}
|
||||
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.lookup("writeFields") >> writeFields_;
|
||||
dict.readIfPresent("scaleFactor", scaleFactor_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldValue::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldValue::write()
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
199
src/functionObjects/field/fieldValues/fieldValue/fieldValue.H
Normal file
199
src/functionObjects/field/fieldValues/fieldValue/fieldValue.H
Normal file
@ -0,0 +1,199 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldValue
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Base class for field value-based function objects.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
fieldValue.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldValue_H
|
||||
#define functionObjects_fieldValue_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "Switch.H"
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class fvMesh;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldValue Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldValue
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public writeFile
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Construction dictionary
|
||||
dictionary dict_;
|
||||
|
||||
//- Name of region (patch, zone, etc.)
|
||||
word regionName_;
|
||||
|
||||
//- List of field names to operate on
|
||||
wordList fields_;
|
||||
|
||||
//- Output field values flag
|
||||
Switch writeFields_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Combine fields from all processor domains into single field
|
||||
template<class Type>
|
||||
void combineFields(Field<Type>& field);
|
||||
|
||||
//- Combine fields from all processor domains into single field
|
||||
template<class Type>
|
||||
void combineFields(tmp<Field<Type>>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("fieldValue");
|
||||
|
||||
// Declare runtime constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
fieldValue,
|
||||
dictionary,
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
),
|
||||
(name, obr, dict)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldValue
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict,
|
||||
const word& valueType
|
||||
);
|
||||
|
||||
//- Construct from objectRegistry and dictionary
|
||||
fieldValue
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const word& valueType
|
||||
);
|
||||
|
||||
//- Return a reference to the selected fieldValue
|
||||
static autoPtr<fieldValue> New
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool output = true
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldValue();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the reference to the construction dictionary
|
||||
inline const dictionary& dict() const;
|
||||
|
||||
//- Return the region name
|
||||
inline const word& regionName() const;
|
||||
|
||||
//- Return the list of field names
|
||||
inline const wordList& fields() const;
|
||||
|
||||
//- Return the output field values flag
|
||||
inline const Switch& writeFields() const;
|
||||
|
||||
//- Read from dictionary
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Execute
|
||||
virtual bool execute();
|
||||
|
||||
//- Write
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "fieldValueI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldValueTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::dictionary& Foam::functionObjects::fieldValue::dict() const
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::word& Foam::functionObjects::fieldValue::regionName() const
|
||||
{
|
||||
return regionName_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::wordList& Foam::functionObjects::fieldValue::fields() const
|
||||
{
|
||||
return fields_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::Switch&
|
||||
Foam::functionObjects::fieldValue::writeFields() const
|
||||
{
|
||||
return writeFields_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldValue.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::functionObjects::fieldValue>
|
||||
Foam::functionObjects::fieldValue::New
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool output
|
||||
)
|
||||
{
|
||||
const word modelType(dict.lookup("type"));
|
||||
|
||||
if (output)
|
||||
{
|
||||
Info<< "Selecting " << typeName << " " << modelType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown " << typeName << " type "
|
||||
<< modelType << nl << nl
|
||||
<< "Valid " << typeName << " types are:" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<fieldValue>(cstrIter()(name, obr, dict));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldValue.H"
|
||||
#include "ListListOps.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldValue::combineFields(Field<Type>& field)
|
||||
{
|
||||
List<Field<Type>> allValues(Pstream::nProcs());
|
||||
|
||||
allValues[Pstream::myProcNo()] = field;
|
||||
|
||||
Pstream::gatherList(allValues);
|
||||
Pstream::scatterList(allValues);
|
||||
|
||||
field =
|
||||
ListListOps::combine<Field<Type>>
|
||||
(
|
||||
allValues,
|
||||
accessOp<Field<Type>>()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::fieldValue::combineFields(tmp<Field<Type>>& field)
|
||||
{
|
||||
combineFields(field());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,233 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldValueDelta.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace fieldValues
|
||||
{
|
||||
defineTypeNameAndDebug(fieldValueDelta, 0);
|
||||
addToRunTimeSelectionTable(functionObject, fieldValueDelta, dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
|
||||
5
|
||||
>::names[] =
|
||||
{
|
||||
"add",
|
||||
"subtract",
|
||||
"min",
|
||||
"max",
|
||||
"average"
|
||||
};
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
|
||||
5
|
||||
> Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldValues::fieldValueDelta::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
const wordList& fields1 = region1Ptr_->fields();
|
||||
const wordList& fields2 = region2Ptr_->fields();
|
||||
|
||||
DynamicList<word> commonFields(fields1.size());
|
||||
forAll(fields1, fieldi)
|
||||
{
|
||||
label index = findIndex(fields2, fields1[fieldi]);
|
||||
if (index != -1)
|
||||
{
|
||||
commonFields.append(fields1[fieldi]);
|
||||
}
|
||||
}
|
||||
|
||||
writeHeaderValue(os, "Source1", region1Ptr_->name());
|
||||
writeHeaderValue(os, "Source2", region2Ptr_->name());
|
||||
writeHeaderValue(os, "Operation", operationTypeNames_[operation_]);
|
||||
writeCommented(os, "Time");
|
||||
|
||||
forAll(commonFields, i)
|
||||
{
|
||||
os << tab << commonFields[i];
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
regionFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name, typeName, dict),
|
||||
operation_(opSubtract),
|
||||
region1Ptr_(nullptr),
|
||||
region2Ptr_(nullptr)
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta::~fieldValueDelta()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldValues::fieldValueDelta::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
regionFunctionObject::read(dict);
|
||||
|
||||
writeFile::read(dict);
|
||||
|
||||
region1Ptr_.reset
|
||||
(
|
||||
fieldValue::New
|
||||
(
|
||||
name() + ".region1",
|
||||
obr_,
|
||||
dict.subDict("region1"),
|
||||
false
|
||||
).ptr()
|
||||
);
|
||||
region2Ptr_.reset
|
||||
(
|
||||
fieldValue::New
|
||||
(
|
||||
name() + ".region2",
|
||||
obr_,
|
||||
dict.subDict("region2"),
|
||||
false
|
||||
).ptr()
|
||||
);
|
||||
|
||||
operation_ = operationTypeNames_.read(dict.lookup("operation"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldValues::fieldValueDelta::write()
|
||||
{
|
||||
region1Ptr_->write();
|
||||
region2Ptr_->write();
|
||||
|
||||
writeTime(file());
|
||||
|
||||
Log << type() << " " << name() << " write:" << endl;
|
||||
|
||||
const word& name1 = source1Ptr_->name();
|
||||
const word& name2 = source2Ptr_->name();
|
||||
|
||||
const wordList entries1 = objectResultEntries(name1);
|
||||
const wordList entries2 = objectResultEntries(name2);
|
||||
|
||||
if (entries1.size() != entries2.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< name_ << ": objects must generate the same number of results"
|
||||
<< nl
|
||||
<< " " << name1 << " objects: " << entries1 << nl
|
||||
<< " " << name2 << " objects: " << entries2 << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
forAll(entries1, i)
|
||||
{
|
||||
const word& entry1(entries1[i]);
|
||||
const word& entry2(entries2[i]);
|
||||
const word type1 = objectResultType(name1, entry1);
|
||||
const word type2 = objectResultType(name2, entry2);
|
||||
|
||||
if (type1 != type2)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< name_
|
||||
<< ": input values for operation must be of the same type"
|
||||
<< nl
|
||||
<< " " << entry1 << ": " << type1 << nl
|
||||
<< " " << entry2 << ": " << type2 << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
|
||||
applyOperation<scalar>(type1, name1, name2, entry1, entry2, found);
|
||||
applyOperation<vector>(type1, name1, name2, entry1, entry2, found);
|
||||
applyOperation<sphericalTensor>
|
||||
(type1, name1, name2, entry1, entry2, found);
|
||||
applyOperation<symmTensor>(type1, name1, name2, entry1, entry2, found);
|
||||
applyOperation<tensor>(type1, name1, name2, entry1, entry2, found);
|
||||
|
||||
if (log && !found)
|
||||
{
|
||||
Info<< "Operation between "
|
||||
<< name1 << " with result " << entry1 << " and "
|
||||
<< name2 << " with result " << entry2 << " not applied"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
Log << (entries1.empty() ? " none" : "") << endl;
|
||||
|
||||
file()<< endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldValues::fieldValueDelta::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,245 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
<<<<<<< HEAD:src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
=======
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
>>>>>>> foundation-github:src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldValues::fieldValueDelta
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
<<<<<<< HEAD:src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
This function object provides applies an operation to the output of two
|
||||
fieldValue function objects.
|
||||
|
||||
The operation is applied to all results of each fieldValue object.
|
||||
Accordingly, each object must generate the same number and type of results.
|
||||
=======
|
||||
Provides a differencing option between two 'field value' function objects.
|
||||
>>>>>>> foundation-github:src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
fieldValueDelta1
|
||||
{
|
||||
type fieldValueDelta;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
operation subtract;
|
||||
|
||||
source1
|
||||
{
|
||||
...
|
||||
}
|
||||
source2
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldValueDelta | yes |
|
||||
\endtable
|
||||
|
||||
The \c operation is one of:
|
||||
\plaintable
|
||||
add | add
|
||||
subtract | subtract
|
||||
min | minimum
|
||||
max | maximum
|
||||
average | average
|
||||
\endplaintable
|
||||
|
||||
<<<<<<< HEAD:src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
SeeAlso
|
||||
Foam::fieldValue
|
||||
=======
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObject::fieldValue
|
||||
Foam::functionObjects::regionFunctionObject
|
||||
Foam::functionObjects::logFiles
|
||||
>>>>>>> foundation-github:src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
|
||||
SourceFiles
|
||||
fieldValueDelta.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_fieldValueDelta_H
|
||||
#define functionObjects_fieldValueDelta_H
|
||||
|
||||
<<<<<<< HEAD:src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
#include "functionObjectState.H"
|
||||
#include "functionObjectFile.H"
|
||||
=======
|
||||
#include "regionFunctionObject.H"
|
||||
#include "logFiles.H"
|
||||
>>>>>>> foundation-github:src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
#include "fieldValue.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace fieldValues
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldValueDelta Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldValueDelta
|
||||
:
|
||||
<<<<<<< HEAD:src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
public functionObjectState,
|
||||
public functionObjectFile
|
||||
=======
|
||||
public regionFunctionObject,
|
||||
public logFiles
|
||||
>>>>>>> foundation-github:src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
{
|
||||
public:
|
||||
//- Operation type enumeration
|
||||
enum operationType
|
||||
{
|
||||
opAdd,
|
||||
opSubtract,
|
||||
opMin,
|
||||
opMax,
|
||||
opAverage
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 5> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
<<<<<<< HEAD:src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
//- Database this class is registered to
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Flag to indicate to load from files
|
||||
bool loadFromFiles_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
=======
|
||||
>>>>>>> foundation-github:src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H
|
||||
//- Operation to apply to values
|
||||
operationType operation_;
|
||||
|
||||
//- Field value region object 1
|
||||
autoPtr<fieldValue> region1Ptr_;
|
||||
|
||||
//- Field value region object 2
|
||||
autoPtr<fieldValue> region2Ptr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Templated function to apply the operation
|
||||
template<class Type>
|
||||
void apply
|
||||
(
|
||||
const word& resultType,
|
||||
const word& name1,
|
||||
const word& name2,
|
||||
const word& entryName1,
|
||||
const word& entryName2,
|
||||
bool& found
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("fieldValueDelta");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
fieldValueDelta
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldValueDelta();
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Read from dictionary
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Do nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Calculate and write
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fieldValues
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fieldValueDeltaTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjects::fieldValues::fieldValueDelta::applyOperation
|
||||
(
|
||||
const word& resultType,
|
||||
const word& name1,
|
||||
const word& name2,
|
||||
const word& entryName1,
|
||||
const word& entryName2,
|
||||
bool& found
|
||||
)
|
||||
{
|
||||
if (pTraits<Type>::typeName != resultType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type result = Zero;
|
||||
|
||||
Type value1 = this->getObjectResult<Type>(name1, entryName1);
|
||||
Type value2 = this->getObjectResult<Type>(name2, entryName2);
|
||||
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
|
||||
switch (operation_)
|
||||
{
|
||||
case opAdd:
|
||||
{
|
||||
result = value1 + value2;
|
||||
break;
|
||||
}
|
||||
case opSubtract:
|
||||
{
|
||||
result = value1 - value2;
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
{
|
||||
result = min(value1, value2);
|
||||
break;
|
||||
}
|
||||
case opMax:
|
||||
{
|
||||
result = max(value1, value2);
|
||||
break;
|
||||
}
|
||||
case opAverage:
|
||||
{
|
||||
result = 0.5*(value1 + value2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to process operation "
|
||||
<< operationTypeNames_[operation_]
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
const word resultName(opName + '(' + entryName1 + ',' + entryName2 + ')');
|
||||
|
||||
Log << " " << resultName << " = " << result << endl;
|
||||
|
||||
this->file()<< tab << result;
|
||||
|
||||
// Write state/results information
|
||||
this->setResult(resultName, result);
|
||||
|
||||
found = true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,785 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceFieldValue.H"
|
||||
#include "fvMesh.H"
|
||||
#include "cyclicPolyPatch.H"
|
||||
#include "emptyPolyPatch.H"
|
||||
#include "coupledPolyPatch.H"
|
||||
#include "sampledSurface.H"
|
||||
#include "mergePoints.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "PatchTools.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace fieldValues
|
||||
{
|
||||
defineTypeNameAndDebug(surfaceFieldValue, 0);
|
||||
addToRunTimeSelectionTable(fieldValue, surfaceFieldValue, dictionary);
|
||||
addToRunTimeSelectionTable(functionObject, surfaceFieldValue, dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
|
||||
3
|
||||
>::names[] =
|
||||
{
|
||||
"faceZone",
|
||||
"patch",
|
||||
"sampledSurface"
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
|
||||
15
|
||||
>::names[] =
|
||||
{
|
||||
"none",
|
||||
"sum",
|
||||
"sumMag",
|
||||
"sumDirection",
|
||||
"sumDirectionBalance",
|
||||
"average",
|
||||
"weightedAverage",
|
||||
"areaAverage",
|
||||
"weightedAreaAverage",
|
||||
"areaIntegrate",
|
||||
"min",
|
||||
"max",
|
||||
"CoV",
|
||||
"areaNormalAverage",
|
||||
"areaNormalIntegrate"
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
|
||||
3
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_;
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
|
||||
15
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
|
||||
{
|
||||
label zoneId = mesh_.faceZones().findZoneID(regionName_);
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl
|
||||
<< " Unknown face zone name: " << regionName_
|
||||
<< ". Valid face zones are: " << mesh_.faceZones().names()
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
const faceZone& fZone = mesh_.faceZones()[zoneId];
|
||||
|
||||
DynamicList<label> faceIds(fZone.size());
|
||||
DynamicList<label> facePatchIds(fZone.size());
|
||||
DynamicList<label> faceSigns(fZone.size());
|
||||
|
||||
forAll(fZone, i)
|
||||
{
|
||||
label facei = fZone[i];
|
||||
|
||||
label faceId = -1;
|
||||
label facePatchId = -1;
|
||||
if (mesh_.isInternalFace(facei))
|
||||
{
|
||||
faceId = facei;
|
||||
facePatchId = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
facePatchId = mesh_.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
|
||||
if (isA<coupledPolyPatch>(pp))
|
||||
{
|
||||
if (refCast<const coupledPolyPatch>(pp).owner())
|
||||
{
|
||||
faceId = pp.whichFace(facei);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceId = -1;
|
||||
}
|
||||
}
|
||||
else if (!isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
faceId = facei - pp.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
faceId = -1;
|
||||
facePatchId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (faceId >= 0)
|
||||
{
|
||||
if (fZone.flipMap()[i])
|
||||
{
|
||||
faceSigns.append(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceSigns.append(1);
|
||||
}
|
||||
faceIds.append(faceId);
|
||||
facePatchIds.append(facePatchId);
|
||||
}
|
||||
}
|
||||
|
||||
faceId_.transfer(faceIds);
|
||||
facePatchId_.transfer(facePatchIds);
|
||||
faceSign_.transfer(faceSigns);
|
||||
nFaces_ = returnReduce(faceId_.size(), sumOp<label>());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Original face zone size = " << fZone.size()
|
||||
<< ", new size = " << faceId_.size() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces()
|
||||
{
|
||||
const label patchid = mesh_.boundaryMesh().findPatchID(regionName_);
|
||||
|
||||
if (patchid < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl
|
||||
<< " Unknown patch name: " << regionName_
|
||||
<< ". Valid patch names are: "
|
||||
<< mesh_.boundaryMesh().names() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[patchid];
|
||||
|
||||
label nFaces = pp.size();
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
nFaces = 0;
|
||||
}
|
||||
|
||||
faceId_.setSize(nFaces);
|
||||
facePatchId_.setSize(nFaces);
|
||||
faceSign_.setSize(nFaces);
|
||||
nFaces_ = returnReduce(faceId_.size(), sumOp<label>());
|
||||
|
||||
forAll(faceId_, facei)
|
||||
{
|
||||
faceId_[facei] = facei;
|
||||
facePatchId_[facei] = patchid;
|
||||
faceSign_[facei] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
surfacePtr_ = sampledSurface::New
|
||||
(
|
||||
name(),
|
||||
mesh_,
|
||||
dict.subDict("sampledSurfaceDict")
|
||||
);
|
||||
surfacePtr_().update();
|
||||
nFaces_ = returnReduce(surfacePtr_().faces().size(), sumOp<label>());
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
pointField& points
|
||||
) const
|
||||
{
|
||||
List<faceList> allFaces(Pstream::nProcs());
|
||||
List<pointField> allPoints(Pstream::nProcs());
|
||||
|
||||
labelList globalFacesIs(faceId_);
|
||||
forAll(globalFacesIs, i)
|
||||
{
|
||||
if (facePatchId_[i] != -1)
|
||||
{
|
||||
label patchi = facePatchId_[i];
|
||||
globalFacesIs[i] += mesh_.boundaryMesh()[patchi].start();
|
||||
}
|
||||
}
|
||||
|
||||
// Add local faces and points to the all* lists
|
||||
indirectPrimitivePatch pp
|
||||
(
|
||||
IndirectList<face>(mesh_.faces(), globalFacesIs),
|
||||
mesh_.points()
|
||||
);
|
||||
allFaces[Pstream::myProcNo()] = pp.localFaces();
|
||||
allPoints[Pstream::myProcNo()] = pp.localPoints();
|
||||
|
||||
Pstream::gatherList(allFaces);
|
||||
Pstream::gatherList(allPoints);
|
||||
|
||||
// Renumber and flatten
|
||||
label nFaces = 0;
|
||||
label nPoints = 0;
|
||||
forAll(allFaces, proci)
|
||||
{
|
||||
nFaces += allFaces[proci].size();
|
||||
nPoints += allPoints[proci].size();
|
||||
}
|
||||
|
||||
faces.setSize(nFaces);
|
||||
points.setSize(nPoints);
|
||||
|
||||
nFaces = 0;
|
||||
nPoints = 0;
|
||||
|
||||
// My own data first
|
||||
{
|
||||
const faceList& fcs = allFaces[Pstream::myProcNo()];
|
||||
forAll(fcs, i)
|
||||
{
|
||||
const face& f = fcs[i];
|
||||
face& newF = faces[nFaces++];
|
||||
newF.setSize(f.size());
|
||||
forAll(f, fp)
|
||||
{
|
||||
newF[fp] = f[fp] + nPoints;
|
||||
}
|
||||
}
|
||||
|
||||
const pointField& pts = allPoints[Pstream::myProcNo()];
|
||||
forAll(pts, i)
|
||||
{
|
||||
points[nPoints++] = pts[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Other proc data follows
|
||||
forAll(allFaces, proci)
|
||||
{
|
||||
if (proci != Pstream::myProcNo())
|
||||
{
|
||||
const faceList& fcs = allFaces[proci];
|
||||
forAll(fcs, i)
|
||||
{
|
||||
const face& f = fcs[i];
|
||||
face& newF = faces[nFaces++];
|
||||
newF.setSize(f.size());
|
||||
forAll(f, fp)
|
||||
{
|
||||
newF[fp] = f[fp] + nPoints;
|
||||
}
|
||||
}
|
||||
|
||||
const pointField& pts = allPoints[proci];
|
||||
forAll(pts, i)
|
||||
{
|
||||
points[nPoints++] = pts[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge
|
||||
labelList oldToNew;
|
||||
pointField newPoints;
|
||||
bool hasMerged = mergePoints
|
||||
(
|
||||
points,
|
||||
SMALL,
|
||||
false,
|
||||
oldToNew,
|
||||
newPoints
|
||||
);
|
||||
|
||||
if (hasMerged)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Merged from " << points.size()
|
||||
<< " down to " << newPoints.size() << " points" << endl;
|
||||
}
|
||||
|
||||
points.transfer(newPoints);
|
||||
forAll(faces, i)
|
||||
{
|
||||
inplaceRenumber(oldToNew, faces[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::
|
||||
combineSurfaceGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
pointField& points
|
||||
) const
|
||||
{
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
const sampledSurface& s = surfacePtr_();
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Dimension as fraction of mesh bounding box
|
||||
scalar mergeDim = 1e-10*mesh_.bounds().mag();
|
||||
|
||||
labelList pointsMap;
|
||||
|
||||
PatchTools::gatherAndMerge
|
||||
(
|
||||
mergeDim,
|
||||
primitivePatch
|
||||
(
|
||||
SubList<face>(s.faces(), s.faces().size()),
|
||||
s.points()
|
||||
),
|
||||
points,
|
||||
faces,
|
||||
pointsMap
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
faces = s.faces();
|
||||
points = s.points();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
|
||||
{
|
||||
scalar totalArea;
|
||||
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
totalArea = gSum(surfacePtr_().magSf());
|
||||
}
|
||||
else
|
||||
{
|
||||
totalArea = gSum(filterField(mesh_.magSf(), false));
|
||||
}
|
||||
|
||||
return totalArea;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
dict.lookup("name") >> regionName_;
|
||||
|
||||
switch (regionType_)
|
||||
{
|
||||
case stFaceZone:
|
||||
{
|
||||
setFaceZoneFaces();
|
||||
break;
|
||||
}
|
||||
case stPatch:
|
||||
{
|
||||
setPatchFaces();
|
||||
break;
|
||||
}
|
||||
case stSampledSurface:
|
||||
{
|
||||
sampledSurfaceFaces(dict);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):"
|
||||
<< nl << " Unknown region type. Valid region types are:"
|
||||
<< regionTypeNames_.sortedToc() << nl << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
if (nFaces_ == 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl
|
||||
<< " Region has no faces" << exit(FatalError);
|
||||
}
|
||||
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
surfacePtr_().update();
|
||||
}
|
||||
|
||||
totalArea_ = totalArea();
|
||||
|
||||
Info<< type() << " " << name() << ":" << nl
|
||||
<< " total faces = " << nFaces_ << nl
|
||||
<< " total area = " << totalArea_ << nl;
|
||||
|
||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||
{
|
||||
Info<< " weight field = " << weightFieldName_ << nl;
|
||||
|
||||
if (regionType_ == stSampledSurface)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Cannot use weightField for a sampledSurface"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.found("orientedWeightField"))
|
||||
{
|
||||
if (weightFieldName_ == "none")
|
||||
{
|
||||
dict.lookup("orientedWeightField") >> weightFieldName_;
|
||||
if (log_) Info << " weight field = " << weightFieldName_ << nl;
|
||||
orientWeightField_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Either weightField or orientedWeightField can be supplied, "
|
||||
<< "but not both"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
List<word> orientedFields;
|
||||
if (dict.readIfPresent("orientedFields", orientedFields))
|
||||
{
|
||||
orientedFieldsStart_ = fields_.size();
|
||||
fields_.append(orientedFields);
|
||||
}
|
||||
|
||||
Info<< nl << endl;
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
const word surfaceFormat(dict.lookup("surfaceFormat"));
|
||||
|
||||
surfaceWriterPtr_.reset
|
||||
(
|
||||
surfaceWriter::New
|
||||
(
|
||||
surfaceFormat,
|
||||
dict.subOrEmptyDict("formatOptions").
|
||||
subOrEmptyDict(surfaceFormat)
|
||||
).ptr()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSource::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
if (operation_ != opNone)
|
||||
{
|
||||
writeCommented(os, "Region type : ");
|
||||
os << regionTypeNames_[regionType_] << " " << regionName_ << endl;
|
||||
|
||||
writeHeaderValue(os, "Faces", nFaces_);
|
||||
writeHeaderValue(os, "Area", totalArea_);
|
||||
writeHeaderValue(os, "Scale factor", scaleFactor_);
|
||||
|
||||
writeCommented(os, "Time");
|
||||
if (writeArea_)
|
||||
{
|
||||
os << tab << "Area";
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
os << tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[i] << ")";
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::functionObjects::fieldValues::surfaceFieldValue::
|
||||
processValues
|
||||
(
|
||||
const Field<scalar>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const
|
||||
{
|
||||
switch (operation_)
|
||||
{
|
||||
case opSumDirection:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
return gSum(pos(values*(Sf & n))*mag(values));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
const scalarField nv(values*(Sf & n));
|
||||
|
||||
return gSum(pos(nv)*mag(values) - neg(nv)*mag(values));
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Fall through to other operations
|
||||
return processSameTypeValues(values, Sf, weightField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::vector Foam::functionObjects::fieldValues::surfaceFieldValue::
|
||||
processValues
|
||||
(
|
||||
const Field<vector>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const
|
||||
{
|
||||
switch (operation_)
|
||||
{
|
||||
case opSumDirection:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const scalarField nv(n & values);
|
||||
|
||||
return gSum(pos(nv)*n*(nv));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const scalarField nv(n & values);
|
||||
|
||||
return gSum(pos(nv)*n*(nv));
|
||||
}
|
||||
case opAreaNormalAverage:
|
||||
{
|
||||
scalar result = gSum(values & Sf)/gSum(mag(Sf));
|
||||
return vector(result, 0.0, 0.0);
|
||||
}
|
||||
case opAreaNormalIntegrate:
|
||||
{
|
||||
scalar result = gSum(values & Sf);
|
||||
return vector(result, 0.0, 0.0);
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Fall through to other operations
|
||||
return processSameTypeValues(values, Sf, weightField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldValue(name, runTime, dict, typeName),
|
||||
surfaceWriterPtr_(nullptr),
|
||||
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
weightFieldName_("none"),
|
||||
orientWeightField_(false),
|
||||
orientedFieldsStart_(labelMax),
|
||||
scaleFactor_(1.0),
|
||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||
nFaces_(0),
|
||||
faceId_(),
|
||||
facePatchId_(),
|
||||
faceSign_()
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldValue(name, obr, dict, typeName),
|
||||
surfaceWriterPtr_(nullptr),
|
||||
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
weightFieldName_("none"),
|
||||
orientWeightField_(false),
|
||||
orientedFieldsStart_(labelMax),
|
||||
scaleFactor_(1.0),
|
||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||
nFaces_(0),
|
||||
faceId_(),
|
||||
facePatchId_(),
|
||||
faceSign_()
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::~surfaceFieldValue()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldValues::surfaceFieldValue::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
initialise(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
||||
{
|
||||
if (operation_ != opNone)
|
||||
{
|
||||
fieldValue::write();
|
||||
}
|
||||
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
surfacePtr_().update();
|
||||
}
|
||||
|
||||
if (operation_ != opNone && Pstream::master())
|
||||
{
|
||||
writeTime(file());
|
||||
}
|
||||
|
||||
if (writeArea_)
|
||||
{
|
||||
totalArea_ = totalArea();
|
||||
if (operation_ != opNone && Pstream::master())
|
||||
{
|
||||
file() << tab << totalArea_;
|
||||
}
|
||||
Log << " total area = " << totalArea_ << endl;
|
||||
}
|
||||
|
||||
// Construct weight field. Note: zero size means weight = 1
|
||||
scalarField weightField;
|
||||
if (weightFieldName_ != "none")
|
||||
{
|
||||
weightField =
|
||||
getFieldValues<scalar>
|
||||
(
|
||||
weightFieldName_,
|
||||
true,
|
||||
orientWeightField_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Process the fields
|
||||
forAll(fields_, i)
|
||||
{
|
||||
const word& fieldName = fields_[i];
|
||||
bool ok = false;
|
||||
|
||||
bool orient = i >= orientedFieldsStart_;
|
||||
ok = ok || writeValues<scalar>(fieldName, weightField, orient);
|
||||
ok = ok || writeValues<vector>(fieldName, weightField, orient);
|
||||
ok = ok
|
||||
|| writeValues<sphericalTensor>(fieldName, weightField, orient);
|
||||
ok = ok || writeValues<symmTensor>(fieldName, weightField, orient);
|
||||
ok = ok || writeValues<tensor>(fieldName, weightField, orient);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Requested field " << fieldName
|
||||
<< " not found in database and not processed"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (operation_ != opNone && Pstream::master())
|
||||
{
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,474 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Provides a 'face regionType' variant of the fieldValues function object.
|
||||
|
||||
Given a list of user-specified fields and a selection of mesh (or general
|
||||
surface) faces, a number of operations can be performed, such as sums,
|
||||
averages and integrations.
|
||||
|
||||
For example, to calculate the volumetric or mass flux across a patch,
|
||||
apply the 'sum' operator to the flux field (typically \c phi)
|
||||
|
||||
Examples of function object specification:
|
||||
\verbatim
|
||||
movingWallPatch
|
||||
{
|
||||
type surfaceFieldValue;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
log true;
|
||||
writeControl writeTime;
|
||||
writeFields true;
|
||||
|
||||
regionType patch;
|
||||
name movingWall;
|
||||
|
||||
operation areaAverage;
|
||||
|
||||
fields
|
||||
(
|
||||
p
|
||||
phi
|
||||
U
|
||||
);
|
||||
}
|
||||
|
||||
surfaceFieldValue1
|
||||
{
|
||||
type surfaceFieldValue;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
log true;
|
||||
writeControl writeTime;
|
||||
writeFields true;
|
||||
|
||||
surfaceFormat none;
|
||||
regionType faceZone;
|
||||
name f0;
|
||||
|
||||
operation sum;
|
||||
|
||||
weightField alpha1;
|
||||
|
||||
fields
|
||||
(
|
||||
p
|
||||
phi
|
||||
U
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: surfaceFieldValue | yes |
|
||||
log | write data to standard output | no | no
|
||||
writeFields | Write the region field values | yes |
|
||||
writeArea | Write the area of the surfaceFieldValue | no |
|
||||
surfaceFormat | output value format | no |
|
||||
regionType | face regionType: see below | yes |
|
||||
name | name of face regionType if required | no |
|
||||
operation | operation to perform | yes |
|
||||
weightField | name of field to apply weighting | no |
|
||||
orientedWeightField | name of oriented field to apply weighting | no |
|
||||
scaleFactor | scale factor | no | 1
|
||||
fields | list of fields to operate on | yes |
|
||||
orientedFields | list of oriented fields to operate on | no |
|
||||
\endtable
|
||||
|
||||
Where \c regionType is defined by
|
||||
\plaintable
|
||||
faceZone | requires a 'name' entry to specify the faceZone
|
||||
patch | requires a 'name' entry to specify the patch
|
||||
sampledSurface | requires a 'sampledSurfaceDict' sub-dictionary
|
||||
\endplaintable
|
||||
|
||||
The \c operation is one of:
|
||||
\plaintable
|
||||
none | no operation
|
||||
sum | sum
|
||||
sumMag | sum of component magnitudes
|
||||
sumDirection | sum values which are positive in given direction
|
||||
sumDirectionBalance | sum of balance of values in given direction
|
||||
average | ensemble average
|
||||
weightedAverage | weighted average
|
||||
areaAverage | area weighted average
|
||||
weightedAreaAverage | weighted area average
|
||||
areaIntegrate | area integral
|
||||
min | minimum
|
||||
max | maximum
|
||||
CoV | coefficient of variation: standard deviation/mean
|
||||
areaNormalAverage| area weighted average in face normal direction
|
||||
areaNormalIntegrate | area weighted integral in face normal directon
|
||||
\endplaintable
|
||||
|
||||
Note
|
||||
- The values reported by the areaNormalAverage and areaNormalIntegrate
|
||||
operations are written as the first component of a field with the same
|
||||
rank as the input field.
|
||||
- faces on empty patches get ignored
|
||||
- if the field is a volField the \c faceZone can only consist of boundary
|
||||
faces
|
||||
- the `oriented' entries relate to mesh-oriented fields, such as the
|
||||
flux, phi. These fields will be oriented according to the face normals.
|
||||
- using \c sampledSurface:
|
||||
- not available for surface fields
|
||||
- if interpolate=true they use \c interpolationCellPoint
|
||||
otherwise they use cell values
|
||||
- each triangle in \c sampledSurface is logically only in one cell
|
||||
so interpolation will be wrong when triangles are larger than
|
||||
cells. This can only happen for sampling on a \c triSurfaceMesh
|
||||
- take care when using isoSurfaces - these might have duplicate
|
||||
triangles and so integration might be wrong
|
||||
|
||||
See also
|
||||
Foam::fieldValues
|
||||
Foam::functionObject
|
||||
|
||||
SourceFiles
|
||||
surfaceFieldValue.C
|
||||
surfaceFieldValueTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_surfaceFieldValue_H
|
||||
#define functionObjects_surfaceFieldValue_H
|
||||
|
||||
#include "fieldValue.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class sampledSurface;
|
||||
class surfaceWriter;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace fieldValues
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceFieldValue Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfaceFieldValue
|
||||
:
|
||||
public fieldValue
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- region type enumeration
|
||||
enum regionTypes
|
||||
{
|
||||
stFaceZone,
|
||||
stPatch,
|
||||
stSampledSurface
|
||||
};
|
||||
|
||||
//- region type names
|
||||
static const NamedEnum<regionTypes, 3> regionTypeNames_;
|
||||
|
||||
|
||||
//- Operation type enumeration
|
||||
enum operationType
|
||||
{
|
||||
opNone,
|
||||
opSum,
|
||||
opSumMag,
|
||||
opSumDirection,
|
||||
opSumDirectionBalance,
|
||||
opAverage,
|
||||
opWeightedAverage,
|
||||
opAreaAverage,
|
||||
opWeightedAreaAverage,
|
||||
opAreaIntegrate,
|
||||
opMin,
|
||||
opMax,
|
||||
opCoV,
|
||||
opAreaNormalAverage,
|
||||
opAreaNormalIntegrate
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 15> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Set faces to evaluate based on a face zone
|
||||
void setFaceZoneFaces();
|
||||
|
||||
//- Set faces to evaluate based on a patch
|
||||
void setPatchFaces();
|
||||
|
||||
//- Set faces according to sampledSurface
|
||||
void sampledSurfaceFaces(const dictionary&);
|
||||
|
||||
//- Combine mesh faces and points from multiple processors
|
||||
void combineMeshGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
pointField& points
|
||||
) const;
|
||||
|
||||
//- Combine surface faces and points from multiple processors
|
||||
void combineSurfaceGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
pointField& points
|
||||
) const;
|
||||
|
||||
//- Calculate and return total area of the surfaceFieldValue: sum(magSf)
|
||||
scalar totalArea() const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Surface writer
|
||||
autoPtr<surfaceWriter> surfaceWriterPtr_;
|
||||
|
||||
//- region type
|
||||
regionTypes regionType_;
|
||||
|
||||
//- Operation to apply to values
|
||||
operationType operation_;
|
||||
|
||||
//- Weight field name - optional
|
||||
word weightFieldName_;
|
||||
|
||||
//- Flag to indicate if flipMap should be applied to the weight field
|
||||
bool orientWeightField_;
|
||||
|
||||
//- Start index of fields that require application of flipMap
|
||||
label orientedFieldsStart_;
|
||||
|
||||
//- Total area of the surfaceFieldValue
|
||||
scalar totalArea_;
|
||||
|
||||
//- Optionally write the area of the surfaceFieldValue
|
||||
bool writeArea_;
|
||||
|
||||
//- Global number of faces
|
||||
label nFaces_;
|
||||
|
||||
|
||||
// If operating on mesh faces (faceZone, patch)
|
||||
|
||||
//- Local list of face IDs
|
||||
labelList faceId_;
|
||||
|
||||
//- Local list of patch ID per face
|
||||
labelList facePatchId_;
|
||||
|
||||
//- List of +1/-1 representing face flip map
|
||||
// (1 use as is, -1 negate)
|
||||
labelList faceSign_;
|
||||
|
||||
|
||||
// If operating on sampledSurface
|
||||
|
||||
//- Underlying sampledSurface
|
||||
autoPtr<sampledSurface> surfacePtr_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Initialise, e.g. face addressing
|
||||
void initialise(const dictionary& dict);
|
||||
|
||||
//- Return true if the field name is valid
|
||||
template<class Type>
|
||||
bool validField(const word& fieldName) const;
|
||||
|
||||
//- Return field values by looking up field name
|
||||
template<class Type>
|
||||
tmp<Field<Type>> setFieldValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet = false,
|
||||
const bool applyOrientation = false
|
||||
) const;
|
||||
|
||||
//- Apply the 'operation' to the values. Operation has to
|
||||
// preserve Type.
|
||||
template<class Type>
|
||||
Type processSameTypeValues
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const;
|
||||
|
||||
//- Apply the 'operation' to the values. Wrapper around
|
||||
// processSameTypeValues. See also template specialisation below.
|
||||
template<class Type>
|
||||
Type processValues
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const;
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("surfaceFieldValue");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name, Time and dictionary
|
||||
surfaceFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from name, objectRegistry and dictionary
|
||||
surfaceFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfaceFieldValue();
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Return the region type
|
||||
inline const regionTypes& regionType() const;
|
||||
|
||||
//- Return the local list of face IDs
|
||||
inline const labelList& faceId() const;
|
||||
|
||||
//- Return the local list of patch ID per face
|
||||
inline const labelList& facePatch() const;
|
||||
|
||||
//- Return the list of +1/-1 representing face flip map
|
||||
inline const labelList& faceSign() const;
|
||||
|
||||
//- Return the output directory
|
||||
inline fileName outputDir() const;
|
||||
|
||||
//- Templated helper function to output field values
|
||||
template<class Type>
|
||||
bool writeValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const scalarField& weightField,
|
||||
const bool orient
|
||||
);
|
||||
|
||||
//- Filter a surface field according to faceIds
|
||||
template<class Type>
|
||||
tmp<Field<Type>> filterField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
||||
const bool applyOrientation
|
||||
) const;
|
||||
|
||||
//- Filter a volume field according to faceIds
|
||||
template<class Type>
|
||||
tmp<Field<Type>> filterField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const bool applyOrientation
|
||||
) const;
|
||||
|
||||
//- Read from dictionary
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate and write
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
//- Specialisation for scalar
|
||||
template<>
|
||||
scalar surfaceFieldValue::processValues
|
||||
(
|
||||
const Field<scalar>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const;
|
||||
|
||||
|
||||
//- Specialisation for vector
|
||||
template<>
|
||||
vector surfaceFieldValue::processValues
|
||||
(
|
||||
const Field<vector>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fieldValues
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "surfaceFieldValueI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "surfaceFieldValueTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceFieldValue.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes&
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::regionType() const
|
||||
{
|
||||
return regionType_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelList&
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::faceId() const
|
||||
{
|
||||
return faceId_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelList&
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::facePatch() const
|
||||
{
|
||||
return facePatchId_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelList&
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::faceSign() const
|
||||
{
|
||||
return faceSign_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::fileName
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::outputDir() const
|
||||
{
|
||||
return baseFileDir()/name()/"surface"/obr_.time().timeName();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,448 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceFieldValue.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "volFields.H"
|
||||
#include "sampledSurface.H"
|
||||
#include "surfaceWriter.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::fieldValues::surfaceFieldValue::validField
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||
|
||||
if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (obr_.foundObject<vf>(fieldName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
<<<<<<< HEAD:src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C
|
||||
Foam::tmp<Foam::Field<Type>> Foam::fieldValues::faceSource::setFieldValues
|
||||
=======
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||
>>>>>>> foundation-github:src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet,
|
||||
const bool applyOrientation
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||
|
||||
if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
|
||||
{
|
||||
return filterField(obr_.lookupObject<sf>(fieldName), applyOrientation);
|
||||
}
|
||||
else if (obr_.foundObject<vf>(fieldName))
|
||||
{
|
||||
const vf& fld = obr_.lookupObject<vf>(fieldName);
|
||||
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
if (surfacePtr_().interpolate())
|
||||
{
|
||||
const interpolationCellPoint<Type> interp(fld);
|
||||
tmp<Field<Type>> tintFld(surfacePtr_().interpolate(interp));
|
||||
const Field<Type>& intFld = tintFld();
|
||||
|
||||
// Average
|
||||
const faceList& faces = surfacePtr_().faces();
|
||||
tmp<Field<Type>> tavg
|
||||
(
|
||||
new Field<Type>(faces.size(), Zero)
|
||||
);
|
||||
Field<Type>& avg = tavg.ref();
|
||||
|
||||
forAll(faces, facei)
|
||||
{
|
||||
const face& f = faces[facei];
|
||||
forAll(f, fp)
|
||||
{
|
||||
avg[facei] += intFld[f[fp]];
|
||||
}
|
||||
avg[facei] /= f.size();
|
||||
}
|
||||
|
||||
return tavg;
|
||||
}
|
||||
else
|
||||
{
|
||||
return surfacePtr_().sample(fld);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return filterField(fld, applyOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
if (mustGet)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Field " << fieldName << " not found in database"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return tmp<Field<Type>>(new Field<Type>(0));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjects::fieldValues::surfaceFieldValue::
|
||||
processSameTypeValues
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const
|
||||
{
|
||||
Type result = Zero;
|
||||
switch (operation_)
|
||||
{
|
||||
case opSum:
|
||||
{
|
||||
result = gSum(values);
|
||||
break;
|
||||
}
|
||||
case opSumMag:
|
||||
{
|
||||
result = gSum(cmptMag(values));
|
||||
break;
|
||||
}
|
||||
case opSumDirection:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Operation " << operationTypeNames_[operation_]
|
||||
<< " not available for values of type "
|
||||
<< pTraits<Type>::typeName
|
||||
<< exit(FatalError);
|
||||
|
||||
result = Zero;
|
||||
break;
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Operation " << operationTypeNames_[operation_]
|
||||
<< " not available for values of type "
|
||||
<< pTraits<Type>::typeName
|
||||
<< exit(FatalError);
|
||||
|
||||
result = Zero;
|
||||
break;
|
||||
}
|
||||
case opAverage:
|
||||
{
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
break;
|
||||
}
|
||||
case opWeightedAverage:
|
||||
{
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
|
||||
if (wSize > 0)
|
||||
{
|
||||
result =
|
||||
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case opAreaAverage:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = gSum(magSf*values)/gSum(magSf);
|
||||
break;
|
||||
}
|
||||
case opWeightedAreaAverage:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
|
||||
if (wSize > 0)
|
||||
{
|
||||
result = gSum(weightField*magSf*values)/gSum(magSf*weightField);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = gSum(magSf*values)/gSum(magSf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case opAreaIntegrate:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = gSum(magSf*values);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
{
|
||||
result = gMin(values);
|
||||
break;
|
||||
}
|
||||
case opMax:
|
||||
{
|
||||
result = gMax(values);
|
||||
break;
|
||||
}
|
||||
case opCoV:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
const scalar gSumMagSf = gSum(magSf);
|
||||
|
||||
Type meanValue = gSum(values*magSf)/gSumMagSf;
|
||||
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
scalarField vals(values.component(d));
|
||||
scalar mean = component(meanValue, d);
|
||||
scalar& res = setComponent(result, d);
|
||||
|
||||
res =
|
||||
sqrt(gSum(magSf*sqr(vals - mean))/gSumMagSf)
|
||||
/(mean + ROOTVSMALL);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case opAreaNormalAverage:
|
||||
{}
|
||||
case opAreaNormalIntegrate:
|
||||
{}
|
||||
case opNone:
|
||||
{}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const vectorField& Sf,
|
||||
const scalarField& weightField
|
||||
) const
|
||||
{
|
||||
return processSameTypeValues(values, Sf, weightField);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const scalarField& weightField,
|
||||
const bool orient
|
||||
)
|
||||
{
|
||||
const bool ok = validField<Type>(fieldName);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
Field<Type> values(setFieldValues<Type>(fieldName, true, orient));
|
||||
|
||||
vectorField Sf;
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
// Get oriented Sf
|
||||
Sf = surfacePtr_().Sf();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get oriented Sf
|
||||
Sf = filterField(mesh_.Sf(), true);
|
||||
}
|
||||
|
||||
// Write raw values on surface if specified
|
||||
if (surfaceWriterPtr_.valid())
|
||||
{
|
||||
Field<Type> allValues(values);
|
||||
combineFields(allValues);
|
||||
|
||||
faceList faces;
|
||||
pointField points;
|
||||
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
combineSurfaceGeometry(faces, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
combineMeshGeometry(faces, points);
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
surfaceWriterPtr_->write
|
||||
(
|
||||
outputDir(),
|
||||
regionTypeNames_[regionType_] + ("_" + regionName_),
|
||||
points,
|
||||
faces,
|
||||
fieldName,
|
||||
allValues,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (operation_ != opNone)
|
||||
{
|
||||
// Apply scale factor
|
||||
values *= scaleFactor_;
|
||||
|
||||
Type result = processValues(values, Sf, weightField);
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
Log << " " << operationTypeNames_[operation_]
|
||||
<< "(" << regionName_ << ") of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
|
||||
// Write state/results information
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
word resultName =
|
||||
opName + '(' + sourceName_ + ',' + fieldName + ')';
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const bool applyOrientation
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
|
||||
forAll(values, i)
|
||||
{
|
||||
label facei = faceId_[i];
|
||||
label patchi = facePatchId_[i];
|
||||
if (patchi >= 0)
|
||||
{
|
||||
values[i] = field.boundaryField()[patchi][facei];
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):"
|
||||
<< nl
|
||||
<< " Unable to process internal faces for volume field "
|
||||
<< field.name() << nl << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
if (applyOrientation)
|
||||
{
|
||||
forAll(values, i)
|
||||
{
|
||||
values[i] *= faceSign_[i];
|
||||
}
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
||||
const bool applyOrientation
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
|
||||
forAll(values, i)
|
||||
{
|
||||
label facei = faceId_[i];
|
||||
label patchi = facePatchId_[i];
|
||||
if (patchi >= 0)
|
||||
{
|
||||
values[i] = field.boundaryField()[patchi][facei];
|
||||
}
|
||||
else
|
||||
{
|
||||
values[i] = field[facei];
|
||||
}
|
||||
}
|
||||
|
||||
if (applyOrientation)
|
||||
{
|
||||
forAll(values, i)
|
||||
{
|
||||
values[i] *= faceSign_[i];
|
||||
}
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,218 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volFieldValue.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace fieldValues
|
||||
{
|
||||
defineTypeNameAndDebug(volFieldValue, 0);
|
||||
addToRunTimeSelectionTable(fieldValue, volFieldValue, dictionary);
|
||||
addToRunTimeSelectionTable(functionObject, volFieldValue, dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char*
|
||||
Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationType,
|
||||
11
|
||||
>::names[] =
|
||||
{
|
||||
"none",
|
||||
"sum",
|
||||
"sumMag",
|
||||
"average",
|
||||
"weightedAverage",
|
||||
"volAverage",
|
||||
"weightedVolAverage",
|
||||
"volIntegrate",
|
||||
"min",
|
||||
"max",
|
||||
"CoV"
|
||||
};
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::volFieldValue::operationType,
|
||||
11
|
||||
> Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::fieldValues::volFieldValue::initialise
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||
{
|
||||
Info<< " weight field = " << weightFieldName_;
|
||||
}
|
||||
|
||||
Info<< nl << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldValues::volFieldValue::writeFileHeader
|
||||
(
|
||||
const label i
|
||||
)
|
||||
{
|
||||
volRegion::writeFileHeader(*this, file());
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
|
||||
forAll(fields_, fieldi)
|
||||
{
|
||||
file()
|
||||
<< tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[fieldi] << ")";
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldValue(name, runTime, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
weightFieldName_("none")
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldValue(name, obr, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
weightFieldName_("none")
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldValues::volFieldValue::~volFieldValue()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldValues::volFieldValue::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
|
||||
// No additional info to read
|
||||
initialise(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldValues::volFieldValue::write()
|
||||
{
|
||||
fieldValue::write();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeTime(file());
|
||||
}
|
||||
|
||||
// Construct weight field. Note: zero size means weight = 1
|
||||
scalarField weightField;
|
||||
if (weightFieldName_ != "none")
|
||||
{
|
||||
weightField =
|
||||
getFieldValues<scalar>
|
||||
(
|
||||
weightFieldName_,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
const word& fieldName = fields_[i];
|
||||
bool ok = false;
|
||||
|
||||
ok = ok || writeValues<scalar>(fieldName, weightField);
|
||||
ok = ok || writeValues<vector>(fieldName, weightField);
|
||||
ok = ok || writeValues<sphericalTensor>(fieldName, weightField);
|
||||
ok = ok || writeValues<symmTensor>(fieldName, weightField);
|
||||
ok = ok || writeValues<tensor>(fieldName, weightField);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Requested field " << fieldName
|
||||
<< " not found in database and not ok"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< endl;
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,258 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::fieldValues::volFieldValue
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Provides a 'volRegion' specialization of the fieldValue function object.
|
||||
|
||||
Given a list of user-specified fields and a 'volRegion', a number of
|
||||
operations can be performed, such as sums, averages and integrations.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
volFieldValue1
|
||||
{
|
||||
type volFieldValue;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
log true;
|
||||
writeControl writeTime;
|
||||
writeFields true;
|
||||
|
||||
regionType cellZone;
|
||||
name c0;
|
||||
operation volAverage;
|
||||
|
||||
weightField alpha1;
|
||||
|
||||
fields
|
||||
(
|
||||
p
|
||||
U
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: volFieldValue | yes |
|
||||
log | Write data to standard output | no | no
|
||||
writeFields | Write the region field values | yes |
|
||||
regionType | volRegion type: see below | yes |
|
||||
name | Name of volRegion if required | no |
|
||||
operation | Operation to perform | yes |
|
||||
weightField | Name of field to apply weighting | no |
|
||||
fields | List of fields to operate on | yes |
|
||||
\endtable
|
||||
|
||||
Where \c regionType is defined by
|
||||
\plaintable
|
||||
cellZone | requires a 'name' entry to specify the cellZone
|
||||
all | all cells
|
||||
\endplaintable
|
||||
|
||||
The \c operation is one of:
|
||||
\plaintable
|
||||
none | No operation
|
||||
sum | Sum
|
||||
sumMag | Sum of component magnitudes
|
||||
average | Ensemble average
|
||||
weightedAverage | Weighted average
|
||||
volAverage | Volume weighted average
|
||||
weightedVolAverage | Weighted volume average
|
||||
volIntegrate | Volume integral
|
||||
min | Minimum
|
||||
max | Maximum
|
||||
CoV | Coefficient of variation: standard deviation/mean
|
||||
\endplaintable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldValues::fieldValue
|
||||
Foam::functionObjects::volRegion
|
||||
Foam::functionObject
|
||||
|
||||
SourceFiles
|
||||
volFieldValue.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_volFieldValue_H
|
||||
#define functionObjects_volFieldValue_H
|
||||
|
||||
#include "fieldValue.H"
|
||||
#include "volRegion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace fieldValues
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class volFieldValue Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class volFieldValue
|
||||
:
|
||||
public fieldValue,
|
||||
public volRegion
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Operation type enumeration
|
||||
enum operationType
|
||||
{
|
||||
opNone,
|
||||
opSum,
|
||||
opSumMag,
|
||||
opAverage,
|
||||
opWeightedAverage,
|
||||
opVolAverage,
|
||||
opWeightedVolAverage,
|
||||
opVolIntegrate,
|
||||
opMin,
|
||||
opMax,
|
||||
opCoV
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 11> operationTypeNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Operation to apply to values
|
||||
operationType operation_;
|
||||
|
||||
//- Weight field name - only used for opWeightedAverage mode
|
||||
word weightFieldName_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Initialise, e.g. cell addressing
|
||||
void initialise(const dictionary& dict);
|
||||
|
||||
//- Return true if the field name is valid
|
||||
template<class Type>
|
||||
bool validField(const word& fieldName) const;
|
||||
|
||||
//- Insert field values into values list
|
||||
template<class Type>
|
||||
tmp<Field<Type>> setFieldValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet = false
|
||||
) const;
|
||||
|
||||
//- Apply the 'operation' to the values
|
||||
template<class Type>
|
||||
Type processValues
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const scalarField& V,
|
||||
const scalarField& weightField
|
||||
) const;
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("volFieldValue");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name, Time and dictionary
|
||||
volFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from name, objectRegistry and dictionary
|
||||
volFieldValue
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~volFieldValue();
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Templated helper function to output field values
|
||||
template<class Type>
|
||||
bool writeValues(const word& fieldName, const scalarField& weightField);
|
||||
|
||||
//- Filter a field according to cellIds
|
||||
template<class Type>
|
||||
tmp<Field<Type>> filterField(const Field<Type>& field) const;
|
||||
|
||||
//- Read from dictionary
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate and write
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace fieldValues
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "volFieldValueTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,247 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volFieldValue.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::fieldValues::volFieldValue::validField
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||
|
||||
if (obr_.foundObject<vf>(fieldName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::volFieldValue::setFieldValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||
|
||||
if (obr_.foundObject<vf>(fieldName))
|
||||
{
|
||||
return filterField(obr_.lookupObject<vf>(fieldName));
|
||||
}
|
||||
|
||||
if (mustGet)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Field " << fieldName << " not found in database"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return tmp<Field<Type>>(new Field<Type>(0.0));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjects::fieldValues::volFieldValue::processValues
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const scalarField& V,
|
||||
const scalarField& weightField
|
||||
) const
|
||||
{
|
||||
Type result = Zero;
|
||||
switch (operation_)
|
||||
{
|
||||
case opSum:
|
||||
{
|
||||
result = gSum(values);
|
||||
break;
|
||||
}
|
||||
case opSumMag:
|
||||
{
|
||||
result = gSum(cmptMag(values));
|
||||
break;
|
||||
}
|
||||
case opAverage:
|
||||
{
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
break;
|
||||
}
|
||||
case opWeightedAverage:
|
||||
{
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
|
||||
if (wSize > 0)
|
||||
{
|
||||
result =
|
||||
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case opVolAverage:
|
||||
{
|
||||
result = gSum(values*V)/(gSum(V) + ROOTVSMALL);
|
||||
break;
|
||||
}
|
||||
case opWeightedVolAverage:
|
||||
{
|
||||
result = gSum(weightField*V*values)/gSum(weightField*V);
|
||||
break;
|
||||
}
|
||||
case opVolIntegrate:
|
||||
{
|
||||
result = gSum(V*values);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
{
|
||||
result = gMin(values);
|
||||
break;
|
||||
}
|
||||
case opMax:
|
||||
{
|
||||
result = gMax(values);
|
||||
break;
|
||||
}
|
||||
case opCoV:
|
||||
{
|
||||
const scalar sumV = gSum(V);
|
||||
|
||||
Type meanValue = gSum(V*values)/sumV;
|
||||
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
scalarField vals(values.component(d));
|
||||
scalar mean = component(meanValue, d);
|
||||
scalar& res = setComponent(result, d);
|
||||
|
||||
res = sqrt(gSum(V*sqr(vals - mean))/sumV)/(mean + ROOTVSMALL);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case opNone:
|
||||
{}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
||||
(
|
||||
const word& fieldName
|
||||
const scalarField& weightField
|
||||
)
|
||||
{
|
||||
const bool ok = validField<Type>(fieldName);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
Field<Type> values(setFieldValues<Type>(fieldName));
|
||||
scalarField V(filterField(fieldValue::mesh_.V()));
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
Field<Type> allValues(values);
|
||||
combineFields(allValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
IOField<Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName + '_' + regionTypeNames_[regionType_]
|
||||
+ '-' + volRegion::regionName_,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
scaleFactor_*weightField*allValues
|
||||
).write();
|
||||
}
|
||||
}
|
||||
|
||||
// Apply scale factor
|
||||
values *= scaleFactor_;
|
||||
|
||||
Type result = processValues(values, V, weightField);
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
Log << " " << operationTypeNames_[operation_]
|
||||
<< "(" << volRegion::regionName_ << ") of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
|
||||
// Write state/results information
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
word resultName = opName + '(' + sourceName_ + ',' + fieldName + ')';
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::functionObjects::fieldValues::volFieldValue::filterField
|
||||
(
|
||||
const Field<Type>& field
|
||||
) const
|
||||
{
|
||||
if (isNull(cellIDs()))
|
||||
{
|
||||
return field;
|
||||
}
|
||||
else
|
||||
{
|
||||
return tmp<Field<Type>>(new Field<Type>(field, cellIDs()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
124
src/functionObjects/field/flowType/flowType.C
Normal file
124
src/functionObjects/field/flowType/flowType.C
Normal file
@ -0,0 +1,124 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
flowType
|
||||
|
||||
Group
|
||||
grpPostProcessingUtilities
|
||||
|
||||
Description
|
||||
Calculates and writes the flowType of velocity field U.
|
||||
|
||||
The -noWrite option has no meaning.
|
||||
|
||||
The flow type parameter is obtained according to the following equation:
|
||||
\verbatim
|
||||
|D| - |Omega|
|
||||
lambda = -------------
|
||||
|D| + |Omega|
|
||||
|
||||
-1 = rotational flow
|
||||
0 = simple shear flow
|
||||
1 = planar extensional flow
|
||||
\endverbatim
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "flowType.H"
|
||||
#include "fvcGrad.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(flowType, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
flowType,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::flowType::calc()
|
||||
{
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
const tmp<volTensorField> tgradU(fvc::grad(U));
|
||||
const volTensorField& gradU = tgradU();
|
||||
|
||||
volScalarField magD(mag(symm(gradU)));
|
||||
volScalarField magOmega (mag(skew(gradU)));
|
||||
dimensionedScalar smallMagD("smallMagD", magD.dimensions(), SMALL);
|
||||
|
||||
const volTensorField SSplusWW
|
||||
(
|
||||
(symm(gradU) & symm(gradU))
|
||||
+ (skew(gradU) & skew(gradU))
|
||||
);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
(magD - magOmega)/(magD + magOmega + smallMagD)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::flowType::flowType
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U")
|
||||
{
|
||||
setResultName(typeName, "U");
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::flowType::~flowType()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
110
src/functionObjects/field/flowType/flowType.H
Normal file
110
src/functionObjects/field/flowType/flowType.H
Normal file
@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::flowType
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates and writes the flowType of a velocity field.
|
||||
|
||||
The flow type parameter is obtained according to the following equation:
|
||||
\verbatim
|
||||
|D| - |Omega|
|
||||
lambda = -------------
|
||||
|D| + |Omega|
|
||||
|
||||
-1 = rotational flow
|
||||
0 = simple shear flow
|
||||
1 = planar extensional flow
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
flowType.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_flowType_H
|
||||
#define functionObjects_flowType_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class flowType Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class flowType
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the flowType field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("flowType");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
flowType
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~flowType();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
75
src/functionObjects/field/grad/grad.C
Normal file
75
src/functionObjects/field/grad/grad.C
Normal file
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "grad.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(grad, 0);
|
||||
addToRunTimeSelectionTable(functionObject, grad, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::grad::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcGrad<scalar>();
|
||||
processed = processed || calcGrad<vector>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::grad::grad
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::grad::~grad()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
111
src/functionObjects/field/grad/grad.H
Normal file
111
src/functionObjects/field/grad/grad.H
Normal file
@ -0,0 +1,111 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::grad
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the gradient of a field.
|
||||
|
||||
The operation is limited to scalar and vector volume or surface fields, and
|
||||
the output is a volume vector or tensor field.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
grad.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_grad_H
|
||||
#define functionObjects_grad_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class grad Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class grad
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the magnitude of the field and register the result
|
||||
template<class Type>
|
||||
bool calcGrad();
|
||||
|
||||
//- Calculate the gradient field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("grad");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
grad
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~grad();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "gradTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
61
src/functionObjects/field/grad/gradTemplates.C
Normal file
61
src/functionObjects/field/grad/gradTemplates.C
Normal file
@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvcGrad.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::grad::calcGrad()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::grad(lookupObject<VolFieldType>(fieldName_)),
|
||||
true
|
||||
);
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::grad(lookupObject<SurfaceFieldType>(fieldName_)),
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
198
src/functionObjects/field/histogram/histogram.C
Normal file
198
src/functionObjects/field/histogram/histogram.C
Normal file
@ -0,0 +1,198 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "histogram.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(histogram, 0);
|
||||
addToRunTimeSelectionTable(functionObject, histogram, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::histogram::writeGraph
|
||||
(
|
||||
const coordSet& coords,
|
||||
const word& fieldName,
|
||||
const scalarField& values
|
||||
) const
|
||||
{
|
||||
const wordList fieldNames(1, fieldName);
|
||||
|
||||
fileName outputPath = file_.baseTimeDir();
|
||||
mkDir(outputPath);
|
||||
OFstream graphFile
|
||||
(
|
||||
outputPath/formatterPtr_().getFileName(coords, fieldNames)
|
||||
);
|
||||
|
||||
Log << " Writing histogram of " << fieldName
|
||||
<< " to " << graphFile.name() << endl;
|
||||
|
||||
List<const scalarField*> yPtrs(1);
|
||||
yPtrs[0] = &values;
|
||||
formatterPtr_().write(coords, fieldNames, yPtrs, graphFile);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::histogram::histogram
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
file_(obr_, name)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::histogram::~histogram()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::histogram::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("field") >> fieldName_;
|
||||
dict.lookup("max") >> max_;
|
||||
min_ = dict.lookupOrDefault<scalar>("min", 0);
|
||||
dict.lookup("nBins") >> nBins_;
|
||||
|
||||
word format(dict.lookup("setFormat"));
|
||||
formatterPtr_ = writer<scalar>::New(format);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::histogram::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::histogram::write()
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
autoPtr<volScalarField> fieldPtr;
|
||||
if (obr_.foundObject<volScalarField>(fieldName_))
|
||||
{
|
||||
Log << " Looking up field " << fieldName_ << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log << " Reading field " << fieldName_ << endl;
|
||||
fieldPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const volScalarField& field =
|
||||
(
|
||||
fieldPtr.valid()
|
||||
? fieldPtr()
|
||||
: obr_.lookupObject<volScalarField>(fieldName_)
|
||||
);
|
||||
|
||||
// Calculate the mid-points of bins for the graph axis
|
||||
pointField xBin(nBins_);
|
||||
const scalar delta = (max_- min_)/nBins_;
|
||||
|
||||
scalar x = min_ + 0.5*delta;
|
||||
forAll(xBin, i)
|
||||
{
|
||||
xBin[i] = point(x, 0, 0);
|
||||
x += delta;
|
||||
}
|
||||
|
||||
scalarField volFrac(nBins_, 0);
|
||||
const scalarField& V = mesh_.V();
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
const label bini = (field[celli] - min_)/delta;
|
||||
if (bini >= 0 && bini < nBins_)
|
||||
{
|
||||
volFrac[bini] += V[celli];
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(volFrac, plusEqOp<scalar>());
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
const scalar sumVol = sum(volFrac);
|
||||
|
||||
if (sumVol > SMALL)
|
||||
{
|
||||
volFrac /= sumVol;
|
||||
|
||||
const coordSet coords
|
||||
(
|
||||
"Volume_Fraction",
|
||||
"x",
|
||||
xBin,
|
||||
mag(xBin)
|
||||
);
|
||||
|
||||
writeGraph(coords, field.name(), volFrac);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
173
src/functionObjects/field/histogram/histogram.H
Normal file
173
src/functionObjects/field/histogram/histogram.H
Normal file
@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::histogram
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Write the volume-weighted histogram of a volScalarField.
|
||||
|
||||
Example:
|
||||
\verbatim
|
||||
histogram1
|
||||
{
|
||||
type histogram;
|
||||
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
field p;
|
||||
nBins 100;
|
||||
min -5;
|
||||
max 5;
|
||||
setFormat gnuplot;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: histogram | yes |
|
||||
field | Field to analyse | yes |
|
||||
nBins | Number of bins for the histogram | yes|
|
||||
max | Maximum value sampled | yes |
|
||||
min | minimum value sampled | no | 0
|
||||
setFormat | Output format | yes |
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
histogram.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_histogram_H
|
||||
#define functionObjects_histogram_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class histogram Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class histogram
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
writeFile file_;
|
||||
|
||||
//- Name of field
|
||||
word fieldName_;
|
||||
|
||||
//- Maximum value
|
||||
scalar max_;
|
||||
|
||||
//- Minimum value
|
||||
scalar min_;
|
||||
|
||||
//- Mumber of bins
|
||||
label nBins_;
|
||||
|
||||
//- Output formatter to write
|
||||
autoPtr<writer<scalar>> formatterPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeGraph
|
||||
(
|
||||
const coordSet& coords,
|
||||
const word& valueName,
|
||||
const scalarField& values
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
histogram(const histogram&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const histogram&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("histogram");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
histogram
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
virtual ~histogram();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the histogram data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Calculate the histogram and write.
|
||||
// postProcess overrides the usual writeControl behaviour and
|
||||
// forces writing always (used in post-processing mode)
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
78
src/functionObjects/field/mag/mag.C
Normal file
78
src/functionObjects/field/mag/mag.C
Normal file
@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "mag.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(mag, 0);
|
||||
addToRunTimeSelectionTable(functionObject, mag, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::mag::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcMag<scalar>();
|
||||
processed = processed || calcMag<vector>();
|
||||
processed = processed || calcMag<sphericalTensor>();
|
||||
processed = processed || calcMag<symmTensor>();
|
||||
processed = processed || calcMag<tensor>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::mag::mag
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::mag::~mag()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
111
src/functionObjects/field/mag/mag.H
Normal file
111
src/functionObjects/field/mag/mag.H
Normal file
@ -0,0 +1,111 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::mag
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the magnitude of a field.
|
||||
|
||||
The operation can be applied to any volume or surface fields generating a
|
||||
volume or surface scalar field.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
mag.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_mag_H
|
||||
#define functionObjects_mag_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class mag Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class mag
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the magnitude of the field and register the result
|
||||
template<class Type>
|
||||
bool calcMag();
|
||||
|
||||
//- Calculate the magnitude of the field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("mag");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
mag
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~mag();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "magTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
60
src/functionObjects/field/mag/magTemplates.C
Normal file
60
src/functionObjects/field/mag/magTemplates.C
Normal file
@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::mag::calcMag()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
Foam::mag(lookupObject<VolFieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
Foam::mag(lookupObject<SurfaceFieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
78
src/functionObjects/field/magSqr/magSqr.C
Normal file
78
src/functionObjects/field/magSqr/magSqr.C
Normal file
@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "magSqr.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(magSqr, 0);
|
||||
addToRunTimeSelectionTable(functionObject, magSqr, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::magSqr::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcMagSqr<scalar>();
|
||||
processed = processed || calcMagSqr<vector>();
|
||||
processed = processed || calcMagSqr<sphericalTensor>();
|
||||
processed = processed || calcMagSqr<symmTensor>();
|
||||
processed = processed || calcMagSqr<tensor>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::magSqr::magSqr
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::magSqr::~magSqr()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
113
src/functionObjects/field/magSqr/magSqr.H
Normal file
113
src/functionObjects/field/magSqr/magSqr.H
Normal file
@ -0,0 +1,113 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::magSqr
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Calculates the magnitude of the sqr of a field.
|
||||
|
||||
The operation can be applied to any volume or surface field generating a
|
||||
volume or surface scalar field.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
magSqr.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_magSqr_H
|
||||
#define functionObjects_magSqr_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class magSqr Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class magSqr
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the magnitude of the sqr of the field
|
||||
// and register the result
|
||||
template<class Type>
|
||||
bool calcMagSqr();
|
||||
|
||||
//- Calculate the magnitude of the sqr of the field
|
||||
// and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("magSqr");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
magSqr
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~magSqr();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "magSqrTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
60
src/functionObjects/field/magSqr/magSqrTemplates.C
Normal file
60
src/functionObjects/field/magSqr/magSqrTemplates.C
Normal file
@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::magSqr::calcMagSqr()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
Foam::magSqr(lookupObject<VolFieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
Foam::magSqr(lookupObject<SurfaceFieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
237
src/functionObjects/field/nearWallFields/findCellParticle.C
Normal file
237
src/functionObjects/field/nearWallFields/findCellParticle.C
Normal file
@ -0,0 +1,237 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "findCellParticle.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::findCellParticle::findCellParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label celli,
|
||||
const label tetFacei,
|
||||
const label tetPtI,
|
||||
const point& end,
|
||||
const label data
|
||||
)
|
||||
:
|
||||
particle(mesh, position, celli, tetFacei, tetPtI),
|
||||
end_(end),
|
||||
data_(data)
|
||||
{}
|
||||
|
||||
|
||||
Foam::findCellParticle::findCellParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields
|
||||
)
|
||||
:
|
||||
particle(mesh, is, readFields)
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
is >> end_;
|
||||
data_ = readLabel(is);
|
||||
}
|
||||
else
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&end_),
|
||||
sizeof(end_) + sizeof(data_)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check
|
||||
(
|
||||
"findCellParticle::findCellParticle"
|
||||
"(const Cloud<findCellParticle>&, Istream&, bool)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::findCellParticle::move
|
||||
(
|
||||
trackingData& td,
|
||||
const scalar maxTrackLen
|
||||
)
|
||||
{
|
||||
td.switchProcessor = false;
|
||||
td.keepParticle = true;
|
||||
|
||||
scalar tEnd = (1.0 - stepFraction())*maxTrackLen;
|
||||
scalar dtMax = tEnd;
|
||||
|
||||
while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
|
||||
{
|
||||
// set the lagrangian time-step
|
||||
scalar dt = min(dtMax, tEnd);
|
||||
|
||||
dt *= trackToFace(end_, td);
|
||||
|
||||
tEnd -= dt;
|
||||
stepFraction() = 1.0 - tEnd/maxTrackLen;
|
||||
}
|
||||
|
||||
if (tEnd < SMALL || !td.keepParticle)
|
||||
{
|
||||
// Hit endpoint or patch. If patch hit could do fancy stuff but just
|
||||
// to use the patch point is good enough for now.
|
||||
td.cellToData()[cell()].append(data());
|
||||
td.cellToEnd()[cell()].append(position());
|
||||
}
|
||||
|
||||
return td.keepParticle;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::findCellParticle::hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
trackingData& td,
|
||||
const label patchi,
|
||||
const scalar trackFraction,
|
||||
const tetIndices& tetIs
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::findCellParticle::hitWedgePatch
|
||||
(
|
||||
const wedgePolyPatch&,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::findCellParticle::hitSymmetryPlanePatch
|
||||
(
|
||||
const symmetryPlanePolyPatch&,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::findCellParticle::hitSymmetryPatch
|
||||
(
|
||||
const symmetryPolyPatch&,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::findCellParticle::hitCyclicPatch
|
||||
(
|
||||
const cyclicPolyPatch&,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::findCellParticle::hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.switchProcessor = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::findCellParticle::hitWallPatch
|
||||
(
|
||||
const wallPolyPatch& wpp,
|
||||
trackingData& td,
|
||||
const tetIndices&
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::findCellParticle::hitPatch
|
||||
(
|
||||
const polyPatch& wpp,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const findCellParticle& p)
|
||||
{
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
os << static_cast<const particle&>(p)
|
||||
<< token::SPACE << p.end_
|
||||
<< token::SPACE << p.data_;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << static_cast<const particle&>(p);
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.end_),
|
||||
sizeof(p.end_) + sizeof(p.data_)
|
||||
);
|
||||
}
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const findCellParticle&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
274
src/functionObjects/field/nearWallFields/findCellParticle.H
Normal file
274
src/functionObjects/field/nearWallFields/findCellParticle.H
Normal file
@ -0,0 +1,274 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::findCellParticle
|
||||
|
||||
Description
|
||||
Particle class that finds cells by tracking
|
||||
|
||||
SourceFiles
|
||||
findCellParticle.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef findCellParticle_H
|
||||
#define findCellParticle_H
|
||||
|
||||
#include "particle.H"
|
||||
#include "autoPtr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class findCellParticleCloud;
|
||||
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class findCellParticle;
|
||||
|
||||
Ostream& operator<<(Ostream&, const findCellParticle&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class findCellParticle Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class findCellParticle
|
||||
:
|
||||
public particle
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- End point to track to
|
||||
point end_;
|
||||
|
||||
//- Passive data
|
||||
label data_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
friend class Cloud<findCellParticle>;
|
||||
|
||||
//- Class used to pass tracking data to the trackToFace function
|
||||
class trackingData
|
||||
:
|
||||
public particle::TrackingData<Cloud<findCellParticle>>
|
||||
{
|
||||
labelListList& cellToData_;
|
||||
List<List<point>>& cellToEnd_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
trackingData
|
||||
(
|
||||
Cloud<findCellParticle>& cloud,
|
||||
labelListList& cellToData,
|
||||
List<List<point>>& cellToEnd
|
||||
)
|
||||
:
|
||||
particle::TrackingData<Cloud<findCellParticle>>(cloud),
|
||||
cellToData_(cellToData),
|
||||
cellToEnd_(cellToEnd)
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
labelListList& cellToData()
|
||||
{
|
||||
return cellToData_;
|
||||
}
|
||||
|
||||
List<List<point>>& cellToEnd()
|
||||
{
|
||||
return cellToEnd_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
findCellParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label celli,
|
||||
const label tetFacei,
|
||||
const label tetPtI,
|
||||
const point& end,
|
||||
const label data
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
findCellParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields = true
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
autoPtr<particle> clone() const
|
||||
{
|
||||
return autoPtr<particle>(new findCellParticle(*this));
|
||||
}
|
||||
|
||||
//- Factory class to read-construct particles used for
|
||||
// parallel transfer
|
||||
class iNew
|
||||
{
|
||||
const polyMesh& mesh_;
|
||||
|
||||
public:
|
||||
|
||||
iNew(const polyMesh& mesh)
|
||||
:
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
autoPtr<findCellParticle> operator()(Istream& is) const
|
||||
{
|
||||
return autoPtr<findCellParticle>
|
||||
(
|
||||
new findCellParticle(mesh_, is, true)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Point to track to
|
||||
const point& end() const
|
||||
{
|
||||
return end_;
|
||||
}
|
||||
|
||||
//- Transported label
|
||||
label data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
|
||||
// Tracking
|
||||
|
||||
//- Track all particles to their end point
|
||||
bool move(trackingData&, const scalar);
|
||||
|
||||
|
||||
//- Overridable function to handle the particle hitting a patch
|
||||
// Executed before other patch-hitting functions
|
||||
bool hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
trackingData& td,
|
||||
const label patchi,
|
||||
const scalar trackFraction,
|
||||
const tetIndices& tetIs
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a wedge
|
||||
void hitWedgePatch
|
||||
(
|
||||
const wedgePolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a
|
||||
// symmetry plane
|
||||
void hitSymmetryPlanePatch
|
||||
(
|
||||
const symmetryPlanePolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a
|
||||
// symmetry patch
|
||||
void hitSymmetryPatch
|
||||
(
|
||||
const symmetryPolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a cyclic
|
||||
void hitCyclicPatch
|
||||
(
|
||||
const cyclicPolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a
|
||||
//- processorPatch
|
||||
void hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a wallPatch
|
||||
void hitWallPatch
|
||||
(
|
||||
const wallPolyPatch&,
|
||||
trackingData& td,
|
||||
const tetIndices&
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a polyPatch
|
||||
void hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const findCellParticle&);
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
inline bool contiguous<findCellParticle>()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "findCellParticle.H"
|
||||
#include "Cloud.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTemplateTypeNameAndDebug(Cloud<findCellParticle>, 0);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
362
src/functionObjects/field/nearWallFields/nearWallFields.C
Normal file
362
src/functionObjects/field/nearWallFields/nearWallFields.C
Normal file
@ -0,0 +1,362 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nearWallFields.H"
|
||||
#include "wordReList.H"
|
||||
#include "findCellParticle.H"
|
||||
#include "mappedPatchBase.H"
|
||||
#include "OBJstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(nearWallFields, 0);
|
||||
addToRunTimeSelectionTable(functionObject, nearWallFields, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
{
|
||||
// Count number of faces
|
||||
label nPatchFaces = 0;
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
nPatchFaces += mesh_.boundary()[patchi].size();
|
||||
}
|
||||
|
||||
// Global indexing
|
||||
globalIndex globalWalls(nPatchFaces);
|
||||
|
||||
DebugInFunction << "nPatchFaces: " << globalWalls.size() << endl;
|
||||
|
||||
// Construct cloud
|
||||
Cloud<findCellParticle> cloud(mesh_, IDLList<findCellParticle>());
|
||||
|
||||
// Add particles to track to sample locations
|
||||
nPatchFaces = 0;
|
||||
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
const fvPatch& patch = mesh_.boundary()[patchi];
|
||||
|
||||
vectorField nf(patch.nf());
|
||||
vectorField faceCellCentres(patch.patch().faceCellCentres());
|
||||
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
label meshFacei = patch.start()+patchFacei;
|
||||
|
||||
// Find starting point on face (since faceCentre might not
|
||||
// be on face-diagonal decomposition)
|
||||
pointIndexHit startInfo
|
||||
(
|
||||
mappedPatchBase::facePoint
|
||||
(
|
||||
mesh_,
|
||||
meshFacei,
|
||||
polyMesh::FACE_DIAG_TRIS
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
point start;
|
||||
if (startInfo.hit())
|
||||
{
|
||||
start = startInfo.hitPoint();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback: start tracking from neighbouring cell centre
|
||||
start = faceCellCentres[patchFacei];
|
||||
}
|
||||
|
||||
const point end = start-distance_*nf[patchFacei];
|
||||
|
||||
// Find tet for starting location
|
||||
label celli = -1;
|
||||
label tetFacei = -1;
|
||||
label tetPti = -1;
|
||||
mesh_.findCellFacePt(start, celli, tetFacei, tetPti);
|
||||
|
||||
// Add to cloud. Add originating face as passive data
|
||||
cloud.addParticle
|
||||
(
|
||||
new findCellParticle
|
||||
(
|
||||
mesh_,
|
||||
start,
|
||||
celli,
|
||||
tetFacei,
|
||||
tetPti,
|
||||
end,
|
||||
globalWalls.toGlobal(nPatchFaces) // passive data
|
||||
)
|
||||
);
|
||||
|
||||
nPatchFaces++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// Dump particles
|
||||
OBJstream str
|
||||
(
|
||||
mesh_.time().path()
|
||||
/"wantedTracks_" + mesh_.time().timeName() + ".obj"
|
||||
);
|
||||
InfoInFunction << "Dumping tracks to " << str.name() << endl;
|
||||
|
||||
forAllConstIter(Cloud<findCellParticle>, cloud, iter)
|
||||
{
|
||||
const findCellParticle& tp = iter();
|
||||
str.write(linePointRef(tp.position(), tp.end()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Per cell: empty or global wall index and end location
|
||||
cellToWalls_.setSize(mesh_.nCells());
|
||||
cellToSamples_.setSize(mesh_.nCells());
|
||||
|
||||
// Database to pass into findCellParticle::move
|
||||
findCellParticle::trackingData td(cloud, cellToWalls_, cellToSamples_);
|
||||
|
||||
// Track all particles to their end position.
|
||||
scalar maxTrackLen = 2.0*mesh_.bounds().mag();
|
||||
|
||||
|
||||
//Debug: collect start points
|
||||
pointField start;
|
||||
if (debug)
|
||||
{
|
||||
start.setSize(nPatchFaces);
|
||||
nPatchFaces = 0;
|
||||
forAllConstIter(Cloud<findCellParticle>, cloud, iter)
|
||||
{
|
||||
const findCellParticle& tp = iter();
|
||||
start[nPatchFaces++] = tp.position();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cloud.move(td, maxTrackLen);
|
||||
|
||||
|
||||
// Rework cell-to-globalpatchface into a map
|
||||
List<Map<label>> compactMap;
|
||||
getPatchDataMapPtr_.reset
|
||||
(
|
||||
new mapDistribute
|
||||
(
|
||||
globalWalls,
|
||||
cellToWalls_,
|
||||
compactMap
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Debug: dump resulting tracks
|
||||
if (debug)
|
||||
{
|
||||
getPatchDataMapPtr_().distribute(start);
|
||||
{
|
||||
OBJstream str
|
||||
(
|
||||
mesh_.time().path()
|
||||
/"obtainedTracks_" + mesh_.time().timeName() + ".obj"
|
||||
);
|
||||
InfoInFunction << "Dumping obtained to " << str.name() << endl;
|
||||
|
||||
forAll(cellToWalls_, celli)
|
||||
{
|
||||
const List<point>& ends = cellToSamples_[celli];
|
||||
const labelList& cData = cellToWalls_[celli];
|
||||
forAll(cData, i)
|
||||
{
|
||||
str.write(linePointRef(ends[i], start[cData[i]]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::nearWallFields::nearWallFields
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::nearWallFields::~nearWallFields()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
patchSet_ =
|
||||
mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches")));
|
||||
distance_ = readScalar(dict.lookup("distance"));
|
||||
|
||||
|
||||
// Clear out any previously loaded fields
|
||||
vsf_.clear();
|
||||
vvf_.clear();
|
||||
vSpheretf_.clear();
|
||||
vSymmtf_.clear();
|
||||
vtf_.clear();
|
||||
fieldMap_.clear();
|
||||
reverseFieldMap_.clear();
|
||||
|
||||
|
||||
// Generate fields with mappedField boundary condition
|
||||
|
||||
// Convert field to map
|
||||
fieldMap_.resize(2*fieldSet_.size());
|
||||
reverseFieldMap_.resize(2*fieldSet_.size());
|
||||
forAll(fieldSet_, setI)
|
||||
{
|
||||
const word& fldName = fieldSet_[setI].first();
|
||||
const word& sampleFldName = fieldSet_[setI].second();
|
||||
|
||||
fieldMap_.insert(fldName, sampleFldName);
|
||||
reverseFieldMap_.insert(sampleFldName, fldName);
|
||||
}
|
||||
|
||||
Log << type() << " " << name()
|
||||
<< ": Sampling " << fieldMap_.size() << " fields" << endl;
|
||||
|
||||
// Do analysis
|
||||
calcAddressing();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::nearWallFields::execute()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
if
|
||||
(
|
||||
fieldMap_.size()
|
||||
&& vsf_.empty()
|
||||
&& vvf_.empty()
|
||||
&& vSpheretf_.empty()
|
||||
&& vSymmtf_.empty()
|
||||
&& vtf_.empty()
|
||||
)
|
||||
{
|
||||
Log << type() << " " << name()
|
||||
<< ": Creating " << fieldMap_.size() << " fields" << endl;
|
||||
|
||||
createFields(vsf_);
|
||||
createFields(vvf_);
|
||||
createFields(vSpheretf_);
|
||||
createFields(vSymmtf_);
|
||||
createFields(vtf_);
|
||||
|
||||
Log << endl;
|
||||
}
|
||||
|
||||
Log << type() << " " << name()
|
||||
<< " write:" << nl
|
||||
<< " Sampling fields to " << time_.timeName()
|
||||
<< endl;
|
||||
|
||||
sampleFields(vsf_);
|
||||
sampleFields(vvf_);
|
||||
sampleFields(vSpheretf_);
|
||||
sampleFields(vSymmtf_);
|
||||
sampleFields(vtf_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::nearWallFields::write()
|
||||
{
|
||||
DebugInFunction << endl;
|
||||
|
||||
Log << " Writing sampled fields to " << time_.timeName()
|
||||
<< endl;
|
||||
|
||||
forAll(vsf_, i)
|
||||
{
|
||||
vsf_[i].write();
|
||||
}
|
||||
forAll(vvf_, i)
|
||||
{
|
||||
vvf_[i].write();
|
||||
}
|
||||
forAll(vSpheretf_, i)
|
||||
{
|
||||
vSpheretf_[i].write();
|
||||
}
|
||||
forAll(vSymmtf_, i)
|
||||
{
|
||||
vSymmtf_[i].write();
|
||||
}
|
||||
forAll(vtf_, i)
|
||||
{
|
||||
vtf_[i].write();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
233
src/functionObjects/field/nearWallFields/nearWallFields.H
Normal file
233
src/functionObjects/field/nearWallFields/nearWallFields.H
Normal file
@ -0,0 +1,233 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::nearWallFields
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Samples near-patch volume fields.
|
||||
|
||||
Fields are stored
|
||||
- every time step the field is updated with new values
|
||||
- at output it writes the fields
|
||||
|
||||
This functionObject can either be used
|
||||
- to calculate a new field as a post-processing step or
|
||||
- since the fields are registered, used in another functionObject
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
nearWallFields1
|
||||
{
|
||||
type nearWallFields;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
writeControl writeTime;
|
||||
|
||||
fields
|
||||
(
|
||||
(p pNear)
|
||||
(U UNear)
|
||||
);
|
||||
|
||||
patches (movingWall);
|
||||
|
||||
distance 0.13;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: nearWallFields | yes |
|
||||
fields | list of fields with corresponding output field names | yes |
|
||||
patches | list of patches to sample | yes |
|
||||
distance | distance from patch to sample | yes |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
nearWallFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_nearWallFields_H
|
||||
#define functionObjects_nearWallFields_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "volFields.H"
|
||||
#include "Tuple2.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class nearWallFields Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class nearWallFields
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected member data
|
||||
|
||||
// Read from dictionary
|
||||
|
||||
//- Fields to process
|
||||
List<Tuple2<word, word>> fieldSet_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Patches to sample
|
||||
labelHashSet patchSet_;
|
||||
|
||||
//- Distance away from wall
|
||||
scalar distance_;
|
||||
|
||||
//- From original field to sampled result
|
||||
HashTable<word> fieldMap_;
|
||||
|
||||
//- From resulting back to original field
|
||||
HashTable<word> reverseFieldMap_;
|
||||
|
||||
|
||||
// Calculated addressing
|
||||
|
||||
//- From cell to seed patch faces
|
||||
labelListList cellToWalls_;
|
||||
|
||||
//- From cell to tracked end point
|
||||
List<List<point>> cellToSamples_;
|
||||
|
||||
//- Map from cell based data back to patch based data
|
||||
autoPtr<mapDistribute> getPatchDataMapPtr_;
|
||||
|
||||
|
||||
// Locally constructed fields
|
||||
|
||||
PtrList<volScalarField> vsf_;
|
||||
PtrList<volVectorField> vvf_;
|
||||
PtrList<volSphericalTensorField> vSpheretf_;
|
||||
PtrList<volSymmTensorField> vSymmtf_;
|
||||
PtrList<volTensorField> vtf_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Calculate addressing from cells back to patch faces
|
||||
void calcAddressing();
|
||||
|
||||
template<class Type>
|
||||
void createFields
|
||||
(
|
||||
PtrList<GeometricField<Type, fvPatchField, volMesh>>&
|
||||
) const;
|
||||
|
||||
//- Override boundary fields with sampled values
|
||||
template<class Type>
|
||||
void sampleBoundaryField
|
||||
(
|
||||
const interpolationCellPoint<Type>& interpolator,
|
||||
GeometricField<Type, fvPatchField, volMesh>& fld
|
||||
) const;
|
||||
|
||||
template<class Type>
|
||||
void sampleFields
|
||||
(
|
||||
PtrList<GeometricField<Type, fvPatchField, volMesh>>&
|
||||
) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
nearWallFields(const nearWallFields&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const nearWallFields&);
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("nearWallFields");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
nearWallFields
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~nearWallFields();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the controls
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the near-wall fields
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the near-wall fields
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "nearWallFieldsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,150 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nearWallFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::nearWallFields::createFields
|
||||
(
|
||||
PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
HashTable<const VolFieldType*> flds(obr_.lookupClass<VolFieldType>());
|
||||
|
||||
forAllConstIter(typename HashTable<const VolFieldType*>, flds, iter)
|
||||
{
|
||||
const VolFieldType& fld = *iter();
|
||||
|
||||
if (fieldMap_.found(fld.name()))
|
||||
{
|
||||
const word& sampleFldName = fieldMap_[fld.name()];
|
||||
|
||||
if (obr_.found(sampleFldName))
|
||||
{
|
||||
WarningInFunction
|
||||
<< " a field named " << sampleFldName
|
||||
<< " already exists on the mesh"
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
label sz = sflds.size();
|
||||
sflds.setSize(sz+1);
|
||||
|
||||
IOobject io(fld);
|
||||
io.readOpt() = IOobject::NO_READ;
|
||||
io.writeOpt() = IOobject::NO_WRITE;
|
||||
io.rename(sampleFldName);
|
||||
|
||||
sflds.set(sz, new VolFieldType(io, fld));
|
||||
|
||||
Log << " created " << sflds[sz].name()
|
||||
<< " to sample " << fld.name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::nearWallFields::sampleBoundaryField
|
||||
(
|
||||
const interpolationCellPoint<Type>& interpolator,
|
||||
GeometricField<Type, fvPatchField, volMesh>& fld
|
||||
) const
|
||||
{
|
||||
// Construct flat fields for all patch faces to be sampled
|
||||
Field<Type> sampledValues(getPatchDataMapPtr_().constructSize());
|
||||
|
||||
forAll(cellToWalls_, celli)
|
||||
{
|
||||
const labelList& cData = cellToWalls_[celli];
|
||||
|
||||
forAll(cData, i)
|
||||
{
|
||||
const point& samplePt = cellToSamples_[celli][i];
|
||||
sampledValues[cData[i]] = interpolator.interpolate(samplePt, celli);
|
||||
}
|
||||
}
|
||||
|
||||
// Send back sampled values to patch faces
|
||||
getPatchDataMapPtr_().reverseDistribute
|
||||
(
|
||||
getPatchDataMapPtr_().constructSize(),
|
||||
sampledValues
|
||||
);
|
||||
|
||||
typename GeometricField<Type, fvPatchField, volMesh>::
|
||||
Boundary& fldBf = fld.boundaryFieldRef();
|
||||
|
||||
// Pick up data
|
||||
label nPatchFaces = 0;
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
|
||||
fvPatchField<Type>& pfld = fldBf[patchi];
|
||||
|
||||
Field<Type> newFld(pfld.size());
|
||||
forAll(pfld, i)
|
||||
{
|
||||
newFld[i] = sampledValues[nPatchFaces++];
|
||||
}
|
||||
|
||||
pfld == newFld;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::nearWallFields::sampleFields
|
||||
(
|
||||
PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
forAll(sflds, i)
|
||||
{
|
||||
const word& fldName = reverseFieldMap_[sflds[i].name()];
|
||||
const VolFieldType& fld = obr_.lookupObject<VolFieldType>(fldName);
|
||||
|
||||
// Take over internal and boundary values
|
||||
sflds[i] == fld;
|
||||
|
||||
// Construct interpolation method
|
||||
interpolationCellPoint<Type> interpolator(fld);
|
||||
|
||||
// Override sampled values
|
||||
sampleBoundaryField(interpolator, sflds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
275
src/functionObjects/field/pressure/pressure.C
Normal file
275
src/functionObjects/field/pressure/pressure.C
Normal file
@ -0,0 +1,275 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pressure.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(pressure, 0);
|
||||
addToRunTimeSelectionTable(functionObject, pressure, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::functionObjects::pressure::resultName() const
|
||||
{
|
||||
word rName;
|
||||
|
||||
if (calcTotal_)
|
||||
{
|
||||
rName = "total(" + fieldName_ + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
rName = "static(" + fieldName_ + ")";
|
||||
}
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
rName += "_coeff";
|
||||
}
|
||||
|
||||
return rName;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
if (p.dimensions() == dimPressure)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!rhoInfInitialised_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name_ << ": "
|
||||
<< "pressure identified as incompressible, but reference "
|
||||
<< "density is not set. Please set rhoName to rhoInf, and "
|
||||
<< "set an appropriate value for rhoInf"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return dimensionedScalar("rhoInf", dimDensity, rhoInf_)*p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
|
||||
(
|
||||
const volScalarField& p,
|
||||
const tmp<volScalarField>& tsf
|
||||
) const
|
||||
{
|
||||
if (p.dimensions() == dimPressure)
|
||||
{
|
||||
return lookupObject<volScalarField>(rhoName_)*tsf;
|
||||
}
|
||||
else
|
||||
{
|
||||
return dimensionedScalar("rhoInf", dimDensity, rhoInf_)*tsf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::pRef
|
||||
(
|
||||
const tmp<volScalarField>& tp
|
||||
) const
|
||||
{
|
||||
if (calcTotal_)
|
||||
{
|
||||
return tp + dimensionedScalar("pRef", dimPressure, pRef_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::move(tp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::pDyn
|
||||
(
|
||||
const volScalarField& p,
|
||||
const tmp<volScalarField>& tp
|
||||
) const
|
||||
{
|
||||
if (calcTotal_)
|
||||
{
|
||||
return
|
||||
tp
|
||||
+ rhoScale(p, 0.5*magSqr(lookupObject<volVectorField>(UName_)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::move(tp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::coeff
|
||||
(
|
||||
const tmp<volScalarField>& tp
|
||||
) const
|
||||
{
|
||||
if (calcCoeff_)
|
||||
{
|
||||
tmp<volScalarField> tpCoeff(tp.ptr());
|
||||
volScalarField& pCoeff = tpCoeff.ref();
|
||||
|
||||
pCoeff -= dimensionedScalar("pInf", dimPressure, pInf_);
|
||||
|
||||
const dimensionedScalar pSmall("pSmall", dimPressure, SMALL);
|
||||
const dimensionedVector U("U", dimVelocity, UInf_);
|
||||
const dimensionedScalar rho("rho", dimDensity, rhoInf_);
|
||||
|
||||
pCoeff /= 0.5*rho*magSqr(U) + pSmall;
|
||||
|
||||
return tpCoeff;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::move(tp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::pressure::calc()
|
||||
{
|
||||
if (foundObject<volScalarField>(fieldName_))
|
||||
{
|
||||
const volScalarField& p = lookupObject<volScalarField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
coeff(pRef(pDyn(p, rhoScale(p))))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::pressure::pressure
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "p"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
calcTotal_(false),
|
||||
pRef_(0),
|
||||
calcCoeff_(false),
|
||||
pInf_(0),
|
||||
UInf_(Zero),
|
||||
rhoInf_(1),
|
||||
rhoInfInitialised_(false)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
dimensionSet pDims(dimPressure);
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
pDims /= dimPressure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::pressure::~pressure()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::pressure::read(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("U", UName_);
|
||||
dict.readIfPresent("rho", rhoName_);
|
||||
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoInf_;
|
||||
rhoInfInitialised_ = true;
|
||||
}
|
||||
|
||||
dict.lookup("calcTotal") >> calcTotal_;
|
||||
if (calcTotal_)
|
||||
{
|
||||
dict.lookup("pRef") >> pRef_;
|
||||
}
|
||||
|
||||
dict.lookup("calcCoeff") >> calcCoeff_;
|
||||
if (calcCoeff_)
|
||||
{
|
||||
dict.lookup("pInf") >> pInf_;
|
||||
dict.lookup("UInf") >> UInf_;
|
||||
dict.lookup("rhoInf") >> rhoInf_;
|
||||
|
||||
scalar zeroCheck = 0.5*rhoInf_*magSqr(UInf_) + pInf_;
|
||||
|
||||
if (mag(zeroCheck) < ROOTVSMALL)
|
||||
{
|
||||
WarningInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< "Coefficient calculation requested, but reference "
|
||||
<< "pressure level is zero. Please check the supplied "
|
||||
<< "values of pInf, UInf and rhoInf" << endl;
|
||||
}
|
||||
|
||||
rhoInfInitialised_ = true;
|
||||
}
|
||||
|
||||
resultName_ = dict.lookupOrDefault<word>("result", resultName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
243
src/functionObjects/field/pressure/pressure.H
Normal file
243
src/functionObjects/field/pressure/pressure.H
Normal file
@ -0,0 +1,243 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::pressure
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Includes tools to manipulate the pressure into different forms.
|
||||
|
||||
These currently include:
|
||||
- static pressure
|
||||
\f[
|
||||
p = \rho p_k
|
||||
\f]
|
||||
- total pressure
|
||||
\f[
|
||||
p_0 = p_{ref} + p + 0.5 \rho |U|^2
|
||||
\f]
|
||||
- static pressure coefficient
|
||||
\f[
|
||||
Cp = \frac{p - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
|
||||
\f]
|
||||
- total pressure coefficient
|
||||
\f[
|
||||
Cp_0 = \frac{p_0 - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
|
||||
\f]
|
||||
|
||||
where
|
||||
\vartable
|
||||
\rho | Density [kg/m3]
|
||||
U | Velocity [m/s]
|
||||
\rho_{\inf} | Freestream density [kg/m3]
|
||||
p_{\inf} | Freestream pressure [Pa]
|
||||
U_{\inf} | Freestream velocity [m/s]
|
||||
p_k | Kinematic pressure (p/rho)[m2/s2]
|
||||
p | Pressure [Pa]
|
||||
p_0 | Total pressure [Pa]
|
||||
p_{ref} | Reference pressure level [Pa]
|
||||
Cp | Pressure coefficient
|
||||
Cp_0 | Total pressure coefficient
|
||||
\endvartable
|
||||
|
||||
The function object will operate on both kinematic (\f$ p_k \f$) and static
|
||||
pressure (\f$ p \f$) fields, and the result is written as a
|
||||
volScalarField.
|
||||
|
||||
The modes of operation are:
|
||||
\table
|
||||
Mode | calcTotal | calcCoeff
|
||||
Static pressure | no | no
|
||||
Total pressure | yes | no
|
||||
Pressure coefficient | no | yes
|
||||
Total pressure coefficient | yes | yes
|
||||
\endtable
|
||||
|
||||
Example of function object specification to calculate pressure coefficient:
|
||||
\verbatim
|
||||
pressure1
|
||||
{
|
||||
type pressure;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
calcTotal no;
|
||||
calcCoeff yes;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: pressure | yes |
|
||||
field | Name of the pressure field | no | p
|
||||
U | Name of the velocity field | no | U
|
||||
rho | Name of the density field | no | rho
|
||||
result | Name of the resulting field | no | derived from p
|
||||
calcTotal | Calculate total coefficient | yes |
|
||||
pRef | Reference pressure for total pressure | no | 0
|
||||
calcCoeff | Calculate pressure coefficient | yes |
|
||||
pInf | Freestream pressure for coefficient calculation | no |
|
||||
UInf | Freestream velocity for coefficient calculation | no |
|
||||
rhoInf | Freestream density for coefficient calculation | no |
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
pressure.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_pressure_H
|
||||
#define functionObjects_pressure_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "dimensionedScalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pressure Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pressure
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of velocity field, default is "U"
|
||||
word UName_;
|
||||
|
||||
//- Name of density field, default is "rho"
|
||||
word rhoName_;
|
||||
|
||||
//- Flag to show whether rhoInf has been initialised
|
||||
bool rhoInfInitialised_;
|
||||
|
||||
|
||||
// Total pressure calculation
|
||||
|
||||
//- Flag to calculate total pressure
|
||||
bool calcTotal_;
|
||||
|
||||
//- Reference pressure level
|
||||
scalar pRef_;
|
||||
|
||||
|
||||
// Pressure coefficient calculation
|
||||
|
||||
//- Flag to calculate pressure coefficient
|
||||
bool calcCoeff_;
|
||||
|
||||
//- Freestream pressure
|
||||
scalar pInf_;
|
||||
|
||||
//- Freestream velocity
|
||||
vector UInf_;
|
||||
|
||||
//- Freestream density
|
||||
scalar rhoInf_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return the name of the derived pressure field
|
||||
word resultName() const;
|
||||
|
||||
//- Multiply the static pressure p by rhoInf if necessary and return
|
||||
tmp<volScalarField> rhoScale(const volScalarField& p) const;
|
||||
|
||||
//- Multiply the given field by rho or rhoInf as appropriate and return
|
||||
tmp<volScalarField> rhoScale
|
||||
(
|
||||
const volScalarField& p,
|
||||
const tmp<volScalarField>& tsf
|
||||
) const;
|
||||
|
||||
//- Return the reference pressure
|
||||
tmp<volScalarField> pRef(const tmp<volScalarField>& tp) const;
|
||||
|
||||
//- Calculate and return the dynamic pressure
|
||||
tmp<volScalarField> pDyn
|
||||
(
|
||||
const volScalarField& p,
|
||||
const tmp<volScalarField>& tp
|
||||
) const;
|
||||
|
||||
//- Convert to coeff by applying the freestream dynamic pressure scaling
|
||||
tmp<volScalarField> coeff(const tmp<volScalarField>& tp) const;
|
||||
|
||||
//- Calculate the derived pressure field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pressure");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
pressure
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pressure();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the pressure data
|
||||
virtual bool read(const dictionary&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
35
src/functionObjects/field/processorField/postProcessingDict
Normal file
35
src/functionObjects/field/processorField/postProcessingDict
Normal file
@ -0,0 +1,35 @@
|
||||
/*--------------------------------*- 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 dictionary;
|
||||
object postProcessingDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
functions
|
||||
{
|
||||
processorField1
|
||||
{
|
||||
// Type of functionObject
|
||||
type processorField;
|
||||
|
||||
// Where to load it from (if not already in solver)
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
// Function object enabled flag
|
||||
enabled true;
|
||||
|
||||
// When to output the average fields
|
||||
writeControl writeTime;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
115
src/functionObjects/field/processorField/processorField.C
Normal file
115
src/functionObjects/field/processorField/processorField.C
Normal file
@ -0,0 +1,115 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "processorField.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(processorField, 0);
|
||||
addToRunTimeSelectionTable(functionObject, processorField, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::processorField::processorField
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
volScalarField* procFieldPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"processorID",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh_.objectRegistry::store(procFieldPtr);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::processorField::~processorField()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::processorField::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::processorField::execute()
|
||||
{
|
||||
const volScalarField& procField =
|
||||
mesh_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
const_cast<volScalarField&>(procField) ==
|
||||
dimensionedScalar("proci", dimless, Pstream::myProcNo());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::processorField::write()
|
||||
{
|
||||
const volScalarField& procField =
|
||||
mesh_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
procField.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
137
src/functionObjects/field/processorField/processorField.H
Normal file
137
src/functionObjects/field/processorField/processorField.H
Normal file
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::processorField
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Writes a scalar field whose value is the local processor ID. The output
|
||||
field name is 'processorID'.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
processorField1
|
||||
{
|
||||
type processorField;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: processorField | yes |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
processorField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_processorField_H
|
||||
#define functionObjects_processorField_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class processorField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class processorField
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
|
||||
//- Result name
|
||||
word resultName_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
processorField(const processorField&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const processorField&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("processorField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
processorField
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~processorField();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the input data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the processorID field
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the processorID field
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
90
src/functionObjects/field/randomise/randomise.C
Normal file
90
src/functionObjects/field/randomise/randomise.C
Normal file
@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "randomise.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(randomise, 0);
|
||||
addToRunTimeSelectionTable(functionObject, randomise, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::randomise::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcRandomised<scalar>();
|
||||
processed = processed || calcRandomised<vector>();
|
||||
processed = processed || calcRandomised<sphericalTensor>();
|
||||
processed = processed || calcRandomised<symmTensor>();
|
||||
processed = processed || calcRandomised<tensor>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::randomise::randomise
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::randomise::~randomise()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::randomise::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
dict.lookup("magPerturbation") >> magPerturbation_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
122
src/functionObjects/field/randomise/randomise.H
Normal file
122
src/functionObjects/field/randomise/randomise.H
Normal file
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::randomise
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Adds a random component to a field, with a specified perturbation magnitude.
|
||||
|
||||
The operation can be applied to any volume field.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
randomise.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_randomise_H
|
||||
#define functionObjects_randomise_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class randomise Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class randomise
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private member data
|
||||
|
||||
//- The magnitude of the purturbation
|
||||
scalar magPerturbation_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the randomisenitude of the field and register the result
|
||||
template<class Type>
|
||||
bool calcRandomised();
|
||||
|
||||
//- Calculate the randomised field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("randomise");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
randomise
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~randomise();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the randomise data
|
||||
virtual bool read(const dictionary&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "randomiseTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
65
src/functionObjects/field/randomise/randomiseTemplates.C
Normal file
65
src/functionObjects/field/randomise/randomiseTemplates.C
Normal file
@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volFields.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::randomise::calcRandomised()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
const VolFieldType& field = lookupObject<VolFieldType>(fieldName_);
|
||||
|
||||
resultName_ = fieldName_ + "Random";
|
||||
|
||||
tmp<VolFieldType> rfieldt(new VolFieldType(field));
|
||||
VolFieldType& rfield = rfieldt.ref();
|
||||
|
||||
Random rand(1234567);
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
Type rndPert;
|
||||
rand.randomise(rndPert);
|
||||
rndPert = 2.0*rndPert - pTraits<Type>::one;
|
||||
rndPert /= mag(rndPert);
|
||||
rfield[celli] += magPerturbation_*rndPert;
|
||||
}
|
||||
|
||||
return store(resultName_, rfieldt);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
53
src/functionObjects/field/readFields/postProcessingDict
Normal file
53
src/functionObjects/field/readFields/postProcessingDict
Normal file
@ -0,0 +1,53 @@
|
||||
/*--------------------------------*- 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 dictionary;
|
||||
object postProcessingDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
functions
|
||||
{
|
||||
readFields1
|
||||
{
|
||||
type readFields;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
enabled true;
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
|
||||
fields
|
||||
(
|
||||
interpolateU
|
||||
);
|
||||
}
|
||||
|
||||
faceObj2
|
||||
{
|
||||
type surfaceFieldValue;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
enabled true;
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
log true;
|
||||
writeFields true;
|
||||
regionType faceZone;
|
||||
name f0;
|
||||
operation areaAverage;
|
||||
|
||||
fields
|
||||
(
|
||||
interpolateU
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
101
src/functionObjects/field/readFields/readFields.C
Normal file
101
src/functionObjects/field/readFields/readFields.C
Normal file
@ -0,0 +1,101 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "readFields.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(readFields, 0);
|
||||
addToRunTimeSelectionTable(functionObject, readFields, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::readFields::readFields
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::readFields::~readFields()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::readFields::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::readFields::execute()
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldSet_[fieldi];
|
||||
|
||||
// If necessary load field
|
||||
loadField<scalar>(fieldName, vsf_, ssf_);
|
||||
loadField<vector>(fieldName, vvf_, svf_);
|
||||
loadField<sphericalTensor>(fieldName, vSpheretf_, sSpheretf_);
|
||||
loadField<symmTensor>(fieldName, vSymmtf_, sSymmtf_);
|
||||
loadField<tensor>(fieldName, vtf_, stf_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::readFields::write()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
161
src/functionObjects/field/readFields/readFields.H
Normal file
161
src/functionObjects/field/readFields/readFields.H
Normal file
@ -0,0 +1,161 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::readFields
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Reads fields from the time directories and adds them to the mesh database
|
||||
for further post-processing.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
readFields1
|
||||
{
|
||||
type readFields;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
fields (U p);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: readFields | yes |
|
||||
fields | list of fields to read | no |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
readFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_readFields_H
|
||||
#define functionObjects_readFields_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class readFields Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class readFields
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Fields to load
|
||||
wordList fieldSet_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
template<class Type>
|
||||
bool loadField(const word&) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
readFields(const readFields&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const readFields&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("readFields");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
readFields
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~readFields();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the set of fields from dictionary
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Read the fields
|
||||
virtual bool execute();
|
||||
|
||||
//- Do nothing
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "readFieldsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
93
src/functionObjects/field/readFields/readFieldsTemplates.C
Normal file
93
src/functionObjects/field/readFields/readFieldsTemplates.C
Normal file
@ -0,0 +1,93 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "readFields.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::readFields::loadField(const word& fieldName) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (obr_.foundObject<VolFieldType>(fieldName))
|
||||
{
|
||||
DebugInfo
|
||||
<< "readFields : " << VolFieldType::typeName
|
||||
<< " " << fieldName << " already in database"
|
||||
<< endl;
|
||||
}
|
||||
else if (obr_.foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
DebugInfo<< "readFields: " << SurfaceFieldType::typeName
|
||||
<< " " << fieldName << " already exists in database"
|
||||
<< " already in database" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
fieldHeader.typeHeaderOk<vfType>(false)
|
||||
&& fieldHeader.headerClassName() == VolFieldType::typeName
|
||||
)
|
||||
{
|
||||
// Store field on mesh database
|
||||
Log << " Reading " << fieldName << endl;
|
||||
tmp<VolFieldType> tvf(new VolFieldType(fieldHeader, mesh));
|
||||
store(tvf, fieldName);
|
||||
return true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.typeHeaderOk<sfType>(false)
|
||||
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName
|
||||
)
|
||||
{
|
||||
// Store field on mesh database
|
||||
Log << " Reading " << fieldName << endl;
|
||||
tmp<SurfaceFieldType> tsf(new SurfaceFieldType(fieldHeader, mesh));
|
||||
store(tsf, fieldName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,981 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "regionSizeDistribution.H"
|
||||
#include "fvcVolumeIntegrate.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(regionSizeDistribution, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
regionSizeDistribution,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
//- Plus op for FixedList<scalar>
|
||||
template<class T, unsigned Size>
|
||||
class ListPlusEqOp
|
||||
{
|
||||
public:
|
||||
void operator()
|
||||
(
|
||||
FixedList<T, Size>& x,
|
||||
const FixedList<T, Size>& y
|
||||
) const
|
||||
{
|
||||
forAll(x, i)
|
||||
{
|
||||
x[i] += y[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::regionSizeDistribution::writeGraph
|
||||
(
|
||||
const coordSet& coords,
|
||||
const word& valueName,
|
||||
const scalarField& values
|
||||
) const
|
||||
{
|
||||
const wordList valNames(1, valueName);
|
||||
|
||||
fileName outputPath = baseTimeDir();
|
||||
mkDir(outputPath);
|
||||
|
||||
OFstream str(outputPath/formatterPtr_().getFileName(coords, valNames));
|
||||
|
||||
Log << " Writing distribution of " << valueName << " to " << str.name()
|
||||
<< endl;
|
||||
|
||||
List<const scalarField*> valPtrs(1);
|
||||
valPtrs[0] = &values;
|
||||
formatterPtr_().write(coords, valNames, valPtrs, str);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
|
||||
(
|
||||
const regionSplit& regions,
|
||||
const Map<label>& patchRegions,
|
||||
const Map<scalar>& regionVolume,
|
||||
const volScalarField& alpha
|
||||
) const
|
||||
{
|
||||
const scalar maxDropletVol = 1.0/6.0*pow(maxDiam_, 3);
|
||||
|
||||
// Split alpha field
|
||||
// ~~~~~~~~~~~~~~~~~
|
||||
// Split into
|
||||
// - liquidCore : region connected to inlet patches
|
||||
// - per region a volume : for all other regions
|
||||
// - backgroundAlpha : remaining alpha
|
||||
|
||||
|
||||
// Construct field
|
||||
volScalarField liquidCore
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
alphaName_ + "_liquidCore",
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
alpha,
|
||||
fvPatchField<scalar>::calculatedType()
|
||||
);
|
||||
|
||||
volScalarField backgroundAlpha
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
alphaName_ + "_background",
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
alpha,
|
||||
fvPatchField<scalar>::calculatedType()
|
||||
);
|
||||
|
||||
|
||||
// Knock out any cell not in patchRegions
|
||||
forAll(liquidCore, celli)
|
||||
{
|
||||
label regionI = regions[celli];
|
||||
if (patchRegions.found(regionI))
|
||||
{
|
||||
backgroundAlpha[celli] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
liquidCore[celli] = 0;
|
||||
|
||||
scalar regionVol = regionVolume[regionI];
|
||||
if (regionVol < maxDropletVol)
|
||||
{
|
||||
backgroundAlpha[celli] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
liquidCore.correctBoundaryConditions();
|
||||
backgroundAlpha.correctBoundaryConditions();
|
||||
|
||||
if (log)
|
||||
{
|
||||
Info<< " Volume of liquid-core = "
|
||||
<< fvc::domainIntegrate(liquidCore).value()
|
||||
<< endl;
|
||||
Info<< " Volume of background = "
|
||||
<< fvc::domainIntegrate(backgroundAlpha).value()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Log << " Writing liquid-core field to " << liquidCore.name() << endl;
|
||||
liquidCore.write();
|
||||
|
||||
Log<< " Writing background field to " << backgroundAlpha.name() << endl;
|
||||
backgroundAlpha.write();
|
||||
}
|
||||
|
||||
|
||||
Foam::Map<Foam::label>
|
||||
Foam::functionObjects::regionSizeDistribution::findPatchRegions
|
||||
(
|
||||
const regionSplit& regions
|
||||
) const
|
||||
{
|
||||
// Mark all regions starting at patches
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Count number of patch faces (just for initial sizing)
|
||||
const labelHashSet patchIDs(mesh_.boundaryMesh().patchSet(patchNames_));
|
||||
|
||||
label nPatchFaces = 0;
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
nPatchFaces += mesh_.boundaryMesh()[iter.key()].size();
|
||||
}
|
||||
|
||||
|
||||
Map<label> patchRegions(nPatchFaces);
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[iter.key()];
|
||||
|
||||
// Collect all regions on the patch
|
||||
const labelList& faceCells = pp.faceCells();
|
||||
|
||||
forAll(faceCells, i)
|
||||
{
|
||||
patchRegions.insert
|
||||
(
|
||||
regions[faceCells[i]],
|
||||
Pstream::myProcNo() // dummy value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make sure all the processors have the same set of regions
|
||||
Pstream::mapCombineGather(patchRegions, minEqOp<label>());
|
||||
Pstream::mapCombineScatter(patchRegions);
|
||||
|
||||
return patchRegions;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::functionObjects::regionSizeDistribution::divide
|
||||
(
|
||||
const scalarField& num,
|
||||
const scalarField& denom
|
||||
)
|
||||
{
|
||||
tmp<scalarField> tresult(new scalarField(num.size()));
|
||||
scalarField& result = tresult.ref();
|
||||
|
||||
forAll(denom, i)
|
||||
{
|
||||
if (denom[i] != 0)
|
||||
{
|
||||
result[i] = num[i]/denom[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
result[i] = 0.0;
|
||||
}
|
||||
}
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::regionSizeDistribution::writeGraphs
|
||||
(
|
||||
const word& fieldName, // name of field
|
||||
const labelList& indices, // index of bin for each region
|
||||
const scalarField& sortedField, // per region field data
|
||||
const scalarField& binCount, // per bin number of regions
|
||||
const coordSet& coords // graph data for bins
|
||||
) const
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Calculate per-bin average
|
||||
scalarField binSum(nBins_, 0.0);
|
||||
forAll(sortedField, i)
|
||||
{
|
||||
binSum[indices[i]] += sortedField[i];
|
||||
}
|
||||
|
||||
scalarField binAvg(divide(binSum, binCount));
|
||||
|
||||
// Per bin deviation
|
||||
scalarField binSqrSum(nBins_, 0.0);
|
||||
forAll(sortedField, i)
|
||||
{
|
||||
binSqrSum[indices[i]] += Foam::sqr(sortedField[i]);
|
||||
}
|
||||
scalarField binDev
|
||||
(
|
||||
sqrt(divide(binSqrSum, binCount) - Foam::sqr(binAvg))
|
||||
);
|
||||
|
||||
// Write average
|
||||
writeGraph(coords, fieldName + "_sum", binSum);
|
||||
// Write average
|
||||
writeGraph(coords, fieldName + "_avg", binAvg);
|
||||
// Write deviation
|
||||
writeGraph(coords, fieldName + "_dev", binDev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::regionSizeDistribution::writeGraphs
|
||||
(
|
||||
const word& fieldName, // name of field
|
||||
const scalarField& cellField, // per cell field data
|
||||
const regionSplit& regions, // per cell the region(=droplet)
|
||||
const labelList& sortedRegions, // valid regions in sorted order
|
||||
const scalarField& sortedNormalisation,
|
||||
|
||||
const labelList& indices, // per region index of bin
|
||||
const scalarField& binCount, // per bin number of regions
|
||||
const coordSet& coords // graph data for bins
|
||||
) const
|
||||
{
|
||||
// Sum on a per-region basis. Parallel reduced.
|
||||
Map<scalar> regionField(regionSum(regions, cellField));
|
||||
|
||||
// Extract in region order
|
||||
scalarField sortedField
|
||||
(
|
||||
sortedNormalisation
|
||||
* extractData
|
||||
(
|
||||
sortedRegions,
|
||||
regionField
|
||||
)
|
||||
);
|
||||
|
||||
writeGraphs
|
||||
(
|
||||
fieldName, // name of field
|
||||
indices, // index of bin for each region
|
||||
sortedField, // per region field data
|
||||
binCount, // per bin number of regions
|
||||
coords // graph data for bins
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::regionSizeDistribution::regionSizeDistribution
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
file_(obr_, name),
|
||||
alphaName_(dict.lookup("field")),
|
||||
patchNames_(dict.lookup("patches")),
|
||||
isoPlanes_(dict.lookupOrDefault<bool>("isoPlanes", false))
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (isA<fvMesh>(obr_))
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::regionSizeDistribution::~regionSizeDistribution()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("field") >> alphaName_;
|
||||
dict.lookup("patches") >> patchNames_;
|
||||
dict.lookup("threshold") >> threshold_;
|
||||
dict.lookup("maxDiameter") >> maxDiam_;
|
||||
minDiam_ = 0.0;
|
||||
dict.readIfPresent("minDiameter", minDiam_);
|
||||
dict.lookup("nBins") >> nBins_;
|
||||
dict.lookup("fields") >> fields_;
|
||||
|
||||
word format(dict.lookup("setFormat"));
|
||||
formatterPtr_ = writer<scalar>::New(format);
|
||||
|
||||
if (dict.found("coordinateSystem"))
|
||||
{
|
||||
coordSysPtr_.reset(new coordinateSystem(obr_, dict));
|
||||
|
||||
Log < "Transforming all vectorFields with coordinate system "
|
||||
<< coordSysPtr_().name() << endl;
|
||||
}
|
||||
|
||||
if (isoPlanes_)
|
||||
{
|
||||
dict.lookup("origin") >> origin_;
|
||||
dict.lookup("direction") >> direction_;
|
||||
dict.lookup("maxDiameter") >> maxDiameter_;
|
||||
dict.lookup("nDownstreamBins") >> nDownstreamBins_;
|
||||
dict.lookup("maxDownstream") >> maxDownstream_;
|
||||
direction_ /= mag(direction_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::regionSizeDistribution::execute()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::regionSizeDistribution::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::regionSizeDistribution::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::regionSizeDistribution::write()
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
autoPtr<volScalarField> alphaPtr;
|
||||
if (obr_.foundObject<volScalarField>(alphaName_))
|
||||
{
|
||||
Log << " Looking up field " << alphaName_ << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " Reading field " << alphaName_ << endl;
|
||||
alphaPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
alphaName_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const volScalarField& alpha =
|
||||
(
|
||||
alphaPtr.valid()
|
||||
? alphaPtr()
|
||||
: obr_.lookupObject<volScalarField>(alphaName_)
|
||||
);
|
||||
|
||||
Log << " Volume of alpha = "
|
||||
<< fvc::domainIntegrate(alpha).value()
|
||||
<< endl;
|
||||
|
||||
const scalar meshVol = gSum(mesh_.V());
|
||||
const scalar maxDropletVol = 1.0/6.0*pow3(maxDiam_);
|
||||
const scalar delta = (maxDiam_-minDiam_)/nBins_;
|
||||
|
||||
Log << " Mesh volume = " << meshVol << nl
|
||||
<< " Maximum droplet diameter = " << maxDiam_ << nl
|
||||
<< " Maximum droplet volume = " << maxDropletVol
|
||||
<< endl;
|
||||
|
||||
|
||||
// Determine blocked faces
|
||||
boolList blockedFace(mesh_.nFaces(), false);
|
||||
label nBlocked = 0;
|
||||
|
||||
{
|
||||
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
|
||||
{
|
||||
scalar ownVal = alpha[mesh_.faceOwner()[facei]];
|
||||
scalar neiVal = alpha[mesh_.faceNeighbour()[facei]];
|
||||
|
||||
if
|
||||
(
|
||||
(ownVal < threshold_ && neiVal > threshold_)
|
||||
|| (ownVal > threshold_ && neiVal < threshold_)
|
||||
)
|
||||
{
|
||||
blockedFace[facei] = true;
|
||||
nBlocked++;
|
||||
}
|
||||
}
|
||||
|
||||
// Block coupled faces
|
||||
forAll(alpha.boundaryField(), patchi)
|
||||
{
|
||||
const fvPatchScalarField& fvp = alpha.boundaryField()[patchi];
|
||||
if (fvp.coupled())
|
||||
{
|
||||
tmp<scalarField> townFld(fvp.patchInternalField());
|
||||
const scalarField& ownFld = townFld();
|
||||
tmp<scalarField> tnbrFld(fvp.patchNeighbourField());
|
||||
const scalarField& nbrFld = tnbrFld();
|
||||
|
||||
label start = fvp.patch().patch().start();
|
||||
|
||||
forAll(ownFld, i)
|
||||
{
|
||||
scalar ownVal = ownFld[i];
|
||||
scalar neiVal = nbrFld[i];
|
||||
|
||||
if
|
||||
(
|
||||
(ownVal < threshold_ && neiVal > threshold_)
|
||||
|| (ownVal > threshold_ && neiVal < threshold_)
|
||||
)
|
||||
{
|
||||
blockedFace[start+i] = true;
|
||||
nBlocked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
regionSplit regions(mesh_, blockedFace);
|
||||
|
||||
Log << " Determined " << regions.nRegions()
|
||||
<< " disconnected regions" << endl;
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
volScalarField region
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"region",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("zero", dimless, 0)
|
||||
);
|
||||
Info<< " Dumping region as volScalarField to " << region.name()
|
||||
<< endl;
|
||||
|
||||
forAll(regions, celli)
|
||||
{
|
||||
region[celli] = regions[celli];
|
||||
}
|
||||
region.correctBoundaryConditions();
|
||||
region.write();
|
||||
}
|
||||
|
||||
|
||||
// Determine regions connected to supplied patches
|
||||
Map<label> patchRegions(findPatchRegions(regions));
|
||||
|
||||
|
||||
// Sum all regions
|
||||
const scalarField alphaVol(alpha.primitiveField()*mesh_.V());
|
||||
Map<scalar> allRegionVolume(regionSum(regions, mesh_.V()));
|
||||
Map<scalar> allRegionAlphaVolume(regionSum(regions, alphaVol));
|
||||
Map<label> allRegionNumCells
|
||||
(
|
||||
regionSum
|
||||
(
|
||||
regions,
|
||||
labelField(mesh_.nCells(), 1.0)
|
||||
)
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " " << token::TAB << "Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< token::TAB << "nCells"
|
||||
<< endl;
|
||||
scalar meshSumVol = 0.0;
|
||||
scalar alphaSumVol = 0.0;
|
||||
label nCells = 0;
|
||||
|
||||
Map<scalar>::const_iterator vIter = allRegionVolume.begin();
|
||||
Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin();
|
||||
Map<label>::const_iterator numIter = allRegionNumCells.begin();
|
||||
for
|
||||
(
|
||||
;
|
||||
vIter != allRegionVolume.end()
|
||||
&& aIter != allRegionAlphaVolume.end();
|
||||
++vIter, ++aIter, ++numIter
|
||||
)
|
||||
{
|
||||
Info<< " " << token::TAB << vIter.key()
|
||||
<< token::TAB << vIter()
|
||||
<< token::TAB << aIter()
|
||||
<< token::TAB << numIter()
|
||||
<< endl;
|
||||
|
||||
meshSumVol += vIter();
|
||||
alphaSumVol += aIter();
|
||||
nCells += numIter();
|
||||
}
|
||||
Info<< " " << token::TAB << "Total:"
|
||||
<< token::TAB << meshSumVol
|
||||
<< token::TAB << alphaSumVol
|
||||
<< token::TAB << nCells
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (log)
|
||||
{
|
||||
Info<< " Patch connected regions (liquid core):" << endl;
|
||||
Info<< token::TAB << " Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< endl;
|
||||
forAllConstIter(Map<label>, patchRegions, iter)
|
||||
{
|
||||
label regionI = iter.key();
|
||||
Info<< " " << token::TAB << iter.key()
|
||||
<< token::TAB << allRegionVolume[regionI]
|
||||
<< token::TAB << allRegionAlphaVolume[regionI] << endl;
|
||||
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (log)
|
||||
{
|
||||
Info<< " Background regions:" << endl;
|
||||
Info<< " " << token::TAB << "Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< endl;
|
||||
Map<scalar>::const_iterator vIter = allRegionVolume.begin();
|
||||
Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin();
|
||||
|
||||
for
|
||||
(
|
||||
;
|
||||
vIter != allRegionVolume.end()
|
||||
&& aIter != allRegionAlphaVolume.end();
|
||||
++vIter, ++aIter
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
!patchRegions.found(vIter.key())
|
||||
&& vIter() >= maxDropletVol
|
||||
)
|
||||
{
|
||||
Info<< " " << token::TAB << vIter.key()
|
||||
<< token::TAB << vIter()
|
||||
<< token::TAB << aIter() << endl;
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Split alpha field
|
||||
// ~~~~~~~~~~~~~~~~~
|
||||
// Split into
|
||||
// - liquidCore : region connected to inlet patches
|
||||
// - per region a volume : for all other regions
|
||||
// - backgroundAlpha : remaining alpha
|
||||
writeAlphaFields(regions, patchRegions, allRegionVolume, alpha);
|
||||
|
||||
|
||||
// Extract droplet-only allRegionVolume, i.e. delete liquid core
|
||||
// (patchRegions) and background regions from maps.
|
||||
// Note that we have to use mesh volume (allRegionVolume) and not
|
||||
// allRegionAlphaVolume since background might not have alpha in it.
|
||||
// Deleting regions where the volume-alpha-weighted is lower than
|
||||
// threshold
|
||||
forAllIter(Map<scalar>, allRegionVolume, vIter)
|
||||
{
|
||||
label regionI = vIter.key();
|
||||
if
|
||||
(
|
||||
patchRegions.found(regionI)
|
||||
|| vIter() >= maxDropletVol
|
||||
|| (allRegionAlphaVolume[regionI]/vIter() < threshold_)
|
||||
)
|
||||
{
|
||||
allRegionVolume.erase(vIter);
|
||||
allRegionAlphaVolume.erase(regionI);
|
||||
allRegionNumCells.erase(regionI);
|
||||
}
|
||||
}
|
||||
|
||||
if (allRegionVolume.size())
|
||||
{
|
||||
// Construct mids of bins for plotting
|
||||
pointField xBin(nBins_);
|
||||
|
||||
scalar x = 0.5*delta;
|
||||
forAll(xBin, i)
|
||||
{
|
||||
xBin[i] = point(x, 0, 0);
|
||||
x += delta;
|
||||
}
|
||||
|
||||
const coordSet coords("diameter", "x", xBin, mag(xBin));
|
||||
|
||||
|
||||
// Get in region order the alpha*volume and diameter
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
const labelList sortedRegions = allRegionAlphaVolume.sortedToc();
|
||||
|
||||
scalarField sortedVols
|
||||
(
|
||||
extractData
|
||||
(
|
||||
sortedRegions,
|
||||
allRegionAlphaVolume
|
||||
)
|
||||
);
|
||||
|
||||
vectorField centroids(sortedVols.size(), vector::zero);
|
||||
|
||||
// Check if downstream bins are calculated
|
||||
if (isoPlanes_)
|
||||
{
|
||||
vectorField alphaDistance
|
||||
(
|
||||
(alpha.primitiveField()*mesh.V())
|
||||
* (mesh.C().primitiveField() - origin_)()
|
||||
);
|
||||
|
||||
Map<vector> allRegionAlphaDistance
|
||||
(
|
||||
regionSum
|
||||
(
|
||||
regions,
|
||||
alphaDistance
|
||||
)
|
||||
);
|
||||
|
||||
// 2. centroid
|
||||
vectorField sortedMoment
|
||||
(
|
||||
extractData
|
||||
(
|
||||
sortedRegions,
|
||||
allRegionAlphaDistance
|
||||
)
|
||||
);
|
||||
|
||||
centroids = sortedMoment/sortedVols + origin_;
|
||||
|
||||
// Bin according to centroid
|
||||
scalarField distToPlane((centroids - origin_) & direction_);
|
||||
|
||||
vectorField radialDistToOrigin
|
||||
(
|
||||
(centroids - origin_) - (distToPlane*direction_)
|
||||
);
|
||||
|
||||
const scalar deltaX = maxDownstream_/nDownstreamBins_;
|
||||
labelList downstreamIndices(distToPlane.size(), -1);
|
||||
forAll(distToPlane, i)
|
||||
{
|
||||
if
|
||||
(
|
||||
(mag(radialDistToOrigin[i]) < maxDiameter_)
|
||||
&& (distToPlane[i] < maxDownstream_)
|
||||
)
|
||||
{
|
||||
downstreamIndices[i] = distToPlane[i]/deltaX;
|
||||
}
|
||||
}
|
||||
|
||||
scalarField binDownCount(nDownstreamBins_, 0.0);
|
||||
forAll(distToPlane, i)
|
||||
{
|
||||
if (downstreamIndices[i] != -1)
|
||||
{
|
||||
binDownCount[downstreamIndices[i]] += 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Write
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Construct mids of bins for plotting
|
||||
pointField xBin(nDownstreamBins_);
|
||||
|
||||
scalar x = 0.5*deltaX;
|
||||
forAll(xBin, i)
|
||||
{
|
||||
xBin[i] = point(x, 0, 0);
|
||||
x += deltaX;
|
||||
}
|
||||
|
||||
const coordSet coords("distance", "x", xBin, mag(xBin));
|
||||
writeGraph(coords, "isoPlanes", binDownCount);
|
||||
}
|
||||
|
||||
// Write to log
|
||||
if (log)
|
||||
{
|
||||
Info<< " Iso-planes Bins:" << nl
|
||||
<< " " << token::TAB << "Bin"
|
||||
<< token::TAB << "Min distance"
|
||||
<< token::TAB << "Count:"
|
||||
<< endl;
|
||||
|
||||
scalar delta = 0.0;
|
||||
forAll(binDownCount, binI)
|
||||
{
|
||||
Info<< " " << token::TAB << binI
|
||||
<< token::TAB << delta
|
||||
<< token::TAB << binDownCount[binI] << endl;
|
||||
delta += deltaX;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the diameters
|
||||
scalarField sortedDiameters(sortedVols.size());
|
||||
forAll(sortedDiameters, i)
|
||||
{
|
||||
sortedDiameters[i] = Foam::cbrt
|
||||
(
|
||||
sortedVols[i]
|
||||
*6/constant::mathematical::pi
|
||||
);
|
||||
}
|
||||
|
||||
// Determine the bin index for all the diameters
|
||||
labelList indices(sortedDiameters.size());
|
||||
forAll(sortedDiameters, i)
|
||||
{
|
||||
indices[i] = (sortedDiameters[i]-minDiam_)/delta;
|
||||
}
|
||||
|
||||
// Calculate the counts per diameter bin
|
||||
scalarField binCount(nBins_, 0.0);
|
||||
forAll(sortedDiameters, i)
|
||||
{
|
||||
binCount[indices[i]] += 1.0;
|
||||
}
|
||||
|
||||
// Write counts
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeGraph(coords, "count", binCount);
|
||||
}
|
||||
|
||||
// Write to log
|
||||
if (log)
|
||||
{
|
||||
Info<< " Bins:" << nl
|
||||
<< " " << token::TAB << "Bin"
|
||||
<< token::TAB << "Min diameter"
|
||||
<< token::TAB << "Count:"
|
||||
<< endl;
|
||||
|
||||
scalar diam = 0.0;
|
||||
forAll(binCount, binI)
|
||||
{
|
||||
Info<< " " << token::TAB << binI
|
||||
<< token::TAB << diam
|
||||
<< token::TAB << binCount[binI] << endl;
|
||||
|
||||
diam += delta;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
// Write average and deviation of droplet volume.
|
||||
writeGraphs
|
||||
(
|
||||
"volume", // name of field
|
||||
indices, // per region the bin index
|
||||
sortedVols, // per region field data
|
||||
binCount, // per bin number of regions
|
||||
coords // graph data for bins
|
||||
);
|
||||
|
||||
// Collect some more field
|
||||
{
|
||||
wordList scalarNames(obr_.names(volScalarField::typeName));
|
||||
labelList selected = findStrings(fields_, scalarNames);
|
||||
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fldName = scalarNames[selected[i]];
|
||||
Log << " Scalar field " << fldName << endl;
|
||||
|
||||
const scalarField& fld = obr_.lookupObject
|
||||
<
|
||||
volScalarField
|
||||
>(fldName).primitiveField();
|
||||
|
||||
writeGraphs
|
||||
(
|
||||
fldName, // name of field
|
||||
alphaVol*fld, // per cell field data
|
||||
|
||||
regions, // per cell the region(=droplet)
|
||||
sortedRegions, // valid regions in sorted order
|
||||
1.0/sortedVols, // per region normalisation
|
||||
|
||||
indices, // index of bin for each region
|
||||
binCount, // per bin number of regions
|
||||
coords // graph data for bins
|
||||
);
|
||||
}
|
||||
}
|
||||
{
|
||||
wordList vectorNames(obr_.names(volVectorField::typeName));
|
||||
labelList selected = findStrings(fields_, vectorNames);
|
||||
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fldName = vectorNames[selected[i]];
|
||||
Log << " Vector field " << fldName << endl;
|
||||
|
||||
vectorField fld = obr_.lookupObject
|
||||
<
|
||||
volVectorField
|
||||
>(fldName).primitiveField();
|
||||
|
||||
if (coordSysPtr_.valid())
|
||||
{
|
||||
Log << "Transforming vector field " << fldName
|
||||
<< " with coordinate system "
|
||||
<< coordSysPtr_().name()
|
||||
<< endl;
|
||||
|
||||
fld = coordSysPtr_().localVector(fld);
|
||||
}
|
||||
|
||||
|
||||
// Components
|
||||
|
||||
for (direction cmp = 0; cmp < vector::nComponents; cmp++)
|
||||
{
|
||||
writeGraphs
|
||||
(
|
||||
fldName + vector::componentNames[cmp],
|
||||
alphaVol*fld.component(cmp),// per cell field data
|
||||
|
||||
regions, // per cell the region(=droplet)
|
||||
sortedRegions, // valid regions in sorted order
|
||||
1.0/sortedVols, // per region normalisation
|
||||
|
||||
indices, // index of bin for each region
|
||||
binCount, // per bin number of regions
|
||||
coords // graph data for bins
|
||||
);
|
||||
}
|
||||
|
||||
// Magnitude
|
||||
writeGraphs
|
||||
(
|
||||
fldName + "mag", // name of field
|
||||
alphaVol*mag(fld), // per cell field data
|
||||
|
||||
regions, // per cell the region(=droplet)
|
||||
sortedRegions, // valid regions in sorted order
|
||||
1.0/sortedVols, // per region normalisation
|
||||
|
||||
indices, // index of bin for each region
|
||||
binCount, // per bin number of regions
|
||||
coords // graph data for bins
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,335 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::regionSizeDistribution
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Creates a size distribution via interrogating a continuous phase fraction
|
||||
field.
|
||||
|
||||
Looks up a phase-fraction (alpha) field and splits the mesh into regions
|
||||
based on where the field is below the threshold value. These
|
||||
regions ("droplets") can now be analysed.
|
||||
|
||||
|
||||
|
||||
Regions:
|
||||
- print the regions connected to a user-defined set of patches.
|
||||
(in spray calculation these form the liquid core)
|
||||
- print the regions with too large volume. These are the 'background'
|
||||
regions.
|
||||
- (debug) write regions as a volScalarField
|
||||
- (debug) print for all regions the sum of volume and alpha*volume
|
||||
|
||||
Output (volume scalar) fields include:
|
||||
- alpha_liquidCore : alpha with outside liquid core set to 0
|
||||
- alpha_background : alpha with outside background set to 0.
|
||||
|
||||
%Histogram:
|
||||
- determine histogram of diameter (given minDiameter, maxDiameter, nBins)
|
||||
- write graph of number of droplets per bin
|
||||
- write graph of sum, average and deviation of droplet volume per bin
|
||||
- write graph of sum, average and deviation of user-defined fields. For
|
||||
volVectorFields these are those of the 3 components and the magnitude.
|
||||
- (optional) write graph of histogram of centroids on iso planes
|
||||
downstream of the injector determined by origin, direction and maxDiameter
|
||||
up to maxDownstream
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
regionSizeDistribution1
|
||||
{
|
||||
type regionSizeDistribution;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
field alpha;
|
||||
patches (inlet);
|
||||
threshold 0.4;
|
||||
fields (p U);
|
||||
nBins 100;
|
||||
maxDiameter 0.5e-4;
|
||||
minDiameter 0;
|
||||
setFormat gnuplot;
|
||||
origin (0 0 0);
|
||||
coordinateRoation
|
||||
{
|
||||
type cartesian;
|
||||
e3 (0 1 1);
|
||||
e1 (1 0 0);
|
||||
}
|
||||
|
||||
// Optional downstream iso-plane bins.
|
||||
isoPlanes true;
|
||||
|
||||
// Plane normal and point definition
|
||||
direction (1 0 1);
|
||||
origin (1e-4 0 5e-4);
|
||||
|
||||
// Maximum diameter of the cylinder formed by the origin point
|
||||
// and direction
|
||||
maxDiameter 3e-4;
|
||||
|
||||
// Maximum downstream distance
|
||||
maxDownstream 6e-4;
|
||||
|
||||
// Number of iso-plane bins
|
||||
nDownstreamBins 20;
|
||||
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: regionSizeDistribution |yes|
|
||||
field | phase field to interrogate | yes |
|
||||
patches | patches from which the liquid core is identified | yes|
|
||||
threshold | phase fraction applied to delimit regions | yes |
|
||||
fields | fields to sample | yes |
|
||||
nBins | number of bins for histogram | yes |
|
||||
maxDiameter | maximum region equivalent diameter | yes |
|
||||
minDiameter | minimum region equivalent diameter | no | 0
|
||||
setFormat | writing format | yes |
|
||||
origin | origin of local co-ordinate system | yes |
|
||||
coordinateRoation | orientation of local co-ordinate system | no |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
regionSizeDistribution.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_regionSizeDistribution_H
|
||||
#define functionObjects_regionSizeDistribution_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "writer.H"
|
||||
#include "Map.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "wordReList.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class regionSplit;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class regionSizeDistribution Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regionSizeDistribution
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
writeFile file_;
|
||||
|
||||
//- Name of field
|
||||
word alphaName_;
|
||||
|
||||
//- Patches to walk from
|
||||
wordReList patchNames_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Clip value
|
||||
scalar threshold_;
|
||||
|
||||
//- Maximum droplet diameter
|
||||
scalar maxDiam_;
|
||||
|
||||
//- Minimum droplet diameter
|
||||
scalar minDiam_;
|
||||
|
||||
//- Mumber of bins
|
||||
label nBins_;
|
||||
|
||||
//- Names of fields to sample on regions
|
||||
wordReList fields_;
|
||||
|
||||
//- Output formatter to write
|
||||
autoPtr<writer<scalar>> formatterPtr_;
|
||||
|
||||
//- Optional coordinate system
|
||||
autoPtr<coordinateSystem> coordSysPtr_;
|
||||
|
||||
// Optional extra definition of bins on planes downstream to the origin
|
||||
// point and maximum diameter
|
||||
|
||||
//- Switch to enable iso-planes sampling
|
||||
bool isoPlanes_;
|
||||
|
||||
//- Optional origin point
|
||||
vector origin_;
|
||||
|
||||
//- Optional plane normal direction
|
||||
vector direction_;
|
||||
|
||||
//- Optional maximum diameter on plane
|
||||
scalar maxDiameter_;
|
||||
|
||||
//- Optional number of bins for
|
||||
scalar nDownstreamBins_;
|
||||
|
||||
//- Optional maximum downstream coordinate from origin
|
||||
scalar maxDownstream_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
template<class Type>
|
||||
Map<Type> regionSum(const regionSplit&, const Field<Type>&) const;
|
||||
|
||||
//- Get data in order
|
||||
template<class Type>
|
||||
List<Type> extractData(const UList<label>& keys, const Map<Type>&)
|
||||
const;
|
||||
|
||||
void writeGraph
|
||||
(
|
||||
const coordSet& coords,
|
||||
const word& valueName,
|
||||
const scalarField& values
|
||||
) const;
|
||||
|
||||
//- Write volfields with the parts of alpha which are not
|
||||
// droplets (liquidCore, backGround)
|
||||
void writeAlphaFields
|
||||
(
|
||||
const regionSplit& regions,
|
||||
const Map<label>& keepRegions,
|
||||
const Map<scalar>& regionVolume,
|
||||
const volScalarField& alpha
|
||||
) const;
|
||||
|
||||
//- Mark all regions starting at patches
|
||||
Map<label> findPatchRegions(const regionSplit&) const;
|
||||
|
||||
//- Helper: divide if denom != 0
|
||||
static tmp<scalarField> divide(const scalarField&, const scalarField&);
|
||||
|
||||
//- Given per-region data calculate per-bin average/deviation and graph
|
||||
void writeGraphs
|
||||
(
|
||||
const word& fieldName, // name of field
|
||||
const labelList& indices, // index of bin for each region
|
||||
const scalarField& sortedField, // per region field data
|
||||
const scalarField& binCount, // per bin number of regions
|
||||
const coordSet& coords // graph data for bins
|
||||
) const;
|
||||
|
||||
//- Given per-cell data calculate per-bin average/deviation and graph
|
||||
void writeGraphs
|
||||
(
|
||||
const word& fieldName, // name of field
|
||||
const scalarField& cellField, // per cell field data
|
||||
|
||||
const regionSplit& regions, // per cell the region(=droplet)
|
||||
const labelList& sortedRegions, // valid regions in sorted order
|
||||
const scalarField& sortedNormalisation,
|
||||
|
||||
const labelList& indices, // index of bin for each region
|
||||
const scalarField& binCount, // per bin number of regions
|
||||
const coordSet& coords // graph data for bins
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
regionSizeDistribution(const regionSizeDistribution&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const regionSizeDistribution&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("regionSizeDistribution");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
regionSizeDistribution
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~regionSizeDistribution();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the regionSizeDistribution data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Do nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Calculate the regionSizeDistribution and write
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "regionSizeDistributionTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "regionSizeDistribution.H"
|
||||
#include "regionSplit.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Map<Type> Foam::functionObjects::regionSizeDistribution::regionSum
|
||||
(
|
||||
const regionSplit& regions,
|
||||
const Field<Type>& fld
|
||||
) const
|
||||
{
|
||||
// Per region the sum of fld
|
||||
Map<Type> regionToSum(regions.nRegions()/Pstream::nProcs());
|
||||
|
||||
forAll(fld, celli)
|
||||
{
|
||||
label regionI = regions[celli];
|
||||
|
||||
typename Map<Type>::iterator fnd = regionToSum.find(regionI);
|
||||
if (fnd == regionToSum.end())
|
||||
{
|
||||
regionToSum.insert(regionI, fld[celli]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fnd() += fld[celli];
|
||||
}
|
||||
}
|
||||
Pstream::mapCombineGather(regionToSum, plusEqOp<Type>());
|
||||
Pstream::mapCombineScatter(regionToSum);
|
||||
|
||||
return regionToSum;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::List<Type> Foam::functionObjects::regionSizeDistribution::extractData
|
||||
(
|
||||
const UList<label>& keys,
|
||||
const Map<Type>& regionData
|
||||
) const
|
||||
{
|
||||
List<Type> sortedData(keys.size());
|
||||
|
||||
forAll(keys, i)
|
||||
{
|
||||
sortedData[i] = regionData[keys[i]];
|
||||
}
|
||||
return sortedData;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
463
src/functionObjects/field/streamFunction/streamFunction.C
Normal file
463
src/functionObjects/field/streamFunction/streamFunction.C
Normal file
@ -0,0 +1,463 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "streamFunction.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "emptyPolyPatch.H"
|
||||
#include "symmetryPlanePolyPatch.H"
|
||||
#include "symmetryPolyPatch.H"
|
||||
#include "wedgePolyPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(streamFunction, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
streamFunction,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::pointScalarField> Foam::functionObjects::streamFunction::calc
|
||||
(
|
||||
const surfaceScalarField& phi
|
||||
) const
|
||||
{
|
||||
Log << " functionObjects::" << type() << " " << name()
|
||||
<< " calculating steam-function" << endl;
|
||||
|
||||
Vector<label> slabNormal((Vector<label>::one - mesh_.geometricD())/2);
|
||||
const direction slabDir
|
||||
(
|
||||
slabNormal
|
||||
& Vector<label>(Vector<label>::X, Vector<label>::Y, Vector<label>::Z)
|
||||
);
|
||||
|
||||
scalar thickness = vector(slabNormal) & mesh_.bounds().span();
|
||||
|
||||
const pointMesh& pMesh = pointMesh::New(mesh_);
|
||||
|
||||
tmp<pointScalarField> tstreamFunction
|
||||
(
|
||||
new pointScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"streamFunction",
|
||||
time_.timeName(),
|
||||
mesh_
|
||||
),
|
||||
pMesh,
|
||||
dimensionedScalar("zero", phi.dimensions(), 0.0)
|
||||
)
|
||||
);
|
||||
pointScalarField& streamFunction = tstreamFunction.ref();
|
||||
|
||||
labelList visitedPoint(mesh_.nPoints());
|
||||
forAll(visitedPoint, pointi)
|
||||
{
|
||||
visitedPoint[pointi] = 0;
|
||||
}
|
||||
label nVisited = 0;
|
||||
label nVisitedOld = 0;
|
||||
|
||||
const faceUList& faces = mesh_.faces();
|
||||
const pointField& points = mesh_.points();
|
||||
|
||||
label nInternalFaces = mesh_.nInternalFaces();
|
||||
|
||||
vectorField unitAreas(mesh_.faceAreas());
|
||||
unitAreas /= mag(unitAreas);
|
||||
|
||||
const polyPatchList& patches = mesh_.boundaryMesh();
|
||||
|
||||
bool finished = true;
|
||||
|
||||
// Find the boundary face with zero flux. set the stream function
|
||||
// to zero on that face
|
||||
bool found = false;
|
||||
|
||||
do
|
||||
{
|
||||
found = false;
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const primitivePatch& bouFaces = patches[patchi];
|
||||
|
||||
if (!isType<emptyPolyPatch>(patches[patchi]))
|
||||
{
|
||||
forAll(bouFaces, facei)
|
||||
{
|
||||
if
|
||||
(
|
||||
magSqr(phi.boundaryField()[patchi][facei]) < SMALL
|
||||
)
|
||||
{
|
||||
const labelList& zeroPoints = bouFaces[facei];
|
||||
|
||||
// Zero flux face found
|
||||
found = true;
|
||||
|
||||
forAll(zeroPoints, pointi)
|
||||
{
|
||||
if (visitedPoint[zeroPoints[pointi]] == 1)
|
||||
{
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
Log << " Zero face: patch: " << patchi
|
||||
<< " face: " << facei << endl;
|
||||
|
||||
forAll(zeroPoints, pointi)
|
||||
{
|
||||
streamFunction[zeroPoints[pointi]] = 0;
|
||||
visitedPoint[zeroPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found) break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
Log << " Zero flux boundary face not found. "
|
||||
<< "Using cell as a reference."
|
||||
<< endl;
|
||||
|
||||
const cellList& c = mesh_.cells();
|
||||
|
||||
forAll(c, cI)
|
||||
{
|
||||
labelList zeroPoints = c[cI].labels(mesh_.faces());
|
||||
|
||||
bool found = true;
|
||||
|
||||
forAll(zeroPoints, pointi)
|
||||
{
|
||||
if (visitedPoint[zeroPoints[pointi]] == 1)
|
||||
{
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
forAll(zeroPoints, pointi)
|
||||
{
|
||||
streamFunction[zeroPoints[pointi]] = 0.0;
|
||||
visitedPoint[zeroPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot find initialisation face or a cell."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through all faces. If one of the points on
|
||||
// the face has the streamfunction value different
|
||||
// from -1, all points with -1 ont that face have the
|
||||
// streamfunction value equal to the face flux in
|
||||
// that point plus the value in the visited point
|
||||
do
|
||||
{
|
||||
finished = true;
|
||||
|
||||
for (label facei = nInternalFaces; facei<faces.size(); facei++)
|
||||
{
|
||||
const labelList& curBPoints = faces[facei];
|
||||
bool bPointFound = false;
|
||||
|
||||
scalar currentBStream = 0.0;
|
||||
vector currentBStreamPoint(0, 0, 0);
|
||||
|
||||
forAll(curBPoints, pointi)
|
||||
{
|
||||
// Check if the point has been visited
|
||||
if (visitedPoint[curBPoints[pointi]] == 1)
|
||||
{
|
||||
// The point has been visited
|
||||
currentBStream = streamFunction[curBPoints[pointi]];
|
||||
currentBStreamPoint = points[curBPoints[pointi]];
|
||||
|
||||
bPointFound = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bPointFound)
|
||||
{
|
||||
// Sort out other points on the face
|
||||
forAll(curBPoints, pointi)
|
||||
{
|
||||
// Check if the point has been visited
|
||||
if (visitedPoint[curBPoints[pointi]] == 0)
|
||||
{
|
||||
label patchNo =
|
||||
mesh_.boundaryMesh().whichPatch(facei);
|
||||
|
||||
if
|
||||
(
|
||||
!isType<emptyPolyPatch>(patches[patchNo])
|
||||
&& !isType<symmetryPlanePolyPatch>
|
||||
(patches[patchNo])
|
||||
&& !isType<symmetryPolyPatch>(patches[patchNo])
|
||||
&& !isType<wedgePolyPatch>(patches[patchNo])
|
||||
)
|
||||
{
|
||||
label faceNo =
|
||||
mesh_.boundaryMesh()[patchNo]
|
||||
.whichFace(facei);
|
||||
|
||||
vector edgeHat =
|
||||
points[curBPoints[pointi]]
|
||||
- currentBStreamPoint;
|
||||
edgeHat.replace(slabDir, 0);
|
||||
edgeHat /= mag(edgeHat);
|
||||
|
||||
vector nHat = unitAreas[facei];
|
||||
|
||||
if (edgeHat.y() > VSMALL)
|
||||
{
|
||||
visitedPoint[curBPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
|
||||
streamFunction[curBPoints[pointi]] =
|
||||
currentBStream
|
||||
+ phi.boundaryField()[patchNo][faceNo]
|
||||
*sign(nHat.x());
|
||||
}
|
||||
else if (edgeHat.y() < -VSMALL)
|
||||
{
|
||||
visitedPoint[curBPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
|
||||
streamFunction[curBPoints[pointi]] =
|
||||
currentBStream
|
||||
- phi.boundaryField()[patchNo][faceNo]
|
||||
*sign(nHat.x());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (edgeHat.x() > VSMALL)
|
||||
{
|
||||
visitedPoint[curBPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
|
||||
streamFunction[curBPoints[pointi]] =
|
||||
currentBStream
|
||||
+ phi.boundaryField()[patchNo][faceNo]
|
||||
*sign(nHat.y());
|
||||
}
|
||||
else if (edgeHat.x() < -VSMALL)
|
||||
{
|
||||
visitedPoint[curBPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
|
||||
streamFunction[curBPoints[pointi]] =
|
||||
currentBStream
|
||||
- phi.boundaryField()[patchNo][faceNo]
|
||||
*sign(nHat.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finished = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (label facei=0; facei<nInternalFaces; facei++)
|
||||
{
|
||||
// Get the list of point labels for the face
|
||||
const labelList& curPoints = faces[facei];
|
||||
|
||||
bool pointFound = false;
|
||||
|
||||
scalar currentStream = 0.0;
|
||||
point currentStreamPoint(0, 0, 0);
|
||||
|
||||
forAll(curPoints, pointi)
|
||||
{
|
||||
// Check if the point has been visited
|
||||
if (visitedPoint[curPoints[pointi]] == 1)
|
||||
{
|
||||
// The point has been visited
|
||||
currentStream = streamFunction[curPoints[pointi]];
|
||||
currentStreamPoint = points[curPoints[pointi]];
|
||||
pointFound = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pointFound)
|
||||
{
|
||||
// Sort out other points on the face
|
||||
forAll(curPoints, pointi)
|
||||
{
|
||||
// Check if the point has been visited
|
||||
if (visitedPoint[curPoints[pointi]] == 0)
|
||||
{
|
||||
vector edgeHat =
|
||||
points[curPoints[pointi]] - currentStreamPoint;
|
||||
|
||||
edgeHat.replace(slabDir, 0);
|
||||
edgeHat /= mag(edgeHat);
|
||||
|
||||
vector nHat = unitAreas[facei];
|
||||
|
||||
if (edgeHat.y() > VSMALL)
|
||||
{
|
||||
visitedPoint[curPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
|
||||
streamFunction[curPoints[pointi]] =
|
||||
currentStream
|
||||
+ phi[facei]*sign(nHat.x());
|
||||
}
|
||||
else if (edgeHat.y() < -VSMALL)
|
||||
{
|
||||
visitedPoint[curPoints[pointi]] = 1;
|
||||
nVisited++;
|
||||
|
||||
streamFunction[curPoints[pointi]] =
|
||||
currentStream
|
||||
- phi[facei]*sign(nHat.x());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finished = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (nVisited == nVisitedOld)
|
||||
{
|
||||
// Find new seed. This must be a
|
||||
// multiply connected domain
|
||||
Log << " Exhausted a seed, looking for new seed "
|
||||
<< "(this is correct for multiply connected domains).";
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
nVisitedOld = nVisited;
|
||||
}
|
||||
} while (!finished);
|
||||
} while (!finished);
|
||||
|
||||
// Normalise the stream-function by the 2D mesh thickness
|
||||
streamFunction /= thickness;
|
||||
streamFunction.boundaryFieldRef() = 0.0;
|
||||
|
||||
return tstreamFunction;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::streamFunction::calc()
|
||||
{
|
||||
if (foundObject<surfaceScalarField>(fieldName_))
|
||||
{
|
||||
const surfaceScalarField& phi =
|
||||
mesh_.lookupObject<surfaceScalarField>(fieldName_);
|
||||
|
||||
return store(resultName_, calc(phi));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::streamFunction::streamFunction
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi")
|
||||
{
|
||||
setResultName("streamFunction", "phi");
|
||||
|
||||
label nD = mesh_.nGeometricD();
|
||||
|
||||
if (nD != 2)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Case is not 2D, stream-function cannot be computed"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::streamFunction::~streamFunction()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
105
src/functionObjects/field/streamFunction/streamFunction.H
Normal file
105
src/functionObjects/field/streamFunction/streamFunction.H
Normal file
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::streamFunction
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates and outputs the stream-function as a
|
||||
pointScalarField.
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldExpression
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
streamFunction.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_streamFunction_H
|
||||
#define functionObjects_streamFunction_H
|
||||
|
||||
#include "fieldExpression.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "pointFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class streamFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class streamFunction
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
tmp<pointScalarField> calc(const surfaceScalarField& phi) const;
|
||||
|
||||
//- Calculate the stream-function and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("streamFunction");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
streamFunction
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~streamFunction();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
677
src/functionObjects/field/streamLine/streamLine.C
Normal file
677
src/functionObjects/field/streamLine/streamLine.C
Normal file
@ -0,0 +1,677 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Pstream.H"
|
||||
#include "functionObjectList.H"
|
||||
#include "streamLine.H"
|
||||
#include "streamLineParticleCloud.H"
|
||||
#include "ReadFields.H"
|
||||
#include "meshSearch.H"
|
||||
#include "sampledSet.H"
|
||||
#include "globalIndex.H"
|
||||
#include "mapDistribute.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
#include "PatchTools.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(streamLine, 0);
|
||||
addToRunTimeSelectionTable(functionObject, streamLine, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::indirectPrimitivePatch>
|
||||
Foam::functionObjects::streamLine::wallPatch() const
|
||||
{
|
||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||
|
||||
label nFaces = 0;
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
if (isA<wallPolyPatch>(patches[patchi]))
|
||||
{
|
||||
nFaces += patches[patchi].size();
|
||||
}
|
||||
}
|
||||
|
||||
labelList addressing(nFaces);
|
||||
|
||||
nFaces = 0;
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
if (isA<wallPolyPatch>(patches[patchi]))
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
forAll(pp, i)
|
||||
{
|
||||
addressing[nFaces++] = pp.start()+i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return autoPtr<indirectPrimitivePatch>
|
||||
(
|
||||
new indirectPrimitivePatch
|
||||
(
|
||||
IndirectList<face>
|
||||
(
|
||||
mesh_.faces(),
|
||||
addressing
|
||||
),
|
||||
mesh_.points()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::streamLine::track()
|
||||
{
|
||||
IDLList<streamLineParticle> initialParticles;
|
||||
streamLineParticleCloud particles
|
||||
(
|
||||
mesh_,
|
||||
cloudName_,
|
||||
initialParticles
|
||||
);
|
||||
|
||||
const sampledSet& seedPoints = sampledSetPtr_();
|
||||
|
||||
forAll(seedPoints, i)
|
||||
{
|
||||
particles.addParticle
|
||||
(
|
||||
new streamLineParticle
|
||||
(
|
||||
mesh_,
|
||||
seedPoints[i],
|
||||
seedPoints.cells()[i],
|
||||
lifeTime_
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
label nSeeds = returnReduce(particles.size(), sumOp<label>());
|
||||
|
||||
Info << " seeded " << nSeeds << " particles" << endl;
|
||||
|
||||
// Read or lookup fields
|
||||
PtrList<volScalarField> vsFlds;
|
||||
PtrList<interpolation<scalar>> vsInterp;
|
||||
PtrList<volVectorField> vvFlds;
|
||||
PtrList<interpolation<vector>> vvInterp;
|
||||
|
||||
label UIndex = -1;
|
||||
|
||||
label nScalar = 0;
|
||||
label nVector = 0;
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
if (mesh_.foundObject<volScalarField>(fields_[i]))
|
||||
{
|
||||
nScalar++;
|
||||
}
|
||||
else if (mesh_.foundObject<volVectorField>(fields_[i]))
|
||||
{
|
||||
nVector++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot find field " << fields_[i] << nl
|
||||
<< "Valid scalar fields are:"
|
||||
<< mesh_.names(volScalarField::typeName) << nl
|
||||
<< "Valid vector fields are:"
|
||||
<< mesh_.names(volVectorField::typeName)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
vsInterp.setSize(nScalar);
|
||||
nScalar = 0;
|
||||
vvInterp.setSize(nVector);
|
||||
nVector = 0;
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
if (mesh_.foundObject<volScalarField>(fields_[i]))
|
||||
{
|
||||
const volScalarField& f = mesh_.lookupObject<volScalarField>
|
||||
(
|
||||
fields_[i]
|
||||
);
|
||||
vsInterp.set
|
||||
(
|
||||
nScalar++,
|
||||
interpolation<scalar>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
f
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (mesh_.foundObject<volVectorField>(fields_[i]))
|
||||
{
|
||||
const volVectorField& f = mesh_.lookupObject<volVectorField>
|
||||
(
|
||||
fields_[i]
|
||||
);
|
||||
|
||||
if (f.name() == UName_)
|
||||
{
|
||||
UIndex = nVector;
|
||||
}
|
||||
|
||||
vvInterp.set
|
||||
(
|
||||
nVector++,
|
||||
interpolation<vector>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
f
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Store the names
|
||||
scalarNames_.setSize(vsInterp.size());
|
||||
forAll(vsInterp, i)
|
||||
{
|
||||
scalarNames_[i] = vsInterp[i].psi().name();
|
||||
}
|
||||
vectorNames_.setSize(vvInterp.size());
|
||||
forAll(vvInterp, i)
|
||||
{
|
||||
vectorNames_[i] = vvInterp[i].psi().name();
|
||||
}
|
||||
|
||||
// Check that we know the index of U in the interpolators.
|
||||
|
||||
if (UIndex == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot find field to move particles with : " << UName_ << nl
|
||||
<< "This field has to be present in the sampled fields " << fields_
|
||||
<< " and in the objectRegistry."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Sampled data
|
||||
// ~~~~~~~~~~~~
|
||||
|
||||
// Size to maximum expected sizes.
|
||||
allTracks_.clear();
|
||||
allTracks_.setCapacity(nSeeds);
|
||||
allScalars_.setSize(vsInterp.size());
|
||||
forAll(allScalars_, i)
|
||||
{
|
||||
allScalars_[i].clear();
|
||||
allScalars_[i].setCapacity(nSeeds);
|
||||
}
|
||||
allVectors_.setSize(vvInterp.size());
|
||||
forAll(allVectors_, i)
|
||||
{
|
||||
allVectors_[i].clear();
|
||||
allVectors_[i].setCapacity(nSeeds);
|
||||
}
|
||||
|
||||
|
||||
// Additional particle info
|
||||
streamLineParticle::trackingData td
|
||||
(
|
||||
particles,
|
||||
vsInterp,
|
||||
vvInterp,
|
||||
UIndex, // index of U in vvInterp
|
||||
trackForward_, // track in +u direction?
|
||||
nSubCycle_, // automatic track control:step through cells in steps?
|
||||
trackLength_, // fixed track length
|
||||
|
||||
allTracks_,
|
||||
allScalars_,
|
||||
allVectors_
|
||||
);
|
||||
|
||||
|
||||
// Set very large dt. Note: cannot use GREAT since 1/GREAT is SMALL
|
||||
// which is a trigger value for the tracking...
|
||||
const scalar trackTime = Foam::sqrt(GREAT);
|
||||
|
||||
// Track
|
||||
particles.move(td, trackTime);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::streamLine::streamLine
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
dict_(dict),
|
||||
nSubCycle_(0)
|
||||
{
|
||||
read(dict_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::streamLine::~streamLine()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::streamLine::read(const dictionary& dict)
|
||||
{
|
||||
if (dict != dict_)
|
||||
{
|
||||
dict_ = dict;
|
||||
}
|
||||
|
||||
Info<< type() << " " << name() << ":" << nl;
|
||||
|
||||
dict.lookup("fields") >> fields_;
|
||||
if (dict.found("U"))
|
||||
{
|
||||
dict.lookup("U") >> UName_;
|
||||
}
|
||||
else
|
||||
{
|
||||
UName_ = "U";
|
||||
if (dict.found("U"))
|
||||
{
|
||||
IOWarningInFunction(dict)
|
||||
<< "Using deprecated entry \"U\"."
|
||||
<< " Please use \"UName\" instead."
|
||||
<< endl;
|
||||
dict.lookup("U") >> UName_;
|
||||
}
|
||||
}
|
||||
|
||||
if (findIndex(fields_, UName_) == -1)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Velocity field for tracking " << UName_
|
||||
<< " should be present in the list of fields " << fields_
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
dict.lookup("trackForward") >> trackForward_;
|
||||
dict.lookup("lifeTime") >> lifeTime_;
|
||||
if (lifeTime_ < 1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Illegal value " << lifeTime_ << " for lifeTime"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
bool subCycling = dict.found("nSubCycle");
|
||||
bool fixedLength = dict.found("trackLength");
|
||||
|
||||
if (subCycling && fixedLength)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Cannot both specify automatic time stepping (through '"
|
||||
<< "nSubCycle' specification) and fixed track length (through '"
|
||||
<< "trackLength')"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
nSubCycle_ = 1;
|
||||
if (dict.readIfPresent("nSubCycle", nSubCycle_))
|
||||
{
|
||||
trackLength_ = VGREAT;
|
||||
if (nSubCycle_ < 1)
|
||||
{
|
||||
nSubCycle_ = 1;
|
||||
}
|
||||
Info<< " automatic track length specified through"
|
||||
<< " number of sub cycles : " << nSubCycle_ << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
dict.lookup("trackLength") >> trackLength_;
|
||||
|
||||
Info<< " fixed track length specified : "
|
||||
<< trackLength_ << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
interpolationScheme_ = dict.lookupOrDefault
|
||||
(
|
||||
"interpolationScheme",
|
||||
interpolationCellPoint<scalar>::typeName
|
||||
);
|
||||
|
||||
cloudName_ = dict.lookupOrDefault<word>("cloudName", "streamLine");
|
||||
dict.lookup("seedSampleSet") >> seedSet_;
|
||||
|
||||
meshSearchPtr_.reset(new meshSearch(mesh_));
|
||||
|
||||
const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs");
|
||||
sampledSetPtr_ = sampledSet::New
|
||||
(
|
||||
seedSet_,
|
||||
mesh_,
|
||||
meshSearchPtr_(),
|
||||
coeffsDict
|
||||
);
|
||||
coeffsDict.lookup("axis") >> sampledSetAxis_;
|
||||
|
||||
scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
|
||||
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::streamLine::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::streamLine::write()
|
||||
{
|
||||
Info<< type() << " " << name() << " write:" << nl;
|
||||
|
||||
const Time& runTime = obr_.time();
|
||||
|
||||
// Do all injection and tracking
|
||||
track();
|
||||
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Append slave tracks to master ones
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
globalIndex globalTrackIDs(allTracks_.size());
|
||||
|
||||
// Construct a distribution map to pull all to the master.
|
||||
labelListList sendMap(Pstream::nProcs());
|
||||
labelListList recvMap(Pstream::nProcs());
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Master: receive all. My own first, then consecutive
|
||||
// processors.
|
||||
label trackI = 0;
|
||||
|
||||
forAll(recvMap, proci)
|
||||
{
|
||||
labelList& fromProc = recvMap[proci];
|
||||
fromProc.setSize(globalTrackIDs.localSize(proci));
|
||||
forAll(fromProc, i)
|
||||
{
|
||||
fromProc[i] = trackI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
labelList& toMaster = sendMap[0];
|
||||
toMaster.setSize(globalTrackIDs.localSize());
|
||||
forAll(toMaster, i)
|
||||
{
|
||||
toMaster[i] = i;
|
||||
}
|
||||
|
||||
const mapDistribute distMap
|
||||
(
|
||||
globalTrackIDs.size(),
|
||||
sendMap.xfer(),
|
||||
recvMap.xfer()
|
||||
);
|
||||
|
||||
|
||||
// Distribute the track positions. Note: use scheduled comms
|
||||
// to prevent buffering.
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
false,
|
||||
allTracks_,
|
||||
flipOp()
|
||||
);
|
||||
|
||||
// Distribute the scalars
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
allScalars_[scalarI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
false,
|
||||
allScalars_[scalarI],
|
||||
flipOp()
|
||||
);
|
||||
allScalars_[scalarI].setCapacity(allScalars_[scalarI].size());
|
||||
}
|
||||
// Distribute the vectors
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
allVectors_[vectorI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
false,
|
||||
allVectors_[vectorI],
|
||||
flipOp()
|
||||
);
|
||||
allVectors_[vectorI].setCapacity(allVectors_[vectorI].size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
label n = 0;
|
||||
forAll(allTracks_, trackI)
|
||||
{
|
||||
n += allTracks_[trackI].size();
|
||||
}
|
||||
|
||||
Info<< " Tracks:" << allTracks_.size() << nl
|
||||
<< " Total samples:" << n
|
||||
<< endl;
|
||||
|
||||
|
||||
// Massage into form suitable for writers
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (Pstream::master() && allTracks_.size())
|
||||
{
|
||||
// Make output directory
|
||||
|
||||
fileName vtkPath
|
||||
(
|
||||
Pstream::parRun()
|
||||
? runTime.path()/".."/"postProcessing"/"sets"/name()
|
||||
: runTime.path()/"postProcessing"/"sets"/name()
|
||||
);
|
||||
if (mesh_.name() != fvMesh::defaultRegion)
|
||||
{
|
||||
vtkPath = vtkPath/mesh_.name();
|
||||
}
|
||||
vtkPath = vtkPath/mesh_.time().timeName();
|
||||
|
||||
mkDir(vtkPath);
|
||||
|
||||
// Convert track positions
|
||||
|
||||
PtrList<coordSet> tracks(allTracks_.size());
|
||||
forAll(allTracks_, trackI)
|
||||
{
|
||||
tracks.set
|
||||
(
|
||||
trackI,
|
||||
new coordSet
|
||||
(
|
||||
"track" + Foam::name(trackI),
|
||||
sampledSetAxis_ //"xyz"
|
||||
)
|
||||
);
|
||||
tracks[trackI].transfer(allTracks_[trackI]);
|
||||
}
|
||||
|
||||
// Convert scalar values
|
||||
|
||||
if (allScalars_.size() > 0)
|
||||
{
|
||||
List<List<scalarField>> scalarValues(allScalars_.size());
|
||||
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
DynamicList<scalarList>& allTrackVals =
|
||||
allScalars_[scalarI];
|
||||
scalarValues[scalarI].setSize(allTrackVals.size());
|
||||
|
||||
forAll(allTrackVals, trackI)
|
||||
{
|
||||
scalarList& trackVals = allTrackVals[trackI];
|
||||
scalarValues[scalarI][trackI].transfer(trackVals);
|
||||
}
|
||||
}
|
||||
|
||||
fileName vtkFile
|
||||
(
|
||||
vtkPath
|
||||
/ scalarFormatterPtr_().getFileName
|
||||
(
|
||||
tracks[0],
|
||||
scalarNames_
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Writing data to " << vtkFile.path() << endl;
|
||||
|
||||
scalarFormatterPtr_().write
|
||||
(
|
||||
true, // writeTracks
|
||||
tracks,
|
||||
scalarNames_,
|
||||
scalarValues,
|
||||
OFstream(vtkFile)()
|
||||
);
|
||||
}
|
||||
|
||||
// Convert vector values
|
||||
|
||||
if (allVectors_.size() > 0)
|
||||
{
|
||||
List<List<vectorField>> vectorValues(allVectors_.size());
|
||||
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
DynamicList<vectorList>& allTrackVals =
|
||||
allVectors_[vectorI];
|
||||
vectorValues[vectorI].setSize(allTrackVals.size());
|
||||
|
||||
forAll(allTrackVals, trackI)
|
||||
{
|
||||
vectorList& trackVals = allTrackVals[trackI];
|
||||
vectorValues[vectorI][trackI].transfer(trackVals);
|
||||
}
|
||||
}
|
||||
|
||||
fileName vtkFile
|
||||
(
|
||||
vtkPath
|
||||
/ vectorFormatterPtr_().getFileName
|
||||
(
|
||||
tracks[0],
|
||||
vectorNames_
|
||||
)
|
||||
);
|
||||
|
||||
vectorFormatterPtr_().write
|
||||
(
|
||||
true, // writeTracks
|
||||
tracks,
|
||||
vectorNames_,
|
||||
vectorValues,
|
||||
OFstream(vtkFile)()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::streamLine::updateMesh(const mapPolyMesh& mpm)
|
||||
{
|
||||
if (&mpm.mesh() == &mesh_)
|
||||
{
|
||||
read(dict_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::streamLine::movePoints(const polyMesh& mesh)
|
||||
{
|
||||
if (&mesh == &mesh_)
|
||||
{
|
||||
// Moving mesh affects the search tree
|
||||
read(dict_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
184
src/functionObjects/field/streamLine/streamLine.H
Normal file
184
src/functionObjects/field/streamLine/streamLine.H
Normal file
@ -0,0 +1,184 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::streamLine
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Generates streamline data by sampling a set of user-specified fields along a
|
||||
particle track, transported by a user-specified velocity field.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
streamLine1
|
||||
{
|
||||
type streamLine;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
|
||||
writeControl writeTime;
|
||||
|
||||
setFormat vtk;
|
||||
trackForward yes;
|
||||
fields
|
||||
(
|
||||
U
|
||||
p
|
||||
);
|
||||
lifeTime 10000;
|
||||
trackLength 1e-3;
|
||||
nSubCycle 5;
|
||||
bounds (0.2 -10 -10)(0.22 10 10);
|
||||
cloudName particleTracks;
|
||||
seedSampleSet uniform;
|
||||
uniformCoeffs
|
||||
{
|
||||
type uniform;
|
||||
axis x; //distance;
|
||||
start (-0.0205 0.0001 0.00001);
|
||||
end (-0.0205 0.0005 0.00001);
|
||||
nPoints 100;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: streamLine | yes |
|
||||
setFormat | Output data type | yes |
|
||||
U | Tracking velocity field name | yes |
|
||||
fields | Fields to sample | yes |
|
||||
lifetime | Maximum number of particle tracking steps | yes |
|
||||
trackLength | Tracking segment length | no |
|
||||
nSubCycle | Number of tracking steps per cell | no|
|
||||
cloudName | Cloud name to use | yes |
|
||||
bounds | Bounding box to trim tracks | no | greatBox
|
||||
seedSampleSet| Seeding method (see below)| yes |
|
||||
\endtable
|
||||
|
||||
Where \c seedSampleSet is typically one of
|
||||
\plaintable
|
||||
uniform | uniform particle seeding
|
||||
cloud | cloud of points
|
||||
triSurfaceMeshPointSet | points according to a tri-surface mesh
|
||||
\endplaintable
|
||||
|
||||
Note
|
||||
When specifying the track resolution, the \c trackLength OR \c nSubCycle
|
||||
option should be used
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::timeControl
|
||||
Foam::sampledSet
|
||||
Foam::wallBoundedStreamLine
|
||||
Foam::streamLineBase
|
||||
|
||||
SourceFiles
|
||||
streamLine.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_streamLine_H
|
||||
#define functionObjects_streamLine_H
|
||||
|
||||
#include "streamLineBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class streamLine Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class streamLine
|
||||
:
|
||||
public streamLineBase
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Number of subcycling steps
|
||||
label nSubCycle_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
streamLine(const streamLine&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const streamLine&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("streamLine");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
streamLine
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~streamLine();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read settings
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Do the actual tracking to fill the track data
|
||||
virtual void track();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
987
src/functionObjects/field/streamLine/streamLineBase.C
Normal file
987
src/functionObjects/field/streamLine/streamLineBase.C
Normal file
@ -0,0 +1,987 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "streamLineBase.H"
|
||||
#include "fvMesh.H"
|
||||
#include "ReadFields.H"
|
||||
#include "sampledSet.H"
|
||||
#include "globalIndex.H"
|
||||
#include "mapDistribute.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "meshSearchMeshObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(streamLineBase, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::indirectPrimitivePatch>
|
||||
Foam::streamLineBase::wallPatch() const
|
||||
{
|
||||
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
label nFaces = 0;
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
//if (!polyPatch::constraintType(patches[patchI].type()))
|
||||
if (isA<wallPolyPatch>(patches[patchI]))
|
||||
{
|
||||
nFaces += patches[patchI].size();
|
||||
}
|
||||
}
|
||||
|
||||
labelList addressing(nFaces);
|
||||
|
||||
nFaces = 0;
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
//if (!polyPatch::constraintType(patches[patchI].type()))
|
||||
if (isA<wallPolyPatch>(patches[patchI]))
|
||||
{
|
||||
const polyPatch& pp = patches[patchI];
|
||||
|
||||
forAll(pp, i)
|
||||
{
|
||||
addressing[nFaces++] = pp.start()+i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return autoPtr<indirectPrimitivePatch>
|
||||
(
|
||||
new indirectPrimitivePatch
|
||||
(
|
||||
IndirectList<face>
|
||||
(
|
||||
mesh.faces(),
|
||||
addressing
|
||||
),
|
||||
mesh.points()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineBase::initInterpolations
|
||||
(
|
||||
const label nSeeds,
|
||||
label& UIndex,
|
||||
PtrList<volScalarField>& vsFlds,
|
||||
PtrList<interpolation<scalar>>& vsInterp,
|
||||
PtrList<volVectorField>& vvFlds,
|
||||
PtrList<interpolation<vector>>& vvInterp
|
||||
)
|
||||
{
|
||||
const Time& runTime = obr_.time();
|
||||
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
|
||||
|
||||
// Read or lookup fields
|
||||
|
||||
if (loadFromFiles_)
|
||||
{
|
||||
IOobjectList allObjects(mesh, runTime.timeName());
|
||||
|
||||
IOobjectList objects(2*fields_.size());
|
||||
forAll(fields_, i)
|
||||
{
|
||||
objects.add(*allObjects[fields_[i]]);
|
||||
}
|
||||
|
||||
ReadFields(mesh, objects, vsFlds);
|
||||
vsInterp.setSize(vsFlds.size());
|
||||
forAll(vsFlds, i)
|
||||
{
|
||||
vsInterp.set
|
||||
(
|
||||
i,
|
||||
interpolation<scalar>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
vsFlds[i]
|
||||
)
|
||||
);
|
||||
}
|
||||
ReadFields(mesh, objects, vvFlds);
|
||||
vvInterp.setSize(vvFlds.size());
|
||||
forAll(vvFlds, i)
|
||||
{
|
||||
vvInterp.set
|
||||
(
|
||||
i,
|
||||
interpolation<vector>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
vvFlds[i]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label nScalar = 0;
|
||||
label nVector = 0;
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
if (mesh.foundObject<volScalarField>(fields_[i]))
|
||||
{
|
||||
nScalar++;
|
||||
}
|
||||
else if (mesh.foundObject<volVectorField>(fields_[i]))
|
||||
{
|
||||
nVector++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot find field " << fields_[i] << nl
|
||||
<< "Valid scalar fields are:"
|
||||
<< mesh.names(volScalarField::typeName) << nl
|
||||
<< "Valid vector fields are:"
|
||||
<< mesh.names(volVectorField::typeName)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
vsInterp.setSize(nScalar);
|
||||
nScalar = 0;
|
||||
vvInterp.setSize(nVector);
|
||||
nVector = 0;
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
if (mesh.foundObject<volScalarField>(fields_[i]))
|
||||
{
|
||||
const volScalarField& f = mesh.lookupObject<volScalarField>
|
||||
(
|
||||
fields_[i]
|
||||
);
|
||||
vsInterp.set
|
||||
(
|
||||
nScalar++,
|
||||
interpolation<scalar>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
f
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (mesh.foundObject<volVectorField>(fields_[i]))
|
||||
{
|
||||
const volVectorField& f = mesh.lookupObject<volVectorField>
|
||||
(
|
||||
fields_[i]
|
||||
);
|
||||
|
||||
if (f.name() == UName_)
|
||||
{
|
||||
UIndex = nVector;
|
||||
}
|
||||
|
||||
vvInterp.set
|
||||
(
|
||||
nVector++,
|
||||
interpolation<vector>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
f
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store the names
|
||||
scalarNames_.setSize(vsInterp.size());
|
||||
forAll(vsInterp, i)
|
||||
{
|
||||
scalarNames_[i] = vsInterp[i].psi().name();
|
||||
}
|
||||
vectorNames_.setSize(vvInterp.size());
|
||||
forAll(vvInterp, i)
|
||||
{
|
||||
vectorNames_[i] = vvInterp[i].psi().name();
|
||||
}
|
||||
|
||||
// Check that we know the index of U in the interpolators.
|
||||
|
||||
if (UIndex == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot find field to move particles with : " << UName_ << nl
|
||||
<< "This field has to be present in the sampled fields " << fields_
|
||||
<< " and in the objectRegistry."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Sampled data
|
||||
// ~~~~~~~~~~~~
|
||||
|
||||
// Size to maximum expected sizes.
|
||||
allTracks_.clear();
|
||||
allTracks_.setCapacity(nSeeds);
|
||||
allScalars_.setSize(vsInterp.size());
|
||||
forAll(allScalars_, i)
|
||||
{
|
||||
allScalars_[i].clear();
|
||||
allScalars_[i].setCapacity(nSeeds);
|
||||
}
|
||||
allVectors_.setSize(vvInterp.size());
|
||||
forAll(allVectors_, i)
|
||||
{
|
||||
allVectors_[i].clear();
|
||||
allVectors_[i].setCapacity(nSeeds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineBase::storePoint
|
||||
(
|
||||
const label trackI,
|
||||
|
||||
const scalar w,
|
||||
const label leftI,
|
||||
const label rightI,
|
||||
|
||||
DynamicList<point>& newTrack,
|
||||
DynamicList<scalarList>& newScalars,
|
||||
DynamicList<vectorList>& newVectors
|
||||
) const
|
||||
{
|
||||
label sz = newTrack.size();
|
||||
|
||||
const List<point>& track = allTracks_[trackI];
|
||||
|
||||
newTrack.append((1.0-w)*track[leftI] + w*track[rightI]);
|
||||
|
||||
// Scalars
|
||||
{
|
||||
newScalars.append(scalarList(allScalars_.size()));
|
||||
scalarList& newVals = newScalars[sz];
|
||||
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
const scalarList& trackVals = allScalars_[scalarI][trackI];
|
||||
newVals[scalarI] = (1.0-w)*trackVals[leftI] + w*trackVals[rightI];
|
||||
}
|
||||
}
|
||||
|
||||
// Vectors
|
||||
{
|
||||
newVectors.append(vectorList(allVectors_.size()));
|
||||
vectorList& newVals = newVectors[sz];
|
||||
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
const vectorList& trackVals = allVectors_[vectorI][trackI];
|
||||
newVals[vectorI] = (1.0-w)*trackVals[leftI] + w*trackVals[rightI];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Can split a track into multiple tracks
|
||||
void Foam::streamLineBase::trimToBox
|
||||
(
|
||||
const treeBoundBox& bb,
|
||||
const label trackI,
|
||||
PtrList<DynamicList<point>>& newTracks,
|
||||
PtrList<DynamicList<scalarList>>& newScalars,
|
||||
PtrList<DynamicList<vectorList>>& newVectors
|
||||
) const
|
||||
{
|
||||
const List<point>& track = allTracks_[trackI];
|
||||
if (track.size())
|
||||
{
|
||||
for
|
||||
(
|
||||
label segmentI = 1;
|
||||
segmentI < track.size();
|
||||
segmentI++
|
||||
)
|
||||
{
|
||||
const point& startPt = track[segmentI-1];
|
||||
const point& endPt = track[segmentI];
|
||||
|
||||
const vector d(endPt-startPt);
|
||||
scalar magD = mag(d);
|
||||
if (magD > ROOTVSMALL)
|
||||
{
|
||||
if (bb.contains(startPt))
|
||||
{
|
||||
// Store 1.0*track[segmentI-1]+0*track[segmentI]
|
||||
storePoint
|
||||
(
|
||||
trackI,
|
||||
|
||||
0.0,
|
||||
segmentI-1,
|
||||
segmentI,
|
||||
|
||||
newTracks.last(),
|
||||
newScalars.last(),
|
||||
newVectors.last()
|
||||
);
|
||||
|
||||
if (!bb.contains(endPt))
|
||||
{
|
||||
point clipPt;
|
||||
if (bb.intersects(endPt, startPt, clipPt))
|
||||
{
|
||||
// End of track. Store point and interpolated
|
||||
// values
|
||||
storePoint
|
||||
(
|
||||
trackI,
|
||||
|
||||
mag(clipPt-startPt)/magD,
|
||||
segmentI-1,
|
||||
segmentI,
|
||||
|
||||
newTracks.last(),
|
||||
newScalars.last(),
|
||||
newVectors.last()
|
||||
);
|
||||
|
||||
newTracks.last().shrink();
|
||||
newScalars.last().shrink();
|
||||
newVectors.last().shrink();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// startPt outside box. New track. Get starting point
|
||||
|
||||
point clipPt;
|
||||
if (bb.intersects(startPt, endPt, clipPt))
|
||||
{
|
||||
// New track
|
||||
newTracks.append
|
||||
(
|
||||
new DynamicList<point>(track.size()/10)
|
||||
);
|
||||
newScalars.append
|
||||
(
|
||||
new DynamicList<scalarList>(track.size()/10)
|
||||
);
|
||||
newVectors.append
|
||||
(
|
||||
new DynamicList<vectorList>(track.size()/10)
|
||||
);
|
||||
|
||||
// Store point and interpolated values
|
||||
storePoint
|
||||
(
|
||||
trackI,
|
||||
|
||||
mag(clipPt-startPt)/magD,
|
||||
segmentI-1,
|
||||
segmentI,
|
||||
|
||||
newTracks.last(),
|
||||
newScalars.last(),
|
||||
newVectors.last()
|
||||
);
|
||||
|
||||
if (!bb.contains(endPt))
|
||||
{
|
||||
bb.intersects
|
||||
(
|
||||
endPt,
|
||||
point(clipPt),
|
||||
clipPt
|
||||
);
|
||||
|
||||
// Store point and interpolated values
|
||||
storePoint
|
||||
(
|
||||
trackI,
|
||||
|
||||
mag(clipPt-startPt)/magD,
|
||||
segmentI-1,
|
||||
segmentI,
|
||||
|
||||
newTracks.last(),
|
||||
newScalars.last(),
|
||||
newVectors.last()
|
||||
);
|
||||
|
||||
newTracks.last().shrink();
|
||||
newScalars.last().shrink();
|
||||
newVectors.last().shrink();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Last point
|
||||
if (bb.contains(track.last()))
|
||||
{
|
||||
storePoint
|
||||
(
|
||||
trackI,
|
||||
|
||||
1.0,
|
||||
track.size()-2,
|
||||
track.size()-1,
|
||||
|
||||
newTracks.last(),
|
||||
newScalars.last(),
|
||||
newVectors.last()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineBase::trimToBox(const treeBoundBox& bb)
|
||||
{
|
||||
// Storage for new tracks. Per track, per sample the coordinate (newTracks)
|
||||
// or values for all the sampled fields (newScalars, newVectors)
|
||||
PtrList<DynamicList<point>> newTracks;
|
||||
PtrList<DynamicList<scalarList>> newScalars;
|
||||
PtrList<DynamicList<vectorList>> newVectors;
|
||||
|
||||
forAll(allTracks_, trackI)
|
||||
{
|
||||
const List<point>& track = allTracks_[trackI];
|
||||
|
||||
if (track.size())
|
||||
{
|
||||
// New track. Assume it consists of the whole track
|
||||
newTracks.append(new DynamicList<point>(track.size()));
|
||||
newScalars.append(new DynamicList<scalarList>(track.size()));
|
||||
newVectors.append(new DynamicList<vectorList>(track.size()));
|
||||
|
||||
// Trim, split and append to newTracks
|
||||
trimToBox(bb, trackI, newTracks, newScalars, newVectors);
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer newTracks to allTracks_
|
||||
allTracks_.setSize(newTracks.size());
|
||||
forAll(allTracks_, trackI)
|
||||
{
|
||||
allTracks_[trackI].transfer(newTracks[trackI]);
|
||||
}
|
||||
// Replace track scalars
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
DynamicList<scalarList>& fieldVals = allScalars_[scalarI];
|
||||
fieldVals.setSize(newTracks.size());
|
||||
|
||||
forAll(fieldVals, trackI)
|
||||
{
|
||||
scalarList& trackVals = allScalars_[scalarI][trackI];
|
||||
trackVals.setSize(newScalars[trackI].size());
|
||||
forAll(trackVals, sampleI)
|
||||
{
|
||||
trackVals[sampleI] = newScalars[trackI][sampleI][scalarI];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Replace track vectors
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
DynamicList<vectorList>& fieldVals = allVectors_[vectorI];
|
||||
fieldVals.setSize(newTracks.size());
|
||||
forAll(fieldVals, trackI)
|
||||
{
|
||||
vectorList& trackVals = allVectors_[vectorI][trackI];
|
||||
trackVals.setSize(newVectors[trackI].size());
|
||||
forAll(trackVals, sampleI)
|
||||
{
|
||||
trackVals[sampleI] = newVectors[trackI][sampleI][vectorI];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::streamLineBase::streamLineBase
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectState(obr, name),
|
||||
dict_(dict),
|
||||
obr_(obr),
|
||||
loadFromFiles_(loadFromFiles),
|
||||
log_(true)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::streamLineBase::~streamLineBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::streamLineBase::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_.readIfPresent("log", dict);
|
||||
|
||||
if (log_) Info<< type() << " " << name_ << ":" << nl;
|
||||
|
||||
dict.lookup("fields") >> fields_;
|
||||
if (dict.found("UName"))
|
||||
{
|
||||
dict.lookup("UName") >> UName_;
|
||||
}
|
||||
else
|
||||
{
|
||||
UName_ = "U";
|
||||
if (dict.found("U"))
|
||||
{
|
||||
IOWarningInFunction(dict)
|
||||
<< "Using deprecated entry \"U\"."
|
||||
<< " Please use \"UName\" instead."
|
||||
<< endl;
|
||||
dict.lookup("U") >> UName_;
|
||||
}
|
||||
}
|
||||
|
||||
if (findIndex(fields_, UName_) == -1)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Velocity field for tracking " << UName_
|
||||
<< " should be present in the list of fields " << fields_
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
dict.lookup("trackForward") >> trackForward_;
|
||||
dict.lookup("lifeTime") >> lifeTime_;
|
||||
if (lifeTime_ < 1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Illegal value " << lifeTime_ << " for lifeTime"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
trackLength_ = VGREAT;
|
||||
if (dict.found("trackLength"))
|
||||
{
|
||||
dict.lookup("trackLength") >> trackLength_;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " : fixed track length specified : "
|
||||
<< trackLength_ << nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bounds_ = boundBox::greatBox;
|
||||
if (dict.readIfPresent("bounds", bounds_))
|
||||
{
|
||||
if (log_) Info<< " clipping all segments to " << bounds_ << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
interpolationScheme_ = dict.lookupOrDefault
|
||||
(
|
||||
"interpolationScheme",
|
||||
interpolationCellPoint<scalar>::typeName
|
||||
);
|
||||
|
||||
//if (log_) Info<< " using interpolation " << interpolationScheme_
|
||||
// << endl;
|
||||
|
||||
cloudName_ = dict.lookupOrDefault<word>("cloudName", type());
|
||||
dict.lookup("seedSampleSet") >> seedSet_;
|
||||
|
||||
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
|
||||
|
||||
const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs");
|
||||
|
||||
sampledSetPtr_ = sampledSet::New
|
||||
(
|
||||
seedSet_,
|
||||
mesh,
|
||||
meshSearchMeshObject::New(mesh),
|
||||
coeffsDict
|
||||
);
|
||||
coeffsDict.lookup("axis") >> sampledSetAxis_;
|
||||
|
||||
scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
|
||||
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineBase::execute()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::streamLineBase::end()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::streamLineBase::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::streamLineBase::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
const Time& runTime = obr_.time();
|
||||
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
|
||||
|
||||
|
||||
// Do all injection and tracking
|
||||
track();
|
||||
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Append slave tracks to master ones
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
globalIndex globalTrackIDs(allTracks_.size());
|
||||
|
||||
// Construct a distribution map to pull all to the master.
|
||||
labelListList sendMap(Pstream::nProcs());
|
||||
labelListList recvMap(Pstream::nProcs());
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Master: receive all. My own first, then consecutive
|
||||
// processors.
|
||||
label trackI = 0;
|
||||
|
||||
forAll(recvMap, procI)
|
||||
{
|
||||
labelList& fromProc = recvMap[procI];
|
||||
fromProc.setSize(globalTrackIDs.localSize(procI));
|
||||
forAll(fromProc, i)
|
||||
{
|
||||
fromProc[i] = trackI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
labelList& toMaster = sendMap[0];
|
||||
toMaster.setSize(globalTrackIDs.localSize());
|
||||
forAll(toMaster, i)
|
||||
{
|
||||
toMaster[i] = i;
|
||||
}
|
||||
|
||||
const mapDistribute distMap
|
||||
(
|
||||
globalTrackIDs.size(),
|
||||
sendMap.xfer(),
|
||||
recvMap.xfer()
|
||||
);
|
||||
|
||||
|
||||
// Distribute the track positions. Note: use scheduled comms
|
||||
// to prevent buffering.
|
||||
allTracks_.shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
false,
|
||||
allTracks_,
|
||||
flipOp()
|
||||
);
|
||||
allTracks_.setCapacity(allTracks_.size());
|
||||
|
||||
// Distribute the scalars
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
allScalars_[scalarI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
false,
|
||||
allScalars_[scalarI],
|
||||
flipOp()
|
||||
);
|
||||
allScalars_[scalarI].setCapacity(allScalars_[scalarI].size());
|
||||
}
|
||||
// Distribute the vectors
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
allVectors_[vectorI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
false,
|
||||
allVectors_[vectorI],
|
||||
flipOp()
|
||||
);
|
||||
allVectors_[vectorI].setCapacity(allVectors_[vectorI].size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Note: filenames scattered below since used in global call
|
||||
fileName scalarVtkFile;
|
||||
fileName vectorVtkFile;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (bounds_ != boundBox::greatBox)
|
||||
{
|
||||
// Clip to bounding box
|
||||
trimToBox(treeBoundBox(bounds_));
|
||||
}
|
||||
|
||||
|
||||
label nTracks = 0;
|
||||
label n = 0;
|
||||
forAll(allTracks_, trackI)
|
||||
{
|
||||
if (allTracks_[trackI].size())
|
||||
{
|
||||
nTracks++;
|
||||
n += allTracks_[trackI].size();
|
||||
}
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Tracks:" << nTracks << nl
|
||||
<< " Total samples:" << n
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// Massage into form suitable for writers
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Make output directory
|
||||
|
||||
fileName vtkPath
|
||||
(
|
||||
Pstream::parRun()
|
||||
? runTime.path()/".."/"postProcessing"/"sets"/name()
|
||||
: runTime.path()/"postProcessing"/"sets"/name()
|
||||
);
|
||||
if (mesh.name() != fvMesh::defaultRegion)
|
||||
{
|
||||
vtkPath = vtkPath/mesh.name();
|
||||
}
|
||||
vtkPath = vtkPath/mesh.time().timeName();
|
||||
|
||||
mkDir(vtkPath);
|
||||
|
||||
// Convert track positions (and compact out empty tracks)
|
||||
|
||||
PtrList<coordSet> tracks(nTracks);
|
||||
nTracks = 0;
|
||||
labelList oldToNewTrack(allTracks_.size(), -1);
|
||||
|
||||
forAll(allTracks_, trackI)
|
||||
{
|
||||
if (allTracks_[trackI].size())
|
||||
{
|
||||
tracks.set
|
||||
(
|
||||
nTracks,
|
||||
new coordSet
|
||||
(
|
||||
"track" + Foam::name(nTracks),
|
||||
sampledSetAxis_ //"xyz"
|
||||
)
|
||||
);
|
||||
oldToNewTrack[trackI] = nTracks;
|
||||
tracks[nTracks].transfer(allTracks_[trackI]);
|
||||
nTracks++;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert scalar values
|
||||
|
||||
if (allScalars_.size() > 0)
|
||||
{
|
||||
List<List<scalarField>> scalarValues(allScalars_.size());
|
||||
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
DynamicList<scalarList>& allTrackVals =
|
||||
allScalars_[scalarI];
|
||||
scalarValues[scalarI].setSize(nTracks);
|
||||
|
||||
forAll(allTrackVals, trackI)
|
||||
{
|
||||
scalarList& vals = allTrackVals[trackI];
|
||||
if (vals.size())
|
||||
{
|
||||
label newTrackI = oldToNewTrack[trackI];
|
||||
scalarValues[scalarI][newTrackI].transfer(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scalarVtkFile = fileName
|
||||
(
|
||||
vtkPath
|
||||
/ scalarFormatterPtr_().getFileName
|
||||
(
|
||||
tracks[0],
|
||||
scalarNames_
|
||||
)
|
||||
);
|
||||
|
||||
if (log_) Info
|
||||
<< " Writing data to " << scalarVtkFile.path() << endl;
|
||||
|
||||
scalarFormatterPtr_().write
|
||||
(
|
||||
true, // writeTracks
|
||||
tracks,
|
||||
scalarNames_,
|
||||
scalarValues,
|
||||
OFstream(scalarVtkFile)()
|
||||
);
|
||||
}
|
||||
|
||||
// Convert vector values
|
||||
|
||||
if (allVectors_.size() > 0)
|
||||
{
|
||||
List<List<vectorField>> vectorValues(allVectors_.size());
|
||||
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
DynamicList<vectorList>& allTrackVals =
|
||||
allVectors_[vectorI];
|
||||
vectorValues[vectorI].setSize(nTracks);
|
||||
|
||||
forAll(allTrackVals, trackI)
|
||||
{
|
||||
vectorList& vals = allTrackVals[trackI];
|
||||
if (vals.size())
|
||||
{
|
||||
label newTrackI = oldToNewTrack[trackI];
|
||||
vectorValues[vectorI][newTrackI].transfer(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vectorVtkFile = fileName
|
||||
(
|
||||
vtkPath
|
||||
/ vectorFormatterPtr_().getFileName
|
||||
(
|
||||
tracks[0],
|
||||
vectorNames_
|
||||
)
|
||||
);
|
||||
|
||||
//if (log_) Info<< " Writing vector data to "
|
||||
// << vectorVtkFile << endl;
|
||||
|
||||
vectorFormatterPtr_().write
|
||||
(
|
||||
true, // writeTracks
|
||||
tracks,
|
||||
vectorNames_,
|
||||
vectorValues,
|
||||
OFstream(vectorVtkFile)()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fileNames are generated on the master but setProperty needs to
|
||||
// be across all procs
|
||||
Pstream::scatter(scalarVtkFile);
|
||||
forAll(scalarNames_, nameI)
|
||||
{
|
||||
dictionary propsDict;
|
||||
propsDict.add("file", scalarVtkFile);
|
||||
const word& fieldName = scalarNames_[nameI];
|
||||
setProperty(fieldName, propsDict);
|
||||
}
|
||||
|
||||
Pstream::scatter(vectorVtkFile);
|
||||
forAll(vectorNames_, nameI)
|
||||
{
|
||||
dictionary propsDict;
|
||||
propsDict.add("file", vectorVtkFile);
|
||||
const word& fieldName = vectorNames_[nameI];
|
||||
setProperty(fieldName, propsDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineBase::updateMesh(const mapPolyMesh&)
|
||||
{
|
||||
read(dict_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineBase::movePoints(const polyMesh&)
|
||||
{
|
||||
// Moving mesh affects the search tree
|
||||
read(dict_);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
246
src/functionObjects/field/streamLine/streamLineBase.H
Normal file
246
src/functionObjects/field/streamLine/streamLineBase.H
Normal file
@ -0,0 +1,246 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::streamLineBase
|
||||
|
||||
SeeAlso
|
||||
Foam::streamLine
|
||||
Foam::wallBoundedStreamLine
|
||||
|
||||
SourceFiles
|
||||
streamLineBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef streamLineBase_H
|
||||
#define streamLineBase_H
|
||||
|
||||
#include "functionObjectState.H"
|
||||
#include "DynamicList.H"
|
||||
#include "scalarList.H"
|
||||
#include "vectorList.H"
|
||||
#include "writer.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "interpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class mapPolyMesh;
|
||||
class meshSearch;
|
||||
class sampledSet;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class streamLineBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class streamLineBase
|
||||
:
|
||||
public functionObjectState
|
||||
{
|
||||
protected:
|
||||
|
||||
//- Input dictionary
|
||||
dictionary dict_;
|
||||
|
||||
//- Database this class is registered to
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Load fields from files (not from objectRegistry)
|
||||
bool loadFromFiles_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- List of fields to sample
|
||||
wordList fields_;
|
||||
|
||||
//- Field to transport particle with
|
||||
word UName_;
|
||||
|
||||
//- Interpolation scheme to use
|
||||
word interpolationScheme_;
|
||||
|
||||
//- Whether to use +u or -u
|
||||
bool trackForward_;
|
||||
|
||||
//- Maximum lifetime (= number of cells) of particle
|
||||
label lifeTime_;
|
||||
|
||||
//- Track length
|
||||
scalar trackLength_;
|
||||
|
||||
//- Optional trimming of tracks
|
||||
boundBox bounds_;
|
||||
|
||||
//- Optional specified name of particles
|
||||
word cloudName_;
|
||||
|
||||
//- Type of seed
|
||||
word seedSet_;
|
||||
|
||||
//- Names of scalar fields
|
||||
wordList scalarNames_;
|
||||
|
||||
//- Names of vector fields
|
||||
wordList vectorNames_;
|
||||
|
||||
|
||||
// Demand driven
|
||||
|
||||
//- Mesh searching enigne
|
||||
autoPtr<meshSearch> meshSearchPtr_;
|
||||
|
||||
//- Seed set engine
|
||||
autoPtr<sampledSet> sampledSetPtr_;
|
||||
|
||||
//- Axis of the sampled points to output
|
||||
word sampledSetAxis_;
|
||||
|
||||
//- File writer for scalar data
|
||||
autoPtr<writer<scalar>> scalarFormatterPtr_;
|
||||
|
||||
//- File writer for vector data
|
||||
autoPtr<writer<vector>> vectorFormatterPtr_;
|
||||
|
||||
|
||||
// Generated data
|
||||
|
||||
//- All tracks. Per track the points it passed through
|
||||
DynamicList<List<point>> allTracks_;
|
||||
|
||||
//- Per scalarField, per track, the sampled values
|
||||
List<DynamicList<scalarList>> allScalars_;
|
||||
|
||||
//- Per vectorField, per track, the sampled values
|
||||
List<DynamicList<vectorList>> allVectors_;
|
||||
|
||||
|
||||
//- Construct patch out of all wall patch faces
|
||||
autoPtr<indirectPrimitivePatch> wallPatch() const;
|
||||
|
||||
//- Initialise fields, interpolators and track storage
|
||||
void initInterpolations
|
||||
(
|
||||
const label nSeeds,
|
||||
label& UIndex,
|
||||
PtrList<volScalarField>& vsFlds,
|
||||
PtrList<interpolation<scalar>>& vsInterp,
|
||||
PtrList<volVectorField>& vvFlds,
|
||||
PtrList<interpolation<vector>>& vvInterp
|
||||
);
|
||||
|
||||
//- Generate point and values by interpolating from existing values
|
||||
void storePoint
|
||||
(
|
||||
const label trackI,
|
||||
|
||||
const scalar w,
|
||||
const label leftI,
|
||||
const label rightI,
|
||||
|
||||
DynamicList<point>& newTrack,
|
||||
DynamicList<List<scalar>>& newScalars,
|
||||
DynamicList<List<vector>>& newVectors
|
||||
) const;
|
||||
|
||||
//- Trim and possibly split a track
|
||||
void trimToBox
|
||||
(
|
||||
const treeBoundBox& bb,
|
||||
const label trackI,
|
||||
PtrList<DynamicList<point>>& newTracks,
|
||||
PtrList<DynamicList<scalarList>>& newScalars,
|
||||
PtrList<DynamicList<vectorList>>& newVectors
|
||||
) const;
|
||||
|
||||
//- Trim tracks to bounding box
|
||||
void trimToBox(const treeBoundBox& bb);
|
||||
|
||||
//- Do the actual tracking to fill the track data
|
||||
virtual void track() = 0;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("streamLineBase");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
streamLineBase
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~streamLineBase();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field average data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute the averaging
|
||||
virtual void execute();
|
||||
|
||||
//- Execute the averaging at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Track and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&);
|
||||
|
||||
//- Update for mesh point-motion
|
||||
virtual void movePoints(const polyMesh&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
507
src/functionObjects/field/streamLine/streamLineParticle.C
Normal file
507
src/functionObjects/field/streamLine/streamLineParticle.C
Normal file
@ -0,0 +1,507 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "streamLineParticle.H"
|
||||
#include "vectorFieldIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// defineParticleTypeNameAndDebug(streamLineParticle, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::streamLineParticle::calcSubCycleDeltaT
|
||||
(
|
||||
trackingData& td,
|
||||
const scalar dt,
|
||||
const vector& U
|
||||
) const
|
||||
{
|
||||
particle testParticle(*this);
|
||||
|
||||
bool oldKeepParticle = td.keepParticle;
|
||||
bool oldSwitchProcessor = td.switchProcessor;
|
||||
scalar fraction = testParticle.trackToFace(position()+dt*U, td);
|
||||
td.keepParticle = oldKeepParticle;
|
||||
td.switchProcessor = oldSwitchProcessor;
|
||||
// Adapt the dt to subdivide the trajectory into substeps.
|
||||
return dt*fraction/td.nSubCycle_;
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::streamLineParticle::interpolateFields
|
||||
(
|
||||
const trackingData& td,
|
||||
const point& position,
|
||||
const label celli,
|
||||
const label facei
|
||||
)
|
||||
{
|
||||
if (celli == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cell:" << celli << abort(FatalError);
|
||||
}
|
||||
|
||||
sampledScalars_.setSize(td.vsInterp_.size());
|
||||
forAll(td.vsInterp_, scalarI)
|
||||
{
|
||||
sampledScalars_[scalarI].append
|
||||
(
|
||||
td.vsInterp_[scalarI].interpolate
|
||||
(
|
||||
position,
|
||||
celli,
|
||||
facei
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sampledVectors_.setSize(td.vvInterp_.size());
|
||||
forAll(td.vvInterp_, vectorI)
|
||||
{
|
||||
sampledVectors_[vectorI].append
|
||||
(
|
||||
td.vvInterp_[vectorI].interpolate
|
||||
(
|
||||
position,
|
||||
celli,
|
||||
facei
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const DynamicList<vector>& U = sampledVectors_[td.UIndex_];
|
||||
|
||||
return U.last();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::streamLineParticle::streamLineParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label celli,
|
||||
const label lifeTime
|
||||
)
|
||||
:
|
||||
particle(mesh, position, celli),
|
||||
lifeTime_(lifeTime)
|
||||
{}
|
||||
|
||||
|
||||
Foam::streamLineParticle::streamLineParticle
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields
|
||||
)
|
||||
:
|
||||
particle(mesh, is, readFields)
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
//if (is.format() == IOstream::ASCII)
|
||||
List<scalarList> sampledScalars;
|
||||
List<vectorList> sampledVectors;
|
||||
|
||||
is >> lifeTime_ >> sampledPositions_ >> sampledScalars
|
||||
>> sampledVectors;
|
||||
|
||||
sampledScalars_.setSize(sampledScalars.size());
|
||||
forAll(sampledScalars, i)
|
||||
{
|
||||
sampledScalars_[i].transfer(sampledScalars[i]);
|
||||
}
|
||||
sampledVectors_.setSize(sampledVectors.size());
|
||||
forAll(sampledVectors, i)
|
||||
{
|
||||
sampledVectors_[i].transfer(sampledVectors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Check state of Istream
|
||||
is.check
|
||||
(
|
||||
"streamLineParticle::streamLineParticle"
|
||||
"(const Cloud<streamLineParticle>&, Istream&, bool)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::streamLineParticle::streamLineParticle
|
||||
(
|
||||
const streamLineParticle& p
|
||||
)
|
||||
:
|
||||
particle(p),
|
||||
lifeTime_(p.lifeTime_),
|
||||
sampledPositions_(p.sampledPositions_),
|
||||
sampledScalars_(p.sampledScalars_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::streamLineParticle::move
|
||||
(
|
||||
trackingData& td,
|
||||
const scalar trackTime
|
||||
)
|
||||
{
|
||||
streamLineParticle& p = static_cast<streamLineParticle&>(*this);
|
||||
|
||||
td.switchProcessor = false;
|
||||
td.keepParticle = true;
|
||||
|
||||
scalar tEnd = (1.0 - stepFraction())*trackTime;
|
||||
scalar maxDt = mesh_.bounds().mag();
|
||||
|
||||
while
|
||||
(
|
||||
td.keepParticle
|
||||
&& !td.switchProcessor
|
||||
&& lifeTime_ > 0
|
||||
)
|
||||
{
|
||||
// set the lagrangian time-step
|
||||
scalar dt = maxDt;
|
||||
|
||||
// Cross cell in steps:
|
||||
// - at subiter 0 calculate dt to cross cell in nSubCycle steps
|
||||
// - at the last subiter do all of the remaining track
|
||||
for (label subIter = 0; subIter < td.nSubCycle_; subIter++)
|
||||
{
|
||||
--lifeTime_;
|
||||
|
||||
// Store current position and sampled velocity.
|
||||
sampledPositions_.append(position());
|
||||
vector U = interpolateFields(td, position(), cell(), face());
|
||||
|
||||
if (!td.trackForward_)
|
||||
{
|
||||
U = -U;
|
||||
}
|
||||
|
||||
scalar magU = mag(U);
|
||||
|
||||
if (magU < SMALL)
|
||||
{
|
||||
// Stagnant particle. Might as well stop
|
||||
lifeTime_ = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
U /= magU;
|
||||
|
||||
if (td.trackLength_ < GREAT)
|
||||
{
|
||||
dt = td.trackLength_;
|
||||
//Pout<< " subiteration " << subIter
|
||||
// << " : fixed length: updated dt:" << dt << endl;
|
||||
}
|
||||
else if (subIter == 0 && td.nSubCycle_ > 1)
|
||||
{
|
||||
// Adapt dt to cross cell in a few steps
|
||||
dt = calcSubCycleDeltaT(td, dt, U);
|
||||
}
|
||||
else if (subIter == td.nSubCycle_ - 1)
|
||||
{
|
||||
// Do full step on last subcycle
|
||||
dt = maxDt;
|
||||
}
|
||||
|
||||
|
||||
scalar fraction = trackToFace(position() + dt*U, td);
|
||||
dt *= fraction;
|
||||
|
||||
tEnd -= dt;
|
||||
stepFraction() = 1.0 - tEnd/trackTime;
|
||||
|
||||
if (tEnd <= ROOTVSMALL)
|
||||
{
|
||||
// Force removal
|
||||
lifeTime_ = 0;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
face() != -1
|
||||
|| !td.keepParticle
|
||||
|| td.switchProcessor
|
||||
|| lifeTime_ == 0
|
||||
)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!td.keepParticle || lifeTime_ == 0)
|
||||
{
|
||||
if (lifeTime_ == 0)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "streamLineParticle : Removing stagnant particle:"
|
||||
<< p.position()
|
||||
<< " sampled positions:" << sampledPositions_.size()
|
||||
<< endl;
|
||||
}
|
||||
td.keepParticle = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal exit. Store last position and fields
|
||||
sampledPositions_.append(position());
|
||||
interpolateFields(td, position(), cell(), face());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "streamLineParticle : Removing particle:"
|
||||
<< p.position()
|
||||
<< " sampled positions:" << sampledPositions_.size()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer particle data into trackingData.
|
||||
//td.allPositions_.append(sampledPositions_);
|
||||
td.allPositions_.append(vectorList());
|
||||
vectorList& top = td.allPositions_.last();
|
||||
top.transfer(sampledPositions_);
|
||||
|
||||
forAll(sampledScalars_, i)
|
||||
{
|
||||
//td.allScalars_[i].append(sampledScalars_[i]);
|
||||
td.allScalars_[i].append(scalarList());
|
||||
scalarList& top = td.allScalars_[i].last();
|
||||
top.transfer(sampledScalars_[i]);
|
||||
}
|
||||
forAll(sampledVectors_, i)
|
||||
{
|
||||
//td.allVectors_[i].append(sampledVectors_[i]);
|
||||
td.allVectors_[i].append(vectorList());
|
||||
vectorList& top = td.allVectors_[i].last();
|
||||
top.transfer(sampledVectors_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return td.keepParticle;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::streamLineParticle::hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
trackingData& td,
|
||||
const label patchi,
|
||||
const scalar trackFraction,
|
||||
const tetIndices& tetIs
|
||||
)
|
||||
{
|
||||
// Disable generic patch interaction
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::hitWedgePatch
|
||||
(
|
||||
const wedgePolyPatch& pp,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::hitSymmetryPlanePatch
|
||||
(
|
||||
const symmetryPlanePolyPatch& pp,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::hitSymmetryPatch
|
||||
(
|
||||
const symmetryPolyPatch& pp,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::hitCyclicPatch
|
||||
(
|
||||
const cyclicPolyPatch& pp,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Switch particle
|
||||
td.switchProcessor = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::hitWallPatch
|
||||
(
|
||||
const wallPolyPatch& wpp,
|
||||
trackingData& td,
|
||||
const tetIndices&
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::hitPatch
|
||||
(
|
||||
const polyPatch& wpp,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
// Remove particle
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::readFields(Cloud<streamLineParticle>& c)
|
||||
{
|
||||
if (!c.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
particle::readFields(c);
|
||||
|
||||
IOField<label> lifeTime
|
||||
(
|
||||
c.fieldIOobject("lifeTime", IOobject::MUST_READ)
|
||||
);
|
||||
c.checkFieldIOobject(c, lifeTime);
|
||||
|
||||
vectorFieldIOField sampledPositions
|
||||
(
|
||||
c.fieldIOobject("sampledPositions", IOobject::MUST_READ)
|
||||
);
|
||||
c.checkFieldIOobject(c, sampledPositions);
|
||||
|
||||
// vectorFieldIOField sampleVelocity
|
||||
// (
|
||||
// c.fieldIOobject("sampleVelocity", IOobject::MUST_READ)
|
||||
// );
|
||||
// c.checkFieldIOobject(c, sampleVelocity);
|
||||
|
||||
label i = 0;
|
||||
forAllIter(Cloud<streamLineParticle>, c, iter)
|
||||
{
|
||||
iter().lifeTime_ = lifeTime[i];
|
||||
iter().sampledPositions_.transfer(sampledPositions[i]);
|
||||
// iter().sampleVelocity_.transfer(sampleVelocity[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c)
|
||||
{
|
||||
particle::writeFields(c);
|
||||
|
||||
label np = c.size();
|
||||
|
||||
IOField<label> lifeTime
|
||||
(
|
||||
c.fieldIOobject("lifeTime", IOobject::NO_READ),
|
||||
np
|
||||
);
|
||||
vectorFieldIOField sampledPositions
|
||||
(
|
||||
c.fieldIOobject("sampledPositions", IOobject::NO_READ),
|
||||
np
|
||||
);
|
||||
// vectorFieldIOField sampleVelocity
|
||||
// (
|
||||
// c.fieldIOobject("sampleVelocity", IOobject::NO_READ),
|
||||
// np
|
||||
// );
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(Cloud<streamLineParticle>, c, iter)
|
||||
{
|
||||
lifeTime[i] = iter().lifeTime_;
|
||||
sampledPositions[i] = iter().sampledPositions_;
|
||||
// sampleVelocity[i] = iter().sampleVelocity_;
|
||||
i++;
|
||||
}
|
||||
|
||||
lifeTime.write();
|
||||
sampledPositions.write();
|
||||
// sampleVelocity.write();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const streamLineParticle& p)
|
||||
{
|
||||
os << static_cast<const particle&>(p)
|
||||
<< token::SPACE << p.lifeTime_
|
||||
<< token::SPACE << p.sampledPositions_
|
||||
<< token::SPACE << p.sampledScalars_
|
||||
<< token::SPACE << p.sampledVectors_;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const streamLineParticle&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
317
src/functionObjects/field/streamLine/streamLineParticle.H
Normal file
317
src/functionObjects/field/streamLine/streamLineParticle.H
Normal file
@ -0,0 +1,317 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::streamLineParticle
|
||||
|
||||
Description
|
||||
Particle class that samples fields as it passes through. Used in streamline
|
||||
calculation.
|
||||
|
||||
SourceFiles
|
||||
streamLineParticle.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef streamLineParticle_H
|
||||
#define streamLineParticle_H
|
||||
|
||||
#include "particle.H"
|
||||
#include "autoPtr.H"
|
||||
#include "interpolation.H"
|
||||
#include "vectorList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class streamLineParticleCloud;
|
||||
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class streamLineParticle;
|
||||
|
||||
Ostream& operator<<(Ostream&, const streamLineParticle&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class streamLineParticle Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class streamLineParticle
|
||||
:
|
||||
public particle
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Class used to pass tracking data to the trackToFace function
|
||||
class trackingData
|
||||
:
|
||||
public particle::TrackingData<Cloud<streamLineParticle>>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
const PtrList<interpolation<scalar>>& vsInterp_;
|
||||
const PtrList<interpolation<vector>>& vvInterp_;
|
||||
const label UIndex_;
|
||||
const bool trackForward_;
|
||||
const label nSubCycle_;
|
||||
const scalar trackLength_;
|
||||
|
||||
DynamicList<vectorList>& allPositions_;
|
||||
List<DynamicList<scalarList>>& allScalars_;
|
||||
List<DynamicList<vectorList>>& allVectors_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
trackingData
|
||||
(
|
||||
Cloud<streamLineParticle>& cloud,
|
||||
const PtrList<interpolation<scalar>>& vsInterp,
|
||||
const PtrList<interpolation<vector>>& vvInterp,
|
||||
const label UIndex,
|
||||
const bool trackForward,
|
||||
const label nSubCycle,
|
||||
const scalar trackLength,
|
||||
|
||||
DynamicList<List<point>>& allPositions,
|
||||
List<DynamicList<scalarList>>& allScalars,
|
||||
List<DynamicList<vectorList>>& allVectors
|
||||
)
|
||||
:
|
||||
particle::TrackingData<Cloud<streamLineParticle>>(cloud),
|
||||
vsInterp_(vsInterp),
|
||||
vvInterp_(vvInterp),
|
||||
UIndex_(UIndex),
|
||||
trackForward_(trackForward),
|
||||
nSubCycle_(nSubCycle),
|
||||
trackLength_(trackLength),
|
||||
|
||||
allPositions_(allPositions),
|
||||
allScalars_(allScalars),
|
||||
allVectors_(allVectors)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Lifetime of particle. Particle dies when reaches 0.
|
||||
label lifeTime_;
|
||||
|
||||
//- Sampled positions
|
||||
DynamicList<point> sampledPositions_;
|
||||
|
||||
//- Sampled scalars
|
||||
List<DynamicList<scalar>> sampledScalars_;
|
||||
|
||||
//- Sampled vectors
|
||||
List<DynamicList<vector>> sampledVectors_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Estimate dt to cross from current face to next one in nSubCycle
|
||||
// steps.
|
||||
scalar calcSubCycleDeltaT
|
||||
(
|
||||
trackingData& td,
|
||||
const scalar dt,
|
||||
const vector& U
|
||||
) const;
|
||||
|
||||
void constrainVelocity
|
||||
(
|
||||
trackingData& td,
|
||||
const scalar dt,
|
||||
vector& U
|
||||
);
|
||||
|
||||
//- Interpolate all quantities; return interpolated velocity.
|
||||
vector interpolateFields
|
||||
(
|
||||
const trackingData&,
|
||||
const point&,
|
||||
const label celli,
|
||||
const label facei
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
streamLineParticle
|
||||
(
|
||||
const polyMesh& c,
|
||||
const vector& position,
|
||||
const label celli,
|
||||
const label lifeTime
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
streamLineParticle
|
||||
(
|
||||
const polyMesh& c,
|
||||
Istream& is,
|
||||
bool readFields = true
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
streamLineParticle(const streamLineParticle& p);
|
||||
|
||||
//- Construct and return a clone
|
||||
autoPtr<particle> clone() const
|
||||
{
|
||||
return autoPtr<particle>(new streamLineParticle(*this));
|
||||
}
|
||||
|
||||
//- Factory class to read-construct particles used for
|
||||
// parallel transfer
|
||||
class iNew
|
||||
{
|
||||
const polyMesh& mesh_;
|
||||
|
||||
public:
|
||||
|
||||
iNew(const polyMesh& mesh)
|
||||
:
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
autoPtr<streamLineParticle> operator()(Istream& is) const
|
||||
{
|
||||
return autoPtr<streamLineParticle>
|
||||
(
|
||||
new streamLineParticle(mesh_, is, true)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Tracking
|
||||
|
||||
//- Track all particles to their end point
|
||||
bool move(trackingData&, const scalar trackTime);
|
||||
|
||||
|
||||
//- Overridable function to handle the particle hitting a patch
|
||||
// Executed before other patch-hitting functions
|
||||
bool hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
trackingData& td,
|
||||
const label patchi,
|
||||
const scalar trackFraction,
|
||||
const tetIndices& tetIs
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a wedge
|
||||
void hitWedgePatch
|
||||
(
|
||||
const wedgePolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a
|
||||
// symmetry plane
|
||||
void hitSymmetryPlanePatch
|
||||
(
|
||||
const symmetryPlanePolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a
|
||||
// symmetry patch
|
||||
void hitSymmetryPatch
|
||||
(
|
||||
const symmetryPolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a cyclic
|
||||
void hitCyclicPatch
|
||||
(
|
||||
const cyclicPolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a
|
||||
//- processorPatch
|
||||
void hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a wallPatch
|
||||
void hitWallPatch
|
||||
(
|
||||
const wallPolyPatch&,
|
||||
trackingData& td,
|
||||
const tetIndices&
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a polyPatch
|
||||
void hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Read
|
||||
static void readFields(Cloud<streamLineParticle>&);
|
||||
|
||||
//- Write
|
||||
static void writeFields(const Cloud<streamLineParticle>&);
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const streamLineParticle&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "streamLineParticleCloud.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTemplateTypeNameAndDebug(Cloud<streamLineParticle>, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::streamLineParticleCloud::streamLineParticleCloud
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& cloudName,
|
||||
bool readFields
|
||||
)
|
||||
:
|
||||
Cloud<streamLineParticle>(mesh, cloudName, false)
|
||||
{
|
||||
if (readFields)
|
||||
{
|
||||
streamLineParticle::readFields(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::streamLineParticleCloud::streamLineParticleCloud
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& cloudName,
|
||||
const IDLList<streamLineParticle>& particles
|
||||
)
|
||||
:
|
||||
Cloud<streamLineParticle>(mesh, cloudName, particles)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user