View Issue Details

IDProjectCategoryView StatusLast Update
0001832OpenFOAMBugpublic2015-08-19 11:44
ReportermaHein Assigned Tohenry  
PrioritynormalSeveritytextReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSDebianOS Version8
Summary0001832: noise documentation incorrect
DescriptionThe documentation for the noise tool states, that the noiseDict should look like the following:

csvFileData
{
    fileName "pressureData"
    nHeaderLine 1;
    refColumn 0;
    componentColumns (1);
    separator " ";
}

However, this does not work and abort with the following error message:

--> FOAM FATAL IO ERROR:
keyword pressureData is undefined in dictionary "/disk401/home/heinri8/Projekt/Validation/tandemCylinder/simulation/backward/system/noiseDict"


The correct dict looks like:

pressureDat
{
    fileName "pressureData";
    nHeaderLine 0;
    refColumn 0;
    componentColumns (2);
    mergeSeparators true;
    separator " ";
}

Could you correct the documentation in the noise.C file?
TagsNo tags attached.

Activities

maHein

2015-08-18 14:25

reporter   ~0005260

My mistake, the correct dict looks like:

pressureData
{
    fileName "pressureData";
    nHeaderLine 0;
    refColumn 0;
    componentColumns (2);
    mergeSeparators true;
    separator " ";
}

wyldckat

2015-08-18 18:42

updater  

noise_and_CSV.patch (1,762 bytes)   
diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C
index 79a5521..28c3b4a 100644
--- a/applications/utilities/postProcessing/noise/noise.C
+++ b/applications/utilities/postProcessing/noise/noise.C
@@ -42,13 +42,16 @@ Description
     fU          10000;
     graphFormat raw;
 
-    csvFileData
+    pressureData
     {
         fileName        "pressureData"
-        nHeaderLine     1;
-        refColumn       0;
-        componentColumns (1);
-        separator       " ";
+        nHeaderLine         1;          // number of header lines
+        refColumn           0;          // reference column index
+        componentColumns    (1);        // component column indices
+        separator           " ";        // optional (defaults to ",")
+        mergeSeparators     no;         // merge multiple separators
+        outOfBounds         clamp;      // optional out-of-bounds handling
+        interpolationScheme linear;     // optional interpolation scheme
     }
     \endverbatim
 
diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H
index 78476ad..fa048f9 100644
--- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H
+++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H
@@ -32,7 +32,7 @@ Description
         <entryName> csvFile;
         <entryName>Coeffs
         {
-            nHeaderLine         4;
+            nHeaderLine         4;          // number of header lines
             refColumn           0;          // reference column index
             componentColumns    (1 2 3);    // component column indices
             separator           ",";        // optional (defaults to ",")
noise_and_CSV.patch (1,762 bytes)   

wyldckat

2015-08-18 18:42

updater  

noise.C (5,866 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
     \\/     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/>.

Application
    noise

Description
    Utility to perform noise analysis of pressure data using the noiseFFT
    library.

    Control settings are read from the $FOAM_CASE/system/noiseDict dictionary,
    or user-specified dictionary using the -dict option.  Pressure data is
    read using a CSV reader:

    \heading Usage

    \verbatim
    pRef        101325;
    N           65536;
    nw          100;
    f1          25;
    fU          10000;
    graphFormat raw;

    pressureData
    {
        fileName        "pressureData"
        nHeaderLine         1;          // number of header lines
        refColumn           0;          // reference column index
        componentColumns    (1);        // component column indices
        separator           " ";        // optional (defaults to ",")
        mergeSeparators     no;         // merge multiple separators
        outOfBounds         clamp;      // optional out-of-bounds handling
        interpolationScheme linear;     // optional interpolation scheme
    }
    \endverbatim

    where
    \table
        Property    | Description                   | Required  | Default value
        pRef        | Reference pressure            | no        | 0
        N           | Number of samples in sampling window | no | 65536
        nw          | Number of sampling windows    | no        | 100
        fl          | Lower frequency band          | no        | 25
        fU          | Upper frequency band          | no        | 10000
        graphFormat | Output graph format          | no        | raw
    \endtable

    Current graph outputs include:
    - FFT of the pressure data
    - narrow-band PFL (pressure-fluctuation level) spectrum
    - one-third-octave-band PFL spectrum
    - one-third-octave-band pressure spectrum

SeeAlso
    CSV.H
    noiseFFT.H

\*---------------------------------------------------------------------------*/


#include "noiseFFT.H"
#include "argList.H"
#include "Time.H"
#include "functionObjectFile.H"
#include "CSV.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

using namespace Foam;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Foam::scalar checkUniformTimeStep(const scalarField& t)
{
    // check that a uniform time step has been applied
    scalar deltaT = -1.0;
    if (t.size() > 1)
    {
        for (label i = 1; i < t.size(); i++)
        {
            scalar dT = t[i] - t[i-1];
            if (deltaT < 0)
            {
                deltaT = dT;
            }

            if (mag(deltaT - dT) > SMALL)
            {
                FatalErrorIn("checkUniformTimeStep(const scalarField&)")
                    << "Unable to process data with a variable time step"
                    << exit(FatalError);
            }
        }
    }
    else
    {
        FatalErrorIn("checkUniformTimeStep(const scalarField&)")
            << "Unable to create FFT with a single value"
            << exit(FatalError);
    }

    return deltaT;
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    argList::noParallel();
    #include "addDictOption.H"
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createFields.H"

    Info<< "Reading data file" << endl;
    CSV<scalar> pData("pressure", dict, "Data");

    // time history data
    const scalarField t(pData.x());

    // pressure data
    const scalarField p(pData.y());

    if (t.size() < N)
    {
        FatalErrorIn(args.executable())
            << "Block size N = " << N
            << " is larger than number of data = " << t.size()
            << exit(FatalError);
    }

    Info<< "    read " << t.size() << " values" << nl << endl;


    Info<< "Creating noise FFT" << endl;
    noiseFFT nfft(checkUniformTimeStep(t), p);

    nfft -= pRef;

    fileName baseFileName(pData.fName().lessExt());

    graph Pf(nfft.RMSmeanPf(N, min(nfft.size()/N, nw)));
    Info<< "    Creating graph for " << Pf.title() << endl;
    Pf.write(baseFileName + graph::wordify(Pf.title()), graphFormat);

    graph Lf(nfft.Lf(Pf));
    Info<< "    Creating graph for " << Lf.title() << endl;
    Lf.write(baseFileName + graph::wordify(Lf.title()), graphFormat);

    graph Ldelta(nfft.Ldelta(Lf, f1, fU));
    Info<< "    Creating graph for " << Ldelta.title() << endl;
    Ldelta.write(baseFileName + graph::wordify(Ldelta.title()), graphFormat);

    graph Pdelta(nfft.Pdelta(Pf, f1, fU));
    Info<< "    Creating graph for " << Pdelta.title() << endl;
    Pdelta.write(baseFileName + graph::wordify(Pdelta.title()), graphFormat);

    Info<< nl << "End\n" << endl;

    return 0;
}


// ************************************************************************* //
noise.C (5,866 bytes)   

wyldckat

2015-08-18 18:43

updater  

CSV.H (5,956 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
     \\/     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::CSV

Description
    Templated CSV container data entry.  Reference column is always a scalar,
    e.g. time

    \verbatim
        <entryName> csvFile;
        <entryName>Coeffs
        {
            nHeaderLine         4;          // number of header lines
            refColumn           0;          // reference column index
            componentColumns    (1 2 3);    // component column indices
            separator           ",";        // optional (defaults to ",")
            mergeSeparators     no;         // merge multiple separators
            fileName            "fileXYZ";  // name of csv data file
            outOfBounds         clamp;      // optional out-of-bounds handling
            interpolationScheme linear;     // optional interpolation scheme
        }
    \endverbatim

SourceFiles
    CSV.C

\*---------------------------------------------------------------------------*/

#ifndef CSV_H
#define CSV_H

#include "DataEntry.H"
#include "TableBase.H"
#include "Tuple2.H"
#include "labelList.H"
#include "ISstream.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

template<class Type>
class CSV;

template<class Type>
Ostream& operator<<
(
    Ostream&,
    const CSV<Type>&
);

/*---------------------------------------------------------------------------*\
                           Class CSV Declaration
\*---------------------------------------------------------------------------*/

template<class Type>
class CSV
:
    public DataEntry<Type>,
    public TableBase<Type>
{
    // Private data

        //- Coefficients dictionary (for convenience on reading)
        dictionary coeffs_;

        //- Number header lines
        label nHeaderLine_;

        //- Column of the time
        label refColumn_;

        //- Labels of the components
        labelList componentColumns_;

        //- Separator character
        char separator_;

        //- Merge separators flag, e.g. ',,,' becomes ','
        bool mergeSeparators_;

        //- File name for csv table
        fileName fName_;


    // Private Member Functions

        //- Read csv data table
        void read();

        //- Read the next value from the splitted string
        Type readValue(const List<string>&);

        //- Disallow default bitwise assignment
        void operator=(const CSV<Type>&);


public:

    //- Runtime type information
    TypeName("csvFile");


    // Constructors

        //- Construct from entry name and dictionary
        CSV
        (
            const word& entryName,
            const dictionary& dict,
            const word& ext = "Coeffs"
        );

        //- Copy constructor
        CSV(const CSV<Type>& tbl);

        //- Construct and return a clone
        virtual tmp<DataEntry<Type> > clone() const
        {
            return tmp<DataEntry<Type> >(new CSV<Type>(*this));
        }


    //- Destructor
    virtual ~CSV();


    // Member Functions

        // Manipulation

            //- Convert time
            virtual void convertTimeBase(const Time& t)
            {
                TableBase<Type>::convertTimeBase(t);
            }


        // Access

            //- Return const access to the file name
            virtual const fileName& fName() const;


        // Evaluation

            //- Return Table value
            virtual Type value(const scalar x) const
            {
                return TableBase<Type>::value(x);
            }

            //- Integrate between two (scalar) values
            virtual Type integrate(const scalar x1, const scalar x2) const
            {
                return TableBase<Type>::integrate(x1, x2);
            }

            //- Return dimensioned constant value
            virtual dimensioned<Type> dimValue(const scalar x) const
            {
                return TableBase<Type>::dimValue(x);
            }

            //- Integrate between two values and return dimensioned type
            virtual dimensioned<Type> dimIntegrate
            (
                const scalar x1,
                const scalar x2
            ) const
            {
                return TableBase<Type>::dimIntegrate(x1, x2);
            }


    // I/O

        //- Ostream Operator
        friend Ostream& operator<< <Type>
        (
            Ostream& os,
            const CSV<Type>& cnst
        );

        //- Write in dictionary format
        virtual void writeData(Ostream& os) const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#ifdef NoRepository
#   include "CSV.C"
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //
CSV.H (5,956 bytes)   

wyldckat

2015-08-18 18:45

updater   ~0005265

Last edited: 2015-08-18 18:53

Attached 3 files:

 - "noise_and_CSV.patch" - includes the changes provided in the following 2 files.

 - "noise.C" file for updating "applications/utilities/postProcessing/noise/noise.C", which includes the updated description based on the original "noise.C" file and the "CSV.H" file.

 - "CSV.H" file for updating "src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H", only because the "nHeaderLine" keyword didn't have a description on the header.

edit: all 3 referring to 2.4.x.

henry

2015-08-19 11:43

manager   ~0005271

Thanks for the patch but the files were more useful to merge the changes into OpenFOAM-dev.

Resolved by
commit a0fd6061860ab3b5e6ce9d3b7f9d57b9b1a13f45 in OpenFOAM-2.4.x
commit 2828d82cba8f68a2e4819c4e593cbb452952e87a in OpenFOAM-dev

Issue History

Date Modified Username Field Change
2015-08-18 14:24 maHein New Issue
2015-08-18 14:25 maHein Note Added: 0005260
2015-08-18 18:42 wyldckat File Added: noise_and_CSV.patch
2015-08-18 18:42 wyldckat File Added: noise.C
2015-08-18 18:43 wyldckat File Added: CSV.H
2015-08-18 18:45 wyldckat Note Added: 0005265
2015-08-18 18:53 wyldckat Note Edited: 0005265
2015-08-19 11:43 henry Note Added: 0005271
2015-08-19 11:43 henry Status new => resolved
2015-08-19 11:43 henry Resolution open => fixed
2015-08-19 11:43 henry Assigned To => henry