From 65bb236e4f5acca2900f6f5e39c91405e060a591 Mon Sep 17 00:00:00 2001
From: graham <graham.macpherson@strath.ac.uk>
Date: Wed, 4 Mar 2009 18:00:57 +0000
Subject: [PATCH] Added new fields to solver and basic calculation of momentum
 and energy change on wall impact.  Need to add references to new fields to
 DsmcCloud and constructors, all references are to be non-const as the field
 calculation will occur inside the DsmcCloud.

---
 .../solvers/dsmc/dsmcFoam/createFields.H      | 109 +++++++++++++-----
 .../parcels/Templates/DsmcParcel/DsmcParcel.C |  12 ++
 2 files changed, 90 insertions(+), 31 deletions(-)

diff --git a/applications/solvers/dsmc/dsmcFoam/createFields.H b/applications/solvers/dsmc/dsmcFoam/createFields.H
index 5f586665bba..5e5751bddfc 100644
--- a/applications/solvers/dsmc/dsmcFoam/createFields.H
+++ b/applications/solvers/dsmc/dsmcFoam/createFields.H
@@ -1,33 +1,5 @@
 
-    // volScalarField rhoN
-    // (
-    //     IOobject
-    //     (
-    //         "rhoN",
-    //         runTime.timeName(),
-    //         mesh,
-    //         IOobject::MUST_READ,
-    //         IOobject::AUTO_WRITE
-    //     ),
-    //     mesh
-    // );
-
-
-    // volScalarField rhoM
-    // (
-    //     IOobject
-    //     (
-    //         "rhoM",
-    //         runTime.timeName(),
-    //         mesh,
-    //         IOobject::MUST_READ,
-    //         IOobject::AUTO_WRITE
-    //     ),
-    //     mesh
-    // );
-
-
-    Info<< "\nReading field U\n" << endl;
+    Info<< nl << "Reading field U" << endl;
     volVectorField U
     (
         IOobject
@@ -41,7 +13,7 @@
         mesh
     );
 
-    Info<< "\nReading field T\n" << endl;
+    Info<< nl << "Reading field T" << endl;
     volScalarField T
     (
         IOobject
@@ -55,6 +27,81 @@
         mesh
     );
 
+    Info<< nl << "Reading field rhoN" << endl;
+    volScalarField rhoN
+    (
+        IOobject
+        (
+            "rhoN",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+    Info<< nl << "Reading field rhoM" << endl;
+    volScalarField rhoM
+    (
+        IOobject
+        (
+            "rhoM",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+    Info<< nl << "Reading field rhoNdsmc (dsmc particle density)" << endl;
+    volScalarField dsmcRhoN
+    (
+        IOobject
+        (
+            "dsmcRhoN",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+    Info<< nl
+        << "Fields required to record solid surface forces and heat flux:"
+        << endl;
+
+    Info<< nl << "Reading field q (surface heat transfer)" << endl;
+    volScalarField q
+    (
+        IOobject
+        (
+            "q",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
+    Info<< nl << "Reading field fD (surface force density" << endl;
+    volVectorField fD
+    (
+        IOobject
+        (
+            "fD",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        mesh
+    );
+
     Info<< "Constructing dsmcCloud " << endl;
 
-    dsmcCloud dsmc("dsmc", T, U);
+dsmcCloud dsmc("dsmc", T, U);
+    //, rhoN, rhoM, dsmcRhoN, q, f);
diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C
index 1b38143c90f..babf4be2920 100644
--- a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C
+++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C
@@ -109,6 +109,10 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch
 {
     const constantProperties& constProps(td.cloud().constProps(typeId_));
 
+    scalar preInteractionEnergy = 0.5*constProps.mass()*(U_ & U_) + Ei_;
+
+    vector preInteractionMomentum = constProps.mass()*U_;
+
     td.cloud().wallInteraction().correct
     (
         wpp,
@@ -116,6 +120,14 @@ void Foam::DsmcParcel<ParcelType>::hitWallPatch
         U_,
         constProps.mass()
     );
+
+    scalar postInteractionEnergy = 0.5*constProps.mass()*(U_ & U_) + Ei_;
+
+    vector postInteractionMomentum = constProps.mass()*U_;
+
+    scalar deltaEnergy =preInteractionEnergy - postInteractionEnergy;
+
+    vector deltaMomentum = preInteractionMomentum - postInteractionMomentum;
 }
 
 
-- 
GitLab