From 28868f8d4d7ca4bc38e2fa4b8efa79ef41ba7168 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Thu, 18 May 2017 14:44:52 +0100 Subject: [PATCH] ENH: Updated reading of dimensioned types from transportProperties dictionary to avoid the need to provide the dimension set --- .../basic/laplacianFoam/createFields.H | 58 ++++++------- .../basic/scalarTransportFoam/createFields.H | 84 ++++++++++--------- .../readThermodynamicProperties.H | 62 +++++++------- .../adjointShapeOptimizationFoam.C | 2 - .../createFields.H | 15 +++- 5 files changed, 117 insertions(+), 104 deletions(-) diff --git a/applications/solvers/basic/laplacianFoam/createFields.H b/applications/solvers/basic/laplacianFoam/createFields.H index 616afe1a88..7056505e99 100644 --- a/applications/solvers/basic/laplacianFoam/createFields.H +++ b/applications/solvers/basic/laplacianFoam/createFields.H @@ -1,37 +1,39 @@ - Info<< "Reading field T\n" << endl; +Info<< "Reading field T\n" << endl; - volScalarField T +volScalarField T +( + IOobject ( - IOobject - ( - "T", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); + "T", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); - Info<< "Reading transportProperties\n" << endl; +Info<< "Reading transportProperties\n" << endl; - IOdictionary transportProperties +IOdictionary transportProperties +( + IOobject ( - IOobject - ( - "transportProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) +); - Info<< "Reading diffusivity DT\n" << endl; +Info<< "Reading diffusivity DT\n" << endl; - dimensionedScalar DT - ( - transportProperties.lookup("DT") - ); +dimensionedScalar DT +( + "DT", + dimArea/dimTime, + transportProperties +); diff --git a/applications/solvers/basic/scalarTransportFoam/createFields.H b/applications/solvers/basic/scalarTransportFoam/createFields.H index c6ba83629b..54dcb3fca5 100644 --- a/applications/solvers/basic/scalarTransportFoam/createFields.H +++ b/applications/solvers/basic/scalarTransportFoam/createFields.H @@ -1,55 +1,57 @@ - Info<< "Reading field T\n" << endl; +Info<< "Reading field T\n" << endl; - volScalarField T +volScalarField T +( + IOobject ( - IOobject - ( - "T", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); + "T", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); - Info<< "Reading field U\n" << endl; +Info<< "Reading field U\n" << endl; - volVectorField U +volVectorField U +( + IOobject ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); - Info<< "Reading transportProperties\n" << endl; +Info<< "Reading transportProperties\n" << endl; - IOdictionary transportProperties +IOdictionary transportProperties +( + IOobject ( - IOobject - ( - "transportProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) +); - Info<< "Reading diffusivity DT\n" << endl; +Info<< "Reading diffusivity DT\n" << endl; - dimensionedScalar DT - ( - transportProperties.lookup("DT") - ); +dimensionedScalar DT +( + "DT", + dimArea/dimTime, + transportProperties +); - #include "createPhi.H" +#include "createPhi.H" diff --git a/applications/solvers/compressible/sonicFoam/sonicLiquidFoam/readThermodynamicProperties.H b/applications/solvers/compressible/sonicFoam/sonicLiquidFoam/readThermodynamicProperties.H index 82ebe7ae30..8f420d91c6 100644 --- a/applications/solvers/compressible/sonicFoam/sonicLiquidFoam/readThermodynamicProperties.H +++ b/applications/solvers/compressible/sonicFoam/sonicLiquidFoam/readThermodynamicProperties.H @@ -1,37 +1,37 @@ - Info<< "Reading thermodynamicProperties\n" << endl; +Info<< "Reading thermodynamicProperties\n" << endl; - IOdictionary thermodynamicProperties +IOdictionary thermodynamicProperties +( + IOobject ( - IOobject - ( - "thermodynamicProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); + "thermodynamicProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) +); - dimensionedScalar rho0 - ( - "rho0", - dimDensity, - thermodynamicProperties - ); +dimensionedScalar rho0 +( + "rho0", + dimDensity, + thermodynamicProperties +); - dimensionedScalar p0 - ( - "p0", - dimPressure, - thermodynamicProperties - ); +dimensionedScalar p0 +( + "p0", + dimPressure, + thermodynamicProperties +); - dimensionedScalar psi - ( - "psi", - dimCompressibility, - thermodynamicProperties - ); +dimensionedScalar psi +( + "psi", + dimCompressibility, + thermodynamicProperties +); - // Density offset, i.e. the constant part of the density - dimensionedScalar rhoO("rhoO", rho0 - psi*p0); +// Density offset, i.e. the constant part of the density +dimensionedScalar rhoO("rhoO", rho0 - psi*p0); diff --git a/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C b/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C index ccbe3b8141..7296a8cb37 100644 --- a/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C +++ b/applications/solvers/incompressible/adjointShapeOptimizationFoam/adjointShapeOptimizationFoam.C @@ -93,8 +93,6 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; - laminarTransport.lookup("lambda") >> lambda; - //alpha += // mesh.relaxationFactor("alpha") // *(lambda*max(Ua & U, zeroSensitivity) - alpha); diff --git a/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H b/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H index 93da72123d..bba352e71c 100644 --- a/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H +++ b/applications/solvers/incompressible/adjointShapeOptimizationFoam/createFields.H @@ -89,8 +89,19 @@ autoPtr turbulence dimensionedScalar zeroSensitivity("0", dimVelocity*dimVelocity, 0.0); dimensionedScalar zeroAlpha("0", dimless/dimTime, 0.0); -dimensionedScalar lambda(laminarTransport.lookup("lambda")); -dimensionedScalar alphaMax(laminarTransport.lookup("alphaMax")); +dimensionedScalar lambda +( + "lambda", + dimTime/sqr(dimLength), + laminarTransport +); + +dimensionedScalar alphaMax +( + "alphaMax", + dimless/dimTime, + laminarTransport +); const labelList& inletCells = mesh.boundary()["inlet"].faceCells(); //const labelList& outletCells = mesh.boundary()["outlet"].faceCells();