From 6c6a91c425beebd4cfa709b11591d3f97849ec6e Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Mon, 28 Jan 2013 16:45:11 +0000
Subject: [PATCH] ENH: Added helper function to return CSV data as fields

---
 .../functions/DataEntry/Table/TableBase.C     | 32 ++++++++++++++++++-
 .../functions/DataEntry/Table/TableBase.H     |  8 ++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C
index 08dde8e7583..054d87575e2 100644
--- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C
+++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -414,6 +414,36 @@ Foam::dimensioned<Type> Foam::TableBase<Type>::dimIntegrate
 }
 
 
+template<class Type>
+Foam::tmp<Foam::scalarField> Foam::TableBase<Type>::x() const
+{
+    tmp<scalarField> tfld(new scalarField(table_.size(), 0.0));
+    scalarField& fld = tfld();
+
+    forAll(table_, i)
+    {
+        fld[i] = table_[i].first();
+    }
+
+    return tfld;
+}
+
+
+template<class Type>
+Foam::tmp<Foam::Field<Type> > Foam::TableBase<Type>::y() const
+{
+    tmp<Field<Type> > tfld(new Field<Type>(table_.size(), pTraits<Type>::zero));
+    Field<Type>& fld = tfld();
+
+    forAll(table_, i)
+    {
+        fld[i] = table_[i].second();
+    }
+
+    return tfld;
+}
+
+
 // * * * * * * * * * * * * * *  IOStream operators * * * * * * * * * * * * * //
 
 #include "TableBaseIO.C"
diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H
index da670e2db56..793716803ae 100644
--- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H
+++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -172,6 +172,12 @@ public:
             const scalar x2
         ) const;
 
+        //- Return the reference values
+        virtual tmp<scalarField> x() const;
+
+        //- Return the dependent values
+        virtual tmp<Field<Type> > y() const;
+
 
     // I/O
 
-- 
GitLab