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

This commit is contained in:
mattijs
2009-03-20 12:59:15 +00:00
227 changed files with 7756 additions and 4614 deletions

View File

@ -152,17 +152,12 @@ inline void Foam::FixedList<T, Size>::checkSize(const label size) const
}
// Check index i is within valid range (0 ... size-1).
// Check index i is within valid range (0 ... size-1)
// The check for zero-sized list is already done in static assert
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::checkIndex(const label i) const
{
if (!Size)
{
FatalErrorIn("FixedList<T, Size>::checkIndex(const label)")
<< "attempt to access element from zero-sized list"
<< abort(FatalError);
}
else if (i < 0 || i >= label(Size))
if (i < 0 || unsigned(i) >= Size)
{
FatalErrorIn("FixedList<T, Size>::checkIndex(const label)")
<< "index " << i << " out of range 0 ... " << (Size-1)

View File

@ -58,10 +58,6 @@ Foam::List<T>::List(const label s)
{
this->v_ = new T[this->size_];
}
else
{
this->v_ = 0;
}
}
@ -87,10 +83,6 @@ Foam::List<T>::List(const label s, const T& a)
List_ELEM((*this), vp, i) = a;
List_END_FOR_ALL
}
else
{
this->v_ = 0;
}
}
@ -119,16 +111,12 @@ Foam::List<T>::List(const List<T>& a)
List_END_FOR_ALL
}
}
else
{
this->v_ = 0;
}
}
// Construct by transferring the parameter contents
template<class T>
Foam::List<T>::List(const Xfer<List<T> >& lst)
Foam::List<T>::List(const Xfer< List<T> >& lst)
{
transfer(lst());
}
@ -165,10 +153,6 @@ Foam::List<T>::List(List<T>& a, bool reUse)
List_END_FOR_ALL
}
}
else
{
this->v_ = 0;
}
}
@ -188,10 +172,6 @@ Foam::List<T>::List(const UList<T>& a, const unallocLabelList& map)
List_ELEM((*this), vp, i) = List_ELEM(a, ap, (map[i]));
List_END_FOR_ALL
}
else
{
this->v_ = 0;
}
}
@ -234,7 +214,7 @@ Foam::List<T>::List(const FixedList<T, Size>& lst)
:
UList<T>(NULL, Size)
{
if (Size)
if (this->size_)
{
this->v_ = new T[this->size_];
@ -243,10 +223,6 @@ Foam::List<T>::List(const FixedList<T, Size>& lst)
this->operator[](i) = lst[i];
}
}
else
{
this->v_ = 0;
}
}
@ -265,10 +241,6 @@ Foam::List<T>::List(const PtrList<T>& lst)
this->operator[](i) = lst[i];
}
}
else
{
this->v_ = 0;
}
}
@ -293,10 +265,6 @@ Foam::List<T>::List(const SLList<T>& lst)
this->operator[](i++) = iter();
}
}
else
{
this->v_ = 0;
}
}
@ -315,10 +283,6 @@ Foam::List<T>::List(const IndirectList<T>& lst)
this->operator[](i) = lst[i];
}
}
else
{
this->v_ = 0;
}
}
@ -337,10 +301,6 @@ Foam::List<T>::List(const UIndirectList<T>& lst)
this->operator[](i) = lst[i];
}
}
else
{
this->v_ = 0;
}
}
@ -359,10 +319,6 @@ Foam::List<T>::List(const BiIndirectList<T>& lst)
this->operator[](i) = lst[i];
}
}
else
{
this->v_ = 0;
}
}

View File

@ -26,8 +26,8 @@ Class
Foam::UIndirectList
Description
A List with indirect addressing. Like IndirectList but does not store
addressing.
A List with indirect addressing.
Like IndirectList but does not store addressing.
SourceFiles
UIndirectListI.H
@ -44,8 +44,12 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
template<class T> class UIndirectList;
template<class T> Ostream& operator<<(Ostream&, const UIndirectList<T>&);
/*---------------------------------------------------------------------------*\
Class UIndirectList Declaration
Class UIndirectList Declaration
\*---------------------------------------------------------------------------*/
template<class T>
@ -92,6 +96,17 @@ public:
//- Assignment of all entries to the given value
inline void operator=(const T&);
// Ostream operator
//- Write UIndirectList to Ostream
// Binary output is currently still a bit of a problem
friend Ostream& operator<<
#ifndef __CINT__
<T>
#endif
(Ostream&, const UIndirectList<T>&);
};
@ -103,6 +118,10 @@ public:
#include "UIndirectListI.H"
#ifdef NoRepository
# include "UIndirectListIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "UIndirectList.H"
#include "Ostream.H"
#include "token.H"
#include "contiguous.H"
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class T>
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::UIndirectList<T>& L
)
{
// Write list contents depending on data format
if (os.format() == IOstream::ASCII || !contiguous<T>())
{
bool uniform = false;
if (L.size() > 1 && contiguous<T>())
{
uniform = true;
forAll(L, i)
{
if (L[i] != L[0])
{
uniform = false;
break;
}
}
}
if (uniform)
{
// Write size and start delimiter
os << L.size() << token::BEGIN_BLOCK;
// Write contents
os << L[0];
// Write end delimiter
os << token::END_BLOCK;
}
else if (L.size() < 11 && contiguous<T>())
{
// Write size and start delimiter
os << L.size() << token::BEGIN_LIST;
// Write contents
forAll(L, i)
{
if (i) os << token::SPACE;
os << L[i];
}
// Write end delimiter
os << token::END_LIST;
}
else
{
// Write size and start delimiter
os << nl << L.size() << nl << token::BEGIN_LIST;
// Write contents
forAll(L, i)
{
os << nl << L[i];
}
// Write end delimiter
os << nl << token::END_LIST << nl;
}
}
else
{
// this is annoying, and wasteful, but there's currently no alternative
os << nl << L.size() << nl;
if (L.size())
{
List<T> lst = L();
os.write
(
reinterpret_cast<const char*>(lst.cdata()),
lst.byteSize()
);
}
}
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const UIndirectList&)");
return os;
}
// ************************************************************************* //

View File

@ -359,6 +359,10 @@ public:
template<class Stream>
static inline Stream& writeDivider(Stream& os);
//- Write the standard end file divider
template<class Stream>
static inline Stream& writeEndDivider(Stream& os);
//- Write header
bool writeHeader(Ostream&) const;

View File

@ -82,5 +82,14 @@ inline Stream& Foam::IOobject::writeDivider(Stream& os)
return os;
}
template<class Stream>
inline Stream& Foam::IOobject::writeEndDivider(Stream& os)
{
os << "\n\n"
"// ************************************************************************* //\n";
return os;
}
// ************************************************************************* //

View File

@ -45,7 +45,7 @@ namespace Foam
{
//- Read a hex label from an input stream
label readHexLabel(ISstream& is);
label readHexLabel(ISstream&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -36,16 +36,16 @@ const char* const Foam::instant::typeName = "instant";
Foam::instant::instant()
{}
Foam::instant::instant(const scalar tval, const word& tname)
Foam::instant::instant(const scalar val, const word& tname)
:
value_(tval),
value_(val),
name_(tname)
{}
Foam::instant::instant(const scalar tval)
Foam::instant::instant(const scalar val)
:
value_(tval),
name_(Time::timeName(tval))
value_(val),
name_(Time::timeName(val))
{}
Foam::instant::instant(const word& tname)
@ -57,20 +57,19 @@ Foam::instant::instant(const word& tname)
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
int Foam::operator==(const instant& I1, const instant& I2)
bool Foam::operator==(const instant& a, const instant& b)
{
return
(
I1.value_ < I2.value_ + SMALL
&& I1.value_ > I2.value_ - SMALL
a.value_ < b.value_ + SMALL
&& a.value_ > b.value_ - SMALL
);
}
int Foam::operator != (const instant& I1, const instant& I2)
bool Foam::operator!=(const instant& a, const instant& b)
{
// Invert the '==' operator ('0'='false')
return I1 == I2 ? 0 : 1;
return !operator==(a, b);
}

View File

@ -50,8 +50,8 @@ class instant;
// Friend Operators
int operator==(const instant&, const instant&);
int operator!=(const instant&, const instant&);
bool operator==(const instant&, const instant&);
bool operator!=(const instant&, const instant&);
// IOstream Operators
@ -79,9 +79,9 @@ public:
{
public:
bool operator()(const instant& one, const instant& two) const
bool operator()(const instant& a, const instant& b) const
{
return one.value() < two.value();
return a.value() < b.value();
}
};
@ -137,8 +137,8 @@ public:
// Friend Operators
friend int operator==(const instant&, const instant&);
friend int operator!=(const instant&, const instant&);
friend bool operator==(const instant&, const instant&);
friend bool operator!=(const instant&, const instant&);
// IOstream Operators

View File

@ -117,12 +117,7 @@ Foam::dictionary::dictionary
name_(dict.name()),
parent_(parentDict)
{
for
(
IDLList<entry>::iterator iter = begin();
iter != end();
++iter
)
forAllIter(IDLList<entry>, *this, iter)
{
hashedEntries_.insert(iter().keyword(), &iter());
@ -147,12 +142,7 @@ Foam::dictionary::dictionary
name_(dict.name()),
parent_(dictionary::null)
{
for
(
IDLList<entry>::iterator iter = begin();
iter != end();
++iter
)
forAllIter(IDLList<entry>, *this, iter)
{
hashedEntries_.insert(iter().keyword(), &iter());
@ -238,12 +228,7 @@ Foam::SHA1Digest Foam::dictionary::digest() const
OSHA1stream os;
// process entries
for
(
IDLList<entry>::const_iterator iter = begin();
iter != end();
++iter
)
forAllConstIter(IDLList<entry>, *this, iter)
{
os << *iter;
}
@ -262,7 +247,8 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
{
if (patternEntries_.size())
{
DLList<entry*>::const_iterator wcLink = patternEntries_.begin();
DLList<entry*>::const_iterator wcLink =
patternEntries_.begin();
DLList<autoPtr<regExp> >::const_iterator reLink =
patternRegexps_.begin();
@ -475,12 +461,7 @@ Foam::wordList Foam::dictionary::toc() const
wordList keys(size());
label nKeys = 0;
for
(
IDLList<entry>::const_iterator iter = begin();
iter != end();
++iter
)
forAllConstIter(IDLList<entry>::const_iterator, *this, iter)
{
keys[nKeys++] = iter().keyword();
}
@ -494,12 +475,7 @@ Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
List<keyType> keys(size());
label nKeys = 0;
for
(
IDLList<entry>::const_iterator iter = begin();
iter != end();
++iter
)
forAllConstIter(IDLList<entry>, *this, iter)
{
if (iter().keyword().isPattern() ? patterns : !patterns)
{
@ -665,8 +641,10 @@ bool Foam::dictionary::remove(const word& Keyword)
if (iter != hashedEntries_.end())
{
// Delete from patterns first
DLList<entry*>::iterator wcLink = patternEntries_.begin();
DLList<autoPtr<regExp> >::iterator reLink = patternRegexps_.begin();
DLList<entry*>::iterator wcLink =
patternEntries_.begin();
DLList<autoPtr<regExp> >::iterator reLink =
patternRegexps_.begin();
// Find in pattern using exact match only
if (findInPatterns(false, Keyword, wcLink, reLink))
@ -792,12 +770,7 @@ bool Foam::dictionary::merge(const dictionary& dict)
bool changed = false;
for
(
IDLList<entry>::const_iterator iter = dict.begin();
iter != dict.end();
++iter
)
forAllConstIter(IDLList<entry>, *this, iter)
{
HashTable<entry*>::iterator fnd = hashedEntries_.find(iter().keyword());
@ -882,12 +855,7 @@ void Foam::dictionary::operator=(const dictionary& rhs)
// Create clones of the entries in the given dictionary
// resetting the parentDict to this dictionary
for
(
IDLList<entry>::const_iterator iter = rhs.begin();
iter != rhs.end();
++iter
)
forAllConstIter(IDLList<entry>, rhs, iter)
{
add(iter().clone(*this).ptr());
}
@ -904,12 +872,7 @@ void Foam::dictionary::operator+=(const dictionary& rhs)
<< abort(FatalError);
}
for
(
IDLList<entry>::const_iterator iter = rhs.begin();
iter != rhs.end();
++iter
)
forAllConstIter(IDLList<entry>, rhs, iter)
{
add(iter().clone(*this).ptr());
}
@ -926,12 +889,7 @@ void Foam::dictionary::operator|=(const dictionary& rhs)
<< abort(FatalError);
}
for
(
IDLList<entry>::const_iterator iter = rhs.begin();
iter != rhs.end();
++iter
)
forAllConstIter(IDLList<entry>, rhs, iter)
{
if (!found(iter().keyword()))
{
@ -951,12 +909,7 @@ void Foam::dictionary::operator<<=(const dictionary& rhs)
<< abort(FatalError);
}
for
(
IDLList<entry>::const_iterator iter = rhs.begin();
iter != rhs.end();
++iter
)
forAllConstIter(IDLList<entry>, rhs, iter)
{
set(iter().clone(*this).ptr());
}

View File

@ -154,12 +154,8 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const
// Write entry
os << e;
// Add new line if applicable
if
(
(e.isDict() || (!e.isDict() && parent()==dictionary::null))
&& e != *last()
)
// Add extra new line between entries for "top-level" dictionaries
if (!subDict && parent() == dictionary::null && e != *last())
{
os << nl;
}
@ -167,7 +163,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const
// Check stream before going to next entry.
if (!os.good())
{
WarningIn("dictionary::write(Ostream& os, bool subDict)")
WarningIn("dictionary::write(Ostream&, bool subDict)")
<< "Can't write entry " << iter().keyword()
<< " for dictionary " << name()
<< endl;

View File

@ -103,14 +103,13 @@ bool Foam::functionEntry::execute
is.fatalCheck
(
"functionEntry::execute"
"(const word& functionName, const dictionary& parentDict, "
"primitiveEntry&, Istream&)"
"(const word&, const dictionary&, primitiveEntry&, Istream&)"
);
if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
{
cerr<<"functionEntry::execute"
<< "(const word&, dictionary&, primitiveEntry&, Istream&)"
<< "(const word&, const dictionary&, primitiveEntry&, Istream&)"
<< " not yet initialized, function = "
<< functionName.c_str() << std::endl;
@ -126,8 +125,7 @@ bool Foam::functionEntry::execute
FatalErrorIn
(
"functionEntry::execute"
"(const word& functionName, const dictionary& parentDict, "
"primitiveEntry&, Istream&)"
"(const word&, const dictionary&, primitiveEntry&, Istream&)"
) << "Unknown functionEntry " << functionName
<< endl << endl
<< "Valid functionEntries are :" << endl

View File

@ -95,7 +95,7 @@ public:
(
const word& functionName,
dictionary& parentDict,
Istream& is
Istream&
);
declareMemberFunctionSelectionTable
@ -117,8 +117,8 @@ public:
(
const word& functionName,
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
primitiveEntry&,
Istream&
);

View File

@ -62,8 +62,7 @@ namespace functionEntries
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::fileName Foam::functionEntries::includeEntry::includeFileName
(
@ -73,6 +72,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
fileName fName(is);
fName.expand();
// relative name
if (fName.size() && fName[0] != '/')
{
fName = fileName(is.name()).path()/fName;
@ -82,17 +82,19 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
IFstream fileStream(includeFileName(is));
IFstream ifs(includeFileName(is));
if (fileStream)
if (ifs)
{
parentDict.read(fileStream);
parentDict.read(ifs);
return true;
}
else
@ -100,9 +102,9 @@ bool Foam::functionEntries::includeEntry::execute
FatalIOErrorIn
(
"functionEntries::includeEntry::includeEntry"
"(dictionary& parentDict,Istream& is)",
"(dictionary& parentDict, Istream&)",
is
) << "Cannot open include file " << fileStream.name()
) << "Cannot open include file " << ifs.name()
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);
@ -117,11 +119,11 @@ bool Foam::functionEntries::includeEntry::execute
Istream& is
)
{
IFstream fileStream(includeFileName(is));
IFstream ifs(includeFileName(is));
if (fileStream)
if (ifs)
{
entry.read(parentDict, fileStream);
entry.read(parentDict, ifs);
return true;
}
else
@ -129,9 +131,9 @@ bool Foam::functionEntries::includeEntry::execute
FatalIOErrorIn
(
"functionEntries::includeEntry::includeEntry"
"(dictionary& parentDict, primitiveEntry& entry, Istream& is)",
"(dictionary& parentDict, primitiveEntry& entry, Istream&)",
is
) << "Cannot open include file " << fileStream.name()
) << "Cannot open include file " << ifs.name()
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);

View File

@ -58,7 +58,7 @@ namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class includeEntry Declaration
Class includeEntry Declaration
\*---------------------------------------------------------------------------*/
class includeEntry
@ -68,7 +68,7 @@ class includeEntry
// Private Member Functions
//- Read the include fileName from Istream, expand and return
static fileName includeFileName(Istream& is);
static fileName includeFileName(Istream&);
//- Disallow default bitwise copy construct
includeEntry(const includeEntry&);
@ -86,18 +86,14 @@ public:
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute
(
dictionary& parentDict,
Istream& is
);
static bool execute(dictionary& parentDict, Istream&);
//- Execute the functionEntry in a primitiveEntry context
static bool execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
primitiveEntry&,
Istream&
);
};

View File

@ -39,6 +39,9 @@ const Foam::word Foam::functionEntries::inputModeEntry::typeName
// might include inputModeEntries
int Foam::functionEntries::inputModeEntry::debug(0);
Foam::functionEntries::inputModeEntry::inputMode
Foam::functionEntries::inputModeEntry::mode_(MERGE);
namespace Foam
{
namespace functionEntries
@ -53,10 +56,6 @@ namespace functionEntries
}
}
// * * * * * * * * * * * * * * * * Private Data * * * * * * * * * * * * * * //
Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// we could combine this into execute() directly, but leave it here for now
@ -65,17 +64,17 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
clear();
word mode(is);
if (mode == "merge")
if (mode == "merge" || mode == "default")
{
mode_ = imMerge;
mode_ = MERGE;
}
else if (mode == "overwrite")
{
mode_ = imOverwrite;
mode_ = OVERWRITE;
}
else if (mode == "error" || mode == "default")
else if (mode == "error")
{
mode_ = imError;
mode_ = ERROR;
}
else
{
@ -101,33 +100,19 @@ bool Foam::functionEntries::inputModeEntry::execute
void Foam::functionEntries::inputModeEntry::clear()
{
mode_ = imError;
mode_ = MERGE;
}
bool Foam::functionEntries::inputModeEntry::merge()
{
if (mode_ & imMerge)
{
return true;
}
else
{
return false;
}
return mode_ == MERGE;
}
bool Foam::functionEntries::inputModeEntry::overwrite()
{
if (mode_ & imOverwrite)
{
return true;
}
else
{
return false;
}
return mode_ == OVERWRITE;
}

View File

@ -38,7 +38,7 @@ Description
@param merge merge sub-dictionaries when possible
@param overwrite keep last entry and silently remove previous ones
@param error flag duplicate entry as an error
@param default currently the same as error
@param default currently the same as merge
SourceFiles
inputModeEntry.C
@ -68,13 +68,13 @@ class inputModeEntry
//- input mode options
enum inputMode
{
imError = 0,
imMerge = 0x1,
imOverwrite = 0x2
ERROR,
MERGE,
OVERWRITE
};
//- current input mode
static label mode_;
static inputMode mode_;
// Private Member Functions
@ -98,19 +98,15 @@ public:
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute
(
dictionary& parentDict,
Istream&
);
static bool execute(dictionary& parentDict, Istream&);
//- Reset the inputMode to 'default'
//- Reset the inputMode to %default
static void clear();
//- Return true if the inputMode is 'merge'
//- Return true if the inputMode is %merge
static bool merge();
//- Return true if the inputMode is 'overwrite'
//- Return true if the inputMode is %overwrite
static bool overwrite();
};

View File

@ -80,11 +80,7 @@ public:
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute
(
dictionary& parentDict,
Istream& is
);
static bool execute(dictionary& parentDict, Istream&);
};

View File

@ -101,7 +101,7 @@ Foam::wordList Foam::objectRegistry::names() const
wordList objectNames(size());
label count=0;
for (const_iterator iter = begin(); iter != end(); ++iter)
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{
objectNames[count++] = iter()->name();
}
@ -115,7 +115,7 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const
wordList objectNames(size());
label count=0;
for (const_iterator iter = begin(); iter != end(); ++iter)
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{
if (iter()->type() == ClassName)
{
@ -234,15 +234,33 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
<< " in registry " << name()
<< endl;
}
}
return false;
}
return false;
void Foam::objectRegistry::rename(const word& newName)
{
regIOobject::rename(newName);
// adjust dbDir_ as well
string::size_type i = dbDir_.rfind('/');
if (i == string::npos)
{
dbDir_ = newName;
}
else
{
dbDir_.replace(i+1, string::npos, newName);
}
}
bool Foam::objectRegistry::modified() const
{
for (const_iterator iter = begin(); iter != end(); ++iter)
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{
if (iter()->modified())
{
@ -287,7 +305,7 @@ bool Foam::objectRegistry::writeObject
{
bool ok = true;
for (const_iterator iter = begin(); iter != end(); ++iter)
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{
if (objectRegistry::debug)
{

View File

@ -160,6 +160,9 @@ public:
// Edit
//- Rename
virtual void rename(const word& newName);
//- Add an regIOobject to registry
bool checkIn(regIOobject&) const;

View File

@ -147,8 +147,7 @@ const Type& Foam::objectRegistry::lookupObject(const word& name) const
}
}
const Type* dummyPtr_ = NULL;
return *dummyPtr_;
return *reinterpret_cast< const Type* >(0);
}

View File

@ -103,9 +103,7 @@ bool Foam::regIOobject::writeObject
return false;
}
os << "\n\n"
"// ************************************************************************* //"
<< endl;
writeEndDivider(os);
osGood = os.good();
}

View File

@ -41,7 +41,7 @@ Description
(baseType,thisType,argNames) \
\
/* Add the thisType constructor function to the table */ \
baseType::add##argNames##ConstructorToTable<thisType> \
baseType::add##argNames##ConstructorToTable< thisType > \
add##thisType##argNames##ConstructorTo##baseType##Table_
@ -50,7 +50,7 @@ Description
(baseType,thisType,argNames,lookup) \
\
/* Add the thisType constructor function to the table, find by lookup */ \
baseType::add##argNames##ConstructorToTable<thisType> \
baseType::add##argNames##ConstructorToTable< thisType > \
add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_(#lookup)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,7 +62,7 @@ Description
(baseType,thisType,Targ,argNames) \
\
/* Add the thisType constructor function to the table */ \
baseType::add##argNames##ConstructorToTable<thisType<Targ> > \
baseType::add##argNames##ConstructorToTable< thisType< Targ > > \
add##thisType##Targ##argNames##ConstructorTo##baseType##Table_
@ -72,7 +72,7 @@ Description
(baseType,thisType,Targ,argNames,lookup) \
\
/* Add the thisType constructor function to the table, find by lookup */ \
baseType::add##argNames##ConstructorToTable<thisType<Targ> > \
baseType::add##argNames##ConstructorToTable< thisType< Targ > > \
add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Table_(#lookup)
@ -85,7 +85,7 @@ Description
(baseType,thisType,Targ,argNames) \
\
/* Add the thisType constructor function to the table */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ> > \
baseType< Targ >::add##argNames##ConstructorToTable< thisType< Targ > > \
add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_
@ -95,7 +95,7 @@ Description
(baseType,thisType,Targ,argNames,lookup) \
\
/* Add the thisType constructor function to the table, find by lookup */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ> > \
baseType< Targ >::add##argNames##ConstructorToTable< thisType< Targ > > \
add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_(#lookup)

View File

@ -54,24 +54,24 @@ Description
(autoPtr,baseType,argNames,argList,parList) \
\
/* Construct from argList function pointer type */ \
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \
\
/* Construct from argList function table type */ \
typedef HashTable<argNames##ConstructorPtr, word, string::hash> \
typedef HashTable< argNames##ConstructorPtr, word, string::hash > \
argNames##ConstructorTable; \
\
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
/* Class to add constructor from argList to table */ \
template<class baseType##Type> \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
{ \
public: \
\
static autoPtr<baseType> New argList \
static autoPtr< baseType > New argList \
{ \
return autoPtr<baseType>(new baseType##Type parList); \
return autoPtr< baseType >(new baseType##Type parList); \
} \
\
add##argNames##ConstructorToTable \
@ -103,24 +103,24 @@ Description
(autoPtr,baseType,argNames,argList,parList) \
\
/* Construct from argList function pointer type */ \
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \
\
/* Construct from argList function table type */ \
typedef HashTable<argNames##ConstructorPtr, word, string::hash> \
typedef HashTable< argNames##ConstructorPtr, word, string::hash > \
argNames##ConstructorTable; \
\
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
/* Class to add constructor from argList to table */ \
template<class baseType##Type> \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
{ \
public: \
\
static autoPtr<baseType> New##baseType argList \
static autoPtr< baseType > New##baseType argList \
{ \
return autoPtr<baseType>(baseType##Type::New parList.ptr()); \
return autoPtr< baseType >(baseType##Type::New parList.ptr()); \
} \
\
add##argNames##ConstructorToTable \
@ -213,7 +213,7 @@ Description
(baseType,argNames) \
\
defineRunTimeSelectionTablePtr(baseType,argNames); \
defineRunTimeSelectionTableConstructor(baseType,argNames) \
defineRunTimeSelectionTableConstructor(baseType,argNames); \
defineRunTimeSelectionTableDestructor(baseType,argNames)
@ -227,7 +227,7 @@ Description
template<> \
defineRunTimeSelectionTablePtr(baseType,argNames); \
template<> \
defineRunTimeSelectionTableConstructor(baseType,argNames) \
defineRunTimeSelectionTableConstructor(baseType,argNames); \
template<> \
defineRunTimeSelectionTableDestructor(baseType,argNames)
@ -242,14 +242,14 @@ Description
(baseType,argNames,Targ) \
\
/* Table constructor called from the table add function */ \
void baseType<Targ>::construct##argNames##ConstructorTables() \
void baseType< Targ >::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
\
if (!constructed) \
{ \
baseType<Targ>::argNames##ConstructorTablePtr_ \
= new baseType<Targ>::argNames##ConstructorTable; \
baseType< Targ >::argNames##ConstructorTablePtr_ \
= new baseType< Targ >::argNames##ConstructorTable; \
\
constructed = true; \
} \
@ -263,12 +263,12 @@ Description
(baseType,argNames,Targ) \
\
/* Table destructor called from the table add function destructor */ \
void baseType<Targ>::destroy##argNames##ConstructorTables() \
void baseType< Targ >::destroy##argNames##ConstructorTables() \
{ \
if (baseType<Targ>::argNames##ConstructorTablePtr_) \
if (baseType< Targ >::argNames##ConstructorTablePtr_) \
{ \
delete baseType<Targ>::argNames##ConstructorTablePtr_; \
baseType<Targ>::argNames##ConstructorTablePtr_ = NULL; \
delete baseType< Targ >::argNames##ConstructorTablePtr_; \
baseType< Targ >::argNames##ConstructorTablePtr_ = NULL; \
} \
}
@ -280,8 +280,8 @@ Description
(baseType,argNames,Targ) \
\
/* Define the constructor function table */ \
baseType<Targ>::argNames##ConstructorTable* \
baseType<Targ>::argNames##ConstructorTablePtr_ = NULL
baseType< Targ >::argNames##ConstructorTable* \
baseType< Targ >::argNames##ConstructorTablePtr_ = NULL
// external use:
@ -294,7 +294,7 @@ Description
template<> \
defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \
template<> \
defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ) \
defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ); \
template<> \
defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ)

View File

@ -44,13 +44,13 @@ Description
// Without debug information
#define ClassNameNoDebug(TypeNameString) \
static const char* typeName_() { return TypeNameString; } \
static const ::Foam::word typeName;
static const ::Foam::word typeName
//- Add typeName information from argument @a TypeNameString to a namespace.
// Without debug information.
#define NamespaceNameNoDebug(TypeNameString) \
inline const char* typeName_() { return TypeNameString; } \
extern const ::Foam::word typeName;
extern const ::Foam::word typeName
//- Add typeName information from argument @a TemplateNameString to a template class.
// Without debug information.
@ -60,7 +60,7 @@ class TemplateNameString##Name \
public: \
TemplateNameString##Name() {} \
ClassNameNoDebug(#TemplateNameString); \
};
}
@ -89,7 +89,7 @@ class TemplateNameString##Name \
public: \
TemplateNameString##Name() {} \
ClassName(#TemplateNameString); \
};
}
@ -100,30 +100,30 @@ public: \
//- Define the typeName, with alternative lookup as @a Name
#define defineTypeNameWithName(Type, Name) \
const ::Foam::word Type::typeName(Name);
const ::Foam::word Type::typeName(Name)
//- Define the typeName
#define defineTypeName(Type) \
defineTypeNameWithName(Type, Type::typeName_());
defineTypeNameWithName(Type, Type::typeName_())
#ifdef __INTEL_COMPILER
//- Define the typeName as @a Name for template classes
# define defineTemplateTypeNameWithName(Type, Name) \
defineTypeNameWithName(Type, Name);
defineTypeNameWithName(Type, Name)
#else
//- Define the typeName as @a Name for template classes
# define defineTemplateTypeNameWithName(Type, Name) \
template<> \
defineTypeNameWithName(Type, Name);
defineTypeNameWithName(Type, Name)
#endif
//- Define the typeName for template classes, useful with typedefs
#define defineTemplateTypeName(Type) \
defineTemplateTypeNameWithName(Type, #Type);
defineTemplateTypeNameWithName(Type, #Type)
//- Define the typeName directly for template classes
#define defineNamedTemplateTypeName(Type) \
defineTemplateTypeNameWithName(Type, Type::typeName_());
defineTemplateTypeNameWithName(Type, Type::typeName_())
@ -134,31 +134,31 @@ public: \
//- Define the debug information, lookup as @a Name
#define defineDebugSwitchWithName(Type, Name, DebugSwitch) \
int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch));
int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch))
//- Define the debug information
#define defineDebugSwitch(Type, DebugSwitch) \
defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch);
defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
#ifdef __INTEL_COMPILER
//- Define the debug information for templates, lookup as @a Name
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
defineDebugSwitchWithName(Type, Name, DebugSwitch);
defineDebugSwitchWithName(Type, Name, DebugSwitch)
#else
//- Define the debug information for templates, lookup as @a Name
# define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \
template<> \
defineDebugSwitchWithName(Type, Name, DebugSwitch);
defineDebugSwitchWithName(Type, Name, DebugSwitch)
#endif
//- Define the debug information for templates
// Useful with typedefs
#define defineTemplateDebugSwitch(Type, DebugSwitch) \
defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch);
defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch)
//- Define the debug information directly for templates
#define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \
defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch);
defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch)
@ -170,21 +170,21 @@ public: \
//- Define the typeName and debug information
#define defineTypeNameAndDebug(Type, DebugSwitch) \
defineTypeName(Type); \
defineDebugSwitch(Type, DebugSwitch);
defineDebugSwitch(Type, DebugSwitch)
//- Define the typeName and debug information, lookup as @a Name
#define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \
defineTemplateTypeNameWithName(Type, Name); \
defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch);
defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch)
//- Define the typeName and debug information for templates, useful with typedefs
#define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \
defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch);
defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch)
//- Define the typeName and debug information for templates
#define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \
defineNamedTemplateTypeName(Type); \
defineNamedTemplateDebugSwitch(Type, DebugSwitch);
defineNamedTemplateDebugSwitch(Type, DebugSwitch)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -29,10 +29,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cloud, 0);
}
defineTypeNameAndDebug(Foam::cloud, 0);
const Foam::word Foam::cloud::prefix("lagrangian");
Foam::word Foam::cloud::defaultName("defaultCloud");
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -42,9 +42,9 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
(
IOobject
(
cloudName,
( cloudName.size() ? cloudName : defaultName ),
obr.time().timeName(),
"lagrangian",
prefix,
obr,
IOobject::NO_READ,
IOobject::AUTO_WRITE

View File

@ -47,7 +47,7 @@ namespace Foam
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class cloud Declaration
Class cloud Declaration
\*---------------------------------------------------------------------------*/
class cloud
@ -69,15 +69,16 @@ public:
//- Runtime type information
TypeName("cloud");
//- The prefix to local: %lagrangian
static const word prefix;
//- The default cloud name: %defaultCloud
static word defaultName;
// Constructors
//- Construct for the given objectRegistry and named cloud instance
cloud
(
const objectRegistry& obr,
const word& cloudName = "defaultCloud"
);
cloud(const objectRegistry&, const word& cloudName = "");
// Destructor

View File

@ -162,10 +162,7 @@ bool Foam::solution::read()
relaxationFactors_ = dict.subDict("relaxationFactors");
}
if (relaxationFactors_.found("default"))
{
relaxationFactors_.lookup("default") >> defaultRelaxationFactor_;
}
relaxationFactors_.readIfPresent("default", defaultRelaxationFactor_);
if (dict.found("solvers"))
{
@ -227,7 +224,7 @@ Foam::scalar Foam::solution::relaxationFactor(const word& name) const
{
FatalIOErrorIn
(
"Foam::solution::relaxationFactor(const word& name)",
"Foam::solution::relaxationFactor(const word&)",
relaxationFactors_
) << "Cannot find relaxationFactor for '" << name
<< "' or a suitable default value."
@ -242,7 +239,7 @@ const Foam::dictionary& Foam::solution::solverDict(const word& name) const
{
if (debug)
{
InfoIn("solution::solverDict(const word& name)")
InfoIn("solution::solverDict(const word&)")
<< "Lookup solver for " << name << endl;
}
@ -254,7 +251,7 @@ const Foam::dictionary& Foam::solution::solver(const word& name) const
{
if (debug)
{
InfoIn("solution::solver(const word& name)")
InfoIn("solution::solver(const word&)")
<< "Lookup solver for " << name << endl;
}

View File

@ -176,9 +176,10 @@ public:
}
//- Assignment from bool
void operator=(const bool b)
const Switch& operator=(const bool b)
{
switch_ = (b ? Switch::TRUE : Switch::FALSE);
return *this;
}

View File

@ -51,13 +51,13 @@ namespace Foam
class complex;
inline scalar magSqr(const complex& c);
inline complex sqr(const complex& c);
inline scalar mag(const complex& c);
inline const complex& max(const complex& c1, const complex& c2);
inline const complex& min(const complex& c1, const complex& c2);
inline complex limit(const complex& c1, const complex& c2);
inline const complex& sum(const complex& c);
inline scalar magSqr(const complex&);
inline complex sqr(const complex&);
inline scalar mag(const complex&);
inline const complex& max(const complex&, const complex&);
inline const complex& min(const complex&, const complex&);
inline complex limit(const complex&, const complex&);
inline const complex& sum(const complex&);
inline complex operator+(const complex&, const complex&);
inline complex operator-(const complex&);
inline complex operator-(const complex&, const complex&);
@ -67,8 +67,8 @@ inline complex operator*(const scalar, const complex&);
inline complex operator*(const complex&, const scalar);
inline complex operator/(const complex&, const scalar);
inline complex operator/(const scalar, const complex&);
Istream& operator>>(Istream& is, complex&);
Ostream& operator<<(Ostream& os, const complex& C);
Istream& operator>>(Istream&, complex&);
Ostream& operator<<(Ostream&, const complex&);
/*---------------------------------------------------------------------------*\
@ -127,13 +127,13 @@ public:
// Member operators
inline void operator=(const complex&);
inline const complex& operator=(const complex&);
inline void operator+=(const complex&);
inline void operator-=(const complex&);
inline void operator*=(const complex&);
inline void operator/=(const complex&);
inline void operator=(const scalar);
inline const complex& operator=(const scalar);
inline void operator+=(const scalar);
inline void operator-=(const scalar);
inline void operator*=(const scalar);
@ -150,12 +150,12 @@ public:
friend scalar magSqr(const complex& c);
friend complex sqr(const complex& c);
friend scalar mag(const complex& c);
friend const complex& max(const complex& c1, const complex& c2);
friend const complex& min(const complex& c1, const complex& c2);
friend const complex& max(const complex&, const complex&);
friend const complex& min(const complex&, const complex&);
friend complex limit(const complex& c1, const complex& c2);
friend complex limit(const complex&, const complex&);
friend const complex& sum(const complex& c);
friend const complex& sum(const complex&);
// Friend operators

View File

@ -76,10 +76,11 @@ inline complex complex::conjugate() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void complex::operator=(const complex& c)
inline const complex& complex::operator=(const complex& c)
{
re = c.re;
im = c.im;
return *this;
}
@ -109,10 +110,11 @@ inline void complex::operator/=(const complex& c)
}
inline void complex::operator=(const scalar s)
inline const complex& complex::operator=(const scalar s)
{
re = s;
im = 0.0;
return *this;
}
@ -234,8 +236,8 @@ inline complex operator+(const complex& c1, const complex& c2)
{
return complex
(
c1.re+c2.re,
c1.im+c2.im
c1.re + c2.re,
c1.im + c2.im
);
}
@ -254,8 +256,8 @@ inline complex operator-(const complex& c1, const complex& c2)
{
return complex
(
c1.re-c2.re,
c1.im-c2.im
c1.re - c2.re,
c1.im - c2.im
);
}

View File

@ -196,36 +196,41 @@ Foam::word Foam::fileName::component
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::fileName::operator=(const fileName& str)
const Foam::fileName& Foam::fileName::operator=(const fileName& str)
{
string::operator=(str);
return *this;
}
void Foam::fileName::operator=(const word& str)
const Foam::fileName& Foam::fileName::operator=(const word& str)
{
string::operator=(str);
return *this;
}
void Foam::fileName::operator=(const string& str)
const Foam::fileName& Foam::fileName::operator=(const string& str)
{
string::operator=(str);
stripInvalid();
return *this;
}
void Foam::fileName::operator=(const std::string& str)
const Foam::fileName& Foam::fileName::operator=(const std::string& str)
{
string::operator=(str);
stripInvalid();
return *this;
}
void Foam::fileName::operator=(const char* str)
const Foam::fileName& Foam::fileName::operator=(const char* str)
{
string::operator=(str);
stripInvalid();
return *this;
}

View File

@ -158,11 +158,11 @@ public:
// Assignment
void operator=(const fileName&);
void operator=(const word&);
void operator=(const string&);
void operator=(const std::string&);
void operator=(const char*);
const fileName& operator=(const fileName&);
const fileName& operator=(const word&);
const fileName& operator=(const string&);
const fileName& operator=(const std::string&);
const fileName& operator=(const char*);
// IOstream operators

View File

@ -106,12 +106,12 @@ public:
// Assignment
inline void operator=(const keyType&);
inline void operator=(const word&);
inline const keyType& operator=(const keyType&);
inline const keyType& operator=(const word&);
//- Assign from regular expression.
inline void operator=(const string&);
inline void operator=(const char*);
inline const keyType& operator=(const string&);
inline const keyType& operator=(const char*);
// IOstream operators

View File

@ -89,34 +89,38 @@ inline bool Foam::keyType::isPattern() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::keyType::operator=(const keyType& s)
inline const Foam::keyType& Foam::keyType::operator=(const keyType& s)
{
// Bypass checking
string::operator=(s);
isPattern_ = s.isPattern_;
return *this;
}
inline void Foam::keyType::operator=(const word& s)
inline const Foam::keyType& Foam::keyType::operator=(const word& s)
{
word::operator=(s);
isPattern_ = false;
return *this;
}
inline void Foam::keyType::operator=(const string& s)
inline const Foam::keyType& Foam::keyType::operator=(const string& s)
{
// Bypass checking
string::operator=(s);
isPattern_ = true;
return *this;
}
inline void Foam::keyType::operator=(const char* s)
inline const Foam::keyType& Foam::keyType::operator=(const char* s)
{
// Bypass checking
string::operator=(s);
isPattern_ = false;
return *this;
}

View File

@ -144,6 +144,9 @@ public:
template<class String>
static inline string quotemeta(const string&, const char quote='\\');
//- Avoid masking the normal std::string replace
using std::string::replace;
//- Replace first occurence of sub-string oldStr with newStr
// starting at start
string& replace

View File

@ -117,10 +117,10 @@ public:
// Assignment
inline void operator=(const word&);
inline void operator=(const string&);
inline void operator=(const std::string&);
inline void operator=(const char*);
inline const word& operator=(const word&);
inline const word& operator=(const string&);
inline const word& operator=(const std::string&);
inline const word& operator=(const char*);
// Friend Operators

View File

@ -132,30 +132,34 @@ inline bool Foam::word::valid(char c)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::word::operator=(const word& q)
inline const Foam::word& Foam::word::operator=(const word& q)
{
string::operator=(q);
return *this;
}
inline void Foam::word::operator=(const string& q)
inline const Foam::word& Foam::word::operator=(const string& q)
{
string::operator=(q);
stripInvalid();
return *this;
}
inline void Foam::word::operator=(const std::string& q)
inline const Foam::word& Foam::word::operator=(const std::string& q)
{
string::operator=(q);
stripInvalid();
return *this;
}
inline void Foam::word::operator=(const char* q)
inline const Foam::word& Foam::word::operator=(const char* q)
{
string::operator=(q);
stripInvalid();
return *this;
}

View File

@ -41,7 +41,7 @@ Description
Note
If the string contents are changed - eg, by the operator+=() or by
string::replace(), etc - it will be necessary to use compile() or
recompile() to sychronize the regular expression.
recompile() to synchronize the regular expression.
SourceFiles
wordRe.C
@ -187,22 +187,22 @@ public:
//- Assign copy
// Always case sensitive
inline void operator=(const wordRe&);
inline const wordRe& operator=(const wordRe&);
//- Copy word, never a regular expression
inline void operator=(const word&);
inline const wordRe& operator=(const word&);
//- Copy string, auto-test for regular expression
// Always case sensitive
inline void operator=(const string&);
inline const wordRe& operator=(const string&);
//- Copy string, auto-test for regular expression
// Always case sensitive
inline void operator=(const std::string&);
inline const wordRe& operator=(const std::string&);
//- Copy string, auto-test for regular expression
// Always case sensitive
inline void operator=(const char*);
inline const wordRe& operator=(const char*);
// IOstream operators

View File

@ -213,7 +213,7 @@ inline void Foam::wordRe::set(const char* str, const compOption opt)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::wordRe::operator=(const wordRe& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const wordRe& str)
{
string::operator=(str);
@ -225,34 +225,39 @@ inline void Foam::wordRe::operator=(const wordRe& str)
{
re_.clear();
}
return *this;
}
inline void Foam::wordRe::operator=(const word& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const word& str)
{
word::operator=(str);
re_.clear();
return *this;
}
inline void Foam::wordRe::operator=(const string& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const string& str)
{
string::operator=(str);
compile(DETECT); // auto-detect regex
return *this;
}
inline void Foam::wordRe::operator=(const std::string& str)
inline const Foam::wordRe& Foam::wordRe::operator=(const std::string& str)
{
string::operator=(str);
compile(DETECT); // auto-detect regex
return *this;
}
inline void Foam::wordRe::operator=(const char* str)
inline const Foam::wordRe& Foam::wordRe::operator=(const char* str)
{
string::operator=(str);
compile(DETECT); // auto-detect regex
return *this;
}

View File

@ -97,10 +97,8 @@ void Foam::meshReader::writeInterfaces(const objectRegistry& registry) const
OFstream os(ioObj.objectPath());
ioObj.writeHeader(os);
os << interfaces_
<< "// *************************************"
<< "************************************ //"
<< endl;
os << interfaces_;
ioObj.writeEndDivider(os);
}

View File

@ -33,6 +33,8 @@ sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C
sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
sampledSurface/thresholdCellFaces/thresholdCellFaces.C
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
surfWriters = sampledSurface/writers
@ -40,8 +42,8 @@ $(surfWriters)/surfaceWriters.C
$(surfWriters)/dx/dxSurfaceWriterRunTime.C
$(surfWriters)/foamFile/foamFileSurfaceWriterRunTime.C
$(surfWriters)/null/nullSurfaceWriterRunTime.C
$(surfWriters)/proxy/proxySurfaceWriterRunTime.C
$(surfWriters)/raw/rawSurfaceWriterRunTime.C
$(surfWriters)/stl/stlSurfaceWriterRunTime.C
$(surfWriters)/vtk/vtkSurfaceWriterRunTime.C
graphField/writePatchGraph.C

View File

@ -62,10 +62,10 @@ class primitiveMesh;
class cuttingPlane
:
public plane,
public BasicMeshedSurface<face>
public MeshedSurface<face>
{
//- Private typedefs for convenience
typedef BasicMeshedSurface<face> MeshStorage;
typedef MeshedSurface<face> MeshStorage;
// Private data

View File

@ -81,7 +81,7 @@ public:
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
Ostream&
) const;
};

View File

@ -32,7 +32,7 @@ License
namespace Foam
{
makeSetWriters(gnuplotSetWriter)
makeSetWriters(gnuplotSetWriter);
}
// ************************************************************************* //

View File

@ -54,7 +54,7 @@ class jplotSetWriter
// Private Member Functions
//- Write header
Ostream& writeHeader(Ostream& os) const;
Ostream& writeHeader(Ostream&) const;
public:
@ -85,7 +85,7 @@ public:
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
Ostream&
) const;
};

View File

@ -32,7 +32,7 @@ License
namespace Foam
{
makeSetWriters(jplotSetWriter)
makeSetWriters(jplotSetWriter);
}
// ************************************************************************* //

View File

@ -81,7 +81,7 @@ public:
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
Ostream&
) const;
};

View File

@ -32,7 +32,7 @@ License
namespace Foam
{
makeSetWriters(rawSetWriter)
makeSetWriters(rawSetWriter);
}
// ************************************************************************* //

View File

@ -91,22 +91,12 @@ protected:
//- Generates filename from coordSet and sampled fields
fileName getBaseName(const coordSet&, const wordList&) const;
void writeCoord
(
const coordSet& samples,
const label sampleI,
Ostream& os
) const;
void writeCoord(const coordSet&, const label sampleI, Ostream&) const;
//- Writes single-column ascii write. Column 1 is coordSet coordinate,
// columns 2 is the value. Uses write() function
// to write coordinate in correct format.
void writeTable
(
const coordSet&,
const List<Type>&,
Ostream& os
) const;
void writeTable(const coordSet&, const List<Type>&, Ostream&) const;
//- Writes multi-column ascii write. Column 1 is coordSet coordinate,
// columns 2..n are the values. Uses write() function
@ -139,10 +129,7 @@ public:
// Selectors
//- Return a reference to the selected writer
static autoPtr<writer> New
(
const word& writeFormat
);
static autoPtr<writer> New(const word& writeFormat);
// Constructors
@ -165,8 +152,8 @@ public:
) const = 0;
//- General entry point for writing.
// The data is organized in a set of point with one or
// more values per point
// The data is organized in a set of point with one or more values
// per point
virtual void write
(
const coordSet&,
@ -179,7 +166,7 @@ public:
virtual Ostream& write(const scalar, Ostream&) const;
template<class VSType>
Ostream& writeVS(const VSType& value, Ostream& os) const;
Ostream& writeVS(const VSType&, Ostream&) const;
//- Write vector. Tab separated ascii
virtual Ostream& write(const vector&, Ostream&) const;

View File

@ -40,27 +40,27 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Only used internally
#define makeTypeSetWritersTypeName(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter<dataType >, 0);
#define makeTypeSetWritersTypeName(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0)
// Sometimes used externally
#define makeSetWritersTypeName(typeWriter) \
\
makeTypeSetWritersTypeName(typeWriter, scalar); \
makeTypeSetWritersTypeName(typeWriter, vector); \
makeTypeSetWritersTypeName(typeWriter, sphericalTensor); \
makeTypeSetWritersTypeName(typeWriter, symmTensor); \
makeTypeSetWritersTypeName(typeWriter, tensor);
#define makeSetWritersTypeName(typeWriter) \
\
makeTypeSetWritersTypeName(typeWriter, scalar); \
makeTypeSetWritersTypeName(typeWriter, vector); \
makeTypeSetWritersTypeName(typeWriter, sphericalTensor); \
makeTypeSetWritersTypeName(typeWriter, symmTensor); \
makeTypeSetWritersTypeName(typeWriter, tensor)
// Define type info for single dataType template instantiation (eg, vector)
#define makeSetWriterType(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter<dataType >, 0); \
addTemplatedToRunTimeSelectionTable \
( \
writer, typeWriter, dataType, word \
);
#define makeSetWriterType(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0); \
addTemplatedToRunTimeSelectionTable \
( \
writer, typeWriter, dataType, word \
)
// Define type info for scalar, vector etc. instantiations
@ -70,7 +70,7 @@ SourceFiles
makeSetWriterType(typeWriter, vector); \
makeSetWriterType(typeWriter, sphericalTensor); \
makeSetWriterType(typeWriter, symmTensor); \
makeSetWriterType(typeWriter, tensor);
makeSetWriterType(typeWriter, tensor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -81,7 +81,7 @@ public:
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
Ostream&
) const;
};

View File

@ -32,7 +32,7 @@ License
namespace Foam
{
makeSetWriters(xmgraceSetWriter)
makeSetWriters(xmgraceSetWriter);
}
// ************************************************************************* //

View File

@ -50,11 +50,11 @@ namespace Foam
class sampledPatch
:
public BasicMeshedSurface<face>,
public MeshedSurface<face>,
public sampledSurface
{
//- Private typedefs for convenience
typedef BasicMeshedSurface<face> MeshStorage;
typedef MeshedSurface<face> MeshStorage;
// Private data

View File

@ -70,18 +70,27 @@ Foam::scalar Foam::sampledSurfaces::mergeTol_(1e-10);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::sampledSurfaces::checkFieldTypes()
Foam::label Foam::sampledSurfaces::classifyFieldTypes()
{
wordList fieldTypes(fieldNames_.size());
label nFields = 0;
// check files for a particular time
if (loadFromFiles_)
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
forAll(fieldNames_, fieldI)
{
forAll(fieldNames_, fieldI)
const word& fieldName = fieldNames_[fieldI];
word fieldType = "";
// check files for a particular time
if (loadFromFiles_)
{
IOobject io
(
fieldNames_[fieldI],
fieldName,
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -91,69 +100,96 @@ bool Foam::sampledSurfaces::checkFieldTypes()
if (io.headerOk())
{
fieldTypes[fieldI] = io.headerClassName();
fieldType = io.headerClassName();
}
else
{
fieldTypes[fieldI] = "(notFound)";
continue;
}
}
}
else
{
// check objectRegistry
forAll(fieldNames_, fieldI)
else
{
objectRegistry::const_iterator iter =
mesh_.find(fieldNames_[fieldI]);
// check objectRegistry
objectRegistry::const_iterator iter = mesh_.find(fieldName);
if (iter != mesh_.objectRegistry::end())
{
fieldTypes[fieldI] = iter()->type();
fieldType = iter()->type();
}
else
{
fieldTypes[fieldI] = "(notFound)";
continue;
}
}
if (fieldType == volScalarField::typeName)
{
scalarFields_.append(fieldName);
nFields++;
}
else if (fieldType == volVectorField::typeName)
{
vectorFields_.append(fieldName);
nFields++;
}
else if (fieldType == volSphericalTensorField::typeName)
{
sphericalTensorFields_.append(fieldName);
nFields++;
}
else if (fieldType == volSymmTensorField::typeName)
{
symmTensorFields_.append(fieldName);
nFields++;
}
else if (fieldType == volTensorField::typeName)
{
tensorFields_.append(fieldName);
nFields++;
}
}
return nFields;
}
label nFields = 0;
// classify fieldTypes
nFields += grep(scalarFields_, fieldTypes);
nFields += grep(vectorFields_, fieldTypes);
nFields += grep(sphericalTensorFields_, fieldTypes);
nFields += grep(symmTensorFields_, fieldTypes);
nFields += grep(tensorFields_, fieldTypes);
void Foam::sampledSurfaces::writeGeometry() const
{
// Write to time directory under outputPath_
// skip surface without faces (eg, a failed cut-plane)
if (Pstream::master())
const fileName outputDir = outputPath_/mesh_.time().timeName();
forAll(*this, surfI)
{
if (debug)
{
Pout<< "timeName = " << mesh_.time().timeName() << nl
<< "scalarFields " << scalarFields_ << nl
<< "vectorFields " << vectorFields_ << nl
<< "sphTensorFields " << sphericalTensorFields_ << nl
<< "symTensorFields " << symmTensorFields_ <<nl
<< "tensorFields " << tensorFields_ <<nl;
}
const sampledSurface& s = operator[](surfI);
if (nFields > 0)
if (Pstream::parRun())
{
if (debug)
if (Pstream::master() && mergeList_[surfI].faces.size())
{
Pout<< "Creating directory "
<< outputPath_/mesh_.time().timeName()
<< nl << endl;
genericFormatter_->write
(
outputDir,
s.name(),
mergeList_[surfI].points,
mergeList_[surfI].faces
);
}
mkDir(outputPath_/mesh_.time().timeName());
}
else if (s.faces().size())
{
genericFormatter_->write
(
outputDir,
s.name(),
s.points(),
s.faces()
);
}
}
return nFields > 0;
}
@ -176,6 +212,7 @@ Foam::sampledSurfaces::sampledSurfaces
interpolationScheme_(word::null),
writeFormat_(word::null),
mergeList_(),
genericFormatter_(NULL),
scalarFields_(),
vectorFields_(),
sphericalTensorFields_(),
@ -223,11 +260,39 @@ void Foam::sampledSurfaces::end()
void Foam::sampledSurfaces::write()
{
if (size() && checkFieldTypes())
if (size())
{
// finalize surfaces, merge points etc.
update();
const label nFields = classifyFieldTypes();
if (Pstream::master())
{
if (debug)
{
Pout<< "timeName = " << mesh_.time().timeName() << nl
<< "scalarFields " << scalarFields_ << nl
<< "vectorFields " << vectorFields_ << nl
<< "sphTensorFields " << sphericalTensorFields_ << nl
<< "symTensorFields " << symmTensorFields_ <<nl
<< "tensorFields " << tensorFields_ <<nl;
Pout<< "Creating directory "
<< outputPath_/mesh_.time().timeName() << nl << endl;
}
mkDir(outputPath_/mesh_.time().timeName());
}
// write geometry first if required, or when no fields would otherwise
// be written
if (nFields == 0 || genericFormatter_->separateFiles())
{
writeGeometry();
}
sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_);
@ -241,6 +306,14 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
{
fieldNames_ = wordList(dict.lookup("fields"));
const label nFields = fieldNames_.size();
scalarFields_.reset(nFields);
vectorFields_.reset(nFields);
sphericalTensorFields_.reset(nFields);
symmTensorFields_.reset(nFields);
tensorFields_.reset(nFields);
interpolationScheme_ = dict.lookupOrDefault<word>
(
"interpolationScheme",
@ -252,6 +325,11 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
"null"
);
// define the generic (geometry) writer
genericFormatter_ = surfaceWriter<bool>::New(writeFormat_);
PtrList<sampledSurface> newList
(
dict.lookup("surfaces"),

View File

@ -64,24 +64,24 @@ class sampledSurfaces
template<class Type>
class fieldGroup
:
public wordList
public DynamicList<word>
{
public:
//- Surface formatter
autoPtr<surfaceWriter<Type> > formatter;
autoPtr< surfaceWriter<Type> > formatter;
//- Construct null
fieldGroup()
:
wordList(0),
DynamicList<word>(0),
formatter(NULL)
{}
//- Construct for a particular surface format
fieldGroup(const word& writeFormat)
:
wordList(0),
DynamicList<word>(0),
formatter(surfaceWriter<Type>::New(writeFormat))
{}
@ -93,10 +93,17 @@ class sampledSurfaces
const wordList& fieldNames
)
:
wordList(fieldNames),
DynamicList<word>(fieldNames),
formatter(surfaceWriter<Type>::New(writeFormat))
{}
void reset(const label nElem)
{
formatter.clear();
DynamicList<word>::setCapacity(nElem);
DynamicList<word>::clear();
}
void operator=(const word& writeFormat)
{
formatter = surfaceWriter<Type>::New(writeFormat);
@ -104,7 +111,7 @@ class sampledSurfaces
void operator=(const wordList& fieldNames)
{
wordList::operator=(fieldNames);
DynamicList<word>::operator=(fieldNames);
}
};
@ -171,6 +178,9 @@ class sampledSurfaces
// Calculated
//- Generic surface formatter
autoPtr< surfaceWriter<bool> > genericFormatter_;
//- Categorized scalar/vector/tensor fields
fieldGroup<scalar> scalarFields_;
fieldGroup<vector> vectorFields_;
@ -181,16 +191,11 @@ class sampledSurfaces
// Private Member Functions
//- Classify field types, return true if nFields > 0
bool checkFieldTypes();
//- Classify field types, returns the number of fields
label classifyFieldTypes();
//- Find the fields in the list of the given type, return count
template<class Type>
label grep
(
fieldGroup<Type>& fieldList,
const wordList& fieldTypes
) const;
//- Write geometry only
void writeGeometry() const;
//- Sample and write a particular volume field
template<class Type>

View File

@ -30,35 +30,6 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::label Foam::sampledSurfaces::grep
(
fieldGroup<Type>& fieldList,
const wordList& fieldTypes
) const
{
fieldList.setSize(fieldNames_.size());
label nFields = 0;
forAll(fieldNames_, fieldI)
{
if
(
fieldTypes[fieldI]
== GeometricField<Type, fvPatchField, volMesh>::typeName
)
{
fieldList[nFields] = fieldNames_[fieldI];
nFields++;
}
}
fieldList.setSize(nFields);
return nFields;
}
template<class Type>
void Foam::sampledSurfaces::sampleAndWrite
(
@ -67,10 +38,10 @@ void Foam::sampledSurfaces::sampleAndWrite
)
{
// interpolator for this field
autoPtr<interpolation<Type> > interpolator;
autoPtr< interpolation<Type> > interpolator;
const word& fieldName = vField.name();
const fileName& timeDir = vField.time().timeName();
const fileName outputDir = outputPath_/vField.time().timeName();
forAll(*this, surfI)
{
@ -128,8 +99,7 @@ void Foam::sampledSurfaces::sampleAndWrite
{
formatter.write
(
outputPath_,
timeDir,
outputDir,
s.name(),
mergeList_[surfI].points,
mergeList_[surfI].faces,
@ -147,8 +117,7 @@ void Foam::sampledSurfaces::sampleAndWrite
{
formatter.write
(
outputPath_,
timeDir,
outputDir,
s.name(),
s.points(),
s.faces(),
@ -217,7 +186,7 @@ void Foam::sampledSurfaces::sampleAndWrite
sampleAndWrite
(
mesh_.lookupObject
<GeometricField<Type, fvPatchField, volMesh> >
<GeometricField<Type, fvPatchField, volMesh> >
(
fields[fieldI]
),

View File

@ -0,0 +1,333 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "sampledThresholdCellFaces.H"
#include "dictionary.H"
#include "volFields.H"
#include "volPointInterpolation.H"
#include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
#include "thresholdCellFaces.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sampledThresholdCellFaces, 0);
addNamedToRunTimeSelectionTable
(
sampledSurface,
sampledThresholdCellFaces,
word,
thresholdCellFaces
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::sampledThresholdCellFaces::updateGeometry() const
{
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
// no update needed
if (fvm.time().timeIndex() == prevTimeIndex_)
{
return false;
}
prevTimeIndex_ = fvm.time().timeIndex();
// Optionally read volScalarField
autoPtr<volScalarField> readFieldPtr_;
// 1. see if field in database
// 2. see if field can be read
const volScalarField* cellFldPtr = NULL;
if (fvm.foundObject<volScalarField>(fieldName_))
{
if (debug)
{
Info<< "sampledThresholdCellFaces::updateGeometry() : lookup "
<< fieldName_ << endl;
}
cellFldPtr = &fvm.lookupObject<volScalarField>(fieldName_);
}
else
{
// Bit of a hack. Read field and store.
if (debug)
{
Info<< "sampledThresholdCellFaces::updateGeometry() : reading "
<< fieldName_ << " from time " << fvm.time().timeName()
<< endl;
}
readFieldPtr_.reset
(
new volScalarField
(
IOobject
(
fieldName_,
fvm.time().timeName(),
fvm,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
fvm
)
);
cellFldPtr = readFieldPtr_.operator->();
}
const volScalarField& cellFld = *cellFldPtr;
thresholdCellFaces surf
(
fvm,
cellFld.internalField(),
lowerThreshold_,
upperThreshold_,
triangulate_
);
const_cast<sampledThresholdCellFaces&>
(
*this
).MeshedSurface<face>::transfer(surf);
meshCells_.transfer(surf.meshCells());
if (debug)
{
Pout<< "sampledThresholdCellFaces::updateGeometry() : constructed"
<< nl
<< " field : " << fieldName_ << nl
<< " lowerLimit : " << lowerThreshold_ << nl
<< " upperLimit : " << upperThreshold_ << nl
<< " point : " << points().size() << nl
<< " faces : " << faces().size() << nl
<< " cut cells : " << meshCells_.size() << endl;
}
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledThresholdCellFaces::sampledThresholdCellFaces
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
sampledSurface(name, mesh, dict),
fieldName_(dict.lookup("field")),
lowerThreshold_(dict.lookupOrDefault<scalar>("lowerLimit", -VGREAT)),
upperThreshold_(dict.lookupOrDefault<scalar>("upperLimit", VGREAT)),
zoneName_(word::null),
triangulate_(dict.lookupOrDefault("triangulate", false)),
prevTimeIndex_(-1),
meshCells_(0)
{
if (!dict.found("lowerLimit") && !dict.found("upperLimit"))
{
FatalErrorIn
(
"sampledThresholdCellFaces::sampledThresholdCellFaces(..)"
)
<< "require at least one of 'lowerLimit' or 'upperLimit'" << endl
<< abort(FatalError);
}
// dict.readIfPresent("zone", zoneName_);
//
// if (debug && zoneName_.size())
// {
// if (mesh.cellZones().findZoneID(zoneName_) < 0)
// {
// Info<< "cellZone \"" << zoneName_
// << "\" not found - using entire mesh" << endl;
// }
// }
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledThresholdCellFaces::~sampledThresholdCellFaces()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sampledThresholdCellFaces::needsUpdate() const
{
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
return fvm.time().timeIndex() != prevTimeIndex_;
}
bool Foam::sampledThresholdCellFaces::expire()
{
// already marked as expired
if (prevTimeIndex_ == -1)
{
return false;
}
// force update
prevTimeIndex_ = -1;
return true;
}
bool Foam::sampledThresholdCellFaces::update()
{
return updateGeometry();
}
Foam::tmp<Foam::scalarField>
Foam::sampledThresholdCellFaces::sample
(
const volScalarField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::vectorField>
Foam::sampledThresholdCellFaces::sample
(
const volVectorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::sphericalTensorField>
Foam::sampledThresholdCellFaces::sample
(
const volSphericalTensorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::symmTensorField>
Foam::sampledThresholdCellFaces::sample
(
const volSymmTensorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::tensorField>
Foam::sampledThresholdCellFaces::sample
(
const volTensorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::scalarField>
Foam::sampledThresholdCellFaces::interpolate
(
const interpolation<scalar>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::vectorField>
Foam::sampledThresholdCellFaces::interpolate
(
const interpolation<vector>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::sphericalTensorField>
Foam::sampledThresholdCellFaces::interpolate
(
const interpolation<sphericalTensor>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::symmTensorField>
Foam::sampledThresholdCellFaces::interpolate
(
const interpolation<symmTensor>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::tensorField>
Foam::sampledThresholdCellFaces::interpolate
(
const interpolation<tensor>& interpolator
) const
{
return interpolateField(interpolator);
}
void Foam::sampledThresholdCellFaces::print(Ostream& os) const
{
os << "sampledThresholdCellFaces: " << name() << " :"
<< " field:" << fieldName_
<< " lowerLimit:" << lowerThreshold_
<< " upperLimit:" << upperThreshold_;
//<< " faces:" << faces().size() // possibly no geom yet
//<< " points:" << points().size();
}
// ************************************************************************* //

View File

@ -0,0 +1,234 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::sampledThresholdCellFaces
Description
A sampledSurface defined by the cell faces corresponding to a threshold
value.
SourceFiles
sampledThresholdCellFaces.C
\*---------------------------------------------------------------------------*/
#ifndef sampledThresholdCellFaces_H
#define sampledThresholdCellFaces_H
#include "sampledSurface.H"
#include "MeshedSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sampledThresholdCellFaces Declaration
\*---------------------------------------------------------------------------*/
class sampledThresholdCellFaces
:
public sampledSurface,
public MeshedSurface<face>
{
//- Private typedefs for convenience
typedef MeshedSurface<face> MeshStorage;
// Private data
//- Field to get isoSurface of
const word fieldName_;
//- Threshold value
const scalar lowerThreshold_;
//- Threshold value
const scalar upperThreshold_;
//- zone name (if restricted to zones)
word zoneName_;
//- Triangulated faces or keep faces as is
bool triangulate_;
// Recreated for every time-step
//- Time at last call, also track it surface needs an update
mutable label prevTimeIndex_;
//- For every face the original cell in mesh
mutable labelList meshCells_;
// Private Member Functions
//- Create surface (if time has changed)
// Do nothing (and return false) if no update was needed
bool updateGeometry() const;
//- sample field on faces
template <class Type>
tmp<Field<Type> > sampleField
(
const GeometricField<Type, fvPatchField, volMesh>& vField
) const;
template <class Type>
tmp<Field<Type> >
interpolateField(const interpolation<Type>&) const;
public:
//- Runtime type information
TypeName("sampledThresholdCellFaces");
// Constructors
//- Construct from dictionary
sampledThresholdCellFaces
(
const word& name,
const polyMesh&,
const dictionary&
);
// Destructor
virtual ~sampledThresholdCellFaces();
// Member Functions
//- Does the surface need an update?
virtual bool needsUpdate() const;
//- Mark the surface as needing an update.
// May also free up unneeded data.
// Return false if surface was already marked as expired.
virtual bool expire();
//- Update the surface as required.
// Do nothing (and return false) if no update was needed
virtual bool update();
//- Points of surface
virtual const pointField& points() const
{
return MeshStorage::points();
}
//- Faces of surface
virtual const faceList& faces() const
{
return MeshStorage::faces();
}
//- sample field on surface
virtual tmp<scalarField> sample
(
const volScalarField&
) const;
//- sample field on surface
virtual tmp<vectorField> sample
(
const volVectorField&
) const;
//- sample field on surface
virtual tmp<sphericalTensorField> sample
(
const volSphericalTensorField&
) const;
//- sample field on surface
virtual tmp<symmTensorField> sample
(
const volSymmTensorField&
) const;
//- sample field on surface
virtual tmp<tensorField> sample
(
const volTensorField&
) const;
//- interpolate field on surface
virtual tmp<scalarField> interpolate
(
const interpolation<scalar>&
) const;
//- interpolate field on surface
virtual tmp<vectorField> interpolate
(
const interpolation<vector>&
) const;
//- interpolate field on surface
virtual tmp<sphericalTensorField> interpolate
(
const interpolation<sphericalTensor>&
) const;
//- interpolate field on surface
virtual tmp<symmTensorField> interpolate
(
const interpolation<symmTensor>&
) const;
//- interpolate field on surface
virtual tmp<tensorField> interpolate
(
const interpolation<tensor>&
) const;
//- Write
virtual void print(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "sampledThresholdCellFacesTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "sampledThresholdCellFaces.H"
#include "thresholdCellFaces.H"
#include "volFieldsFwd.H"
#include "pointFields.H"
#include "volPointInterpolation.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledThresholdCellFaces::sampleField
(
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
// Recreate geometry if time has changed
updateGeometry();
return tmp<Field<Type> >(new Field<Type>(vField, meshCells_));
}
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledThresholdCellFaces::interpolateField
(
const interpolation<Type>& interpolator
) const
{
// Recreate geometry if time has changed
updateGeometry();
// One value per point
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
{
const face& f = faces()[cutFaceI];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
if (!pointDone[pointI])
{
values[pointI] = interpolator.interpolate
(
points()[pointI],
meshCells_[cutFaceI]
);
pointDone[pointI] = true;
}
}
}
return tvalues;
}
// ************************************************************************* //

View File

@ -0,0 +1,288 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "thresholdCellFaces.H"
#include "polyMesh.H"
#include "DynamicList.H"
#include "emptyPolyPatch.H"
#include "processorPolyPatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::thresholdCellFaces, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::thresholdCellFaces::calculate
(
const scalarField& field,
const scalar lowerThreshold,
const scalar upperThreshold,
const bool triangulate
)
{
const labelList& own = mesh_.faceOwner();
const labelList& nei = mesh_.faceNeighbour();
const faceList& origFaces = mesh_.faces();
const pointField& origPoints = mesh_.points();
const polyBoundaryMesh& bMesh = mesh_.boundaryMesh();
surfZoneList surfZones(bMesh.size()+1);
surfZones[0] = surfZone
(
"internalMesh",
0, // size
0, // start
0 // index
);
forAll(bMesh, patchI)
{
surfZones[patchI+1] = surfZone
(
bMesh[patchI].name(),
0, // size
0, // start
patchI+1 // index
);
}
label nFaces = 0;
label nPoints = 0;
meshCells_.clear();
DynamicList<face> surfFaces(0.5 * mesh_.nFaces());
DynamicList<label> surfCells(surfFaces.size());
labelList oldToNewPoints(origPoints.size(), -1);
// internal faces only
for (label faceI = 0; faceI < mesh_.nInternalFaces(); ++faceI)
{
int side = 0;
// check lowerThreshold
if (field[own[faceI]] > lowerThreshold)
{
if (field[nei[faceI]] < lowerThreshold)
{
side = +1;
}
}
else if (field[nei[faceI]] > lowerThreshold)
{
side = -1;
}
// check upperThreshold
if (field[own[faceI]] < upperThreshold)
{
if (field[nei[faceI]] > upperThreshold)
{
side = +1;
}
}
else if (field[nei[faceI]] < upperThreshold)
{
side = -1;
}
if (side)
{
const face& f = origFaces[faceI];
forAll(f, fp)
{
if (oldToNewPoints[f[fp]] == -1)
{
oldToNewPoints[f[fp]] = nPoints++;
}
}
label cellId;
face surfFace;
if (side > 0)
{
surfFace = f;
cellId = own[faceI];
}
else
{
surfFace = f.reverseFace();
cellId = nei[faceI];
}
if (triangulate)
{
label count = surfFace.triangles(origPoints, surfFaces);
while (count-- > 0)
{
surfCells.append(cellId);
}
}
else
{
surfFaces.append(surfFace);
surfCells.append(cellId);
}
}
}
surfZones[0].size() = surfFaces.size();
// nothing special for processor patches?
forAll(bMesh, patchI)
{
const polyPatch& p = bMesh[patchI];
surfZone& zone = surfZones[patchI+1];
zone.start() = nFaces;
if
(
isType<emptyPolyPatch>(p)
|| (Pstream::parRun() && isType<processorPolyPatch>(p))
)
{
continue;
}
label faceI = p.start();
// patch faces
forAll(p, localFaceI)
{
if
(
field[own[faceI]] > lowerThreshold
&& field[own[faceI]] < upperThreshold
)
{
const face& f = origFaces[faceI];
forAll(f, fp)
{
if (oldToNewPoints[f[fp]] == -1)
{
oldToNewPoints[f[fp]] = nPoints++;
}
}
label cellId = own[faceI];
if (triangulate)
{
label count = f.triangles(origPoints, surfFaces);
while (count-- > 0)
{
surfCells.append(cellId);
}
}
else
{
surfFaces.append(f);
surfCells.append(cellId);
}
}
++faceI;
}
zone.size() = surfFaces.size() - zone.start();
}
surfFaces.shrink();
surfCells.shrink();
// renumber
forAll(surfFaces, faceI)
{
inplaceRenumber(oldToNewPoints, surfFaces[faceI]);
}
pointField surfPoints(nPoints);
nPoints = 0;
forAll(oldToNewPoints, pointI)
{
if (oldToNewPoints[pointI] >= 0)
{
surfPoints[oldToNewPoints[pointI]] = origPoints[pointI];
nPoints++;
}
}
surfPoints.setSize(nPoints);
this->storedPoints().transfer(surfPoints);
this->storedFaces().transfer(surfFaces);
this->storedZones().transfer(surfZones);
meshCells_.transfer(surfCells);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::thresholdCellFaces::thresholdCellFaces
(
const polyMesh& mesh,
const scalarField& field,
const scalar lowerThreshold,
const scalar upperThreshold,
const bool triangulate
)
:
mesh_(mesh)
{
if (lowerThreshold > upperThreshold)
{
WarningIn("thresholdCellFaces::thresholdCellFaces(...)")
<< "lower > upper limit! "
<< lowerThreshold << " > " << upperThreshold << endl;
}
calculate(field, lowerThreshold, upperThreshold, triangulate);
}
// ************************************************************************* //

View File

@ -0,0 +1,123 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::thresholdCellFaces
Description
Selects the mesh cell faces specified by a threshold value.
Non-triangulated by default.
SourceFiles
thresholdCellFaces.C
\*---------------------------------------------------------------------------*/
#ifndef thresholdCellFaces_H
#define thresholdCellFaces_H
#include "MeshedSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
/*---------------------------------------------------------------------------*\
Class thresholdCellFaces Declaration
\*---------------------------------------------------------------------------*/
class thresholdCellFaces
:
public MeshedSurface<face>
{
//- Private typedefs for convenience
typedef MeshedSurface<face> MeshStorage;
//- Reference to mesh
const polyMesh& mesh_;
//- For every face the original cell in mesh
labelList meshCells_;
// Private Member Functions
void calculate
(
const scalarField&,
const scalar lowerThreshold,
const scalar upperThreshold,
const bool triangulate
);
public:
//- Runtime type information
TypeName("thresholdCellFaces");
// Constructors
//- Construct from mesh, field and threshold value
thresholdCellFaces
(
const polyMesh&,
const scalarField&,
const scalar lowerThreshold,
const scalar upperThreshold,
const bool triangulate = false
);
// Member Functions
//- For every face original cell in mesh
labelList& meshCells()
{
return meshCells_;
}
//- For every face original cell in mesh
const labelList& meshCells() const
{
return meshCells_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -25,20 +25,19 @@ License
\*---------------------------------------------------------------------------*/
#include "dxSurfaceWriter.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::dxSurfaceWriter<Type>::writeDXGeometry
void Foam::dxSurfaceWriter<Type>::writeGeometry
(
Ostream& os,
const pointField& points,
const faceList& faces,
Ostream& os
) const
const faceList& faces
)
{
// Write vertex coordinates
@ -69,7 +68,7 @@ void Foam::dxSurfaceWriter<Type>::writeDXGeometry
{
FatalErrorIn
(
"writeDXGeometry(Ostream&, const pointField&, const faceList&)"
"writeGeometry(Ostream&, const pointField&, const faceList&)"
) << "Face " << faceI << " vertices " << f
<< " is not a triangle."
<< exit(FatalError);
@ -82,181 +81,137 @@ void Foam::dxSurfaceWriter<Type>::writeDXGeometry
}
// Write scalarField in DX format
template<class Type>
void Foam::dxSurfaceWriter<Type>::writeDXData
(
const pointField& points,
const scalarField& values,
Ostream& os
) const
namespace Foam
{
// Write data
os << "object 3 class array type float rank 0 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
// Write scalarField in DX format
template<>
void Foam::dxSurfaceWriter<Foam::scalar>::writeData
(
Ostream& os,
const Field<scalar>& values
)
{
os << float(values[elemI]) << nl;
// Write data
os << "object 3 class array type float rank 0 items "
<< values.size() << " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI]) << nl;
}
}
if (values.size() == points.size())
// Write vectorField in DX format
template<>
void Foam::dxSurfaceWriter<Foam::vector>::writeData
(
Ostream& os,
const Field<vector>& values
)
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
// Write data
os << "object 3 class array type float rank 1 shape 3 items "
<< values.size() << " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI].x()) << ' '
<< float(values[elemI].y()) << ' '
<< float(values[elemI].z()) << nl;
}
}
else
// Write sphericalTensorField in DX format
template<>
void Foam::dxSurfaceWriter<Foam::sphericalTensor>::writeData
(
Ostream& os,
const Field<sphericalTensor>& values
)
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
// Write data
os << "object 3 class array type float rank 0 items "
<< values.size() << " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI][0]) << nl;
}
}
// Write symmTensorField in DX format
template<>
void Foam::dxSurfaceWriter<Foam::symmTensor>::writeData
(
Ostream& os,
const Field<symmTensor>& values
)
{
// Write data
os << "object 3 class array type float rank 2 shape 3 items "
<< values.size() << " data follows" << nl;
forAll(values, elemI)
{
const symmTensor& t = values[elemI];
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
<< float(t.xy()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
<< float(t.xz()) << ' ' << float(t.yz()) << ' ' << float(t.zz())
<< nl;
}
}
// Write tensorField in DX format
template<>
void Foam::dxSurfaceWriter<Foam::tensor>::writeData
(
Ostream& os,
const Field<tensor>& values
)
{
// Write data
os << "object 3 class array type float rank 2 shape 3 items "
<< values.size() << " data follows" << nl;
forAll(values, elemI)
{
const tensor& t = values[elemI];
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
<< float(t.yx()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
<< float(t.zx()) << ' ' << float(t.zy()) << ' ' << float(t.zz())
<< nl;
}
}
}
// Write vectorField in DX format
template<class Type>
void Foam::dxSurfaceWriter<Type>::writeDXData
(
const pointField& points,
const vectorField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 1 shape 3 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI].x()) << ' '
<< float(values[elemI].y()) << ' '
<< float(values[elemI].z()) << nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write sphericalTensorField in DX format
template<class Type>
void Foam::dxSurfaceWriter<Type>::writeDXData
(
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 0 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
os << float(values[elemI][0]) << nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write symmTensorField in DX format
template<class Type>
void Foam::dxSurfaceWriter<Type>::writeDXData
(
const pointField& points,
const symmTensorField& values,
Ostream& os
) const
{
// Write data
os << "object 3 class array type float rank 2 shape 3 items "
<< values.size()
<< " data follows" << nl;
forAll(values, elemI)
{
const symmTensor& t = values[elemI];
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
<< float(t.xy()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
<< float(t.xz()) << ' ' << float(t.yz()) << ' ' << float(t.zz())
<< nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
}
// Write tensorField in DX format
template<class Type>
void Foam::dxSurfaceWriter<Type>::writeDXData
void Foam::dxSurfaceWriter<Type>::writeData
(
const pointField& points,
const tensorField& values,
Ostream& os
) const
Ostream& os,
const Field<Type>& values
)
{
// Write data
os << "object 3 class array type float rank 2 shape 3 items "
<< values.size()
<< " data follows" << nl;
os << "object 3 class array type float rank 0 items "
<< values.size() << " data follows" << nl;
forAll(values, elemI)
{
const tensor& t = values[elemI];
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
<< float(t.yx()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
<< float(t.zx()) << ' ' << float(t.zy()) << ' ' << float(t.zz())
<< nl;
}
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
os << float(0.0) << nl;
}
}
// Write trailer in DX format
template<class Type>
void Foam::dxSurfaceWriter<Type>::writeDXTrailer(Ostream& os) const
void Foam::dxSurfaceWriter<Type>::writeTrailer(Ostream& os)
{
os << "# the field, with three components: \"positions\","
<< " \"connections\", and \"data\"" << nl
@ -290,8 +245,7 @@ Foam::dxSurfaceWriter<Type>::~dxSurfaceWriter()
template<class Type>
void Foam::dxSurfaceWriter<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
@ -300,27 +254,37 @@ void Foam::dxSurfaceWriter<Type>::write
const bool verbose
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!isDir(surfaceDir))
if (!isDir(outputDir))
{
mkDir(surfaceDir);
mkDir(outputDir);
}
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".dx");
OFstream os
(
outputDir/fieldName + '_' + surfaceName + ".dx"
);
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << fName << endl;
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
}
OFstream os(fName);
writeGeometry(os, points, faces);
writeDXGeometry(points, faces, os);
writeData(os, values);
writeDXData(points, values, os);
if (values.size() == points.size())
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
writeDXTrailer(os);
writeTrailer(os);
os << "end" << nl;
}

View File

@ -54,49 +54,11 @@ class dxSurfaceWriter
// Private Member Functions
void writeDXGeometry
(
const pointField& points,
const faceList& faces,
Ostream& os
) const;
static void writeGeometry(Ostream&, const pointField&, const faceList&);
void writeDXData
(
const pointField& points,
const scalarField& values,
Ostream& os
) const;
static void writeData(Ostream&, const Field<Type>& values);
void writeDXData
(
const pointField& points,
const vectorField& values,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const symmTensorField& values,
Ostream& os
) const;
void writeDXData
(
const pointField& points,
const tensorField& values,
Ostream& os
) const;
void writeDXTrailer(Ostream& os) const;
static void writeTrailer(Ostream&);
public:
@ -122,8 +84,7 @@ public:
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,

View File

@ -25,9 +25,8 @@ License
\*---------------------------------------------------------------------------*/
#include "foamFileSurfaceWriter.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -51,8 +50,37 @@ Foam::foamFileSurfaceWriter<Type>::~foamFileSurfaceWriter()
template<class Type>
void Foam::foamFileSurfaceWriter<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
{
fileName surfaceDir(outputDir/surfaceName);
if (!isDir(surfaceDir))
{
mkDir(surfaceDir);
}
if (verbose)
{
Info<< "Writing geometry to " << surfaceDir << endl;
}
// Points
OFstream(surfaceDir/"points")() << points;
// Faces
OFstream(surfaceDir/"faces")() << faces;
}
template<class Type>
void Foam::foamFileSurfaceWriter<Type>::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
@ -61,7 +89,7 @@ void Foam::foamFileSurfaceWriter<Type>::write
const bool verbose
) const
{
fileName surfaceDir(samplePath/timeDir/surfaceName);
fileName surfaceDir(outputDir/surfaceName);
if (!isDir(surfaceDir))
{
@ -73,11 +101,7 @@ void Foam::foamFileSurfaceWriter<Type>::write
Info<< "Writing field " << fieldName << " to " << surfaceDir << endl;
}
// Points
OFstream(surfaceDir/"points")() << points;
// Faces
OFstream(surfaceDir/"faces")() << faces;
// geometry should already have been written
// Values to separate directory (e.g. "scalarField/p")

View File

@ -72,13 +72,26 @@ public:
// Member Functions
// Write
//- Return true if the surface format supports separate files
virtual bool separateFiles()
{
return true;
}
//- Write geometry to file.
virtual void write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose = false
) const;
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,

View File

@ -35,6 +35,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(foamFileSurfaceWriter, bool);
makeSurfaceWriters(foamFileSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,10 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "nullSurfaceWriter.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -53,8 +49,7 @@ Foam::nullSurfaceWriter<Type>::~nullSurfaceWriter()
template<class Type>
void Foam::nullSurfaceWriter<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,

View File

@ -76,8 +76,7 @@ public:
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,

View File

@ -35,6 +35,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(nullSurfaceWriter, bool);
makeSurfaceWriters(nullSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,91 +24,65 @@ License
\*---------------------------------------------------------------------------*/
#include "stlSurfaceWriter.H"
#include "fileName.H"
#include "proxySurfaceWriter.H"
#include "MeshedSurfaceProxy.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
#include "triSurface.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::stlSurfaceWriter<Type>::stlSurfaceWriter()
Foam::proxySurfaceWriter<Type>::proxySurfaceWriter(const word& ext)
:
surfaceWriter<Type>()
surfaceWriter<Type>(),
ext_(ext)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::stlSurfaceWriter<Type>::~stlSurfaceWriter()
Foam::proxySurfaceWriter<Type>::~proxySurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::stlSurfaceWriter<Type>::write
void Foam::proxySurfaceWriter<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values,
const bool verbose
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!isDir(surfaceDir))
// avoid bad values
if (ext_.empty())
{
mkDir(surfaceDir);
return;
}
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".stl");
if (!isDir(outputDir))
{
mkDir(outputDir);
}
fileName fName(outputDir/surfaceName + "." + ext_);
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << fName << endl;
Info<< "Writing geometry to " << fName << endl;
}
// Convert faces to triangles.
DynamicList<labelledTri> tris(faces.size());
forAll(faces, i)
{
const face& f = faces[i];
faceList triFaces(f.nTriangles(points));
label nTris = 0;
f.triangles(points, nTris, triFaces);
forAll(triFaces, triI)
{
const face& tri = triFaces[triI];
tris.append(labelledTri(tri[0], tri[1], tri[2], 0));
}
}
triSurface
MeshedSurfaceProxy<face>
(
tris.shrink(),
geometricSurfacePatchList
(
1,
geometricSurfacePatch
(
"patch", // geometricType
string::validate<word>(fieldName), // fieldName
0 // index
)
),
points
points,
faces
).write(fName);
}

View File

@ -23,17 +23,17 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::stlSurfaceWriter
Foam::proxySurfaceWriter
Description
SourceFiles
stlSurfaceWriter.C
proxySurfaceWriter.C
\*---------------------------------------------------------------------------*/
#ifndef stlSurfaceWriter_H
#define stlSurfaceWriter_H
#ifndef proxySurfaceWriter_H
#define proxySurfaceWriter_H
#include "surfaceWriter.H"
@ -43,48 +43,70 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class stlSurfaceWriter Declaration
Class proxySurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class stlSurfaceWriter
class proxySurfaceWriter
:
public surfaceWriter<Type>
{
// Private data
//- The associated file extension
word ext_;
public:
//- Runtime type information
TypeName("stl");
TypeName("proxy");
// Constructors
//- Construct null
stlSurfaceWriter();
//- Construct for a given extension
proxySurfaceWriter(const word& ext);
// Destructor
virtual ~stlSurfaceWriter();
virtual ~proxySurfaceWriter();
// Member Functions
//- Always write separate geometry file
virtual bool separateFiles()
{
return true;
}
// Write
//- Write geometry to file.
virtual void write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose = false
) const;
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<Type>& values,
const bool verbose = false
) const;
) const
{}
};
@ -95,7 +117,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "stlSurfaceWriter.C"
# include "proxySurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "stlSurfaceWriter.H"
#include "proxySurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
@ -35,7 +35,9 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriters(stlSurfaceWriter);
// create type names, but do not register with run-time tables
makeTypeSurfaceWritersTypeName(proxySurfaceWriter, bool);
makeSurfaceWritersTypeName(proxySurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,9 +25,8 @@ License
\*---------------------------------------------------------------------------*/
#include "rawSurfaceWriter.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
#include "IOmanip.H"
@ -37,9 +36,9 @@ template<class Type>
void Foam::rawSurfaceWriter<Type>::writeGeometry
(
const pointField& points,
const label& pointI,
const label pointI,
Ostream& os
) const
)
{
const point& pt = points[pointI];
@ -52,15 +51,16 @@ void Foam::rawSurfaceWriter<Type>::writeGeometry
(
const pointField& points,
const faceList& faces,
const label& faceI,
const label faceI,
Ostream& os
) const
)
{
const point& ct = faces[faceI].centre(points);
os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
}
// Write scalarField in raw format
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeData
@ -70,38 +70,29 @@ void Foam::rawSurfaceWriter<Type>::writeData
const faceList& faces,
const scalarField& values,
Ostream& os
) const
)
{
// header
os << "# " << fieldName;
os << "# x y z " << fieldName << endl;
// Write data
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
os << values[elemI] << nl;
}
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# x y z " << fieldName
<< endl;
// Write data
forAll(values, elemI)
{
if (values.size() == points.size())
{
writeGeometry(points, elemI, os);
}
else
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
os << values[elemI] << nl;
}
os << values[elemI] << endl;
}
os << nl;
}
@ -115,22 +106,9 @@ void Foam::rawSurfaceWriter<Type>::writeData
const faceList& faces,
const vectorField& values,
Ostream& os
) const
)
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# x y z "
<< fieldName << "_x "
<< fieldName << "_y "
@ -138,21 +116,27 @@ void Foam::rawSurfaceWriter<Type>::writeData
<< endl;
// Write data
forAll(values, elemI)
if (values.size() == points.size())
{
const vector& v = values[elemI];
if (values.size() == points.size())
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const vector& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
}
else
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
const vector& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
}
}
}
@ -165,40 +149,32 @@ void Foam::rawSurfaceWriter<Type>::writeData
const faceList& faces,
const sphericalTensorField& values,
Ostream& os
) const
)
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# ii ";
os << fieldName << "_ii" << endl;
// Write data
forAll(values, elemI)
if (values.size() == points.size())
{
const sphericalTensor& v = values[elemI];
if (values.size() == points.size())
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const sphericalTensor& v = values[elemI];
os << v[0] << nl;
}
else
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << nl;
const sphericalTensor& v = values[elemI];
os << v[0] << nl;
}
}
}
@ -212,22 +188,9 @@ void Foam::rawSurfaceWriter<Type>::writeData
const faceList& faces,
const symmTensorField& values,
Ostream& os
) const
)
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# xx xy xz yy yz ";
for(int i=0; i<6; i++)
{
@ -236,22 +199,31 @@ void Foam::rawSurfaceWriter<Type>::writeData
os << endl;
// Write data
forAll(values, elemI)
if (values.size() == points.size())
{
const symmTensor& v = values[elemI];
if (values.size() == points.size())
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const symmTensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< nl;
}
else
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< nl;
const symmTensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< nl;
}
}
}
@ -265,46 +237,40 @@ void Foam::rawSurfaceWriter<Type>::writeData
const faceList& faces,
const tensorField& values,
Ostream& os
) const
)
{
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA " << values.size()
<< nl;
}
else
{
os << " FACE_DATA " << values.size()
<< nl;
}
os << "# xx xy xz yx yy yz zx zy zz";
for(int i=0; i<9; i++)
for (int i=0; i<9; ++i)
{
os << fieldName << "_" << i << " ";
}
os << endl;
// Write data
forAll(values, elemI)
if (values.size() == points.size())
{
const tensor& v = values[elemI];
if (values.size() == points.size())
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const tensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
}
else
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
}
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
const tensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2]
<< v[3] << ' ' << v[4] << ' ' << v[5]
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
}
}
}
@ -330,8 +296,66 @@ Foam::rawSurfaceWriter<Type>::~rawSurfaceWriter()
template<class Type>
void Foam::rawSurfaceWriter<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
{
if (!isDir(outputDir))
{
mkDir(outputDir);
}
OFstream os
(
outputDir/surfaceName + ".raw"
);
if (verbose)
{
Info<< "Writing geometry to " << os.name() << endl;
}
// header
os << "# geometry NO_DATA " << faces.size() << nl
<< "# x y z" << endl;
// Write faces
forAll(faces, elemI)
{
writeGeometry(points, faces, elemI, os);
os << nl;
}
os << nl;
}
namespace Foam
{
// bool fields aren't supported
template<>
void Foam::rawSurfaceWriter<bool>::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const fileName& fieldName,
const Field<bool>& values,
const bool verbose
) const
{}
}
template<class Type>
void Foam::rawSurfaceWriter<Type>::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
@ -340,21 +364,35 @@ void Foam::rawSurfaceWriter<Type>::write
const bool verbose
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!isDir(surfaceDir))
if (!isDir(outputDir))
{
mkDir(surfaceDir);
mkDir(outputDir);
}
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".raw");
OFstream os
(
outputDir/fieldName + '_' + surfaceName + ".raw"
);
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << fName << endl;
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
}
OFstream os(fName);
// header
os << "# " << fieldName;
if (values.size() == points.size())
{
os << " POINT_DATA ";
}
else
{
os << " FACE_DATA ";
}
os << values.size() << nl;
writeData(fieldName, points, faces, values, os);
}

View File

@ -53,65 +53,65 @@ class rawSurfaceWriter
{
// Private Member Functions
void writeGeometry
static void writeGeometry
(
const pointField& points,
const label& pointI,
const label pointI,
Ostream& os
) const;
);
void writeGeometry
static void writeGeometry
(
const pointField& points,
const faceList& faces,
const label& faceI,
const label faceI,
Ostream& os
) const;
);
void writeData
static void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const scalarField& values,
Ostream& os
) const;
);
void writeData
static void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const vectorField& values,
Ostream& os
) const;
);
void writeData
static void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const sphericalTensorField& values,
Ostream& os
) const;
);
void writeData
static void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const symmTensorField& values,
Ostream& os
) const;
);
void writeData
static void writeData
(
const fileName& fieldName,
const pointField& points,
const faceList& faces,
const tensorField& values,
Ostream& os
) const;
);
public:
@ -135,11 +135,20 @@ public:
// Write
//- Write geometry to file.
virtual void write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose = false
) const;
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,

View File

@ -35,6 +35,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(rawSurfaceWriter, bool);
makeSurfaceWriters(rawSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,54 +25,83 @@ License
\*---------------------------------------------------------------------------*/
#include "surfaceWriter.H"
#include "MeshedSurfaceProxy.H"
#include "nullSurfaceWriter.H"
#include "proxySurfaceWriter.H"
#include "HashTable.H"
#include "word.H"
#include "fileName.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
autoPtr<surfaceWriter<Type> > surfaceWriter<Type>::New(const word& writeType)
Foam::autoPtr< Foam::surfaceWriter<Type> >
Foam::surfaceWriter<Type>::New(const word& writeType)
{
typename wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_
->find(writeType);
wordConstructorTablePtr_->find(writeType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
// not supported for this data type, but it generally does work
// (it handles the 'bool' specialization - ie, geometry write)
if
(
"surfaceWriter::New(const word&)"
) << "Unknown write type " << writeType
<< endl << endl
<< "Valid write types : " << endl
<< wordConstructorTablePtr_->toc()
<< exit(FatalError);
Foam::surfaceWriter<bool>::wordConstructorTablePtr_->found
(
writeType
)
)
{
// use 'null' handler instead
return autoPtr< surfaceWriter<Type> >
(
new nullSurfaceWriter<Type>()
);
}
else if (MeshedSurfaceProxy<face>::canWriteType(writeType))
{
// generally unknown, but can be written via MeshedSurfaceProxy
// use 'proxy' handler instead
return autoPtr< surfaceWriter<Type> >
(
new proxySurfaceWriter<Type>(writeType)
);
}
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"surfaceWriter::New(const word&)"
) << "Unknown write type \"" << writeType << "\"\n\n"
<< "Valid write types : "
<< wordConstructorTablePtr_->toc() << nl
<< "Valid proxy types : "
<< MeshedSurfaceProxy<face>::writeTypes() << endl
<< exit(FatalError);
}
}
return autoPtr<surfaceWriter<Type> >(cstrIter()());
return autoPtr< surfaceWriter<Type> >(cstrIter()());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
surfaceWriter<Type>::surfaceWriter()
Foam::surfaceWriter<Type>::surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
surfaceWriter<Type>::~surfaceWriter()
Foam::surfaceWriter<Type>::~surfaceWriter()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -37,23 +37,33 @@ SourceFiles
#include "Field.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "pointField.H"
#include "faceList.H"
#include "fileName.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class Type> class surfaceWriter;
template<class Type> class nullSurfaceWriter;
template<class Type> class proxySurfaceWriter;
/*---------------------------------------------------------------------------*\
Class surfaceWriter Declaration
Class surfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class surfaceWriter
{
//- friendship between writer data types
template<class Type2> friend class surfaceWriter;
public:
@ -91,12 +101,30 @@ public:
// Member Functions
//- Return true if the surface format supports separate files
virtual bool separateFiles()
{
return false;
}
//- Writes single surface geometry to file.
virtual void write
(
const fileName& outputDir, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const bool verbose = false
) const
{}
//- Writes single surface to file. Either one value per vertex or
// one value per face (detected by values.size()==faces.size())
virtual void write
(
const fileName& samplePath, // <root>/<case>/sampleSurfaces
const fileName& timeDir, // time directory
const fileName& outputDir, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,

View File

@ -33,8 +33,10 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define defineSurfaceWriterType(dataType) \
defineNamedTemplateTypeNameAndDebug(surfaceWriter<dataType >, 0); \
defineTemplatedRunTimeSelectionTable(surfaceWriter, word, dataType);
defineNamedTemplateTypeNameAndDebug(surfaceWriter< dataType >, 0); \
defineTemplatedRunTimeSelectionTable(surfaceWriter, word, dataType)
defineSurfaceWriterType(bool);
defineSurfaceWriterType(scalar);
defineSurfaceWriterType(vector);

View File

@ -39,7 +39,7 @@ Description
// Only used internally
#define makeTypeSurfaceWritersTypeName(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter<dataType >, 0);
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0)
// Sometimes used externally
#define makeSurfaceWritersTypeName(typeWriter) \
@ -48,16 +48,16 @@ Description
makeTypeSurfaceWritersTypeName(typeWriter, vector); \
makeTypeSurfaceWritersTypeName(typeWriter, sphericalTensor); \
makeTypeSurfaceWritersTypeName(typeWriter, symmTensor); \
makeTypeSurfaceWritersTypeName(typeWriter, tensor);
makeTypeSurfaceWritersTypeName(typeWriter, tensor)
// Define type info for single dataType template instantiation (eg, vector)
#define makeSurfaceWriterType(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter<dataType >, 0); \
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0); \
addTemplatedToRunTimeSelectionTable \
( \
surfaceWriter, typeWriter, dataType, word \
);
)
// Define type info for scalar, vector etc. instantiations
@ -67,7 +67,7 @@ Description
makeSurfaceWriterType(typeWriter, vector); \
makeSurfaceWriterType(typeWriter, sphericalTensor); \
makeSurfaceWriterType(typeWriter, symmTensor); \
makeSurfaceWriterType(typeWriter, tensor);
makeSurfaceWriterType(typeWriter, tensor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,9 +25,8 @@ License
\*---------------------------------------------------------------------------*/
#include "vtkSurfaceWriter.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -35,13 +34,12 @@ License
template<class Type>
void Foam::vtkSurfaceWriter<Type>::writeGeometry
(
Ostream& os,
const pointField& points,
const faceList& faces,
Ostream& os
) const
const faceList& faces
)
{
// Write vertex coordinates
// header
os
<< "# vtk DataFile Version 2.0" << nl
<< "sampleSurface" << nl
@ -57,7 +55,7 @@ void Foam::vtkSurfaceWriter<Type>::writeGeometry
<< float(pt.y()) << ' '
<< float(pt.z()) << nl;
}
os << endl;
os << nl;
// Write faces
@ -84,193 +82,133 @@ void Foam::vtkSurfaceWriter<Type>::writeGeometry
}
// Write scalarField in vtk format
template<class Type>
void Foam::vtkSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const scalarField& values,
Ostream& os
) const
namespace Foam
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 1 " << values.size() << " float" << nl;
forAll(values, elemI)
// Write scalarField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::scalar>::writeData
(
Ostream& os,
const Field<Foam::scalar>& values
)
{
if (elemI)
os << "1 " << values.size() << " float" << nl;
forAll(values, elemI)
{
if (elemI % 10)
if (elemI)
{
os << ' ';
}
else
{
os << nl;
if (elemI % 10)
{
os << ' ';
}
else
{
os << nl;
}
}
const scalar& v = values[elemI];
os << float(v);
}
os << float(values[elemI]);
os << nl;
}
os << nl;
// Write vectorField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::vector>::writeData
(
Ostream& os,
const Field<Foam::vector>& values
)
{
os << "3 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const vector& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< nl;
}
}
// Write sphericalTensorField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::sphericalTensor>::writeData
(
Ostream& os,
const Field<sphericalTensor>& values
)
{
os << "1 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const sphericalTensor& v = values[elemI];
os << float(v[0]) << nl;
}
}
// Write symmTensorField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::symmTensor>::writeData
(
Ostream& os,
const Field<symmTensor>& values
)
{
os << "6 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const symmTensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
<< nl;
}
}
// Write tensorField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::tensor>::writeData
(
Ostream& os,
const Field<tensor>& values
)
{
os << "9 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const tensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
<< float(v[6]) << ' ' << float(v[7]) << ' ' << float(v[8])
<< nl;
}
}
}
// Write vectorField in vtk format
// Write generic field in vtk format
template<class Type>
void Foam::vtkSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const vectorField& values,
Ostream& os
) const
Ostream& os,
const Field<Type>& values
)
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 3 " << values.size() << " float" << nl;
os << "1 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const vector& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2]) << nl;
}
}
// Write sphericalTensorField in vtk format
template<class Type>
void Foam::vtkSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 1 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const sphericalTensor& v = values[elemI];
os << float(v[0])
<< nl;
}
}
// Write symmTensorField in vtk format
template<class Type>
void Foam::vtkSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const symmTensorField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 6 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const symmTensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
<< nl;
}
}
// Write tensorField in vtk format
template<class Type>
void Foam::vtkSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
const tensorField& values,
Ostream& os
) const
{
// Write data
if (values.size() == points.size())
{
os << "POINT_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
else
{
os << "CELL_DATA " << values.size()
<< nl
<< "FIELD attributes 1" << nl;
}
os << fieldName << " 9 " << values.size() << " float" << nl;
forAll(values, elemI)
{
const tensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
<< float(v[6]) << ' ' << float(v[7]) << ' ' << float(v[8])
<< nl;
os << float(0) << nl;
}
}
@ -297,8 +235,34 @@ Foam::vtkSurfaceWriter<Type>::~vtkSurfaceWriter()
template<class Type>
void Foam::vtkSurfaceWriter<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
{
if (!isDir(outputDir))
{
mkDir(outputDir);
}
fileName fName(outputDir/surfaceName + ".vtk");
if (verbose)
{
Info<< "Writing geometry to " << fName << endl;
}
OFstream os(fName);
writeGeometry(os, points, faces);
}
template<class Type>
void Foam::vtkSurfaceWriter<Type>::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
@ -307,24 +271,40 @@ void Foam::vtkSurfaceWriter<Type>::write
const bool verbose
) const
{
fileName surfaceDir(samplePath/timeDir);
if (!isDir(surfaceDir))
if (!isDir(outputDir))
{
mkDir(surfaceDir);
mkDir(outputDir);
}
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".vtk");
OFstream os
(
outputDir/fieldName + '_' + surfaceName + ".vtk"
);
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << fName << endl;
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
}
OFstream os(fName);
writeGeometry(os, points, faces);
// start writing data
if (values.size() == points.size())
{
os << "POINT_DATA ";
}
else
{
os << "CELL_DATA ";
}
os << values.size() << nl
<< "FIELD attributes 1" << nl
<< fieldName << " ";
// Write data
writeData(os, values);
writeGeometry(points, faces, os);
writeData(fieldName, points, values, os);
}

View File

@ -53,52 +53,9 @@ class vtkSurfaceWriter
{
// Private Member Functions
void writeGeometry
(
const pointField& points,
const faceList& faces,
Ostream& os
) const;
static void writeGeometry(Ostream&, const pointField&, const faceList&);
void writeData
(
const fileName& fieldName,
const pointField& points,
const scalarField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const vectorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const sphericalTensorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const symmTensorField& values,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
const pointField& points,
const tensorField& values,
Ostream& os
) const;
static void writeData(Ostream&, const Field<Type>& values);
public:
@ -122,11 +79,21 @@ public:
// Write
//- Write geometry to file.
virtual void write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose = false
) const;
//- Writes single surface to file.
virtual void write
(
const fileName& samplePath,
const fileName& timeDir,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,

View File

@ -35,6 +35,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(vtkSurfaceWriter, bool);
makeSurfaceWriters(vtkSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,572 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "BasicMeshedSurface.H"
#include "boundBox.H"
#include "mergePoints.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face>
inline bool Foam::BasicMeshedSurface<Face>::isTri()
{
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::BasicMeshedSurface<Face>::BasicMeshedSurface()
:
ParentType(List<Face>(), pointField())
{}
template<class Face>
Foam::BasicMeshedSurface<Face>::BasicMeshedSurface
(
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst
)
:
ParentType(List<Face>(), pointField())
{
reset(pointLst, faceLst);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Face>
Foam::BasicMeshedSurface<Face>::~BasicMeshedSurface()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Face>
void Foam::BasicMeshedSurface<Face>::clear()
{
ParentType::clearOut();
storedPoints().clear();
storedFaces().clear();
}
template<class Face>
void Foam::BasicMeshedSurface<Face>::movePoints(const pointField& newPoints)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(newPoints);
// Copy new points
storedPoints() = newPoints;
}
template<class Face>
void Foam::BasicMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
{
// avoid bad scaling
if (scaleFactor > 0 && scaleFactor != 1.0)
{
// Remove all geometry dependent data
ParentType::clearTopology();
// Adapt for new point position
ParentType::movePoints(pointField());
storedPoints() *= scaleFactor;
}
}
template<class Face>
void Foam::BasicMeshedSurface<Face>::reset
(
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst
)
{
ParentType::clearOut();
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (&pointLst)
{
storedPoints().transfer(pointLst());
}
if (&faceLst)
{
storedFaces().transfer(faceLst());
}
}
template<class Face>
void Foam::BasicMeshedSurface<Face>::reset
(
const Xfer< List<point> >& pointLst,
const Xfer< List<Face> >& faceLst
)
{
ParentType::clearOut();
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (&pointLst)
{
storedPoints().transfer(pointLst());
}
if (&faceLst)
{
storedFaces().transfer(faceLst());
}
}
// Remove badly degenerate faces, double faces.
template<class Face>
void Foam::BasicMeshedSurface<Face>::cleanup(const bool verbose)
{
// merge points (already done for STL, TRI)
stitchFaces(SMALL, verbose);
checkFaces(verbose);
this->checkTopology(verbose);
}
template<class Face>
bool Foam::BasicMeshedSurface<Face>::stitchFaces
(
const scalar tol,
const bool verbose
)
{
pointField& pointLst = this->storedPoints();
// Merge points
labelList pointMap(pointLst.size());
pointField newPoints(pointLst.size());
bool hasMerged = mergePoints(pointLst, tol, verbose, pointMap, newPoints);
if (!hasMerged)
{
return false;
}
if (verbose)
{
Info<< "BasicMeshedSurface::stitchFaces : Renumbering all faces"
<< endl;
}
// Set the coordinates to the merged ones
pointLst.transfer(newPoints);
List<Face>& faceLst = this->storedFaces();
List<label> faceMap(faceLst.size());
// Reset the point labels to the unique points array
label newFaceI = 0;
forAll(faceLst, faceI)
{
Face& f = faceLst[faceI];
forAll(f, fp)
{
f[fp] = pointMap[f[fp]];
}
// for extra safety: collapse face as well
if (f.collapse() >= 3)
{
if (newFaceI != faceI)
{
faceLst[newFaceI] = f;
}
faceMap[newFaceI] = faceI;
newFaceI++;
}
else if (verbose)
{
Pout<< "BasicMeshedSurface::stitchFaces : "
<< "Removing collapsed face " << faceI << endl
<< " vertices :" << f << endl;
}
}
pointMap.clear();
if (newFaceI != faceLst.size())
{
if (verbose)
{
Pout<< "BasicMeshedSurface::stitchFaces : "
<< "Removed " << faceLst.size() - newFaceI
<< " faces" << endl;
}
faceLst.setSize(newFaceI);
remapFaces(faceMap);
}
faceMap.clear();
// Merging points might have changed geometric factors
ParentType::clearOut();
return true;
}
// Remove badly degenerate faces and double faces.
template<class Face>
bool Foam::BasicMeshedSurface<Face>::checkFaces
(
const bool verbose
)
{
bool changed = false;
List<Face>& faceLst = this->storedFaces();
List<label> faceMap(faceLst.size());
label newFaceI = 0;
// Detect badly labelled faces and mark degenerate faces
const label maxPointI = this->points().size() - 1;
forAll(faceLst, faceI)
{
Face& f = faceLst[faceI];
// avoid degenerate faces
if (f.collapse() >= 3)
{
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] > maxPointI)
{
FatalErrorIn("BasicMeshedSurface::checkFaces(bool)")
<< "face " << f
<< " uses point indices outside point range 0.."
<< maxPointI
<< exit(FatalError);
}
}
faceMap[faceI] = faceI;
newFaceI++;
}
else
{
// mark as bad face
faceMap[faceI] = -1;
changed = true;
if (verbose)
{
WarningIn
(
"BasicMeshedSurface::checkFaces(bool verbose)"
) << "face[" << faceI << "] = " << f
<< " does not have three unique vertices" << endl;
}
}
}
// Detect doubled faces
// do not touch the faces
const labelListList& fFaces = this->faceFaces();
newFaceI = 0;
forAll(faceLst, faceI)
{
// skip already collapsed faces:
if (faceMap[faceI] < 0)
{
continue;
}
const Face& f = faceLst[faceI];
// duplicate face check
bool okay = true;
const labelList& neighbours = fFaces[faceI];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(neighbours, neighI)
{
const label neiFaceI = neighbours[neighI];
if (neiFaceI <= faceI || faceMap[neiFaceI] < 0)
{
// lower numbered faces already checked
// skip neighbours that are themselves collapsed
continue;
}
const Face& nei = faceLst[neiFaceI];
if (f == nei)
{
okay = false;
if (verbose)
{
WarningIn
(
"BasicMeshedSurface::checkFaces(bool verbose)"
) << "faces share the same vertices:" << nl
<< " face[" << faceI << "] : " << f << nl
<< " face[" << neiFaceI << "] : " << nei << endl;
// printFace(Warning, " ", f, points());
// printFace(Warning, " ", nei, points());
}
break;
}
}
if (okay)
{
faceMap[faceI] = faceI;
newFaceI++;
}
else
{
faceMap[faceI] = -1;
}
}
// Phase 1: pack
// Done to keep numbering constant in phase 1
if (changed || newFaceI < faceLst.size())
{
changed = true;
if (verbose)
{
WarningIn
(
"BasicMeshedSurface::checkFaces(bool verbose)"
) << "Removed " << faceLst.size() - newFaceI
<< " illegal faces." << endl;
}
// compress the face list
newFaceI = 0;
forAll(faceLst, faceI)
{
if (faceMap[faceI] >= 0)
{
if (newFaceI != faceI)
{
faceLst[newFaceI] = faceLst[faceI];
}
faceMap[newFaceI] = faceI;
newFaceI++;
}
}
faceLst.setSize(newFaceI);
remapFaces(faceMap);
}
faceMap.clear();
// Topology can change because of renumbering
ParentType::clearOut();
return changed;
}
template<class Face>
Foam::label Foam::BasicMeshedSurface<Face>::triangulate()
{
return triangulate
(
const_cast<List<label>&>(List<label>::null())
);
}
template<class Face>
Foam::label Foam::BasicMeshedSurface<Face>::triangulate
(
List<label>& faceMapOut
)
{
label nTri = 0;
label maxTri = 0; // the maximum number of triangles for any single face
List<Face>& faceLst = this->storedFaces();
// determine how many triangles will be needed
forAll(faceLst, faceI)
{
const label n = faceLst[faceI].nTriangles();
if (maxTri < n)
{
maxTri = n;
}
nTri += n;
}
// nothing to do
if (nTri <= faceLst.size())
{
if (&faceMapOut)
{
faceMapOut.clear();
}
return 0;
}
List<Face> newFaces(nTri);
List<label> faceMap;
// reuse storage from optional faceMap
if (&faceMapOut)
{
faceMap.transfer(faceMapOut);
}
faceMap.setSize(nTri);
// remember the number of *additional* faces
nTri -= faceLst.size();
if (this->points().empty())
{
// triangulate without points
// simple face triangulation around f[0]
label newFaceI = 0;
forAll(faceLst, faceI)
{
const Face& f = faceLst[faceI];
for (label fp = 1; fp < f.size() - 1; ++fp)
{
label fp1 = f.fcIndex(fp);
newFaces[newFaceI] = triFace(f[0], f[fp], f[fp1]);
faceMap[newFaceI] = faceI;
newFaceI++;
}
}
}
else
{
// triangulate with points
List<face> tmpTri(maxTri);
label newFaceI = 0;
forAll(faceLst, faceI)
{
// 'face' not '<Face>'
const face& f = faceLst[faceI];
label nTmp;
f.triangles(this->points(), nTmp, tmpTri);
for (label triI = 0; triI < nTmp; triI++)
{
newFaces[newFaceI] = Face
(
static_cast<UList<label>&>(tmpTri[triI])
);
faceMap[newFaceI] = faceI;
newFaceI++;
}
}
}
faceLst.transfer(newFaces);
remapFaces(faceMap);
// optionally return the faceMap
if (&faceMapOut)
{
faceMapOut.transfer(faceMap);
}
faceMap.clear();
// Topology can change because of renumbering
ParentType::clearOut();
return nTri;
}
// dummy implementation to avoid a pure virtual class
template<class Face>
void Foam::BasicMeshedSurface<Face>::remapFaces(const UList<label>&)
{
}
template<class Face>
void Foam::BasicMeshedSurface<Face>::writeStats(Ostream& os) const
{
os << "points : " << this->points().size() << nl;
if (this->isTri())
{
os << "triangles : " << this->size() << nl;
}
else
{
label nTri = 0;
label nQuad = 0;
forAll(*this, i)
{
const label n = this->operator[](i).size();
if (n == 3)
{
nTri++;
}
else if (n == 4)
{
nQuad++;
}
}
os << "faces : " << this->size()
<< " (tri:" << nTri << " quad:" << nQuad
<< " poly:" << (this->size() - nTri - nQuad ) << ")" << nl;
}
os << "boundingBox : " << boundBox(this->points()) << endl;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -1,223 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::BasicMeshedSurface
Description
Holds surfaces without any zone information
SourceFiles
BasicMeshedSurface.C
\*---------------------------------------------------------------------------*/
#ifndef BasicMeshedSurface_H
#define BasicMeshedSurface_H
#include "PrimitivePatch.H"
#include "PatchTools.H"
#include "pointField.H"
#include "face.H"
#include "triFace.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
/*---------------------------------------------------------------------------*\
Class BasicMeshedSurface Declaration
\*---------------------------------------------------------------------------*/
template<class Face>
class BasicMeshedSurface
:
public PrimitivePatch<Face, ::Foam::List, pointField, point>
{
// Private typedefs
typedef PrimitivePatch
<
Face,
::Foam::List,
pointField,
point
>
ParentType;
protected:
// Protected Member Functions
//- Non-const access to global points
pointField& storedPoints()
{
return const_cast<pointField&>(ParentType::points());
}
//- Non-const access to the faces
List<Face>& storedFaces()
{
return static_cast<List<Face> &>(*this);
}
//- Set new zones from faceMap
virtual void remapFaces(const UList<label>& faceMap);
public:
// Static
//- Face storage only handles triangulated faces
inline static bool isTri();
// Constructors
//- Construct null
BasicMeshedSurface();
//- Construct by transferring components (points, faces).
BasicMeshedSurface
(
const Xfer< pointField >&,
const Xfer< List<Face> >&
);
// Destructor
virtual ~BasicMeshedSurface();
// Member Functions
// Access
//- Return const access to the faces
inline const List<Face>& faces() const
{
return static_cast<const List<Face> &>(*this);
}
// Edit
//- Clear all storage
virtual void clear();
//- Move points
virtual void movePoints(const pointField&);
//- Scale points. A non-positive factor is ignored
virtual void scalePoints(const scalar&);
//- Transfer components (points, faces).
virtual void reset
(
const Xfer< pointField >&,
const Xfer< List<Face> >&
);
//- Transfer components (points, faces).
virtual void reset
(
const Xfer< List<point> >&,
const Xfer< List<Face> >&
);
//- Remove invalid faces
virtual void cleanup(const bool verbose);
virtual bool stitchFaces
(
const scalar tol=SMALL,
const bool verbose=false
);
virtual bool checkFaces
(
const bool verbose=false
);
//- Triangulate in-place, returning the number of triangles added
virtual label triangulate();
//- Triangulate in-place, returning the number of triangles added
// and setting a map of original face Ids.
// The faceMap is zero-sized when no triangulation was done.
virtual label triangulate(List<label>& faceMap);
// Write
void writeStats(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Specialization for holding triangulated information
template<>
inline bool BasicMeshedSurface<triFace>::isTri()
{
return true;
}
//- Specialization for holding triangulated information
template<>
inline label BasicMeshedSurface<triFace>::triangulate()
{
return 0;
}
//- Specialization for holding triangulated information
template<>
inline label BasicMeshedSurface<triFace>::triangulate(List<label>& faceMap)
{
if (&faceMap)
{
faceMap.clear();
}
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "BasicMeshedSurface.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,16 +2,20 @@ surfZone/surfZone/surfZone.C
surfZone/surfZone/surfZoneIOList.C
surfZone/surfZoneIdentifier/surfZoneIdentifier.C
MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C
MeshedSurface/MeshedSurfaceCore.C
MeshedSurface/MeshedSurfaces.C
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
MeshedSurfaceProxy/MeshedSurfaceProxyCore.C
surfaceRegistry/surfaceRegistry.C
surfFields/surfFields.C
surfPointFields/surfPointFields.C
surfMesh/surfMesh.C
surfMesh/surfMeshClear.C
surfMesh/surfMeshIO.C
surfFields/surfFields/surfFields.C
surfFields/surfPointFields/surfPointFields.C
surfaceFormats = surfaceFormats
$(surfaceFormats)/surfaceFormatsCore.C
@ -22,11 +26,10 @@ $(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C
$(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C
$(surfaceFormats)/nas/NASsurfaceFormatCore.C
$(surfaceFormats)/nas/NASsurfaceFormatRunTime.C
$(surfaceFormats)/obj/OBJsurfaceFormatCore.C
$(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C
$(surfaceFormats)/off/OFFsurfaceFormatCore.C
$(surfaceFormats)/off/OFFsurfaceFormatRunTime.C
$(surfaceFormats)/smesh/SMESHsurfaceFormatCore.C
$(surfaceFormats)/ofs/OFSsurfaceFormatCore.C
$(surfaceFormats)/ofs/OFSsurfaceFormatRunTime.C
$(surfaceFormats)/smesh/SMESHsurfaceFormatRunTime.C
$(surfaceFormats)/starcd/STARCDsurfaceFormatCore.C
$(surfaceFormats)/starcd/STARCDsurfaceFormatRunTime.C
@ -37,6 +40,10 @@ $(surfaceFormats)/tri/TRIsurfaceFormatCore.C
$(surfaceFormats)/tri/TRIsurfaceFormatRunTime.C
$(surfaceFormats)/vtk/VTKsurfaceFormatCore.C
$(surfaceFormats)/vtk/VTKsurfaceFormatRunTime.C
$(surfaceFormats)/wrl/WRLsurfaceFormatCore.C
$(surfaceFormats)/wrl/WRLsurfaceFormatRunTime.C
$(surfaceFormats)/x3d/X3DsurfaceFormatCore.C
$(surfaceFormats)/x3d/X3DsurfaceFormatRunTime.C
LIB = $(FOAM_LIBBIN)/libsurfMesh

File diff suppressed because it is too large Load Diff

View File

@ -26,15 +26,19 @@ Class
Foam::MeshedSurface
Description
A surface geometry mesh with zone information, not to be confused
with a similarily named surfaceMesh, which actually refers to
the cell faces of a volume mesh.
A surface geometry mesh with zone information, not to be confused with
the similarly named surfaceMesh, which actually refers to the cell faces
of a volume mesh.
The MeshedSurface is intended for surfaces from a variety of sources.
- A set of points and faces without any surface zone information.
- A set of points and faces with randomly ordered zone information.
This could arise, for example, from reading external file formats
such as STL, etc.
A MeshedSurface can have zero or more surface zones (roughly equivalent
to faceZones for a polyMesh). If surface zones are defined, they must
be contiguous and cover all of the faces.
The MeshedSurface is intended for surfaces from a variety of sources.
- A set of points and faces without any surface zone information.
- A set of points and faces with randomly ordered zone information.
This could arise, for example, from reading external file formats
such as STL, etc.
SourceFiles
MeshedSurface.C
@ -44,7 +48,12 @@ SourceFiles
#ifndef MeshedSurface_H
#define MeshedSurface_H
#include "BasicMeshedSurface.H"
#include "PrimitivePatch.H"
#include "PatchTools.H"
#include "pointField.H"
#include "face.H"
#include "triFace.H"
#include "surfZoneList.H"
#include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H"
@ -60,14 +69,11 @@ namespace Foam
class Time;
class surfMesh;
template<class Face> class MeshedSurface;
template<class Face> class UnsortedMeshedSurface;
class polyBoundaryMesh;
class surfMesh;
template<class Face>
Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
template<class Face> class MeshedSurface;
template<class Face> class MeshedSurfaceProxy;
template<class Face> class UnsortedMeshedSurface;
/*---------------------------------------------------------------------------*\
Class MeshedSurface Declaration
@ -76,24 +82,29 @@ Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
template<class Face>
class MeshedSurface
:
public BasicMeshedSurface<Face>,
public PrimitivePatch<Face, ::Foam::List, pointField, point>,
public fileFormats::surfaceFormatsCore
{
// friends despite different faces
template<class Face2>
friend class MeshedSurface;
// friends despite different faces
template<class Face2>
friend class UnsortedMeshedSurface;
// friends - despite different face representationsx
template<class Face2> friend class MeshedSurface;
template<class Face2> friend class UnsortedMeshedSurface;
friend class surfMesh;
private:
//- Private typedefs for convenience
typedef BasicMeshedSurface<Face> ParentType;
typedef UnsortedMeshedSurface<Face> SiblingType;
typedef PrimitivePatch
<
Face,
::Foam::List,
pointField,
point
>
ParentType;
typedef UnsortedMeshedSurface<Face> FriendType;
typedef MeshedSurfaceProxy<Face> ProxyType;
// Private Member Data
@ -101,21 +112,31 @@ private:
// (face ordering nFaces/startFace only used during reading/writing)
List<surfZone> zones_;
// Private member functions
//- Read OpenFOAM Surface format
bool read(Istream&);
//- Transfer points/zones and transcribe face -> triFace
void transcribe(MeshedSurface<face>&);
protected:
// Protected Member functions
//- Transfer points/zones and transcribe face -> triFace
void transcribe(MeshedSurface<face>&);
//- basic sanity check on zones
void checkZones();
//- Non-const access to global points
pointField& storedPoints()
{
return const_cast<pointField&>(ParentType::points());
}
//- Non-const access to the faces
List<Face>& storedFaces()
{
return static_cast<List<Face> &>(*this);
}
//- Non-const access to the zones
surfZoneList& storedZones()
{
@ -125,8 +146,8 @@ protected:
//- sort faces by zones and store sorted faces
void sortFacesAndStore
(
const Xfer<List<Face> >& unsortedFaces,
const Xfer<List<label> >& zoneIds,
const Xfer< List<Face> >& unsortedFaces,
const Xfer< List<label> >& zoneIds,
const bool sorted
);
@ -140,6 +161,9 @@ public:
// Static
//- Face storage only handles triangulated faces
inline static bool isTri();
//- Can we read this file format?
static bool canRead(const fileName&, const bool verbose=false);
@ -160,21 +184,27 @@ public:
//- Construct by transferring components (points, faces, zones).
MeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const Xfer<surfZoneList>&
const Xfer< pointField >&,
const Xfer< List<Face> >&,
const Xfer< surfZoneList >&
);
//- Construct by transferring points, faces.
// Use zone information, or set single default zone.
//- Construct by transferring components (points, faces).
// Use zone information if available
MeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const UList<label>& zoneSizes = UList<label>::null(),
const UList<word>& zoneNames = UList<word>::null()
const Xfer< pointField >&,
const Xfer< List<Face> >&,
const UList<label>& zoneSizes = UList<label>(),
const UList<word>& zoneNames = UList<word>()
);
//- Construct as copy
MeshedSurface(const MeshedSurface&);
//- Construct from a UnsortedMeshedSurface
MeshedSurface(const UnsortedMeshedSurface<Face>&);
//- Construct from a boundary mesh with local points/faces
MeshedSurface
(
@ -182,9 +212,6 @@ public:
const bool globalPoints=false
);
//- Construct from a UnsortedMeshedSurface
MeshedSurface(const UnsortedMeshedSurface<Face>&);
//- Construct from a surfMesh
MeshedSurface(const surfMesh&);
@ -200,15 +227,9 @@ public:
//- Construct from file name (uses extension to determine type)
MeshedSurface(const fileName&, const word& ext);
//- Construct from Istream
MeshedSurface(Istream&);
//- Construct from objectRegistry
//- Construct from database
MeshedSurface(const Time&, const word& surfName="");
//- Construct as copy
MeshedSurface(const MeshedSurface&);
// Declare run-time constructor selection table
declareRunTimeSelectionTable
@ -244,7 +265,7 @@ public:
declareMemberFunctionSelectionTable
(
void,
MeshedSurface,
UnsortedMeshedSurface,
write,
fileExtension,
(
@ -268,41 +289,98 @@ public:
return ParentType::size();
}
const List<surfZone>& zones() const
//- Return const access to the faces
inline const List<Face>& faces() const
{
return static_cast<const List<Face> &>(*this);
}
//- Const access to the surface zones.
// If zones are defined, they must be contiguous and cover the entire
// surface.
const List<surfZone>& surfZones() const
{
return zones_;
}
//- set a single zone, optionally with a specific name
void oneZone(const word& name = word::null);
//- Add zones
void addZones
//- Add surface zones
virtual void addZones
(
const UList<surfZone>&,
const bool cullEmpty=false
);
//- Add zones
void addZones
//- Add surface zones
virtual void addZones
(
const UList<label>& sizes,
const UList<word>& names,
const bool cullEmpty=false
);
//- Add zones
void addZones
//- Add surface zones
virtual void addZones
(
const UList<label>& sizes,
const bool cullEmpty=false
);
//- Remove surface zones
virtual void removeZones();
// Edit
//- Clear all storage
virtual void clear();
//- Move points
virtual void movePoints(const pointField&);
//- Scale points. A non-positive factor is ignored
virtual void scalePoints(const scalar&);
//- Reset primitive data (points, faces and zones)
// Note, optimized to avoid overwriting data (with Xfer::null)
virtual void reset
(
const Xfer< pointField >& points,
const Xfer< List<Face> >& faces,
const Xfer< surfZoneList >& zones
);
//- Reset primitive data (points, faces and zones)
// Note, optimized to avoid overwriting data (with Xfer::null)
virtual void reset
(
const Xfer< List<point> >& points,
const Xfer< List<Face> >& faces,
const Xfer< surfZoneList >& zones
);
//- Remove invalid faces
virtual void cleanup(const bool verbose);
virtual bool stitchFaces
(
const scalar tol=SMALL,
const bool verbose=false
);
virtual bool checkFaces
(
const bool verbose=false
);
//- Triangulate in-place, returning the number of triangles added
virtual label triangulate();
//- Triangulate in-place, returning the number of triangles added
// and setting a map of original face Ids.
// The faceMap is zero-sized when no triangulation was done.
virtual label triangulate(List<label>& faceMap);
//- Return new surface.
// Returns return pointMap, faceMap from subsetMeshMap
MeshedSurface subsetMesh
@ -338,8 +416,7 @@ public:
// Write
//- Write to Ostream in simple FOAM format
virtual void write(Ostream&) const;
void writeStats(Ostream& os) const;
//- Generic write routine. Chooses writer based on extension.
virtual void write(const fileName& name) const
@ -355,17 +432,40 @@ public:
void operator=(const MeshedSurface<Face>&);
// Ostream Operator
//- Conversion operator to MeshedSurfaceProxy
operator MeshedSurfaceProxy<Face>() const;
friend Ostream& operator<<
<Face>
(
Ostream&,
const MeshedSurface<Face>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Specialization for holding triangulated information
template<>
inline bool MeshedSurface<triFace>::isTri()
{
return true;
}
//- Specialization for holding triangulated information
template<>
inline label MeshedSurface<triFace>::triangulate()
{
return 0;
}
//- Specialization for holding triangulated information
template<>
inline label MeshedSurface<triFace>::triangulate(List<label>& faceMap)
{
if (&faceMap)
{
faceMap.clear();
}
return 0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -38,7 +38,7 @@ namespace Foam
// first triangulate
surf.triangulate();
this->storedPoints().transfer(surf.storedPoints());
zones_.transfer(surf.zones_);
this->storedZones().transfer(surf.storedZones());
// transcribe from face -> triFace
List<face>& origFaces = surf.storedFaces();

View File

@ -25,117 +25,44 @@ License
\*---------------------------------------------------------------------------*/
#include "MeshedSurface.H"
#include "UnsortedMeshedSurface.H"
#include "IFstream.H"
#include "OFstream.H"
#include "boundBox.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Read surf grouping, points, faces directly from Istream
template<class Face>
bool Foam::MeshedSurface<Face>::read(Istream& is)
void Foam::MeshedSurface<Face>::writeStats(Ostream& os) const
{
clear();
List<surfZone> newZones(is);
// copy and set the indices
zones_.setSize(newZones.size());
forAll(newZones, zoneI)
os << "points : " << this->points().size() << nl;
if (MeshedSurface<Face>::isTri())
{
zones_[zoneI] = surfZone
(
newZones[zoneI],
zoneI
);
}
// read points:
is >> this->storedPoints();
// must triangulate?
if (this->isTri())
{
List<face> faceLst(is);
MeshedSurface<face> surf;
surf.reset
(
Xfer<pointField>::null(),
faceLst.xfer()
);
surf.addZones(zones_);
// this will break if the triangulation needed points
surf.triangulate();
zones_ = surf.zones();
// transcribe from face -> triFace (Face)
const List<face>& origFaces = surf.faces();
List<Face> newFaces(origFaces.size());
forAll(origFaces, faceI)
{
newFaces[faceI] = Face
(
static_cast<const UList<label>&>(origFaces[faceI])
);
}
surf.clear();
this->storedFaces().transfer(newFaces);
os << "triangles : " << this->size() << nl;
}
else
{
// read faces:
is >> this->storedFaces();
label nTri = 0;
label nQuad = 0;
forAll(*this, i)
{
const label n = this->operator[](i).size();
if (n == 3)
{
nTri++;
}
else if (n == 4)
{
nQuad++;
}
}
os << "faces : " << this->size()
<< " (tri:" << nTri << " quad:" << nQuad
<< " poly:" << (this->size() - nTri - nQuad ) << ")" << nl;
}
return is.good();
os << "boundingBox : " << boundBox(this->points()) << endl;
}
template<class Face>
void Foam::MeshedSurface<Face>::write(Ostream& os) const
{
// just emit some information until we get a nice IOobject
IOobject::writeBanner(os);
os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// zones:" << nl
<< zones_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(zones_, zoneI)
{
zones_[zoneI].writeDict(os);
}
os << decrIndent << token::END_LIST << nl;
IOobject::writeDivider(os);
// Note: Write with global point numbering
os << "\n// points:" << nl << this->points() << nl;
IOobject::writeDivider(os);
os << "\n// faces:" << nl << this->faces() << nl;
IOobject::writeDivider(os);
// Check state of Ostream
os.check("MeshedSurface::write(Ostream&)");
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Face>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
surf.write(os);
return os;
}
// ************************************************************************* //

View File

@ -31,7 +31,7 @@ License
template<class Face>
Foam::autoPtr<Foam::MeshedSurface<Face> >
Foam::autoPtr< Foam::MeshedSurface<Face> >
Foam::MeshedSurface<Face>::New(const fileName& name, const word& ext)
{
if (debug)
@ -47,19 +47,18 @@ Foam::MeshedSurface<Face>::New(const fileName& name, const word& ext)
if (cstrIter == fileExtensionConstructorTablePtr_->end())
{
// no direct reader, delegate if possible
wordHashSet supported = SiblingType::readTypes();
wordHashSet supported = FriendType::readTypes();
if (supported.found(ext))
{
// create indirectly
autoPtr<MeshedSurface<Face> > surf(new MeshedSurface<Face>);
surf().transfer(SiblingType::New(name, ext)());
autoPtr< MeshedSurface<Face> > surf(new MeshedSurface<Face>);
surf().transfer(FriendType::New(name, ext)());
return surf;
}
// nothing left to try, issue error
supported += readTypes();
supported.insert(nativeExt);
FatalErrorIn
(
@ -71,12 +70,12 @@ Foam::MeshedSurface<Face>::New(const fileName& name, const word& ext)
<< exit(FatalError);
}
return autoPtr<MeshedSurface<Face> >(cstrIter()(name));
return autoPtr< MeshedSurface<Face> >(cstrIter()(name));
}
template<class Face>
Foam::autoPtr<Foam::MeshedSurface<Face> >
Foam::autoPtr< Foam::MeshedSurface<Face> >
Foam::MeshedSurface<Face>::New(const fileName& name)
{
word ext = name.ext();

View File

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "MeshedSurface.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Face>
void Foam::MeshedSurface<Face>::checkZones()
{
// extra safety, ensure we have at some zones
// and they cover all the faces - fix start silently
surfZoneList& zones = this->storedZones();
if (zones.size())
{
label count = 0;
forAll(zones, zoneI)
{
zones[zoneI].start() = count;
count += zones[zoneI].size();
}
if (count < this->size())
{
WarningIn
(
"MeshedSurface::checkZones()\n"
)
<< "more faces " << this->size() << " than zones " << count
<< " ... extending final zone"
<< endl;
zones[zones.size()-1].size() += count - this->size();
}
else if (count > this->size())
{
FatalErrorIn
(
"MeshedSurface::checkZones()\n"
)
<< "more zones " << count << " than faces " << this->size()
<< exit(FatalError);
}
}
}
template<class Face>
void Foam::MeshedSurface<Face>::sortFacesAndStore
(
const Xfer< List<Face> >& unsortedFaces,
const Xfer< List<label> >& zoneIds,
const bool sorted
)
{
List<Face> oldFaces(unsortedFaces);
List<label> zones(zoneIds);
if (sorted)
{
// already sorted - simply transfer faces
this->storedFaces().transfer(oldFaces);
}
else
{
// unsorted - determine the sorted order:
// avoid SortableList since we discard the main list anyhow
List<label> faceMap;
sortedOrder(zones, faceMap);
zones.clear();
// sorted faces
List<Face> newFaces(faceMap.size());
forAll(faceMap, faceI)
{
// use transfer to recover memory where possible
newFaces[faceI].transfer(oldFaces[faceMap[faceI]]);
}
this->storedFaces().transfer(newFaces);
}
zones.clear();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Face>
void Foam::MeshedSurface<Face>::addZones
(
const UList<surfZone>& srfZones,
const bool cullEmpty
)
{
label nZone = 0;
surfZoneList& zones = this->storedZones();
zones.setSize(zones.size());
forAll(zones, zoneI)
{
if (srfZones[zoneI].size() || !cullEmpty)
{
zones[nZone] = surfZone(srfZones[zoneI], nZone);
nZone++;
}
}
zones.setSize(nZone);
}
template<class Face>
void Foam::MeshedSurface<Face>::addZones
(
const UList<label>& sizes,
const UList<word>& names,
const bool cullEmpty
)
{
label start = 0;
label nZone = 0;
surfZoneList& zones = this->storedZones();
zones.setSize(sizes.size());
forAll(zones, zoneI)
{
if (sizes[zoneI] || !cullEmpty)
{
zones[nZone] = surfZone
(
names[zoneI],
sizes[zoneI],
start,
nZone
);
start += sizes[zoneI];
nZone++;
}
}
zones.setSize(nZone);
}
template<class Face>
void Foam::MeshedSurface<Face>::addZones
(
const UList<label>& sizes,
const bool cullEmpty
)
{
label start = 0;
label nZone = 0;
surfZoneList& zones = this->storedZones();
zones.setSize(sizes.size());
forAll(zones, zoneI)
{
if (sizes[zoneI] || !cullEmpty)
{
zones[nZone] = surfZone
(
word("zone") + ::Foam::name(nZone),
sizes[zoneI],
start,
nZone
);
start += sizes[zoneI];
nZone++;
}
}
zones.setSize(nZone);
}
template<class Face>
void Foam::MeshedSurface<Face>::removeZones()
{
this->storedZones().clear();
}
// ************************************************************************* //

View File

@ -0,0 +1,147 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "MeshedSurfaceIOAllocator.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
(
const IOobject& ioPoints,
const IOobject& ioFaces,
const IOobject& ioZones
)
:
points_(ioPoints),
faces_(ioFaces),
zones_(ioZones)
{}
Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
(
const IOobject& ioPoints,
const pointField& points,
const IOobject& ioFaces,
const faceList& faces,
const IOobject& ioZones,
const surfZoneList& zones
)
:
points_(ioPoints, points),
faces_(ioFaces, faces),
zones_(ioZones, zones)
{}
Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
(
const IOobject& ioPoints,
const Xfer< pointField >& points,
const IOobject& ioFaces,
const Xfer< faceList >& faces,
const IOobject& ioZones,
const Xfer< surfZoneList >& zones
)
:
points_(ioPoints, points),
faces_(ioFaces, faces),
zones_(ioZones, zones)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::MeshedSurfaceIOAllocator::clear()
{
points_.clear();
faces_.clear();
zones_.clear();
}
void Foam::MeshedSurfaceIOAllocator::resetFaces
(
const Xfer< List<face> >& faces,
const Xfer< surfZoneList >& zones
)
{
if (&faces)
{
faces_.transfer(faces());
}
if (&zones)
{
zones_.transfer(zones());
}
}
void Foam::MeshedSurfaceIOAllocator::reset
(
const Xfer< pointField >& points,
const Xfer< faceList >& faces,
const Xfer< surfZoneList >& zones
)
{
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (&points)
{
points_.transfer(points());
}
resetFaces(faces, zones);
}
void Foam::MeshedSurfaceIOAllocator::reset
(
const Xfer< List<point> >& points,
const Xfer< faceList >& faces,
const Xfer< surfZoneList >& zones
)
{
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (&points)
{
points_.transfer(points());
}
resetFaces(faces, zones);
}
// ************************************************************************* //

View File

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::MeshedSurfaceIOAllocator
Description
A helper class for storing points, faces and zones with IO capabilities.
SourceFiles
MeshedSurfaceIOAllocator.C
\*---------------------------------------------------------------------------*/
#ifndef MeshedSurfaceIOAllocator_H
#define MeshedSurfaceIOAllocator_H
#include "pointIOField.H"
#include "faceIOList.H"
#include "surfZoneIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class MeshedSurfaceIOAllocator Declaration
\*---------------------------------------------------------------------------*/
//- A helper class for storing points, faces and zones
class MeshedSurfaceIOAllocator
{
// Private data
//- Points
pointIOField points_;
//- Faces
faceIOList faces_;
//- Surface zones
surfZoneIOList zones_;
// Private Member Functions
//- Disallow default bitwise copy construct
MeshedSurfaceIOAllocator(const MeshedSurfaceIOAllocator&);
//- Disallow default bitwise assignment
void operator=(const MeshedSurfaceIOAllocator&);
public:
// Constructors
//- Read construct from IOobjects
MeshedSurfaceIOAllocator
(
const IOobject& ioPoints,
const IOobject& ioFaces,
const IOobject& ioZones
);
//- Construct from IOobjects, copying components
MeshedSurfaceIOAllocator
(
const IOobject& ioPoints,
const pointField& points,
const IOobject& ioFaces,
const faceList& faces,
const IOobject& ioZones,
const surfZoneList& zones
);
//- Construct from IOobjects, possibly transferring components
MeshedSurfaceIOAllocator
(
const IOobject& ioPoints,
const Xfer< pointField >& points,
const IOobject& ioFaces,
const Xfer< faceList >& faces,
const IOobject& ioZones,
const Xfer< surfZoneList >& zones
);
// Destructor
// Member Functions
// Access
//- Non-const access to the points
pointIOField& storedIOPoints()
{
return points_;
}
//- Non-const access to the faces
faceIOList& storedIOFaces()
{
return faces_;
}
//- Non-const access to the zones
surfZoneIOList& storedIOZones()
{
return zones_;
}
//- Const access to the points
const pointIOField& storedIOPoints() const
{
return points_;
}
//- Const access to the faces
const faceIOList& storedIOFaces() const
{
return faces_;
}
//- Const access to the zones
const surfZoneIOList& storedIOZones() const
{
return zones_;
}
// Storage management
//- Clear primitive data (points, faces and zones)
void clear();
//- Reset primitive data (points, faces and zones)
// Note, optimized to avoid overwriting data (with Xfer::null)
void resetFaces
(
const Xfer< faceList >& faces,
const Xfer< surfZoneList >& zones
);
//- Reset primitive data (points, faces and zones)
// Note, optimized to avoid overwriting data (with Xfer::null)
void reset
(
const Xfer< pointField >& points,
const Xfer< faceList >& faces,
const Xfer< surfZoneList >& zones
);
//- Reset primitive data (points, faces and zones)
// Note, optimized to avoid overwriting data (with Xfer::null)
void reset
(
const Xfer< List<point> >& points,
const Xfer< faceList >& faces,
const Xfer< surfZoneList >& zones
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,261 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "MeshedSurfaceProxy.H"
#include "Time.H"
#include "surfMesh.H"
#include "OFstream.H"
#include "ListOps.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face>
Foam::wordHashSet Foam::MeshedSurfaceProxy<Face>::writeTypes()
{
return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
}
template<class Face>
bool Foam::MeshedSurfaceProxy<Face>::canWriteType
(
const word& ext,
const bool verbose
)
{
return checkSupport(writeTypes(), ext, verbose, "writing");
}
template<class Face>
void Foam::MeshedSurfaceProxy<Face>::write
(
const fileName& name,
const MeshedSurfaceProxy& surf
)
{
if (debug)
{
Info<< "MeshedSurfaceProxy::write"
"(const fileName&, const MeshedSurfaceProxy&) : "
"writing to " << name
<< endl;
}
word ext = name.ext();
typename writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{
FatalErrorIn
(
"MeshedSurfaceProxy::write(const fileName&)"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << endl
<< writeTypes()
<< exit(FatalError);
}
mfIter()(name, surf);
}
template<class Face>
void Foam::MeshedSurfaceProxy<Face>::write
(
const Time& t,
const word& surfName
) const
{
// the surface name to be used
word name(surfName.size() ? surfName : surfaceRegistry::defaultName);
if (debug)
{
Info<< "MeshedSurfaceProxy::write"
"(const Time&, const word&) : "
"writing to " << name
<< endl;
}
// the local location
const fileName objectDir
(
t.timePath()/surfaceRegistry::prefix/name/surfMesh::meshSubDir
);
if (!isDir(objectDir))
{
mkDir(objectDir);
}
// write surfMesh/points
{
pointIOField io
(
IOobject
(
"points",
t.timeName(),
surfMesh::meshSubDir,
t,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
OFstream os
(
objectDir/io.name(),
t.writeFormat(),
IOstream::currentVersion,
t.writeCompression()
);
io.writeHeader(os);
os << this->points();
io.writeEndDivider(os);
}
// write surfMesh/faces
{
faceIOList io
(
IOobject
(
"faces",
t.timeName(),
surfMesh::meshSubDir,
t,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
OFstream os
(
objectDir/io.name(),
t.writeFormat(),
IOstream::currentVersion,
t.writeCompression()
);
io.writeHeader(os);
if (this->useFaceMap())
{
// this is really a bit annoying (and wasteful) but no other way
os << reorder(this->faceMap(), this->faces());
}
else
{
os << this->faces();
}
io.writeEndDivider(os);
}
// write surfMesh/surfZones
{
surfZoneIOList io
(
IOobject
(
"surfZones",
t.timeName(),
surfMesh::meshSubDir,
t,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
// write as ascii
OFstream os(objectDir/io.name());
io.writeHeader(os);
os << this->surfZones();
io.writeEndDivider(os);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Face>
Foam::MeshedSurfaceProxy<Face>::MeshedSurfaceProxy
(
const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst,
const List<label>& faceMap
)
:
points_(pointLst),
faces_(faceLst),
zones_(zoneLst),
faceMap_(faceMap)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Face>
Foam::MeshedSurfaceProxy<Face>::~MeshedSurfaceProxy()
{}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::MeshedSurfaceProxy
Description
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh
to various file formats.
SourceFiles
MeshedSurfaceProxy.C
MeshedSurfaceProxyCore.C
\*---------------------------------------------------------------------------*/
#ifndef MeshedSurfaceProxy_H
#define MeshedSurfaceProxy_H
#include "pointField.H"
#include "face.H"
#include "triFace.H"
#include "surfZoneList.H"
#include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class Face> class MeshedSurface;
/*---------------------------------------------------------------------------*\
Class MeshedSurfaceProxy Declaration
\*---------------------------------------------------------------------------*/
template<class Face>
class MeshedSurfaceProxy
:
public fileFormats::surfaceFormatsCore
{
//- Private data
const pointField& points_;
const List<Face>& faces_;
const List<surfZone>& zones_;
const List<label>& faceMap_;
public:
//- Runtime type information
ClassName("MeshedSurfaceProxy");
// Static
//- The file format types that can be written via MeshedSurfaceProxy
static wordHashSet writeTypes();
//- Can this file format type be written via MeshedSurfaceProxy?
static bool canWriteType(const word& ext, const bool verbose=false);
// Constructors
//- Construct from component references
MeshedSurfaceProxy
(
const pointField&,
const List<Face>&,
const List<surfZone>& = List<surfZone>(),
const List<label>& faceMap = List<label>()
);
// Destructor
virtual ~MeshedSurfaceProxy();
// Member Function Selectors
declareMemberFunctionSelectionTable
(
void,
MeshedSurfaceProxy,
write,
fileExtension,
(
const fileName& name,
const MeshedSurfaceProxy<Face>& surf
),
(name, surf)
);
//- Write to file
static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
// Member Functions
// Access
//- Return const access to the points
inline const pointField& points() const
{
return points_;
}
//- Return const access to the faces
inline const List<Face>& faces() const
{
return faces_;
}
//- Const access to the surface zones.
// If zones are defined, they must be contiguous and cover the entire
// surface.
inline const List<surfZone>& surfZones() const
{
return zones_;
}
//- Const access to the faceMap, zero-sized when unused
inline const List<label>& faceMap() const
{
return faceMap_;
}
//- Use faceMap?
inline bool useFaceMap() const
{
return faceMap_.size() == faces_.size();
}
// Write
//- Generic write routine. Chooses writer based on extension.
virtual void write(const fileName& name) const
{
write(name, *this);
}
//- Write to database
virtual void write(const Time&, const word& surfName = "") const;
//?? void writeStats(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "MeshedSurfaceProxy.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "MeshedSurfaceProxy.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define makeSurface(surfType, faceType) \
defineNamedTemplateTypeNameAndDebug(surfType<faceType>, 0); \
defineTemplatedMemberFunctionSelectionTable(surfType,write,fileExtension,faceType);
makeSurface(MeshedSurfaceProxy, face)
makeSurface(MeshedSurfaceProxy, triFace)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -26,6 +26,7 @@ License
#include "MeshedSurface.H"
#include "UnsortedMeshedSurface.H"
#include "MeshedSurfaceProxy.H"
#include "IFstream.H"
#include "OFstream.H"
#include "Time.H"
@ -57,21 +58,13 @@ bool Foam::UnsortedMeshedSurface<Face>::canReadType
const bool verbose
)
{
// handle 'native' format directly
if (isNative(ext))
{
return true;
}
else
{
return checkSupport
(
readTypes() | SiblingType::readTypes(),
ext,
verbose,
"reading"
);
}
return checkSupport
(
readTypes() | ParentType::readTypes(),
ext,
verbose,
"reading"
);
}
@ -82,13 +75,13 @@ bool Foam::UnsortedMeshedSurface<Face>::canWriteType
const bool verbose
)
{
// handle 'native' format directly
if (isNative(ext))
{
return true;
}
return checkSupport(writeTypes(), ext, verbose, "writing");
return checkSupport
(
writeTypes(),
ext,
verbose,
"writing"
);
}
@ -125,29 +118,34 @@ void Foam::UnsortedMeshedSurface<Face>::write
const word ext = name.ext();
// handle 'native' format directly
if (isNative(ext))
{
surf.write(OFstream(name)());
return;
}
typename writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{
FatalErrorIn
(
"UnsortedMeshedSurface::write"
"(const fileName&, const UnsortedMeshedSurface&)"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << endl
<< writeTypes()
<< exit(FatalError);
}
// no direct writer, delegate to proxy if possible
wordHashSet supported = ProxyType::writeTypes();
mfIter()(name, surf);
if (supported.found(ext))
{
MeshedSurfaceProxy<Face>(surf).write(name);
}
else
{
FatalErrorIn
(
"UnsortedMeshedSurface::write"
"(const fileName&, const UnsortedMeshedSurface&)"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << endl
<< (supported | writeTypes())
<< exit(FatalError);
}
}
else
{
mfIter()(name, surf);
}
}
@ -155,16 +153,18 @@ void Foam::UnsortedMeshedSurface<Face>::write
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface()
:
ParentType()
{}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const Xfer<List<label> >& zoneIds,
const Xfer<surfZoneIdentifierList>& zoneTofc
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst,
const Xfer< List<label> >& zoneIds,
const Xfer< surfZoneIdentifierList >& zoneTofc
)
:
ParentType(pointLst, faceLst),
@ -176,17 +176,17 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst,
const UList<label>& zoneSizes,
const UList<word>& zoneNames
)
:
ParentType(pointLst, faceLst)
{
if (&zoneSizes)
if (zoneSizes.size())
{
if (&zoneNames)
if (zoneNames.size())
{
setZones(zoneSizes, zoneNames);
}
@ -197,89 +197,50 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
}
else
{
oneZone();
setOneZone();
}
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const polyBoundaryMesh& bMesh,
const bool useGlobalPoints
)
{
// creating via MeshedSurface is the easiest
MeshedSurface<Face> surf(bMesh, useGlobalPoints);
transfer(surf);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const MeshedSurface<Face>& surf
)
:
ParentType(xferCopy(surf.points()), xferCopy(surf.faces()))
{
setZones(surf.zones());
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const fileName& name,
const word& ext
)
{
read(name, ext);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const fileName& name)
{
read(name);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(Istream& is)
{
read(is);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Time& d,
const word& surfName
)
{
read(IFstream(findMeshFile(d, surfName))());
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const UnsortedMeshedSurface<Face>& surf
)
:
ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
zoneIds_(surf.zoneIds_),
zoneToc_(surf.zoneToc_)
ParentType
(
xferCopy(surf.points()),
xferCopy(surf.faces())
),
zoneIds_(surf.zoneIds()),
zoneToc_(surf.zoneToc())
{}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer<UnsortedMeshedSurface<Face> >& surf
const MeshedSurface<Face>& surf
)
:
ParentType
(
xferCopy(surf.points()),
xferCopy(surf.faces())
)
{
setZones(surf.surfZones());
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer< UnsortedMeshedSurface<Face> >& surf
)
:
ParentType()
{
transfer(surf());
}
@ -288,12 +249,51 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer<MeshedSurface<Face> >& surf
const Xfer< MeshedSurface<Face> >& surf
)
:
ParentType()
{
transfer(surf());
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const fileName& name,
const word& ext
)
:
ParentType()
{
read(name, ext);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const fileName& name)
:
ParentType()
{
read(name);
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Time& t,
const word& surfName
)
:
ParentType()
{
MeshedSurface<Face> surf(t, surfName);
transfer(surf);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Face>
@ -308,22 +308,19 @@ Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::oneZone(const word& name)
void Foam::UnsortedMeshedSurface<Face>::setOneZone()
{
zoneIds_.setSize(size());
zoneIds_ = 0;
word zoneName(name);
word zoneName;
if (zoneToc_.size())
{
zoneName = zoneToc_[0].name();
}
if (zoneName.empty())
{
if (zoneToc_.size())
{
zoneName = zoneToc_[0].name();
}
if (zoneName.empty())
{
zoneName = "zone0";
}
zoneName = "zone0";
}
// set single default zone
@ -344,7 +341,6 @@ void Foam::UnsortedMeshedSurface<Face>::setZones
forAll(zoneToc_, zoneI)
{
const surfZone& zone = zoneLst[zoneI];
zoneToc_[zoneI] = zone;
// assign sub-zone Ids
@ -416,7 +412,7 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
{
if (zoneToc_.empty())
{
oneZone();
setOneZone();
}
else if (zoneToc_.size() == 1)
{
@ -442,7 +438,7 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
{
ParentType::setSize(s);
this->storedFaces().setSize(s);
// if zones extend: set with last zoneId
zoneIds_.setSize(s, zoneToc_.size() - 1);
}
@ -470,12 +466,81 @@ Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones
zoneNames.insert(zoneI, zoneToc_[zoneI].name());
}
return sortedZonesById(zoneIds_, zoneNames, faceMap);
// std::sort() really seems to mix up the order.
// and std::stable_sort() might take too long / too much memory
// Assuming that we have relatively fewer zones compared to the
// number of items, just do it ourselves
// step 1: get zone sizes and store (origId => zoneI)
Map<label> lookup;
forAll(zoneIds_, faceI)
{
const label origId = zoneIds_[faceI];
Map<label>::iterator fnd = lookup.find(origId);
if (fnd != lookup.end())
{
fnd()++;
}
else
{
lookup.insert(origId, 1);
}
}
// step 2: assign start/size (and name) to the newZones
// re-use the lookup to map (zoneId => zoneI)
surfZoneList zoneLst(lookup.size());
label start = 0;
label zoneI = 0;
forAllIter(Map<label>, lookup, iter)
{
label origId = iter.key();
word name;
Map<word>::const_iterator fnd = zoneNames.find(origId);
if (fnd != zoneNames.end())
{
name = fnd();
}
else
{
name = word("zone") + ::Foam::name(zoneI);
}
zoneLst[zoneI] = surfZone
(
name,
0, // initialize with zero size
start,
zoneI
);
// increment the start for the next zone
// and save the (zoneId => zoneI) mapping
start += iter();
iter() = zoneI++;
}
// step 3: build the re-ordering
faceMap.setSize(zoneIds_.size());
forAll(zoneIds_, faceI)
{
label zoneI = lookup[zoneIds_[faceI]];
faceMap[faceI] = zoneLst[zoneI].start() + zoneLst[zoneI].size()++;
}
// with reordered faces registered in faceMap
return zoneLst;
}
template<class Face>
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
Foam::UnsortedMeshedSurface<Face>
Foam::UnsortedMeshedSurface<Face>::subsetMesh
(
const labelHashSet& include,
labelList& pointMap,
@ -542,12 +607,39 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::reset
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const Xfer<List<label> >& zoneIds
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst,
const Xfer< List<label> >& zoneIds
)
{
ParentType::reset(pointLst, faceLst);
ParentType::reset
(
pointLst,
faceLst,
Xfer<surfZoneList>()
);
if (&zoneIds)
{
zoneIds_.transfer(zoneIds());
}
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::reset
(
const Xfer< List<point> >& pointLst,
const Xfer< List<Face> >& faceLst,
const Xfer< List<label> >& zoneIds
)
{
ParentType::reset
(
pointLst,
faceLst,
Xfer<surfZoneList>()
);
if (&zoneIds)
{
@ -562,12 +654,14 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
UnsortedMeshedSurface<Face>& surf
)
{
reset
ParentType::reset
(
xferMove(surf.storedPoints()),
xferMove(surf.storedFaces()),
xferMove(surf.zoneIds_)
Xfer<surfZoneList>()
);
zoneIds_.transfer(surf.zoneIds_);
zoneToc_.transfer(surf.zoneToc_);
surf.clear();
@ -580,8 +674,14 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
MeshedSurface<Face>& surf
)
{
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
setZones(surf.zones());
ParentType::reset
(
xferMove(surf.storedPoints()),
xferMove(surf.storedFaces()),
Xfer<surfZoneList>()
);
setZones(surf.surfZones());
surf.clear();
}
@ -620,28 +720,22 @@ bool Foam::UnsortedMeshedSurface<Face>::read
const word& ext
)
{
// handle 'native' format directly
if (isNative(ext))
{
return read(IFstream(name)());
}
else
{
// use selector mechanism
transfer(New(name, ext)());
return true;
}
clear();
// read via use selector mechanism
transfer(New(name, ext)());
return true;
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::write
(
const Time& d,
const Time& t,
const word& surfName
) const
{
write(OFstream(findMeshFile(d, surfName))());
MeshedSurfaceProxy<Face>(*this).write(t, surfName);
}
@ -662,13 +756,30 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
}
template<class Face>
Foam::UnsortedMeshedSurface<Face>::operator
Foam::MeshedSurfaceProxy<Face>() const
{
labelList faceMap;
List<surfZone> zoneLst = this->sortedZones(faceMap);
return MeshedSurfaceProxy<Face>
(
this->points(),
this->faces(),
zoneLst,
faceMap
);
}
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "UnsortedMeshedSurfaceIO.C"
#include "UnsortedMeshedSurfaceNew.C"
// ************************************************************************* //

View File

@ -47,7 +47,7 @@ SourceFiles
#ifndef UnsortedMeshedSurface_H
#define UnsortedMeshedSurface_H
#include "BasicMeshedSurface.H"
#include "MeshedSurface.H"
#include "surfZoneIdentifierList.H"
#include "surfZoneList.H"
#include "surfaceFormatsCore.H"
@ -64,14 +64,10 @@ namespace Foam
class Time;
class IFstream;
template<class Face> class UnsortedMeshedSurface;
template<class Face> class MeshedSurface;
class polyBoundaryMesh;
template<class Face>
Ostream& operator<<(Ostream&, const UnsortedMeshedSurface<Face>&);
template<class Face> class MeshedSurfaceProxy;
template<class Face> class UnsortedMeshedSurface;
/*---------------------------------------------------------------------------*\
Class UnsortedMeshedSurface Declaration
@ -80,24 +76,20 @@ Ostream& operator<<(Ostream&, const UnsortedMeshedSurface<Face>&);
template<class Face>
class UnsortedMeshedSurface
:
public BasicMeshedSurface<Face>,
public fileFormats::surfaceFormatsCore
public MeshedSurface<Face>
{
// friends despite different faces
template<class Face2>
friend class MeshedSurface;
// friends despite different faces
template<class Face2>
friend class UnsortedMeshedSurface;
friend class MeshedSurface<Face>;
// friends - despite different face representationsx
template<class Face2> friend class MeshedSurface;
template<class Face2> friend class UnsortedMeshedSurface;
friend class surfMesh;
private:
//- Typedefs for convenience
typedef BasicMeshedSurface<Face> ParentType;
typedef MeshedSurface<Face> SiblingType;
//- Private typedefs for convenience
typedef MeshedSurface<Face> ParentType;
typedef MeshedSurface<Face> FriendType;
typedef MeshedSurfaceProxy<Face> ProxyType;
// Private Member Data
@ -166,10 +158,10 @@ public:
// (points, faces, zone ids, zone info).
UnsortedMeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const Xfer<List<label> >& zoneIds,
const Xfer<surfZoneIdentifierList>&
const Xfer< pointField >&,
const Xfer< List<Face> >&,
const Xfer< List<label> >& zoneIds,
const Xfer< surfZoneIdentifierList >&
);
//- Construct by transferring points, faces.
@ -178,16 +170,12 @@ public:
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const UList<label>& zoneSizes = UList<label>::null(),
const UList<word>& zoneNames = UList<word>::null()
const UList<label>& zoneSizes = UList<label>(),
const UList<word>& zoneNames = UList<word>()
);
//- Construct from a boundary mesh with local points/faces
UnsortedMeshedSurface
(
const polyBoundaryMesh&,
const bool globalPoints=false
);
//- Construct as copy
UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
//- Construct from a meshedSurface
UnsortedMeshedSurface(const MeshedSurface<Face>&);
@ -207,12 +195,9 @@ public:
//- Construct from Istream
UnsortedMeshedSurface(Istream&);
//- Construct from objectRegistry
//- Construct from objectRegistry and a named surface
UnsortedMeshedSurface(const Time&, const word& surfName="");
//- Construct as copy
UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
// Declare run-time constructor selection table
declareRunTimeSelectionTable
@ -287,13 +272,12 @@ public:
return zoneToc_;
}
//- Sort faces according to zone.
//- Sort faces according to zoneIds
// Returns a surfZoneList and sets faceMap to index within faces()
surfZoneList sortedZones(labelList& faceMap) const;
//- Set zones to 0 and set a single zone
// Optionally with a specific name
void oneZone(const word& name = word::null);
void setOneZone();
//- Set zone ids and zones
void setZones(const surfZoneList&);
@ -328,9 +312,17 @@ public:
//- Transfer components (points, faces, zone ids).
virtual void reset
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const Xfer<List<label> >& zoneIds = Xfer<List<label> >::null()
const Xfer< pointField >&,
const Xfer< List<Face> >&,
const Xfer< List<label> >& zoneIds
);
//- Transfer components (points, faces, zone ids).
virtual void reset
(
const Xfer< List<point> >&,
const Xfer< List<Face> >&,
const Xfer< List<label> >& zoneIds
);
//- Transfer the contents of the argument and annull the argument
@ -354,9 +346,6 @@ public:
// Write
//- Write to Ostream in simple FOAM format
virtual void write(Ostream&) const;
//- Generic write routine. Chooses writer based on extension.
virtual void write(const fileName& name) const
{
@ -371,15 +360,8 @@ public:
void operator=(const UnsortedMeshedSurface<Face>&);
// Ostream Operator
friend Ostream& operator<<
<Face>
(
Ostream&,
const UnsortedMeshedSurface<Face>&
);
//- Conversion operator to MeshedSurfaceProxy
operator MeshedSurfaceProxy<Face>() const;
};

View File

@ -1,108 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "MeshedSurface.H"
#include "UnsortedMeshedSurface.H"
#include "IFstream.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Read surf grouping, points, faces directly from Istream
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::read(Istream& is)
{
MeshedSurface<Face> surf(is);
transfer(surf);
return is.good();
}
// write (sorted)
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
{
const List<Face>& faceLst = this->faces();
labelList faceMap;
surfZoneList zoneLst = sortedZones(faceMap);
// just emit some information until we get a nice IOobject
IOobject::writeBanner(os);
os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// zones:" << nl
<< zoneLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(zoneLst, zoneI)
{
zoneLst[zoneI].writeDict(os);
}
os << decrIndent << token::END_LIST << nl;
IOobject::writeDivider(os);
// Note: Write with global point numbering
os << "\n// points:" << nl << this->points() << nl;
IOobject::writeDivider(os);
os << "\n// faces:" << nl;
os << faceLst.size() << nl << token::BEGIN_LIST << nl;
label faceI = 0;
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
forAll(zone, localFaceI)
{
os << faceLst[faceMap[faceI++]] << nl;
}
}
os << token::END_LIST << nl;
IOobject::writeDivider(os);
// Check state of Ostream
os.check("UnsortedMeshedSurface::write(Ostream&)");
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Face>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const UnsortedMeshedSurface<Face>& surf
)
{
surf.write(os);
return os;
}
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More