From 0901b9f36f7fa45a1370501eb39807d5aec3c04d Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Mon, 9 Dec 2013 09:41:36 +0000
Subject: [PATCH] ENH: region models - sub-models write to common output
 properties dictionary

---
 .../regionModel/regionModel/regionModel.C     | 24 ++++++++++++
 .../regionModel/regionModel/regionModel.H     |  9 +++++
 .../regionModel/regionModel/regionModelI.H    | 38 ++++++++++++++++++-
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C
index 5bf29514515..8068660057b 100644
--- a/src/regionModels/regionModel/regionModel/regionModel.C
+++ b/src/regionModels/regionModel/regionModel/regionModel.C
@@ -142,6 +142,27 @@ void Foam::regionModels::regionModel::initialise()
             << "Region model has no mapped boundary conditions - transfer "
             << "between regions will not be possible" << endl;
     }
+
+    if (!outputPropertiesPtr_.valid())
+    {
+        const fileName uniformPath(word("uniform")/"regionModels");
+
+        outputPropertiesPtr_.reset
+        (
+            new IOdictionary
+            (
+                IOobject
+                (
+                    regionName_ + "OutputProperties",
+                    time_.timeName(),
+                    uniformPath/regionName_,
+                    primaryMesh_,
+                    IOobject::READ_IF_PRESENT,
+                    IOobject::AUTO_WRITE
+                )
+            )
+        );
+    }
 }
 
 
@@ -389,6 +410,7 @@ Foam::regionModels::regionModel::regionModel
     modelName_("none"),
     regionMeshPtr_(NULL),
     coeffs_(dictionary::null),
+    outputPropertiesPtr_(NULL),
     primaryPatchIDs_(),
     intCoupledPatchIDs_(),
     regionName_("none"),
@@ -424,6 +446,7 @@ Foam::regionModels::regionModel::regionModel
     modelName_(modelName),
     regionMeshPtr_(NULL),
     coeffs_(subOrEmptyDict(modelName + "Coeffs")),
+    outputPropertiesPtr_(NULL),
     primaryPatchIDs_(),
     intCoupledPatchIDs_(),
     regionName_(lookup("regionName")),
@@ -471,6 +494,7 @@ Foam::regionModels::regionModel::regionModel
     modelName_(modelName),
     regionMeshPtr_(NULL),
     coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")),
+    outputPropertiesPtr_(NULL),
     primaryPatchIDs_(),
     intCoupledPatchIDs_(),
     regionName_(dict.lookup("regionName")),
diff --git a/src/regionModels/regionModel/regionModel/regionModel.H b/src/regionModels/regionModel/regionModel/regionModel.H
index 83afc6898be..d77916c70b2 100644
--- a/src/regionModels/regionModel/regionModel/regionModel.H
+++ b/src/regionModels/regionModel/regionModel/regionModel.H
@@ -105,6 +105,9 @@ protected:
         //- Model coefficients dictionary
         dictionary coeffs_;
 
+        //- Dictionary of output properties
+        autoPtr<IOdictionary> outputPropertiesPtr_;
+
 
         // Addressing
 
@@ -216,6 +219,12 @@ public:
             //- Return the solution dictionary
             inline const dictionary& solution() const;
 
+            //- Return const access to the output properties dictionary
+            inline const IOdictionary& outputProperties() const;
+
+            //- Return output properties dictionary
+            inline IOdictionary& outputProperties();
+
 
             // Addressing
 
diff --git a/src/regionModels/regionModel/regionModel/regionModelI.H b/src/regionModels/regionModel/regionModel/regionModelI.H
index 287fcc19202..95defc744ed 100644
--- a/src/regionModels/regionModel/regionModel/regionModelI.H
+++ b/src/regionModels/regionModel/regionModel/regionModelI.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
@@ -112,6 +112,42 @@ Foam::regionModels::regionModel::solution() const
 }
 
 
+inline const Foam::IOdictionary&
+Foam::regionModels::regionModel::outputProperties() const
+{
+    if (!outputPropertiesPtr_.valid())
+    {
+        FatalErrorIn
+        (
+            "inline const Foam::IOdictionary& "
+            "Foam::regionModels::regionModel::outputProperties() const"
+        )
+            << "outputProperties dictionary not available"
+            << abort(FatalError);
+    }
+
+    return outputPropertiesPtr_();
+}
+
+
+inline Foam::IOdictionary&
+Foam::regionModels::regionModel::outputProperties()
+{
+    if (!outputPropertiesPtr_.valid())
+    {
+        FatalErrorIn
+        (
+            "inline Foam::IOdictionary& "
+            "Foam::regionModels::regionModel::outputProperties()"
+        )
+            << "outputProperties dictionary not available"
+            << abort(FatalError);
+    }
+
+    return outputPropertiesPtr_();
+}
+
+
 inline bool Foam::regionModels::regionModel::isCoupledPatch
 (
     const label regionPatchI
-- 
GitLab