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

This commit is contained in:
mattijs
2009-12-02 16:44:12 +00:00
51 changed files with 1077 additions and 777 deletions

2
.gitignore vendored
View File

@ -51,7 +51,9 @@ doc/[Dd]oxygen/latex
doc/[Dd]oxygen/man doc/[Dd]oxygen/man
# generated files in the main directory (e.g. ReleaseNotes-?.?.html) # generated files in the main directory (e.g. ReleaseNotes-?.?.html)
# and in the doc directory
/*.html /*.html
/doc/*.html
# source packages - anywhere # source packages - anywhere
*.tar.bz2 *.tar.bz2

View File

@ -92,6 +92,8 @@ int main(int argc, char *argv[])
labelHashSet setD(1); labelHashSet setD(1);
setD.insert(11); setD.insert(11);
setD.insert(100); setD.insert(100);
setD.insert(49);
setD.insert(36);
setD.insert(2008); setD.insert(2008);
Info<< "setD : " << setD << endl; Info<< "setD : " << setD << endl;
@ -138,6 +140,17 @@ int main(int argc, char *argv[])
// this doesn't work (yet?) // this doesn't work (yet?)
// setD[12] = true; // setD[12] = true;
List<label> someLst(10);
forAll(someLst, elemI)
{
someLst[elemI] = elemI*elemI;
}
label added = setD.set(someLst);
Info<< "added " << added << " from " << someLst.size() << endl;
Info<< "setD : " << setD << endl;
return 0; return 0;
} }

View File

@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
#------------------------------------------------------------------------------ #-------------------------------------------------------------------------------
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
@ -36,7 +36,7 @@
# Note # Note
# The foamCopySettings.rc (found with the ~OpenFOAM expansion) can be used # The foamCopySettings.rc (found with the ~OpenFOAM expansion) can be used
# to add any custom rsync options. # to add any custom rsync options.
#------------------------------------------------------------------------------ #-------------------------------------------------------------------------------
Script=${0##*/} Script=${0##*/}
if [ "$1" = "-h" -o "$1" = "-help" -o "$#" -ne 2 ] if [ "$1" = "-h" -o "$1" = "-help" -o "$#" -ne 2 ]
then then
@ -48,8 +48,8 @@ Usage: $Script srcDir dstDir
- requires rsync - requires rsync
Note Note
The $Script.rc (found with the ~OpenFOAM expansion) can be used The $Script.rc (found via the ~OpenFOAM expansion - see foamEtcFile)
to add any custom rsync options. can be used to add any custom rsync options.
USAGE USAGE
exit 1 exit 1
@ -78,7 +78,6 @@ done
# avoid processor directories here too to make for cleaner output # avoid processor directories here too to make for cleaner output
fileList=$(find -H $srcDir -mindepth 1 -maxdepth 1 -not -name "processor*") fileList=$(find -H $srcDir -mindepth 1 -maxdepth 1 -not -name "processor*")
# avoid polyMesh and processor* directories # avoid polyMesh and processor* directories
rsync="rsync --exclude polyMesh --exclude processor*" rsync="rsync --exclude polyMesh --exclude processor*"
@ -108,15 +107,20 @@ do
# skip numerical (results) directories (except 0) # skip numerical (results) directories (except 0)
# and things that look like log files or queuing system output # and things that look like log files or queuing system output
case "$name" in case "$name" in
[1-9] | [0-9]?* | log | *.log | foam.[eo][1-9]* ) ( [1-9] | [0-9]?* | log | *.log | foam.[eo][1-9]* )
echo "$i [skipped]" echo "$i [skipped]"
continue continue
;; ;;
*) # skip things that look sampled directories and converted data
( probes | sets | surfaces | En[Ss]ight )
echo "$i [skipped]"
continue
;;
(*)
echo "$i -> $dstDir/$name" echo "$i -> $dstDir/$name"
$rsync -a $i $dstDir $rsync -a $i $dstDir
;; ;;
esac esac
done done
# --------------------------------------------------------------- end-of-file # ------------------------------------------------------------------ end-of-file

108
bin/tools/org-batch Executable file
View File

@ -0,0 +1,108 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2009-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
#
# Script
# org-batch
#
# Description
# Batch process emacs org-mode files to create html/LaTeX etc.
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTIONS] file1 [.. fileN]
options:
-html create html (default)
-latex create LaTeX
* Batch process emacs org-mode files to create html/LaTeX etc.
USAGE
exit 1
}
# default is html export:
mode=html
case $Script in
*latex)
mode=latex
;;
*html)
mode=html
;;
esac
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-html)
mode=html
shift
;;
-latex)
mode=latex
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# default is the current directory
[ "$#" -gt 0 ] || usage "No files specified"
type emacs >/dev/null 2>&1 || usage "No emacs found in PATH"
for org
do
echo "Processing: $org"
echo "----------"
if [ -f "$org" ]
then
emacs --batch -l org --visit=$org \
--funcall org-export-as-$mode-batch
else
echo "File not found"
fi
echo "----------"
done
#------------------------------------------------------------------------------

1
bin/tools/org-html Symbolic link
View File

@ -0,0 +1 @@
org-batch

1
bin/tools/org-latex Symbolic link
View File

@ -0,0 +1 @@
org-batch

View File

@ -132,7 +132,7 @@ unset MPI_ARCH_PATH
switch ("$WM_MPLIB") switch ("$WM_MPLIB")
case OPENMPI: case OPENMPI:
set mpi_version=openmpi-1.3.3 set mpi_version=openmpi-1.3.4
setenv MPI_HOME $WM_THIRD_PARTY_DIR/$mpi_version setenv MPI_HOME $WM_THIRD_PARTY_DIR/$mpi_version
setenv MPI_ARCH_PATH $MPI_HOME/platforms/$WM_OPTIONS setenv MPI_ARCH_PATH $MPI_HOME/platforms/$WM_OPTIONS

View File

@ -163,7 +163,7 @@ unset MPI_ARCH_PATH
case "$WM_MPLIB" in case "$WM_MPLIB" in
OPENMPI) OPENMPI)
mpi_version=openmpi-1.3.3 mpi_version=openmpi-1.3.4
export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version
export MPI_ARCH_PATH=$MPI_HOME/platforms/$WM_OPTIONS export MPI_ARCH_PATH=$MPI_HOME/platforms/$WM_OPTIONS

View File

@ -32,14 +32,30 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Key, class Hash> template<class Key, class Hash>
template<class AnyType> Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst)
Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& h) :
HashTable<nil, Key, Hash>(2*lst.size())
{
forAll(lst, elemI)
{
insert(lst[elemI]);
}
}
template<class Key, class Hash>
template<class AnyType, class AnyHash>
Foam::HashSet<Key, Hash>::HashSet
(
const HashTable<AnyType, Key, AnyHash>& h
)
: :
HashTable<nil, Key, Hash>(h.size()) HashTable<nil, Key, Hash>(h.size())
{ {
for for
( (
typename HashTable<AnyType, Key, Hash>::const_iterator cit = h.cbegin(); typename HashTable<AnyType, Key, AnyHash>::const_iterator
cit = h.cbegin();
cit != h.cend(); cit != h.cend();
++cit ++cit
) )
@ -49,6 +65,24 @@ Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& h)
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Key, class Hash>
Foam::label Foam::HashSet<Key, Hash>::insert(const UList<Key>& lst)
{
label count = 0;
forAll(lst, elemI)
{
if (insert(lst[elemI]))
{
++count;
}
}
return count;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Key, class Hash> template<class Key, class Hash>

View File

@ -84,15 +84,7 @@ public:
{} {}
//- Construct from UList of Key //- Construct from UList of Key
HashSet(const UList<Key>& lst) HashSet(const UList<Key>&);
:
HashTable<nil, Key, Hash>(2*lst.size())
{
forAll(lst, i)
{
insert(lst[i]);
}
}
//- Construct as copy //- Construct as copy
HashSet(const HashSet<Key, Hash>& hs) HashSet(const HashSet<Key, Hash>& hs)
@ -114,8 +106,9 @@ public:
//- Construct from the keys of another HashTable, //- Construct from the keys of another HashTable,
// the type of values held is arbitrary. // the type of values held is arbitrary.
template<class AnyType> template<class AnyType, class AnyHash>
HashSet(const HashTable<AnyType, Key, Hash>&); HashSet(const HashTable<AnyType, Key, AnyHash>&);
// Member Functions // Member Functions
@ -127,12 +120,23 @@ public:
return HashTable<nil, Key, Hash>::insert(key, nil()); return HashTable<nil, Key, Hash>::insert(key, nil());
} }
//- Insert keys from a UList of Key
// Return the number of new elements inserted
label insert(const UList<Key>&);
//- Same as insert (cannot overwrite nil content) //- Same as insert (cannot overwrite nil content)
bool set(const Key& key) bool set(const Key& key)
{ {
return HashTable<nil, Key, Hash>::insert(key, nil()); return insert(key);
} }
//- Same as insert (cannot overwrite nil content)
label set(const UList<Key>& lst)
{
return insert(lst);
}
// Member Operators // Member Operators
//- Return true if the entry exists, same as found() //- Return true if the entry exists, same as found()
@ -163,7 +167,6 @@ public:
//- Remove entries listed in the given HashSet from this HashSet //- Remove entries listed in the given HashSet from this HashSet
void operator-=(const HashSet<Key, Hash>&); void operator-=(const HashSet<Key, Hash>&);
}; };

View File

@ -58,7 +58,7 @@ Foam::IOobjectList::IOobjectList
} }
} }
// Create list file names in directory // Create a list of file names in this directory
fileNameList ObjectNames = fileNameList ObjectNames =
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE); readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
@ -130,8 +130,8 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
{ {
if (IOobject::debug) if (IOobject::debug)
{ {
Info<< "IOobjectList::lookup : found " << name Info<< "IOobjectList::lookup : found "
<< endl; << name << endl;
} }
return const_cast<IOobject*>(*iter); return const_cast<IOobject*>(*iter);
@ -140,8 +140,8 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
{ {
if (IOobject::debug) if (IOobject::debug)
{ {
Info<< "IOobjectList::lookup : could not find " << name Info<< "IOobjectList::lookup : could not find "
<< endl; << name << endl;
} }
return NULL; return NULL;
@ -151,7 +151,7 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const
{ {
IOobjectList IOobjectsOfClass(size()); IOobjectList objectsOfClass(size());
for for
( (
@ -165,34 +165,26 @@ Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const
if (IOobject::debug) if (IOobject::debug)
{ {
Info<< "IOobjectList::lookupClass : found " Info<< "IOobjectList::lookupClass : found "
<< iter()->name() << iter.key() << endl;
<< endl;
} }
IOobjectsOfClass.insert(iter()->name(), new IOobject(*iter())); objectsOfClass.insert(iter.key(), new IOobject(*iter()));
} }
} }
return IOobjectsOfClass; return objectsOfClass;
} }
Foam::wordList Foam::IOobjectList::names() const Foam::wordList Foam::IOobjectList::names() const
{ {
wordList objectNames(size()); return HashPtrTable<IOobject>::toc();
}
label count = 0;
for
(
HashPtrTable<IOobject>::const_iterator iter = begin();
iter != end();
++iter
)
{
objectNames[count++] = iter()->name();
}
return objectNames; Foam::wordList Foam::IOobjectList::sortedNames() const
{
return HashPtrTable<IOobject>::sortedToc();
} }
@ -210,7 +202,7 @@ Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
{ {
if (iter()->headerClassName() == ClassName) if (iter()->headerClassName() == ClassName)
{ {
objectNames[count++] = iter()->name(); objectNames[count++] = iter.key();
} }
} }
@ -220,4 +212,13 @@ Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
} }
Foam::wordList Foam::IOobjectList::sortedNames(const word& ClassName) const
{
wordList sortedLst = names(ClassName);
sort(sortedLst);
return sortedLst;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -84,23 +84,29 @@ public:
// Member functions // Member functions
//- Add an IOobject to list //- Add an IOobject to the list
bool add(IOobject&); bool add(IOobject&);
//- Remove an IOobject from list //- Remove an IOobject from the list
bool remove(IOobject&); bool remove(IOobject&);
//- Lookup a given name and return IOobject ptr if found else NULL //- Lookup a given name and return IOobject ptr if found else NULL
IOobject* lookup(const word& name) const; IOobject* lookup(const word& name) const;
//- Return the list for all IOobjects of given class //- Return the list for all IOobjects of a given class
IOobjectList lookupClass(const word& className) const; IOobjectList lookupClass(const word& className) const;
//- Return the list of names of the IOobjects //- Return the list of names of the IOobjects
wordList names() const; wordList names() const;
//- Return the sorted list of names of the IOobjects
wordList sortedNames() const;
//- Return the list of names of the IOobjects of given class //- Return the list of names of the IOobjects of given class
wordList names(const word& className) const; wordList names(const word& className) const;
//- Return the sorted list of names of the IOobjects of given class
wordList sortedNames(const word& className) const;
}; };

View File

@ -29,6 +29,19 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class OutputFilter>
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
(
const word& outputFilterName,
const IOobject& ioDict,
const bool readFromFiles
)
:
IOdictionary(ioDict),
OutputFilter(outputFilterName, ioDict.db(), *this, readFromFiles)
{}
template<class OutputFilter> template<class OutputFilter>
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
( (

View File

@ -29,6 +29,11 @@ Description
IOdictionary wrapper around OutputFilter to allow them to read from IOdictionary wrapper around OutputFilter to allow them to read from
their associated dictionaries. their associated dictionaries.
Note
The IOobject or the objectRegistry will normally have to be
derived from a fvMesh for a subsequent cast (within OutputFilter)
to work correctly.
SourceFiles SourceFiles
IOOutputFilter.C IOOutputFilter.C
@ -69,6 +74,15 @@ public:
// Constructors // Constructors
//- Construct from an IOobject for IOdictionary
// Allow the possibility to load fields from files
IOOutputFilter
(
const word& outputFilterName,
const IOobject& ioDict,
const bool loadFromFile = false
);
//- Construct for given objectRegistry and dictionary //- Construct for given objectRegistry and dictionary
// Allow dictionary to be optional // Allow dictionary to be optional
// Allow the possibility to load fields from files // Allow the possibility to load fields from files

View File

@ -93,7 +93,7 @@ Foam::objectRegistry::~objectRegistry()
} }
} }
for (label i=0; i<nMyObjects; i++) for (label i=0; i < nMyObjects; i++)
{ {
checkOut(*myObjects[i]); checkOut(*myObjects[i]);
} }
@ -104,15 +104,13 @@ Foam::objectRegistry::~objectRegistry()
Foam::wordList Foam::objectRegistry::names() const Foam::wordList Foam::objectRegistry::names() const
{ {
wordList objectNames(size()); return HashTable<regIOobject*>::toc();
}
label count=0;
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{
objectNames[count++] = iter()->name();
}
return objectNames; Foam::wordList Foam::objectRegistry::sortedNames() const
{
return HashTable<regIOobject*>::sortedToc();
} }
@ -125,7 +123,7 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const
{ {
if (iter()->type() == ClassName) if (iter()->type() == ClassName)
{ {
objectNames[count++] = iter()->name(); objectNames[count++] = iter.key();
} }
} }
@ -135,6 +133,15 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const
} }
Foam::wordList Foam::objectRegistry::sortedNames(const word& ClassName) const
{
wordList sortedLst = names(ClassName);
sort(sortedLst);
return sortedLst;
}
const Foam::objectRegistry& Foam::objectRegistry::subRegistry const Foam::objectRegistry& Foam::objectRegistry::subRegistry
( (
const word& name const word& name
@ -151,8 +158,8 @@ Foam::label Foam::objectRegistry::getEvent() const
if (event_ == labelMax) if (event_ == labelMax)
{ {
WarningIn("objectRegistry::getEvent() const") WarningIn("objectRegistry::getEvent() const")
<< "Event counter has overflowed. Resetting counter on all" << "Event counter has overflowed. "
<< " dependent objects." << endl << "Resetting counter on all dependent objects." << nl
<< "This might cause extra evaluations." << endl; << "This might cause extra evaluations." << endl;
// Reset event counter // Reset event counter
@ -202,7 +209,7 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
if (objectRegistry::debug) if (objectRegistry::debug)
{ {
Pout<< "objectRegistry::checkOut(regIOobject&) : " Pout<< "objectRegistry::checkOut(regIOobject&) : "
<< name() << " : checking out " << io.name() << name() << " : checking out " << iter.key()
<< endl; << endl;
} }
@ -211,7 +218,8 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
if (objectRegistry::debug) if (objectRegistry::debug)
{ {
WarningIn("objectRegistry::checkOut(regIOobject&)") WarningIn("objectRegistry::checkOut(regIOobject&)")
<< name() << " : attempt to checkOut copy of " << io.name() << name() << " : attempt to checkOut copy of "
<< iter.key()
<< endl; << endl;
} }
@ -286,8 +294,7 @@ void Foam::objectRegistry::readModifiedObjects()
{ {
Pout<< "objectRegistry::readModifiedObjects() : " Pout<< "objectRegistry::readModifiedObjects() : "
<< name() << " : Considering reading object " << name() << " : Considering reading object "
<< iter()->name() << iter.key() << endl;
<< endl;
} }
iter()->readIfModified(); iter()->readIfModified();
@ -317,7 +324,7 @@ bool Foam::objectRegistry::writeObject
{ {
Pout<< "objectRegistry::write() : " Pout<< "objectRegistry::write() : "
<< name() << " : Considering writing object " << name() << " : Considering writing object "
<< iter()->name() << iter.key()
<< " with writeOpt " << iter()->writeOpt() << " with writeOpt " << iter()->writeOpt()
<< " to file " << iter()->objectPath() << " to file " << iter()->objectPath()
<< endl; << endl;

View File

@ -132,9 +132,15 @@ public:
//- Return the list of names of the IOobjects //- Return the list of names of the IOobjects
wordList names() const; wordList names() const;
//- Return the list of names of the IOobjects of given class name //- Return the sorted list of names of the IOobjects
wordList sortedNames() const;
//- Return the list of names of IOobjects of given class name
wordList names(const word& className) const; wordList names(const word& className) const;
//- Return the sorted list of names of IOobjects of given class name
wordList sortedNames(const word& className) const;
//- Return the list of names of the IOobjects of given type //- Return the list of names of the IOobjects of given type
template<class Type> template<class Type>
wordList names() const; wordList names() const;
@ -142,11 +148,11 @@ public:
//- Lookup and return a const sub-objectRegistry //- Lookup and return a const sub-objectRegistry
const objectRegistry& subRegistry(const word& name) const; const objectRegistry& subRegistry(const word& name) const;
//- Lookup and return all the object of the given Type //- Lookup and return all objects of the given Type
template<class Type> template<class Type>
HashTable<const Type*> lookupClass() const; HashTable<const Type*> lookupClass() const;
//- Is the named Type //- Is the named Type found?
template<class Type> template<class Type>
bool foundObject(const word& name) const; bool foundObject(const word& name) const;

View File

@ -234,35 +234,16 @@ public:
//- Read a value from the named option //- Read a value from the named option
template<class T> template<class T>
T optionRead(const word& opt) const T optionRead(const word& opt) const;
{
T val;
optionLookup(opt)() >> val;
return val;
}
//- Read a value from the named option if present. //- Read a value from the named option if present.
// Return true if the named option was found. // Return true if the named option was found.
template<class T> template<class T>
bool optionReadIfPresent(const word& opt, T& val) const bool optionReadIfPresent(const word& opt, T& val) const;
{
if (optionFound(opt))
{
optionLookup(opt)() >> val;
return true;
}
else
{
return false;
}
}
//- Read a List of values from the named option //- Read a List of values from the named option
template<class T> template<class T>
List<T> optionReadList(const word& opt) const List<T> optionReadList(const word& opt) const;
{
return readList<T>(optionLookup(opt)());
}
// Edit // Edit
@ -300,6 +281,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "argListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-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 "argList.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
T Foam::argList::optionRead(const word& opt) const
{
T val;
optionLookup(opt)() >> val;
return val;
}
template<class T>
bool Foam::argList::optionReadIfPresent(const word& opt, T& val) const
{
if (optionFound(opt))
{
val = optionRead<T>(opt);
return true;
}
else
{
return false;
}
}
template<class T>
Foam::List<T> Foam::argList::optionReadList(const word& opt) const
{
return readList<T>(optionLookup(opt)());
}
// ************************************************************************* //

View File

@ -130,7 +130,7 @@ public:
// Member Operators // Member Operators
//- Construct given SphericalTensor2D //- Copy SphericalTensor2D
inline void operator=(const SphericalTensor2D<Cmpt>&); inline void operator=(const SphericalTensor2D<Cmpt>&);
}; };

View File

@ -474,6 +474,14 @@ public:
}; };
template<class Cmpt>
class innerProduct<Tensor2D<Cmpt>, Tensor2D<Cmpt> >
{
public:
typedef Tensor2D<Cmpt> type;
};
template<class Cmpt> template<class Cmpt>
class innerProduct<SphericalTensor2D<Cmpt>, Tensor2D<Cmpt> > class innerProduct<SphericalTensor2D<Cmpt>, Tensor2D<Cmpt> >
{ {
@ -490,6 +498,23 @@ public:
typedef Tensor2D<Cmpt> type; typedef Tensor2D<Cmpt> type;
}; };
template<class Cmpt>
class innerProduct<Tensor2D<Cmpt>, Vector2D<Cmpt> >
{
public:
typedef Vector2D<Cmpt> type;
};
template<class Cmpt>
class innerProduct<Vector2D<Cmpt>, Tensor2D<Cmpt> >
{
public:
typedef Vector2D<Cmpt> type;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -51,15 +51,6 @@ class CECCellToFaceStencil
: :
public cellToFaceStencil public cellToFaceStencil
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
CECCellToFaceStencil(const CECCellToFaceStencil&);
//- Disallow default bitwise assignment
void operator=(const CECCellToFaceStencil&);
public: public:
// Constructors // Constructors

View File

@ -51,14 +51,6 @@ class CFCCellToFaceStencil
: :
public cellToFaceStencil public cellToFaceStencil
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
CFCCellToFaceStencil(const CFCCellToFaceStencil&);
//- Disallow default bitwise assignment
void operator=(const CFCCellToFaceStencil&);
public: public:
// Constructors // Constructors

View File

@ -51,15 +51,6 @@ class CPCCellToFaceStencil
: :
public cellToFaceStencil public cellToFaceStencil
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
CPCCellToFaceStencil(const CPCCellToFaceStencil&);
//- Disallow default bitwise assignment
void operator=(const CPCCellToFaceStencil&);
public: public:
// Constructors // Constructors

View File

@ -65,13 +65,6 @@ class FECCellToFaceStencil
void calcFaceStencil(labelListList& faceStencil) const; void calcFaceStencil(labelListList& faceStencil) const;
//- Disallow default bitwise copy construct
FECCellToFaceStencil(const FECCellToFaceStencil&);
//- Disallow default bitwise assignment
void operator=(const FECCellToFaceStencil&);
public: public:
// Constructors // Constructors

View File

@ -56,11 +56,6 @@ class CFCFaceToCellStencil
void calcCellStencil(labelListList& globalCellFaces) const; void calcCellStencil(labelListList& globalCellFaces) const;
//- Disallow default bitwise copy construct
CFCFaceToCellStencil(const CFCFaceToCellStencil&);
//- Disallow default bitwise assignment
void operator=(const CFCFaceToCellStencil&);
public: public:

View File

@ -1,5 +1,6 @@
probes/probes.C probes/probes.C
probes/probesFunctionObject.C probes/probesGrouping.C
probes/probesFunctionObject/probesFunctionObject.C
sampledSet/cloud/cloudSet.C sampledSet/cloud/cloudSet.C
sampledSet/coordSet/coordSet.C sampledSet/coordSet/coordSet.C
@ -9,6 +10,7 @@ sampledSet/midPoint/midPointSet.C
sampledSet/midPointAndFace/midPointAndFaceSet.C sampledSet/midPointAndFace/midPointAndFaceSet.C
sampledSet/sampledSet/sampledSet.C sampledSet/sampledSet/sampledSet.C
sampledSet/sampledSets/sampledSets.C sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSets/sampledSetsGrouping.C
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C
sampledSet/uniform/uniformSet.C sampledSet/uniform/uniformSet.C
@ -34,6 +36,7 @@ sampledSurface/distanceSurface/distanceSurface.C
sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C
sampledSurface/sampledSurface/sampledSurface.C sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurfaces/sampledSurfaces.C sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
sampledSurface/thresholdCellFaces/thresholdCellFaces.C sampledSurface/thresholdCellFaces/thresholdCellFaces.C
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C

View File

@ -36,14 +36,9 @@ Description
#include "octreeDataCell.H" #include "octreeDataCell.H"
#include "octreeDataFace.H" #include "octreeDataFace.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void meshToMesh::calcAddressing() void Foam::meshToMesh::calcAddressing()
{ {
if (debug) if (debug)
{ {
@ -225,7 +220,7 @@ void meshToMesh::calcAddressing()
} }
void meshToMesh::cellAddresses void Foam::meshToMesh::cellAddresses
( (
labelList& cellAddressing_, labelList& cellAddressing_,
const pointField& points, const pointField& points,
@ -356,8 +351,4 @@ void meshToMesh::cellAddresses
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,14 +26,9 @@ License
#include "meshToMesh.H" #include "meshToMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void meshToMesh::calculateInverseDistanceWeights() const void Foam::meshToMesh::calculateInverseDistanceWeights() const
{ {
if (debug) if (debug)
{ {
@ -93,7 +88,7 @@ void meshToMesh::calculateInverseDistanceWeights() const
invDistCoeffs[celli][ni + 1] = invDist; invDistCoeffs[celli][ni + 1] = invDist;
sumInvDist += invDist; sumInvDist += invDist;
} }
// divide by the total inverse-distance // divide by the total inverse-distance
forAll (invDistCoeffs[celli], i) forAll (invDistCoeffs[celli], i)
{ {
@ -107,19 +102,15 @@ void meshToMesh::calculateInverseDistanceWeights() const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const scalarListList& meshToMesh::inverseDistanceWeights() const const Foam::scalarListList& Foam::meshToMesh::inverseDistanceWeights() const
{ {
if (!inverseDistanceWeightsPtr_) if (!inverseDistanceWeightsPtr_)
{ {
calculateInverseDistanceWeights(); calculateInverseDistanceWeights();
} }
return *inverseDistanceWeightsPtr_; return *inverseDistanceWeightsPtr_;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -28,20 +28,15 @@ License
#include "processorFvPatch.H" #include "processorFvPatch.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(meshToMesh, 0); defineTypeNameAndDebug(Foam::meshToMesh, 0);
const Foam::scalar Foam::meshToMesh::directHitTol = 1e-5;
const scalar meshToMesh::directHitTol = 1e-5;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
meshToMesh::meshToMesh Foam::meshToMesh::meshToMesh
( (
const fvMesh& meshFrom, const fvMesh& meshFrom,
const fvMesh& meshTo, const fvMesh& meshTo,
@ -114,7 +109,7 @@ meshToMesh::meshToMesh
} }
meshToMesh::meshToMesh Foam::meshToMesh::meshToMesh
( (
const fvMesh& meshFrom, const fvMesh& meshFrom,
const fvMesh& meshTo const fvMesh& meshTo
@ -159,7 +154,7 @@ meshToMesh::meshToMesh
<< exit(FatalError); << exit(FatalError);
} }
if if
( (
fromMesh_.boundaryMesh()[patchi].type() fromMesh_.boundaryMesh()[patchi].type()
!= toMesh_.boundaryMesh()[patchi].type() != toMesh_.boundaryMesh()[patchi].type()
@ -201,14 +196,10 @@ meshToMesh::meshToMesh
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
meshToMesh::~meshToMesh() Foam::meshToMesh::~meshToMesh()
{ {
deleteDemandDrivenData(inverseDistanceWeightsPtr_); deleteDemandDrivenData(inverseDistanceWeightsPtr_);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -56,7 +56,7 @@ class octree;
class octreeDataCell; class octreeDataCell;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class meshToMesh Declaration Class meshToMesh Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class meshToMesh class meshToMesh
@ -207,7 +207,7 @@ public:
{ {
return fromMesh_; return fromMesh_;
} }
const fvMesh& toMesh() const const fvMesh& toMesh() const
{ {
return toMesh_; return toMesh_;

View File

@ -30,15 +30,10 @@ License
#include "SubField.H" #include "SubField.H"
#include "mixedFvPatchField.H" #include "mixedFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void meshToMesh::mapField void Foam::meshToMesh::mapField
( (
Field<Type>& toF, Field<Type>& toF,
const Field<Type>& fromVf, const Field<Type>& fromVf,
@ -60,7 +55,7 @@ void meshToMesh::mapField
template<class Type> template<class Type>
void meshToMesh::interpolateField void Foam::meshToMesh::interpolateField
( (
Field<Type>& toF, Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
@ -79,7 +74,7 @@ void meshToMesh::interpolateField
{ {
const labelList& neighbours = cc[adr[celli]]; const labelList& neighbours = cc[adr[celli]];
const scalarList& w = weights[celli]; const scalarList& w = weights[celli];
toF[celli] = fromVf[adr[celli]]*w[0]; toF[celli] = fromVf[adr[celli]]*w[0];
for (label ni = 1; ni < w.size(); ni++) for (label ni = 1; ni < w.size(); ni++)
@ -92,7 +87,7 @@ void meshToMesh::interpolateField
template<class Type> template<class Type>
void meshToMesh::interpolateField void Foam::meshToMesh::interpolateField
( (
Field<Type>& toF, Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
@ -118,7 +113,7 @@ void meshToMesh::interpolateField
template<class Type> template<class Type>
void meshToMesh::interpolateInternalField void Foam::meshToMesh::interpolateInternalField
( (
Field<Type>& toF, Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
@ -160,7 +155,7 @@ void meshToMesh::interpolateInternalField
case INTERPOLATE: case INTERPOLATE:
interpolateField interpolateField
( (
toF, toF,
fromVf, fromVf,
cellAddressing_, cellAddressing_,
inverseDistanceWeights() inverseDistanceWeights()
@ -170,7 +165,7 @@ void meshToMesh::interpolateInternalField
case CELL_POINT_INTERPOLATE: case CELL_POINT_INTERPOLATE:
interpolateField interpolateField
( (
toF, toF,
fromVf, fromVf,
cellAddressing_, cellAddressing_,
toMesh_.cellCentres() toMesh_.cellCentres()
@ -190,7 +185,7 @@ void meshToMesh::interpolateInternalField
template<class Type> template<class Type>
void meshToMesh::interpolateInternalField void Foam::meshToMesh::interpolateInternalField
( (
Field<Type>& toF, Field<Type>& toF,
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf, const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
@ -203,7 +198,7 @@ void meshToMesh::interpolateInternalField
template<class Type> template<class Type>
void meshToMesh::interpolate void Foam::meshToMesh::interpolate
( (
GeometricField<Type, fvPatchField, volMesh>& toVf, GeometricField<Type, fvPatchField, volMesh>& toVf,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
@ -268,7 +263,7 @@ void meshToMesh::interpolate
).refValue() = toVf.boundaryField()[patchi]; ).refValue() = toVf.boundaryField()[patchi];
} }
} }
else if else if
( (
patchMap_.found(toPatch.name()) patchMap_.found(toPatch.name())
&& fromMeshPatches_.found(patchMap_.find(toPatch.name())()) && fromMeshPatches_.found(patchMap_.find(toPatch.name())())
@ -300,7 +295,7 @@ void meshToMesh::interpolate
template<class Type> template<class Type>
void meshToMesh::interpolate void Foam::meshToMesh::interpolate
( (
GeometricField<Type, fvPatchField, volMesh>& toVf, GeometricField<Type, fvPatchField, volMesh>& toVf,
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf, const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
@ -313,7 +308,8 @@ void meshToMesh::interpolate
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate Foam::tmp< Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
meshToMesh::order ord meshToMesh::order ord
@ -387,7 +383,8 @@ tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate Foam::tmp< Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::interpolate
( (
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf, const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
meshToMesh::order ord meshToMesh::order ord
@ -401,8 +398,4 @@ tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -32,243 +32,163 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam defineTypeNameAndDebug(Foam::probes, 0);
{
defineTypeNameAndDebug(probes, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::probes::findCells(const fvMesh& mesh) void Foam::probes::findCells(const fvMesh& mesh)
{ {
if (cellList_.empty()) cellList_.clear();
cellList_.setSize(size());
forAll(*this, probeI)
{ {
cellList_.setSize(probeLocations_.size()); const vector& location = operator[](probeI);
forAll(probeLocations_, probeI) cellList_[probeI] = mesh.findCell(location);
if (debug && cellList_[probeI] != -1)
{ {
cellList_[probeI] = mesh.findCell(probeLocations_[probeI]); Pout<< "probes : found point " << location
<< " in cell " << cellList_[probeI] << endl;
}
}
if (debug && cellList_[probeI] != -1)
// Check if all probes have been found.
forAll(cellList_, probeI)
{
const vector& location = operator[](probeI);
label cellI = cellList_[probeI];
// Check at least one processor with cell.
reduce(cellI, maxOp<label>());
if (cellI == -1)
{
if (Pstream::master())
{ {
Pout<< "probes : found point " << probeLocations_[probeI] WarningIn("probes::read()")
<< " in cell " << cellList_[probeI] << endl; << "Did not find location " << location
<< " in any cell. Skipping location." << endl;
} }
} }
else
// Check if all probes have been found.
forAll(cellList_, probeI)
{ {
label cellI = cellList_[probeI]; // Make sure location not on two domains.
if (cellList_[probeI] != -1 && cellList_[probeI] != cellI)
// Check at least one processor with cell.
reduce(cellI, maxOp<label>());
if (cellI == -1)
{ {
if (Pstream::master()) WarningIn("probes::read()")
{ << "Location " << location
WarningIn("probes::read()") << " seems to be on multiple domains:"
<< "Did not find location " << probeLocations_[probeI] << " cell " << cellList_[probeI]
<< " in any cell. Skipping location." << endl; << " on my domain " << Pstream::myProcNo()
}
}
else
{
// Make sure location not on two domains.
if (cellList_[probeI] != -1 && cellList_[probeI] != cellI)
{
WarningIn("probes::read()")
<< "Location " << probeLocations_[probeI]
<< " seems to be on multiple domains:"
<< " cell " << cellList_[probeI]
<< " on my domain " << Pstream::myProcNo()
<< " and cell " << cellI << " on some other domain." << " and cell " << cellI << " on some other domain."
<< endl << endl
<< "This might happen if the probe location is on" << "This might happen if the probe location is on"
<< " a processor patch. Change the location slightly" << " a processor patch. Change the location slightly"
<< " to prevent this." << endl; << " to prevent this." << endl;
}
} }
} }
} }
} }
bool Foam::probes::checkFieldTypes() Foam::label Foam::probes::prepare()
{ {
wordList fieldTypes(fieldNames_.size()); const label nFields = classifyFields();
// check files for a particular time
if (loadFromFiles_)
{
forAll(fieldNames_, fieldI)
{
IOobject io
(
fieldNames_[fieldI],
obr_.time().timeName(),
refCast<const polyMesh>(obr_),
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[fieldI] = io.headerClassName();
}
else
{
fieldTypes[fieldI] = "(notFound)";
}
}
}
else
{
// check objectRegistry
forAll(fieldNames_, fieldI)
{
objectRegistry::const_iterator iter =
obr_.find(fieldNames_[fieldI]);
if (iter != obr_.end())
{
fieldTypes[fieldI] = iter()->type();
}
else
{
fieldTypes[fieldI] = "(notFound)";
}
}
}
label nFields = 0;
// classify fieldTypes
nFields += countFields(scalarFields_, fieldTypes);
nFields += countFields(vectorFields_, fieldTypes);
nFields += countFields(sphericalTensorFields_, fieldTypes);
nFields += countFields(symmTensorFields_, fieldTypes);
nFields += countFields(tensorFields_, fieldTypes);
// concatenate all the lists into foundFields
wordList foundFields(nFields);
label fieldI = 0;
forAll(scalarFields_, i)
{
foundFields[fieldI++] = scalarFields_[i];
}
forAll(vectorFields_, i)
{
foundFields[fieldI++] = vectorFields_[i];
}
forAll(sphericalTensorFields_, i)
{
foundFields[fieldI++] = sphericalTensorFields_[i];
}
forAll(symmTensorFields_, i)
{
foundFields[fieldI++] = symmTensorFields_[i];
}
forAll(tensorFields_, i)
{
foundFields[fieldI++] = tensorFields_[i];
}
// adjust file streams
if (Pstream::master()) if (Pstream::master())
{ {
fileName probeDir; wordHashSet currentFields;
currentFields.insert(scalarFields_);
currentFields.insert(vectorFields_);
currentFields.insert(sphericalTensorFields_);
currentFields.insert(symmTensorFields_);
currentFields.insert(tensorFields_);
if (debug)
{
Info<< "Probing fields:" << currentFields << nl
<< "Probing locations:" << *this << nl
<< endl;
}
fileName probeDir;
fileName probeSubDir = name_; fileName probeSubDir = name_;
if (obr_.name() != polyMesh::defaultRegion) if (mesh_.name() != polyMesh::defaultRegion)
{ {
probeSubDir = probeSubDir/obr_.name(); probeSubDir = probeSubDir/mesh_.name();
} }
probeSubDir = probeSubDir/obr_.time().timeName(); probeSubDir = probeSubDir/mesh_.time().timeName();
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// Put in undecomposed case // Put in undecomposed case
// (Note: gives problems for distributed data running) // (Note: gives problems for distributed data running)
probeDir = obr_.time().path()/".."/probeSubDir; probeDir = mesh_.time().path()/".."/probeSubDir;
} }
else else
{ {
probeDir = obr_.time().path()/probeSubDir; probeDir = mesh_.time().path()/probeSubDir;
} }
// Close the file if any fields have been removed. // ignore known fields, close streams for fields that no longer exist
forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter) forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)
{ {
if (findIndex(foundFields, iter.key()) == -1) if (!currentFields.erase(iter.key()))
{ {
if (debug) if (debug)
{ {
Pout<< "close stream: " << iter()->name() << endl; Info<< "close probe stream: " << iter()->name() << endl;
} }
delete probeFilePtrs_.remove(iter); delete probeFilePtrs_.remove(iter);
} }
} }
// Open new files for new fields. Keep existing files. // currentFields now just has the new fields - open streams for them
forAllConstIter(wordHashSet, currentFields, iter)
probeFilePtrs_.resize(2*foundFields.size());
forAll(foundFields, fieldI)
{ {
const word& fldName = foundFields[fieldI]; const word& fieldName = iter.key();
// Check if added field. If so open a stream for it. // Create directory if does not exist.
mkDir(probeDir);
if (!probeFilePtrs_.found(fldName)) OFstream* sPtr = new OFstream(probeDir/fieldName);
if (debug)
{ {
// Create directory if does not exist. Info<< "open probe stream: " << sPtr->name() << endl;
mkDir(probeDir);
OFstream* sPtr = new OFstream(probeDir/fldName);
if (debug)
{
Pout<< "open stream: " << sPtr->name() << endl;
}
probeFilePtrs_.insert(fldName, sPtr);
unsigned int w = IOstream::defaultPrecision() + 7;
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
{
*sPtr<< '#' << setw(IOstream::defaultPrecision() + 6)
<< vector::componentNames[cmpt];
forAll(probeLocations_, probeI)
{
*sPtr<< ' ' << setw(w) << probeLocations_[probeI][cmpt];
}
*sPtr << endl;
}
*sPtr<< '#' << setw(IOstream::defaultPrecision() + 6)
<< "Time" << endl;
} }
}
if (debug) probeFilePtrs_.insert(fieldName, sPtr);
{
Pout<< "Probing fields:" << foundFields << nl unsigned int w = IOstream::defaultPrecision() + 7;
<< "Probing locations:" << probeLocations_ << nl
<< endl; for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
{
*sPtr<< '#' << setw(IOstream::defaultPrecision() + 6)
<< vector::componentNames[cmpt];
forAll(*this, probeI)
{
*sPtr<< ' ' << setw(w) << operator[](probeI)[cmpt];
}
*sPtr << endl;
}
*sPtr<< '#' << setw(IOstream::defaultPrecision() + 6)
<< "Time" << endl;
} }
} }
return nFields;
return nFields > 0;
} }
@ -282,18 +202,10 @@ Foam::probes::probes
const bool loadFromFiles const bool loadFromFiles
) )
: :
pointField(0),
name_(name), name_(name),
obr_(obr), mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles), loadFromFiles_(loadFromFiles)
fieldNames_(0),
probeLocations_(0),
scalarFields_(),
vectorFields_(),
sphericalTensorFields_(),
symmTensorFields_(),
tensorFields_(),
cellList_(0),
probeFilePtrs_(0)
{ {
read(dict); read(dict);
} }
@ -321,7 +233,7 @@ void Foam::probes::end()
void Foam::probes::write() void Foam::probes::write()
{ {
if (probeLocations_.size() && checkFieldTypes()) if (size() && prepare())
{ {
sampleAndWrite(scalarFields_); sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_); sampleAndWrite(vectorFields_);
@ -334,13 +246,12 @@ void Foam::probes::write()
void Foam::probes::read(const dictionary& dict) void Foam::probes::read(const dictionary& dict)
{ {
dict.lookup("fields") >> fieldNames_; dict.lookup("probeLocations") >> *this;
dict.lookup("probeLocations") >> probeLocations_; dict.lookup("fields") >> fieldSelection_;
// Force all cell locations to be redetermined // redetermined all cell locations
cellList_.clear(); findCells(mesh_);
findCells(refCast<const fvMesh>(obr_)); prepare();
checkFieldTypes();
} }

View File

@ -44,6 +44,8 @@ SourceFiles
#include "pointField.H" #include "pointField.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -60,6 +62,8 @@ class mapPolyMesh;
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class probes class probes
:
public pointField
{ {
// Private classes // Private classes
@ -67,20 +71,15 @@ class probes
template<class Type> template<class Type>
class fieldGroup class fieldGroup
: :
public wordList public DynamicList<word>
{ {
public: public:
//- Construct null //- Construct null
fieldGroup() fieldGroup()
: :
wordList() DynamicList<word>(0)
{} {}
//- Construct for a list of field names
fieldGroup(const wordList& fieldNames)
:
wordList(fieldNames)
{}
}; };
@ -90,8 +89,8 @@ class probes
// Also used as the name of the probes directory. // Also used as the name of the probes directory.
word name_; word name_;
//- Const reference to objectRegistry //- Const reference to fvMesh
const objectRegistry& obr_; const fvMesh& mesh_;
//- Load fields from files (not from objectRegistry) //- Load fields from files (not from objectRegistry)
bool loadFromFiles_; bool loadFromFiles_;
@ -100,11 +99,7 @@ class probes
// Read from dictonary // Read from dictonary
//- Names of fields to probe //- Names of fields to probe
wordList fieldNames_; wordReList fieldSelection_;
//- Locations to probe
vectorField probeLocations_;
// Calculated // Calculated
@ -124,19 +119,21 @@ class probes
// Private Member Functions // Private Member Functions
//- Clear old field groups
void clearFieldGroups();
//- Append fieldName to the appropriate group
label appendFieldGroup(const word& fieldName, const word& fieldType);
//- Classify field types, returns the number of fields
label classifyFields();
//- Find cells containing probes //- Find cells containing probes
void findCells(const fvMesh&); void findCells(const fvMesh&);
//- classify field types, return true if nFields > 0 //- Classify field type and Open/close file streams,
bool checkFieldTypes(); // returns number of fields
label prepare();
//- Find the fields in the list of the given type, return count
template<class Type>
label countFields
(
fieldGroup<Type>& fieldList,
const wordList& fieldTypes
) const;
//- Sample and write a particular volume field //- Sample and write a particular volume field
template<class Type> template<class Type>
@ -146,7 +143,7 @@ class probes
); );
//- Sample and write all the fields of the given type //- Sample and write all the fields of the given type
template <class Type> template<class Type>
void sampleAndWrite(const fieldGroup<Type>&); void sampleAndWrite(const fieldGroup<Type>&);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -188,15 +185,21 @@ public:
} }
//- Return names of fields to probe //- Return names of fields to probe
virtual const wordList& fieldNames() const virtual const wordReList& fieldNames() const
{ {
return fieldNames_; return fieldSelection_;
} }
//- Return locations to probe //- Return locations to probe
virtual const vectorField& probeLocations() const virtual const pointField& probeLocations() const
{ {
return probeLocations_; return *this;
}
//- Return location for probe i
virtual const point& probe(const label i) const
{
return operator[](i);
} }
//- Cells to be probed (obtained from the locations) //- Cells to be probed (obtained from the locations)

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "probes.H"
#include "volFields.H"
#include "IOobjectList.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::probes::clearFieldGroups()
{
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
}
Foam::label Foam::probes::appendFieldGroup
(
const word& fieldName,
const word& fieldType
)
{
if (fieldType == volScalarField::typeName)
{
scalarFields_.append(fieldName);
return 1;
}
else if (fieldType == volVectorField::typeName)
{
vectorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSphericalTensorField::typeName)
{
sphericalTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSymmTensorField::typeName)
{
symmTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volTensorField::typeName)
{
tensorFields_.append(fieldName);
return 1;
}
return 0;
}
Foam::label Foam::probes::classifyFields()
{
label nFields = 0;
clearFieldGroups();
if (loadFromFiles_)
{
// check files for a particular time
IOobjectList objects(mesh_, mesh_.time().timeName());
wordList allFields = objects.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
{
const word& fieldName = allFields[indices[fieldI]];
nFields += appendFieldGroup
(
fieldName,
objects.find(fieldName)()->headerClassName()
);
}
}
else
{
// check currently available fields
wordList allFields = mesh_.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
{
const word& fieldName = allFields[indices[fieldI]];
nFields += appendFieldGroup
(
fieldName,
mesh_.find(fieldName)()->type()
);
}
}
return nFields;
}
// ************************************************************************* //

View File

@ -63,35 +63,6 @@ public:
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::label Foam::probes::countFields
(
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> template<class Type>
void Foam::probes::sampleAndWrite void Foam::probes::sampleAndWrite
( (
@ -103,15 +74,15 @@ void Foam::probes::sampleAndWrite
if (Pstream::master()) if (Pstream::master())
{ {
unsigned int w = IOstream::defaultPrecision() + 7; unsigned int w = IOstream::defaultPrecision() + 7;
OFstream& probeStream = *probeFilePtrs_[vField.name()]; OFstream& os = *probeFilePtrs_[vField.name()];
probeStream << setw(w) << vField.time().value(); os << setw(w) << vField.time().value();
forAll(values, probeI) forAll(values, probeI)
{ {
probeStream << ' ' << setw(w) << values[probeI]; os << ' ' << setw(w) << values[probeI];
} }
probeStream << endl; os << endl;
} }
} }
@ -133,30 +104,30 @@ void Foam::probes::sampleAndWrite
IOobject IOobject
( (
fields[fieldI], fields[fieldI],
obr_.time().timeName(), mesh_.time().timeName(),
refCast<const polyMesh>(obr_), mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
refCast<const fvMesh>(obr_) mesh_
) )
); );
} }
else else
{ {
objectRegistry::const_iterator iter = obr_.find(fields[fieldI]); objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
if if
( (
iter != obr_.end() iter != objectRegistry::end()
&& iter()->type() && iter()->type()
== GeometricField<Type, fvPatchField, volMesh>::typeName == GeometricField<Type, fvPatchField, volMesh>::typeName
) )
{ {
sampleAndWrite sampleAndWrite
( (
obr_.lookupObject mesh_.lookupObject
<GeometricField<Type, fvPatchField, volMesh> > <GeometricField<Type, fvPatchField, volMesh> >
( (
fields[fieldI] fields[fieldI]
@ -181,12 +152,12 @@ Foam::probes::sample
tmp<Field<Type> > tValues tmp<Field<Type> > tValues
( (
new Field<Type>(probeLocations_.size(), unsetVal) new Field<Type>(this->size(), unsetVal)
); );
Field<Type>& values = tValues(); Field<Type>& values = tValues();
forAll(probeLocations_, probeI) forAll(*this, probeI)
{ {
if (cellList_[probeI] >= 0) if (cellList_[probeI] >= 0)
{ {
@ -207,7 +178,7 @@ Foam::probes::sample(const word& fieldName) const
{ {
return sample return sample
( (
obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> > mesh_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
( (
fieldName fieldName
) )

View File

@ -34,103 +34,12 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam defineTypeNameAndDebug(Foam::sampledSets, 0);
{
defineTypeNameAndDebug(sampledSets, 0);
}
bool Foam::sampledSets::verbose_ = false; bool Foam::sampledSets::verbose_ = false;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::sampledSets::checkFieldTypes()
{
wordList fieldTypes(fieldNames_.size());
// check files for a particular time
if (loadFromFiles_)
{
forAll(fieldNames_, fieldi)
{
IOobject io
(
fieldNames_[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[fieldi] = io.headerClassName();
}
else
{
fieldTypes[fieldi] = "(notFound)";
}
}
}
else
{
// check objectRegistry
forAll(fieldNames_, fieldi)
{
objectRegistry::const_iterator iter =
mesh_.find(fieldNames_[fieldi]);
if (iter != mesh_.objectRegistry::end())
{
fieldTypes[fieldi] = iter()->type();
}
else
{
fieldTypes[fieldi] = "(notFound)";
}
}
}
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);
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;
}
if (nFields > 0)
{
if (debug)
{
Pout<< "Creating directory "
<< outputPath_/mesh_.time().timeName()
<< nl << endl;
}
mkDir(outputPath_/mesh_.time().timeName());
}
}
return nFields > 0;
}
void Foam::sampledSets::combineSampledSets void Foam::sampledSets::combineSampledSets
( (
PtrList<coordSet>& masterSampledSets, PtrList<coordSet>& masterSampledSets,
@ -147,9 +56,9 @@ void Foam::sampledSets::combineSampledSets
const PtrList<sampledSet>& sampledSets = *this; const PtrList<sampledSet>& sampledSets = *this;
forAll(sampledSets, seti) forAll(sampledSets, setI)
{ {
const sampledSet& samplePts = sampledSets[seti]; const sampledSet& samplePts = sampledSets[setI];
// Collect data from all processors // Collect data from all processors
List<List<point> > gatheredPts(Pstream::nProcs()); List<List<point> > gatheredPts(Pstream::nProcs());
@ -190,7 +99,7 @@ void Foam::sampledSets::combineSampledSets
// Sort curveDist and use to fill masterSamplePts // Sort curveDist and use to fill masterSamplePts
SortableList<scalar> sortedDist(allCurveDist); SortableList<scalar> sortedDist(allCurveDist);
indexSets[seti] = sortedDist.indices(); indexSets[setI] = sortedDist.indices();
// Get reference point (note: only master has all points) // Get reference point (note: only master has all points)
point refPt; point refPt;
@ -207,12 +116,12 @@ void Foam::sampledSets::combineSampledSets
masterSampledSets.set masterSampledSets.set
( (
seti, setI,
new coordSet new coordSet
( (
samplePts.name(), samplePts.name(),
samplePts.axis(), samplePts.axis(),
List<point>(UIndirectList<point>(allPts, indexSets[seti])), List<point>(UIndirectList<point>(allPts, indexSets[setI])),
refPt refPt
) )
); );
@ -236,7 +145,6 @@ Foam::sampledSets::sampledSets
loadFromFiles_(loadFromFiles), loadFromFiles_(loadFromFiles),
outputPath_(fileName::null), outputPath_(fileName::null),
searchEngine_(mesh_, true), searchEngine_(mesh_, true),
fieldNames_(),
interpolationScheme_(word::null), interpolationScheme_(word::null),
writeFormat_(word::null) writeFormat_(word::null)
{ {
@ -285,13 +193,43 @@ void Foam::sampledSets::end()
void Foam::sampledSets::write() void Foam::sampledSets::write()
{ {
if (size() && checkFieldTypes()) if (size())
{ {
sampleAndWrite(scalarFields_); const label nFields = classifyFields();
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_); if (Pstream::master())
sampleAndWrite(symmTensorFields_); {
sampleAndWrite(tensorFields_); if (debug)
{
Pout<< "timeName = " << mesh_.time().timeName() << nl
<< "scalarFields " << scalarFields_ << nl
<< "vectorFields " << vectorFields_ << nl
<< "sphTensorFields " << sphericalTensorFields_ << nl
<< "symTensorFields " << symmTensorFields_ <<nl
<< "tensorFields " << tensorFields_ <<nl;
}
if (nFields)
{
if (debug)
{
Pout<< "Creating directory "
<< outputPath_/mesh_.time().timeName()
<< nl << endl;
}
mkDir(outputPath_/mesh_.time().timeName());
}
}
if (nFields)
{
sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_);
sampleAndWrite(symmTensorFields_);
sampleAndWrite(tensorFields_);
}
} }
} }
@ -299,20 +237,20 @@ void Foam::sampledSets::write()
void Foam::sampledSets::read(const dictionary& dict) void Foam::sampledSets::read(const dictionary& dict)
{ {
dict_ = dict; dict_ = dict;
dict_.lookup("fields") >> fieldSelection_;
clearFieldGroups();
fieldNames_ = wordList(dict_.lookup("fields")); interpolationScheme_ = dict.lookupOrDefault<word>
(
"interpolationScheme",
"cell"
);
writeFormat_ = dict.lookupOrDefault<word>
(
"setFormat",
"null"
);
interpolationScheme_ = "cell";
dict_.readIfPresent("interpolationScheme", interpolationScheme_);
writeFormat_ = "null";
dict_.readIfPresent("setFormat", writeFormat_);
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
PtrList<sampledSet> newList PtrList<sampledSet> newList
( (
@ -324,7 +262,7 @@ void Foam::sampledSets::read(const dictionary& dict)
if (Pstream::master() && debug) if (Pstream::master() && debug)
{ {
Pout<< "sample fields:" << fieldNames_ << nl Pout<< "sample fields:" << fieldSelection_ << nl
<< "sample sets:" << nl << "(" << nl; << "sample sets:" << nl << "(" << nl;
forAll(*this, si) forAll(*this, si)

View File

@ -43,6 +43,7 @@ SourceFiles
#include "interpolation.H" #include "interpolation.H"
#include "coordSet.H" #include "coordSet.H"
#include "writer.H" #include "writer.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,7 +55,7 @@ class dictionary;
class fvMesh; class fvMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class sampledSets Declaration Class sampledSets Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class sampledSets class sampledSets
@ -67,25 +68,40 @@ class sampledSets
template<class Type> template<class Type>
class fieldGroup class fieldGroup
: :
public wordList public DynamicList<word>
{ {
public: public:
//- Set formatter //- The set formatter
autoPtr<writer<Type> > formatter; autoPtr< writer<Type> > formatter;
//- Construct null //- Construct null
fieldGroup() fieldGroup()
: :
wordList(0), DynamicList<word>(0),
formatter(NULL) formatter(NULL)
{} {}
//- Construct for a particular format
fieldGroup(const word& writeFormat)
:
DynamicList<word>(0),
formatter(writer<Type>::New(writeFormat))
{}
//- Reset format and field list
void clear() void clear()
{ {
wordList::clear(); DynamicList<word>::clear();
formatter.clear(); formatter.clear();
} }
//- Assign a new formatter
void operator=(const word& writeFormat)
{
formatter = writer<Type>::New(writeFormat);
}
}; };
@ -161,7 +177,7 @@ class sampledSets
// Read from dictonary // Read from dictonary
//- Names of fields to sample //- Names of fields to sample
wordList fieldNames_; wordReList fieldSelection_;
//- Interpolation scheme to use //- Interpolation scheme to use
word interpolationScheme_; word interpolationScheme_;
@ -187,16 +203,14 @@ class sampledSets
// Private Member Functions // Private Member Functions
//- Classify field types, return true if nFields > 0 //- Clear old field groups
bool checkFieldTypes(); void clearFieldGroups();
//- Find the fields in the list of the given type, return count //- Append fieldName to the appropriate group
template<class Type> label appendFieldGroup(const word& fieldName, const word& fieldType);
label grep
( //- Classify field types, returns the number of fields
fieldGroup<Type>& fieldList, label classifyFields();
const wordList& fieldTypes
) const;
//- Combine points from all processors. Sort by curveDist and produce //- Combine points from all processors. Sort by curveDist and produce
// index list. Valid result only on master processor. // index list. Valid result only on master processor.

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "sampledSets.H"
#include "volFields.H"
#include "IOobjectList.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sampledSets::clearFieldGroups()
{
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
}
Foam::label Foam::sampledSets::appendFieldGroup
(
const word& fieldName,
const word& fieldType
)
{
if (fieldType == volScalarField::typeName)
{
scalarFields_.append(fieldName);
return 1;
}
else if (fieldType == volVectorField::typeName)
{
vectorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSphericalTensorField::typeName)
{
sphericalTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSymmTensorField::typeName)
{
symmTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volTensorField::typeName)
{
tensorFields_.append(fieldName);
return 1;
}
return 0;
}
Foam::label Foam::sampledSets::classifyFields()
{
label nFields = 0;
clearFieldGroups();
if (loadFromFiles_)
{
// check files for a particular time
IOobjectList objects(mesh_, mesh_.time().timeName());
wordList allFields = objects.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
{
const word& fieldName = allFields[indices[fieldI]];
nFields += appendFieldGroup
(
fieldName,
objects.find(fieldName)()->headerClassName()
);
}
}
else
{
// check currently available fields
wordList allFields = mesh_.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
{
const word& fieldName = allFields[indices[fieldI]];
nFields += appendFieldGroup
(
fieldName,
mesh_.find(fieldName)()->type()
);
}
}
return nFields;
}
// ************************************************************************* //

View File

@ -46,10 +46,10 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
interpolation<Type>::New(interpolationScheme, field) interpolation<Type>::New(interpolationScheme, field)
); );
forAll(samplers, seti) forAll(samplers, setI)
{ {
Field<Type>& values = this->operator[](seti); Field<Type>& values = this->operator[](setI);
const sampledSet& samples = samplers[seti]; const sampledSet& samples = samplers[setI];
values.setSize(samples.size()); values.setSize(samples.size());
forAll(samples, samplei) forAll(samples, samplei)
@ -79,10 +79,10 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
List<Field<Type> >(samplers.size()), List<Field<Type> >(samplers.size()),
name_(field.name()) name_(field.name())
{ {
forAll(samplers, seti) forAll(samplers, setI)
{ {
Field<Type>& values = this->operator[](seti); Field<Type>& values = this->operator[](setI);
const sampledSet& samples = samplers[seti]; const sampledSet& samples = samplers[setI];
values.setSize(samples.size()); values.setSize(samples.size());
forAll(samples, samplei) forAll(samples, samplei)
@ -105,41 +105,12 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
{} {}
template<class Type>
Foam::label Foam::sampledSets::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> template<class Type>
void Foam::sampledSets::writeSampleFile void Foam::sampledSets::writeSampleFile
( (
const coordSet& masterSampleSet, const coordSet& masterSampleSet,
const PtrList<volFieldSampler<Type> >& masterFields, const PtrList<volFieldSampler<Type> >& masterFields,
const label seti, const label setI,
const fileName& timeDir, const fileName& timeDir,
const writer<Type>& formatter const writer<Type>& formatter
) )
@ -150,7 +121,7 @@ void Foam::sampledSets::writeSampleFile
forAll(masterFields, fieldi) forAll(masterFields, fieldi)
{ {
valueSetNames[fieldi] = masterFields[fieldi].name(); valueSetNames[fieldi] = masterFields[fieldi].name();
valueSets[fieldi] = &masterFields[fieldi][seti]; valueSets[fieldi] = &masterFields[fieldi][setI];
} }
fileName fName fileName fName
@ -180,11 +151,11 @@ void Foam::sampledSets::combineSampledValues
{ {
List<Field<T> > masterValues(indexSets.size()); List<Field<T> > masterValues(indexSets.size());
forAll(indexSets, seti) forAll(indexSets, setI)
{ {
// Collect data from all processors // Collect data from all processors
List<Field<T> > gatheredData(Pstream::nProcs()); List<Field<T> > gatheredData(Pstream::nProcs());
gatheredData[Pstream::myProcNo()] = sampledFields[fieldi][seti]; gatheredData[Pstream::myProcNo()] = sampledFields[fieldi][setI];
Pstream::gatherList(gatheredData); Pstream::gatherList(gatheredData);
if (Pstream::master()) if (Pstream::master())
@ -198,10 +169,10 @@ void Foam::sampledSets::combineSampledValues
) )
); );
masterValues[seti] = UIndirectList<T> masterValues[setI] = UIndirectList<T>
( (
allData, allData,
indexSets[seti] indexSets[setI]
)(); )();
} }
} }
@ -232,7 +203,7 @@ void Foam::sampledSets::sampleAndWrite
// Create or use existing writer // Create or use existing writer
if (fields.formatter.empty()) if (fields.formatter.empty())
{ {
fields.formatter = writer<Type>::New(writeFormat_); fields = writeFormat_;
} }
// Storage for interpolated values // Storage for interpolated values
@ -326,13 +297,13 @@ void Foam::sampledSets::sampleAndWrite
if (Pstream::master()) if (Pstream::master())
{ {
forAll(masterSampledSets_, seti) forAll(masterSampledSets_, setI)
{ {
writeSampleFile writeSampleFile
( (
masterSampledSets_[seti], masterSampledSets_[setI],
masterFields, masterFields,
seti, setI,
outputPath_/mesh_.time().timeName(), outputPath_/mesh_.time().timeName(),
fields.formatter() fields.formatter()
); );

View File

@ -153,7 +153,7 @@ void Foam::vtkSetWriter<Type>::write
label globalPtI = 0; label globalPtI = 0;
forAll(tracks, trackI) forAll(tracks, trackI)
{ {
const coordSet& points = tracks[trackI]; const coordSet& points = tracks[trackI];
os << points.size(); os << points.size();
forAll(points, i) forAll(points, i)
@ -164,7 +164,7 @@ void Foam::vtkSetWriter<Type>::write
os << nl; os << nl;
} }
} }
os << "POINT_DATA " << nPoints << nl os << "POINT_DATA " << nPoints << nl
<< " FIELD attributes " << valueSetNames.size() << nl; << " FIELD attributes " << valueSetNames.size() << nl;

View File

@ -243,7 +243,7 @@ bool Foam::sampledIsoSurfaceCell::expire()
{ {
return false; return false;
} }
// force update // force update
prevTimeIndex_ = -1; prevTimeIndex_ = -1;
return true; return true;

View File

@ -35,6 +35,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::sampledSurfaces, 0);
bool Foam::sampledSurfaces::verbose_ = false;
Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1e-10;
namespace Foam namespace Foam
{ {
//- Used to offset faces in Pstream::combineOffset //- Used to offset faces in Pstream::combineOffset
@ -60,101 +64,11 @@ namespace Foam
} }
}; };
defineTypeNameAndDebug(sampledSurfaces, 0);
} }
bool Foam::sampledSurfaces::verbose_(false);
Foam::scalar Foam::sampledSurfaces::mergeTol_(1e-10);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::sampledSurfaces::classifyFieldTypes()
{
label nFields = 0;
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
forAll(fieldNames_, fieldI)
{
const word& fieldName = fieldNames_[fieldI];
word fieldType = "";
// check files for a particular time
if (loadFromFiles_)
{
IOobject io
(
fieldName,
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldType = io.headerClassName();
}
else
{
continue;
}
}
else
{
// check objectRegistry
objectRegistry::const_iterator iter = mesh_.find(fieldName);
if (iter != mesh_.objectRegistry::end())
{
fieldType = iter()->type();
}
else
{
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;
}
void Foam::sampledSurfaces::writeGeometry() const void Foam::sampledSurfaces::writeGeometry() const
{ {
// Write to time directory under outputPath_ // Write to time directory under outputPath_
@ -208,7 +122,7 @@ Foam::sampledSurfaces::sampledSurfaces
mesh_(refCast<const fvMesh>(obr)), mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles), loadFromFiles_(loadFromFiles),
outputPath_(fileName::null), outputPath_(fileName::null),
fieldNames_(), fieldSelection_(),
interpolationScheme_(word::null), interpolationScheme_(word::null),
writeFormat_(word::null), writeFormat_(word::null),
mergeList_(), mergeList_(),
@ -265,7 +179,7 @@ void Foam::sampledSurfaces::write()
// finalize surfaces, merge points etc. // finalize surfaces, merge points etc.
update(); update();
const label nFields = classifyFieldTypes(); const label nFields = classifyFields();
if (Pstream::master()) if (Pstream::master())
{ {
@ -286,8 +200,8 @@ void Foam::sampledSurfaces::write()
mkDir(outputPath_/mesh_.time().timeName()); mkDir(outputPath_/mesh_.time().timeName());
} }
// write geometry first if required, or when no fields would otherwise // write geometry first if required,
// be written // or when no fields would otherwise be written
if (nFields == 0 || genericFormatter_->separateFiles()) if (nFields == 0 || genericFormatter_->separateFiles())
{ {
writeGeometry(); writeGeometry();
@ -304,15 +218,8 @@ void Foam::sampledSurfaces::write()
void Foam::sampledSurfaces::read(const dictionary& dict) void Foam::sampledSurfaces::read(const dictionary& dict)
{ {
fieldNames_ = wordList(dict.lookup("fields")); dict.lookup("fields") >> fieldSelection_;
clearFieldGroups();
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_ = dict.lookupOrDefault<word>
( (
@ -335,7 +242,6 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
dict.lookup("surfaces"), dict.lookup("surfaces"),
sampledSurface::iNew(mesh_) sampledSurface::iNew(mesh_)
); );
transfer(newList); transfer(newList);
if (Pstream::parRun()) if (Pstream::parRun())
@ -348,7 +254,7 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
if (Pstream::master() && debug) if (Pstream::master() && debug)
{ {
Pout<< "sample fields:" << fieldNames_ << nl Pout<< "sample fields:" << fieldSelection_ << nl
<< "sample surfaces:" << nl << "(" << nl; << "sample surfaces:" << nl << "(" << nl;
forAll(*this, surfI) forAll(*this, surfI)

View File

@ -41,6 +41,7 @@ SourceFiles
#include "sampledSurface.H" #include "sampledSurface.H"
#include "surfaceWriter.H" #include "surfaceWriter.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -51,7 +52,7 @@ class fvMesh;
class dictionary; class dictionary;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class sampledSurfaces Declaration Class sampledSurfaces Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class sampledSurfaces class sampledSurfaces
@ -68,7 +69,7 @@ class sampledSurfaces
{ {
public: public:
//- Surface formatter //- The surface formatter
autoPtr< surfaceWriter<Type> > formatter; autoPtr< surfaceWriter<Type> > formatter;
//- Construct null //- Construct null
@ -85,34 +86,19 @@ class sampledSurfaces
formatter(surfaceWriter<Type>::New(writeFormat)) formatter(surfaceWriter<Type>::New(writeFormat))
{} {}
//- Construct for a particular surface format and a list of field //- Reset format and field list
// names void clear()
fieldGroup
(
const word& writeFormat,
const wordList& fieldNames
)
:
DynamicList<word>(fieldNames),
formatter(surfaceWriter<Type>::New(writeFormat))
{}
void reset(const label nElem)
{ {
DynamicList<word>::clear();
formatter.clear(); formatter.clear();
DynamicList<word>::setCapacity(nElem);
DynamicList<word>::clear();
} }
//- Assign a new formatter
void operator=(const word& writeFormat) void operator=(const word& writeFormat)
{ {
formatter = surfaceWriter<Type>::New(writeFormat); formatter = surfaceWriter<Type>::New(writeFormat);
} }
void operator=(const wordList& fieldNames)
{
DynamicList<word>::operator=(fieldNames);
}
}; };
@ -161,7 +147,7 @@ class sampledSurfaces
// Read from dictonary // Read from dictonary
//- Names of fields to sample //- Names of fields to sample
wordList fieldNames_; wordReList fieldSelection_;
//- Interpolation scheme to use //- Interpolation scheme to use
word interpolationScheme_; word interpolationScheme_;
@ -191,8 +177,14 @@ class sampledSurfaces
// Private Member Functions // Private Member Functions
//- Clear old field groups
void clearFieldGroups();
//- Append fieldName to the appropriate group
label appendFieldGroup(const word& fieldName, const word& fieldType);
//- Classify field types, returns the number of fields //- Classify field types, returns the number of fields
label classifyFieldTypes(); label classifyFields();
//- Write geometry only //- Write geometry only
void writeGeometry() const; void writeGeometry() const;

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "sampledSurfaces.H"
#include "volFields.H"
#include "IOobjectList.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sampledSurfaces::clearFieldGroups()
{
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
}
Foam::label Foam::sampledSurfaces::appendFieldGroup
(
const word& fieldName,
const word& fieldType
)
{
if (fieldType == volScalarField::typeName)
{
scalarFields_.append(fieldName);
return 1;
}
else if (fieldType == volVectorField::typeName)
{
vectorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSphericalTensorField::typeName)
{
sphericalTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSymmTensorField::typeName)
{
symmTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volTensorField::typeName)
{
tensorFields_.append(fieldName);
return 1;
}
return 0;
}
Foam::label Foam::sampledSurfaces::classifyFields()
{
label nFields = 0;
clearFieldGroups();
// check files for a particular time
if (loadFromFiles_)
{
IOobjectList objects(mesh_, mesh_.time().timeName());
wordList allFields = objects.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
{
const word& fieldName = allFields[indices[fieldI]];
nFields += appendFieldGroup
(
fieldName,
objects.find(fieldName)()->headerClassName()
);
}
}
else
{
wordList allFields = mesh_.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
{
const word& fieldName = allFields[indices[fieldI]];
nFields += appendFieldGroup
(
fieldName,
mesh_.find(fieldName)()->type()
);
}
}
return nFields;
}
// ************************************************************************* //

View File

@ -178,7 +178,7 @@ void Foam::sampledSurfaces::sampleAndWrite
if if
( (
iter != mesh_.objectRegistry::end() iter != objectRegistry::end()
&& iter()->type() && iter()->type()
== GeometricField<Type, fvPatchField, volMesh>::typeName == GeometricField<Type, fvPatchField, volMesh>::typeName
) )

View File

@ -67,7 +67,7 @@ class thresholdCellFaces
void calculate void calculate
( (
const scalarField&, const scalarField&,
const scalar lowerThreshold, const scalar lowerThreshold,
const scalar upperThreshold, const scalar upperThreshold,
const bool triangulate const bool triangulate

View File

@ -1,6 +1,6 @@
.SUFFIXES: .C .cxx .cc .cpp .SUFFIXES: .C .cxx .cc .cpp
c++WARN = -wd654,819,1125,1476,1505,1572 c++WARN = -wd327,654,819,1125,1476,1505,1572
CC = icpc CC = icpc

View File

@ -1,6 +1,6 @@
.SUFFIXES: .C .cxx .cc .cpp .SUFFIXES: .C .cxx .cc .cpp
c++WARN = -wd654,819,1125,1476,1505,1572 c++WARN = -wd327,654,819,1125,1476,1505,1572
CC = icpc CC = icpc

View File

@ -1,6 +1,6 @@
.SUFFIXES: .C .cxx .cc .cpp .SUFFIXES: .C .cxx .cc .cpp
c++WARN = -wd654,819,1125,1476,1505,1572 c++WARN = -wd327,654,819,1125,1476,1505,1572
#CC = icpc -gcc-version=400 #CC = icpc -gcc-version=400
CC = icpc CC = icpc