Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 134 additions and 115 deletions
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -90,16 +90,6 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::value
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::integrate
(
const scalarField& x1,
const scalarField& x2
) const
{
return (x2 - x1)*value_;
}
template<class Type>
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
{
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -73,7 +73,6 @@ public:
TypeName("constant");
// Generated Methods
//- No copy assignment
......@@ -118,26 +117,11 @@ public:
//- Return value as a function of (scalar) independent variable
virtual tmp<Field<Type>> value(const scalarField& x) const;
//- Integrate between two (scalar) values
virtual tmp<Field<Type>> integrate
(
const scalarField& x1,
const scalarField& x2
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
template<>
tmp<Field<label>> Function1Types::Constant<label>::integrate
(
const scalarField& x1,
const scalarField& x2
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -43,7 +44,7 @@ inline Type Foam::Function1Types::Constant<Type>::integrate
const scalar x2
) const
{
return (x2 - x1)*value_;
return Type((x2 - x1)*value_);
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -60,7 +60,7 @@ template<class Type>
Type Foam::Function1<Type>::value(const scalar x) const
{
NotImplemented;
return Zero;
return Type();
}
......@@ -80,7 +80,7 @@ template<class Type>
Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
{
NotImplemented;
return Zero;
return Type();
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -285,7 +285,7 @@ Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
// Use interpolator
interpolator().valueWeights(xDash, currentIndices_, currentWeights_);
Type t = currentWeights_[0]*table_[currentIndices_[0]].second();
Type t(currentWeights_[0]*table_[currentIndices_[0]].second());
for (label i = 1; i < currentIndices_.size(); i++)
{
t += currentWeights_[i]*table_[currentIndices_[i]].second();
......@@ -305,7 +305,7 @@ Type Foam::Function1Types::TableBase<Type>::integrate
// Use interpolator
interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
Type sum = currentWeights_[0]*table_[currentIndices_[0]].second();
Type sum(currentWeights_[0]*table_[currentIndices_[0]].second());
for (label i = 1; i < currentIndices_.size(); i++)
{
sum += currentWeights_[i]*table_[currentIndices_[i]].second();
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -59,6 +59,13 @@ License
makeFunction1Type(Scale, Type); \
makeFunction1Type(LimitRange, Type);
#define makeFieldFunction1s(Type) \
makeFunction1(Type); \
makeFunction1Type(Constant, Type); \
makeFunction1Type(Uniform, Type); \
makeFunction1Type(Table, Type); \
makeFunction1Type(TableFile, Type); \
namespace Foam
{
makeFunction1(label);
......@@ -69,19 +76,8 @@ namespace Foam
makeFunction1s(sphericalTensor);
makeFunction1s(symmTensor);
makeFunction1s(tensor);
}
template<>
Foam::tmp<Foam::Field<Foam::label>>
Foam::Function1Types::Constant<Foam::label>::integrate
(
const scalarField& x1,
const scalarField& x2
) const
{
NotImplemented;
return tmp<Field<label>>::New(x1.size());
makeFieldFunction1s(scalarField);
}
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -35,11 +35,17 @@ License
Foam::string Foam::stringOps::evaluate
(
label fieldWidth,
const std::string& str,
size_t pos,
size_t len
)
{
if (fieldWidth < 1)
{
fieldWidth = 1;
}
/// InfoErr<< "Evaluate " << str.substr(pos, len) << nl;
const auto trimPoints = stringOps::findTrim(str, pos, len);
......@@ -49,14 +55,14 @@ Foam::string Foam::stringOps::evaluate
if (!len)
{
return "";
return string();
}
/// InfoErr<< "Evaluate " << str.substr(pos, len) << nl;
expressions::exprResult result;
{
expressions::fieldExprDriver driver(1);
expressions::fieldExprDriver driver(fieldWidth);
driver.parse(str, pos, len);
result = std::move(driver.result());
}
......@@ -67,14 +73,32 @@ Foam::string Foam::stringOps::evaluate
<< "Failed evaluation: "
<< str.substr(pos, len) << nl;
return "";
return string();
}
OStringStream os;
result.writeValue(os);
if (result.size() <= 1)
{
result.writeValue(os);
}
else
{
result.writeField(os);
}
return os.str();
}
Foam::string Foam::stringOps::evaluate
(
const std::string& str,
size_t pos,
size_t len
)
{
return stringOps::evaluate(1, str, pos, len);
}
// ************************************************************************* //
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -34,6 +34,7 @@ Description
#ifndef stringOpsEvaluate_H
#define stringOpsEvaluate_H
#include "labelFwd.H"
#include "string.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -42,6 +43,15 @@ namespace Foam
{
namespace stringOps
{
//- String evaluation with specified (positive, non-zero) field width
string evaluate
(
label fieldWidth,
const std::string& s,
size_t pos = 0,
size_t len = std::string::npos
);
//- A simple string evaluation that handles various basic
//- expressions. For trivial input, use readScalar instead (faster).
//
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -497,7 +497,7 @@ void Foam::vtk::vtuSizing::populateArrays
addPointsIds[nPointDecomp++] = celli;
// Whether to insert cell in place of original or not.
bool first = true;
bool firstCell = true;
const labelList& cFaces = mesh.cells()[celli];
......@@ -523,9 +523,9 @@ void Foam::vtk::vtuSizing::populateArrays
constexpr label nShapePoints = 5; // pyr (5 vertices)
label celLoc, vrtLoc;
if (first)
if (firstCell)
{
first = false;
firstCell = false;
celLoc = celli;
vrtLoc = nVertLabels;
nVertLabels += prefix + nShapePoints;
......@@ -551,10 +551,10 @@ void Foam::vtk::vtuSizing::populateArrays
// See note above about the orientation.
if (isOwner)
{
vertLabels[vrtLoc++] = quad[0];
vertLabels[vrtLoc++] = quad[3];
vertLabels[vrtLoc++] = quad[2];
vertLabels[vrtLoc++] = quad[1];
vertLabels[vrtLoc++] = quad[0];
}
else
{
......@@ -575,9 +575,9 @@ void Foam::vtk::vtuSizing::populateArrays
constexpr label nShapePoints = 4; // tet (4 vertices)
label celLoc, vrtLoc;
if (first)
if (firstCell)
{
first = false;
firstCell = false;
celLoc = celli;
vrtLoc = nVertLabels;
nVertLabels += prefix + nShapePoints;
......@@ -603,9 +603,9 @@ void Foam::vtk::vtuSizing::populateArrays
// See note above about the orientation.
if (isOwner)
{
vertLabels[vrtLoc++] = tria[0];
vertLabels[vrtLoc++] = tria[2];
vertLabels[vrtLoc++] = tria[1];
vertLabels[vrtLoc++] = tria[0];
}
else
{
......@@ -633,7 +633,7 @@ void Foam::vtk::vtuSizing::populateArrays
if (output == contentType::LEGACY)
{
faceOutput[startLabel] = 0; // placeholder for size
faceOutput[startLabel] = 0; // placeholder for total size
++faceIndexer;
}
......@@ -643,24 +643,24 @@ void Foam::vtk::vtuSizing::populateArrays
{
const face& f = mesh.faces()[facei];
const bool isOwner = (owner[facei] == celli);
const label nFacePoints = f.size();
hashUniqId.insert(f);
// The number of labels for this face
faceOutput[faceIndexer++] = f.size();
faceOutput[faceIndexer++] = nFacePoints;
faceOutput[faceIndexer++] = f[0];
if (isOwner)
{
forAll(f, fp)
for (label fp = 1; fp < nFacePoints; ++fp)
{
faceOutput[faceIndexer++] = f[fp];
}
}
else
{
// fairly immaterial if we reverse the list
// or use face::reverseFace()
forAllReverse(f, fp)
for (label fp = nFacePoints - 1; fp > 0; --fp)
{
faceOutput[faceIndexer++] = f[fp];
}
......@@ -684,10 +684,9 @@ void Foam::vtk::vtuSizing::populateArrays
vertLabels[nVertLabels++] = hashUniqId.size();
}
const labelList uniq = hashUniqId.sortedToc();
for (const label fpi : uniq)
for (const label pointi : hashUniqId.sortedToc())
{
vertLabels[nVertLabels++] = fpi;
vertLabels[nVertLabels++] = pointi;
}
}
}
......@@ -726,7 +725,7 @@ void Foam::vtk::vtuSizing::populateArrays
for (LabelType& off : faceOffset)
{
const auto sz = off;
const LabelType sz(off);
if (sz > 0)
{
prev += sz;
......@@ -745,7 +744,7 @@ void Foam::vtk::vtuSizing::populateArrays
for (LabelType& off : vertOffset)
{
const auto sz = off;
const LabelType sz(off);
off = beg;
beg += 1 + sz; // Additional 1 to skip embedded prefix
}
......@@ -758,7 +757,7 @@ void Foam::vtk::vtuSizing::populateArrays
for (LabelType& off : faceOffset)
{
const auto sz = off;
const LabelType sz(off);
if (sz > 0)
{
off = beg;
......@@ -782,7 +781,7 @@ void Foam::vtk::vtuSizing::populateArrays
for (LabelType& off : vertOffset)
{
const auto sz = off;
const LabelType sz(off);
off = total;
total += sz;
}
......@@ -795,7 +794,7 @@ void Foam::vtk::vtuSizing::populateArrays
for (LabelType& off : faceOffset)
{
const auto sz = off;
const LabelType sz(off);
if (sz > 0)
{
off = beg;
......
......@@ -67,7 +67,7 @@
#define TOK_SSPH_TENSOR_ID 67
#define TOK_SYM_TENSOR_ID 68
#define TOK_SSYM_TENSOR_ID 69
#define TOK_UNIT_TENSOR 70
#define TOK_IDENTITY_TENSOR 70
#define TOK_TENSOR_ID 71
#define TOK_STENSOR_ID 72
#define TOK_LTRUE 73
......
......@@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -242,7 +242,7 @@ dnl
\*---------------------------------------------------------------------------*/
evaluate ::= _target_ (a) . { driver->setResult(a); }
tfield (lhs) ::= UNIT_TENSOR . { lhs = _new_tfield(Foam::tensor::I); }
tfield (lhs) ::= IDENTITY_TENSOR . { lhs = _new_tfield(Foam::tensor::I); }
rule_get_field(_target_, TENSOR_ID)
rule_get_field(_target_, STENSOR_ID)
......
......@@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -595,7 +595,7 @@ tr9:
goto st11;
tr11:
#line 418 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(UNIT_TENSOR); }}
{te = p+1;{ EMIT_TOKEN(IDENTITY_TENSOR); }}
goto st11;
tr12:
#line 359 "patchExprScanner.rl"
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -415,7 +415,7 @@ static int driverTokenType
"Zero" =>{ EMIT_TOKEN(ZERO); };
"true" =>{ EMIT_TOKEN(LTRUE); };
"false" =>{ EMIT_TOKEN(LFALSE); };
"tensor::I" =>{ EMIT_TOKEN(UNIT_TENSOR); };
"tensor::I" =>{ EMIT_TOKEN(IDENTITY_TENSOR); };
"arg" =>{ EMIT_TOKEN(ARG); };
"time" =>{ EMIT_TOKEN(TIME); };
......
......@@ -63,7 +63,7 @@
#define TOK_VECTOR_ID 63
#define TOK_SPH_TENSOR_ID 64
#define TOK_SYM_TENSOR_ID 65
#define TOK_UNIT_TENSOR 66
#define TOK_IDENTITY_TENSOR 66
#define TOK_TENSOR_ID 67
#define TOK_LTRUE 68
#define TOK_LFALSE 69
......
......@@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -274,7 +274,7 @@ dnl
\*---------------------------------------------------------------------------*/
evaluate ::= _target_ (a) . { driver->setResult(a); }
tfield (lhs) ::= UNIT_TENSOR . { lhs = _new_tfield(Foam::tensor::I); }
tfield (lhs) ::= IDENTITY_TENSOR . { lhs = _new_tfield(Foam::tensor::I); }
rule_get_field(_target_, TENSOR_ID)
......
......@@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -624,7 +624,7 @@ tr9:
goto st11;
tr11:
#line 447 "volumeExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(UNIT_TENSOR); }}
{te = p+1;{ EMIT_TOKEN(IDENTITY_TENSOR); }}
goto st11;
tr12:
#line 388 "volumeExprScanner.rl"
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -444,7 +444,7 @@ static int driverTokenType
"Zero" =>{ EMIT_TOKEN(ZERO); };
"true" =>{ EMIT_TOKEN(LTRUE); };
"false" =>{ EMIT_TOKEN(LFALSE); };
"tensor::I" =>{ EMIT_TOKEN(UNIT_TENSOR); };
"tensor::I" =>{ EMIT_TOKEN(IDENTITY_TENSOR); };
"arg" =>{ EMIT_TOKEN(ARG); };
"time" =>{ EMIT_TOKEN(TIME); };
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -37,13 +38,7 @@ namespace Foam
namespace fv
{
defineTypeNameAndDebug(radiation, 0);
addToRunTimeSelectionTable
(
option,
radiation,
dictionary
);
addToRunTimeSelectionTable(option, radiation, dictionary);
}
}
......@@ -60,8 +55,7 @@ Foam::fv::radiation::radiation
:
option(sourceName, modelType, dict, mesh)
{
const basicThermo& thermo =
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
fieldNames_.setSize(1);
fieldNames_[0] = thermo.he().name();
......@@ -86,8 +80,7 @@ void Foam::fv::radiation::addSup
const label fieldi
)
{
const basicThermo& thermo =
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
radiation_->correct();
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -27,17 +28,33 @@ Class
Foam::fv::radiation
Description
Calculates and applies the radiation source to the energy equation.
Applies radiation sources (i.e. \c Sh)
to the energy equation for compressible flows.
Usage
Example usage:
Minimal example by using \c constant/fvOptions:
\verbatim
radiationCoeffs
radiation1
{
fields (h); // Name of energy field
// Mandatory entries (unmodifiable)
type radiation;
fields (h);
// Mandatory/Optional (inherited) entries
...
}
\endverbatim
where the entries mean:
\table
Property | Description | Type | Reqd | Dflt
type | Type name: radiation | word | yes | -
fields | Name of operand energy field | word | yes | -
\endtable
The inherited entries are elaborated in:
- \link fvOption.H \endlink
SourceFiles
radiation.C
......@@ -58,14 +75,14 @@ namespace fv
{
/*---------------------------------------------------------------------------*\
Class radiation Declaration
Class radiation Declaration
\*---------------------------------------------------------------------------*/
class radiation
:
public option
{
// Private data
// Private Data
//- The radiation model pointer
autoPtr<Foam::radiation::radiationModel> radiation_;
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -120,7 +120,16 @@ void Foam::radiation::fvDOM::initialise()
if (useExternalBeam_)
{
coeffs_.readEntry("spectralDistribution", spectralDistribution_);
spectralDistributions_.reset
(
new TimeFunction1<scalarField>
(
mesh_.time(), "spectralDistribution", coeffs_
)
);
spectralDistribution_ =
spectralDistributions_->value(mesh_.time().value());
spectralDistribution_ =
spectralDistribution_/sum(spectralDistribution_);
......@@ -428,6 +437,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
),
useExternalBeam_(false),
spectralDistribution_(),
spectralDistributions_(),
solarCalculator_(),
updateTimeIndex_(0)
{
......@@ -533,6 +543,7 @@ Foam::radiation::fvDOM::fvDOM
),
useExternalBeam_(false),
spectralDistribution_(),
spectralDistributions_(),
solarCalculator_(),
updateTimeIndex_(0)
{
......@@ -540,12 +551,6 @@ Foam::radiation::fvDOM::fvDOM
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::fvDOM::~fvDOM()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::radiation::fvDOM::read()
......