mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -51,7 +51,9 @@ doc/[Dd]oxygen/latex
|
||||
doc/[Dd]oxygen/man
|
||||
|
||||
# generated files in the main directory (e.g. ReleaseNotes-?.?.html)
|
||||
# and in the doc directory
|
||||
/*.html
|
||||
/doc/*.html
|
||||
|
||||
# source packages - anywhere
|
||||
*.tar.bz2
|
||||
|
||||
@ -92,6 +92,8 @@ int main(int argc, char *argv[])
|
||||
labelHashSet setD(1);
|
||||
setD.insert(11);
|
||||
setD.insert(100);
|
||||
setD.insert(49);
|
||||
setD.insert(36);
|
||||
setD.insert(2008);
|
||||
|
||||
Info<< "setD : " << setD << endl;
|
||||
@ -138,6 +140,17 @@ int main(int argc, char *argv[])
|
||||
// this doesn't work (yet?)
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
# \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
@ -36,7 +36,7 @@
|
||||
# Note
|
||||
# The foamCopySettings.rc (found with the ~OpenFOAM expansion) can be used
|
||||
# to add any custom rsync options.
|
||||
#------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
Script=${0##*/}
|
||||
if [ "$1" = "-h" -o "$1" = "-help" -o "$#" -ne 2 ]
|
||||
then
|
||||
@ -48,8 +48,8 @@ Usage: $Script srcDir dstDir
|
||||
- requires rsync
|
||||
|
||||
Note
|
||||
The $Script.rc (found with the ~OpenFOAM expansion) can be used
|
||||
to add any custom rsync options.
|
||||
The $Script.rc (found via the ~OpenFOAM expansion - see foamEtcFile)
|
||||
can be used to add any custom rsync options.
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
@ -78,7 +78,6 @@ done
|
||||
# avoid processor directories here too to make for cleaner output
|
||||
fileList=$(find -H $srcDir -mindepth 1 -maxdepth 1 -not -name "processor*")
|
||||
|
||||
|
||||
# avoid polyMesh and processor* directories
|
||||
rsync="rsync --exclude polyMesh --exclude processor*"
|
||||
|
||||
@ -108,15 +107,20 @@ do
|
||||
# skip numerical (results) directories (except 0)
|
||||
# and things that look like log files or queuing system output
|
||||
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]"
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
# skip things that look sampled directories and converted data
|
||||
( probes | sets | surfaces | En[Ss]ight )
|
||||
echo "$i [skipped]"
|
||||
continue
|
||||
;;
|
||||
(*)
|
||||
echo "$i -> $dstDir/$name"
|
||||
$rsync -a $i $dstDir
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# --------------------------------------------------------------- end-of-file
|
||||
# ------------------------------------------------------------------ end-of-file
|
||||
|
||||
108
bin/tools/org-batch
Executable file
108
bin/tools/org-batch
Executable 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
1
bin/tools/org-html
Symbolic link
@ -0,0 +1 @@
|
||||
org-batch
|
||||
1
bin/tools/org-latex
Symbolic link
1
bin/tools/org-latex
Symbolic link
@ -0,0 +1 @@
|
||||
org-batch
|
||||
@ -132,7 +132,7 @@ unset MPI_ARCH_PATH
|
||||
|
||||
switch ("$WM_MPLIB")
|
||||
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_ARCH_PATH $MPI_HOME/platforms/$WM_OPTIONS
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ unset MPI_ARCH_PATH
|
||||
|
||||
case "$WM_MPLIB" in
|
||||
OPENMPI)
|
||||
mpi_version=openmpi-1.3.3
|
||||
mpi_version=openmpi-1.3.4
|
||||
export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version
|
||||
export MPI_ARCH_PATH=$MPI_HOME/platforms/$WM_OPTIONS
|
||||
|
||||
|
||||
@ -32,14 +32,30 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Key, class Hash>
|
||||
template<class AnyType>
|
||||
Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& h)
|
||||
Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst)
|
||||
:
|
||||
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())
|
||||
{
|
||||
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
|
||||
)
|
||||
@ -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 * * * * * * * * * * * * * //
|
||||
|
||||
template<class Key, class Hash>
|
||||
|
||||
@ -84,15 +84,7 @@ public:
|
||||
{}
|
||||
|
||||
//- Construct from UList of Key
|
||||
HashSet(const UList<Key>& lst)
|
||||
:
|
||||
HashTable<nil, Key, Hash>(2*lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
insert(lst[i]);
|
||||
}
|
||||
}
|
||||
HashSet(const UList<Key>&);
|
||||
|
||||
//- Construct as copy
|
||||
HashSet(const HashSet<Key, Hash>& hs)
|
||||
@ -114,8 +106,9 @@ public:
|
||||
|
||||
//- Construct from the keys of another HashTable,
|
||||
// the type of values held is arbitrary.
|
||||
template<class AnyType>
|
||||
HashSet(const HashTable<AnyType, Key, Hash>&);
|
||||
template<class AnyType, class AnyHash>
|
||||
HashSet(const HashTable<AnyType, Key, AnyHash>&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -127,12 +120,23 @@ public:
|
||||
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)
|
||||
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
|
||||
|
||||
//- Return true if the entry exists, same as found()
|
||||
@ -163,7 +167,6 @@ public:
|
||||
|
||||
//- Remove entries listed in the given HashSet from this HashSet
|
||||
void operator-=(const HashSet<Key, Hash>&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ Foam::IOobjectList::IOobjectList
|
||||
}
|
||||
}
|
||||
|
||||
// Create list file names in directory
|
||||
// Create a list of file names in this directory
|
||||
fileNameList ObjectNames =
|
||||
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)
|
||||
{
|
||||
Info<< "IOobjectList::lookup : found " << name
|
||||
<< endl;
|
||||
Info<< "IOobjectList::lookup : found "
|
||||
<< name << endl;
|
||||
}
|
||||
|
||||
return const_cast<IOobject*>(*iter);
|
||||
@ -140,8 +140,8 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
Info<< "IOobjectList::lookup : could not find " << name
|
||||
<< endl;
|
||||
Info<< "IOobjectList::lookup : could not find "
|
||||
<< name << endl;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -151,7 +151,7 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
|
||||
|
||||
Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const
|
||||
{
|
||||
IOobjectList IOobjectsOfClass(size());
|
||||
IOobjectList objectsOfClass(size());
|
||||
|
||||
for
|
||||
(
|
||||
@ -165,34 +165,26 @@ Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const
|
||||
if (IOobject::debug)
|
||||
{
|
||||
Info<< "IOobjectList::lookupClass : found "
|
||||
<< iter()->name()
|
||||
<< endl;
|
||||
<< iter.key() << 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
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -84,23 +84,29 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Add an IOobject to list
|
||||
//- Add an IOobject to the list
|
||||
bool add(IOobject&);
|
||||
|
||||
//- Remove an IOobject from list
|
||||
//- Remove an IOobject from the list
|
||||
bool remove(IOobject&);
|
||||
|
||||
//- Lookup a given name and return IOobject ptr if found else NULL
|
||||
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;
|
||||
|
||||
//- Return the list of names of the IOobjects
|
||||
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
|
||||
wordList names(const word& className) const;
|
||||
|
||||
//- Return the sorted list of names of the IOobjects of given class
|
||||
wordList sortedNames(const word& className) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -29,6 +29,19 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * 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>
|
||||
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
|
||||
(
|
||||
|
||||
@ -29,6 +29,11 @@ Description
|
||||
IOdictionary wrapper around OutputFilter to allow them to read from
|
||||
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
|
||||
IOOutputFilter.C
|
||||
|
||||
@ -69,6 +74,15 @@ public:
|
||||
|
||||
// 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
|
||||
// Allow dictionary to be optional
|
||||
// Allow the possibility to load fields from files
|
||||
|
||||
@ -93,7 +93,7 @@ Foam::objectRegistry::~objectRegistry()
|
||||
}
|
||||
}
|
||||
|
||||
for (label i=0; i<nMyObjects; i++)
|
||||
for (label i=0; i < nMyObjects; i++)
|
||||
{
|
||||
checkOut(*myObjects[i]);
|
||||
}
|
||||
@ -104,15 +104,13 @@ Foam::objectRegistry::~objectRegistry()
|
||||
|
||||
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)
|
||||
{
|
||||
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 word& name
|
||||
@ -151,8 +158,8 @@ Foam::label Foam::objectRegistry::getEvent() const
|
||||
if (event_ == labelMax)
|
||||
{
|
||||
WarningIn("objectRegistry::getEvent() const")
|
||||
<< "Event counter has overflowed. Resetting counter on all"
|
||||
<< " dependent objects." << endl
|
||||
<< "Event counter has overflowed. "
|
||||
<< "Resetting counter on all dependent objects." << nl
|
||||
<< "This might cause extra evaluations." << endl;
|
||||
|
||||
// Reset event counter
|
||||
@ -202,7 +209,7 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
Pout<< "objectRegistry::checkOut(regIOobject&) : "
|
||||
<< name() << " : checking out " << io.name()
|
||||
<< name() << " : checking out " << iter.key()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -211,7 +218,8 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
WarningIn("objectRegistry::checkOut(regIOobject&)")
|
||||
<< name() << " : attempt to checkOut copy of " << io.name()
|
||||
<< name() << " : attempt to checkOut copy of "
|
||||
<< iter.key()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -286,8 +294,7 @@ void Foam::objectRegistry::readModifiedObjects()
|
||||
{
|
||||
Pout<< "objectRegistry::readModifiedObjects() : "
|
||||
<< name() << " : Considering reading object "
|
||||
<< iter()->name()
|
||||
<< endl;
|
||||
<< iter.key() << endl;
|
||||
}
|
||||
|
||||
iter()->readIfModified();
|
||||
@ -317,7 +324,7 @@ bool Foam::objectRegistry::writeObject
|
||||
{
|
||||
Pout<< "objectRegistry::write() : "
|
||||
<< name() << " : Considering writing object "
|
||||
<< iter()->name()
|
||||
<< iter.key()
|
||||
<< " with writeOpt " << iter()->writeOpt()
|
||||
<< " to file " << iter()->objectPath()
|
||||
<< endl;
|
||||
|
||||
@ -132,9 +132,15 @@ public:
|
||||
//- Return the list of names of the IOobjects
|
||||
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;
|
||||
|
||||
//- 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
|
||||
template<class Type>
|
||||
wordList names() const;
|
||||
@ -142,11 +148,11 @@ public:
|
||||
//- Lookup and return a const sub-objectRegistry
|
||||
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>
|
||||
HashTable<const Type*> lookupClass() const;
|
||||
|
||||
//- Is the named Type
|
||||
//- Is the named Type found?
|
||||
template<class Type>
|
||||
bool foundObject(const word& name) const;
|
||||
|
||||
|
||||
@ -234,35 +234,16 @@ public:
|
||||
|
||||
//- Read a value from the named option
|
||||
template<class T>
|
||||
T optionRead(const word& opt) const
|
||||
{
|
||||
T val;
|
||||
optionLookup(opt)() >> val;
|
||||
return val;
|
||||
}
|
||||
T optionRead(const word& opt) const;
|
||||
|
||||
//- Read a value from the named option if present.
|
||||
// Return true if the named option was found.
|
||||
template<class T>
|
||||
bool optionReadIfPresent(const word& opt, T& val) const
|
||||
{
|
||||
if (optionFound(opt))
|
||||
{
|
||||
optionLookup(opt)() >> val;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool optionReadIfPresent(const word& opt, T& val) const;
|
||||
|
||||
//- Read a List of values from the named option
|
||||
template<class T>
|
||||
List<T> optionReadList(const word& opt) const
|
||||
{
|
||||
return readList<T>(optionLookup(opt)());
|
||||
}
|
||||
List<T> optionReadList(const word& opt) const;
|
||||
|
||||
|
||||
// Edit
|
||||
@ -300,6 +281,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "argListTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
63
src/OpenFOAM/global/argList/argListTemplates.C
Normal file
63
src/OpenFOAM/global/argList/argListTemplates.C
Normal 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)());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -130,7 +130,7 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Construct given SphericalTensor2D
|
||||
//- Copy SphericalTensor2D
|
||||
inline void operator=(const SphericalTensor2D<Cmpt>&);
|
||||
};
|
||||
|
||||
|
||||
@ -474,6 +474,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<Tensor2D<Cmpt>, Tensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SphericalTensor2D<Cmpt>, Tensor2D<Cmpt> >
|
||||
{
|
||||
@ -490,6 +498,23 @@ public:
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -51,15 +51,6 @@ class CECCellToFaceStencil
|
||||
:
|
||||
public cellToFaceStencil
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
CECCellToFaceStencil(const CECCellToFaceStencil&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CECCellToFaceStencil&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -51,14 +51,6 @@ class CFCCellToFaceStencil
|
||||
:
|
||||
public cellToFaceStencil
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
CFCCellToFaceStencil(const CFCCellToFaceStencil&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CFCCellToFaceStencil&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -51,15 +51,6 @@ class CPCCellToFaceStencil
|
||||
:
|
||||
public cellToFaceStencil
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
CPCCellToFaceStencil(const CPCCellToFaceStencil&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CPCCellToFaceStencil&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -65,13 +65,6 @@ class FECCellToFaceStencil
|
||||
void calcFaceStencil(labelListList& faceStencil) const;
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
FECCellToFaceStencil(const FECCellToFaceStencil&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const FECCellToFaceStencil&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -56,11 +56,6 @@ class CFCFaceToCellStencil
|
||||
|
||||
void calcCellStencil(labelListList& globalCellFaces) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
CFCFaceToCellStencil(const CFCFaceToCellStencil&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CFCFaceToCellStencil&);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
probes/probes.C
|
||||
probes/probesFunctionObject.C
|
||||
probes/probesGrouping.C
|
||||
probes/probesFunctionObject/probesFunctionObject.C
|
||||
|
||||
sampledSet/cloud/cloudSet.C
|
||||
sampledSet/coordSet/coordSet.C
|
||||
@ -9,6 +10,7 @@ sampledSet/midPoint/midPointSet.C
|
||||
sampledSet/midPointAndFace/midPointAndFaceSet.C
|
||||
sampledSet/sampledSet/sampledSet.C
|
||||
sampledSet/sampledSets/sampledSets.C
|
||||
sampledSet/sampledSets/sampledSetsGrouping.C
|
||||
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
|
||||
sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C
|
||||
sampledSet/uniform/uniformSet.C
|
||||
@ -34,6 +36,7 @@ sampledSurface/distanceSurface/distanceSurface.C
|
||||
sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C
|
||||
sampledSurface/sampledSurface/sampledSurface.C
|
||||
sampledSurface/sampledSurfaces/sampledSurfaces.C
|
||||
sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
|
||||
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
|
||||
sampledSurface/thresholdCellFaces/thresholdCellFaces.C
|
||||
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
|
||||
|
||||
@ -36,14 +36,9 @@ Description
|
||||
#include "octreeDataCell.H"
|
||||
#include "octreeDataFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void meshToMesh::calcAddressing()
|
||||
void Foam::meshToMesh::calcAddressing()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -225,7 +220,7 @@ void meshToMesh::calcAddressing()
|
||||
}
|
||||
|
||||
|
||||
void meshToMesh::cellAddresses
|
||||
void Foam::meshToMesh::cellAddresses
|
||||
(
|
||||
labelList& cellAddressing_,
|
||||
const pointField& points,
|
||||
@ -356,8 +351,4 @@ void meshToMesh::cellAddresses
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,14 +26,9 @@ License
|
||||
|
||||
#include "meshToMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void meshToMesh::calculateInverseDistanceWeights() const
|
||||
void Foam::meshToMesh::calculateInverseDistanceWeights() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -107,7 +102,7 @@ void meshToMesh::calculateInverseDistanceWeights() const
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const scalarListList& meshToMesh::inverseDistanceWeights() const
|
||||
const Foam::scalarListList& Foam::meshToMesh::inverseDistanceWeights() const
|
||||
{
|
||||
if (!inverseDistanceWeightsPtr_)
|
||||
{
|
||||
@ -118,8 +113,4 @@ const scalarListList& meshToMesh::inverseDistanceWeights() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -28,20 +28,15 @@ License
|
||||
#include "processorFvPatch.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(meshToMesh, 0);
|
||||
|
||||
const scalar meshToMesh::directHitTol = 1e-5;
|
||||
defineTypeNameAndDebug(Foam::meshToMesh, 0);
|
||||
const Foam::scalar Foam::meshToMesh::directHitTol = 1e-5;
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
meshToMesh::meshToMesh
|
||||
Foam::meshToMesh::meshToMesh
|
||||
(
|
||||
const fvMesh& meshFrom,
|
||||
const fvMesh& meshTo,
|
||||
@ -114,7 +109,7 @@ meshToMesh::meshToMesh
|
||||
}
|
||||
|
||||
|
||||
meshToMesh::meshToMesh
|
||||
Foam::meshToMesh::meshToMesh
|
||||
(
|
||||
const fvMesh& meshFrom,
|
||||
const fvMesh& meshTo
|
||||
@ -201,14 +196,10 @@ meshToMesh::meshToMesh
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
meshToMesh::~meshToMesh()
|
||||
Foam::meshToMesh::~meshToMesh()
|
||||
{
|
||||
deleteDemandDrivenData(inverseDistanceWeightsPtr_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -56,7 +56,7 @@ class octree;
|
||||
class octreeDataCell;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class meshToMesh Declaration
|
||||
Class meshToMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class meshToMesh
|
||||
|
||||
@ -30,15 +30,10 @@ License
|
||||
#include "SubField.H"
|
||||
#include "mixedFvPatchField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::mapField
|
||||
void Foam::meshToMesh::mapField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const Field<Type>& fromVf,
|
||||
@ -60,7 +55,7 @@ void meshToMesh::mapField
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateField
|
||||
void Foam::meshToMesh::interpolateField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
@ -92,7 +87,7 @@ void meshToMesh::interpolateField
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateField
|
||||
void Foam::meshToMesh::interpolateField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
@ -118,7 +113,7 @@ void meshToMesh::interpolateField
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateInternalField
|
||||
void Foam::meshToMesh::interpolateInternalField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
@ -190,7 +185,7 @@ void meshToMesh::interpolateInternalField
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateInternalField
|
||||
void Foam::meshToMesh::interpolateInternalField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
|
||||
@ -203,7 +198,7 @@ void meshToMesh::interpolateInternalField
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolate
|
||||
void Foam::meshToMesh::interpolate
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& toVf,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
@ -300,7 +295,7 @@ void meshToMesh::interpolate
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolate
|
||||
void Foam::meshToMesh::interpolate
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& toVf,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
|
||||
@ -313,7 +308,8 @@ void meshToMesh::interpolate
|
||||
|
||||
|
||||
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,
|
||||
meshToMesh::order ord
|
||||
@ -387,7 +383,8 @@ tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate
|
||||
|
||||
|
||||
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,
|
||||
meshToMesh::order ord
|
||||
@ -401,8 +398,4 @@ tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -32,243 +32,163 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(probes, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::probes, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
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]
|
||||
<< " in cell " << cellList_[probeI] << endl;
|
||||
WarningIn("probes::read()")
|
||||
<< "Did not find location " << location
|
||||
<< " in any cell. Skipping location." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if all probes have been found.
|
||||
forAll(cellList_, probeI)
|
||||
else
|
||||
{
|
||||
label cellI = cellList_[probeI];
|
||||
|
||||
// Check at least one processor with cell.
|
||||
reduce(cellI, maxOp<label>());
|
||||
|
||||
if (cellI == -1)
|
||||
// Make sure location not on two domains.
|
||||
if (cellList_[probeI] != -1 && cellList_[probeI] != cellI)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
WarningIn("probes::read()")
|
||||
<< "Did not find location " << probeLocations_[probeI]
|
||||
<< " in any cell. Skipping location." << endl;
|
||||
}
|
||||
}
|
||||
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()
|
||||
WarningIn("probes::read()")
|
||||
<< "Location " << location
|
||||
<< " seems to be on multiple domains:"
|
||||
<< " cell " << cellList_[probeI]
|
||||
<< " on my domain " << Pstream::myProcNo()
|
||||
<< " and cell " << cellI << " on some other domain."
|
||||
<< endl
|
||||
<< "This might happen if the probe location is on"
|
||||
<< " a processor patch. Change the location slightly"
|
||||
<< " to prevent this." << endl;
|
||||
}
|
||||
<< endl
|
||||
<< "This might happen if the probe location is on"
|
||||
<< " a processor patch. Change the location slightly"
|
||||
<< " to prevent this." << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::probes::checkFieldTypes()
|
||||
Foam::label Foam::probes::prepare()
|
||||
{
|
||||
wordList fieldTypes(fieldNames_.size());
|
||||
|
||||
// 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];
|
||||
}
|
||||
const label nFields = classifyFields();
|
||||
|
||||
// adjust file streams
|
||||
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_;
|
||||
|
||||
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())
|
||||
{
|
||||
// Put in undecomposed case
|
||||
// (Note: gives problems for distributed data running)
|
||||
probeDir = obr_.time().path()/".."/probeSubDir;
|
||||
probeDir = mesh_.time().path()/".."/probeSubDir;
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (findIndex(foundFields, iter.key()) == -1)
|
||||
if (!currentFields.erase(iter.key()))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "close stream: " << iter()->name() << endl;
|
||||
Info<< "close probe stream: " << iter()->name() << endl;
|
||||
}
|
||||
|
||||
delete probeFilePtrs_.remove(iter);
|
||||
}
|
||||
}
|
||||
|
||||
// Open new files for new fields. Keep existing files.
|
||||
|
||||
probeFilePtrs_.resize(2*foundFields.size());
|
||||
|
||||
forAll(foundFields, fieldI)
|
||||
// currentFields now just has the new fields - open streams for them
|
||||
forAllConstIter(wordHashSet, currentFields, iter)
|
||||
{
|
||||
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.
|
||||
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;
|
||||
Info<< "open probe stream: " << sPtr->name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Probing fields:" << foundFields << nl
|
||||
<< "Probing locations:" << probeLocations_ << nl
|
||||
<< endl;
|
||||
probeFilePtrs_.insert(fieldName, sPtr);
|
||||
|
||||
unsigned int w = IOstream::defaultPrecision() + 7;
|
||||
|
||||
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 > 0;
|
||||
return nFields;
|
||||
}
|
||||
|
||||
|
||||
@ -282,18 +202,10 @@ Foam::probes::probes
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
pointField(0),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
loadFromFiles_(loadFromFiles),
|
||||
fieldNames_(0),
|
||||
probeLocations_(0),
|
||||
scalarFields_(),
|
||||
vectorFields_(),
|
||||
sphericalTensorFields_(),
|
||||
symmTensorFields_(),
|
||||
tensorFields_(),
|
||||
cellList_(0),
|
||||
probeFilePtrs_(0)
|
||||
mesh_(refCast<const fvMesh>(obr)),
|
||||
loadFromFiles_(loadFromFiles)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -321,7 +233,7 @@ void Foam::probes::end()
|
||||
|
||||
void Foam::probes::write()
|
||||
{
|
||||
if (probeLocations_.size() && checkFieldTypes())
|
||||
if (size() && prepare())
|
||||
{
|
||||
sampleAndWrite(scalarFields_);
|
||||
sampleAndWrite(vectorFields_);
|
||||
@ -334,13 +246,12 @@ void Foam::probes::write()
|
||||
|
||||
void Foam::probes::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("fields") >> fieldNames_;
|
||||
dict.lookup("probeLocations") >> probeLocations_;
|
||||
dict.lookup("probeLocations") >> *this;
|
||||
dict.lookup("fields") >> fieldSelection_;
|
||||
|
||||
// Force all cell locations to be redetermined
|
||||
cellList_.clear();
|
||||
findCells(refCast<const fvMesh>(obr_));
|
||||
checkFieldTypes();
|
||||
// redetermined all cell locations
|
||||
findCells(mesh_);
|
||||
prepare();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@ SourceFiles
|
||||
#include "pointField.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
#include "wordReList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -60,6 +62,8 @@ class mapPolyMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class probes
|
||||
:
|
||||
public pointField
|
||||
{
|
||||
// Private classes
|
||||
|
||||
@ -67,20 +71,15 @@ class probes
|
||||
template<class Type>
|
||||
class fieldGroup
|
||||
:
|
||||
public wordList
|
||||
public DynamicList<word>
|
||||
{
|
||||
public:
|
||||
//- Construct null
|
||||
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.
|
||||
word name_;
|
||||
|
||||
//- Const reference to objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
//- Const reference to fvMesh
|
||||
const fvMesh& mesh_;
|
||||
|
||||
//- Load fields from files (not from objectRegistry)
|
||||
bool loadFromFiles_;
|
||||
@ -100,11 +99,7 @@ class probes
|
||||
// Read from dictonary
|
||||
|
||||
//- Names of fields to probe
|
||||
wordList fieldNames_;
|
||||
|
||||
//- Locations to probe
|
||||
vectorField probeLocations_;
|
||||
|
||||
wordReList fieldSelection_;
|
||||
|
||||
// Calculated
|
||||
|
||||
@ -124,19 +119,21 @@ class probes
|
||||
|
||||
// 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
|
||||
void findCells(const fvMesh&);
|
||||
|
||||
//- classify field types, return true if nFields > 0
|
||||
bool checkFieldTypes();
|
||||
|
||||
//- Find the fields in the list of the given type, return count
|
||||
template<class Type>
|
||||
label countFields
|
||||
(
|
||||
fieldGroup<Type>& fieldList,
|
||||
const wordList& fieldTypes
|
||||
) const;
|
||||
//- Classify field type and Open/close file streams,
|
||||
// returns number of fields
|
||||
label prepare();
|
||||
|
||||
//- Sample and write a particular volume field
|
||||
template<class Type>
|
||||
@ -146,7 +143,7 @@ class probes
|
||||
);
|
||||
|
||||
//- Sample and write all the fields of the given type
|
||||
template <class Type>
|
||||
template<class Type>
|
||||
void sampleAndWrite(const fieldGroup<Type>&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -188,15 +185,21 @@ public:
|
||||
}
|
||||
|
||||
//- Return names of fields to probe
|
||||
virtual const wordList& fieldNames() const
|
||||
virtual const wordReList& fieldNames() const
|
||||
{
|
||||
return fieldNames_;
|
||||
return fieldSelection_;
|
||||
}
|
||||
|
||||
//- 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)
|
||||
|
||||
125
src/sampling/probes/probesGrouping.C
Normal file
125
src/sampling/probes/probesGrouping.C
Normal 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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -63,35 +63,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * 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>
|
||||
void Foam::probes::sampleAndWrite
|
||||
(
|
||||
@ -103,15 +74,15 @@ void Foam::probes::sampleAndWrite
|
||||
if (Pstream::master())
|
||||
{
|
||||
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)
|
||||
{
|
||||
probeStream << ' ' << setw(w) << values[probeI];
|
||||
os << ' ' << setw(w) << values[probeI];
|
||||
}
|
||||
probeStream << endl;
|
||||
os << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,30 +104,30 @@ void Foam::probes::sampleAndWrite
|
||||
IOobject
|
||||
(
|
||||
fields[fieldI],
|
||||
obr_.time().timeName(),
|
||||
refCast<const polyMesh>(obr_),
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
refCast<const fvMesh>(obr_)
|
||||
mesh_
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
objectRegistry::const_iterator iter = obr_.find(fields[fieldI]);
|
||||
objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
|
||||
|
||||
if
|
||||
(
|
||||
iter != obr_.end()
|
||||
iter != objectRegistry::end()
|
||||
&& iter()->type()
|
||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
sampleAndWrite
|
||||
(
|
||||
obr_.lookupObject
|
||||
mesh_.lookupObject
|
||||
<GeometricField<Type, fvPatchField, volMesh> >
|
||||
(
|
||||
fields[fieldI]
|
||||
@ -181,12 +152,12 @@ Foam::probes::sample
|
||||
|
||||
tmp<Field<Type> > tValues
|
||||
(
|
||||
new Field<Type>(probeLocations_.size(), unsetVal)
|
||||
new Field<Type>(this->size(), unsetVal)
|
||||
);
|
||||
|
||||
Field<Type>& values = tValues();
|
||||
|
||||
forAll(probeLocations_, probeI)
|
||||
forAll(*this, probeI)
|
||||
{
|
||||
if (cellList_[probeI] >= 0)
|
||||
{
|
||||
@ -207,7 +178,7 @@ Foam::probes::sample(const word& fieldName) const
|
||||
{
|
||||
return sample
|
||||
(
|
||||
obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
|
||||
mesh_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
|
||||
(
|
||||
fieldName
|
||||
)
|
||||
|
||||
@ -34,103 +34,12 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledSets, 0);
|
||||
}
|
||||
|
||||
defineTypeNameAndDebug(Foam::sampledSets, 0);
|
||||
bool Foam::sampledSets::verbose_ = false;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * 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
|
||||
(
|
||||
PtrList<coordSet>& masterSampledSets,
|
||||
@ -147,9 +56,9 @@ void Foam::sampledSets::combineSampledSets
|
||||
|
||||
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
|
||||
List<List<point> > gatheredPts(Pstream::nProcs());
|
||||
@ -190,7 +99,7 @@ void Foam::sampledSets::combineSampledSets
|
||||
|
||||
// Sort curveDist and use to fill masterSamplePts
|
||||
SortableList<scalar> sortedDist(allCurveDist);
|
||||
indexSets[seti] = sortedDist.indices();
|
||||
indexSets[setI] = sortedDist.indices();
|
||||
|
||||
// Get reference point (note: only master has all points)
|
||||
point refPt;
|
||||
@ -207,12 +116,12 @@ void Foam::sampledSets::combineSampledSets
|
||||
|
||||
masterSampledSets.set
|
||||
(
|
||||
seti,
|
||||
setI,
|
||||
new coordSet
|
||||
(
|
||||
samplePts.name(),
|
||||
samplePts.axis(),
|
||||
List<point>(UIndirectList<point>(allPts, indexSets[seti])),
|
||||
List<point>(UIndirectList<point>(allPts, indexSets[setI])),
|
||||
refPt
|
||||
)
|
||||
);
|
||||
@ -236,7 +145,6 @@ Foam::sampledSets::sampledSets
|
||||
loadFromFiles_(loadFromFiles),
|
||||
outputPath_(fileName::null),
|
||||
searchEngine_(mesh_, true),
|
||||
fieldNames_(),
|
||||
interpolationScheme_(word::null),
|
||||
writeFormat_(word::null)
|
||||
{
|
||||
@ -285,13 +193,43 @@ void Foam::sampledSets::end()
|
||||
|
||||
void Foam::sampledSets::write()
|
||||
{
|
||||
if (size() && checkFieldTypes())
|
||||
if (size())
|
||||
{
|
||||
sampleAndWrite(scalarFields_);
|
||||
sampleAndWrite(vectorFields_);
|
||||
sampleAndWrite(sphericalTensorFields_);
|
||||
sampleAndWrite(symmTensorFields_);
|
||||
sampleAndWrite(tensorFields_);
|
||||
const label nFields = classifyFields();
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
(
|
||||
@ -324,7 +262,7 @@ void Foam::sampledSets::read(const dictionary& dict)
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
Pout<< "sample fields:" << fieldNames_ << nl
|
||||
Pout<< "sample fields:" << fieldSelection_ << nl
|
||||
<< "sample sets:" << nl << "(" << nl;
|
||||
|
||||
forAll(*this, si)
|
||||
|
||||
@ -43,6 +43,7 @@ SourceFiles
|
||||
#include "interpolation.H"
|
||||
#include "coordSet.H"
|
||||
#include "writer.H"
|
||||
#include "wordReList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -54,7 +55,7 @@ class dictionary;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledSets Declaration
|
||||
Class sampledSets Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledSets
|
||||
@ -67,25 +68,40 @@ class sampledSets
|
||||
template<class Type>
|
||||
class fieldGroup
|
||||
:
|
||||
public wordList
|
||||
public DynamicList<word>
|
||||
{
|
||||
public:
|
||||
|
||||
//- Set formatter
|
||||
autoPtr<writer<Type> > formatter;
|
||||
//- The set formatter
|
||||
autoPtr< writer<Type> > formatter;
|
||||
|
||||
//- Construct null
|
||||
fieldGroup()
|
||||
:
|
||||
wordList(0),
|
||||
DynamicList<word>(0),
|
||||
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()
|
||||
{
|
||||
wordList::clear();
|
||||
DynamicList<word>::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
|
||||
|
||||
//- Names of fields to sample
|
||||
wordList fieldNames_;
|
||||
wordReList fieldSelection_;
|
||||
|
||||
//- Interpolation scheme to use
|
||||
word interpolationScheme_;
|
||||
@ -187,16 +203,14 @@ class sampledSets
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Classify field types, return true if nFields > 0
|
||||
bool checkFieldTypes();
|
||||
//- Clear old field groups
|
||||
void clearFieldGroups();
|
||||
|
||||
//- Find the fields in the list of the given type, return count
|
||||
template<class Type>
|
||||
label grep
|
||||
(
|
||||
fieldGroup<Type>& fieldList,
|
||||
const wordList& fieldTypes
|
||||
) const;
|
||||
//- Append fieldName to the appropriate group
|
||||
label appendFieldGroup(const word& fieldName, const word& fieldType);
|
||||
|
||||
//- Classify field types, returns the number of fields
|
||||
label classifyFields();
|
||||
|
||||
//- Combine points from all processors. Sort by curveDist and produce
|
||||
// index list. Valid result only on master processor.
|
||||
|
||||
125
src/sampling/sampledSet/sampledSets/sampledSetsGrouping.C
Normal file
125
src/sampling/sampledSet/sampledSets/sampledSetsGrouping.C
Normal 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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -46,10 +46,10 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
|
||||
interpolation<Type>::New(interpolationScheme, field)
|
||||
);
|
||||
|
||||
forAll(samplers, seti)
|
||||
forAll(samplers, setI)
|
||||
{
|
||||
Field<Type>& values = this->operator[](seti);
|
||||
const sampledSet& samples = samplers[seti];
|
||||
Field<Type>& values = this->operator[](setI);
|
||||
const sampledSet& samples = samplers[setI];
|
||||
|
||||
values.setSize(samples.size());
|
||||
forAll(samples, samplei)
|
||||
@ -79,10 +79,10 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
|
||||
List<Field<Type> >(samplers.size()),
|
||||
name_(field.name())
|
||||
{
|
||||
forAll(samplers, seti)
|
||||
forAll(samplers, setI)
|
||||
{
|
||||
Field<Type>& values = this->operator[](seti);
|
||||
const sampledSet& samples = samplers[seti];
|
||||
Field<Type>& values = this->operator[](setI);
|
||||
const sampledSet& samples = samplers[setI];
|
||||
|
||||
values.setSize(samples.size());
|
||||
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>
|
||||
void Foam::sampledSets::writeSampleFile
|
||||
(
|
||||
const coordSet& masterSampleSet,
|
||||
const PtrList<volFieldSampler<Type> >& masterFields,
|
||||
const label seti,
|
||||
const label setI,
|
||||
const fileName& timeDir,
|
||||
const writer<Type>& formatter
|
||||
)
|
||||
@ -150,7 +121,7 @@ void Foam::sampledSets::writeSampleFile
|
||||
forAll(masterFields, fieldi)
|
||||
{
|
||||
valueSetNames[fieldi] = masterFields[fieldi].name();
|
||||
valueSets[fieldi] = &masterFields[fieldi][seti];
|
||||
valueSets[fieldi] = &masterFields[fieldi][setI];
|
||||
}
|
||||
|
||||
fileName fName
|
||||
@ -180,11 +151,11 @@ void Foam::sampledSets::combineSampledValues
|
||||
{
|
||||
List<Field<T> > masterValues(indexSets.size());
|
||||
|
||||
forAll(indexSets, seti)
|
||||
forAll(indexSets, setI)
|
||||
{
|
||||
// Collect data from all processors
|
||||
List<Field<T> > gatheredData(Pstream::nProcs());
|
||||
gatheredData[Pstream::myProcNo()] = sampledFields[fieldi][seti];
|
||||
gatheredData[Pstream::myProcNo()] = sampledFields[fieldi][setI];
|
||||
Pstream::gatherList(gatheredData);
|
||||
|
||||
if (Pstream::master())
|
||||
@ -198,10 +169,10 @@ void Foam::sampledSets::combineSampledValues
|
||||
)
|
||||
);
|
||||
|
||||
masterValues[seti] = UIndirectList<T>
|
||||
masterValues[setI] = UIndirectList<T>
|
||||
(
|
||||
allData,
|
||||
indexSets[seti]
|
||||
indexSets[setI]
|
||||
)();
|
||||
}
|
||||
}
|
||||
@ -232,7 +203,7 @@ void Foam::sampledSets::sampleAndWrite
|
||||
// Create or use existing writer
|
||||
if (fields.formatter.empty())
|
||||
{
|
||||
fields.formatter = writer<Type>::New(writeFormat_);
|
||||
fields = writeFormat_;
|
||||
}
|
||||
|
||||
// Storage for interpolated values
|
||||
@ -326,13 +297,13 @@ void Foam::sampledSets::sampleAndWrite
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
forAll(masterSampledSets_, seti)
|
||||
forAll(masterSampledSets_, setI)
|
||||
{
|
||||
writeSampleFile
|
||||
(
|
||||
masterSampledSets_[seti],
|
||||
masterSampledSets_[setI],
|
||||
masterFields,
|
||||
seti,
|
||||
setI,
|
||||
outputPath_/mesh_.time().timeName(),
|
||||
fields.formatter()
|
||||
);
|
||||
|
||||
@ -35,6 +35,10 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::sampledSurfaces, 0);
|
||||
bool Foam::sampledSurfaces::verbose_ = false;
|
||||
Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1e-10;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
//- 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 * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
{
|
||||
// Write to time directory under outputPath_
|
||||
@ -208,7 +122,7 @@ Foam::sampledSurfaces::sampledSurfaces
|
||||
mesh_(refCast<const fvMesh>(obr)),
|
||||
loadFromFiles_(loadFromFiles),
|
||||
outputPath_(fileName::null),
|
||||
fieldNames_(),
|
||||
fieldSelection_(),
|
||||
interpolationScheme_(word::null),
|
||||
writeFormat_(word::null),
|
||||
mergeList_(),
|
||||
@ -265,7 +179,7 @@ void Foam::sampledSurfaces::write()
|
||||
// finalize surfaces, merge points etc.
|
||||
update();
|
||||
|
||||
const label nFields = classifyFieldTypes();
|
||||
const label nFields = classifyFields();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
@ -286,8 +200,8 @@ void Foam::sampledSurfaces::write()
|
||||
mkDir(outputPath_/mesh_.time().timeName());
|
||||
}
|
||||
|
||||
// write geometry first if required, or when no fields would otherwise
|
||||
// be written
|
||||
// write geometry first if required,
|
||||
// or when no fields would otherwise be written
|
||||
if (nFields == 0 || genericFormatter_->separateFiles())
|
||||
{
|
||||
writeGeometry();
|
||||
@ -304,15 +218,8 @@ void Foam::sampledSurfaces::write()
|
||||
|
||||
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);
|
||||
dict.lookup("fields") >> fieldSelection_;
|
||||
clearFieldGroups();
|
||||
|
||||
interpolationScheme_ = dict.lookupOrDefault<word>
|
||||
(
|
||||
@ -335,7 +242,6 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
dict.lookup("surfaces"),
|
||||
sampledSurface::iNew(mesh_)
|
||||
);
|
||||
|
||||
transfer(newList);
|
||||
|
||||
if (Pstream::parRun())
|
||||
@ -348,7 +254,7 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
Pout<< "sample fields:" << fieldNames_ << nl
|
||||
Pout<< "sample fields:" << fieldSelection_ << nl
|
||||
<< "sample surfaces:" << nl << "(" << nl;
|
||||
|
||||
forAll(*this, surfI)
|
||||
|
||||
@ -41,6 +41,7 @@ SourceFiles
|
||||
#include "sampledSurface.H"
|
||||
#include "surfaceWriter.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "wordReList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,7 +52,7 @@ class fvMesh;
|
||||
class dictionary;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledSurfaces Declaration
|
||||
Class sampledSurfaces Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledSurfaces
|
||||
@ -68,7 +69,7 @@ class sampledSurfaces
|
||||
{
|
||||
public:
|
||||
|
||||
//- Surface formatter
|
||||
//- The surface formatter
|
||||
autoPtr< surfaceWriter<Type> > formatter;
|
||||
|
||||
//- Construct null
|
||||
@ -85,34 +86,19 @@ class sampledSurfaces
|
||||
formatter(surfaceWriter<Type>::New(writeFormat))
|
||||
{}
|
||||
|
||||
//- Construct for a particular surface format and a list of field
|
||||
// names
|
||||
fieldGroup
|
||||
(
|
||||
const word& writeFormat,
|
||||
const wordList& fieldNames
|
||||
)
|
||||
:
|
||||
DynamicList<word>(fieldNames),
|
||||
formatter(surfaceWriter<Type>::New(writeFormat))
|
||||
{}
|
||||
|
||||
void reset(const label nElem)
|
||||
//- Reset format and field list
|
||||
void clear()
|
||||
{
|
||||
formatter.clear();
|
||||
DynamicList<word>::setCapacity(nElem);
|
||||
DynamicList<word>::clear();
|
||||
formatter.clear();
|
||||
}
|
||||
|
||||
//- Assign a new formatter
|
||||
void operator=(const word& writeFormat)
|
||||
{
|
||||
formatter = surfaceWriter<Type>::New(writeFormat);
|
||||
}
|
||||
|
||||
void operator=(const wordList& fieldNames)
|
||||
{
|
||||
DynamicList<word>::operator=(fieldNames);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -161,7 +147,7 @@ class sampledSurfaces
|
||||
// Read from dictonary
|
||||
|
||||
//- Names of fields to sample
|
||||
wordList fieldNames_;
|
||||
wordReList fieldSelection_;
|
||||
|
||||
//- Interpolation scheme to use
|
||||
word interpolationScheme_;
|
||||
@ -191,8 +177,14 @@ class sampledSurfaces
|
||||
|
||||
// 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 classifyFieldTypes();
|
||||
label classifyFields();
|
||||
|
||||
//- Write geometry only
|
||||
void writeGeometry() const;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -178,7 +178,7 @@ void Foam::sampledSurfaces::sampleAndWrite
|
||||
|
||||
if
|
||||
(
|
||||
iter != mesh_.objectRegistry::end()
|
||||
iter != objectRegistry::end()
|
||||
&& iter()->type()
|
||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
.SUFFIXES: .C .cxx .cc .cpp
|
||||
|
||||
c++WARN = -wd654,819,1125,1476,1505,1572
|
||||
c++WARN = -wd327,654,819,1125,1476,1505,1572
|
||||
|
||||
CC = icpc
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
.SUFFIXES: .C .cxx .cc .cpp
|
||||
|
||||
c++WARN = -wd654,819,1125,1476,1505,1572
|
||||
c++WARN = -wd327,654,819,1125,1476,1505,1572
|
||||
|
||||
CC = icpc
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
.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
|
||||
|
||||
Reference in New Issue
Block a user