mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added sumDirection operation into faceSource function object
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -48,10 +48,11 @@ namespace Foam
|
|||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* NamedEnum<fieldValues::faceSource::operationType, 11>::names[] =
|
const char* NamedEnum<fieldValues::faceSource::operationType, 12>::names[] =
|
||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
"sum",
|
"sum",
|
||||||
|
"sumDirection",
|
||||||
"average",
|
"average",
|
||||||
"weightedAverage",
|
"weightedAverage",
|
||||||
"areaAverage",
|
"areaAverage",
|
||||||
@ -74,7 +75,7 @@ namespace Foam
|
|||||||
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
|
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
|
||||||
Foam::fieldValues::faceSource::sourceTypeNames_;
|
Foam::fieldValues::faceSource::sourceTypeNames_;
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 11>
|
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 12>
|
||||||
Foam::fieldValues::faceSource::operationTypeNames_;
|
Foam::fieldValues::faceSource::operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
@ -486,6 +487,46 @@ void Foam::fieldValues::faceSource::writeFileHeader(const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
Foam::scalar Foam::fieldValues::faceSource::processValues
|
||||||
|
(
|
||||||
|
const Field<scalar>& values,
|
||||||
|
const vectorField& Sf,
|
||||||
|
const scalarField& weightField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
switch (operation_)
|
||||||
|
{
|
||||||
|
case opSumDirection:
|
||||||
|
{
|
||||||
|
const vector direction(dict_.lookup("direction"));
|
||||||
|
|
||||||
|
scalar v = 0.0;
|
||||||
|
|
||||||
|
forAll(Sf, i)
|
||||||
|
{
|
||||||
|
scalar d = Sf[i] & direction;
|
||||||
|
if (d > 0)
|
||||||
|
{
|
||||||
|
v += pos(values[i])*values[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v += neg(values[i])*values[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// Fall through to other operations
|
||||||
|
return processSameTypeValues(values, Sf, weightField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
Foam::vector Foam::fieldValues::faceSource::processValues
|
Foam::vector Foam::fieldValues::faceSource::processValues
|
||||||
(
|
(
|
||||||
@ -496,14 +537,35 @@ Foam::vector Foam::fieldValues::faceSource::processValues
|
|||||||
{
|
{
|
||||||
switch (operation_)
|
switch (operation_)
|
||||||
{
|
{
|
||||||
|
case opSumDirection:
|
||||||
|
{
|
||||||
|
const vector direction(dict_.lookup("direction"));
|
||||||
|
|
||||||
|
vector v(vector::zero);
|
||||||
|
|
||||||
|
forAll(Sf, i)
|
||||||
|
{
|
||||||
|
scalar d = Sf[i] & direction;
|
||||||
|
if (d > 0)
|
||||||
|
{
|
||||||
|
v += pos(values[i] & direction)*values[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v += neg(values[i] & direction)*values[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
case opAreaNormalAverage:
|
case opAreaNormalAverage:
|
||||||
{
|
{
|
||||||
scalar result = sum(values&Sf)/sum(mag(Sf));
|
scalar result = sum(values & Sf)/sum(mag(Sf));
|
||||||
return vector(result, 0.0, 0.0);
|
return vector(result, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
case opAreaNormalIntegrate:
|
case opAreaNormalIntegrate:
|
||||||
{
|
{
|
||||||
scalar result = sum(values&Sf);
|
scalar result = sum(values & Sf);
|
||||||
return vector(result, 0.0, 0.0);
|
return vector(result, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -87,6 +87,7 @@ Description
|
|||||||
\plaintable
|
\plaintable
|
||||||
none | no operation
|
none | no operation
|
||||||
sum | sum
|
sum | sum
|
||||||
|
sumDirection | sum values which are positive in given direction
|
||||||
average | ensemble average
|
average | ensemble average
|
||||||
weightedAverage | weighted average
|
weightedAverage | weighted average
|
||||||
areaAverage | area weighted average
|
areaAverage | area weighted average
|
||||||
@ -176,6 +177,7 @@ public:
|
|||||||
{
|
{
|
||||||
opNone,
|
opNone,
|
||||||
opSum,
|
opSum,
|
||||||
|
opSumDirection,
|
||||||
opAverage,
|
opAverage,
|
||||||
opWeightedAverage,
|
opWeightedAverage,
|
||||||
opAreaAverage,
|
opAreaAverage,
|
||||||
@ -188,7 +190,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//- Operation type names
|
//- Operation type names
|
||||||
static const NamedEnum<operationType, 11> operationTypeNames_;
|
static const NamedEnum<operationType, 12> operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -366,8 +368,17 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//- Specialisation of processing vectors for opAreaNormalAverage,
|
//- Specialisation of processing scalars
|
||||||
// opAreaNormalIntegrate (use inproduct - dimension reducing operation)
|
template<>
|
||||||
|
scalar faceSource::processValues
|
||||||
|
(
|
||||||
|
const Field<scalar>& values,
|
||||||
|
const vectorField& Sf,
|
||||||
|
const scalarField& weightField
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Specialisation of processing vectors
|
||||||
template<>
|
template<>
|
||||||
vector faceSource::processValues
|
vector faceSource::processValues
|
||||||
(
|
(
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -141,6 +141,26 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
|||||||
result = sum(values);
|
result = sum(values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case opSumDirection:
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"template<class Type>"
|
||||||
|
"Type Foam::fieldValues::faceSource::processSameTypeValues"
|
||||||
|
"("
|
||||||
|
"const Field<Type>&, "
|
||||||
|
"const vectorField&, "
|
||||||
|
"const scalarField&"
|
||||||
|
") const"
|
||||||
|
)
|
||||||
|
<< "Operation " << operationTypeNames_[operation_]
|
||||||
|
<< " not available for values of type "
|
||||||
|
<< pTraits<Type>::typeName
|
||||||
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
result = pTraits<Type>::zero;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case opAverage:
|
case opAverage:
|
||||||
{
|
{
|
||||||
result = sum(values)/values.size();
|
result = sum(values)/values.size();
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -43,6 +43,8 @@ void Foam::fieldValue::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
|
dict_ = dict;
|
||||||
|
|
||||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||||
dict.lookup("fields") >> fields_;
|
dict.lookup("fields") >> fields_;
|
||||||
dict.lookup("valueOutput") >> valueOutput_;
|
dict.lookup("valueOutput") >> valueOutput_;
|
||||||
@ -78,6 +80,7 @@ Foam::fieldValue::fieldValue
|
|||||||
functionObjectFile(obr, name, valueType),
|
functionObjectFile(obr, name, valueType),
|
||||||
name_(name),
|
name_(name),
|
||||||
obr_(obr),
|
obr_(obr),
|
||||||
|
dict_(dict),
|
||||||
active_(true),
|
active_(true),
|
||||||
log_(false),
|
log_(false),
|
||||||
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
|
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -75,6 +75,9 @@ protected:
|
|||||||
//- Database this class is registered to
|
//- Database this class is registered to
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
|
//- Construction dictionary
|
||||||
|
dictionary dict_;
|
||||||
|
|
||||||
//- Active flag
|
//- Active flag
|
||||||
bool active_;
|
bool active_;
|
||||||
|
|
||||||
@ -149,6 +152,9 @@ public:
|
|||||||
//- Return the reference to the object registry
|
//- Return the reference to the object registry
|
||||||
inline const objectRegistry& obr() const;
|
inline const objectRegistry& obr() const;
|
||||||
|
|
||||||
|
//- Return the reference to the construction dictionary
|
||||||
|
inline const dictionary& dict() const;
|
||||||
|
|
||||||
//- Return the active flag
|
//- Return the active flag
|
||||||
inline bool active() const;
|
inline bool active() const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -40,6 +40,12 @@ inline const Foam::objectRegistry& Foam::fieldValue::obr() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::dictionary& Foam::fieldValue::dict() const
|
||||||
|
{
|
||||||
|
return dict_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::fieldValue::active() const
|
inline bool Foam::fieldValue::active() const
|
||||||
{
|
{
|
||||||
return active_;
|
return active_;
|
||||||
|
|||||||
Reference in New Issue
Block a user