From 4414a656830153e80ff33b75160ec8201d642702 Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Mon, 24 Sep 2012 12:37:56 +0100
Subject: [PATCH] ENH: Added helper function to set 'writer' API

---
 src/sampling/sampledSet/writers/writer.C | 21 ++++++++++++++++++++-
 src/sampling/sampledSet/writers/writer.H | 21 +++++++++++++--------
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/src/sampling/sampledSet/writers/writer.C b/src/sampling/sampledSet/writers/writer.C
index ded4523d1c8..69dbdec6fe7 100644
--- a/src/sampling/sampledSet/writers/writer.C
+++ b/src/sampling/sampledSet/writers/writer.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -152,6 +152,25 @@ Foam::writer<Type>::~writer()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
+template<class Type>
+void Foam::writer<Type>::write
+(
+    const coordSet& points,
+    const wordList& valueSetNames,
+    const List<Field<Type> >& valueSets,
+    Ostream& os
+) const
+{
+    List<const Field<Type>*> valueSetPtrs(valueSets.size());
+    forAll(valueSetPtrs, i)
+    {
+        valueSetPtrs[i] = &valueSets[i];
+    }
+    
+    write(points, valueSetNames, valueSetPtrs, os);
+}
+
+
 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
index 6e55a20b6ed..8c754bd47b1 100644
--- a/src/sampling/sampledSet/writers/writer.H
+++ b/src/sampling/sampledSet/writers/writer.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -40,13 +40,7 @@ Description
         // Output list of points and corresponding values
         scalarFormatter().write
         (
-            coordSet
-            (
-                points,         // sample coordinates
-                "someLine",     // name of coordSet
-                "distance",     // write coordinates as distance to refPoint
-                points[0]       // reference point
-            ),
+            coordSet(...)
             "U.component(0)",   // name of values
             vals                // values
         );
@@ -164,6 +158,17 @@ public:
             Ostream&
         ) const = 0;
 
+        //- General entry point for writing.
+        //  The data is organized in a set of point with one or more values
+        //  per point
+        virtual void write
+        (
+            const coordSet&,
+            const wordList&,
+            const List<Field<Type> >&,
+            Ostream&
+        ) const;
+
         //- General entry point for writing of multiple coordSets.
         //  Each coordSet (track) has same data variables.
         //  The data is per variable, per track, per point of track.
-- 
GitLab