2016-09-29 23:18 BST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000097OpenFOAM[All Projects] Bugpublic2011-05-04 12:34
Reporterbgschaid 
Assigned Touser4 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusclosedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000097: Add support vor CSV (Comma separated value) files to OpenFOAM
DescriptionCSV is a very simple format that can be read and written by spreadsheet-programs (but also other data-processing programs). This set of patches adds support to those OF-classes where that kind of input/output is beneficial
- a new probe-class that writes CSV
- a writer for sampledSets that writes CSV
- an alternate Reader to the interpolationTable that reads from a CSV-file (thus enabling for instance timeVaryingUniformFixedValue to read from CSV)

These three patches are independent of each other.
Additional InformationDescription of the Patches:

CSVProbes.patch: adds a new functionObject csvProbes that inherits from probes but writes CSV files. To make the inheritance possible the interface to probes was slightly modified

CSVWrites.patch: adds a new writer based on raw for sampledSets. Modifies the writer class to generalize it (a separator-character can be chosen depending on the writer-type instead of the hardcoded space)

CSVTimeLine.patch: factors out the part of the interpolationTable-class that reads from a file into another run-time-selectable class. There are two implementations: "openfoam" which is the default file-format (this is used if no specific file format is chosen) and "csv" which reads from a csv-File. Typical usage is

        type timeVaryingUniformFixedValue;
        readerType csv;
        outOfBounds clamp;
        fileName "$FOAM_CASE/conditions.csv";
        hasHeaderLine true;
        timeColumn 0;
        valueColumns (3 4 5);

where readerType selects the reader (if not present it is assumed to be "openfoam"), fileName and outOfBounds are as usual, hasHeaderLine indicates whether there is a header line with descriptions of the columns (not uncommon fro spreadsheets), timeColumn is the column in which the time is found, valueColumns are the components of the value (this example is from a U-file. For a scalar this would be a single-value list)

This way of specifying makes it possible to use the same CSV-file for different boundary conditions (T in column 2 for instance) which makes it easier to keep the timeVarying boundary conditions consistent
TagsInput/output
Attached Files
  • patch file icon CSVProbes.patch (29,758 bytes) 2010-12-01 20:30 -
    # HG changeset patch
    # Parent 3702c3466a23e58b7eea748b70b2fd8fed4c104e
    
    diff --git a/src/sampling/Make/files b/src/sampling/Make/files
    --- a/src/sampling/Make/files
    +++ b/src/sampling/Make/files
    @@ -1,5 +1,7 @@
     probes/probes.C
    +probes/csvProbes.C
     probes/probesFunctionObject.C
    +probes/csvProbesFunctionObject.C
     
     sampledSet/coordSet/coordSet.C
     sampledSet/sampledSet/sampledSet.C
    diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/csvProbes.C
    copy from src/sampling/probes/probes.C
    copy to src/sampling/probes/csvProbes.C
    --- a/src/sampling/probes/probes.C
    +++ b/src/sampling/probes/csvProbes.C
    @@ -23,7 +23,7 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "probes.H"
    +#include "csvProbes.H"
     #include "volFields.H"
     #include "dictionary.H"
     #include "Time.H"
    @@ -33,247 +33,15 @@
     
     namespace Foam
     {
    -    defineTypeNameAndDebug(probes, 0);
    +    defineTypeNameAndDebug(csvProbes, 0);
     }
     
     // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
     
    -void Foam::probes::findCells(const fvMesh& mesh)
    -{
    -    if (cellList_.empty())
    -    {
    -        cellList_.setSize(probeLocations_.size());
    -
    -        forAll(probeLocations_, probeI)
    -        {
    -            cellList_[probeI] = mesh.findCell(probeLocations_[probeI]);
    -
    -            if (debug && cellList_[probeI] != -1)
    -            {
    -                Pout<< "probes : found point " << probeLocations_[probeI]
    -                    << " in cell " << cellList_[probeI] << endl;
    -            }
    -        }
    -
    -
    -        // Check if all probes have been found.
    -        forAll(cellList_, probeI)
    -        {
    -            label cellI = cellList_[probeI];
    -
    -            // Check at least one processor with cell.
    -            reduce(cellI, maxOp<label>());
    -
    -            if (cellI == -1)
    -            {
    -                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()
    -                        << " 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;
    -                }
    -            }
    -        }
    -    }
    -}
    -
    -
    -bool Foam::probes::checkFieldTypes()
    -{
    -    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];
    -    }
    -
    -    if (Pstream::master())
    -    {
    -        fileName probeDir;
    -
    -        fileName probeSubDir = name_;
    -
    -        if (obr_.name() != polyMesh::defaultRegion)
    -        {
    -            probeSubDir = probeSubDir/obr_.name();
    -        }
    -        probeSubDir = probeSubDir/obr_.time().timeName();
    -
    -        if (Pstream::parRun())
    -        {
    -            // Put in undecomposed case
    -            // (Note: gives problems for distributed data running)
    -            probeDir = obr_.time().path()/".."/probeSubDir;
    -        }
    -        else
    -        {
    -            probeDir = obr_.time().path()/probeSubDir;
    -        }
    -
    -        // Close the file if any fields have been removed.
    -        forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)
    -        {
    -            if (findIndex(foundFields, iter.key()) == -1)
    -            {
    -                if (debug)
    -                {
    -                    Pout<< "close 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)
    -        {
    -            const word& fldName = foundFields[fieldI];
    -
    -            // Check if added field. If so open a stream for it.
    -
    -            if (!probeFilePtrs_.found(fldName))
    -            {
    -                // 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;
    -            }
    -        }
    -
    -        if (debug)
    -        {
    -            Pout<< "Probing fields:" << foundFields << nl
    -                << "Probing locations:" << probeLocations_ << nl
    -                << endl;
    -        }
    -    }
    -
    -
    -    return nFields > 0;
    -}
    -
     
     // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
     
    -Foam::probes::probes
    +Foam::csvProbes::csvProbes
     (
         const word& name,
         const objectRegistry& obr,
    @@ -281,18 +49,13 @@
         const bool loadFromFiles
     )
     :
    -    name_(name),
    -    obr_(obr),
    -    loadFromFiles_(loadFromFiles),
    -    fieldNames_(0),
    -    probeLocations_(0),
    -    scalarFields_(),
    -    vectorFields_(),
    -    sphericalTensorFields_(),
    -    symmTensorFields_(),
    -    tensorFields_(),
    -    cellList_(0),
    -    probeFilePtrs_(0)
    +    probes(
    +        name,
    +        obr,
    +        dict,
    +        ".csv",
    +        loadFromFiles
    +    )
     {
         read(dict);
     }
    @@ -300,25 +63,13 @@
     
     // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
     
    -Foam::probes::~probes()
    +Foam::csvProbes::~csvProbes()
     {}
     
     
     // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
     
    -void Foam::probes::execute()
    -{
    -    // Do nothing - only valid on write
    -}
    -
    -
    -void Foam::probes::end()
    -{
    -    // Do nothing - only valid on write
    -}
    -
    -
    -void Foam::probes::write()
    +void Foam::csvProbes::write()
     {
         if (probeLocations_.size() && checkFieldTypes())
         {
    @@ -331,16 +82,4 @@
     }
     
     
    -void Foam::probes::read(const dictionary& dict)
    -{
    -    dict.lookup("fields") >> fieldNames_;
    -    dict.lookup("probeLocations") >> probeLocations_;
    -
    -    // Force all cell locations to be redetermined
    -    cellList_.clear();
    -    findCells(refCast<const fvMesh>(obr_));
    -    checkFieldTypes();
    -}
    -
    -
     // ************************************************************************* //
    diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/csvProbes.H
    copy from src/sampling/probes/probes.H
    copy to src/sampling/probes/csvProbes.H
    --- a/src/sampling/probes/probes.H
    +++ b/src/sampling/probes/csvProbes.H
    @@ -22,7 +22,7 @@
         along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
     
     Class
    -    Foam::probes
    +    Foam::csvProbes
     
     Description
         Set of locations to sample.
    @@ -30,113 +30,28 @@
         Call write() to sample and write files.
     
     SourceFiles
    -    probes.C
    +    csvProbes.C
     
     \*---------------------------------------------------------------------------*/
     
    -#ifndef probes_H
    -#define probes_H
    +#ifndef csvProbes_H
    +#define csvProbes_H
     
    -#include "HashPtrTable.H"
    -#include "OFstream.H"
    -#include "polyMesh.H"
    -#include "pointField.H"
    -#include "volFieldsFwd.H"
    +#include "probes.H"
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     namespace Foam
     {
     
    -// Forward declaration of classes
    -class objectRegistry;
    -class dictionary;
    -class fvMesh;
    -class mapPolyMesh;
    -
     /*---------------------------------------------------------------------------*\
    -                          Class probes Declaration
    +                          Class csvProbes Declaration
     \*---------------------------------------------------------------------------*/
     
    -class probes
    +class csvProbes
    +:
    +    public probes
     {
    -    // Private classes
    -
    -        //- Class used for grouping field types
    -        template<class Type>
    -        class fieldGroup
    -        :
    -            public wordList
    -        {
    -        public:
    -            //- Construct null
    -            fieldGroup()
    -            :
    -                wordList()
    -            {}
    -
    -            //- Construct for a list of field names
    -            fieldGroup(const wordList& fieldNames)
    -            :
    -                wordList(fieldNames)
    -            {}
    -        };
    -
    -
    -    // Private data
    -
    -        //- Name of this set of probes,
    -        //  Also used as the name of the probes directory.
    -        word name_;
    -
    -        //- Const reference to objectRegistry
    -        const objectRegistry& obr_;
    -
    -        //- Load fields from files (not from objectRegistry)
    -        bool loadFromFiles_;
    -
    -
    -        // Read from dictonary
    -
    -            //- Names of fields to probe
    -            wordList fieldNames_;
    -
    -            //- Locations to probe
    -            vectorField probeLocations_;
    -
    -
    -        // Calculated
    -
    -            //- Categorized scalar/vector/tensor fields
    -            fieldGroup<scalar> scalarFields_;
    -            fieldGroup<vector> vectorFields_;
    -            fieldGroup<sphericalTensor> sphericalTensorFields_;
    -            fieldGroup<symmTensor> symmTensorFields_;
    -            fieldGroup<tensor> tensorFields_;
    -
    -            // Cells to be probed (obtained from the locations)
    -            labelList cellList_;
    -
    -            //- Current open files
    -            HashPtrTable<OFstream> probeFilePtrs_;
    -
    -
    -    // Private Member Functions
    -
    -        //- 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;
    -
             //- Sample and write a particular volume field
             template<class Type>
             void sampleAndWrite
    @@ -149,23 +64,26 @@
             void sampleAndWrite(const fieldGroup<Type>&);
     
             //- Disallow default bitwise copy construct
    -        probes(const probes&);
    +        csvProbes(const csvProbes&);
     
             //- Disallow default bitwise assignment
    -        void operator=(const probes&);
    +        void operator=(const csvProbes&);
     
    +        //- write the probe-Header
    +         template<class T>
    +         void writeCSVProbeHeader(Ostream &out);
     
     public:
     
         //- Runtime type information
    -    TypeName("probes");
    +    TypeName("csvProbes");
     
     
         // Constructors
     
             //- Construct for given objectRegistry and dictionary.
             //  Allow the possibility to load fields from files
    -        probes
    +        csvProbes
             (
                 const word& name,
                 const objectRegistry&,
    @@ -175,69 +93,15 @@
     
     
         //- Destructor
    -    virtual ~probes();
    +    virtual ~csvProbes();
     
     
         // Member Functions
     
    -        //- Return name of the set of probes
    -        virtual const word& name() const
    -        {
    -            return name_;
    -        }
    -
    -        //- Return names of fields to probe
    -        virtual const wordList& fieldNames() const
    -        {
    -            return fieldNames_;
    -        }
    -
    -        //- Return locations to probe
    -        virtual const vectorField& probeLocations() const
    -        {
    -            return probeLocations_;
    -        }
    -
    -        //- Cells to be probed (obtained from the locations)
    -        const labelList& cells() const
    -        {
    -            return cellList_;
    -        }
    -
    -        //- Execute, currently does nothing
    -        virtual void execute();
    -
    -        //- Execute at the final time-loop, currently does nothing
    -        virtual void end();
     
             //- Sample and write
             virtual void write();
     
    -        //- Read the probes
    -        virtual void read(const dictionary&);
    -
    -        //- Update for changes of mesh
    -        virtual void updateMesh(const mapPolyMesh&)
    -        {}
    -
    -        //- Update for changes of mesh
    -        virtual void movePoints(const pointField&)
    -        {}
    -
    -        //- Update for changes of mesh due to readUpdate
    -        virtual void readUpdate(const polyMesh::readUpdateState state)
    -        {}
    -
    -        //- Sample a volume field at all locations
    -        template<class Type>
    -        tmp<Field<Type> > sample
    -        (
    -            const GeometricField<Type, fvPatchField, volMesh>&
    -        ) const;
    -
    -        //- Sample a single field on all sample locations
    -        template <class Type>
    -        tmp<Field<Type> > sample(const word& fieldName) const;
     };
     
     
    @@ -248,7 +112,7 @@
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     #ifdef NoRepository
    -#   include "probesTemplates.C"
    +#   include "csvProbesTemplates.C"
     #endif
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    diff --git a/src/sampling/probes/probesFunctionObject.C b/src/sampling/probes/csvProbesFunctionObject.C
    copy from src/sampling/probes/probesFunctionObject.C
    copy to src/sampling/probes/csvProbesFunctionObject.C
    --- a/src/sampling/probes/probesFunctionObject.C
    +++ b/src/sampling/probes/csvProbesFunctionObject.C
    @@ -23,18 +23,18 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "probesFunctionObject.H"
    +#include "csvProbesFunctionObject.H"
     
     // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
     
     namespace Foam
     {
    -    defineNamedTemplateTypeNameAndDebug(probesFunctionObject, 0);
    +    defineNamedTemplateTypeNameAndDebug(csvProbesFunctionObject, 0);
     
         addToRunTimeSelectionTable
         (
             functionObject,
    -        probesFunctionObject,
    +        csvProbesFunctionObject,
             dictionary
         );
     }
    diff --git a/src/sampling/probes/probesFunctionObject.H b/src/sampling/probes/csvProbesFunctionObject.H
    copy from src/sampling/probes/probesFunctionObject.H
    copy to src/sampling/probes/csvProbesFunctionObject.H
    --- a/src/sampling/probes/probesFunctionObject.H
    +++ b/src/sampling/probes/csvProbesFunctionObject.H
    @@ -22,28 +22,28 @@
         along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
     
     Typedef
    -    Foam::probesFunctionObject
    +    Foam::csvProbesFunctionObject
     
     Description
    -    FunctionObject wrapper around probes to allow them to be created via the
    +    FunctionObject wrapper around csvProbes to allow them to be created via the
         functions list within controlDict.
     
     SourceFiles
    -    probesFunctionObject.C
    +    csvProbesFunctionObject.C
     
     \*---------------------------------------------------------------------------*/
     
    -#ifndef probesFunctionObject_H
    -#define probesFunctionObject_H
    +#ifndef csvProbesFunctionObject_H
    +#define csvProbesFunctionObject_H
     
    -#include "probes.H"
    +#include "csvProbes.H"
     #include "OutputFilterFunctionObject.H"
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     namespace Foam
     {
    -    typedef OutputFilterFunctionObject<probes> probesFunctionObject;
    +    typedef OutputFilterFunctionObject<csvProbes> csvProbesFunctionObject;
     }
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    diff --git a/src/sampling/probes/probesTemplates.C b/src/sampling/probes/csvProbesTemplates.C
    copy from src/sampling/probes/probesTemplates.C
    copy to src/sampling/probes/csvProbesTemplates.C
    --- a/src/sampling/probes/probesTemplates.C
    +++ b/src/sampling/probes/csvProbesTemplates.C
    @@ -23,7 +23,7 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "probes.H"
    +#include "csvProbes.H"
     #include "volFields.H"
     #include "IOmanip.H"
     
    @@ -32,67 +32,72 @@
     namespace Foam
     {
     
    -//- comparison operator for probes class
    -template<class T>
    -class isNotEqOp
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +template<>
    +inline void Foam::csvProbes::writeCSVProbeHeader<scalar>(Ostream &out)
     {
    -public:
    +    out << "Time";
    +        
    +    forAll(probeLocations_, probeI)
    +    {
    +        out << ",@" << probeLocations_[probeI];
    +    }
     
    -    void operator()(T& x, const T& y) const
    -    {
    -        const T unsetVal(-VGREAT*pTraits<T>::one);
    -
    -        if (x != unsetVal)
    -        {
    -            // Keep x.
    -
    -            // Note:chould check for y != unsetVal but multiple sample cells
    -            // already handled in read().
    -        }
    -        else
    -        {
    -            // x is not set. y might be.
    -            x = y;
    -        }
    -    }
    -};
    -
    +    out << endl;
     }
     
    -
    -// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    -
     template<class Type>
    -Foam::label Foam::probes::countFields
    -(
    -    fieldGroup<Type>& fieldList,
    -    const wordList& fieldTypes
    -) const
    +void Foam::csvProbes::writeCSVProbeHeader(Ostream &out)
     {
    -    fieldList.setSize(fieldNames_.size());
    -    label nFields = 0;
    -
    -    forAll(fieldNames_, fieldI)
    +    out << "Time";
    +        
    +    forAll(probeLocations_, probeI)
         {
    -        if
    -        (
    -            fieldTypes[fieldI]
    -         == GeometricField<Type, fvPatchField, volMesh>::typeName
    -        )
    -        {
    -            fieldList[nFields] = fieldNames_[fieldI];
    -            nFields++;
    +        for(label j=0;j<Type::nComponents;j++) {
    +            out << "," << Type::componentNames[j]
    +                << "@" << probeLocations_[probeI] ;
             }
         }
     
    -    fieldList.setSize(nFields);
    -
    -    return nFields;
    +    out << endl;
     }
     
    +template<>
    +inline void Foam::csvProbes::sampleAndWrite
    +(
    +    const GeometricField<scalar, fvPatchField, volMesh>& vField
    +)
    +{
    +    Field<scalar> values = sample(vField);
    +
    +    if (Pstream::master())
    +    {
    +        // formatting pretty throws some Spreadsheets off the track
    +        //        unsigned int w = IOstream::defaultPrecision() + 7;
    +
    +        OFstream& probeStream = *probeFilePtrs_[vField.name()];
    +        if( !probeFileHasHeader_.found(vField.name()) ) 
    +        {
    +            probeFileHasHeader_.insert(vField.name());
    +            writeCSVProbeHeader<scalar>(probeStream);
    +        }
    +
    +        //        probeStream << setw(w) << vField.time().value();
    +        probeStream << vField.time().value();
    +
    +        forAll(values, probeI)
    +        {
    +            //            probeStream << ',' << setw(w) << values[probeI];
    +            probeStream << ',' << values[probeI];
    +        }
    +        probeStream << endl;
    +    }
    +}
    +
     
     template<class Type>
    -void Foam::probes::sampleAndWrite
    +void Foam::csvProbes::sampleAndWrite
     (
         const GeometricField<Type, fvPatchField, volMesh>& vField
     )
    @@ -101,14 +106,24 @@
     
         if (Pstream::master())
         {
    -        unsigned int w = IOstream::defaultPrecision() + 7;
    +        //        unsigned int w = IOstream::defaultPrecision() + 7;
    +
             OFstream& probeStream = *probeFilePtrs_[vField.name()];
    +        if( !probeFileHasHeader_.found(vField.name()) ) 
    +        {
    +            probeFileHasHeader_.insert(vField.name());
    +            writeCSVProbeHeader<Type>(probeStream);
    +        }
     
    -        probeStream << setw(w) << vField.time().value();
    +        //        probeStream  << setw(w) << vField.time().value();
    +        probeStream << vField.time().value();
     
             forAll(values, probeI)
             {
    -            probeStream << ' ' << setw(w) << values[probeI];
    +            for(label j=0;j<Type::nComponents;j++) {
    +                //                probeStream << ',' << setw(w) << values[probeI][j];
    +                probeStream << ',' << values[probeI][j];
    +            }
             }
             probeStream << endl;
         }
    @@ -116,7 +131,7 @@
     
     
     template <class Type>
    -void Foam::probes::sampleAndWrite
    +void Foam::csvProbes::sampleAndWrite
     (
         const fieldGroup<Type>& fields
     )
    @@ -169,49 +184,6 @@
     
     // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
     
    -template<class Type>
    -Foam::tmp<Foam::Field<Type> >
    -Foam::probes::sample
    -(
    -    const GeometricField<Type, fvPatchField, volMesh>& vField
    -) const
    -{
    -    const Type unsetVal(-VGREAT*pTraits<Type>::one);
    -
    -    tmp<Field<Type> > tValues
    -    (
    -        new Field<Type>(probeLocations_.size(), unsetVal)
    -    );
    -
    -    Field<Type>& values = tValues();
    -
    -    forAll(probeLocations_, probeI)
    -    {
    -        if (cellList_[probeI] >= 0)
    -        {
    -            values[probeI] = vField[cellList_[probeI]];
    -        }
    -    }
    -
    -    Pstream::listCombineGather(values, isNotEqOp<Type>());
    -    Pstream::listCombineScatter(values);
    -
    -    return tValues;
     }
     
    -
    -template<class Type>
    -Foam::tmp<Foam::Field<Type> >
    -Foam::probes::sample(const word& fieldName) const
    -{
    -    return sample
    -    (
    -        obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
    -        (
    -            fieldName
    -        )
    -    );
    -}
    -
    -
     // ************************************************************************* //
    diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C
    --- a/src/sampling/probes/probes.C
    +++ b/src/sampling/probes/probes.C
    @@ -178,6 +178,13 @@
             foundFields[fieldI++] = tensorFields_[i];
         }
     
    +    createFiles(foundFields);
    +
    +    return nFields > 0;
    +}
    +
    +void Foam::probes::createFiles(const wordList &foundFields)
    +{
         if (Pstream::master())
         {
             fileName probeDir;
    @@ -206,6 +213,10 @@
             {
                 if (findIndex(foundFields, iter.key()) == -1)
                 {
    +                if(probeFileHasHeader_.found(iter.key())) {
    +                    probeFileHasHeader_.erase(iter.key());
    +                }
    +
                     if (debug)
                     {
                         Pout<< "close stream: " << iter()->name() << endl;
    @@ -230,7 +241,7 @@
                     // Create directory if does not exist.
                     mkDir(probeDir);
     
    -                OFstream* sPtr = new OFstream(probeDir/fldName);
    +                OFstream* sPtr = new OFstream(probeDir/fldName+fileExtension_);
     
                     if (debug)
                     {
    @@ -238,23 +249,6 @@
                     }
     
                     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;
                 }
             }
     
    @@ -265,11 +259,27 @@
                     << endl;
             }
         }
    -
    -
    -    return nFields > 0;
     }
     
    +void Foam::probes::writeProbeHeader(Ostream &out)
    +{
    +    unsigned int w = IOstream::defaultPrecision() + 7;
    +    
    +    for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
    +    {
    +        out << '#' << setw(IOstream::defaultPrecision() + 6)
    +            << vector::componentNames[cmpt];
    +        
    +        forAll(probeLocations_, probeI)
    +        {
    +            out << ' ' << setw(w) << probeLocations_[probeI][cmpt];
    +        }
    +        out << endl;
    +    }
    +    
    +    out << '#' << setw(IOstream::defaultPrecision() + 6)
    +        << "Time" << endl;
    +}
     
     // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
     
    @@ -297,6 +307,31 @@
         read(dict);
     }
     
    +Foam::probes::probes
    +(
    +    const word& name,
    +    const objectRegistry& obr,
    +    const dictionary& dict,
    +    const word &extension,
    +    const bool loadFromFiles
    +)
    +:
    +    fileExtension_(extension),
    +    name_(name),
    +    obr_(obr),
    +    loadFromFiles_(loadFromFiles),
    +    fieldNames_(0),
    +    probeLocations_(0),
    +    scalarFields_(),
    +    vectorFields_(),
    +    sphericalTensorFields_(),
    +    symmTensorFields_(),
    +    tensorFields_(),
    +    cellList_(0),
    +    probeFilePtrs_(0)
    +{
    +}
    +
     
     // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
     
    @@ -339,7 +374,8 @@
         // Force all cell locations to be redetermined
         cellList_.clear();
         findCells(refCast<const fvMesh>(obr_));
    -    checkFieldTypes();
    +
    +    checkFieldTypes(); 
     }
     
     
    diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/probes.H
    --- a/src/sampling/probes/probes.H
    +++ b/src/sampling/probes/probes.H
    @@ -82,9 +82,15 @@
                 {}
             };
     
    +    //- write the probe-Header
    +    void writeProbeHeader(Ostream &out);
     
         // Private data
     
    +    //- extension for written files
    +    word fileExtension_;
    +protected:
    +
             //- Name of this set of probes,
             //  Also used as the name of the probes directory.
             word name_;
    @@ -120,15 +126,14 @@
                 //- Current open files
                 HashPtrTable<OFstream> probeFilePtrs_;
     
    +            //- Has this file a header?
    +            HashSet<word> probeFileHasHeader_;
     
         // Private Member Functions
     
             //- 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
    @@ -148,12 +153,33 @@
             template <class Type>
             void sampleAndWrite(const fieldGroup<Type>&);
     
    +        //- Construct for given objectRegistry and dictionary.
    +        //  Allow the possibility to load fields from files.
    +        // to be used by subclasses
    +        probes
    +        (
    +            const word& name,
    +            const objectRegistry&,
    +            const dictionary&,
    +            const word &extension,
    +            const bool loadFromFiles = false
    +        );
    +
    +private:
    +
             //- Disallow default bitwise copy construct
             probes(const probes&);
     
             //- Disallow default bitwise assignment
             void operator=(const probes&);
     
    +protected:
    +
    +        //- classify field types, return true if nFields > 0
    +        bool checkFieldTypes();
    +
    +        //- create the files
    +        void createFiles(const wordList &foundFields);
     
     public:
     
    diff --git a/src/sampling/probes/probesTemplates.C b/src/sampling/probes/probesTemplates.C
    --- a/src/sampling/probes/probesTemplates.C
    +++ b/src/sampling/probes/probesTemplates.C
    @@ -104,6 +104,11 @@
             unsigned int w = IOstream::defaultPrecision() + 7;
             OFstream& probeStream = *probeFilePtrs_[vField.name()];
     
    +        if( !probeFileHasHeader_.found(vField.name()) ) 
    +        {
    +            probeFileHasHeader_.insert(vField.name());
    +            writeProbeHeader(probeStream);
    +        }
             probeStream << setw(w) << vField.time().value();
     
             forAll(values, probeI)
    
    patch file icon CSVProbes.patch (29,758 bytes) 2010-12-01 20:30 +
  • patch file icon CSVTimeline.patch (36,584 bytes) 2010-12-01 20:31 -
    # HG changeset patch
    # Parent 929201f1b7231d52dce7dc723cd2aa0c198a3580
    
    diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
    --- a/src/OpenFOAM/Make/files
    +++ b/src/OpenFOAM/Make/files
    @@ -512,6 +512,10 @@
     interpolation = $(interpolations)/interpolation
     $(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C
     
    +$(interpolations)/interpolationTable/tableReaders/tableReaders.C
    +$(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C
    +$(interpolations)/interpolationTable/tableReaders/csv/csvTableReaders.C
    +
     algorithms/MeshWave/MeshWaveName.C
     algorithms/MeshWave/FaceCellWaveName.C
     
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
    --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
    +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
    @@ -26,6 +26,8 @@
     #include "interpolationTable.H"
     #include "IFstream.H"
     
    +#include "openFoamTableReader.H"
    +
     // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
     
     template<class Type>
    @@ -38,7 +40,7 @@
         fName.expand();
     
         // Read data from file
    -    IFstream(fName)() >> *this;
    +    reader_()(fName,*this);
     
         // Check that the data are okay
         check();
    @@ -53,7 +55,6 @@
         }
     }
     
    -
     // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
     
     template<class Type>
    @@ -61,7 +62,8 @@
     :
         List<Tuple2<scalar, Type> >(),
         boundsHandling_(interpolationTable::WARN),
    -    fileName_("fileNameIsUndefined")
    +    fileName_("fileNameIsUndefined"),
    +    reader_(new openFoamTableReader<Type>())
     {}
     
     
    @@ -75,7 +77,8 @@
     :
         List<Tuple2<scalar, Type> >(values),
         boundsHandling_(bounds),
    -    fileName_(fName)
    +    fileName_(fName),
    +    reader_(new openFoamTableReader<Type>())
     {}
     
     
    @@ -84,7 +87,8 @@
     :
         List<Tuple2<scalar, Type> >(),
         boundsHandling_(interpolationTable::WARN),
    -    fileName_(fName)
    +    fileName_(fName),
    +    reader_(new openFoamTableReader<Type>())
     {
         readTable();
     }
    @@ -95,7 +99,8 @@
     :
         List<Tuple2<scalar, Type> >(),
         boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))),
    -    fileName_(dict.lookup("fileName"))
    +    fileName_(dict.lookup("fileName")),
    +    reader_(tableReader<Type>::New(dict))
     {
         readTable();
     }
    @@ -109,7 +114,8 @@
     :
         List<Tuple2<scalar, Type> >(interpTable),
         boundsHandling_(interpTable.boundsHandling_),
    -    fileName_(interpTable.fileName_)
    +    fileName_(interpTable.fileName_),
    +    reader_(interpTable.reader_->clone())
     {}
     
     
    @@ -233,6 +239,7 @@
             << fileName_ << token::END_STATEMENT << nl;
         os.writeKeyword("outOfBounds")
             << boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
    +    reader_->write(os);
     }
     
     
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H
    --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H
    +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H
    @@ -49,6 +49,9 @@
     #include "List.H"
     #include "Tuple2.H"
     
    +#include "tableReader.H"
    +#include "autoPtr.H"
    +
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     namespace Foam
    @@ -87,12 +90,17 @@
             //- File name
             fileName fileName_;
     
    +        //- the actual reader
    +        autoPtr<tableReader<Type> > reader_;
     
         // Private Member Functions
     
             //- Read the table of data from file
             void readTable();
     
    +        //- Read the table of data from file. Format is to be determined
    +    //        void readTable(const dictionary &spec);
    +
     
     public:
     
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
    @@ -0,0 +1,189 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "csvTableReader.H"
    +#include "IFstream.H"
    +#include "DynamicList.H"
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::csvTableReader<Type>::csvTableReader()
    +    : 
    +    headerLine_(true),
    +    timeColumn_(-1),
    +    componentColumns_(0,-1)
    +{
    +    notImplemented("Foam::csvTableReader<Type>::csvTableReader()")
    +}
    +
    +template<class Type>
    +Foam::csvTableReader<Type>::csvTableReader(const dictionary &spec)
    +    :
    +    headerLine_(readBool(spec.lookup("hasHeaderLine"))),
    +    timeColumn_(readLabel(spec.lookup("timeColumn"))),
    +    componentColumns_(spec.lookup("valueColumns")),
    +    separator_(spec.lookupOrDefault<string>("separator",string(","))[0])
    +{
    +    if(componentColumns_.size()!=pTraits<Type>::nComponents) {
    +        FatalErrorIn("")
    +            << componentColumns_ << " does not have the expected length "
    +                << pTraits<Type>::nComponents << endl
    +                << abort(FatalError);
    +    }
    +}
    +
    +
    +// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::csvTableReader<Type>::~csvTableReader()
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
    +
    +namespace Foam {
    +    // doesn't recognize specialization otherwise
    +    template<>
    +    scalar csvTableReader<scalar>::readValue(const List<string> &splitted)
    +    {
    +        if(componentColumns_[0]>=splitted.size()) {
    +            FatalErrorIn("scalar csvTableReader<scalar>::readValue(const List<string> &splitted)")
    +                << "No column " << componentColumns_[0] << " in " 
    +                    << splitted << endl
    +                    << abort(FatalError);
    +        }
    +
    +        return readScalar(IStringStream(splitted[componentColumns_[0]])());
    +    }
    +    
    +    template<class Type>
    +    Type csvTableReader<Type>::readValue(const List<string> &splitted)
    +    {
    +        Type result;
    +
    +        for(label i=0;i<pTraits<Type>::nComponents;i++) {
    +            if(componentColumns_[i]>=splitted.size()) {
    +                FatalErrorIn("Type csvTableReader<Type>::readValue(const List<string> &splitted)")
    +                    << "No column " << componentColumns_[i] << " in " 
    +                        << splitted << endl
    +                        << abort(FatalError);
    +            }
    +
    +            result[i]=readScalar(IStringStream(splitted[componentColumns_[i]])());
    +        }
    +
    +        return result;
    +    }
    +}
    +
    +template<class Type>
    +Foam::string Foam::csvTableReader<Type>::readLine(IFstream &in)
    +{
    +    string result="";
    +
    +    char c='.';
    +
    +    while(
    +        !in.eof()
    +        &&
    +        c!='\n'
    +    ) {
    +        in.get(c);
    +        if(c!='\n' && !in.eof()) {
    +            result+=c;
    +        }
    +    }
    +
    +    return result;
    +}
    +
    +template<class Type>
    +void Foam::csvTableReader<Type>::operator()(const fileName &fName,List<Tuple2<scalar, Type> > &data)
    +{
    +    IFstream in(fName);
    +
    +    DynamicList<Tuple2<scalar, Type> > values;
    +
    +    label lineNr=0;
    +
    +    while(!in.eof()) {
    +        string line=readLine(in);
    +
    +        lineNr++;
    +        if( headerLine_ && lineNr==1) {
    +            continue;
    +        }
    +        DynamicList<string> splitted;
    +        std::size_t pos=0;
    +        while(pos!=std::string::npos) {
    +            std::size_t nPos=line.find(separator_,pos);
    +            if(nPos==std::string::npos) {
    +                splitted.append(line.substr(pos));
    +                pos=nPos;
    +            } else {
    +                splitted.append(line.substr(pos,nPos-pos));
    +                pos=nPos+1;
    +            }
    +        }
    +
    +        if(splitted.size()<=1) {
    +            break;
    +        }
    +
    +        scalar time=readScalar(IStringStream(splitted[timeColumn_])());
    +        Type value=readValue(splitted);
    +
    +        values.append(Tuple2<scalar,Type>(time,value));
    +    }
    +
    +    data.transfer(values);
    +}
    +
    +template<class Type>
    +void Foam::csvTableReader<Type>::write(Ostream& os) const
    +{
    +    tableReader<Type>::write(os);
    +
    +    os.writeKeyword("hasHeaderLine")
    +        << headerLine_ << token::END_STATEMENT << nl;
    +    os.writeKeyword("timeColumn")
    +        << timeColumn_ << token::END_STATEMENT << nl;
    +    os.writeKeyword("valueColumns")
    +        << componentColumns_ << token::END_STATEMENT << nl;
    +    os.writeKeyword("separator")
    +        << string(separator_) << token::END_STATEMENT << nl;
    +
    +}
    +
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H
    @@ -0,0 +1,128 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +Class
    +    Foam::tableReader
    +
    +Description
    +    Reads an interpolation table from a file - CSV-format
    +
    +SourceFiles
    +    tableReader.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef csvTableReader_H
    +#define csvTableReader_H
    +
    +#include "tableReader.H"
    +#include "labelList.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +    class IFstream;
    +
    +/*---------------------------------------------------------------------------*\
    +                           Class csvTableReader Declaration
    +\*---------------------------------------------------------------------------*/
    +
    +template<class Type>
    +class csvTableReader
    +:
    +    public tableReader<Type>
    +{
    +    //- does the file have a header line?
    +    bool headerLine_;
    +
    +    //- column of the time
    +    label timeColumn_;
    +
    +    //- labels of the components
    +    labelList componentColumns_;
    +
    +    //- read the nect value from the splitted string
    +    Type readValue(const List<string> &splitted);
    +
    +    //- read a line from a stream
    +    string readLine(IFstream &in);
    +
    +    //- separator character 
    +    char separator_;
    +public:
    +
    +    //- Runtime type information
    +    TypeName("csv");
    +
    +    // Constructors
    +
    +        //- Construct null
    +        csvTableReader();
    +
    +        //- Construct from dictionary
    +        csvTableReader(const dictionary &dict);
    +
    +
    +    //- Destructor
    +    virtual ~csvTableReader();
    +
    +    //- Read the table
    +    virtual void operator()(const fileName &fName,List<Tuple2<scalar, Type> > &);
    +
    +    //- write the remaining parameters
    +    virtual void write(Ostream& os) const;
    +
    +    //- Construct and return a copy
    +    virtual autoPtr<tableReader<Type> > clone() const
    +    {
    +        return autoPtr<tableReader<Type> >
    +        (
    +            new csvTableReader<Type>
    +            (
    +                *this
    +            )
    +        );
    +    }
    +
    +
    +};
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#ifdef NoRepository
    +#   include "csvTableReader.C"
    +#endif
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReaders.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReaders.C
    @@ -0,0 +1,37 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "csvTableReader.H"
    +#include "tableReaders.H"
    +#include "addToRunTimeSelectionTable.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +    makeTableReaders(csvTableReader);
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C
    @@ -0,0 +1,62 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "openFoamTableReader.H"
    +#include "IFstream.H"
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::openFoamTableReader<Type>::openFoamTableReader()
    +{}
    +
    +template<class Type>
    +Foam::openFoamTableReader<Type>::openFoamTableReader(const dictionary &spec)
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::openFoamTableReader<Type>::~openFoamTableReader()
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
    +
    +template<class Type>
    +void Foam::openFoamTableReader<Type>::operator()(const fileName &fName,List<Tuple2<scalar, Type> > &data)
    +{
    +    // Read data from file
    +    IFstream(fName)() >> data;
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H
    @@ -0,0 +1,105 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +Class
    +    Foam::tableReader
    +
    +Description
    +    Reads an interpolation table from a file - OpenFOAM-format
    +
    +SourceFiles
    +    tableReader.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef openFoamTableReader_H
    +#define openFoamTableReader_H
    +
    +#include "tableReader.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +/*---------------------------------------------------------------------------*\
    +                           Class openFoamTableReader Declaration
    +\*---------------------------------------------------------------------------*/
    +
    +template<class Type>
    +class openFoamTableReader
    +:
    +    public tableReader<Type>
    +{
    +
    +public:
    +
    +    //- Runtime type information
    +    TypeName("openFoam");
    +
    +    // Constructors
    +
    +        //- Construct null
    +        openFoamTableReader();
    +
    +        //- Construct from dictionary
    +        openFoamTableReader(const dictionary &dict);
    +
    +
    +    //- Destructor
    +    virtual ~openFoamTableReader();
    +
    +    //- Read the table
    +    virtual void operator()(const fileName &fName,List<Tuple2<scalar, Type> > &);
    +
    +    //- Construct and return a copy
    +    virtual autoPtr<tableReader<Type> > clone() const
    +    {
    +        return autoPtr<tableReader<Type> >
    +        (
    +            new openFoamTableReader<Type>
    +            (
    +                *this
    +            )
    +        );
    +    }
    +
    +};
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#ifdef NoRepository
    +#   include "openFoamTableReader.C"
    +#endif
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C
    @@ -0,0 +1,37 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "openFoamTableReader.H"
    +#include "tableReaders.H"
    +#include "addToRunTimeSelectionTable.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +    makeTableReaders(openFoamTableReader);
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C
    @@ -0,0 +1,88 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "tableReader.H"
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::autoPtr<Foam::tableReader<Type> > Foam::tableReader<Type>::New
    +(
    +    const dictionary& spec
    +)
    +{
    +    const word readerType=spec.lookupOrDefault<word>("readerType","openFoam");
    +
    +    typename dictionaryConstructorTable::iterator cstrIter =
    +        dictionaryConstructorTablePtr_
    +            ->find(readerType);
    +
    +    if (cstrIter == dictionaryConstructorTablePtr_->end())
    +    {
    +        FatalErrorIn
    +        (
    +            "tableReader::New(const dictionary&)"
    +        )   << "Unknown reader type " << readerType
    +            << nl << nl
    +            << "Valid reader types : " << nl
    +            << dictionaryConstructorTablePtr_->sortedToc()
    +            << exit(FatalError);
    +    }
    +
    +    return autoPtr<tableReader<Type> >(cstrIter()(spec));
    +}
    +
    +
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::tableReader<Type>::tableReader()
    +{}
    +
    +template<class Type>
    +Foam::tableReader<Type>::tableReader(const dictionary &spec)
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::tableReader<Type>::~tableReader()
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
    +
    +template<class Type>
    +void Foam::tableReader<Type>::write(Ostream& os) const
    +{
    +    os.writeKeyword("readerType")
    +        << this->type() << token::END_STATEMENT << nl;
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.H
    @@ -0,0 +1,122 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +Class
    +    Foam::tableReader
    +
    +Description
    +    Base class to read table data for the interpolationTable
    +
    +SourceFiles
    +    tableReader.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef tableReader_H
    +#define tableReader_H
    +
    +#include "fileName.H"
    +#include "wordList.H"
    +#include "vector.H"
    +#include "tensor.H"
    +#include "typeInfo.H"
    +#include "runTimeSelectionTables.H"
    +#include "autoPtr.H"
    +#include "dictionary.H"
    +#include "Tuple2.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +/*---------------------------------------------------------------------------*\
    +                           Class tableReader Declaration
    +\*---------------------------------------------------------------------------*/
    +
    +template<class Type>
    +class tableReader
    +{
    +
    +public:
    +
    +    //- Runtime type information
    +    TypeName("tableReader");
    +
    +    // Declare run-time constructor selection table
    +
    +        declareRunTimeSelectionTable
    +        (
    +            autoPtr,
    +            tableReader,
    +            dictionary,
    +            (const dictionary &dict),
    +            (dict)
    +        );
    +
    +
    +    // Selectors
    +
    +        //- Return a reference to the selected tableReader
    +        static autoPtr<tableReader> New(const dictionary& spec);
    +
    +
    +    // Constructors
    +
    +        //- Construct null
    +        tableReader();
    +
    +        //- Construct from dictionary
    +        tableReader(const dictionary &dict);
    +
    +
    +    //- Destructor
    +    virtual ~tableReader();
    +
    +    //- Read the table
    +    virtual void operator()(const fileName &fName,List<Tuple2<scalar, Type> > &) = 0;
    +
    +    //- write additional information
    +    virtual void write(Ostream& os) const;
    +
    +    //- Construct and return a clone
    +    virtual autoPtr<tableReader<Type> > clone() const = 0;
    +};
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#ifdef NoRepository
    +#   include "tableReader.C"
    +#endif
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C
    @@ -0,0 +1,49 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "tableReaders.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +#define defineTableReaderType(dataType)                                         \
    +    defineNamedTemplateTypeNameAndDebug(tableReader<dataType >, 0);                \
    +    defineTemplatedRunTimeSelectionTable(tableReader, dictionary, dataType);
    +
    +defineTableReaderType(scalar);
    +defineTableReaderType(vector);
    +defineTableReaderType(sphericalTensor);
    +defineTableReaderType(symmTensor);
    +defineTableReaderType(tensor);
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H
    @@ -0,0 +1,79 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +InClass
    +    Foam::tableReader
    +
    +SourceFiles
    +    tableReaders.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef tableReaders_H
    +#define tableReaders_H
    +
    +#include "tableReader.H"
    +#include "fieldTypes.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +// Only used internally
    +#define makeTypeTableReadersTypeName(typeTableReader, dataType)                      \
    +                                                                              \
    +    defineNamedTemplateTypeNameAndDebug(typeTableReader< dataType >, 0)
    +
    +// Sometimes used externally
    +#define makeTableReadersTypeName(typeTableReader)                                    \
    +                                                                              \
    +    makeTypeTableReadersTypeName(typeTableReader, scalar);                           \
    +    makeTypeTableReadersTypeName(typeTableReader, vector);                           \
    +    makeTypeTableReadersTypeName(typeTableReader, sphericalTensor);                  \
    +    makeTypeTableReadersTypeName(typeTableReader, symmTensor);                       \
    +    makeTypeTableReadersTypeName(typeTableReader, tensor)
    +
    +// Define type info for single dataType template instantiation (eg, vector)
    +#define makeTableReaderType(typeTableReader, dataType)                               \
    +                                                                              \
    +    defineNamedTemplateTypeNameAndDebug(typeTableReader< dataType >, 0);           \
    +    addTemplatedToRunTimeSelectionTable                                       \
    +    (                                                                         \
    +        tableReader, typeTableReader, dataType, dictionary                                    \
    +    )
    +
    +
    +// Define type info for scalar, vector etc. instantiations
    +#define makeTableReaders(typeTableReader)                                            \
    +                                                                              \
    +    makeTableReaderType(typeTableReader, scalar);                                    \
    +    makeTableReaderType(typeTableReader, vector);                                    \
    +    makeTableReaderType(typeTableReader, sphericalTensor);                           \
    +    makeTableReaderType(typeTableReader, symmTensor);                                \
    +    makeTableReaderType(typeTableReader, tensor)
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    
    patch file icon CSVTimeline.patch (36,584 bytes) 2010-12-01 20:31 +
  • patch file icon CSVWriter.patch (9,350 bytes) 2010-12-01 20:31 -
    # HG changeset patch
    # Parent 111914973bb62bc4d4fb652d40803d130218a6dc
    
    diff --git a/src/sampling/Make/files b/src/sampling/Make/files
    --- a/src/sampling/Make/files
    +++ b/src/sampling/Make/files
    @@ -19,6 +19,7 @@
     $(setWriters)/jplot/jplotSetWriterRunTime.C
     $(setWriters)/raw/rawSetWriterRunTime.C
     $(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
    +$(setWriters)/csv/csvSetWriterRunTime.C
     
     cuttingPlane/cuttingPlane.C
     
    diff --git a/src/sampling/sampledSet/writers/raw/rawSetWriter.C b/src/sampling/sampledSet/writers/csv/csvSetWriter.C
    copy from src/sampling/sampledSet/writers/raw/rawSetWriter.C
    copy to src/sampling/sampledSet/writers/csv/csvSetWriter.C
    --- a/src/sampling/sampledSet/writers/raw/rawSetWriter.C
    +++ b/src/sampling/sampledSet/writers/csv/csvSetWriter.C
    @@ -23,7 +23,7 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "rawSetWriter.H"
    +#include "csvSetWriter.H"
     #include "coordSet.H"
     #include "fileName.H"
     #include "OFstream.H"
    @@ -31,34 +31,36 @@
     // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
     
     template<class Type>
    -Foam::rawSetWriter<Type>::rawSetWriter()
    +Foam::csvSetWriter<Type>::csvSetWriter()
     :
         writer<Type>()
    -{}
    +{
    +    this->separator_ = token::COMMA;
    +}
     
     
     // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
     
     template<class Type>
    -Foam::rawSetWriter<Type>::~rawSetWriter()
    +Foam::csvSetWriter<Type>::~csvSetWriter()
     {}
     
     
     // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
     
     template<class Type>
    -Foam::fileName Foam::rawSetWriter<Type>::getFileName
    +Foam::fileName Foam::csvSetWriter<Type>::getFileName
     (
         const coordSet& points,
         const wordList& valueSetNames
     ) const
     {
    -    return this->getBaseName(points, valueSetNames) + ".xy";
    +    return this->getBaseName(points, valueSetNames) + ".csv";
     }
     
     
     template<class Type>
    -void Foam::rawSetWriter<Type>::write
    +void Foam::csvSetWriter<Type>::write
     (
         const coordSet& points,
         const wordList& valueSetNames,
    @@ -66,6 +68,8 @@
         Ostream& os
     ) const
     {
    +    writeHeader(points,valueSetNames,os);
    +
         // Collect sets into columns
         List<const List<Type>*> columns(valueSets.size());
     
    @@ -79,7 +83,7 @@
     
     
     template<class Type>
    -void Foam::rawSetWriter<Type>::write
    +void Foam::csvSetWriter<Type>::write
     (
         const bool writeTracks,
         const PtrList<coordSet>& points,
    @@ -88,9 +92,11 @@
         Ostream& os
     ) const
     {
    +    writeHeader(points[0],valueSetNames,os);
    +
         if (valueSets.size() != valueSetNames.size())
         {
    -        FatalErrorIn("rawSetWriter<Type>::write(..)")
    +        FatalErrorIn("csvSetWriter<Type>::write(..)")
                 << "Number of variables:" << valueSetNames.size() << endl
                 << "Number of valueSets:" << valueSets.size()
                 << exit(FatalError);
    @@ -111,5 +117,74 @@
         }
     }
     
    +template<class Type>
    +void Foam::csvSetWriter<Type>::writeComponentSeparator
    +(
    +    Ostream& os
    +) const
    +{
    +    os << this->separator_;
    +}
    +
    +namespace Foam {
    +    // otherwise compiler complains about specialization
    +template<>
    +void csvSetWriter<scalar>::writeHeader
    +(
    +    const coordSet& points,
    +    const wordList& valueSetNames,
    +    Ostream& os
    +) const
    +{
    +    writeCoordHeader(points,os);
    +
    +    forAll(valueSetNames,i) {
    +        if( i>0 ) {
    +            os << this->separator_;
    +        }
    +        os << valueSetNames[i];
    +    }
    +
    +    os << nl;
    +}
    +} // end namespace
    +
    +template<class Type>
    +void Foam::csvSetWriter<Type>::writeHeader
    +(
    +    const coordSet& points,
    +    const wordList& valueSetNames,
    +    Ostream& os
    +) const
    +{
    +    writeCoordHeader(points,os);
    +    
    +    forAll(valueSetNames,i) {
    +        for(label j=0;j<Type::nComponents;j++) {
    +            if( i>0 || j>0 ) {
    +                os << this->separator_;
    +            }
    +            os << valueSetNames[i] << "_" << j;
    +        }
    +    }
    +
    +    os << nl;
    +}
    +
    +template<class Type>
    +void Foam::csvSetWriter<Type>::writeCoordHeader
    +(
    +    const coordSet& points,
    +    Ostream& os
    +) const
    +{
    +    if(points.hasVectorAxis()) {
    +        for(unsigned int i=0;i<points.axis().size();i++) {
    +            os << points.axis()[i] << this->separator_;
    +        }
    +    } else {
    +        os << points.axis() << this->separator_;
    +    }    
    +}
     
     // ************************************************************************* //
    diff --git a/src/sampling/sampledSet/writers/raw/rawSetWriter.H b/src/sampling/sampledSet/writers/csv/csvSetWriter.H
    copy from src/sampling/sampledSet/writers/raw/rawSetWriter.H
    copy to src/sampling/sampledSet/writers/csv/csvSetWriter.H
    --- a/src/sampling/sampledSet/writers/raw/rawSetWriter.H
    +++ b/src/sampling/sampledSet/writers/csv/csvSetWriter.H
    @@ -22,17 +22,17 @@
         along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
     
     Class
    -    Foam::rawSetWriter
    +    Foam::csvSetWriter
     
     Description
     
     SourceFiles
    -    rawSetWriter.C
    +    csvSetWriter.C
     
     \*---------------------------------------------------------------------------*/
     
    -#ifndef rawSetWriter_H
    -#define rawSetWriter_H
    +#ifndef csvSetWriter_H
    +#define csvSetWriter_H
     
     #include "writer.H"
     
    @@ -42,29 +42,47 @@
     {
     
     /*---------------------------------------------------------------------------*\
    -                       Class rawSetWriter Declaration
    +                       Class csvSetWriter Declaration
     \*---------------------------------------------------------------------------*/
     
     template<class Type>
    -class rawSetWriter
    +class csvSetWriter
     :
         public writer<Type>
     {
     
    +
    +    void writeCoordHeader
    +    (
    +        const coordSet&,
    +        Ostream&
    +    ) const;
    +
    +    void writeHeader
    +    (
    +        const coordSet&,
    +        const wordList&,
    +        Ostream&
    +    ) const;
    +
    +protected:
    +
    +    virtual void writeComponentSeparator(Ostream& os) const;
    +
     public:
     
         //- Runtime type information
    -    TypeName("raw");
    +    TypeName("csv");
     
     
         // Constructors
     
             //- Construct null
    -        rawSetWriter();
    +        csvSetWriter();
     
     
         //- Destructor
    -    virtual ~rawSetWriter();
    +    virtual ~csvSetWriter();
     
     
         // Member Functions
    @@ -101,7 +119,7 @@
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     #ifdef NoRepository
    -#   include "rawSetWriter.C"
    +#   include "csvSetWriter.C"
     #endif
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    diff --git a/src/sampling/sampledSet/writers/raw/rawSetWriterRunTime.C b/src/sampling/sampledSet/writers/csv/csvSetWriterRunTime.C
    copy from src/sampling/sampledSet/writers/raw/rawSetWriterRunTime.C
    copy to src/sampling/sampledSet/writers/csv/csvSetWriterRunTime.C
    --- a/src/sampling/sampledSet/writers/raw/rawSetWriterRunTime.C
    +++ b/src/sampling/sampledSet/writers/csv/csvSetWriterRunTime.C
    @@ -23,7 +23,7 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "rawSetWriter.H"
    +#include "csvSetWriter.H"
     #include "writers.H"
     #include "addToRunTimeSelectionTable.H"
     
    @@ -31,7 +31,7 @@
     
     namespace Foam
     {
    -    makeSetWriters(rawSetWriter);
    +    makeSetWriters(csvSetWriter);
     }
     
     // ************************************************************************* //
    diff --git a/src/sampling/sampledSet/writers/writer.C b/src/sampling/sampledSet/writers/writer.C
    --- a/src/sampling/sampledSet/writers/writer.C
    +++ b/src/sampling/sampledSet/writers/writer.C
    @@ -107,7 +107,7 @@
         {
             writeCoord(points, pointI, os);
     
    -        os << token::SPACE;
    +        os << separator_;
             write(values[pointI], os);
             os << nl;
         }
    @@ -128,7 +128,7 @@
     
             forAll(valuesPtrList, i)
             {
    -            os << token::SPACE;
    +            os << separator_;
                 const List<Type>& values = *valuesPtrList[i];
                 write(values[pointI], os);
             }
    @@ -141,6 +141,8 @@
     
     template<class Type>
     Foam::writer<Type>::writer()
    +:
    +    separator_(token::SPACE)
     {}
     
     
    @@ -174,16 +176,30 @@
     {
         for (direction d=0; d<VSType::nComponents; d++)
         {
    +        if (d > 0)
    +        {
    +            writeComponentSeparator(os);
    +        }
    +
             os << value.component(d);
     
    -        if (d <= VSType::nComponents-1)
    -        {
    -            os << ' ' << token::TAB;
    -        }
    +        // throws warning for Spherical tensors
    +//         if (d < VSType::nComponents-1)
    +//         {
    +//             writeComponentSeparator(os);
    +//         }
         }
         return os;
     }
     
    +template<class Type>
    +void Foam::writer<Type>::writeComponentSeparator
    +(
    +    Ostream& os
    +) const
    +{
    +    os << separator_ << token::TAB;
    +}
     
     template<class Type>
     Foam::Ostream& Foam::writer<Type>::write
    diff --git a/src/sampling/sampledSet/writers/writer.H b/src/sampling/sampledSet/writers/writer.H
    --- a/src/sampling/sampledSet/writers/writer.H
    +++ b/src/sampling/sampledSet/writers/writer.H
    @@ -86,6 +86,8 @@
     {
     
     protected:
    +    //- Separator between entries
    +    token separator_;
     
         //- Generates filename from coordSet and sampled fields
         fileName getBaseName(const coordSet&, const wordList&) const;
    @@ -107,7 +109,8 @@
             Ostream& os
         ) const;
     
    -
    +    //- Writes a separator between components for vectors etc
    +    virtual void writeComponentSeparator(Ostream& os) const;
     public:
     
         //- Runtime type information
    
    patch file icon CSVWriter.patch (9,350 bytes) 2010-12-01 20:31 +
  • patch file icon CSVTimeline.v2.patch (36,869 bytes) 2010-12-05 11:01 -
    # HG changeset patch
    # Parent 076420bf661e43e36275ac3e2bd23a2cd396f05b
    
    diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
    --- a/src/OpenFOAM/Make/files
    +++ b/src/OpenFOAM/Make/files
    @@ -512,6 +512,10 @@
     interpolation = $(interpolations)/interpolation
     $(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C
     
    +$(interpolations)/interpolationTable/tableReaders/tableReaders.C
    +$(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C
    +$(interpolations)/interpolationTable/tableReaders/csv/csvTableReaders.C
    +
     algorithms/MeshWave/MeshWaveName.C
     algorithms/MeshWave/FaceCellWaveName.C
     
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
    --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
    +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C
    @@ -26,6 +26,8 @@
     #include "interpolationTable.H"
     #include "IFstream.H"
     
    +#include "openFoamTableReader.H"
    +
     // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
     
     template<class Type>
    @@ -37,8 +39,15 @@
     
         fName.expand();
     
    +    if(!exists(fName,false)) {
    +        FatalErrorIn("Foam::interpolationTable<Type>::readTable()")
    +            << " The file " << fileName_ << " (expanded: " << fName
    +                << ") does not exist" 
    +                << endl
    +                << abort(FatalError);
    +    }
         // Read data from file
    -    IFstream(fName)() >> *this;
    +    reader_()(fName,*this);
     
         // Check that the data are okay
         check();
    @@ -53,7 +62,6 @@
         }
     }
     
    -
     // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
     
     template<class Type>
    @@ -61,7 +69,8 @@
     :
         List<Tuple2<scalar, Type> >(),
         boundsHandling_(interpolationTable::WARN),
    -    fileName_("fileNameIsUndefined")
    +    fileName_("fileNameIsUndefined"),
    +    reader_(new openFoamTableReader<Type>())
     {}
     
     
    @@ -75,7 +84,8 @@
     :
         List<Tuple2<scalar, Type> >(values),
         boundsHandling_(bounds),
    -    fileName_(fName)
    +    fileName_(fName),
    +    reader_(new openFoamTableReader<Type>())
     {}
     
     
    @@ -84,7 +94,8 @@
     :
         List<Tuple2<scalar, Type> >(),
         boundsHandling_(interpolationTable::WARN),
    -    fileName_(fName)
    +    fileName_(fName),
    +    reader_(new openFoamTableReader<Type>())
     {
         readTable();
     }
    @@ -95,7 +106,8 @@
     :
         List<Tuple2<scalar, Type> >(),
         boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))),
    -    fileName_(dict.lookup("fileName"))
    +    fileName_(dict.lookup("fileName")),
    +    reader_(tableReader<Type>::New(dict))
     {
         readTable();
     }
    @@ -109,7 +121,8 @@
     :
         List<Tuple2<scalar, Type> >(interpTable),
         boundsHandling_(interpTable.boundsHandling_),
    -    fileName_(interpTable.fileName_)
    +    fileName_(interpTable.fileName_),
    +    reader_(interpTable.reader_->clone())
     {}
     
     
    @@ -233,6 +246,7 @@
             << fileName_ << token::END_STATEMENT << nl;
         os.writeKeyword("outOfBounds")
             << boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
    +    reader_->write(os);
     }
     
     
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H
    --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H
    +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H
    @@ -49,6 +49,9 @@
     #include "List.H"
     #include "Tuple2.H"
     
    +#include "tableReader.H"
    +#include "autoPtr.H"
    +
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     namespace Foam
    @@ -87,12 +90,17 @@
             //- File name
             fileName fileName_;
     
    +        //- the actual reader
    +        autoPtr<tableReader<Type> > reader_;
     
         // Private Member Functions
     
             //- Read the table of data from file
             void readTable();
     
    +        //- Read the table of data from file. Format is to be determined
    +    //        void readTable(const dictionary &spec);
    +
     
     public:
     
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
    @@ -0,0 +1,189 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "csvTableReader.H"
    +#include "IFstream.H"
    +#include "DynamicList.H"
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::csvTableReader<Type>::csvTableReader()
    +    : 
    +    headerLine_(true),
    +    timeColumn_(-1),
    +    componentColumns_(0,-1)
    +{
    +    notImplemented("Foam::csvTableReader<Type>::csvTableReader()")
    +}
    +
    +template<class Type>
    +Foam::csvTableReader<Type>::csvTableReader(const dictionary &spec)
    +    :
    +    headerLine_(readBool(spec.lookup("hasHeaderLine"))),
    +    timeColumn_(readLabel(spec.lookup("timeColumn"))),
    +    componentColumns_(spec.lookup("valueColumns")),
    +    separator_(spec.lookupOrDefault<string>("separator",string(","))[0])
    +{
    +    if(componentColumns_.size()!=pTraits<Type>::nComponents) {
    +        FatalErrorIn("")
    +            << componentColumns_ << " does not have the expected length "
    +                << pTraits<Type>::nComponents << endl
    +                << abort(FatalError);
    +    }
    +}
    +
    +
    +// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::csvTableReader<Type>::~csvTableReader()
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
    +
    +namespace Foam {
    +    // doesn't recognize specialization otherwise
    +    template<>
    +    scalar csvTableReader<scalar>::readValue(const List<string> &splitted)
    +    {
    +        if(componentColumns_[0]>=splitted.size()) {
    +            FatalErrorIn("scalar csvTableReader<scalar>::readValue(const List<string> &splitted)")
    +                << "No column " << componentColumns_[0] << " in " 
    +                    << splitted << endl
    +                    << abort(FatalError);
    +        }
    +
    +        return readScalar(IStringStream(splitted[componentColumns_[0]])());
    +    }
    +    
    +    template<class Type>
    +    Type csvTableReader<Type>::readValue(const List<string> &splitted)
    +    {
    +        Type result;
    +
    +        for(label i=0;i<pTraits<Type>::nComponents;i++) {
    +            if(componentColumns_[i]>=splitted.size()) {
    +                FatalErrorIn("Type csvTableReader<Type>::readValue(const List<string> &splitted)")
    +                    << "No column " << componentColumns_[i] << " in " 
    +                        << splitted << endl
    +                        << abort(FatalError);
    +            }
    +
    +            result[i]=readScalar(IStringStream(splitted[componentColumns_[i]])());
    +        }
    +
    +        return result;
    +    }
    +}
    +
    +template<class Type>
    +Foam::string Foam::csvTableReader<Type>::readLine(IFstream &in)
    +{
    +    string result="";
    +
    +    char c='.';
    +
    +    while(
    +        !in.eof()
    +        &&
    +        c!='\n'
    +    ) {
    +        in.get(c);
    +        if(c!='\n' && !in.eof()) {
    +            result+=c;
    +        }
    +    }
    +
    +    return result;
    +}
    +
    +template<class Type>
    +void Foam::csvTableReader<Type>::operator()(const fileName &fName,List<Tuple2<scalar, Type> > &data)
    +{
    +    IFstream in(fName);
    +
    +    DynamicList<Tuple2<scalar, Type> > values;
    +
    +    label lineNr=0;
    +
    +    while(!in.eof()) {
    +        string line=readLine(in);
    +
    +        lineNr++;
    +        if( headerLine_ && lineNr==1) {
    +            continue;
    +        }
    +        DynamicList<string> splitted;
    +        std::size_t pos=0;
    +        while(pos!=std::string::npos) {
    +            std::size_t nPos=line.find(separator_,pos);
    +            if(nPos==std::string::npos) {
    +                splitted.append(line.substr(pos));
    +                pos=nPos;
    +            } else {
    +                splitted.append(line.substr(pos,nPos-pos));
    +                pos=nPos+1;
    +            }
    +        }
    +
    +        if(splitted.size()<=1) {
    +            break;
    +        }
    +
    +        scalar time=readScalar(IStringStream(splitted[timeColumn_])());
    +        Type value=readValue(splitted);
    +
    +        values.append(Tuple2<scalar,Type>(time,value));
    +    }
    +
    +    data.transfer(values);
    +}
    +
    +template<class Type>
    +void Foam::csvTableReader<Type>::write(Ostream& os) const
    +{
    +    tableReader<Type>::write(os);
    +
    +    os.writeKeyword("hasHeaderLine")
    +        << headerLine_ << token::END_STATEMENT << nl;
    +    os.writeKeyword("timeColumn")
    +        << timeColumn_ << token::END_STATEMENT << nl;
    +    os.writeKeyword("valueColumns")
    +        << componentColumns_ << token::END_STATEMENT << nl;
    +    os.writeKeyword("separator")
    +        << string(separator_) << token::END_STATEMENT << nl;
    +
    +}
    +
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H
    @@ -0,0 +1,128 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +Class
    +    Foam::tableReader
    +
    +Description
    +    Reads an interpolation table from a file - CSV-format
    +
    +SourceFiles
    +    tableReader.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef csvTableReader_H
    +#define csvTableReader_H
    +
    +#include "tableReader.H"
    +#include "labelList.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +    class IFstream;
    +
    +/*---------------------------------------------------------------------------*\
    +                           Class csvTableReader Declaration
    +\*---------------------------------------------------------------------------*/
    +
    +template<class Type>
    +class csvTableReader
    +:
    +    public tableReader<Type>
    +{
    +    //- does the file have a header line?
    +    bool headerLine_;
    +
    +    //- column of the time
    +    label timeColumn_;
    +
    +    //- labels of the components
    +    labelList componentColumns_;
    +
    +    //- read the nect value from the splitted string
    +    Type readValue(const List<string> &splitted);
    +
    +    //- read a line from a stream
    +    string readLine(IFstream &in);
    +
    +    //- separator character 
    +    char separator_;
    +public:
    +
    +    //- Runtime type information
    +    TypeName("csv");
    +
    +    // Constructors
    +
    +        //- Construct null
    +        csvTableReader();
    +
    +        //- Construct from dictionary
    +        csvTableReader(const dictionary &dict);
    +
    +
    +    //- Destructor
    +    virtual ~csvTableReader();
    +
    +    //- Read the table
    +    virtual void operator()(const fileName &fName,List<Tuple2<scalar, Type> > &);
    +
    +    //- write the remaining parameters
    +    virtual void write(Ostream& os) const;
    +
    +    //- Construct and return a copy
    +    virtual autoPtr<tableReader<Type> > clone() const
    +    {
    +        return autoPtr<tableReader<Type> >
    +        (
    +            new csvTableReader<Type>
    +            (
    +                *this
    +            )
    +        );
    +    }
    +
    +
    +};
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#ifdef NoRepository
    +#   include "csvTableReader.C"
    +#endif
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReaders.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReaders.C
    @@ -0,0 +1,37 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "csvTableReader.H"
    +#include "tableReaders.H"
    +#include "addToRunTimeSelectionTable.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +    makeTableReaders(csvTableReader);
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C
    @@ -0,0 +1,62 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "openFoamTableReader.H"
    +#include "IFstream.H"
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::openFoamTableReader<Type>::openFoamTableReader()
    +{}
    +
    +template<class Type>
    +Foam::openFoamTableReader<Type>::openFoamTableReader(const dictionary &spec)
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::openFoamTableReader<Type>::~openFoamTableReader()
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
    +
    +template<class Type>
    +void Foam::openFoamTableReader<Type>::operator()(const fileName &fName,List<Tuple2<scalar, Type> > &data)
    +{
    +    // Read data from file
    +    IFstream(fName)() >> data;
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H
    @@ -0,0 +1,105 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +Class
    +    Foam::tableReader
    +
    +Description
    +    Reads an interpolation table from a file - OpenFOAM-format
    +
    +SourceFiles
    +    tableReader.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef openFoamTableReader_H
    +#define openFoamTableReader_H
    +
    +#include "tableReader.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +/*---------------------------------------------------------------------------*\
    +                           Class openFoamTableReader Declaration
    +\*---------------------------------------------------------------------------*/
    +
    +template<class Type>
    +class openFoamTableReader
    +:
    +    public tableReader<Type>
    +{
    +
    +public:
    +
    +    //- Runtime type information
    +    TypeName("openFoam");
    +
    +    // Constructors
    +
    +        //- Construct null
    +        openFoamTableReader();
    +
    +        //- Construct from dictionary
    +        openFoamTableReader(const dictionary &dict);
    +
    +
    +    //- Destructor
    +    virtual ~openFoamTableReader();
    +
    +    //- Read the table
    +    virtual void operator()(const fileName &fName,List<Tuple2<scalar, Type> > &);
    +
    +    //- Construct and return a copy
    +    virtual autoPtr<tableReader<Type> > clone() const
    +    {
    +        return autoPtr<tableReader<Type> >
    +        (
    +            new openFoamTableReader<Type>
    +            (
    +                *this
    +            )
    +        );
    +    }
    +
    +};
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#ifdef NoRepository
    +#   include "openFoamTableReader.C"
    +#endif
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C
    @@ -0,0 +1,37 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "openFoamTableReader.H"
    +#include "tableReaders.H"
    +#include "addToRunTimeSelectionTable.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +    makeTableReaders(openFoamTableReader);
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C
    @@ -0,0 +1,88 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "tableReader.H"
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::autoPtr<Foam::tableReader<Type> > Foam::tableReader<Type>::New
    +(
    +    const dictionary& spec
    +)
    +{
    +    const word readerType=spec.lookupOrDefault<word>("readerType","openFoam");
    +
    +    typename dictionaryConstructorTable::iterator cstrIter =
    +        dictionaryConstructorTablePtr_
    +            ->find(readerType);
    +
    +    if (cstrIter == dictionaryConstructorTablePtr_->end())
    +    {
    +        FatalErrorIn
    +        (
    +            "tableReader::New(const dictionary&)"
    +        )   << "Unknown reader type " << readerType
    +            << nl << nl
    +            << "Valid reader types : " << nl
    +            << dictionaryConstructorTablePtr_->sortedToc()
    +            << exit(FatalError);
    +    }
    +
    +    return autoPtr<tableReader<Type> >(cstrIter()(spec));
    +}
    +
    +
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +
    +// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::tableReader<Type>::tableReader()
    +{}
    +
    +template<class Type>
    +Foam::tableReader<Type>::tableReader(const dictionary &spec)
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
    +
    +template<class Type>
    +Foam::tableReader<Type>::~tableReader()
    +{}
    +
    +
    +// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
    +
    +template<class Type>
    +void Foam::tableReader<Type>::write(Ostream& os) const
    +{
    +    os.writeKeyword("readerType")
    +        << this->type() << token::END_STATEMENT << nl;
    +}
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.H
    @@ -0,0 +1,122 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +Class
    +    Foam::tableReader
    +
    +Description
    +    Base class to read table data for the interpolationTable
    +
    +SourceFiles
    +    tableReader.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef tableReader_H
    +#define tableReader_H
    +
    +#include "fileName.H"
    +#include "wordList.H"
    +#include "vector.H"
    +#include "tensor.H"
    +#include "typeInfo.H"
    +#include "runTimeSelectionTables.H"
    +#include "autoPtr.H"
    +#include "dictionary.H"
    +#include "Tuple2.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +/*---------------------------------------------------------------------------*\
    +                           Class tableReader Declaration
    +\*---------------------------------------------------------------------------*/
    +
    +template<class Type>
    +class tableReader
    +{
    +
    +public:
    +
    +    //- Runtime type information
    +    TypeName("tableReader");
    +
    +    // Declare run-time constructor selection table
    +
    +        declareRunTimeSelectionTable
    +        (
    +            autoPtr,
    +            tableReader,
    +            dictionary,
    +            (const dictionary &dict),
    +            (dict)
    +        );
    +
    +
    +    // Selectors
    +
    +        //- Return a reference to the selected tableReader
    +        static autoPtr<tableReader> New(const dictionary& spec);
    +
    +
    +    // Constructors
    +
    +        //- Construct null
    +        tableReader();
    +
    +        //- Construct from dictionary
    +        tableReader(const dictionary &dict);
    +
    +
    +    //- Destructor
    +    virtual ~tableReader();
    +
    +    //- Read the table
    +    virtual void operator()(const fileName &fName,List<Tuple2<scalar, Type> > &) = 0;
    +
    +    //- write additional information
    +    virtual void write(Ostream& os) const;
    +
    +    //- Construct and return a clone
    +    virtual autoPtr<tableReader<Type> > clone() const = 0;
    +};
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#ifdef NoRepository
    +#   include "tableReader.C"
    +#endif
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C
    @@ -0,0 +1,49 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#include "tableReaders.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +namespace Foam
    +{
    +
    +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
    +
    +#define defineTableReaderType(dataType)                                         \
    +    defineNamedTemplateTypeNameAndDebug(tableReader<dataType >, 0);                \
    +    defineTemplatedRunTimeSelectionTable(tableReader, dictionary, dataType);
    +
    +defineTableReaderType(scalar);
    +defineTableReaderType(vector);
    +defineTableReaderType(sphericalTensor);
    +defineTableReaderType(symmTensor);
    +defineTableReaderType(tensor);
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +} // End namespace Foam
    +
    +// ************************************************************************* //
    diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H
    new file mode 100644
    --- /dev/null
    +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H
    @@ -0,0 +1,79 @@
    +/*---------------------------------------------------------------------------*\
    +  =========                 |
    +  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    +   \\    /   O peration     |
    +    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
    +     \\/     M anipulation  |
    +-------------------------------------------------------------------------------
    +License
    +    This file is part of OpenFOAM.
    +
    +    OpenFOAM is free software: you can redistribute it and/or modify it
    +    under the terms of the GNU General Public License as published by
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    +    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    +    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    +    for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    +
    +InClass
    +    Foam::tableReader
    +
    +SourceFiles
    +    tableReaders.C
    +
    +\*---------------------------------------------------------------------------*/
    +
    +#ifndef tableReaders_H
    +#define tableReaders_H
    +
    +#include "tableReader.H"
    +#include "fieldTypes.H"
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +// Only used internally
    +#define makeTypeTableReadersTypeName(typeTableReader, dataType)                      \
    +                                                                              \
    +    defineNamedTemplateTypeNameAndDebug(typeTableReader< dataType >, 0)
    +
    +// Sometimes used externally
    +#define makeTableReadersTypeName(typeTableReader)                                    \
    +                                                                              \
    +    makeTypeTableReadersTypeName(typeTableReader, scalar);                           \
    +    makeTypeTableReadersTypeName(typeTableReader, vector);                           \
    +    makeTypeTableReadersTypeName(typeTableReader, sphericalTensor);                  \
    +    makeTypeTableReadersTypeName(typeTableReader, symmTensor);                       \
    +    makeTypeTableReadersTypeName(typeTableReader, tensor)
    +
    +// Define type info for single dataType template instantiation (eg, vector)
    +#define makeTableReaderType(typeTableReader, dataType)                               \
    +                                                                              \
    +    defineNamedTemplateTypeNameAndDebug(typeTableReader< dataType >, 0);           \
    +    addTemplatedToRunTimeSelectionTable                                       \
    +    (                                                                         \
    +        tableReader, typeTableReader, dataType, dictionary                                    \
    +    )
    +
    +
    +// Define type info for scalar, vector etc. instantiations
    +#define makeTableReaders(typeTableReader)                                            \
    +                                                                              \
    +    makeTableReaderType(typeTableReader, scalar);                                    \
    +    makeTableReaderType(typeTableReader, vector);                                    \
    +    makeTableReaderType(typeTableReader, sphericalTensor);                           \
    +    makeTableReaderType(typeTableReader, symmTensor);                                \
    +    makeTableReaderType(typeTableReader, tensor)
    +
    +
    +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    +
    +#endif
    +
    +// ************************************************************************* //
    
    patch file icon CSVTimeline.v2.patch (36,869 bytes) 2010-12-05 11:01 +
  • patch file icon CSVProbes.v2.patch (30,263 bytes) 2010-12-14 16:23 -
    # HG changeset patch
    # Parent 6aff5dadee72e40523e94cb1bab32d85a639994b
    
    diff --git a/src/sampling/Make/files b/src/sampling/Make/files
    --- a/src/sampling/Make/files
    +++ b/src/sampling/Make/files
    @@ -1,6 +1,8 @@
     probes/probes.C
    +probes/csvProbes.C
     probes/probesFunctionObject.C
     probes/patchProbes.C
    +probes/csvProbesFunctionObject.C
     
     sampledSet/coordSet/coordSet.C
     sampledSet/sampledSet/sampledSet.C
    diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/csvProbes.C
    copy from src/sampling/probes/probes.C
    copy to src/sampling/probes/csvProbes.C
    --- a/src/sampling/probes/probes.C
    +++ b/src/sampling/probes/csvProbes.C
    @@ -23,7 +23,7 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "probes.H"
    +#include "csvProbes.H"
     #include "volFields.H"
     #include "dictionary.H"
     #include "Time.H"
    @@ -33,247 +33,15 @@
     
     namespace Foam
     {
    -    defineTypeNameAndDebug(probes, 0);
    +    defineTypeNameAndDebug(csvProbes, 0);
     }
     
     // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
     
    -void Foam::probes::findElements(const fvMesh& mesh)
    -{
    -    if (elementList_.empty())
    -    {
    -        elementList_.setSize(probeLocations_.size());
    -
    -        forAll(probeLocations_, probeI)
    -        {
    -            elementList_[probeI] = mesh.findCell(probeLocations_[probeI]);
    -
    -            if (debug && elementList_[probeI] != -1)
    -            {
    -                Pout<< "probes : found point " << probeLocations_[probeI]
    -                    << " in cell " << elementList_[probeI] << endl;
    -            }
    -        }
    -
    -
    -        // Check if all probes have been found.
    -        forAll(elementList_, probeI)
    -        {
    -            label cellI = elementList_[probeI];
    -
    -            // Check at least one processor with cell.
    -            reduce(cellI, maxOp<label>());
    -
    -            if (cellI == -1)
    -            {
    -                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 (elementList_[probeI] != -1 && elementList_[probeI] != cellI)
    -                {
    -                    WarningIn("probes::read()")
    -                        << "Location " << probeLocations_[probeI]
    -                        << " seems to be on multiple domains:"
    -                        << " cell " << elementList_[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;
    -                }
    -            }
    -        }
    -    }
    -}
    -
    -
    -bool Foam::probes::checkFieldTypes()
    -{
    -    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];
    -    }
    -
    -    if (Pstream::master())
    -    {
    -        fileName probeDir;
    -
    -        fileName probeSubDir = name_;
    -
    -        if (obr_.name() != polyMesh::defaultRegion)
    -        {
    -            probeSubDir = probeSubDir/obr_.name();
    -        }
    -        probeSubDir = probeSubDir/obr_.time().timeName();
    -
    -        if (Pstream::parRun())
    -        {
    -            // Put in undecomposed case
    -            // (Note: gives problems for distributed data running)
    -            probeDir = obr_.time().path()/".."/probeSubDir;
    -        }
    -        else
    -        {
    -            probeDir = obr_.time().path()/probeSubDir;
    -        }
    -
    -        // Close the file if any fields have been removed.
    -        forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)
    -        {
    -            if (findIndex(foundFields, iter.key()) == -1)
    -            {
    -                if (debug)
    -                {
    -                    Pout<< "close 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)
    -        {
    -            const word& fldName = foundFields[fieldI];
    -
    -            // Check if added field. If so open a stream for it.
    -
    -            if (!probeFilePtrs_.found(fldName))
    -            {
    -                // 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;
    -            }
    -        }
    -
    -        if (debug)
    -        {
    -            Pout<< "Probing fields:" << foundFields << nl
    -                << "Probing locations:" << probeLocations_ << nl
    -                << endl;
    -        }
    -    }
    -
    -
    -    return nFields > 0;
    -}
    -
     
     // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
     
    -Foam::probes::probes
    +Foam::csvProbes::csvProbes
     (
         const word& name,
         const objectRegistry& obr,
    @@ -281,18 +49,13 @@
         const bool loadFromFiles
     )
     :
    -    name_(name),
    -    obr_(obr),
    -    loadFromFiles_(loadFromFiles),
    -    fieldNames_(0),
    -    probeLocations_(0),
    -    scalarFields_(),
    -    vectorFields_(),
    -    sphericalTensorFields_(),
    -    symmTensorFields_(),
    -    tensorFields_(),
    -    elementList_(0),
    -    probeFilePtrs_(0)
    +    probes(
    +        name,
    +        obr,
    +        dict,
    +        ".csv",
    +        loadFromFiles
    +    )
     {
         read(dict);
     }
    @@ -300,25 +63,13 @@
     
     // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
     
    -Foam::probes::~probes()
    +Foam::csvProbes::~csvProbes()
     {}
     
     
     // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
     
    -void Foam::probes::execute()
    -{
    -    // Do nothing - only valid on write
    -}
    -
    -
    -void Foam::probes::end()
    -{
    -    // Do nothing - only valid on write
    -}
    -
    -
    -void Foam::probes::write()
    +void Foam::csvProbes::write()
     {
         if (probeLocations_.size() && checkFieldTypes())
         {
    @@ -331,16 +82,4 @@
     }
     
     
    -void Foam::probes::read(const dictionary& dict)
    -{
    -    dict.lookup("fields") >> fieldNames_;
    -    dict.lookup("probeLocations") >> probeLocations_;
    -
    -    // Force all cell locations to be redetermined
    -    elementList_.clear();
    -    findElements(refCast<const fvMesh>(obr_));
    -    checkFieldTypes();
    -}
    -
    -
     // ************************************************************************* //
    diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/csvProbes.H
    copy from src/sampling/probes/probes.H
    copy to src/sampling/probes/csvProbes.H
    --- a/src/sampling/probes/probes.H
    +++ b/src/sampling/probes/csvProbes.H
    @@ -22,7 +22,7 @@
         along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
     
     Class
    -    Foam::probes
    +    Foam::csvProbes
     
     Description
         Set of locations to sample.
    @@ -30,118 +30,28 @@
         Call write() to sample and write files.
     
     SourceFiles
    -    probes.C
    +    csvProbes.C
     
     \*---------------------------------------------------------------------------*/
     
    -#ifndef probes_H
    -#define probes_H
    +#ifndef csvProbes_H
    +#define csvProbes_H
     
    -#include "HashPtrTable.H"
    -#include "OFstream.H"
    -#include "polyMesh.H"
    -#include "pointField.H"
    -#include "volFieldsFwd.H"
    +#include "probes.H"
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     namespace Foam
     {
     
    -// Forward declaration of classes
    -class objectRegistry;
    -class dictionary;
    -class fvMesh;
    -class mapPolyMesh;
    -
     /*---------------------------------------------------------------------------*\
    -                          Class probes Declaration
    +                          Class csvProbes Declaration
     \*---------------------------------------------------------------------------*/
     
    -class probes
    +class csvProbes
    +:
    +    public probes
     {
    -protected:
    -
    -    // Protected classes
    -
    -        //- Class used for grouping field types
    -        template<class Type>
    -        class fieldGroup
    -        :
    -            public wordList
    -        {
    -        public:
    -            //- Construct null
    -            fieldGroup()
    -            :
    -                wordList()
    -            {}
    -
    -            //- Construct for a list of field names
    -            fieldGroup(const wordList& fieldNames)
    -            :
    -                wordList(fieldNames)
    -            {}
    -        };
    -
    -
    -    // Protected data
    -
    -        //- Name of this set of probes,
    -        //  Also used as the name of the probes directory.
    -        word name_;
    -
    -        //- Const reference to objectRegistry
    -        const objectRegistry& obr_;
    -
    -        //- Load fields from files (not from objectRegistry)
    -        bool loadFromFiles_;
    -
    -
    -        // Read from dictonary
    -
    -            //- Names of fields to probe
    -            wordList fieldNames_;
    -
    -            //- Locations to probe
    -            vectorField probeLocations_;
    -
    -
    -        // Calculated
    -
    -            //- Categorized scalar/vector/tensor fields
    -            fieldGroup<scalar> scalarFields_;
    -            fieldGroup<vector> vectorFields_;
    -            fieldGroup<sphericalTensor> sphericalTensorFields_;
    -            fieldGroup<symmTensor> symmTensorFields_;
    -            fieldGroup<tensor> tensorFields_;
    -
    -            // Cells to be probed (obtained from the locations)
    -            labelList elementList_;
    -
    -            //- Current open files
    -            HashPtrTable<OFstream> probeFilePtrs_;
    -
    -
    -    // Private Member Functions
    -
    -        //- Find element containing probes
    -        virtual void findElements(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;
    -
    -
    -private:
    -
             //- Sample and write a particular volume field
             template<class Type>
             void sampleAndWrite
    @@ -154,23 +64,26 @@
             void sampleAndWrite(const fieldGroup<Type>&);
     
             //- Disallow default bitwise copy construct
    -        probes(const probes&);
    +        csvProbes(const csvProbes&);
     
             //- Disallow default bitwise assignment
    -        void operator=(const probes&);
    +        void operator=(const csvProbes&);
     
    +        //- write the probe-Header
    +         template<class T>
    +         void writeCSVProbeHeader(Ostream &out);
     
     public:
     
         //- Runtime type information
    -    TypeName("probes");
    +    TypeName("csvProbes");
     
     
         // Constructors
     
             //- Construct for given objectRegistry and dictionary.
             //  Allow the possibility to load fields from files
    -        probes
    +        csvProbes
             (
                 const word& name,
                 const objectRegistry&,
    @@ -180,69 +93,15 @@
     
     
         //- Destructor
    -    virtual ~probes();
    +    virtual ~csvProbes();
     
     
         // Member Functions
     
    -        //- Return name of the set of probes
    -        virtual const word& name() const
    -        {
    -            return name_;
    -        }
    -
    -        //- Return names of fields to probe
    -        virtual const wordList& fieldNames() const
    -        {
    -            return fieldNames_;
    -        }
    -
    -        //- Return locations to probe
    -        virtual const vectorField& probeLocations() const
    -        {
    -            return probeLocations_;
    -        }
    -
    -        //- Cells to be probed (obtained from the locations)
    -        const labelList& elements() const
    -        {
    -            return elementList_;
    -        }
    -
    -        //- Execute, currently does nothing
    -        virtual void execute();
    -
    -        //- Execute at the final time-loop, currently does nothing
    -        virtual void end();
     
             //- Sample and write
             virtual void write();
     
    -        //- Read the probes
    -        virtual void read(const dictionary&);
    -
    -        //- Update for changes of mesh
    -        virtual void updateMesh(const mapPolyMesh&)
    -        {}
    -
    -        //- Update for changes of mesh
    -        virtual void movePoints(const pointField&)
    -        {}
    -
    -        //- Update for changes of mesh due to readUpdate
    -        virtual void readUpdate(const polyMesh::readUpdateState state)
    -        {}
    -
    -        //- Sample a volume field at all locations
    -        template<class Type>
    -        tmp<Field<Type> > sample
    -        (
    -            const GeometricField<Type, fvPatchField, volMesh>&
    -        ) const;
    -
    -        //- Sample a single field on all sample locations
    -        template <class Type>
    -        tmp<Field<Type> > sample(const word& fieldName) const;
     };
     
     
    @@ -253,7 +112,7 @@
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     #ifdef NoRepository
    -#   include "probesTemplates.C"
    +#   include "csvProbesTemplates.C"
     #endif
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    diff --git a/src/sampling/probes/probesFunctionObject.C b/src/sampling/probes/csvProbesFunctionObject.C
    copy from src/sampling/probes/probesFunctionObject.C
    copy to src/sampling/probes/csvProbesFunctionObject.C
    --- a/src/sampling/probes/probesFunctionObject.C
    +++ b/src/sampling/probes/csvProbesFunctionObject.C
    @@ -23,29 +23,21 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "probesFunctionObject.H"
    +#include "csvProbesFunctionObject.H"
     
     // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
     
     namespace Foam
     {
    -    defineNamedTemplateTypeNameAndDebug(probesFunctionObject, 0);
    -
    -    defineNamedTemplateTypeNameAndDebug(patchProbesFunctionObject, 0);
    +    defineNamedTemplateTypeNameAndDebug(csvProbesFunctionObject, 0);
     
         addToRunTimeSelectionTable
         (
             functionObject,
    -        probesFunctionObject,
    +        csvProbesFunctionObject,
             dictionary
         );
     
    -    addToRunTimeSelectionTable
    -    (
    -        functionObject,
    -        patchProbesFunctionObject,
    -        dictionary
    -    );
     }
     
     // ************************************************************************* //
    diff --git a/src/sampling/probes/probesFunctionObject.H b/src/sampling/probes/csvProbesFunctionObject.H
    copy from src/sampling/probes/probesFunctionObject.H
    copy to src/sampling/probes/csvProbesFunctionObject.H
    --- a/src/sampling/probes/probesFunctionObject.H
    +++ b/src/sampling/probes/csvProbesFunctionObject.H
    @@ -22,30 +22,28 @@
         along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
     
     Typedef
    -    Foam::probesFunctionObject
    +    Foam::csvProbesFunctionObject
     
     Description
    -    FunctionObject wrapper around probes to allow them to be created via the
    +    FunctionObject wrapper around csvProbes to allow them to be created via the
         functions list within controlDict.
     
     SourceFiles
    -    probesFunctionObject.C
    +    csvProbesFunctionObject.C
     
     \*---------------------------------------------------------------------------*/
     
    -#ifndef probesFunctionObject_H
    -#define probesFunctionObject_H
    +#ifndef csvProbesFunctionObject_H
    +#define csvProbesFunctionObject_H
     
    -#include "probes.H"
    -#include "patchProbes.H"
    +#include "csvProbes.H"
     #include "OutputFilterFunctionObject.H"
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
     
     namespace Foam
     {
    -    typedef OutputFilterFunctionObject<probes> probesFunctionObject;
    -    typedef OutputFilterFunctionObject<patchProbes> patchProbesFunctionObject;
    +    typedef OutputFilterFunctionObject<csvProbes> csvProbesFunctionObject;
     }
     
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    diff --git a/src/sampling/probes/probesTemplates.C b/src/sampling/probes/csvProbesTemplates.C
    copy from src/sampling/probes/probesTemplates.C
    copy to src/sampling/probes/csvProbesTemplates.C
    --- a/src/sampling/probes/probesTemplates.C
    +++ b/src/sampling/probes/csvProbesTemplates.C
    @@ -23,7 +23,7 @@
     
     \*---------------------------------------------------------------------------*/
     
    -#include "probes.H"
    +#include "csvProbes.H"
     #include "volFields.H"
     #include "IOmanip.H"
     
    @@ -32,67 +32,72 @@
     namespace Foam
     {
     
    -//- comparison operator for probes class
    -template<class T>
    -class isNotEqOp
    +// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    +
    +template<>
    +inline void Foam::csvProbes::writeCSVProbeHeader<scalar>(Ostream &out)
     {
    -public:
    +    out << "Time";
    +        
    +    forAll(probeLocations_, probeI)
    +    {
    +        out << ",@" << probeLocations_[probeI];
    +    }
     
    -    void operator()(T& x, const T& y) const
    -    {
    -        const T unsetVal(-VGREAT*pTraits<T>::one);
    -
    -        if (x != unsetVal)
    -        {
    -            // Keep x.
    -
    -            // Note:chould check for y != unsetVal but multiple sample cells
    -            // already handled in read().
    -        }
    -        else
    -        {
    -            // x is not set. y might be.
    -            x = y;
    -        }
    -    }
    -};
    -
    +    out << endl;
     }
     
    -
    -// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
    -
     template<class Type>
    -Foam::label Foam::probes::countFields
    -(
    -    fieldGroup<Type>& fieldList,
    -    const wordList& fieldTypes
    -) const
    +void Foam::csvProbes::writeCSVProbeHeader(Ostream &out)
     {
    -    fieldList.setSize(fieldNames_.size());
    -    label nFields = 0;
    -
    -    forAll(fieldNames_, fieldI)
    +    out << "Time";
    +        
    +    forAll(probeLocations_, probeI)
         {
    -        if
    -        (
    -            fieldTypes[fieldI]
    -         == GeometricField<Type, fvPatchField, volMesh>::typeName
    -        )
    -        {
    -            fieldList[nFields] = fieldNames_[fieldI];
    -            nFields++;
    +        for(label j=0;j<Type::nComponents;j++) {
    +            out << "," << Type::componentNames[j]
    +                << "@" << probeLocations_[probeI] ;
             }
         }
     
    -    fieldList.setSize(nFields);
    -
    -    return nFields;
    +    out << endl;
     }
     
    +template<>
    +inline void Foam::csvProbes::sampleAndWrite
    +(
    +    const GeometricField<scalar, fvPatchField, volMesh>& vField
    +)
    +{
    +    Field<scalar> values = sample(vField);
    +
    +    if (Pstream::master())
    +    {
    +        // formatting pretty throws some Spreadsheets off the track
    +        //        unsigned int w = IOstream::defaultPrecision() + 7;
    +
    +        OFstream& probeStream = *probeFilePtrs_[vField.name()];
    +        if( !probeFileHasHeader_.found(vField.name()) ) 
    +        {
    +            probeFileHasHeader_.insert(vField.name());
    +            writeCSVProbeHeader<scalar>(probeStream);
    +        }
    +
    +        //        probeStream << setw(w) << vField.time().value();
    +        probeStream << vField.time().value();
    +
    +        forAll(values, probeI)
    +        {
    +            //            probeStream << ',' << setw(w) << values[probeI];
    +            probeStream << ',' << values[probeI];
    +        }
    +        probeStream << endl;
    +    }
    +}
    +
     
     template<class Type>
    -void Foam::probes::sampleAndWrite
    +void Foam::csvProbes::sampleAndWrite
     (
         const GeometricField<Type, fvPatchField, volMesh>& vField
     )
    @@ -101,14 +106,24 @@
     
         if (Pstream::master())
         {
    -        unsigned int w = IOstream::defaultPrecision() + 7;
    +        //        unsigned int w = IOstream::defaultPrecision() + 7;
    +
             OFstream& probeStream = *probeFilePtrs_[vField.name()];
    +        if( !probeFileHasHeader_.found(vField.name()) ) 
    +        {
    +            probeFileHasHeader_.insert(vField.name());
    +            writeCSVProbeHeader<Type>(probeStream);
    +        }
     
    -        probeStream << setw(w) << vField.time().value();
    +        //        probeStream  << setw(w) << vField.time().value();
    +        probeStream << vField.time().value();
     
             forAll(values, probeI)
             {
    -            probeStream << ' ' << setw(w) << values[probeI];
    +            for(label j=0;j<Type::nComponents;j++) {
    +                //                probeStream << ',' << setw(w) << values[probeI][j];
    +                probeStream << ',' << values[probeI][j];
    +            }
             }
             probeStream << endl;
         }
    @@ -116,7 +131,7 @@
     
     
     template <class Type>
    -void Foam::probes::sampleAndWrite
    +void Foam::csvProbes::sampleAndWrite
     (
         const fieldGroup<Type>& fields
     )
    @@ -169,49 +184,6 @@
     
     // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
     
    -template<class Type>
    -Foam::tmp<Foam::Field<Type> >
    -Foam::probes::sample
    -(
    -    const GeometricField<Type, fvPatchField, volMesh>& vField
    -) const
    -{
    -    const Type unsetVal(-VGREAT*pTraits<Type>::one);
    -
    -    tmp<Field<Type> > tValues
    -    (
    -        new Field<Type>(probeLocations_.size(), unsetVal)
    -    );
    -
    -    Field<Type>& values = tValues();
    -
    -    forAll(probeLocations_, probeI)
    -    {
    -        if (elementList_[probeI] >= 0)
    -        {
    -            values[probeI] = vField[elementList_[probeI]];
    -        }
    -    }
    -
    -    Pstream::listCombineGather(values, isNotEqOp<Type>());
    -    Pstream::listCombineScatter(values);
    -
    -    return tValues;
     }
     
    -
    -template<class Type>
    -Foam::tmp<Foam::Field<Type> >
    -Foam::probes::sample(const word& fieldName) const
    -{
    -    return sample
    -    (
    -        obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
    -        (
    -            fieldName
    -        )
    -    );
    -}
    -
    -
     // ************************************************************************* //
    diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C
    --- a/src/sampling/probes/probes.C
    +++ b/src/sampling/probes/probes.C
    @@ -178,6 +178,13 @@
             foundFields[fieldI++] = tensorFields_[i];
         }
     
    +    createFiles(foundFields);
    +
    +    return nFields > 0;
    +}
    +
    +void Foam::probes::createFiles(const wordList &foundFields)
    +{
         if (Pstream::master())
         {
             fileName probeDir;
    @@ -206,6 +213,10 @@
             {
                 if (findIndex(foundFields, iter.key()) == -1)
                 {
    +                if(probeFileHasHeader_.found(iter.key())) {
    +                    probeFileHasHeader_.erase(iter.key());
    +                }
    +
                     if (debug)
                     {
                         Pout<< "close stream: " << iter()->name() << endl;
    @@ -230,7 +241,7 @@
                     // Create directory if does not exist.
                     mkDir(probeDir);
     
    -                OFstream* sPtr = new OFstream(probeDir/fldName);
    +                OFstream* sPtr = new OFstream(probeDir/fldName+fileExtension_);
     
                     if (debug)
                     {
    @@ -238,23 +249,6 @@
                     }
     
                     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;
                 }
             }
     
    @@ -265,11 +259,27 @@
                     << endl;
             }
         }
    -
    -
    -    return nFields > 0;
     }
     
    +void Foam::probes::writeProbeHeader(Ostream &out)
    +{
    +    unsigned int w = IOstream::defaultPrecision() + 7;
    +    
    +    for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
    +    {
    +        out << '#' << setw(IOstream::defaultPrecision() + 6)
    +            << vector::componentNames[cmpt];
    +        
    +        forAll(probeLocations_, probeI)
    +        {
    +            out << ' ' << setw(w) << probeLocations_[probeI][cmpt];
    +        }
    +        out << endl;
    +    }
    +    
    +    out << '#' << setw(IOstream::defaultPrecision() + 6)
    +        << "Time" << endl;
    +}
     
     // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
     
    @@ -297,6 +307,31 @@
         read(dict);
     }
     
    +Foam::probes::probes
    +(
    +    const word& name,
    +    const objectRegistry& obr,
    +    const dictionary& dict,
    +    const word &extension,
    +    const bool loadFromFiles
    +)
    +:
    +    fileExtension_(extension),
    +    name_(name),
    +    obr_(obr),
    +    loadFromFiles_(loadFromFiles),
    +    fieldNames_(0),
    +    probeLocations_(0),
    +    scalarFields_(),
    +    vectorFields_(),
    +    sphericalTensorFields_(),
    +    symmTensorFields_(),
    +    tensorFields_(),
    +    elementList_(0),
    +    probeFilePtrs_(0)
    +{
    +}
    +
     
     // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
     
    diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/probes.H
    --- a/src/sampling/probes/probes.H
    +++ b/src/sampling/probes/probes.H
    @@ -84,9 +84,15 @@
                 {}
             };
     
    +    //- write the probe-Header
    +    void writeProbeHeader(Ostream &out);
     
         // Protected data
     
    +    //- extension for written files
    +    word fileExtension_;
    +protected:
    +
             //- Name of this set of probes,
             //  Also used as the name of the probes directory.
             word name_;
    @@ -122,15 +128,14 @@
                 //- Current open files
                 HashPtrTable<OFstream> probeFilePtrs_;
     
    +            //- Has this file a header?
    +            HashSet<word> probeFileHasHeader_;
     
         // Private Member Functions
     
             //- Find element containing probes
             virtual void findElements(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
    @@ -140,8 +145,6 @@
             ) const;
     
     
    -private:
    -
             //- Sample and write a particular volume field
             template<class Type>
             void sampleAndWrite
    @@ -153,12 +156,33 @@
             template <class Type>
             void sampleAndWrite(const fieldGroup<Type>&);
     
    +        //- Construct for given objectRegistry and dictionary.
    +        //  Allow the possibility to load fields from files.
    +        // to be used by subclasses
    +        probes
    +        (
    +            const word& name,
    +            const objectRegistry&,
    +            const dictionary&,
    +            const word &extension,
    +            const bool loadFromFiles = false
    +        );
    +
    +private:
    +
             //- Disallow default bitwise copy construct
             probes(const probes&);
     
             //- Disallow default bitwise assignment
             void operator=(const probes&);
     
    +protected:
    +
    +        //- classify field types, return true if nFields > 0
    +        bool checkFieldTypes();
    +
    +        //- create the files
    +        void createFiles(const wordList &foundFields);
     
     public:
     
    diff --git a/src/sampling/probes/probesTemplates.C b/src/sampling/probes/probesTemplates.C
    --- a/src/sampling/probes/probesTemplates.C
    +++ b/src/sampling/probes/probesTemplates.C
    @@ -104,6 +104,11 @@
             unsigned int w = IOstream::defaultPrecision() + 7;
             OFstream& probeStream = *probeFilePtrs_[vField.name()];
     
    +        if( !probeFileHasHeader_.found(vField.name()) ) 
    +        {
    +            probeFileHasHeader_.insert(vField.name());
    +            writeProbeHeader(probeStream);
    +        }
             probeStream << setw(w) << vField.time().value();
     
             forAll(values, probeI)
    
    patch file icon CSVProbes.v2.patch (30,263 bytes) 2010-12-14 16:23 +

-Relationships
+Relationships

-Notes

~0000153

bgschaid (reporter)

Sorry for the (non)formatting. It looked nice (paragraphs and all) in the textbox when I wrote it

~0000155

bgschaid (reporter)

Uploaded a second version of the Timeline-patch that fixes a problem if the data file does not exist

~0000178

bgschaid (reporter)

Recent changes in the GIT made the probes-patch fail so I uploaded a new version

~0000341

user4

Commit 6a818ef288cbfae26620182a0f5b3a7dbe94524b:
- csv interpolationTable readers (CSVTimeLine.patch)
- sampledSet csv writer (CSVWriter.patch)

I've left out the csvProbes.

Thanks!
+Notes

-Issue History
Date Modified Username Field Change
2010-12-01 20:30 bgschaid New Issue
2010-12-01 20:30 bgschaid File Added: CSVProbes.patch
2010-12-01 20:31 bgschaid File Added: CSVTimeline.patch
2010-12-01 20:31 bgschaid File Added: CSVWriter.patch
2010-12-01 20:32 bgschaid Note Added: 0000153
2010-12-01 20:33 bgschaid Tag Attached: Input/output
2010-12-05 11:01 bgschaid File Added: CSVTimeline.v2.patch
2010-12-05 11:02 bgschaid Note Added: 0000155
2010-12-14 16:23 bgschaid File Added: CSVProbes.v2.patch
2010-12-14 16:23 bgschaid Note Added: 0000178
2011-04-26 19:11 user4 Note Added: 0000341
2011-05-04 12:34 user2 Status new => closed
2011-05-04 12:34 user2 Assigned To => user4
2011-05-04 12:34 user2 Resolution open => fixed
2011-05-04 12:34 user2 Fixed in Version => 1.7.x
+Issue History