From de2ac5afd21ea52829fa922a69366e0d5751f308 Mon Sep 17 00:00:00 2001
From: andy <a.heather@opencfd.co.uk>
Date: Mon, 6 Oct 2008 15:25:57 +0100
Subject: [PATCH] new systemCall function object, and added -lsampling to
 options files

---
 src/postProcessing/Allwmake                   |   1 +
 src/postProcessing/forces/Make/options        |   1 +
 src/postProcessing/minMaxFields/Make/options  |   3 +-
 src/postProcessing/systemCall/IOsystemCall.H  |  50 ++++++
 src/postProcessing/systemCall/Make/files      |   4 +
 src/postProcessing/systemCall/Make/options    |   9 ++
 src/postProcessing/systemCall/systemCall.C    |  91 +++++++++++
 src/postProcessing/systemCall/systemCall.H    | 147 ++++++++++++++++++
 .../systemCall/systemCallFunctionObject.C     |  43 +++++
 .../systemCall/systemCallFunctionObject.H     |  55 +++++++
 10 files changed, 403 insertions(+), 1 deletion(-)
 create mode 100644 src/postProcessing/systemCall/IOsystemCall.H
 create mode 100644 src/postProcessing/systemCall/Make/files
 create mode 100644 src/postProcessing/systemCall/Make/options
 create mode 100644 src/postProcessing/systemCall/systemCall.C
 create mode 100644 src/postProcessing/systemCall/systemCall.H
 create mode 100644 src/postProcessing/systemCall/systemCallFunctionObject.C
 create mode 100644 src/postProcessing/systemCall/systemCallFunctionObject.H

diff --git a/src/postProcessing/Allwmake b/src/postProcessing/Allwmake
index 1d889e8b76f..e1f7cc56d82 100755
--- a/src/postProcessing/Allwmake
+++ b/src/postProcessing/Allwmake
@@ -7,5 +7,6 @@ wmake libso forces
 wmake libso fieldAverage
 wmake libso foamCalcFunctions
 wmake libso minMaxFields
+wmake libso systemCall
 
 # ----------------------------------------------------------------- end-of-file
diff --git a/src/postProcessing/forces/Make/options b/src/postProcessing/forces/Make/options
index 929d4c25d15..3ae6adad4ed 100644
--- a/src/postProcessing/forces/Make/options
+++ b/src/postProcessing/forces/Make/options
@@ -11,6 +11,7 @@ EXE_INC = \
 LIB_LIBS = \
     -lfiniteVolume \
     -lmeshTools \
+    -lsampling \
     -lincompressibleTransportModels \
     -lincompressibleRASModels \
     -lincompressibleLESModels \
diff --git a/src/postProcessing/minMaxFields/Make/options b/src/postProcessing/minMaxFields/Make/options
index 0954a906898..5166bcc9e32 100644
--- a/src/postProcessing/minMaxFields/Make/options
+++ b/src/postProcessing/minMaxFields/Make/options
@@ -5,4 +5,5 @@ EXE_INC = \
 
 LIB_LIBS = \
     -lfiniteVolume \
-    -lmeshTools
+    -lmeshTools \
+    -lsampling
diff --git a/src/postProcessing/systemCall/IOsystemCall.H b/src/postProcessing/systemCall/IOsystemCall.H
new file mode 100644
index 00000000000..fff6e7dbdb4
--- /dev/null
+++ b/src/postProcessing/systemCall/IOsystemCall.H
@@ -0,0 +1,50 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM; if not, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Typedef
+    Foam::IOsystemCall
+
+Description
+    Instance of the generic IOOutputFilter for systemCall.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef IOsystemCall_H
+#define IOsystemCall_H
+
+#include "systemCall.H"
+#include "IOOutputFilter.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef IOOutputFilter<systemCall> IOsystemCall;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/postProcessing/systemCall/Make/files b/src/postProcessing/systemCall/Make/files
new file mode 100644
index 00000000000..20bafa8dfa0
--- /dev/null
+++ b/src/postProcessing/systemCall/Make/files
@@ -0,0 +1,4 @@
+systemCall.C
+systemCallFunctionObject.C
+
+LIB = $(FOAM_LIBBIN)/libsystemCall
diff --git a/src/postProcessing/systemCall/Make/options b/src/postProcessing/systemCall/Make/options
new file mode 100644
index 00000000000..5166bcc9e32
--- /dev/null
+++ b/src/postProcessing/systemCall/Make/options
@@ -0,0 +1,9 @@
+EXE_INC = \
+    -I$(LIB_SRC)/finiteVolume/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/sampling/lnInclude
+
+LIB_LIBS = \
+    -lfiniteVolume \
+    -lmeshTools \
+    -lsampling
diff --git a/src/postProcessing/systemCall/systemCall.C b/src/postProcessing/systemCall/systemCall.C
new file mode 100644
index 00000000000..b1756776c50
--- /dev/null
+++ b/src/postProcessing/systemCall/systemCall.C
@@ -0,0 +1,91 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM; if not, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "systemCall.H"
+#include "dictionary.H"
+#include "Time.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(systemCall, 0);
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::systemCall::systemCall
+(
+    const word& name,
+    const objectRegistry& obr,
+    const dictionary& dict,
+    const bool loadFromFiles
+)
+:
+    name_(name),
+    obr_(obr),
+    active_(true),
+    executeCalls_(),
+    writeCalls_()
+{
+    read(dict);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::systemCall::~systemCall()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::systemCall::read(const dictionary& dict)
+{
+    dict.lookup("executeCalls") >> executeCalls_;
+    dict.lookup("writeCalls") >> writeCalls_;
+}
+
+
+void Foam::systemCall::execute()
+{
+    forAll(executeCalls_, callI)
+    {
+        ::system(executeCalls_[callI].c_str());
+    }
+}
+
+void Foam::systemCall::write()
+{
+    forAll(writeCalls_, callI)
+    {
+        ::system(writeCalls_[callI].c_str());
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/src/postProcessing/systemCall/systemCall.H b/src/postProcessing/systemCall/systemCall.H
new file mode 100644
index 00000000000..1d070cd6a99
--- /dev/null
+++ b/src/postProcessing/systemCall/systemCall.H
@@ -0,0 +1,147 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM; if not, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Class
+    Foam::systemCall
+
+Description
+    Executes system calls, entered in the form of a string list
+
+SourceFiles
+    systemCall.C
+    IOsystemCall.H
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef systemCall_H
+#define systemCall_H
+
+#include "stringList.H"
+#include "pointFieldFwd.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of classes
+class objectRegistry;
+class dictionary;
+class mapPolyMesh;
+
+/*---------------------------------------------------------------------------*\
+                       Class systemCall Declaration
+\*---------------------------------------------------------------------------*/
+
+class systemCall
+{
+protected:
+
+    // Private data
+
+        //- Name of this set of forces,
+        //  Also used as the name of the probes directory.
+        word name_;
+
+        const objectRegistry& obr_;
+
+        //- on/off switch
+        bool active_;
+
+        //- List of calls to execute - every step
+        stringList executeCalls_;
+
+        //- List of calls to execute - write steps
+        stringList writeCalls_;
+
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        systemCall(const systemCall&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const systemCall&);
+
+
+public:
+
+    //- Runtime type information
+    TypeName("systemCall");
+
+
+    // Constructors
+
+        //- Construct for given objectRegistry and dictionary.
+        //  Allow the possibility to load fields from files
+        systemCall
+        (
+            const word& name,
+            const objectRegistry&,
+            const dictionary&,
+            const bool loadFromFiles = false
+        );
+
+
+    // Destructor
+
+        virtual ~systemCall();
+
+
+    // Member Functions
+
+        //- Return name of the system call set
+        virtual const word& name() const
+        {
+            return name_;
+        }
+
+        //- Read the system calls
+        virtual void read(const dictionary&);
+
+        //- Execute
+        virtual void execute();
+
+        //- Write
+        virtual void write();
+
+        //- Update for changes of mesh
+        virtual void updateMesh(const mapPolyMesh&)
+        {}
+
+        //- Update for changes of mesh
+        virtual void movePoints(const pointField&)
+        {}
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/postProcessing/systemCall/systemCallFunctionObject.C b/src/postProcessing/systemCall/systemCallFunctionObject.C
new file mode 100644
index 00000000000..6e6b2e646bb
--- /dev/null
+++ b/src/postProcessing/systemCall/systemCallFunctionObject.C
@@ -0,0 +1,43 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM; if not, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "systemCallFunctionObject.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineNamedTemplateTypeNameAndDebug(systemCallFunctionObject, 0);
+
+    addToRunTimeSelectionTable
+    (
+        functionObject,
+        systemCallFunctionObject,
+        dictionary
+    );
+}
+
+// ************************************************************************* //
diff --git a/src/postProcessing/systemCall/systemCallFunctionObject.H b/src/postProcessing/systemCall/systemCallFunctionObject.H
new file mode 100644
index 00000000000..6f8b6ba6353
--- /dev/null
+++ b/src/postProcessing/systemCall/systemCallFunctionObject.H
@@ -0,0 +1,55 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM; if not, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Typedef
+    Foam::systemCallFunctionObject
+
+Description
+    FunctionObject wrapper around systemCall to allow them to be created via
+    the functions list within controlDict.
+
+SourceFiles
+    systemCallFunctionObject.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef systemCallFunctionObject_H
+#define systemCallFunctionObject_H
+
+#include "systemCall.H"
+#include "OutputFilterFunctionObject.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef OutputFilterFunctionObject<systemCall>
+        systemCallFunctionObject;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
-- 
GitLab