Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Sergio Ferraris
2011-11-22 16:24:25 +00:00
72 changed files with 2148 additions and 988 deletions

View File

@ -31,7 +31,7 @@ if (solveSpecies)
==
parcels.SYi(i, Yi)
+ combustion->R(Yi)
+ sources(Yi)
+ sources(rho, Yi)
);
sources.constrain(YEqn);

View File

@ -33,11 +33,10 @@ Application
int main(int argc, char *argv[])
{
#include "setRootCase.H"
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
#include "createTime.H"
#include "createMesh.H"
Info<< "Reading field p\n" << endl;
volScalarField p
@ -67,9 +66,29 @@ int main(int argc, char *argv[])
mesh
);
const pointMesh& pMesh = pointMesh::New(mesh);
const pointBoundaryMesh& pbm = pMesh.boundary();
Info<< "pointMesh boundary" << nl;
forAll(pbm, patchI)
{
Info<< "patch=" << pbm[patchI].name()
<< ", type=" << pbm[patchI].type()
<< ", coupled=" << pbm[patchI].coupled()
<< endl;
}
const volPointInterpolation& pInterp = volPointInterpolation::New(mesh);
pointScalarField pp(pInterp.interpolate(p));
Info<< pp.name() << " boundary" << endl;
forAll(pp.boundaryField(), patchI)
{
Info<< pbm[patchI].name() << " coupled="
<< pp.boundaryField()[patchI].coupled()<< endl;
}
pp.write();
pointVectorField pU(pInterp.interpolate(U));

View File

@ -1,3 +0,0 @@
redistributeMeshPar.C
EXE = $(FOAM_APPBIN)/redistributeMeshPar

View File

@ -0,0 +1,3 @@
redistributePar.C
EXE = $(FOAM_APPBIN)/redistributePar

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
redistributeMeshPar
redistributePar
Description
Redistributes existing decomposed mesh and fields according to the current
@ -42,7 +42,7 @@ Description
cp -r constant processor0
# Distribute
mpirun -np ddd redistributeMeshPar -parallel
mpirun -np ddd redistributePar -parallel
\endverbatim
\*---------------------------------------------------------------------------*/

View File

@ -127,7 +127,7 @@ public:
//- Destructor
~processorPointPatchField();
virtual ~processorPointPatchField();
// Member functions

View File

@ -157,7 +157,6 @@ public:
// and/or mapping. First index is on this patch, second on the
// neighbour patch.
virtual const edgeList& transformPairs() const;
};

View File

@ -0,0 +1,181 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "CSV.H"
#include "DynamicList.H"
#include "IFstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
namespace Foam
{
// doesn't recognize specialization otherwise
template<>
scalar CSV<scalar>::readValue(const List<string>& splitted)
{
if (componentColumns_[0] >= splitted.size())
{
FatalErrorIn("CSV<scalar>::readValue(const List<string>&)")
<< "No column " << componentColumns_[0] << " in "
<< splitted << endl
<< exit(FatalError);
}
return readScalar(IStringStream(splitted[componentColumns_[0]])());
}
template<class Type>
Type CSV<Type>::readValue(const List<string>& splitted)
{
Type result;
for (label i = 0; i < pTraits<Type>::nComponents; i++)
{
if (componentColumns_[i] >= splitted.size())
{
FatalErrorIn("CSV<Type>::readValue(const List<string>&)")
<< "No column " << componentColumns_[i] << " in "
<< splitted << endl
<< exit(FatalError);
}
result[i] =
readScalar(IStringStream(splitted[componentColumns_[i]])());
}
return result;
}
}
template<class Type>
void Foam::CSV<Type>::read()
{
IFstream is(fName_.expand());
DynamicList<Tuple2<scalar, Type> > values;
// skip header
if (headerLine_)
{
string line;
is.getLine(line);
}
// read data
while (is.good())
{
string line;
is.getLine(line);
DynamicList<string> splitted;
std::size_t pos = 0;
while (pos != std::string::npos)
{
std::size_t nPos = line.find(separator_, pos);
if (nPos == std::string::npos)
{
splitted.append(line.substr(pos));
pos = nPos;
}
else
{
splitted.append(line.substr(pos, nPos - pos));
pos = nPos + 1;
}
}
if (splitted.size() <= 1)
{
break;
}
scalar x = readScalar(IStringStream(splitted[refColumn_])());
Type value = readValue(splitted);
values.append(Tuple2<scalar,Type>(x, value));
}
this->table_.transfer(values);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::CSV<Type>::CSV(const word& entryName, const dictionary& dict)
:
DataEntry<Type>(entryName),
TableBase<Type>(entryName, dict.subDict(type() + "Coeffs")),
coeffs_(dict.subDict(type() + "Coeffs")),
headerLine_(readBool(coeffs_.lookup("hasHeaderLine"))),
refColumn_(readLabel(coeffs_.lookup("refColumn"))),
componentColumns_(coeffs_.lookup("componentColumns")),
separator_(coeffs_.lookupOrDefault<string>("separator", string(","))[0]),
fName_(coeffs_.lookup("fileName"))
{
if (componentColumns_.size() != pTraits<Type>::nComponents)
{
FatalErrorIn("Foam::CSV<Type>::CSV(const word&, Istream&)")
<< componentColumns_ << " does not have the expected length of "
<< pTraits<Type>::nComponents << endl
<< exit(FatalError);
}
read();
TableBase<Type>::check();
}
template<class Type>
Foam::CSV<Type>::CSV(const CSV<Type>& tbl)
:
DataEntry<Type>(tbl),
TableBase<Type>(tbl),
headerLine_(tbl.headerLine_),
refColumn_(tbl.refColumn_),
componentColumns_(tbl.componentColumns_),
separator_(tbl.separator_),
fName_(tbl.fName_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::CSV<Type>::~CSV()
{}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "CSVIO.C"
// ************************************************************************* //

View File

@ -0,0 +1,183 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::CSV
Description
Templated CSV container data entry. Reference column is always a scalar,
e.g. time
\verbatim
<entryName> csvFile
{
hasHeaderLine true;
refColumn 0; // reference column index
componentColumns (0 1 2); // component column indices
separator ","; // optional (defaults to ",")
fileName fileXYZ; // name of csv data file
outOfBounds clamp; // optional out-of-bounds handling
}
\endverbatim
SourceFiles
CSV.C
\*---------------------------------------------------------------------------*/
#ifndef CSV_H
#define CSV_H
#include "DataEntry.H"
#include "TableBase.H"
#include "Tuple2.H"
#include "labelList.H"
#include "ISstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
class CSV;
template<class Type>
Ostream& operator<<
(
Ostream&,
const CSV<Type>&
);
/*---------------------------------------------------------------------------*\
Class CSV Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class CSV
:
public DataEntry<Type>,
public TableBase<Type>
{
// Private data
//- Coefficients dictionary (for convenience on reading)
dictionary coeffs_;
//- Does the file have a header line?
bool headerLine_;
//- Column of the time
label refColumn_;
//- Labels of the components
labelList componentColumns_;
//- Separator character
char separator_;
//- File name for csv table (optional)
fileName fName_;
// Private Member Functions
//- Read csv data table
void read();
//- Read the next value from the splitted string
Type readValue(const List<string>&);
//- Disallow default bitwise assignment
void operator=(const CSV<Type>&);
public:
//- Runtime type information
TypeName("csvFile");
// Constructors
//- Construct from entry name and Istream
CSV(const word& entryName, const dictionary& dict);
//- Copy constructor
CSV(const CSV<Type>& tbl);
//- Construct and return a clone
virtual tmp<DataEntry<Type> > clone() const
{
return tmp<DataEntry<Type> >(new CSV<Type>(*this));
}
//- Destructor
virtual ~CSV();
// Member Functions
//- Return Table value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O
//- Ostream Operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const CSV<Type>& cnst
);
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "CSV.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const CSV<Type>& tbl
)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const DataEntry<Type>& >(tbl)
<< token::SPACE << tbl.headerLine_
<< token::SPACE << tbl.timeColumn_
<< token::SPACE << tbl.componentColumns_
<< token::SPACE << tbl.separator_
<< token::SPACE << tbl.fileName_;
}
else
{
os << static_cast<const DataEntry<Type>& >(tbl);
}
// Check state of Ostream
os.check
(
"Ostream& operator<<(Ostream&, const CSV<Type>&)"
);
return os;
}
template<class Type>
void Foam::CSV<Type>::writeData(Ostream& os) const
{
DataEntry<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(type() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("headerLine") << headerLine_ << token::END_STATEMENT << nl;
os.writeKeyword("refColumn") << refColumn_ << token::END_STATEMENT << nl;
os.writeKeyword("componentColumns") << componentColumns_
<< token::END_STATEMENT << nl;
os.writeKeyword("separator") << string(separator_)
<< token::END_STATEMENT << nl;
os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -28,11 +28,14 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Constant<Type>::Constant(const word& entryName, Istream& is)
Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict)
:
DataEntry<Type>(entryName),
value_(pTraits<Type>::zero)
{
Istream& is(dict.lookup(entryName));
word entryType(is);
is >> value_;
}

View File

@ -83,7 +83,7 @@ public:
// Constructors
//- Construct from entry name and Istream
Constant(const word& entryName, Istream& is);
Constant(const word& entryName, const dictionary& dict);
//- Copy constructor
Constant(const Constant<Type>& cnst);

View File

@ -92,9 +92,9 @@ public:
dictionary,
(
const word& entryName,
Istream& is
const dictionary& dict
),
(entryName, is)
(entryName, dict)
);

View File

@ -35,7 +35,6 @@ Foam::autoPtr<Foam::DataEntry<Type> > Foam::DataEntry<Type>::New
)
{
Istream& is(dict.lookup(entryName));
word DataEntryType(is);
typename dictionaryConstructorTable::iterator cstrIter =
@ -54,7 +53,7 @@ Foam::autoPtr<Foam::DataEntry<Type> > Foam::DataEntry<Type>::New
<< exit(FatalError);
}
return autoPtr<DataEntry<Type> >(cstrIter()(entryName, is));
return autoPtr<DataEntry<Type> >(cstrIter()(entryName, dict));
}

View File

@ -28,17 +28,17 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Table<Type>::Table(const word& entryName, Istream& is)
Foam::Table<Type>::Table(const word& entryName, const dictionary& dict)
:
DataEntry<Type>(entryName),
table_(is)
TableBase<Type>(entryName, dictionary::null)
{
if (!table_.size())
{
FatalErrorIn("Foam::Table<Type>::Table(const Istream&)")
<< "Table for entry " << this->name_ << " is invalid (empty)"
<< nl << exit(FatalError);
}
Istream& is(dict.lookup(entryName));
word entryType(is);
is >> this->table_;
TableBase<Type>::check();
}
@ -46,7 +46,7 @@ template<class Type>
Foam::Table<Type>::Table(const Table<Type>& tbl)
:
DataEntry<Type>(tbl),
table_(tbl.table_)
TableBase<Type>(tbl)
{}
@ -57,98 +57,6 @@ Foam::Table<Type>::~Table()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Type Foam::Table<Type>::value(const scalar x) const
{
// Return zero if out of bounds
if (x < table_[0].first() || x > table_.last().first())
{
return pTraits<Type>::zero;
}
// Find i such that x(i) < x < x(i+1)
label i = 0;
while ((table_[i+1].first() < x) && (i+1 < table_.size()))
{
i++;
}
// Linear interpolation to find value. Note constructor needed for
// Table<label> to convert intermediate scalar back to label.
return Type
(
(x - table_[i].first())/(table_[i+1].first() - table_[i].first())
* (table_[i+1].second() - table_[i].second())
+ table_[i].second()
);
}
template<class Type>
Type Foam::Table<Type>::integrate(const scalar x1, const scalar x2) const
{
// Initialise return value
Type sum = pTraits<Type>::zero;
// Return zero if out of bounds
if ((x1 > table_.last().first()) || (x2 < table_[0].first()))
{
return sum;
}
// Find next index greater than x1
label id1 = 0;
while ((table_[id1].first() < x1) && (id1 < table_.size()))
{
id1++;
}
// Find next index less than x2
label id2 = table_.size() - 1;
while ((table_[id2].first() > x2) && (id2 >= 1))
{
id2--;
}
if ((id1 - id2) == 1)
{
// x1 and x2 lie within 1 interval
sum = 0.5*(value(x1) + value(x2))*(x2 - x1);
}
else
{
// x1 and x2 cross multiple intervals
// Integrate table body
for (label i=id1; i<id2; i++)
{
sum +=
(table_[i].second() + table_[i+1].second())
* (table_[i+1].first() - table_[i].first());
}
sum *= 0.5;
// Add table ends (partial segments)
if (id1 > 0)
{
sum += 0.5
* (value(x1) + table_[id1].second())
* (table_[id1].first() - x1);
}
if (id2 < table_.size() - 1)
{
sum += 0.5
* (table_[id2].second() + value(x2))
* (x2 - table_[id2].first());
}
}
return sum;
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "TableIO.C"

View File

@ -70,14 +70,9 @@ Ostream& operator<<
template<class Type>
class Table
:
public DataEntry<Type>
public DataEntry<Type>,
public TableBase<Type>
{
// Private data
//- Table data
List<Tuple2<scalar, Type> > table_;
// Private Member Functions
//- Disallow default bitwise assignment
@ -93,7 +88,7 @@ public:
// Constructors
//- Construct from entry name and Istream
Table(const word& entryName, Istream& is);
Table(const word& entryName, const dictionary& dict);
//- Copy constructor
Table(const Table<Type>& tbl);
@ -112,10 +107,16 @@ public:
// Member Functions
//- Return Table value
Type value(const scalar x) const;
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
Type integrate(const scalar x1, const scalar x2) const;
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O
@ -124,7 +125,7 @@ public:
friend Ostream& operator<< <Type>
(
Ostream& os,
const Table<Type>& cnst
const Table<Type>& tbl
);
//- Write in dictionary format

View File

@ -0,0 +1,399 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "TableBase.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict)
:
name_(name),
boundsHandling_
(
wordToBoundsHandling
(
dict.lookupOrDefault<word>("outOfBounds", "clamp")
)
),
table_()
{}
template<class Type>
Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
:
name_(tbl.name_),
boundsHandling_(tbl.boundsHandling_),
table_(tbl.table_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::TableBase<Type>::~TableBase()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::word Foam::TableBase<Type>::boundsHandlingToWord
(
const boundsHandling& bound
) const
{
word enumName("warn");
switch (bound)
{
case ERROR:
{
enumName = "error";
break;
}
case WARN:
{
enumName = "warn";
break;
}
case CLAMP:
{
enumName = "clamp";
break;
}
case REPEAT:
{
enumName = "repeat";
break;
}
}
return enumName;
}
template<class Type>
typename Foam::TableBase<Type>::boundsHandling
Foam::TableBase<Type>::wordToBoundsHandling
(
const word& bound
) const
{
if (bound == "error")
{
return ERROR;
}
else if (bound == "warn")
{
return WARN;
}
else if (bound == "clamp")
{
return CLAMP;
}
else if (bound == "repeat")
{
return REPEAT;
}
else
{
WarningIn("Foam::TableBase<Type>::wordToBoundsHandling(const word&)")
<< "bad outOfBounds specifier " << bound << " using 'warn'"
<< endl;
return WARN;
}
}
template<class Type>
typename Foam::TableBase<Type>::boundsHandling
Foam::TableBase<Type>::outOfBounds
(
const boundsHandling& bound
)
{
boundsHandling prev = boundsHandling_;
boundsHandling_ = bound;
return prev;
}
template<class Type>
void Foam::TableBase<Type>::check() const
{
if (!table_.size())
{
FatalErrorIn("Foam::TableBase<Type>::check() const")
<< "Table for entry " << this->name_ << " is invalid (empty)"
<< nl << exit(FatalError);
}
label n = table_.size();
scalar prevValue = table_[0].first();
for (label i = 1; i < n; ++i)
{
const scalar currValue = table_[i].first();
// avoid duplicate values (divide-by-zero error)
if (currValue <= prevValue)
{
FatalErrorIn("Foam::TableBase<Type>::check() const")
<< "out-of-order value: " << currValue << " at index " << i
<< exit(FatalError);
}
prevValue = currValue;
}
}
template<class Type>
bool Foam::TableBase<Type>::checkMinBounds
(
const scalar x,
scalar& xDash
) const
{
if (x < table_[0].first())
{
switch (boundsHandling_)
{
case ERROR:
{
FatalErrorIn
(
"bool Foam::TableBase<Type>::checkMinBounds"
"("
"const scalar, "
"scalar&"
") const"
) << "value (" << x << ") underflow"
<< exit(FatalError);
break;
}
case WARN:
{
WarningIn
(
"bool Foam::TableBase<Type>::checkMinBounds"
"("
"const scalar, "
"scalar&"
") const"
) << "value (" << x << ") underflow" << nl
<< endl;
// fall-through to 'CLAMP'
}
case CLAMP:
{
xDash = table_[0].first();
return true;
break;
}
case REPEAT:
{
// adjust x to >= minX
scalar span = table_.last().first() - table_[0].first();
xDash = fmod(x - table_[0].first(), span) + table_[0].first();
break;
}
}
}
else
{
xDash = x;
}
return false;
}
template<class Type>
bool Foam::TableBase<Type>::checkMaxBounds
(
const scalar x,
scalar& xDash
) const
{
if (x > table_.last().first())
{
switch (boundsHandling_)
{
case ERROR:
{
FatalErrorIn
(
"bool Foam::TableBase<Type>::checkMaxBounds"
"("
"const scalar, "
"scalar&"
") const"
) << "value (" << x << ") overflow"
<< exit(FatalError);
break;
}
case WARN:
{
WarningIn
(
"bool Foam::TableBase<Type>::checkMaxBounds"
"("
"const scalar, "
"scalar&"
") const"
) << "value (" << x << ") overflow" << nl
<< endl;
// fall-through to 'CLAMP'
}
case CLAMP:
{
xDash = table_.last().first();
return true;
break;
}
case REPEAT:
{
// adjust x to >= minX
scalar span = table_.last().first() - table_[0].first();
xDash = fmod(x - table_[0].first(), span) + table_[0].first();
break;
}
}
}
else
{
xDash = x;
}
return false;
}
template<class Type>
Type Foam::TableBase<Type>::value(const scalar x) const
{
scalar xDash = x;
if (checkMinBounds(x, xDash))
{
return table_[0].second();
}
if (checkMaxBounds(xDash, xDash))
{
return table_.last().second();
}
// Find i such that x(i) < xDash < x(i+1)
label i = 0;
while ((table_[i+1].first() < xDash) && (i+1 < table_.size()))
{
i++;
}
// Linear interpolation to find value
return Type
(
(xDash - table_[i].first())/(table_[i+1].first() - table_[i].first())
* (table_[i+1].second() - table_[i].second())
+ table_[i].second()
);
}
template<class Type>
Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const
{
// Initialise return value
Type sum = pTraits<Type>::zero;
// Return zero if out of bounds
if ((x1 > table_.last().first()) || (x2 < table_[0].first()))
{
return sum;
}
// Find next index greater than x1
label id1 = 0;
while ((table_[id1].first() < x1) && (id1 < table_.size()))
{
id1++;
}
// Find next index less than x2
label id2 = table_.size() - 1;
while ((table_[id2].first() > x2) && (id2 >= 1))
{
id2--;
}
if ((id1 - id2) == 1)
{
// x1 and x2 lie within 1 interval
sum = 0.5*(value(x1) + value(x2))*(x2 - x1);
}
else
{
// x1 and x2 cross multiple intervals
// Integrate table body
for (label i=id1; i<id2; i++)
{
sum +=
(table_[i].second() + table_[i+1].second())
* (table_[i+1].first() - table_[i].first());
}
sum *= 0.5;
// Add table ends (partial segments)
if (id1 > 0)
{
sum += 0.5
* (value(x1) + table_[id1].second())
* (table_[id1].first() - x1);
}
if (id2 < table_.size() - 1)
{
sum += 0.5
* (table_[id2].second() + value(x2))
* (x2 - table_[id2].first());
}
}
return sum;
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "TableBaseIO.C"
// ************************************************************************* //

View File

@ -0,0 +1,167 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::TableBase
Description
Base class for table with bounds handling, interpolation and integration
SourceFiles
TableBase.C
\*---------------------------------------------------------------------------*/
#ifndef TableBase_H
#define TableBase_H
#include "DataEntry.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
class TableBase;
template<class Type>
Ostream& operator<<
(
Ostream&,
const TableBase<Type>&
);
/*---------------------------------------------------------------------------*\
Class TableBase Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class TableBase
{
public:
// Public data types
//- Enumeration for handling out-of-bound values
enum boundsHandling
{
ERROR, /*!< Exit with a FatalError */
WARN, /*!< Issue warning and clamp value (default) */
CLAMP, /*!< Clamp value to the start/end value */
REPEAT /*!< Treat as a repeating list */
};
protected:
// Protected data
//- Table name
word name_;
//- Enumeration for handling out-of-bound values
boundsHandling boundsHandling_;
//- Table data
List<Tuple2<scalar, Type> > table_;
// Protected Member Functions
//- Disallow default bitwise assignment
void operator=(const TableBase<Type>&);
public:
// Constructors
//- Construct from dictionary - note table is not populated
TableBase(const word& name, const dictionary& dict);
//- Copy constructor
TableBase(const TableBase<Type>& tbl);
//- Destructor
virtual ~TableBase();
// Member Functions
//- Return the out-of-bounds handling as a word
word boundsHandlingToWord(const boundsHandling& bound) const;
//- Return the out-of-bounds handling as an enumeration
boundsHandling wordToBoundsHandling(const word& bound) const;
//- Set the out-of-bounds handling from enum, return previous setting
boundsHandling outOfBounds(const boundsHandling& bound);
//- Check the table for size and consistency
void check() const;
//- Check minimum table bounds
bool checkMinBounds(const scalar x, scalar& xDash) const;
//- Check maximum table bounds
bool checkMaxBounds(const scalar x, scalar& xDash) const;
//- Return Table value
virtual Type value(const scalar x) const;
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const;
// I/O
//- Ostream Operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const TableBase<Type>& tbl
);
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "TableBase.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,28 +23,45 @@ License
\*---------------------------------------------------------------------------*/
#ifndef timeVaryingUniformFixedValueFvPatchFieldsFwd_H
#define timeVaryingUniformFixedValueFvPatchFieldsFwd_H
#include "DataEntry.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const TableBase<Type>& tbl
)
{
if (os.format() == IOstream::ASCII)
{
os << token::SPACE << tbl.table_;
}
else
{
os.write
(
reinterpret_cast<const char*>(&tbl.table_),
sizeof(tbl.table_)
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Check state of Ostream
os.check
(
"Ostream& operator<<(Ostream&, const TableBase<Type>&, const bool)"
);
template<class Type> class timeVaryingUniformFixedValueFvPatchField;
return os;
}
makePatchTypeFieldTypedefs(timeVaryingUniformFixedValue);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::TableBase<Type>::writeData(Ostream& os) const
{
os << nl << indent << table_ << token::END_STATEMENT << nl;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -34,20 +34,8 @@ Foam::Ostream& Foam::operator<<
const Table<Type>& tbl
)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const DataEntry<Type>& >(tbl)
<< token::SPACE << tbl.table_;
}
else
{
os << static_cast<const DataEntry<Type>& >(tbl);
os.write
(
reinterpret_cast<const char*>(&tbl.table_),
sizeof(tbl.table_)
);
}
os << static_cast<const DataEntry<Type>&>(tbl)
<< static_cast<const TableBase<Type>&>(tbl);
// Check state of Ostream
os.check
@ -63,8 +51,7 @@ template<class Type>
void Foam::Table<Type>::writeData(Ostream& os) const
{
DataEntry<Type>::writeData(os);
os << nl << indent << table_ << token::END_STATEMENT << nl;
TableBase<Type>::writeData(os);
}

View File

@ -0,0 +1,69 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "TableFile.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict)
:
DataEntry<Type>(entryName),
TableBase<Type>(entryName, dict.subDict(type() + "Coeffs")),
fName_("none")
{
const dictionary coeffs(dict.subDict(type() + "Coeffs"));
coeffs.lookup("fileName") >> fName_;
IFstream is(fName_.expand());
is >> this->table_;
TableBase<Type>::check();
}
template<class Type>
Foam::TableFile<Type>::TableFile(const TableFile<Type>& tbl)
:
DataEntry<Type>(tbl),
TableBase<Type>(tbl),
fName_(tbl.fName_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::TableFile<Type>::~TableFile()
{}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "TableFileIO.C"
// ************************************************************************* //

View File

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::TableFile
Description
Templated table container data entry where data is read from file.
\verbatim
<entryName> tableFile;
tableCoeffs
{
fileName dataFile; // name of data file
outOfBounds clamp; // optional out-of-bounds handling
}
\endverbatim
Items are stored in a list of Tuple2's. First column is always stored as
scalar entries. Data is read in the form, e.g. for an entry \<entryName\>
that is (scalar, vector):
\verbatim
(
0.0 (1 2 3)
1.0 (4 5 6)
);
\endverbatim
SourceFiles
TableFile.C
\*---------------------------------------------------------------------------*/
#ifndef TableFile_H
#define TableFile_H
#include "DataEntry.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
class TableFile;
template<class Type>
Ostream& operator<<
(
Ostream&,
const TableFile<Type>&
);
/*---------------------------------------------------------------------------*\
Class TableFile Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class TableFile
:
public DataEntry<Type>,
public TableBase<Type>
{
// Private data
//- File name for csv table (optional)
fileName fName_;
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const TableFile<Type>&);
public:
//- Runtime type information
TypeName("tableFile");
// Constructors
//- Construct from entry name and Istream
TableFile(const word& entryName, const dictionary& dict);
//- Copy constructor
TableFile(const TableFile<Type>& tbl);
//- Construct and return a clone
virtual tmp<DataEntry<Type> > clone() const
{
return tmp<DataEntry<Type> >(new TableFile<Type>(*this));
}
//- Destructor
virtual ~TableFile();
// Member Functions
//- Return TableFile value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O
//- Ostream Operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const TableFile<Type>& tbl
);
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "TableFile.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const TableFile<Type>& tbl
)
{
os << static_cast<const DataEntry<Type>&>(tbl)
<< static_cast<const TableBase<Type>&>(tbl);
// Check state of Ostream
os.check
(
"Ostream& operator<<(Ostream&, const TableFile<Type>&)"
);
return os;
}
template<class Type>
void Foam::TableFile<Type>::writeData(Ostream& os) const
{
DataEntry<Type>::writeData(os);
os << token::END_STATEMENT << nl
<< indent << word(type() + "Coeffs") << nl
<< indent << token::BEGIN_BLOCK << nl << incrIndent;
os.writeKeyword("fileName")<< fName_ << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -23,27 +23,56 @@ License
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
#include "Constant.H"
#include "CSV.H"
#include "DataEntry.H"
#include "Table.H"
#include "TableFile.H"
#include "label.H"
#include "scalar.H"
#include "vector.H"
#include "sphericalTensor.H"
#include "symmTensor.H"
#include "tensor.H"
namespace Foam
{
makeDataEntry(label);
makeDataEntryType(Constant, label);
// makeDataEntryType(CSV, label);
makeDataEntryType(Table, label);
makeDataEntryType(TableFile, label);
makeDataEntry(scalar);
makeDataEntryType(Constant, scalar);
makeDataEntryType(CSV, scalar);
makeDataEntryType(Table, scalar);
makeDataEntryType(TableFile, scalar);
makeDataEntry(vector);
makeDataEntryType(Constant, vector);
makeDataEntryType(CSV, vector);
makeDataEntryType(Table, vector);
makeDataEntryType(TableFile, vector);
makeDataEntry(sphericalTensor);
makeDataEntryType(Constant, sphericalTensor);
makeDataEntryType(CSV, sphericalTensor);
makeDataEntryType(Table, sphericalTensor);
makeDataEntryType(TableFile, sphericalTensor);
makeDataEntry(symmTensor);
makeDataEntryType(Constant, symmTensor);
makeDataEntryType(CSV, symmTensor);
makeDataEntryType(Table, symmTensor);
makeDataEntryType(TableFile, symmTensor);
makeDataEntry(tensor);
makeDataEntryType(Constant, tensor);
makeDataEntryType(CSV, tensor);
makeDataEntryType(Table, tensor);
makeDataEntryType(TableFile, tensor);
}

View File

@ -34,12 +34,17 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polynomial::polynomial(const word& entryName, Istream& is)
Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
:
DataEntry<scalar>(entryName),
coeffs_(is),
coeffs_(),
canIntegrate_(true)
{
Istream& is(dict.lookup(entryName));
word entryType(is);
is >> coeffs_;
if (!coeffs_.size())
{
FatalErrorIn("Foam::polynomial::polynomial(const word&, Istream&)")

View File

@ -94,7 +94,7 @@ public:
// Constructors
polynomial(const word& entryName, Istream& is);
polynomial(const word& entryName, const dictionary& dict);
//- Copy constructor
polynomial(const polynomial& poly);

View File

@ -158,8 +158,6 @@ $(derivedFvPatchFields)/surfaceNormalFixedValue/surfaceNormalFixedValueFvPatchVe
$(derivedFvPatchFields)/syringePressure/syringePressureFvPatchScalarField.C
$(derivedFvPatchFields)/timeVaryingMappedFixedValue/AverageIOFields.C
$(derivedFvPatchFields)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchFields.C
$(derivedFvPatchFields)/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.C
$(derivedFvPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C
$(derivedFvPatchFields)/totalPressure/totalPressureFvPatchScalarField.C
$(derivedFvPatchFields)/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.C
$(derivedFvPatchFields)/totalTemperature/totalTemperatureFvPatchScalarField.C

View File

@ -31,8 +31,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
flowRateInletVelocityFvPatchVectorField::
Foam::flowRateInletVelocityFvPatchVectorField::
flowRateInletVelocityFvPatchVectorField
(
const fvPatch& p,
@ -40,14 +39,13 @@ flowRateInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(p, iF),
flowRate_(0),
flowRate_(),
phiName_("phi"),
rhoName_("rho")
{}
Foam::
flowRateInletVelocityFvPatchVectorField::
Foam::flowRateInletVelocityFvPatchVectorField::
flowRateInletVelocityFvPatchVectorField
(
const flowRateInletVelocityFvPatchVectorField& ptf,
@ -57,14 +55,13 @@ flowRateInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
flowRate_(ptf.flowRate_),
flowRate_(ptf.flowRate_().clone().ptr()),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
{}
Foam::
flowRateInletVelocityFvPatchVectorField::
Foam::flowRateInletVelocityFvPatchVectorField::
flowRateInletVelocityFvPatchVectorField
(
const fvPatch& p,
@ -73,28 +70,26 @@ flowRateInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(p, iF, dict),
flowRate_(readScalar(dict.lookup("flowRate"))),
flowRate_(DataEntry<scalar>::New("flowRate", dict)),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{}
Foam::
flowRateInletVelocityFvPatchVectorField::
Foam::flowRateInletVelocityFvPatchVectorField::
flowRateInletVelocityFvPatchVectorField
(
const flowRateInletVelocityFvPatchVectorField& ptf
)
:
fixedValueFvPatchField<vector>(ptf),
flowRate_(ptf.flowRate_),
flowRate_(ptf.flowRate_().clone().ptr()),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
{}
Foam::
flowRateInletVelocityFvPatchVectorField::
Foam::flowRateInletVelocityFvPatchVectorField::
flowRateInletVelocityFvPatchVectorField
(
const flowRateInletVelocityFvPatchVectorField& ptf,
@ -102,7 +97,7 @@ flowRateInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(ptf, iF),
flowRate_(ptf.flowRate_),
flowRate_(ptf.flowRate_().clone().ptr()),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
{}
@ -117,8 +112,10 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
return;
}
const scalar t = db().time().value();
// a simpler way of doing this would be nice
const scalar avgU = -flowRate_/gSum(patch().magSf());
const scalar avgU = -flowRate_->value(t)/gSum(patch().magSf());
tmp<vectorField> n = patch().nf();
@ -157,7 +154,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
flowRate_->writeData(os);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntry("value", os);

View File

@ -57,6 +57,7 @@ SourceFiles
#define flowRateInletVelocityFvPatchVectorField_H
#include "fixedValueFvPatchFields.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +74,7 @@ class flowRateInletVelocityFvPatchVectorField
// Private data
//- Inlet integral flow rate
scalar flowRate_;
autoPtr<DataEntry<scalar> > flowRate_;
//- Name of the flux transporting the field
word phiName_;
@ -153,27 +154,11 @@ public:
// Member functions
// Access
//- Return the flux
scalar flowRate() const
{
return flowRate_;
}
//- Return reference to the flux to allow adjustment
scalar& flowRate()
{
return flowRate_;
}
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};

View File

@ -33,10 +33,13 @@ License
void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
calcTangentialVelocity()
{
vector axisHat = omega_/mag(omega_);
const scalar t = this->db().time().value();
vector om = omega_->value(t);
vector axisHat = om/mag(om);
const vectorField tangentialVelocity
(
(-omega_) ^ (patch().Cf() - axisHat*(axisHat & patch().Cf()))
(-om) ^ (patch().Cf() - axisHat*(axisHat & patch().Cf()))
);
const vectorField n(patch().nf());
@ -54,7 +57,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
)
:
pressureInletOutletVelocityFvPatchVectorField(p, iF),
omega_(vector::zero)
omega_()
{}
@ -68,7 +71,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
)
:
pressureInletOutletVelocityFvPatchVectorField(ptf, p, iF, mapper),
omega_(ptf.omega_)
omega_(ptf.omega_().clone().ptr())
{
calcTangentialVelocity();
}
@ -83,7 +86,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
)
:
pressureInletOutletVelocityFvPatchVectorField(p, iF, dict),
omega_(dict.lookup("omega"))
omega_(DataEntry<vector>::New("omega", dict))
{
calcTangentialVelocity();
}
@ -92,11 +95,11 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
rotatingPressureInletOutletVelocityFvPatchVectorField
(
const rotatingPressureInletOutletVelocityFvPatchVectorField& pivpvf
const rotatingPressureInletOutletVelocityFvPatchVectorField& rppvf
)
:
pressureInletOutletVelocityFvPatchVectorField(pivpvf),
omega_(pivpvf.omega_)
pressureInletOutletVelocityFvPatchVectorField(rppvf),
omega_(rppvf.omega_().clone().ptr())
{
calcTangentialVelocity();
}
@ -105,12 +108,12 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
rotatingPressureInletOutletVelocityFvPatchVectorField
(
const rotatingPressureInletOutletVelocityFvPatchVectorField& pivpvf,
const rotatingPressureInletOutletVelocityFvPatchVectorField& rppvf,
const DimensionedField<vector, volMesh>& iF
)
:
pressureInletOutletVelocityFvPatchVectorField(pivpvf, iF),
omega_(pivpvf.omega_)
pressureInletOutletVelocityFvPatchVectorField(rppvf, iF),
omega_(rppvf.omega_().clone().ptr())
{
calcTangentialVelocity();
}
@ -125,7 +128,7 @@ void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::write
{
fvPatchVectorField::write(os);
os.writeKeyword("phi") << phiName() << token::END_STATEMENT << nl;
os.writeKeyword("omega")<< omega_ << token::END_STATEMENT << nl;
omega_->writeData(os);
writeEntry("value", os);
}

View File

@ -40,6 +40,7 @@ SourceFiles
#include "fvPatchFields.H"
#include "pressureInletOutletVelocityFvPatchVectorField.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,7 +48,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rotatingPressureInletOutletVelocityFvPatch Declaration
Class rotatingPressureInletOutletVelocityFvPatch Declaration
\*---------------------------------------------------------------------------*/
class rotatingPressureInletOutletVelocityFvPatchVectorField
@ -57,7 +58,7 @@ class rotatingPressureInletOutletVelocityFvPatchVectorField
// Private data
//- Angular velocity of the frame
vector omega_;
autoPtr<DataEntry<vector> > omega_;
// Private Member Functions
@ -141,23 +142,6 @@ public:
// Member functions
// Access
//- Return the angular velocity of rotation
const vector& omega() const
{
return omega_;
}
//- Reset the angular velocity of rotation
// and update the tangentialVelocity
void setOmega(const vector& omega)
{
omega_ = omega;
calcTangentialVelocity();
}
//- Write
virtual void write(Ostream&) const;
};

View File

@ -39,7 +39,7 @@ rotatingTotalPressureFvPatchScalarField
)
:
totalPressureFvPatchScalarField(p, iF),
omega_(vector::zero)
omega_()
{}
@ -53,7 +53,7 @@ rotatingTotalPressureFvPatchScalarField
)
:
totalPressureFvPatchScalarField(ptf, p, iF, mapper),
omega_(ptf.omega_)
omega_(ptf.omega_().clone().ptr())
{}
@ -66,30 +66,30 @@ rotatingTotalPressureFvPatchScalarField
)
:
totalPressureFvPatchScalarField(p, iF, dict),
omega_(dict.lookup("omega"))
omega_(DataEntry<vector>::New("omega", dict))
{}
Foam::rotatingTotalPressureFvPatchScalarField::
rotatingTotalPressureFvPatchScalarField
(
const rotatingTotalPressureFvPatchScalarField& tppsf
const rotatingTotalPressureFvPatchScalarField& rtppsf
)
:
totalPressureFvPatchScalarField(tppsf),
omega_(tppsf.omega_)
totalPressureFvPatchScalarField(rtppsf),
omega_(rtppsf.omega_().clone().ptr())
{}
Foam::rotatingTotalPressureFvPatchScalarField::
rotatingTotalPressureFvPatchScalarField
(
const rotatingTotalPressureFvPatchScalarField& tppsf,
const rotatingTotalPressureFvPatchScalarField& rtppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
totalPressureFvPatchScalarField(tppsf, iF),
omega_(tppsf.omega_)
totalPressureFvPatchScalarField(rtppsf, iF),
omega_(rtppsf.omega_().clone().ptr())
{}
@ -102,9 +102,12 @@ void Foam::rotatingTotalPressureFvPatchScalarField::updateCoeffs()
return;
}
vector axisHat = omega_/mag(omega_);
const scalar t = this->db().time().value();
const vector om = omega_->value(t);
vector axisHat = om/mag(om);
tmp<vectorField> rotationVelocity =
omega_ ^ (patch().Cf() - axisHat*(axisHat & patch().Cf()));
om ^ (patch().Cf() - axisHat*(axisHat & patch().Cf()));
const vectorField Up
(
@ -119,7 +122,7 @@ void Foam::rotatingTotalPressureFvPatchScalarField::updateCoeffs()
void Foam::rotatingTotalPressureFvPatchScalarField::write(Ostream& os) const
{
totalPressureFvPatchScalarField::write(os);
os.writeKeyword("omega")<< omega_ << token::END_STATEMENT << nl;
omega_->writeData(os);
}

View File

@ -36,6 +36,7 @@ SourceFiles
#define rotatingTotalPressureFvPatchScalarField_H
#include "totalPressureFvPatchScalarField.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,7 +44,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rotatingTotalPressureFvPatch Declaration
Class rotatingTotalPressureFvPatch Declaration
\*---------------------------------------------------------------------------*/
class rotatingTotalPressureFvPatchScalarField
@ -53,7 +54,7 @@ class rotatingTotalPressureFvPatchScalarField
// Private data
//- Angular velocity of the frame
vector omega_;
autoPtr<DataEntry<vector> > omega_;
public:
@ -126,21 +127,6 @@ public:
// Member functions
// Access
//- Return the angular velocity of rotation
const vector& omega() const
{
return omega_;
}
//- Return the angular velocity of rotation
vector& omega()
{
return omega_;
}
// Evaluation functions
//- Update the coefficients associated with the patch field

View File

@ -38,7 +38,7 @@ rotatingWallVelocityFvPatchVectorField
)
:
fixedValueFvPatchField<vector>(p, iF),
origin_(vector::zero),
origin_(),
axis_(vector::zero),
omega_(0)
{}
@ -56,7 +56,7 @@ rotatingWallVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
origin_(ptf.origin_),
axis_(ptf.axis_),
omega_(ptf.omega_)
omega_(ptf.omega_().clone().ptr())
{}
@ -71,7 +71,7 @@ rotatingWallVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(p, iF),
origin_(dict.lookup("origin")),
axis_(dict.lookup("axis")),
omega_(readScalar(dict.lookup("omega")))
omega_(DataEntry<scalar>::New("omega", dict))
{
// Evaluate the wall velocity
updateCoeffs();
@ -81,27 +81,27 @@ rotatingWallVelocityFvPatchVectorField
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const rotatingWallVelocityFvPatchVectorField& pivpvf
const rotatingWallVelocityFvPatchVectorField& rwvpvf
)
:
fixedValueFvPatchField<vector>(pivpvf),
origin_(pivpvf.origin_),
axis_(pivpvf.axis_),
omega_(pivpvf.omega_)
fixedValueFvPatchField<vector>(rwvpvf),
origin_(rwvpvf.origin_),
axis_(rwvpvf.axis_),
omega_(rwvpvf.omega_().clone().ptr())
{}
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const rotatingWallVelocityFvPatchVectorField& pivpvf,
const rotatingWallVelocityFvPatchVectorField& rwvpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchField<vector>(pivpvf, iF),
origin_(pivpvf.origin_),
axis_(pivpvf.axis_),
omega_(pivpvf.omega_)
fixedValueFvPatchField<vector>(rwvpvf, iF),
origin_(rwvpvf.origin_),
axis_(rwvpvf.axis_),
omega_(rwvpvf.omega_().clone().ptr())
{}
@ -114,10 +114,13 @@ void Foam::rotatingWallVelocityFvPatchVectorField::updateCoeffs()
return;
}
const scalar t = this->db().time().value();
scalar om = omega_->value(t);
// Calculate the rotating wall velocity from the specification of the motion
const vectorField Up
(
(-omega_)*((patch().Cf() - origin_) ^ (axis_/mag(axis_)))
(-om)*((patch().Cf() - origin_) ^ (axis_/mag(axis_)))
);
// Remove the component of Up normal to the wall
@ -134,7 +137,7 @@ void Foam::rotatingWallVelocityFvPatchVectorField::write(Ostream& os) const
fvPatchVectorField::write(os);
os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
os.writeKeyword("omega") << omega_ << token::END_STATEMENT << nl;
omega_->writeData(os);
writeEntry("value", os);
}

View File

@ -36,6 +36,7 @@ SourceFiles
#define rotatingWallVelocityFvPatchVectorField_H
#include "fixedValueFvPatchFields.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,7 +44,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rotatingWallVelocityFvPatch Declaration
Class rotatingWallVelocityFvPatch Declaration
\*---------------------------------------------------------------------------*/
class rotatingWallVelocityFvPatchVectorField
@ -59,7 +60,7 @@ class rotatingWallVelocityFvPatchVectorField
vector axis_;
//- Rotational speed
scalar omega_;
autoPtr<DataEntry<scalar> > omega_;
public:
@ -147,12 +148,6 @@ public:
return axis_;
}
//- Return the rotational speed
scalar omega() const
{
return omega_;
}
//- Return non-const access to the origin of the rotation
vector& origin()
{
@ -165,12 +160,6 @@ public:
return axis_;
}
//- Return non-const access to the rotational speed
scalar& omega()
{
return omega_;
}
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -1,132 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "timeVaryingFlowRateInletVelocityFvPatchVectorField.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "surfaceFields.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
flowRateInletVelocityFvPatchVectorField(p, iF),
timeSeries_()
{}
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
flowRateInletVelocityFvPatchVectorField(ptf, p, iF, mapper),
timeSeries_(ptf.timeSeries_)
{}
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
flowRateInletVelocityFvPatchVectorField(p, iF, dict),
timeSeries_(dict)
{}
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf
)
:
flowRateInletVelocityFvPatchVectorField(ptf),
timeSeries_(ptf.timeSeries_)
{}
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
const DimensionedField<vector, volMesh>& iF
)
:
flowRateInletVelocityFvPatchVectorField(ptf, iF),
timeSeries_(ptf.timeSeries_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
updateCoeffs()
{
if (updated())
{
return;
}
flowRate() = timeSeries_(this->db().time().timeOutputValue());
flowRateInletVelocityFvPatchVectorField::updateCoeffs();
}
void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
write(Ostream& os) const
{
flowRateInletVelocityFvPatchVectorField::write(os);
timeSeries_.write(os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
timeVaryingFlowRateInletVelocityFvPatchVectorField
);
}
// ************************************************************************* //

View File

@ -1,182 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField
Description
A time-varying form of a flow normal vector boundary condition. The
variation is specified as an interpolationTable (see
Foam::interpolationTable).
Example of the boundary condition specification:
\verbatim
inlet
{
type timeVaryingFlowRateInletVelocity;
flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s]
value uniform (0 0 0); // placeholder
fileName "$FOAM_CASE/time-series";
outOfBounds repeat; // (error|warn|clamp|repeat)
}
\endverbatim
Note
- The value is positive inwards
- may not work correctly for transonic inlets!
- strange behaviour with potentialFoam since the U equation is not solved
See Also
Foam::interpolationTable and Foam::flowRateInletVelocityFvPatchVectorField
SourceFiles
timeVaryingFlowRateInletVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef timeVaryingFlowRateInletVelocityFvPatchVectorField_H
#define timeVaryingFlowRateInletVelocityFvPatchVectorField_H
#include "flowRateInletVelocityFvPatchVectorField.H"
#include "interpolationTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class timeVaryingFlowRateInletVelocityFvPatch Declaration
\*---------------------------------------------------------------------------*/
class timeVaryingFlowRateInletVelocityFvPatchVectorField
:
public flowRateInletVelocityFvPatchVectorField
{
// Private data
//- the time series being used, including the bounding treatment
interpolationTable<scalar> timeSeries_;
public:
//- Runtime type information
TypeName("timeVaryingFlowRateInletVelocity");
// Constructors
//- Construct from patch and internal field
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given patch field onto a new patch
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const timeVaryingFlowRateInletVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const timeVaryingFlowRateInletVelocityFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new timeVaryingFlowRateInletVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
timeVaryingFlowRateInletVelocityFvPatchVectorField
(
const timeVaryingFlowRateInletVelocityFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new timeVaryingFlowRateInletVelocityFvPatchVectorField
(
*this,
iF
)
);
}
// Member functions
// Access
//- Return the time series used
const interpolationTable<scalar>& timeSeries() const
{
return timeSeries_;
}
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,137 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "timeVaryingUniformFixedValueFvPatchField.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::timeVaryingUniformFixedValueFvPatchField<Type>::
timeVaryingUniformFixedValueFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
:
fixedValueFvPatchField<Type>(p, iF),
timeSeries_()
{}
template<class Type>
Foam::timeVaryingUniformFixedValueFvPatchField<Type>::
timeVaryingUniformFixedValueFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchField<Type>(p, iF),
timeSeries_(dict)
{
if (dict.found("value"))
{
fvPatchField<Type>::operator==(Field<Type>("value", dict, p.size()));
}
else
{
updateCoeffs();
}
}
template<class Type>
Foam::timeVaryingUniformFixedValueFvPatchField<Type>::
timeVaryingUniformFixedValueFvPatchField
(
const timeVaryingUniformFixedValueFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
timeSeries_(ptf.timeSeries_)
{}
template<class Type>
Foam::timeVaryingUniformFixedValueFvPatchField<Type>::
timeVaryingUniformFixedValueFvPatchField
(
const timeVaryingUniformFixedValueFvPatchField<Type>& ptf
)
:
fixedValueFvPatchField<Type>(ptf),
timeSeries_(ptf.timeSeries_)
{}
template<class Type>
Foam::timeVaryingUniformFixedValueFvPatchField<Type>::
timeVaryingUniformFixedValueFvPatchField
(
const timeVaryingUniformFixedValueFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
fixedValueFvPatchField<Type>(ptf, iF),
timeSeries_(ptf.timeSeries_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::timeVaryingUniformFixedValueFvPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
}
fvPatchField<Type>::operator==
(
timeSeries_(this->db().time().timeOutputValue())
);
fixedValueFvPatchField<Type>::updateCoeffs();
}
template<class Type>
void Foam::timeVaryingUniformFixedValueFvPatchField<Type>::write
(
Ostream& os
) const
{
fvPatchField<Type>::write(os);
timeSeries_.write(os);
this->writeEntry("value", os);
}
// ************************************************************************* //

View File

@ -1,183 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::timeVaryingUniformFixedValueFvPatchField
Description
A time-varying form of a uniform fixed value boundary condition. The
variation is specified as an interpolationTable (see
Foam::interpolationTable for read options).
Example of the boundary condition specification:
\verbatim
inlet
{
type timeVaryingUniformFixedValue;
fileName "$FOAM_CASE/time-series";
outOfBounds clamp; // (error|warn|clamp|repeat)
}
\endverbatim
Note
This class is derived directly from a fixedValue patch rather than from
a uniformFixedValue patch.
See Also
Foam::interpolationTable and Foam::fixedValueFvPatchField
SourceFiles
timeVaryingUniformFixedValueFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef timeVaryingUniformFixedValueFvPatchField_H
#define timeVaryingUniformFixedValueFvPatchField_H
#include "fixedValueFvPatchField.H"
#include "interpolationTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class timeVaryingUniformFixedValueFvPatch Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class timeVaryingUniformFixedValueFvPatchField
:
public fixedValueFvPatchField<Type>
{
// Private data
//- The time series being used, including the bounding treatment
interpolationTable<Type> timeSeries_;
public:
//- Runtime type information
TypeName("timeVaryingUniformFixedValue");
// Constructors
//- Construct from patch and internal field
timeVaryingUniformFixedValueFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch, internal field and dictionary
timeVaryingUniformFixedValueFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping given patch field onto a new patch
timeVaryingUniformFixedValueFvPatchField
(
const timeVaryingUniformFixedValueFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
timeVaryingUniformFixedValueFvPatchField
(
const timeVaryingUniformFixedValueFvPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<fvPatchField<Type> > clone() const
{
return tmp<fvPatchField<Type> >
(
new timeVaryingUniformFixedValueFvPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
timeVaryingUniformFixedValueFvPatchField
(
const timeVaryingUniformFixedValueFvPatchField<Type>&,
const DimensionedField<Type, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<Type> > clone
(
const DimensionedField<Type, volMesh>& iF
) const
{
return tmp<fvPatchField<Type> >
(
new timeVaryingUniformFixedValueFvPatchField<Type>(*this, iF)
);
}
// Member functions
// Access
//- Return the time series used
const interpolationTable<Type>& timeSeries() const
{
return timeSeries_;
}
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "timeVaryingUniformFixedValueFvPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -40,7 +40,7 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
)
:
fixedValueFvPatchField<Type>(p, iF),
uniformValue_(pTraits<Type>::zero)
uniformValue_()
{}
@ -54,9 +54,10 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
)
:
fixedValueFvPatchField<Type>(p, iF),
uniformValue_(ptf.uniformValue_)
uniformValue_(ptf.uniformValue_().clone().ptr())
{
fvPatchField<Type>::operator==(uniformValue_);
const scalar t = this->db().time().value();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
@ -69,9 +70,10 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
)
:
fixedValueFvPatchField<Type>(p, iF),
uniformValue_(pTraits<Type>(dict.lookup("uniformValue")))
uniformValue_(DataEntry<Type>::New("uniformValue", dict))
{
fvPatchField<Type>::operator==(uniformValue_);
const scalar t = this->db().time().value();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
@ -82,9 +84,10 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
)
:
fixedValueFvPatchField<Type>(ptf),
uniformValue_(ptf.uniformValue_)
uniformValue_(ptf.uniformValue_().clone().ptr())
{
fvPatchField<Type>::operator==(uniformValue_);
const scalar t = this->db().time().value();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
@ -96,9 +99,10 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
)
:
fixedValueFvPatchField<Type>(ptf, iF),
uniformValue_(ptf.uniformValue_)
uniformValue_(ptf.uniformValue_().clone().ptr())
{
fvPatchField<Type>::operator==(uniformValue_);
const scalar t = this->db().time().value();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
@ -111,7 +115,8 @@ void uniformFixedValueFvPatchField<Type>::autoMap
)
{
this->setSize(m.size());
fvPatchField<Type>::operator==(uniformValue_);
const scalar t = this->db().time().value();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
@ -119,8 +124,7 @@ template<class Type>
void uniformFixedValueFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
os.writeKeyword("uniformValue")
<< uniformValue_ << token::END_STATEMENT << nl;
uniformValue_->writeData(os);
}

View File

@ -37,6 +37,7 @@ SourceFiles
#include "Random.H"
#include "fixedValueFvPatchFields.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -44,7 +45,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformFixedValueFvPatch Declaration
Class uniformFixedValueFvPatch Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
@ -54,7 +55,7 @@ class uniformFixedValueFvPatchField
{
// Private data
Type uniformValue_;
autoPtr<DataEntry<Type> > uniformValue_;
public:
@ -127,21 +128,6 @@ public:
// Member functions
// Access
//- Return the fluctuation scale
const Type& uniformValue() const
{
return uniformValue_;
}
//- Return reference to the fluctuation scale to allow adjustment
Type& uniformValue()
{
return uniformValue_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object

View File

@ -235,7 +235,11 @@ tmp<Field<Type> > volPointInterpolation::flatBoundaryField
{
label bFaceI = bm[patchI].patch().start() - mesh.nInternalFaces();
if (!isA<emptyFvPatch>(bm[patchI]) && !bm[patchI].coupled())
if
(
!isA<emptyFvPatch>(bm[patchI])
&& !vf.boundaryField()[patchI].coupled()
)
{
SubList<Type>
(

View File

@ -31,6 +31,8 @@ License
#include "coupledPointPatchFields.H"
#include "pointConstraint.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -75,11 +77,19 @@ void volPointInterpolation::calcBoundaryAddressing()
const polyBoundaryMesh& pbm = mesh().boundaryMesh();
// Get precalculated volField only so we can use coupled() tests for
// cyclicAMI
const surfaceScalarField& magSf = mesh().magSf();
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (!isA<emptyPolyPatch>(pp) && !pp.coupled())
if
(
!isA<emptyPolyPatch>(pp)
&& !magSf.boundaryField()[patchI].coupled()
)
{
label bFaceI = pp.start()-mesh().nInternalFaces();

View File

@ -31,9 +31,33 @@ License
#include "Time.H"
#include "OFstream.H"
#include "wallPolyPatch.H"
#include "cyclicAMIPolyPatch.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template<class ParticleType>
void Foam::Cloud<ParticleType>::checkPatches() const
{
const polyBoundaryMesh& pbm = polyMesh_.boundaryMesh();
bool ok = true;
forAll(pbm, patchI)
{
if (isA<cyclicAMIPolyPatch>(pbm[patchI]))
{
ok = false;
break;
}
}
if (!ok)
{
WarningIn("void Foam::Cloud<ParticleType>::initCloud(const bool)")
<< "Particle tracking across AMI patches is not currently "
<< "supported" << endl;
}
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::calcCellWallFaces() const
{
@ -76,6 +100,8 @@ Foam::Cloud<ParticleType>::Cloud
nTrackingRescues_(),
cellWallFacesPtr_()
{
checkPatches();
// Ask for the tetBasePtIs to trigger all processors to build
// them, otherwise, if some processors have no particles then
// there is a comms mismatch.
@ -100,6 +126,8 @@ Foam::Cloud<ParticleType>::Cloud
nTrackingRescues_(),
cellWallFacesPtr_()
{
checkPatches();
// Ask for the tetBasePtIs to trigger all processors to build
// them, otherwise, if some processors have no particles then
// there is a comms mismatch.

View File

@ -93,6 +93,9 @@ class Cloud
// Private Member Functions
//- Check patches
void checkPatches() const;
//- Initialise cloud on IO constructor
void initCloud(const bool checkClass);

View File

@ -162,6 +162,8 @@ Foam::Cloud<ParticleType>::Cloud
nTrackingRescues_(),
cellWallFacesPtr_()
{
checkPatches();
initCloud(checkClass);
}
@ -180,6 +182,8 @@ Foam::Cloud<ParticleType>::Cloud
nTrackingRescues_(),
cellWallFacesPtr_()
{
checkPatches();
initCloud(checkClass);
}

View File

@ -37,6 +37,7 @@ SourceFiles
#include "coupledFacePointPatch.H"
#include "cyclicAMIPolyPatch.H"
#include "pointBoundaryMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -118,6 +119,43 @@ public:
return false;
}
//- Return the constraint type this pointPatch implements.
virtual const word& constraintType() const
{
return type();
}
//- Return the underlying cyclicAMIPolyPatch
const cyclicAMIPolyPatch& cyclicAMIPatch() const
{
return cyclicAMIPolyPatch_;
}
//- Return neighbour point patch
const cyclicAMIPointPatch& neighbPatch() const
{
label patchI = cyclicAMIPolyPatch_.neighbPatchID();
const pointPatch& pp = this->boundaryMesh()[patchI];
return refCast<const cyclicAMIPointPatch>(pp);
}
//- Are the cyclic planes parallel
bool parallel() const
{
return cyclicAMIPolyPatch_.parallel();
}
//- Return face transformation tensor
const tensorField& forwardT() const
{
return cyclicAMIPolyPatch_.forwardT();
}
//- Return neighbour-cell transformation tensor
const tensorField& reverseT() const
{
return cyclicAMIPolyPatch_.reverseT();
}
};

View File

@ -0,0 +1,210 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMIPointPatchField.H"
#include "Swap.H"
#include "transformField.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::cyclicAMIPointPatchField<Type>::cyclicAMIPointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF
)
:
coupledPointPatchField<Type>(p, iF),
cyclicAMIPatch_(refCast<const cyclicAMIPointPatch>(p)),
ppiPtr_(NULL),
nbrPpiPtr_(NULL)
{}
template<class Type>
Foam::cyclicAMIPointPatchField<Type>::cyclicAMIPointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict
)
:
coupledPointPatchField<Type>(p, iF, dict),
cyclicAMIPatch_(refCast<const cyclicAMIPointPatch>(p)),
ppiPtr_(NULL),
nbrPpiPtr_(NULL)
{
if (!isType<cyclicAMIPointPatch>(p))
{
FatalIOErrorIn
(
"cyclicAMIPointPatchField<Type>::cyclicAMIPointPatchField\n"
"(\n"
" const pointPatch&,\n"
" const DimensionedField<Type, pointMesh>&,\n"
" const dictionary&\n"
")\n",
dict
) << "patch " << this->patch().index() << " not cyclicAMI type. "
<< "Patch type = " << p.type()
<< exit(FatalIOError);
}
}
template<class Type>
Foam::cyclicAMIPointPatchField<Type>::cyclicAMIPointPatchField
(
const cyclicAMIPointPatchField<Type>& ptf,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const pointPatchFieldMapper& mapper
)
:
coupledPointPatchField<Type>(ptf, p, iF, mapper),
cyclicAMIPatch_(refCast<const cyclicAMIPointPatch>(p)),
ppiPtr_(NULL),
nbrPpiPtr_(NULL)
{
if (!isType<cyclicAMIPointPatch>(this->patch()))
{
FatalErrorIn
(
"cyclicAMIPointPatchField<Type>::cyclicAMIPointPatchField\n"
"(\n"
" const cyclicAMIPointPatchField<Type>&,\n"
" const pointPatch&,\n"
" const DimensionedField<Type, pointMesh>&,\n"
" const pointPatchFieldMapper&\n"
")\n"
) << "Field type does not correspond to patch type for patch "
<< this->patch().index() << "." << endl
<< "Field type: " << typeName << endl
<< "Patch type: " << this->patch().type()
<< exit(FatalError);
}
}
template<class Type>
Foam::cyclicAMIPointPatchField<Type>::cyclicAMIPointPatchField
(
const cyclicAMIPointPatchField<Type>& ptf,
const DimensionedField<Type, pointMesh>& iF
)
:
coupledPointPatchField<Type>(ptf, iF),
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
ppiPtr_(NULL),
nbrPpiPtr_(NULL)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::cyclicAMIPointPatchField<Type>::swapAddSeparated
(
const Pstream::commsTypes,
Field<Type>& pField
) const
{
if (cyclicAMIPatch_.cyclicAMIPatch().owner())
{
// We inplace modify pField. To prevent the other side (which gets
// evaluated at a later date) using already changed values we do
// all swaps on the side that gets evaluated first.
// Get neighbouring pointPatch
const cyclicAMIPointPatch& nbrPatch = cyclicAMIPatch_.neighbPatch();
// Get neighbouring pointPatchField
const GeometricField<Type, pointPatchField, pointMesh>& fld =
refCast<const GeometricField<Type, pointPatchField, pointMesh> >
(
this->dimensionedInternalField()
);
const cyclicAMIPointPatchField<Type>& nbr =
refCast<const cyclicAMIPointPatchField<Type> >
(
fld.boundaryField()[nbrPatch.index()]
);
Field<Type> ptFld(this->patchInternalField(pField));
Field<Type> nbrPtFld(nbr.patchInternalField(pField));
if (doTransform())
{
const tensor& forwardT = this->forwardT()[0];
const tensor& reverseT = this->reverseT()[0];
transform(ptFld, reverseT, ptFld);
transform(nbrPtFld, forwardT, nbrPtFld);
}
// convert point field to face field, AMI interpolate, then
// face back to point
{
// add neighbour side contribution to owner
Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
// interpolate to owner
nbrFcFld = cyclicAMIPatch_.cyclicAMIPatch().interpolate(nbrFcFld);
// add to internal field
this->addToInternalField
(
pField,
ppi().faceToPointInterpolate(nbrFcFld)()
);
}
{
// add owner side contribution to neighbour
Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
// interpolate to neighbour
fcFld =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate
(
fcFld
);
// add to internal field
nbr.addToInternalField
(
pField,
nbrPpi().faceToPointInterpolate(fcFld)()
);
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,241 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicAMIPointPatchField
Description
Cyclic AMI front and back plane patch field
SourceFiles
cyclicAMIPointPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIPointPatchField_H
#define cyclicAMIPointPatchField_H
#include "coupledPointPatchField.H"
#include "cyclicAMIPointPatch.H"
#include "PrimitivePatchInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMIPointPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class cyclicAMIPointPatchField
:
public coupledPointPatchField<Type>
{
// Private data
//- Local reference cast into the cyclicAMI patch
const cyclicAMIPointPatch& cyclicAMIPatch_;
//- Owner side patch interpolation pointer
mutable autoPtr<PrimitivePatchInterpolation<primitivePatch> > ppiPtr_;
//- Neighbour side patch interpolation pointer
mutable autoPtr<PrimitivePatchInterpolation<primitivePatch> >
nbrPpiPtr_;
// Private Member Functions
//- Owner side patch interpolation
const PrimitivePatchInterpolation<primitivePatch>& ppi() const
{
if (!ppiPtr_.valid())
{
ppiPtr_.reset
(
new PrimitivePatchInterpolation<primitivePatch>
(
cyclicAMIPatch_.cyclicAMIPatch()
)
);
}
return ppiPtr_();
}
//- Neighbour side patch interpolation
const PrimitivePatchInterpolation<primitivePatch>& nbrPpi() const
{
if (!nbrPpiPtr_.valid())
{
nbrPpiPtr_.reset
(
new PrimitivePatchInterpolation<primitivePatch>
(
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch()
)
);
}
return nbrPpiPtr_();
}
public:
//- Runtime type information
TypeName(cyclicAMIPointPatch::typeName_());
// Constructors
//- Construct from patch and internal field
cyclicAMIPointPatchField
(
const pointPatch&,
const DimensionedField<Type, pointMesh>&
);
//- Construct from patch, internal field and dictionary
cyclicAMIPointPatchField
(
const pointPatch&,
const DimensionedField<Type, pointMesh>&,
const dictionary&
);
//- Construct by mapping given patchField<Type> onto a new patch
cyclicAMIPointPatchField
(
const cyclicAMIPointPatchField<Type>&,
const pointPatch&,
const DimensionedField<Type, pointMesh>&,
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type> > clone() const
{
return autoPtr<pointPatchField<Type> >
(
new cyclicAMIPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
cyclicAMIPointPatchField
(
const cyclicAMIPointPatchField<Type>&,
const DimensionedField<Type, pointMesh>&
);
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type> > clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return autoPtr<pointPatchField<Type> >
(
new cyclicAMIPointPatchField<Type>
(
*this, iF
)
);
}
// Member functions
// Constraint handling
//- Return the constraint type this pointPatchField implements
virtual const word& constraintType() const
{
return cyclicAMIPointPatch::typeName;
}
// Cyclic AMI coupled interface functions
//- Does the patch field perform the transfromation
virtual bool doTransform() const
{
return
!(
cyclicAMIPatch_.parallel()
|| pTraits<Type>::rank == 0
);
}
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return cyclicAMIPatch_.forwardT();
}
//- Return neighbour-cell transformation tensor
virtual const tensorField& reverseT() const
{
return cyclicAMIPatch_.reverseT();
}
// Evaluation functions
//- Evaluate the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType=Pstream::blocking
)
{}
//- Complete swap of patch point values and add to local values
virtual void swapAddSeparated
(
const Pstream::commsTypes commsType,
Field<Type>&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "cyclicAMIPointPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,9 +23,9 @@ License
\*---------------------------------------------------------------------------*/
#include "timeVaryingUniformFixedValueFvPatchFields.H"
#include "cyclicAMIPointPatchFields.H"
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -34,7 +34,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePatchFields(timeVaryingUniformFixedValue);
makePointPatchFields(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,10 +23,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef timeVaryingUniformFixedValueFvPatchFields_H
#define timeVaryingUniformFixedValueFvPatchFields_H
#ifndef cyclicAMIPointPatchFields_H
#define cyclicAMIPointPatchFields_H
#include "timeVaryingUniformFixedValueFvPatchField.H"
#include "cyclicAMIPointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -36,7 +36,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(timeVaryingUniformFixedValue);
makePointPatchFieldTypedefs(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -169,6 +169,7 @@ $(AMICycPatches)/cyclicAMILduInterfaceField/cyclicAMILduInterface.C
$(AMICycPatches)/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.C
$(AMICycPatches)/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
$(AMICycPatches)/cyclicAMIPointPatch/cyclicAMIPointPatch.C
$(AMICycPatches)/cyclicAMIPointPatchField/cyclicAMIPointPatchFields.C
mappedPatches/mappedPolyPatch/mappedPatchBase.C
mappedPatches/mappedPolyPatch/mappedPolyPatch.C

View File

@ -50,7 +50,7 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::fieldValues::cellSource::operationType,
7
8
>::names[] =
{
"none",
@ -59,7 +59,8 @@ namespace Foam
"volIntegrate",
"weightedAverage",
"min",
"max"
"max",
"CoV"
};
}
@ -67,7 +68,7 @@ namespace Foam
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 2>
Foam::fieldValues::cellSource::sourceTypeNames_;
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 7>
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 8>
Foam::fieldValues::cellSource::operationTypeNames_;

View File

@ -52,6 +52,7 @@ Description
- volAverage
- volIntegrate
- weightedAverage
- CoV (Coefficient of variation: standard deviation/mean)
SourceFiles
cellSource.C
@ -106,11 +107,12 @@ public:
opVolIntegrate,
opWeightedAverage,
opMin,
opMax
opMax,
opCoV
};
//- Operation type names
static const NamedEnum<operationType, 7> operationTypeNames_;
static const NamedEnum<operationType, 8> operationTypeNames_;
private:

View File

@ -115,6 +115,23 @@ Type Foam::fieldValues::cellSource::processValues
result = max(values);
break;
}
case opCoV:
{
Type meanValue = sum(values*V)/sum(V);
const label nComp = pTraits<Type>::nComponents;
for (direction d=0; d<nComp; ++d)
{
scalarField vals(values.component(d));
scalar mean = component(meanValue, d);
scalar& res = setComponent(result, d);
res = sqrt(sum(V*sqr(vals - mean))/(V.size()*sum(V)))/mean;
}
break;
}
default:
{
// Do nothing

View File

@ -53,7 +53,7 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::fieldValues::faceSource::operationType,
7
8
>::names[] =
{
"none",
@ -62,7 +62,8 @@ namespace Foam
"areaIntegrate",
"weightedAverage",
"min",
"max"
"max",
"CoV"
};
}
@ -71,7 +72,7 @@ namespace Foam
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
Foam::fieldValues::faceSource::sourceTypeNames_;
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 7>
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 8>
Foam::fieldValues::faceSource::operationTypeNames_;

View File

@ -62,6 +62,7 @@ Description
- weightedAverage
- min
- max
- CoV (Coefficient of variation: standard deviation/mean)
Notes:
- faces on empty patches get ignored
@ -132,11 +133,12 @@ public:
opAreaIntegrate,
opWeightedAverage,
opMin,
opMax
opMax,
opCoV
};
//- Operation type names
static const NamedEnum<operationType, 7> operationTypeNames_;
static const NamedEnum<operationType, 8> operationTypeNames_;
private:

View File

@ -134,6 +134,25 @@ Type Foam::fieldValues::faceSource::processValues
result = max(values);
break;
}
case opCoV:
{
Type meanValue = sum(values*magSf)/sum(magSf);
const label nComp = pTraits<Type>::nComponents;
for (direction d=0; d<nComp; ++d)
{
scalarField vals(values.component(d));
scalar mean = component(meanValue, d);
scalar& res = setComponent(result, d);
res =
sqrt(sum(magSf*sqr(vals - mean))/(magSf.size()*sum(magSf)))
/mean;
}
break;
}
default:
{
// Do nothing

View File

@ -38,7 +38,7 @@ boundaryField
left
{
type uniformFixedValue;
uniformValue (1 0 0);
uniformValue constant (1 0 0);
}
cylinder

View File

@ -22,7 +22,7 @@ oneD true;
sampleMode nearestPatchFace;
oneDPolyPatchType emptyPolyPatch; //wedgePolyPatch
oneDPolyPatchType empty; //wedge
extrudeModel linearNormal;

View File

@ -43,7 +43,7 @@ boundaryField
inlet
{
type flowRateInletVelocity;
flowRate 0.1;
flowRate constant 0.1;
value uniform (0 0 0);
}
outlet

View File

@ -43,7 +43,7 @@ boundaryField
inlet
{
type flowRateInletVelocity;
flowRate 0.1;
flowRate constant 0.1;
value uniform (0 0 0);
}
outlet

View File

@ -43,7 +43,7 @@ boundaryField
inlet
{
type flowRateInletVelocity;
flowRate 0.1;
flowRate constant 0.1;
value uniform (0 0 0);
}
outlet

View File

@ -28,7 +28,7 @@ boundaryField
inlet
{
type flowRateInletVelocity;
flowRate 0.5; //0.75;
flowRate constant 0.5; //0.75;
value uniform (0 0 0);
}
outlet

View File

@ -43,7 +43,7 @@ boundaryField
inlet
{
type flowRateInletVelocity;
flowRate 0.1;
flowRate constant 0.1;
value uniform (0 0 0);
}
outlet

View File

@ -15,7 +15,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application potentialFreeSurfaceFoam;
application potentialFreeSurfaceFoam;
startFrom startTime;

View File

@ -30,7 +30,7 @@ boundaryField
outlet
{
type uniformFixedValue;
value uniform $pressure;
value constant $pressure;
uniformValue $pressure;
}

View File

@ -25,7 +25,7 @@ cp system/decomposeParDict-4proc system/decomposeParDict
# Unset floating point trapping since creating processor directories
unset FOAM_SIGFPE
unset FOAM_SETNAN
runParallel redistributeMeshPar 4 -overwrite
runParallel redistributePar 4 -overwrite
runParallel renumberMesh 4 -overwrite
# Add wildcard entries for meshes patches since not preserved

View File

@ -32,13 +32,13 @@ boundaryField
inletCentral
{
type flowRateInletVelocity;
flowRate 0.00379;
flowRate constant 0.00379;
value uniform (0 14.68 0);
}
inletSides
{
type flowRateInletVelocity;
flowRate 0.00832;
flowRate constant 0.00832;
value uniform (0 17.79 0);
}
outlet

View File

@ -32,13 +32,13 @@ boundaryField
inletCentral
{
type flowRateInletVelocity;
flowRate 0.00379;
flowRate constant 0.00379;
value uniform (0 14.68 0);
}
inletSides
{
type flowRateInletVelocity;
flowRate 0.00832;
flowRate constant 0.00832;
value uniform (0 17.79 0);
}
outlet

View File

@ -32,13 +32,13 @@ boundaryField
inletCentral
{
type flowRateInletVelocity;
flowRate 0.00379;
flowRate constant 0.00379;
value uniform (0 14.68 0);
}
inletSides
{
type flowRateInletVelocity;
flowRate 0.00832;
flowRate constant 0.00832;
value uniform (0 17.79 0);
}
outlet