Merge branch 'master' of develop.openfoam.com:Development/OpenFOAM-plus

This commit is contained in:
Andrew Heather
2017-02-10 13:57:55 +00:00
71 changed files with 1148 additions and 803 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,7 +42,11 @@ See also
#include "vector.H"
#include "ListOps.H"
#include<list>
#include "labelRange.H"
#include "ListOps.H"
#include "SubList.H"
#include <list>
using namespace Foam;
@ -61,6 +65,19 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
if (false)
{
labelList intlist(IStringStream("(0 1 2)")());
Info<<"construct from Istream: " << intlist << endl;
IStringStream("(3 4 5)")() >> static_cast<labelUList&>(intlist);
Info<<"is >>: " << intlist << endl;
IStringStream("(6 7 8)")() >> intlist;
Info<<"is >>: " << intlist << endl;
}
List<vector> list1(IStringStream("1 ((0 1 2))")());
Info<< "list1: " << list1 << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,6 +58,7 @@ int main(int argc, char *argv[])
}
labelRange range;
labelRanges ranges;
bool removeMode = false;
@ -74,14 +75,16 @@ int main(int argc, char *argv[])
continue;
}
label start = 0;
label size = 0;
{
label start = 0;
label size = 0;
IStringStream(args[argI])() >> start;
++argI;
IStringStream(args[argI])() >> size;
IStringStream(args[argI])() >> start;
++argI;
IStringStream(args[argI])() >> size;
labelRange range(start, size);
range.reset(start, size);
}
Info<< "---------------" << nl;
if (removeMode)
@ -107,10 +110,11 @@ int main(int argc, char *argv[])
ranges.add(range);
}
Info<< "<list>" << ranges << "</list>" << nl;
forAllConstIter(labelRanges, ranges, iter)
Info<< "<list>" << ranges << "</list>" << nl
<< "content:";
for (auto i : ranges)
{
Info<< " " << iter();
Info<< " " << i;
}
Info<< nl;
}

View File

@ -148,8 +148,9 @@ runParallel()
# Store any parsed additional arguments e.g. decomposeParDict
APP_PARARGS=
# Check the default decomposeParDict if available
nProcs=$(getNumberOfProcessors system/decomposeParDict)
# Initialise number of procs to unset value
nProcs=-1
# Parse options and executable
while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
@ -185,6 +186,8 @@ runParallel()
shift
done
[ "$nProcs" -eq -1 ] && nProcs=$(getNumberOfProcessors system/decomposeParDict)
if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ]
then
echo "$APP_NAME already run on $PWD:" \
@ -213,7 +216,7 @@ cloneCase()
else
echo "Cloning $2 case from $1"
mkdir $2
cpfiles="0 system constant"
cpfiles="0.orig 0 system constant"
for f in $cpfiles
do
\cp -r $1/$f $2

View File

@ -64,7 +64,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
}
else if (firstToken.isLabel())
{
label s = firstToken.labelToken();
const label s = firstToken.labelToken();
// Set list length to that read
L.setSize(s);

View File

@ -183,7 +183,7 @@ bool Foam::UList<T>::operator<(const UList<T>& a) const
(
const_iterator vi = begin(), ai = a.begin();
vi < end() && ai < a.end();
vi++, ai++
++vi, ++ai
)
{
if (*vi < *ai)

View File

@ -427,7 +427,7 @@ inline void reverse(UList<T>&);
// \endcode
// \sa forAllReverse
#define forAll(list, i) \
for (Foam::label i=0; i<(list).size(); i++)
for (Foam::label i=0; i<(list).size(); ++i)
//- Reverse loop across all elements in \a list
// \par Usage
@ -439,7 +439,7 @@ inline void reverse(UList<T>&);
// \endcode
// \sa forAll
#define forAllReverse(list, i) \
for (Foam::label i=(list).size()-1; i>=0; i--)
for (Foam::label i=(list).size()-1; i>=0; --i)
//- Iterate across all elements in the \a container object of type
// \a Container.
@ -472,8 +472,8 @@ inline void reverse(UList<T>&);
#define forAllConstIter(Container,container,iter) \
for \
( \
Container::const_iterator iter = (container).begin(); \
iter != (container).end(); \
Container::const_iterator iter = (container).cbegin(); \
iter != (container).cend(); \
++iter \
)

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,7 +33,7 @@ template<class T>
inline Foam::UList<T>::UList()
:
size_(0),
v_(0)
v_(nullptr)
{}
@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const
template<class T>
inline void Foam::reverse(UList<T>& ul, const label n)
{
for (int i=0; i<n/2; i++)
for (int i=0; i<n/2; ++i)
{
Swap(ul[i], ul[n-1-i]);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -165,7 +165,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
)
);
// Check list length
label s = elems.size();
const label s = elems.size();
if (s != L.size())
{
@ -174,14 +174,14 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
<< " expected " << L.size()
<< exit(FatalIOError);
}
for (label i=0; i<s; i++)
for (label i=0; i<s; ++i)
{
L[i] = elems[i];
}
}
else if (firstToken.isLabel())
{
label s = firstToken.labelToken();
const label s = firstToken.labelToken();
// Set list length to that read
if (s != L.size())
@ -203,7 +203,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
{
if (delimiter == token::BEGIN_LIST)
{
for (label i=0; i<s; i++)
for (label i=0; i<s; ++i)
{
is >> L[i];
@ -226,7 +226,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
"reading the single entry"
);
for (label i=0; i<s; i++)
for (label i=0; i<s; ++i)
{
L[i] = element;
}
@ -281,7 +281,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
(
typename SLList<T>::const_iterator iter = sll.begin();
iter != sll.end();
++iter
++iter, ++i
)
{
L[i] = iter();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,27 +43,35 @@ static const unsigned char base64Chars[64] =
//! \endcond
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
std::size_t Foam::base64Layer::encodedLength(std::size_t n)
{
return 4 * ((n / 3) + (n % 3 ? 1 : 0));
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
inline unsigned char Foam::base64Layer::encode0()
inline unsigned char Foam::base64Layer::encode0() const
{
// Top 6 bits of char0
return base64Chars[((group_[0] & 0xFC) >> 2)];
}
inline unsigned char Foam::base64Layer::encode1()
inline unsigned char Foam::base64Layer::encode1() const
{
// Bottom 2 bits of char0, Top 4 bits of char1
return base64Chars[((group_[0] & 0x03) << 4) | ((group_[1] & 0xF0) >> 4)];
}
inline unsigned char Foam::base64Layer::encode2()
inline unsigned char Foam::base64Layer::encode2() const
{
// Bottom 4 bits of char1, Top 2 bits of char2
return base64Chars[((group_[1] & 0x0F) << 2) | ((group_[2] & 0xC0) >> 6)];
}
inline unsigned char Foam::base64Layer::encode3()
inline unsigned char Foam::base64Layer::encode3() const
{
// Bottom 6 bits of char2
return base64Chars[(group_[2] & 0x3F)];

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,7 +30,7 @@ Description
Base64 encoding accoding to RFC 4648 specification
(https://tools.ietf.org/html/rfc4648#page-5).
It is the obligation of the caller to avoid using normal output
while the base-64 encoding layer is actively being used.
while the base-64 encoding layer is actively used.
SourceFiles
base64Layer.C
@ -70,10 +70,10 @@ class base64Layer
// Private Member Functions
inline unsigned char encode0();
inline unsigned char encode1();
inline unsigned char encode2();
inline unsigned char encode3();
inline unsigned char encode0() const;
inline unsigned char encode1() const;
inline unsigned char encode2() const;
inline unsigned char encode3() const;
//- Disallow default bitwise copy construct
base64Layer(const base64Layer&) = delete;
@ -95,7 +95,7 @@ public:
// Constructors
//- Construct and attach to an output stream
base64Layer(std::ostream&);
base64Layer(std::ostream& os);
//- Destructor
@ -104,6 +104,10 @@ public:
// Member Functions
//- The encoded length has 4 bytes out for every 3 bytes in.
static std::size_t encodedLength(std::size_t n);
//- Encode the character sequence, writing when possible.
void write(const char* s, std::streamsize n);
@ -111,7 +115,7 @@ public:
void reset();
//- End the encoding sequence, padding the final characters with '='.
// Return false if no encoding layer was actually used.
// Return false if no encoding was actually performed.
bool close();
};

View File

@ -32,7 +32,7 @@ Description
Note: cannot access the state dictionary until after construction of the
function objects, since the owner container functionObjectList is owned
by time, and time owns the state dictionary. I.e. need to wait for time
to be fully consttucted.
to be fully constructed.
See also
Foam::functionObject

View File

@ -51,7 +51,7 @@ namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class functionObjectFile Declaration
Class writeFile Declaration
\*---------------------------------------------------------------------------*/
class writeFile

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,8 +29,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::labelRange::const_iterator Foam::labelRange::endIter_;
int Foam::labelRange::debug(::Foam::debug::debugSwitch("labelRange", 0));
@ -47,13 +45,24 @@ Foam::labelRange::labelRange(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::labelRange::intersects
(
const labelRange& range,
const bool touches
) const
void Foam::labelRange::adjust()
{
label final = touches ? 1 : 0;
if (start_ < 0)
{
size_ += start_;
start_ = 0;
}
if (size_ < 0)
{
size_ = 0;
}
}
bool Foam::labelRange::overlaps(const labelRange& range, bool touches) const
{
const label final = touches ? 1 : 0;
return
(
@ -97,7 +106,7 @@ Foam::labelRange Foam::labelRange::join(const labelRange& range) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
Foam::labelRange& Foam::labelRange::operator+=(const labelRange& rhs)
void Foam::labelRange::operator+=(const labelRange& rhs)
{
if (!size_)
{
@ -112,8 +121,6 @@ Foam::labelRange& Foam::labelRange::operator+=(const labelRange& rhs)
start_ = lower;
size_ = upper - lower + 1;
}
return *this;
}
@ -127,10 +134,10 @@ Foam::Istream& Foam::operator>>(Istream& is, labelRange& range)
is.check("operator>>(Istream&, labelRange&)");
// disallow invalid sizes
if (range.size_ <= 0)
// Disallow invalid sizes
if (range.size_ < 0)
{
range.clear();
range.size_ = 0;
}
return is;
@ -139,15 +146,11 @@ Foam::Istream& Foam::operator>>(Istream& is, labelRange& range)
Foam::Ostream& Foam::operator<<(Ostream& os, const labelRange& range)
{
// write ASCII only for now
// Write ASCII only for now
os << token::BEGIN_LIST
<< range.start_ << token::SPACE << range.size_
<< token::END_LIST;
// os << token::BEGIN_BLOCK
// << range.start_ << "-" << range.last()
// << token::END_BLOCK;
os.check("operator<<(Ostream&, const labelRange&)");
return os;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ Class
Foam::labelRange
Description
A label range specifier.
A range of labels.
SourceFiles
labelRange.C
@ -47,8 +47,8 @@ class Ostream;
// Forward declaration of friend functions and operators
class labelRange;
Istream& operator>>(Istream&, labelRange&);
Ostream& operator<<(Ostream&, const labelRange&);
Istream& operator>>(Istream& is, labelRange& range);
Ostream& operator<<(Ostream& os, const labelRange& range);
/*---------------------------------------------------------------------------*\
Class labelRange Declaration
@ -63,7 +63,7 @@ class labelRange
public:
static int debug;
static int debug;
// Public classes
@ -75,31 +75,50 @@ public:
bool operator()(const labelRange& a, const labelRange& b)
{
return a.first() < b.first();
return a.operator<(b);
}
};
// Constructors
//- Construct an empty range
//- Construct an empty range with zero as start and size.
inline labelRange();
//- Construct a range
// A negative size is autmatically changed to zero.
inline labelRange(const label start, const label size);
//- Construct a range from start and size.
// Optionally adjust the start to avoid any negative indices.
// Always reduce a negative size to zero.
inline labelRange
(
const label start,
const label size,
const bool adjustStart = false
);
//- Construct from Istream.
labelRange(Istream&);
labelRange(Istream& is);
// Member Functions
//- Reset to zero size
//- Alias for setSize(const label)
inline void resize(const label n);
//- Adjust size
inline void setSize(const label n);
//- Reset to zero start and zero size
inline void clear();
//- Is the range empty?
inline bool empty() const;
//- Adjust the start to avoid any negative indices
void adjust();
//- Is the range valid (non-empty)?
inline bool valid() const;
//- Return the effective size of the range
inline label size() const;
@ -109,32 +128,44 @@ public:
//- The (inclusive) upper value of the range
inline label last() const;
//- Return true if the value is within the range
inline bool contains(const label) const;
//- Reset start and size.
// Optionally adjust the start to avoid any negative indices.
// Always reduce a negative size to zero.
// Return true if the updated range valid (non-empty).
inline bool reset
(
const label start,
const label size,
const bool adjustStart = false
);
//- Return true if the ranges intersect
//- Return true if the value is within the range
inline bool contains(const label value) const;
//- Return true if the ranges overlap.
// Optional test for ranges that also just touch each other
bool intersects(const labelRange&, const bool touches = false) const;
bool overlaps(const labelRange& range, bool touches=false) const;
//- Return a joined range, squashing any gaps in between
// A prior intersects() check can be used to avoid squashing gaps.
labelRange join(const labelRange&) const;
// A prior overlaps() check can be used to avoid squashing gaps.
labelRange join(const labelRange& range) const;
// Member Operators
//- Return element in range, no bounds checking
inline label operator[](const label) const;
inline label operator[](const label i) const;
//- Comparison function for sorting, compares the start
//- Comparison function for sorting, compares the start.
// If the start values are equal, also compares the size.
inline bool operator<(const labelRange& rhs) const;
//- Join ranges, squashing any gaps in between
// A prior intersects() check can be used to avoid squashing gaps.
labelRange& operator+=(const labelRange&);
// A prior overlaps() check can be used to avoid squashing gaps.
void operator+=(const labelRange& rhs);
inline bool operator==(const labelRange&) const;
inline bool operator!=(const labelRange&) const;
inline bool operator==(const labelRange& rhs) const;
inline bool operator!=(const labelRange& rhs) const;
// STL iterator
@ -142,6 +173,8 @@ public:
//- An STL const_iterator
class const_iterator
{
friend class labelRange;
// Private data
//- Reference to the range for which this is an iterator
@ -150,54 +183,48 @@ public:
//- Current index
label index_;
public:
// Constructors
//- Construct null - equivalent to an 'end' position
inline const_iterator();
//- Construct from range, moving to its 'begin' position
inline explicit const_iterator(const labelRange&);
//- Construct from range at 'begin' or 'end' position
inline const_iterator
(
const labelRange& range,
const bool endIter = false
);
public:
// Member operators
inline bool operator==(const const_iterator&) const;
inline bool operator==(const const_iterator& iter) const;
inline bool operator!=(const const_iterator& iter) const;
inline bool operator!=(const const_iterator&) const;
inline label operator*();
inline label operator()();
inline label operator*() const;
inline label operator()() const;
inline const_iterator& operator++();
inline const_iterator operator++(int);
};
//- const_iterator set to the beginning of the range
//- A const_iterator set to the beginning of the range
inline const_iterator cbegin() const;
//- const_iterator set to beyond the end of the range
inline const const_iterator& cend() const;
//- A const_iterator set to beyond the end of the range
inline const const_iterator cend() const;
//- const_iterator set to the beginning of the range
//- A const_iterator set to the beginning of the range
inline const_iterator begin() const;
//- const_iterator set to beyond the end of the range
inline const const_iterator& end() const;
//- A const_iterator set to beyond the end of the range
inline const const_iterator end() const;
// IOstream Operators
friend Istream& operator>>(Istream&, labelRange&);
friend Ostream& operator<<(Ostream&, const labelRange&);
private:
//- const_iterator returned by end(), cend()
static const const_iterator endIter_;
friend Istream& operator>>(Istream& is, labelRange& range);
friend Ostream& operator<<(Ostream& os, const labelRange& range);
};

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,32 +33,39 @@ inline Foam::labelRange::labelRange()
{}
inline Foam::labelRange::labelRange(const label start, const label size)
inline Foam::labelRange::labelRange
(
const label start,
const label size,
const bool adjustStart
)
:
start_(start),
size_(size)
{
// disallow invalid sizes
if (size_ <= 0)
if (adjustStart)
{
this->clear();
// Disallow invalid indices and sizes
adjust();
}
else if (size_ < 0)
{
// Disallow invalid sizes
size_ = 0;
}
}
// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
inline Foam::labelRange::const_iterator::const_iterator()
:
range_(*reinterpret_cast<Foam::labelRange* >(0)),
index_(-1)
{}
inline Foam::labelRange::const_iterator::const_iterator(const labelRange& range)
inline Foam::labelRange::const_iterator::const_iterator
(
const labelRange& range,
const bool endIter
)
:
range_(range),
index_(range_.empty() ? -1 : 0)
index_(endIter ? range_.size() : 0)
{}
@ -76,17 +83,17 @@ inline bool Foam::labelRange::const_iterator::operator!=
const const_iterator& iter
) const
{
return !(this->operator==(iter));
return (this->index_ != iter.index_);
}
inline Foam::label Foam::labelRange::const_iterator::operator*()
inline Foam::label Foam::labelRange::const_iterator::operator*() const
{
return range_[index_];
}
inline Foam::label Foam::labelRange::const_iterator::operator()()
inline Foam::label Foam::labelRange::const_iterator::operator()() const
{
return range_[index_];
}
@ -95,12 +102,7 @@ inline Foam::label Foam::labelRange::const_iterator::operator()()
inline Foam::labelRange::const_iterator&
Foam::labelRange::const_iterator::operator++()
{
if (++index_ >= range_.size())
{
// equivalent to end iterator
index_ = -1;
}
++index_;
return *this;
}
@ -109,7 +111,7 @@ inline Foam::labelRange::const_iterator
Foam::labelRange::const_iterator::operator++(int)
{
const_iterator old = *this;
this->operator++();
++index_;
return old;
}
@ -120,9 +122,9 @@ inline Foam::labelRange::const_iterator Foam::labelRange::cbegin() const
}
inline const Foam::labelRange::const_iterator& Foam::labelRange::cend() const
inline const Foam::labelRange::const_iterator Foam::labelRange::cend() const
{
return endIter_;
return const_iterator(*this, true);
}
@ -132,14 +134,31 @@ inline Foam::labelRange::const_iterator Foam::labelRange::begin() const
}
inline const Foam::labelRange::const_iterator& Foam::labelRange::end() const
inline const Foam::labelRange::const_iterator Foam::labelRange::end() const
{
return endIter_;
return const_iterator(*this, true);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline void Foam::labelRange::resize(const label n)
{
setSize(n);
}
inline void Foam::labelRange::setSize(const label n)
{
size_ = n;
if (size_ < 0)
{
size_ = 0;
}
}
inline void Foam::labelRange::clear()
{
start_ = size_ = 0;
@ -152,6 +171,12 @@ inline bool Foam::labelRange::empty() const
}
inline bool Foam::labelRange::valid() const
{
return size_;
}
inline Foam::label Foam::labelRange::size() const
{
return size_;
@ -170,6 +195,31 @@ inline Foam::label Foam::labelRange::last() const
}
inline bool Foam::labelRange::reset
(
const label start,
const label size,
const bool adjustStart
)
{
start_ = start;
size_ = size;
if (adjustStart)
{
// Disallow invalid indices and sizes
adjust();
}
else if (size_ < 0)
{
// Disallow invalid sizes
size_ = 0;
}
return size_;
}
inline bool Foam::labelRange::contains(const label value) const
{
return value >= this->first() && value <= this->last();
@ -186,7 +236,11 @@ inline Foam::label Foam::labelRange::operator[](const label i) const
inline bool Foam::labelRange::operator<(const labelRange& rhs) const
{
return this->first() < rhs.first();
return
(
this->first() < rhs.first()
|| (this->first() == rhs.first() && this->size() < rhs.size())
);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,11 +26,6 @@ License
#include "labelRanges.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::labelRanges::const_iterator Foam::labelRanges::endIter_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::labelRanges::insertBefore
@ -141,7 +136,7 @@ bool Foam::labelRanges::add(const labelRange& range)
{
labelRange& currRange = ParentType::operator[](elemI);
if (currRange.intersects(range, true))
if (currRange.overlaps(range, true))
{
// absorb into the existing (adjacent/overlapping) range
currRange += range;
@ -150,7 +145,7 @@ bool Foam::labelRanges::add(const labelRange& range)
for (; elemI < this->size()-1; ++elemI)
{
labelRange& nextRange = ParentType::operator[](elemI+1);
if (currRange.intersects(nextRange, true))
if (currRange.overlaps(nextRange, true))
{
currRange += nextRange;
nextRange.clear();

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,8 +49,8 @@ class Ostream;
// Forward declaration of friend functions and operators
class labelRanges;
Istream& operator>>(Istream&, labelRanges&);
Ostream& operator<<(Ostream&, const labelRanges&);
Istream& operator>>(Istream& is, labelRanges& ranges);
Ostream& operator<<(Ostream& is, const labelRanges& ranges);
/*---------------------------------------------------------------------------*\
Class labelRanges Declaration
@ -68,13 +68,13 @@ class labelRanges
// Private Member Functions
//- Insert range before specified insertion index, by copying up
void insertBefore(const label, const labelRange&);
void insertBefore(const label insert, const labelRange& range);
//- Purge empty ranges, by copying down
void purgeEmpty();
//- Print the range for debugging purposes
Ostream& printRange(Ostream&, const labelRange&) const;
Ostream& printRange(Ostream& os, const labelRange& range) const;
public:
@ -85,10 +85,10 @@ public:
inline labelRanges();
//- Construct given size
inline explicit labelRanges(const label);
inline explicit labelRanges(const label nElem);
//- Construct from Istream.
labelRanges(Istream&);
labelRanges(Istream& is);
// Member Functions
@ -100,19 +100,22 @@ public:
using DynamicList<labelRange>::empty;
//- Return true if the value is within any of the ranges
inline bool contains(const label) const;
inline bool contains(const label value) const;
//- Add the range to the list
bool add(const labelRange&);
bool add(const labelRange& range);
//- Remove the range from the list
bool remove(const labelRange&);
bool remove(const labelRange& range);
// STL iterator
//- An STL const_iterator
class const_iterator
{
friend class labelRanges;
// Private data
//- Reference to the list for which this is an iterator
@ -124,22 +127,21 @@ public:
//- Index of current element at listIndex
label subIndex_;
public:
// Constructors
//- Construct null - equivalent to an 'end' position
inline const_iterator();
//- Construct from list, moving to its 'begin' position
inline explicit const_iterator(const labelRanges&);
//- Construct from ranges at 'begin' or 'end' position
inline const_iterator
(
const labelRanges& lst,
const bool endIter = false
);
public:
// Member operators
inline bool operator==(const const_iterator&) const;
inline bool operator!=(const const_iterator&) const;
inline bool operator==(const const_iterator& iter) const;
inline bool operator!=(const const_iterator& iter) const;
inline label operator*();
inline label operator()();
@ -149,29 +151,23 @@ public:
};
//- const_iterator set to the beginning of the list
//- A const_iterator set to the beginning of the list
inline const_iterator cbegin() const;
//- const_iterator set to beyond the end of the list
inline const const_iterator& cend() const;
//- A const_iterator set to beyond the end of the list
inline const const_iterator cend() const;
//- const_iterator set to the beginning of the list
//- A const_iterator set to the beginning of the list
inline const_iterator begin() const;
//- const_iterator set to beyond the end of the list
inline const const_iterator& end() const;
//- A const_iterator set to beyond the end of the list
inline const const_iterator end() const;
// IOstream Operators
friend Istream& operator>>(Istream&, labelRanges&);
friend Ostream& operator<<(Ostream&, const labelRanges&);
private:
//- const_iterator returned by end(), cend()
static const const_iterator endIter_;
friend Istream& operator>>(Istream& is, labelRanges& ranges);
friend Ostream& operator<<(Ostream& os, const labelRanges& ranges);
};

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,28 +40,18 @@ inline Foam::labelRanges::labelRanges(const label nElem)
// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
inline Foam::labelRanges::const_iterator::const_iterator()
inline Foam::labelRanges::const_iterator::const_iterator
(
const labelRanges& lst,
const bool endIter
)
:
list_(*reinterpret_cast<Foam::labelRanges* >(0)),
index_(-1),
subIndex_(-1)
list_(lst),
index_(endIter ? lst.size() : 0),
subIndex_(0)
{}
inline Foam::labelRanges::const_iterator::const_iterator(const labelRanges& lst)
:
list_(lst),
index_(0),
subIndex_(0)
{
if (list_.empty())
{
// equivalent to end iterator
index_ = subIndex_ = -1;
}
}
inline bool Foam::labelRanges::const_iterator::operator==
(
const const_iterator& iter
@ -69,7 +59,7 @@ inline bool Foam::labelRanges::const_iterator::operator==
{
return
(
this->index_ == iter.index_
this->index_ == iter.index_
&& this->subIndex_ == iter.subIndex_
);
}
@ -101,13 +91,9 @@ Foam::labelRanges::const_iterator::operator++()
{
if (++subIndex_ >= list_[index_].size())
{
// go to next list entry
// Next sub-list
++index_;
subIndex_ = 0;
if (++index_ >= list_.size())
{
// equivalent to end iterator
index_ = subIndex_ = -1;
}
}
return *this;
@ -129,9 +115,9 @@ inline Foam::labelRanges::const_iterator Foam::labelRanges::cbegin() const
}
inline const Foam::labelRanges::const_iterator& Foam::labelRanges::cend() const
inline const Foam::labelRanges::const_iterator Foam::labelRanges::cend() const
{
return endIter_;
return const_iterator(*this, true);
}
@ -141,9 +127,9 @@ inline Foam::labelRanges::const_iterator Foam::labelRanges::begin() const
}
inline const Foam::labelRanges::const_iterator& Foam::labelRanges::end() const
inline const Foam::labelRanges::const_iterator Foam::labelRanges::end() const
{
return endIter_;
return const_iterator(*this, true);
}

View File

@ -326,7 +326,7 @@ void Foam::foamVtkCells::correct()
nAddVerts += 5;
vertOffset_[celLoc] = nAddVerts;
decompose_.superCells_[nAddCells++] = celLoc;
decompose_.superCells_[nAddCells++] = cellI;
}
cellTypes_[celLoc] = foamVtkCore::VTK_PYRAMID;
@ -373,7 +373,7 @@ void Foam::foamVtkCells::correct()
nAddVerts += 4;
vertOffset_[celLoc] = nAddVerts;
decompose_.superCells_[nAddCells++] = celLoc;
decompose_.superCells_[nAddCells++] = cellI;
}
cellTypes_[celLoc] = foamVtkCore::VTK_TETRA;

View File

@ -19,6 +19,7 @@ vtk/format/foamVtkAppendBase64Formatter.C
vtk/format/foamVtkAppendRawFormatter.C
vtk/format/foamVtkAsciiFormatter.C
vtk/format/foamVtkBase64Formatter.C
vtk/format/foamVtkBase64Layer.C
vtk/format/foamVtkLegacyFormatter.C
vtk/format/foamVtkFormatter.C
vtk/format/foamVtkOutputOptions.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,8 +27,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
const char* Foam::foamVtkAppendBase64Formatter::encoding_ = "base64";
const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -38,14 +37,16 @@ Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
std::ostream& os
)
:
foamVtkBase64Formatter(os)
foamVtkBase64Layer(os)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
{}
{
base64Layer::close();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
@ -56,10 +57,4 @@ const char* Foam::foamVtkAppendBase64Formatter::name() const
}
const char* Foam::foamVtkAppendBase64Formatter::encoding() const
{
return encoding_;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,7 @@ SourceFiles
#ifndef foamVtkAppendBase64Formatter_H
#define foamVtkAppendBase64Formatter_H
#include "foamVtkBase64Formatter.H"
#include "foamVtkBase64Layer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,12 +49,11 @@ namespace Foam
class foamVtkAppendBase64Formatter
:
public foamVtkBase64Formatter
public foamVtkBase64Layer
{
// Private Data Members
static const char* name_;
static const char* encoding_;
// Private Member Functions
@ -71,7 +70,7 @@ public:
// Constructors
//- Construct and attach to an output stream
foamVtkAppendBase64Formatter(std::ostream&);
foamVtkAppendBase64Formatter(std::ostream& os);
//- Destructor
@ -83,9 +82,6 @@ public:
//- Output name for XML type ("append")
virtual const char* name() const;
//- Name for the XML append encoding ("base64").
virtual const char* encoding() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -71,9 +71,9 @@ const char* Foam::foamVtkAppendRawFormatter::encoding() const
}
void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t val)
void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t nBytes)
{
write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
}
@ -85,28 +85,28 @@ void Foam::foamVtkAppendRawFormatter::write(const uint8_t val)
void Foam::foamVtkAppendRawFormatter::write(const label val)
{
// std::cerr<<"label is:" << sizeof(val) << '\n';
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(label));
}
void Foam::foamVtkAppendRawFormatter::write(const float val)
{
// std::cerr<<"float is:" << sizeof(val) << '\n';
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(float));
}
void Foam::foamVtkAppendRawFormatter::write(const double val)
{
// std::cerr<<"write double as float:" << val << '\n';
// std::cerr<<"double as float=" << val << '\n';
float copy(val);
write(copy);
}
void Foam::foamVtkAppendRawFormatter::flush()
{}
{/*nop*/}
// ************************************************************************* //

View File

@ -77,7 +77,7 @@ public:
// Constructors
//- Construct and attach to an output stream
foamVtkAppendRawFormatter(std::ostream&);
foamVtkAppendRawFormatter(std::ostream& os);
//- Destructor
@ -94,12 +94,14 @@ public:
//- Write leading size for binary output
virtual void writeSize(const uint64_t);
virtual void writeSize(const uint64_t nBytes);
virtual void write(const uint8_t);
virtual void write(const label);
virtual void write(const float);
virtual void write(const double);
virtual void write(const uint8_t val);
virtual void write(const label val);
virtual void write(const float val);
virtual void write(const double val);
//- A no-op for this format
virtual void flush();
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,6 +47,16 @@ inline void Foam::foamVtkAsciiFormatter::next()
}
inline void Foam::foamVtkAsciiFormatter::done()
{
if (pos_)
{
os()<< '\n';
}
pos_ = 0;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter(std::ostream& os)
@ -73,7 +83,7 @@ Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
{
flush();
done();
}
@ -91,7 +101,7 @@ const char* Foam::foamVtkAsciiFormatter::encoding() const
}
void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t)
void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t ignored)
{/*nop*/}
@ -125,11 +135,14 @@ void Foam::foamVtkAsciiFormatter::write(const double val)
void Foam::foamVtkAsciiFormatter::flush()
{
if (pos_)
{
os()<< '\n';
}
pos_ = 0;
done();
}
std::size_t
Foam::foamVtkAsciiFormatter::encodedLength(std::size_t ignored) const
{
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -62,9 +62,12 @@ class foamVtkAsciiFormatter
// Private Member Functions
//- Advance to next position, adding space or newline as required
//- Advance to next position, adding space or newline as needed
inline void next();
//- Finish an output line, adding newline as needed
inline void done();
//- Disallow default bitwise copy construct
foamVtkAsciiFormatter(const foamVtkAsciiFormatter&) = delete;
@ -78,10 +81,10 @@ public:
// Constructors
//- Construct and attach to an output stream, use default precision
foamVtkAsciiFormatter(std::ostream&);
foamVtkAsciiFormatter(std::ostream& os);
//- Construct and attach to an output stream, use specified precision
foamVtkAsciiFormatter(std::ostream&, unsigned precision);
foamVtkAsciiFormatter(std::ostream& os, unsigned precision);
//- Destructor
@ -95,18 +98,24 @@ public:
virtual const char* name() const;
//- Name for the XML append encoding - unused.
// Currently simply "ASCII", but this should not be relied upon.
// Currently identical to name(), but do not rely on this.
virtual const char* encoding() const;
//- Write leading size - this is a no-op for ascii output
virtual void writeSize(const uint64_t);
virtual void writeSize(const uint64_t ignored);
virtual void write(const uint8_t);
virtual void write(const label);
virtual void write(const float);
virtual void write(const double);
virtual void write(const uint8_t val);
virtual void write(const label val);
virtual void write(const float val);
virtual void write(const double val);
//- Write a newline if needed to finish a line of output.
virtual void flush();
//- The encoded length for ascii output is not applicable.
virtual std::size_t encodedLength(std::size_t ignored) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,28 +27,14 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkBase64Formatter::name_ = "binary";
const char* Foam::foamVtkBase64Formatter::encoding_ = "base64";
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::foamVtkBase64Formatter::write
(
const char* s,
std::streamsize n
)
{
base64Layer::write(s, n);
}
const char* Foam::foamVtkBase64Formatter::name_ = "binary";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
:
foamVtkFormatter(os),
base64Layer(os)
foamVtkBase64Layer(os)
{}
@ -56,7 +42,10 @@ Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
{
flush();
if (base64Layer::close())
{
os().put('\n');
}
}
@ -68,46 +57,6 @@ const char* Foam::foamVtkBase64Formatter::name() const
}
const char* Foam::foamVtkBase64Formatter::encoding() const
{
return encoding_;
}
void Foam::foamVtkBase64Formatter::writeSize(const uint64_t val)
{
write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
}
void Foam::foamVtkBase64Formatter::write(const uint8_t val)
{
base64Layer::add(val);
}
void Foam::foamVtkBase64Formatter::write(const label val)
{
// std::cerr<<"label is:" << sizeof(val) << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(label));
}
void Foam::foamVtkBase64Formatter::write(const float val)
{
// std::cerr<<"float is:" << sizeof(val) << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(float));
}
void Foam::foamVtkBase64Formatter::write(const double val)
{
// std::cerr<<"write double as float:" << val << '\n';
float copy(val);
write(copy);
}
void Foam::foamVtkBase64Formatter::flush()
{
if (base64Layer::close())

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,8 +33,7 @@ Description
#ifndef foamVtkBase64Formatter_H
#define foamVtkBase64Formatter_H
#include "foamVtkFormatter.H"
#include "base64Layer.H"
#include "foamVtkBase64Layer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,8 +46,7 @@ namespace Foam
class foamVtkBase64Formatter
:
public foamVtkFormatter,
private base64Layer
public foamVtkBase64Layer
{
// Private Data Members
@ -64,20 +62,12 @@ class foamVtkBase64Formatter
//- Disallow default bitwise assignment
void operator=(const foamVtkBase64Formatter&) = delete;
protected:
// Protected Member Functions
//- Write
void write(const char* s, std::streamsize n);
public:
// Constructors
//- Construct and attach to an output stream
foamVtkBase64Formatter(std::ostream&);
foamVtkBase64Formatter(std::ostream& os);
//- Destructor
@ -90,17 +80,9 @@ public:
// The lowercase version of the Legacy output type.
virtual const char* name() const;
//- Name for the XML append encoding.
virtual const char* encoding() const;
//- Write leading size for binary output
virtual void writeSize(const uint64_t);
virtual void write(const uint8_t);
virtual void write(const label);
virtual void write(const float);
virtual void write(const double);
//- End the encoding sequence (padding the final characters with '=')
// and write a newline to the output if any encoding was done.
virtual void flush();
};

View File

@ -0,0 +1,116 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 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 "foamVtkBase64Layer.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkBase64Layer::encoding_ = "base64";
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::foamVtkBase64Layer::write
(
const char* s,
std::streamsize n
)
{
base64Layer::write(s, n);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
:
foamVtkFormatter(os),
base64Layer(os)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkBase64Layer::~foamVtkBase64Layer()
{
base64Layer::close();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const char* Foam::foamVtkBase64Layer::encoding() const
{
return encoding_;
}
void Foam::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
{
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
}
void Foam::foamVtkBase64Layer::write(const uint8_t val)
{
base64Layer::add(val);
}
void Foam::foamVtkBase64Layer::write(const label val)
{
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(label));
}
void Foam::foamVtkBase64Layer::write(const float val)
{
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(float));
}
void Foam::foamVtkBase64Layer::write(const double val)
{
// std::cerr<<"double as float=" << val << '\n';
float copy(val);
write(copy);
}
void Foam::foamVtkBase64Layer::flush()
{
base64Layer::close();
}
std::size_t Foam::foamVtkBase64Layer::encodedLength(std::size_t n) const
{
return base64Layer::encodedLength(n);
}
// ************************************************************************* //

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 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
foamVtkBase64Layer
Description
Base-64 encoded output.
\*---------------------------------------------------------------------------*/
#ifndef foamVtkBase64Layer_H
#define foamVtkBase64Layer_H
#include "foamVtkFormatter.H"
#include "base64Layer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class foamVtkBase64Layer Declaration
\*---------------------------------------------------------------------------*/
class foamVtkBase64Layer
:
public foamVtkFormatter,
protected base64Layer
{
// Private Data Members
static const char* encoding_;
// Private Member Functions
//- Disallow default bitwise copy construct
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
//- Disallow default bitwise assignment
void operator=(const foamVtkBase64Layer&) = delete;
protected:
// Protected Member Functions
//- Write
void write(const char* s, std::streamsize n);
// Constructors
//- Construct and attach to an output stream
foamVtkBase64Layer(std::ostream& os);
public:
//- Destructor
virtual ~foamVtkBase64Layer();
// Member Functions
//- Name for the XML append encoding ("base64").
virtual const char* encoding() const;
//- Write leading size for binary output
virtual void writeSize(const uint64_t nBytes);
virtual void write(const uint8_t val);
virtual void write(const label val);
virtual void write(const float val);
virtual void write(const double val);
//- End the encoding sequence (padding the final characters with '=')
virtual void flush();
//- The encoded length for base64 encoded output.
virtual std::size_t encodedLength(std::size_t n) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -52,6 +52,12 @@ Foam::foamVtkFormatter::~foamVtkFormatter()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
std::size_t Foam::foamVtkFormatter::encodedLength(std::size_t n) const
{
return n;
}
void Foam::foamVtkFormatter::indent()
{
label n = xmlTags_.size() * 2;
@ -149,7 +155,6 @@ Foam::foamVtkFormatter::tag(const word& tag)
}
Foam::foamVtkFormatter&
Foam::foamVtkFormatter::endTag(const word& tag)
{
@ -181,7 +186,6 @@ Foam::foamVtkFormatter::endTag(const word& tag)
}
Foam::foamVtkFormatter&
Foam::foamVtkFormatter::xmlAttr
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,8 +74,8 @@ class foamVtkFormatter
template<class Type>
foamVtkFormatter& xmlAttribute
(
const word&,
const Type&,
const word& k,
const Type& v,
const char quote
);
@ -120,14 +120,20 @@ public:
//- Write leading size for binary output
virtual void writeSize(const uint64_t) = 0;
virtual void writeSize(const uint64_t nBytes) = 0;
virtual void write(const uint8_t) = 0;
virtual void write(const label) = 0;
virtual void write(const float) = 0;
virtual void write(const double) = 0;
virtual void write(const uint8_t val) = 0;
virtual void write(const label val) = 0;
virtual void write(const float val) = 0;
virtual void write(const double val) = 0;
//- Flush encoding, write newline etc.
virtual void flush() = 0;
//- The encoded length for binary output.
// The default is pass-through.
virtual std::size_t encodedLength(std::size_t n) const;
// Member Functions
@ -138,7 +144,7 @@ public:
foamVtkFormatter& xmlHeader();
//- Write XML comment (at the current indentation level)
foamVtkFormatter& comment(const std::string&);
foamVtkFormatter& comment(const std::string& text);
//- Open XML tag
@ -177,40 +183,40 @@ public:
//- Write XML attribute
foamVtkFormatter& xmlAttr
(
const word&,
const std::string&,
const word& k,
const std::string& v,
const char quote = '\''
);
//- Write XML attribute
foamVtkFormatter& xmlAttr
(
const word&,
const int32_t,
const word& k,
const int32_t v,
const char quote = '\''
);
//- Write XML attribute
foamVtkFormatter& xmlAttr
(
const word&,
const int64_t,
const word& k,
const int64_t v,
const char quote = '\''
);
//- Write XML attribute
foamVtkFormatter& xmlAttr
(
const word&,
const uint64_t,
const word& k,
const uint64_t v,
const char quote = '\''
);
//- Write XML attribute
foamVtkFormatter& xmlAttr
(
const word&,
const scalar,
const word& k,
const scalar v,
const char quote = '\''
);
@ -219,19 +225,19 @@ public:
// Member Operators
//- Write XML attribute
foamVtkFormatter& operator()(const word&, const std::string&);
foamVtkFormatter& operator()(const word& k, const std::string& v);
//- Write XML attribute
foamVtkFormatter& operator()(const word&, const int32_t);
foamVtkFormatter& operator()(const word& k, const int32_t v);
//- Write XML attribute
foamVtkFormatter& operator()(const word&, const int64_t);
foamVtkFormatter& operator()(const word& k, const int64_t v);
//- Write XML attribute
foamVtkFormatter& operator()(const word&, const uint64_t);
foamVtkFormatter& operator()(const word& k, const uint64_t v);
//- Write XML attribute
foamVtkFormatter& operator()(const word&, const scalar);
foamVtkFormatter& operator()(const word& k, const scalar v);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -71,8 +71,8 @@ const char* Foam::foamVtkLegacyFormatter::encoding() const
}
void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t)
{}
void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t ignored)
{/*nop*/}
void Foam::foamVtkLegacyFormatter::write(const uint8_t val)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,11 +25,10 @@ Class
foamVtkLegacyFormatter
Description
Binary output for the VTK legacy format, always written as big-endian.
Binary output for the VTK legacy format, always written as big-endian
and with 32-bit integers.
The legacy files are always written as big endian.
Since integers in the legacy format are limited to 32-bit,
this format should not be used for OpenFOAM with 64-bit label sizes.
This format should never be used for OpenFOAM with 64-bit label sizes.
SourceFiles
foamVtkLegacyFormatter.C
@ -81,7 +80,7 @@ public:
// Constructors
//- Construct and attach to an output stream
foamVtkLegacyFormatter(std::ostream&);
foamVtkLegacyFormatter(std::ostream& os);
//- Destructor
@ -90,22 +89,25 @@ public:
// Member Functions
//- Name for the Legacy output type ("BINARY")
//- Name for the legacy binary output type ("BINARY")
virtual const char* name() const;
//- Name for the XML append encoding (unused)
// Currently simply "BINARY", but this should not be relied upon.
// Currently identical to name(), but do not rely on this.
virtual const char* encoding() const;
//- Write leading size - a no-op for legacy binary output
virtual void writeSize(const uint64_t);
virtual void writeSize(const uint64_t ignored);
virtual void write(const uint8_t);
virtual void write(const label);
virtual void write(const float);
virtual void write(const double);
virtual void write(const uint8_t val);
virtual void write(const label val);
virtual void write(const float val);
virtual void write(const double val);
//- Write a newline to the output
virtual void flush();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -45,10 +45,8 @@ Foam::foamVtkOutputOptions::foamVtkOutputOptions()
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::foamVtkFormatter> Foam::foamVtkOutputOptions::newFormatter
(
std::ostream& os
) const
Foam::autoPtr<Foam::foamVtkFormatter>
Foam::foamVtkOutputOptions::newFormatter(std::ostream& os) const
{
switch (type_)
{
@ -87,9 +85,9 @@ Foam::autoPtr<Foam::foamVtkFormatter> Foam::foamVtkOutputOptions::newFormatter
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::foamVtkOutputOptions::ascii(bool b)
void Foam::foamVtkOutputOptions::ascii(bool on)
{
if (b)
if (on)
{
// Force ASCII:
@ -132,9 +130,9 @@ void Foam::foamVtkOutputOptions::ascii(bool b)
}
void Foam::foamVtkOutputOptions::append(bool b)
void Foam::foamVtkOutputOptions::append(bool on)
{
if (b)
if (on)
{
if (!(type_ & APPEND))
{
@ -153,9 +151,9 @@ void Foam::foamVtkOutputOptions::append(bool b)
}
void Foam::foamVtkOutputOptions::legacy(bool b)
void Foam::foamVtkOutputOptions::legacy(bool on)
{
if (b)
if (on)
{
if (type_ & APPEND)
{
@ -180,9 +178,9 @@ void Foam::foamVtkOutputOptions::legacy(bool b)
}
void Foam::foamVtkOutputOptions::precision(unsigned val) const
void Foam::foamVtkOutputOptions::precision(unsigned prec) const
{
precision_ = val;
precision_ = prec;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -88,7 +88,7 @@ public:
// Selectors
//- Return new data formatter based on the writer options
autoPtr<foamVtkFormatter> newFormatter(std::ostream&) const;
autoPtr<foamVtkFormatter> newFormatter(std::ostream& os) const;
// Member Functions
@ -117,16 +117,16 @@ public:
// In append mode, this switches between base64 and raw binary.
// In XML mode, this switches between ASCII and base64.
// In legacy mode, this switches between ASCII and binary.
void ascii(bool);
void ascii(bool on);
//- Toggle append mode on/off.
void append(bool);
void append(bool on);
//- Toggle legacy mode on/off.
void legacy(bool);
void legacy(bool on);
//- Set the write precision to be used for new ASCII formatters
void precision(unsigned val) const;
void precision(unsigned prec) const;
// Other

View File

@ -59,11 +59,11 @@ Foam::foamVtkPTraits<double>::typeName = "Float64";
#ifdef WM_LITTLE_ENDIAN
template<>
const char* const
Foam::foamVtkPTraits<::Foam::endian>::typeName = "LittleEndian";
Foam::foamVtkPTraits<Foam::endian>::typeName = "LittleEndian";
#else
template<>
const char* const
Foam::foamVtkPTraits<::Foam::endian>::typeName = "BigEndian";
Foam::foamVtkPTraits<Foam::endian>::typeName = "BigEndian";
#endif

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,28 +58,28 @@ public:
template<>
const char* const foamVtkPTraits<uint8_t>::typeName; // = UInt8
const char* const foamVtkPTraits<uint8_t>::typeName; // UInt8
template<>
const char* const foamVtkPTraits<int32_t>::typeName; // = Int32
const char* const foamVtkPTraits<int32_t>::typeName; // Int32
template<>
const char* const foamVtkPTraits<int32_t>::typeName; // = UInt32
const char* const foamVtkPTraits<uint32_t>::typeName; // UInt32
template<>
const char* const foamVtkPTraits<int32_t>::typeName; // = Int64
const char* const foamVtkPTraits<int64_t>::typeName; // Int64
template<>
const char* const foamVtkPTraits<int64_t>::typeName; // = UInt64
const char* const foamVtkPTraits<uint64_t>::typeName; // UInt64
template<>
const char* const foamVtkPTraits<float>::typeName; // = Float32
const char* const foamVtkPTraits<float>::typeName; // Float32
template<>
const char* const foamVtkPTraits<double>::typeName; // = Float64
const char* const foamVtkPTraits<double>::typeName; // Float64
template<>
const char* const foamVtkPTraits<::Foam::endian>::typeName;
const char* const foamVtkPTraits<Foam::endian>::typeName; // (Big|Little)Endian
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -34,7 +34,7 @@ Description
Usage
\table
Property | Description | Required | Default value
valueFraction | fraction od value used for boundary [0-1] | yes |
valueFraction | fraction of value used for boundary [0-1] | yes |
\endtable
Example of the boundary condition specification:

View File

@ -34,7 +34,7 @@ Foam::slipFvPatchField<Type>::slipFvPatchField
const DimensionedField<Type, volMesh>& iF
)
:
basicSymmetryFvPatchField<Type>(p, iF)
basicSymmetryFvPatchField<Type>(p, iF)
{}

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::runTimePostProcessing
Foam::functionObjects::runTimePostPro::runTimePostProcessing
Group
grpGraphicsFunctionObjects

View File

@ -201,7 +201,7 @@ Foam::functionObjects::scalarTransport::scalarTransport
resetOnStartUp_(false),
schemesField_("unknown-schemesField"),
fvOptions_(mesh_),
bounded01_(dict.lookupOrDefault<bool>("bounded01", true))
bounded01_(dict.lookupOrDefault<Switch>("bounded01", true))
{
read(dict);
@ -235,12 +235,7 @@ bool Foam::functionObjects::scalarTransport::read(const dictionary& dict)
dict.readIfPresent("bounded01", bounded01_);
schemesField_ = dict.lookupOrDefault("schemesField", fieldName_);
constantD_ = false;
if (dict.readIfPresent("D", D_))
{
constantD_ = true;
}
constantD_ = dict.readIfPresent("D", D_);
dict.readIfPresent("nCorr", nCorr_);
dict.readIfPresent("resetOnStartUp", resetOnStartUp_);
@ -256,10 +251,10 @@ bool Foam::functionObjects::scalarTransport::read(const dictionary& dict)
bool Foam::functionObjects::scalarTransport::execute()
{
Log << type() << " write:" << endl;
volScalarField& s = transportedField();
Log << type() << " execute: " << s.name() << endl;
const surfaceScalarField& phi =
mesh_.lookupObject<surfaceScalarField>(phiName_);

View File

@ -111,17 +111,18 @@ Usage
\table
Property | Description | Required | Default value
type | Type name: scalarTransport | yes |
phi | Name of flux field | yes |
field | Name of the scalar field | no | s
phi | Name of flux field | no | phi
rho | Name of density field | no | rho
phase | Name of the phase name | no | none
phase | Name of the phase | no | none
nut | Name of the turbulence viscosity | no | none
D | Diffusion coefficient | no | auto generated
nCorr | Number of correctors | no | 0
resetOnStartUp | Reset scalar to zero on start-up | no | no
schemesField | Name of field to specify schemes | no | fieldName
schemesField | Name of field to specify schemes | no | field name
fvOptions | List of scalar sources | no |
bounded01 | Bounds scalar between 0-1 for multiphase | no |true
phasePhiCompressed |Compressed flux for VOF | no | alphaPhiUn
bounded01 | Bounds scalar between 0-1 for multiphase | no | true
phasePhiCompressed | Compressed flux for VOF | no | alphaPhiUn
\endtable
See also
@ -156,10 +157,10 @@ class scalarTransport
{
// Private data
//- Name of field to process
//- Name of the transport field.
word fieldName_;
//- Name of flux field
//- Name of flux field (optional)
word phiName_;
//- Name of density field (optional)
@ -168,10 +169,10 @@ class scalarTransport
//- Name of turbulent viscosity field (optional)
word nutName_;
//- Name of phase field
//- Name of phase field (optional)
word phaseName_;
//- Name of phase field compressed flux
//- Name of phase field compressed flux (optional)
word phasePhiCompressedName_;
//- Diffusion coefficient (optional)

View File

@ -27,7 +27,7 @@ License
#include "dictionary.H"
#include "polyMesh.H"
#include "volFields.H"
#include "coordinateSystem.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -63,7 +63,6 @@ SourceFiles
#include "surfaceFieldsFwd.H"
#include "surfaceMesh.H"
#include "polyMesh.H"
#include "coordinateSystems.H"
#include "interpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,6 +27,7 @@ License
#include "dictionary.H"
#include "polyMesh.H"
#include "volFields.H"
#include "coordinateSystem.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -52,7 +52,6 @@ SourceFiles
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "polyMesh.H"
#include "coordinateSystems.H"
#include "interpolation.H"
#include "error.H"
#include "IOobjectList.H"

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -264,15 +264,13 @@ void Foam::faceShading::calculate()
{
includeAllFacesPerPatch[patchI].insert
(
faceI //pp.start()
faceI
);
}
}
}
}
labelList triSurfaceToAgglom(5*nFaces);
triSurface localSurface = triangulate
(
includePatches,
@ -294,9 +292,10 @@ void Foam::faceShading::calculate()
dict
);
surfacesMesh.searchableSurface::write();
triSurfaceToAgglom.resize(surfacesMesh.size());
if (debug)
{
surfacesMesh.searchableSurface::write();
}
scalar maxBounding = 5.0*mag(mesh_.bounds().max() - mesh_.bounds().min());
@ -324,7 +323,7 @@ void Foam::faceShading::calculate()
const vector d(direction_*maxBounding);
start.append(fc - SMALL*d);
start.append(fc - 0.001*d);
startIndex.append(myFaceId);
@ -355,7 +354,7 @@ void Foam::faceShading::calculate()
(
mesh_.time().path()/"allVisibleFaces.obj",
end,
Cfs
start
);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,6 +26,9 @@ License
#include "solarCalculator.H"
#include "Time.H"
#include "unitConversion.H"
#include "constants.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -104,6 +107,14 @@ void Foam::solarCalculator::calculateBetaTetha()
beta_ = max(asin(cos(L)*cos(deltaRad)*cos(H) + sin(L)*sin(deltaRad)), 1e-3);
tetha_ = acos((sin(beta_)*sin(L) - sin(deltaRad))/(cos(beta_)*cos(L)));
// theta is the angle between the SOUTH axis and the Sun
// If the hour angle is lower than zero (morning) the Sun is positioned
// on the East side.
if (H < 0)
{
tetha_ += 2*(constant::mathematical::pi - tetha_);
}
if (debug)
{
Info << tab << "altitude : " << radToDeg(beta_) << endl;
@ -126,9 +137,10 @@ void Foam::solarCalculator::calculateSunDirection()
new coordinateSystem("grid", Zero, gridUp_, eastDir_)
);
// Assuming 'z' vertical, 'y' North and 'x' East
direction_.z() = -sin(beta_);
direction_.y() = cos(beta_)*cos(tetha_); //North
direction_.x() = cos(beta_)*sin(tetha_); //East
direction_.y() = cos(beta_)*cos(tetha_); // South axis
direction_.x() = cos(beta_)*sin(tetha_); // West axis
direction_ /= mag(direction_);
@ -137,6 +149,7 @@ void Foam::solarCalculator::calculateSunDirection()
Info<< "Sun direction in absolute coordinates : " << direction_ <<endl;
}
// Transform to actual coordinate system
direction_ = coord_->R().transform(direction_);
if (debug)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -62,7 +62,7 @@ Foam::waveModels::waveAbsorptionModel::waveAbsorptionModel
{
if (readFields)
{
read(dict);
readDict(dict);
}
}
@ -75,9 +75,12 @@ Foam::waveModels::waveAbsorptionModel::~waveAbsorptionModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::waveAbsorptionModel::read(const dictionary& overrideDict)
bool Foam::waveModels::waveAbsorptionModel::readDict
(
const dictionary& overrideDict
)
{
if (waveModel::read(overrideDict))
if (waveModel::readDict(overrideDict))
{
// Note: always set to true
activeAbsorption_ = true;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -77,7 +77,7 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -96,7 +96,7 @@ Foam::waveModels::shallowWaterAbsorption::shallowWaterAbsorption
{
if (readFields)
{
read(dict);
readDict(dict);
}
}
@ -109,12 +109,12 @@ Foam::waveModels::shallowWaterAbsorption::~shallowWaterAbsorption()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::shallowWaterAbsorption::read
bool Foam::waveModels::shallowWaterAbsorption::readDict
(
const dictionary& overrideDict
)
{
return waveAbsorptionModel::read(overrideDict);
return waveAbsorptionModel::readDict(overrideDict);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -94,7 +94,7 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -86,7 +86,7 @@ Foam::waveModels::regularWaveModel::regularWaveModel
{
if (readFields)
{
read(dict);
readDict(dict);
}
}
@ -99,9 +99,12 @@ Foam::waveModels::regularWaveModel::~regularWaveModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::regularWaveModel::read(const dictionary& overrideDict)
bool Foam::waveModels::regularWaveModel::readDict
(
const dictionary& overrideDict
)
{
if (waveGenerationModel::read(overrideDict))
if (waveGenerationModel::readDict(overrideDict))
{
lookup("rampTime") >> rampTime_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -105,12 +105,13 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -70,7 +70,7 @@ Foam::waveModels::solitaryWaveModel::solitaryWaveModel
{
if (readFields)
{
read(dict);
readDict(dict);
}
}
@ -83,9 +83,12 @@ Foam::waveModels::solitaryWaveModel::~solitaryWaveModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::solitaryWaveModel::read(const dictionary& overrideDict)
bool Foam::waveModels::solitaryWaveModel::readDict
(
const dictionary& overrideDict
)
{
if (waveGenerationModel::read(overrideDict))
if (waveGenerationModel::readDict(overrideDict))
{
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -87,12 +87,13 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -55,7 +55,7 @@ Foam::waveModels::waveGenerationModel::waveGenerationModel
{
if (readFields)
{
read(dict);
readDict(dict);
}
}
@ -68,9 +68,12 @@ Foam::waveModels::waveGenerationModel::~waveGenerationModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::waveGenerationModel::read(const dictionary& overrideDict)
bool Foam::waveModels::waveGenerationModel::readDict
(
const dictionary& overrideDict
)
{
if (waveModel::read(overrideDict))
if (waveModel::readDict(overrideDict))
{
lookup("activeAbsorption") >> activeAbsorption_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -80,7 +80,7 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -101,7 +101,7 @@ Foam::vector Foam::waveModels::Boussinesq::Deta
}
Foam::vector Foam::waveModels::Boussinesq::U
Foam::vector Foam::waveModels::Boussinesq::Uf
(
const scalar H,
const scalar h,
@ -139,6 +139,8 @@ Foam::vector Foam::waveModels::Boussinesq::U
}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
void Foam::waveModels::Boussinesq::setLevel
(
const scalar t,
@ -165,44 +167,6 @@ void Foam::waveModels::Boussinesq::setLevel
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::Boussinesq
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
solitaryWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::~Boussinesq()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::Boussinesq::read(const dictionary& overrideDict)
{
if (solitaryWaveModel::read(overrideDict))
{
return true;
}
return false;
}
void Foam::waveModels::Boussinesq::setVelocity
(
const scalar t,
@ -224,7 +188,7 @@ void Foam::waveModels::Boussinesq::setVelocity
{
const label paddlei = faceToPaddle_[facei];
const vector Uf = U
const vector Uf = this->Uf
(
waveHeight_,
waterDepthRef_,
@ -242,6 +206,44 @@ void Foam::waveModels::Boussinesq::setVelocity
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::Boussinesq
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
solitaryWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::Boussinesq::~Boussinesq()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::Boussinesq::readDict(const dictionary& overrideDict)
{
if (solitaryWaveModel::readDict(overrideDict))
{
return true;
}
return false;
}
void Foam::waveModels::Boussinesq::info(Ostream& os) const
{
solitaryWaveModel::info(os);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -49,12 +49,12 @@ class Boussinesq
:
public solitaryWaveModel
{
protected:
private:
// Protected Member Functions
// Private Member Functions
//- Wave height
virtual scalar eta
scalar eta
(
const scalar H,
const scalar h,
@ -66,7 +66,7 @@ protected:
) const;
//- Wave
virtual vector Deta
vector Deta
(
const scalar H,
const scalar h,
@ -78,7 +78,7 @@ protected:
) const;
//- Wave velocity
virtual vector U
vector Uf
(
const scalar H,
const scalar h,
@ -90,6 +90,11 @@ protected:
const scalar z
) const;
protected:
// Protected Member Functions
//- Set the water level
virtual void setLevel
(
@ -128,12 +133,13 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -48,6 +48,26 @@ namespace waveModels
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::scalar Foam::waveModels::StokesI::eta
(
const scalar H,
const scalar Kx,
const scalar x,
const scalar Ky,
const scalar y,
const scalar omega,
const scalar t,
const scalar phase
) const
{
scalar phaseTot = Kx*x + Ky*y - omega*t + phase;
return H*0.5*cos(phaseTot);
}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
Foam::scalar Foam::waveModels::StokesI::waveLength
(
const scalar h,
@ -66,24 +86,7 @@ Foam::scalar Foam::waveModels::StokesI::waveLength
}
Foam::scalar Foam::waveModels::StokesI::eta
(
const scalar H,
const scalar Kx,
const scalar x,
const scalar Ky,
const scalar y,
const scalar omega,
const scalar t,
const scalar phase
) const
{
scalar phaseTot = Kx*x + Ky*y - omega*t + phase;
return H*0.5*cos(phaseTot);
}
Foam::vector Foam::waveModels::StokesI::U
Foam::vector Foam::waveModels::StokesI::UfBase
(
const scalar H,
const scalar h,
@ -141,46 +144,6 @@ void Foam::waveModels::StokesI::setLevel
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::StokesI
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::~StokesI()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesI::read(const dictionary& overrideDict)
{
if (regularWaveModel::read(overrideDict))
{
waveLength_ = waveLength(waterDepthRef_, wavePeriod_);
return true;
}
return false;
}
void Foam::waveModels::StokesI::setVelocity
(
const scalar t,
@ -207,7 +170,7 @@ void Foam::waveModels::StokesI::setVelocity
{
const label paddlei = faceToPaddle_[facei];
const vector Uf = U
const vector Uf = UfBase
(
waveHeight_,
waterDepthRef_,
@ -227,6 +190,46 @@ void Foam::waveModels::StokesI::setVelocity
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::StokesI
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesI::~StokesI()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesI::readDict(const dictionary& overrideDict)
{
if (regularWaveModel::readDict(overrideDict))
{
waveLength_ = waveLength(waterDepthRef_, wavePeriod_);
return true;
}
return false;
}
void Foam::waveModels::StokesI::info(Ostream& os) const
{
regularWaveModel::info(os);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -49,15 +49,12 @@ class StokesI
:
public regularWaveModel
{
protected:
private:
// Protected Member Functions
//- Return the wavelength
virtual scalar waveLength(const scalar h, const scalar T) const;
// Private Member Functions
//- Wave height
virtual scalar eta
scalar eta
(
const scalar H,
const scalar Kx,
@ -69,8 +66,16 @@ protected:
const scalar phase
) const;
protected:
// Protected Member Functions
//- Return the wavelength
virtual scalar waveLength(const scalar h, const scalar T) const;
//- Wave velocity
virtual vector U
virtual vector UfBase
(
const scalar H,
const scalar h,
@ -84,7 +89,6 @@ protected:
const scalar z
) const;
//- Set the water level
virtual void setLevel
(
@ -123,12 +127,13 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -71,7 +71,9 @@ Foam::scalar Foam::waveModels::StokesII::eta
}
Foam::vector Foam::waveModels::StokesII::U
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
Foam::vector Foam::waveModels::StokesII::UfBase
(
const scalar H,
const scalar h,
@ -148,7 +150,7 @@ Foam::waveModels::StokesII::StokesII
{
if (readFields)
{
read(dict);
readDict(dict);
}
}
@ -161,9 +163,9 @@ Foam::waveModels::StokesII::~StokesII()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesII::read(const dictionary& overrideDict)
bool Foam::waveModels::StokesII::readDict(const dictionary& overrideDict)
{
if (StokesI::read(overrideDict))
if (StokesI::readDict(overrideDict))
{
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -49,12 +49,12 @@ class StokesII
:
public StokesI
{
protected:
private:
// Protected Member Functions
// Private Member Functions
//- Wave height
virtual scalar eta
scalar eta
(
const scalar H,
const scalar h,
@ -67,8 +67,13 @@ protected:
const scalar phase
) const;
protected:
// Protected Member Functions
//- Wave velocity
virtual vector U
virtual vector UfBase
(
const scalar H,
const scalar h,
@ -112,12 +117,13 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -680,7 +680,7 @@ Foam::scalar Foam::waveModels::StokesV::eta
}
Foam::vector Foam::waveModels::StokesV::U
Foam::vector Foam::waveModels::StokesV::Uf
(
const scalar d,
const scalar kx,
@ -722,17 +722,17 @@ Foam::vector Foam::waveModels::StokesV::U
scalar u =
a1u*cosh(k*z)*cos(theta)
+ a2u*cosh(2.0*k*z)*cos(2.0*(theta))
+ a3u*cosh(3.0*k*z)*cos(3.0*(theta))
+ a4u*cosh(4.0*k*z)*cos(4.0*(theta))
+ a5u*cosh(5.0*k*z)*cos(5.0*(theta));
+ a2u*cosh(2*k*z)*cos(2*theta)
+ a3u*cosh(3*k*z)*cos(3*theta)
+ a4u*cosh(4*k*z)*cos(4*theta)
+ a5u*cosh(5*k*z)*cos(5*theta);
scalar w =
a1u*sinh(k*z)*sin(theta)
+ a2u*sinh(2.0*k*z)*sin(2.0*(theta))
+ a3u*sinh(3.0*k*z)*sin(3.0*(theta))
+ a4u*sinh(4.0*k*z)*sin(4.0*(theta))
+ a5u*sinh(5.0*k*z)*sin(5.0*(theta));
+ a2u*sinh(2*k*z)*sin(2*theta)
+ a3u*sinh(3*k*z)*sin(3*theta)
+ a4u*sinh(4*k*z)*sin(4*theta)
+ a5u*sinh(5*k*z)*sin(5*theta);
scalar v = u*sin(waveAngle_);
u *= cos(waveAngle_);
@ -741,6 +741,8 @@ Foam::vector Foam::waveModels::StokesV::U
}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
void Foam::waveModels::StokesV::setLevel
(
const scalar t,
@ -773,71 +775,6 @@ void Foam::waveModels::StokesV::setLevel
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::StokesV
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false),
lambda_(0)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::~StokesV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesV::read(const dictionary& overrideDict)
{
if (regularWaveModel::read(overrideDict))
{
scalar f1;
scalar f2;
scalar waveK;
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
waveK,
lambda_,
f1,
f2
);
if (f1 > 0.001 || f2 > 0.001)
{
FatalErrorInFunction
<< "No convergence for Stokes V wave theory" << nl
<< " f1: " << f1 << nl
<< " f2: " << f2 << nl
<< exit(FatalError);
}
waveLength_ = 2.0*mathematical::pi/waveK;
return true;
}
return false;
}
void Foam::waveModels::StokesV::setVelocity
(
const scalar t,
@ -863,7 +800,7 @@ void Foam::waveModels::StokesV::setVelocity
{
const label paddlei = faceToPaddle_[facei];
const vector Uf = U
const vector Uf = this->Uf
(
waterDepthRef_,
waveKx,
@ -883,9 +820,72 @@ void Foam::waveModels::StokesV::setVelocity
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::StokesV
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
StokesI(dict, mesh, patch, false),
lambda_(0)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::StokesV::~StokesV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::StokesV::readDict(const dictionary& overrideDict)
{
if (StokesI::readDict(overrideDict))
{
scalar f1;
scalar f2;
scalar waveK;
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
waveK,
lambda_,
f1,
f2
);
if (f1 > 0.001 || f2 > 0.001)
{
FatalErrorInFunction
<< "No convergence for Stokes V wave theory" << nl
<< " f1: " << f1 << nl
<< " f2: " << f2 << nl
<< exit(FatalError);
}
return true;
}
return false;
}
void Foam::waveModels::StokesV::info(Ostream& os) const
{
regularWaveModel::info(os);
StokesI::info(os);
os << " Lambda : " << lambda_ << nl
<< " Wave type : " << waveType() << nl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -39,7 +39,7 @@ Description
#ifndef waveModels_StokesV_H
#define waveModels_StokesV_H
#include "regularWaveModel.H"
#include "StokesIWaveModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,71 +54,65 @@ namespace waveModels
class StokesV
:
public regularWaveModel
public StokesI
{
protected:
private:
// Proteced Data
//-
scalar lambda_;
// Protected Member Functions
// Private Member Functions
// Model coefficients
virtual scalar A11(const scalar h, const scalar k) const;
scalar A11(const scalar h, const scalar k) const;
virtual scalar A13(const scalar h, const scalar k) const;
scalar A13(const scalar h, const scalar k) const;
virtual scalar A15(const scalar h, const scalar k) const;
scalar A15(const scalar h, const scalar k) const;
virtual scalar A22(const scalar h, const scalar k) const;
scalar A22(const scalar h, const scalar k) const;
virtual scalar A24(const scalar h, const scalar k) const;
scalar A24(const scalar h, const scalar k) const;
virtual scalar A33(const scalar h, const scalar k) const;
scalar A33(const scalar h, const scalar k) const;
virtual scalar A35(const scalar h, const scalar k) const;
scalar A35(const scalar h, const scalar k) const;
virtual scalar A44(const scalar h, const scalar k) const;
scalar A44(const scalar h, const scalar k) const;
virtual scalar A55(const scalar h, const scalar k) const;
scalar A55(const scalar h, const scalar k) const;
virtual scalar B22(const scalar h, const scalar k) const;
scalar B22(const scalar h, const scalar k) const;
virtual scalar B24(const scalar h, const scalar k) const;
scalar B24(const scalar h, const scalar k) const;
virtual scalar B33(const scalar h, const scalar k) const;
scalar B33(const scalar h, const scalar k) const;
virtual scalar B33k(const scalar h, const scalar k) const;
scalar B33k(const scalar h, const scalar k) const;
virtual scalar B35(const scalar h, const scalar k) const;
scalar B35(const scalar h, const scalar k) const;
virtual scalar B35k(const scalar h, const scalar k) const;
scalar B35k(const scalar h, const scalar k) const;
virtual scalar B44(const scalar h, const scalar k) const;
scalar B44(const scalar h, const scalar k) const;
virtual scalar B55(const scalar h, const scalar k) const;
scalar B55(const scalar h, const scalar k) const;
virtual scalar B55k(const scalar h, const scalar k) const;
scalar B55k(const scalar h, const scalar k) const;
virtual scalar C1(const scalar h, const scalar k) const;
scalar C1(const scalar h, const scalar k) const;
virtual scalar C1k(const scalar h, const scalar k) const;
scalar C1k(const scalar h, const scalar k) const;
virtual scalar C2(const scalar h, const scalar k) const;
scalar C2(const scalar h, const scalar k) const;
virtual scalar C2k(const scalar h, const scalar k) const;
scalar C2k(const scalar h, const scalar k) const;
virtual scalar C3(const scalar h, const scalar k) const;
scalar C3(const scalar h, const scalar k) const;
virtual scalar C4(const scalar h, const scalar k) const;
scalar C4(const scalar h, const scalar k) const;
//- Model intialisation
virtual void initialise
void initialise
(
const scalar H,
const scalar d,
@ -130,7 +124,7 @@ protected:
) const;
//- Wave height
virtual scalar eta
scalar eta
(
const scalar h,
const scalar kx,
@ -144,7 +138,7 @@ protected:
) const;
//- Wave velocity
virtual vector U
vector Uf
(
const scalar d,
const scalar kx,
@ -158,6 +152,17 @@ protected:
const scalar z
) const;
protected:
// Proteced Data
//-
scalar lambda_;
// Protected Member Functions
//- Set the water level
virtual void setLevel
(
@ -196,12 +201,13 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -189,7 +189,7 @@ Foam::vector Foam::waveModels::cnoidal::dEtaDx
}
Foam::vector Foam::waveModels::cnoidal::U
Foam::vector Foam::waveModels::cnoidal::Uf
(
const scalar H,
const scalar h,
@ -231,6 +231,8 @@ Foam::vector Foam::waveModels::cnoidal::U
}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
void Foam::waveModels::cnoidal::setLevel
(
const scalar t,
@ -262,55 +264,6 @@ void Foam::waveModels::cnoidal::setLevel
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::cnoidal
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false),
m_(0)
{
if (readFields)
{
read(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::~cnoidal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::cnoidal::read(const dictionary& overrideDict)
{
if (regularWaveModel::read(overrideDict))
{
// Initialise m parameter and wavelength
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
m_,
waveLength_
);
return true;
}
return false;
}
void Foam::waveModels::cnoidal::setVelocity
(
const scalar t,
@ -336,7 +289,7 @@ void Foam::waveModels::cnoidal::setVelocity
{
const label paddlei = faceToPaddle_[facei];
const vector Uf = U
const vector Uf = this->Uf
(
waveHeight_,
waterDepthRef_,
@ -356,6 +309,55 @@ void Foam::waveModels::cnoidal::setVelocity
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::cnoidal
(
const dictionary& dict,
const fvMesh& mesh,
const polyPatch& patch,
const bool readFields
)
:
regularWaveModel(dict, mesh, patch, false),
m_(0)
{
if (readFields)
{
readDict(dict);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::waveModels::cnoidal::~cnoidal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModels::cnoidal::readDict(const dictionary& overrideDict)
{
if (regularWaveModel::readDict(overrideDict))
{
// Initialise m parameter and wavelength
initialise
(
waveHeight_,
waterDepthRef_,
wavePeriod_,
m_,
waveLength_
);
return true;
}
return false;
}
void Foam::waveModels::cnoidal::info(Ostream& os) const
{
regularWaveModel::info(os);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -49,16 +49,11 @@ class cnoidal
:
public regularWaveModel
{
protected:
private:
// Protected data
//- `m' coefficient
scalar m_;
// Protected Member Functions
// Private Member Functions
//- Initialise
void initialise
(
const scalar H,
@ -69,7 +64,7 @@ protected:
) const;
//- Wave height
virtual scalar eta
scalar eta
(
const scalar H,
const scalar Kx,
@ -107,7 +102,7 @@ protected:
) const;
//- Wave velocity
virtual vector U
vector Uf
(
const scalar H,
const scalar h,
@ -121,6 +116,18 @@ protected:
const scalar z
) const;
protected:
// Protected data
//- `m' coefficient
scalar m_;
// Protected Member Functions
//- Set the water level
virtual void setLevel
(
@ -159,12 +166,13 @@ public:
// Public Member Functions
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Info
virtual void info(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace waveModels

View File

@ -277,7 +277,7 @@ Foam::waveModel::waveModel
{
if (readFields)
{
read(dict);
readDict(dict);
}
}
@ -290,7 +290,7 @@ Foam::waveModel::~waveModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::waveModel::read(const dictionary& overrideDict)
bool Foam::waveModel::readDict(const dictionary& overrideDict)
{
readOpt() = IOobject::READ_IF_PRESENT;
if (headerOk())

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 IH-Cantabria
-------------------------------------------------------------------------------
License
@ -231,7 +231,7 @@ public:
static word modelName(const word& patchName);
//- Read from dictionary
virtual bool read(const dictionary& overrideDict);
virtual bool readDict(const dictionary& overrideDict);
//- Return the latest wave velocity prediction
virtual const vectorField& U() const;