mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
adding basic add functionality
This commit is contained in:
@ -8,4 +8,6 @@ field/magGrad/magGrad.C
|
|||||||
field/div/div.C
|
field/div/div.C
|
||||||
field/randomise/randomise.C
|
field/randomise/randomise.C
|
||||||
|
|
||||||
|
basic/add/add.C
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libfoamCalcFunctions
|
LIB = $(FOAM_LIBBIN)/libfoamCalcFunctions
|
||||||
|
|||||||
287
src/postProcessing/foamCalcFunctions/basic/add/add.C
Normal file
287
src/postProcessing/foamCalcFunctions/basic/add/add.C
Normal file
@ -0,0 +1,287 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 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 "add.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace calcTypes
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(add, 0);
|
||||||
|
addToRunTimeSelectionTable(calcType, add, dictionary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::calcTypes::add::writeAddFields
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const IOobject& baseFieldHeader
|
||||||
|
)
|
||||||
|
{
|
||||||
|
bool processed = false;
|
||||||
|
|
||||||
|
IOobject addFieldHeader
|
||||||
|
(
|
||||||
|
addFieldName_,
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ
|
||||||
|
);
|
||||||
|
|
||||||
|
if (addFieldHeader.headerOk())
|
||||||
|
{
|
||||||
|
writeAddField<scalar>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addFieldHeader,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddField<vector>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addFieldHeader,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddField<sphericalTensor>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addFieldHeader,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddField<symmTensor>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addFieldHeader,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddField<tensor>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addFieldHeader,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!processed)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< "Unable to process " << baseFieldName_
|
||||||
|
<< " + " << addFieldName_ << nl
|
||||||
|
<< "No call to add for fields of type "
|
||||||
|
<< baseFieldHeader.headerClassName() << " + "
|
||||||
|
<< addFieldHeader.headerClassName() << nl << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn("calcTypes::add::writeAddFields()")
|
||||||
|
<< "Unable to read add field: " << addFieldName_
|
||||||
|
<< nl << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::calcTypes::add::writeAddValues
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const IOobject& baseFieldHeader
|
||||||
|
)
|
||||||
|
{
|
||||||
|
bool processed = false;
|
||||||
|
|
||||||
|
writeAddValue<scalar>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addValueStr_,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddValue<vector>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addValueStr_,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddValue<sphericalTensor>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addValueStr_,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddValue<symmTensor>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addValueStr_,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
writeAddValue<tensor>
|
||||||
|
(
|
||||||
|
baseFieldHeader,
|
||||||
|
addValueStr_,
|
||||||
|
mesh,
|
||||||
|
processed
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!processed)
|
||||||
|
{
|
||||||
|
FatalErrorIn("calcTypes::add::writeAddValues()")
|
||||||
|
<< "Unable to process " << baseFieldName_
|
||||||
|
<< " + " << addValueStr_ << nl
|
||||||
|
<< "No call to add for fields of type "
|
||||||
|
<< baseFieldHeader.headerClassName() << nl << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::calcTypes::add::add()
|
||||||
|
:
|
||||||
|
calcType(),
|
||||||
|
baseFieldName_(""),
|
||||||
|
calcType_(FIELD),
|
||||||
|
addFieldName_(""),
|
||||||
|
addValueStr_(""),
|
||||||
|
resultName_("")
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::calcTypes::add::~add()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::calcTypes::add::init()
|
||||||
|
{
|
||||||
|
argList::validArgs.append("add");
|
||||||
|
argList::validArgs.append("baseField");
|
||||||
|
argList::validOptions.insert("field", "fieldName");
|
||||||
|
argList::validOptions.insert("value", "valueString");
|
||||||
|
argList::validOptions.insert("resultName", "fieldName");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::calcTypes::add::preCalc
|
||||||
|
(
|
||||||
|
const argList& args,
|
||||||
|
const Time& runTime,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
baseFieldName_ = args.additionalArgs()[1];
|
||||||
|
|
||||||
|
if (args.options().found("field"))
|
||||||
|
{
|
||||||
|
addFieldName_ = args.options()["field"];
|
||||||
|
calcType_ = FIELD;
|
||||||
|
}
|
||||||
|
else if (args.options().found("value"))
|
||||||
|
{
|
||||||
|
addValueStr_ = args.options()["value"];
|
||||||
|
calcType_ = VALUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn("calcTypes::add::preCalc")
|
||||||
|
<< "add requires either -field or -value option"
|
||||||
|
<< nl << exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.options().found("resultName"))
|
||||||
|
{
|
||||||
|
resultName_ = args.options()["resultName"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::calcTypes::add::calc
|
||||||
|
(
|
||||||
|
const argList& args,
|
||||||
|
const Time& runTime,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IOobject baseFieldHeader
|
||||||
|
(
|
||||||
|
baseFieldName_,
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ
|
||||||
|
);
|
||||||
|
|
||||||
|
if (baseFieldHeader.headerOk())
|
||||||
|
{
|
||||||
|
switch (calcType_)
|
||||||
|
{
|
||||||
|
case FIELD:
|
||||||
|
{
|
||||||
|
writeAddFields(runTime, mesh, baseFieldHeader);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VALUE:
|
||||||
|
{
|
||||||
|
writeAddValues(runTime, mesh, baseFieldHeader);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
FatalErrorIn("calcTypes::add::calc")
|
||||||
|
<< "unknown calcType " << calcType_ << nl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn("calcTypes::add::calc")
|
||||||
|
<< "Unable to read base field: " << baseFieldName_
|
||||||
|
<< nl << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
|
|
||||||
208
src/postProcessing/foamCalcFunctions/basic/add/add.H
Normal file
208
src/postProcessing/foamCalcFunctions/basic/add/add.H
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 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::calcTypes::add
|
||||||
|
|
||||||
|
Description
|
||||||
|
Adds and field or value to base field.
|
||||||
|
|
||||||
|
New field name specified by -resultName option, or automatically as:
|
||||||
|
<baseFieldName>_plus_<addFieldName>
|
||||||
|
<baseFieldName>_plus_value
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
add p -value 100000 -resultName pAbs
|
||||||
|
add U -field U0
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
add.C
|
||||||
|
writeAddField.C
|
||||||
|
writeAddValue.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef add_H
|
||||||
|
#define add_H
|
||||||
|
|
||||||
|
#include "calcType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace calcTypes
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class add Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class add
|
||||||
|
:
|
||||||
|
public calcType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum calcTypes
|
||||||
|
{
|
||||||
|
FIELD,
|
||||||
|
VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Name of base field (to add to)
|
||||||
|
word baseFieldName_;
|
||||||
|
|
||||||
|
//- Calc type as given by enumerations above
|
||||||
|
calcTypes calcType_;
|
||||||
|
|
||||||
|
//- Name of field to add
|
||||||
|
word addFieldName_;
|
||||||
|
|
||||||
|
//- String representation of value to add
|
||||||
|
string addValueStr_;
|
||||||
|
|
||||||
|
//- Name of result field
|
||||||
|
word resultName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
// Output
|
||||||
|
|
||||||
|
//- Calc and output field additions
|
||||||
|
void writeAddFields
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const IOobject& baseFieldHeader
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Calc and output field and value additions
|
||||||
|
void writeAddValues
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const IOobject& baseFieldHeader
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
add(const add&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const add&);
|
||||||
|
|
||||||
|
|
||||||
|
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 add field
|
||||||
|
template<class Type>
|
||||||
|
void writeAddField
|
||||||
|
(
|
||||||
|
const IOobject& baseHeader,
|
||||||
|
const IOobject& addHeader,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
bool& processed
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write add value
|
||||||
|
template<class Type>
|
||||||
|
void writeAddValue
|
||||||
|
(
|
||||||
|
const IOobject& baseHeader,
|
||||||
|
const string& valueStr,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
bool& processed
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("add");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
add();
|
||||||
|
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~add();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace calcTypes
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "writeAddField.C"
|
||||||
|
# include "writeAddValue.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 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::add::writeAddField
|
||||||
|
(
|
||||||
|
const IOobject& baseHeader,
|
||||||
|
const IOobject& addHeader,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
bool& processed
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (resultName_ == "")
|
||||||
|
{
|
||||||
|
resultName_ = baseHeader.name() + "_plus_" + addHeader.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
baseHeader.headerClassName() == fieldType::typeName
|
||||||
|
&& baseHeader.headerClassName() == addHeader.headerClassName()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< " Reading " << baseHeader.name() << endl;
|
||||||
|
fieldType baseField(baseHeader, mesh);
|
||||||
|
|
||||||
|
Info<< " Reading " << addHeader.name() << endl;
|
||||||
|
fieldType addField(addHeader, mesh);
|
||||||
|
|
||||||
|
if (baseField.dimensions() == addField.dimensions())
|
||||||
|
{
|
||||||
|
Info<< " Calculating " << resultName_ << endl;
|
||||||
|
|
||||||
|
fieldType newField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
resultName_,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ
|
||||||
|
),
|
||||||
|
baseField + addField
|
||||||
|
);
|
||||||
|
newField.write();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " Cannot calculate " << resultName_ << nl
|
||||||
|
<< " - inconsistent dimensions: "
|
||||||
|
<< baseField.dimensions() << " - " << addField.dimensions()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 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::add::writeAddValue
|
||||||
|
(
|
||||||
|
const IOobject& baseHeader,
|
||||||
|
const string& valueStr,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
bool& processed
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||||
|
|
||||||
|
if (baseHeader.headerClassName() == fieldType::typeName)
|
||||||
|
{
|
||||||
|
if (resultName_ == "")
|
||||||
|
{
|
||||||
|
resultName_ = baseHeader.name() + "_plus_value";
|
||||||
|
}
|
||||||
|
|
||||||
|
Type value;
|
||||||
|
IStringStream(valueStr)() >> value;
|
||||||
|
|
||||||
|
Info<< " Reading " << baseHeader.name() << endl;
|
||||||
|
fieldType baseField(baseHeader, mesh);
|
||||||
|
|
||||||
|
fieldType newField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
resultName_,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ
|
||||||
|
),
|
||||||
|
baseField
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< " Calculating " << resultName_ << endl;
|
||||||
|
newField == baseField
|
||||||
|
+ dimensioned<Type>("value", baseField.dimensions(), value);
|
||||||
|
newField.write();
|
||||||
|
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
Reference in New Issue
Block a user