mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
new foamCalc app and foamCalcFunctions lib, to eventually replace current postProcess functionality
This commit is contained in:
9
src/postProcessing/foamCalcFunctions/Make/files
Normal file
9
src/postProcessing/foamCalcFunctions/Make/files
Normal file
@ -0,0 +1,9 @@
|
||||
calcType/calcType.C
|
||||
calcType/newCalcType.C
|
||||
|
||||
field/components/components.C
|
||||
field/mag/mag.C
|
||||
field/magSqr/magSqr.C
|
||||
field/magGrad/magGrad.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfoamCalcFunctions
|
||||
5
src/postProcessing/foamCalcFunctions/Make/options
Normal file
5
src/postProcessing/foamCalcFunctions/Make/options
Normal file
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume
|
||||
166
src/postProcessing/foamCalcFunctions/calcType/calcType.C
Normal file
166
src/postProcessing/foamCalcFunctions/calcType/calcType.C
Normal file
@ -0,0 +1,166 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "calcType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(calcType, 0);
|
||||
|
||||
defineRunTimeSelectionTable(calcType, dictionary);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcType::calcType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcType::~calcType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::calcType::init()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcType::preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcType::calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcType::postCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::calcType::tryInit()
|
||||
{
|
||||
FatalIOError.throwExceptions();
|
||||
|
||||
try
|
||||
{
|
||||
init();
|
||||
}
|
||||
catch(IOerror& err)
|
||||
{
|
||||
Warning<< err << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcType::tryPreCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
FatalIOError.throwExceptions();
|
||||
|
||||
try
|
||||
{
|
||||
preCalc(args, runTime, mesh);
|
||||
}
|
||||
catch(IOerror& err)
|
||||
{
|
||||
Warning<< err << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcType::tryCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
FatalIOError.throwExceptions();
|
||||
|
||||
try
|
||||
{
|
||||
calc(args, runTime, mesh);
|
||||
}
|
||||
catch(IOerror& err)
|
||||
{
|
||||
Warning<< err << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcType::tryPostCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
FatalIOError.throwExceptions();
|
||||
|
||||
try
|
||||
{
|
||||
postCalc(args, runTime, mesh);
|
||||
}
|
||||
catch(IOerror& err)
|
||||
{
|
||||
Warning<< err << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
175
src/postProcessing/foamCalcFunctions/calcType/calcType.H
Normal file
175
src/postProcessing/foamCalcFunctions/calcType/calcType.H
Normal file
@ -0,0 +1,175 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::calcType
|
||||
|
||||
Description
|
||||
Base class for post-processing calculation functions
|
||||
|
||||
SourceFiles
|
||||
calcType.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef calcType_H
|
||||
#define calcType_H
|
||||
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
#include "fvCFD.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class calcType Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class calcType
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
calcType(const calcType&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const calcType&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected member functions
|
||||
|
||||
// Calculation routines
|
||||
|
||||
//- Initialise - typically setting static variables,
|
||||
// e.g. command line arguments
|
||||
virtual void init();
|
||||
|
||||
//- Pre-time loop calculations
|
||||
virtual void preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Time loop calculations
|
||||
virtual void calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Post-time loop calculations
|
||||
virtual void postCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("calcType");
|
||||
|
||||
|
||||
// Declare runtime constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
calcType,
|
||||
dictionary,
|
||||
(),
|
||||
()
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
calcType();
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
static autoPtr<calcType> New(const word& calcTypeName);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~calcType();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Calculation routines - wrapped by exception handling loop
|
||||
|
||||
//- Initialise - typically setting static variables,
|
||||
// e.g. command line arguments
|
||||
void tryInit();
|
||||
|
||||
//- Pre-time loop calculations
|
||||
void tryPreCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Time loop calculations
|
||||
void tryCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Post-time loop calculations
|
||||
void tryPostCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
55
src/postProcessing/foamCalcFunctions/calcType/newCalcType.C
Normal file
55
src/postProcessing/foamCalcFunctions/calcType/newCalcType.C
Normal file
@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "calcType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::calcType> Foam::calcType::New
|
||||
(
|
||||
const word& calcTypeName
|
||||
)
|
||||
{
|
||||
Info<< "Selecting calcType " << calcTypeName << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(calcTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn("calcType::New()")
|
||||
<< " unknown calcType type " << calcTypeName
|
||||
<< ", constructor not in hash table" << nl << nl
|
||||
<< " Valid calcType selections are: " << nl
|
||||
<< dictionaryConstructorTablePtr_->toc() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<calcType>(cstrIter()());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,132 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "components.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace calcTypes
|
||||
{
|
||||
defineTypeNameAndDebug(components, 0);
|
||||
addToRunTimeSelectionTable(calcType, components, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::components::components()
|
||||
:
|
||||
calcType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::components::~components()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::calcTypes::components::init()
|
||||
{
|
||||
Foam::argList::validArgs.append("components");
|
||||
argList::validArgs.append("fieldName1 .. fieldNameN");
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::components::preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
if (args.additionalArgs().size() < 2)
|
||||
{
|
||||
Info<< nl << "must specify one or more fields" << nl;
|
||||
args.printUsage();
|
||||
FatalError.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::components::calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
for (label fieldi=1; fieldi<params.size(); fieldi++)
|
||||
{
|
||||
const word fieldName(params[fieldi]);
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
// Check field exists
|
||||
if (fieldHeader.headerOk())
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
writeComponentFields<vector>(fieldHeader, mesh, processed);
|
||||
writeComponentFields<sphericalTensor>
|
||||
(
|
||||
fieldHeader,
|
||||
mesh,
|
||||
processed
|
||||
);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
FatalError
|
||||
<< "Unable to process " << fieldName << nl
|
||||
<< "No call to components for fields of type "
|
||||
<< fieldHeader.headerClassName() << nl << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No " << fieldName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::components
|
||||
|
||||
Description
|
||||
Writes scalar fields corresponding to each component of the supplied
|
||||
field (name) for each time.
|
||||
|
||||
SourceFiles
|
||||
components.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef components_H
|
||||
#define components_H
|
||||
|
||||
#include "calcType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace calcTypes
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class components Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class components
|
||||
:
|
||||
public calcType
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
components(const components&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const components&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Calculation routines
|
||||
|
||||
//- Initialise - typically setting static variables,
|
||||
// e.g. command line arguments
|
||||
virtual void init();
|
||||
|
||||
//- Pre-time loop calculations
|
||||
virtual void preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Time loop calculations
|
||||
virtual void calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write component fields
|
||||
template<class Type>
|
||||
void writeComponentFields
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("components");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
components();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~components();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace calcTypes
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writeComponentFields.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Type>
|
||||
void Foam::calcTypes::components::writeComponentFields
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (header.headerClassName() == fieldType::typeName)
|
||||
{
|
||||
Info<< " Reading " << header.name() << endl;
|
||||
fieldType field(header, mesh);
|
||||
|
||||
for (direction i=0; i<Type::nComponents; i++)
|
||||
{
|
||||
Info<< " Calculating " << header.name()
|
||||
<< Type::componentNames[i] << endl;
|
||||
|
||||
volScalarField componentField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
header.name() + word(Type::componentNames[i]),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
field.component(i)
|
||||
);
|
||||
componentField.write();
|
||||
}
|
||||
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
131
src/postProcessing/foamCalcFunctions/field/mag/mag.C
Normal file
131
src/postProcessing/foamCalcFunctions/field/mag/mag.C
Normal file
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "mag.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace calcTypes
|
||||
{
|
||||
defineTypeNameAndDebug(mag, 0);
|
||||
addToRunTimeSelectionTable(calcType, mag, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::mag::mag()
|
||||
:
|
||||
calcType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::mag::~mag()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::calcTypes::mag::init()
|
||||
{
|
||||
Foam::argList::validArgs.append("mag");
|
||||
argList::validArgs.append("fieldName1 .. fieldNameN");
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::mag::preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
if (args.additionalArgs().size() < 2)
|
||||
{
|
||||
Info<< nl << "must specify one or more fields" << nl;
|
||||
args.printUsage();
|
||||
FatalError.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::mag::calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
for (label fieldi=1; fieldi<params.size(); fieldi++)
|
||||
{
|
||||
const word fieldName(params[fieldi]);
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
// Check field exists
|
||||
if (fieldHeader.headerOk())
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
writeMagField<scalar>(fieldHeader, mesh, processed);
|
||||
writeMagField<vector>(fieldHeader, mesh, processed);
|
||||
writeMagField<sphericalTensor>(fieldHeader, mesh, processed);
|
||||
writeMagField<symmTensor>(fieldHeader, mesh, processed);
|
||||
writeMagField<tensor>(fieldHeader, mesh, processed);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
FatalError
|
||||
<< "Unable to process " << fieldName << nl
|
||||
<< "No call to mag for fields of type "
|
||||
<< fieldHeader.headerClassName() << nl << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No " << fieldName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
138
src/postProcessing/foamCalcFunctions/field/mag/mag.H
Normal file
138
src/postProcessing/foamCalcFunctions/field/mag/mag.H
Normal file
@ -0,0 +1,138 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::mag
|
||||
|
||||
Description
|
||||
Calculates and writes the magnitude of a field for each time
|
||||
|
||||
SourceFiles
|
||||
mag.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef mag_H
|
||||
#define mag_H
|
||||
|
||||
#include "calcType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace calcTypes
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class mag Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class mag
|
||||
:
|
||||
public calcType
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
mag(const mag&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const mag&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Calculation routines
|
||||
|
||||
//- Initialise - typically setting static variables,
|
||||
// e.g. command line arguments
|
||||
virtual void init();
|
||||
|
||||
//- Pre-time loop calculations
|
||||
virtual void preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Time loop calculations
|
||||
virtual void calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write component fields
|
||||
template<class Type>
|
||||
void writeMagField
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("mag");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
mag();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~mag();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace calcTypes
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writeMagField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
void Foam::calcTypes::mag::writeMagField
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (header.headerClassName() == fieldType::typeName)
|
||||
{
|
||||
Info<< " Reading " << header.name() << endl;
|
||||
fieldType field(header, mesh);
|
||||
|
||||
Info<< " Calculating mag" << header.name() << endl;
|
||||
volScalarField magField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"mag" + header.name(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
Foam::mag(field)
|
||||
);
|
||||
magField.write();
|
||||
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
128
src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.C
Normal file
128
src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.C
Normal file
@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "magGrad.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace calcTypes
|
||||
{
|
||||
defineTypeNameAndDebug(magGrad, 0);
|
||||
addToRunTimeSelectionTable(calcType, magGrad, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::magGrad::magGrad()
|
||||
:
|
||||
calcType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::magGrad::~magGrad()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::calcTypes::magGrad::init()
|
||||
{
|
||||
Foam::argList::validArgs.append("magGrad");
|
||||
argList::validArgs.append("fieldName1 .. fieldNameN");
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::magGrad::preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
if (args.additionalArgs().size() < 2)
|
||||
{
|
||||
Info<< nl << "must specify one or more fields" << nl;
|
||||
args.printUsage();
|
||||
FatalError.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::magGrad::calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
for (label fieldi=1; fieldi<params.size(); fieldi++)
|
||||
{
|
||||
const word fieldName(params[fieldi]);
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
// Check field exists
|
||||
if (fieldHeader.headerOk())
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
writeMagGradField<scalar>(fieldHeader, mesh, processed);
|
||||
writeMagGradField<vector>(fieldHeader, mesh, processed);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
FatalError
|
||||
<< "Unable to process " << fieldName << nl
|
||||
<< "No call to magGrad for fields of type "
|
||||
<< fieldHeader.headerClassName() << nl << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No " << fieldName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
139
src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.H
Normal file
139
src/postProcessing/foamCalcFunctions/field/magGrad/magGrad.H
Normal file
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::magGrad
|
||||
|
||||
Description
|
||||
Writes scalar fields corresponding to the magnitude ot the gradient
|
||||
of the supplied field (name) for each time.
|
||||
|
||||
SourceFiles
|
||||
magGrad.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef magGrad_H
|
||||
#define magGrad_H
|
||||
|
||||
#include "calcType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace calcTypes
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class magGrad Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class magGrad
|
||||
:
|
||||
public calcType
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
magGrad(const magGrad&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const magGrad&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Calculation routines
|
||||
|
||||
//- Initialise - typically setting static variables,
|
||||
// e.g. command line arguments
|
||||
virtual void init();
|
||||
|
||||
//- Pre-time loop calculations
|
||||
virtual void preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Time loop calculations
|
||||
virtual void calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write magGrad fields
|
||||
template<class Type>
|
||||
void writeMagGradField
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("magGrad");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
magGrad();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~magGrad();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace calcTypes
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writeMagGradField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
void Foam::calcTypes::magGrad::writeMagGradField
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (header.headerClassName() == fieldType::typeName)
|
||||
{
|
||||
Info<< " Reading " << header.name() << endl;
|
||||
fieldType field(header, mesh);
|
||||
|
||||
Info<< " Calculating magGrad" << header.name() << endl;
|
||||
volScalarField magGradField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"magGrad" + header.name(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
Foam::mag(fvc::grad(field))
|
||||
);
|
||||
magGradField.write();
|
||||
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
131
src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.C
Normal file
131
src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.C
Normal file
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "magSqr.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace calcTypes
|
||||
{
|
||||
defineTypeNameAndDebug(magSqr, 0);
|
||||
addToRunTimeSelectionTable(calcType, magSqr, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::magSqr::magSqr()
|
||||
:
|
||||
calcType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::calcTypes::magSqr::~magSqr()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::calcTypes::magSqr::init()
|
||||
{
|
||||
Foam::argList::validArgs.append("magSqr");
|
||||
argList::validArgs.append("fieldName1 .. fieldNameN");
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::magSqr::preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
if (args.additionalArgs().size() < 2)
|
||||
{
|
||||
Info<< nl << "must specify one or more fields" << nl;
|
||||
args.printUsage();
|
||||
FatalError.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::calcTypes::magSqr::calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
{
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
for (label fieldi=1; fieldi<params.size(); fieldi++)
|
||||
{
|
||||
const word fieldName(params[fieldi]);
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
// Check field exists
|
||||
if (fieldHeader.headerOk())
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
writeMagSqrField<scalar>(fieldHeader, mesh, processed);
|
||||
writeMagSqrField<vector>(fieldHeader, mesh, processed);
|
||||
writeMagSqrField<sphericalTensor>(fieldHeader, mesh, processed);
|
||||
writeMagSqrField<symmTensor>(fieldHeader, mesh, processed);
|
||||
writeMagSqrField<tensor>(fieldHeader, mesh, processed);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
FatalError
|
||||
<< "Unable to process " << fieldName << nl
|
||||
<< "No call to magSqr for fields of type "
|
||||
<< fieldHeader.headerClassName() << nl << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No " << fieldName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
138
src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.H
Normal file
138
src/postProcessing/foamCalcFunctions/field/magSqr/magSqr.H
Normal file
@ -0,0 +1,138 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::magSqr
|
||||
|
||||
Description
|
||||
Calculates and writes the magnitude-sqaured of a field for each time
|
||||
|
||||
SourceFiles
|
||||
magSqr.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef magSqr_H
|
||||
#define magSqr_H
|
||||
|
||||
#include "calcType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace calcTypes
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class magSqr Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class magSqr
|
||||
:
|
||||
public calcType
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
magSqr(const magSqr&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const magSqr&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Calculation routines
|
||||
|
||||
//- Initialise - typically setting static variables,
|
||||
// e.g. command line arguments
|
||||
virtual void init();
|
||||
|
||||
//- Pre-time loop calculations
|
||||
virtual void preCalc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Time loop calculations
|
||||
virtual void calc
|
||||
(
|
||||
const argList& args,
|
||||
const Time& runTime,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write component fields
|
||||
template<class Type>
|
||||
void writeMagSqrField
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("magSqr");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
magSqr();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~magSqr();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace calcTypes
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writeMagSqrField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
void Foam::calcTypes::magSqr::writeMagSqrField
|
||||
(
|
||||
const IOobject& header,
|
||||
const fvMesh& mesh,
|
||||
bool& processed
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (header.headerClassName() == fieldType::typeName)
|
||||
{
|
||||
Info<< " Reading " << header.name() << endl;
|
||||
fieldType field(header, mesh);
|
||||
|
||||
Info<< " Calculating magSqr" << header.name() << endl;
|
||||
volScalarField magSqrField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"magSqr" + header.name(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
Foam::magSqr(field)
|
||||
);
|
||||
magSqrField.write();
|
||||
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
Reference in New Issue
Block a user