diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H index c8e3ccba5611cd6eced4965bad4ffaf3e79e8041..762245abf48b4d5dc677a1f454500ebf429af400 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H @@ -13,71 +13,177 @@ ); const dictionary& rhoDict(mechanicalProperties.subDict("rho")); - word rhoType(rhoDict.lookup("rho")); + word rhoType(rhoDict.lookup("type")); - volScalarField rho + autoPtr<volScalarField> rhoPtr; + + IOobject rhoIO ( - IOobject - ( - "rho", - runTime.timeName(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "rho", + runTime.timeName(0), mesh, - dimensionedScalar("zero", dimMass/dimVolume, 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); - if (rhoType == "rhoInf") + if (rhoType == "uniform") { - rho = rhoDict.lookup("rhoInf"); + scalar rhoValue(readScalar(rhoDict.lookup("value"))); + + rhoPtr.reset + ( + new volScalarField + ( + rhoIO, + mesh, + dimensionedScalar + ( + "rho", + dimMass/dimVolume, + rhoValue + ), + zeroGradientFvPatchField<scalar>::typeName + ) + ); } + else if (rhoType == "field") + { + rhoIO.readOpt() = IOobject::MUST_READ; - volScalarField rhoE - ( - IOobject + rhoPtr.reset ( - "E", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + new volScalarField + ( + rhoIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readMechanicalProperties.H" + ) << "Valid type entries are uniform or field for rho" + << abort(FatalError); + } + + volScalarField& rho = rhoPtr(); + + const dictionary& EDict(mechanicalProperties.subDict("E")); + word EType(EDict.lookup("type")); + + autoPtr<volScalarField> EPtr; + + IOobject EIO + ( + "E", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimMass/dimLength/sqr(dimTime), 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); - const dictionary& EDict(mechanicalProperties.subDict("E")); - word EType(EDict.lookup("E")); - if (EType == "EInf") + if (EType == "uniform") { - rhoE = EDict.lookup("EInf"); + scalar rhoEValue(readScalar(EDict.lookup("value"))); + + EPtr.reset + ( + new volScalarField + ( + EIO, + mesh, + dimensionedScalar + ( + "Erho", + dimMass/dimLength/sqr(dimTime), + rhoEValue + ), + zeroGradientFvPatchField<scalar>::typeName + ) + ); + } + else if (EType == "field") + { + EIO.readOpt() = IOobject::MUST_READ; + + EPtr.reset + ( + new volScalarField + ( + EIO, + mesh + ) + ); } + else + { + FatalErrorIn + ( + "readMechanicalProperties.H" + ) << "Valid type entries are uniform or field for E" + << abort(FatalError); + } + + volScalarField& rhoE = EPtr(); + autoPtr<volScalarField> nuPtr; - volScalarField nu + IOobject nuIO ( - IOobject - ( - "nu", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "nu", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimless, 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); const dictionary& nuDict(mechanicalProperties.subDict("nu")); - word nuType(nuDict.lookup("nu")); + word nuType(nuDict.lookup("type")); - if (nuType == "nuInf") + if (nuType == "uniform") + { + scalar nuValue(readScalar(nuDict.lookup("value"))); + nuPtr.reset + ( + new volScalarField + ( + nuIO, + mesh, + dimensionedScalar + ( + "nu", + dimless, + nuValue + ), + zeroGradientFvPatchField<scalar>::typeName + ) + ); + } + else if(nuType == "field") { - nu = nuDict.lookup("nuInf"); + nuIO.readOpt() = IOobject::MUST_READ; + nuPtr.reset + ( + new volScalarField + ( + nuIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readMechanicalProperties.H" + ) << "Valid type entries are uniform or field for nu" + << abort(FatalError); } + volScalarField& nu = nuPtr(); + Info<< "Normalising E : E/rho\n" << endl; volScalarField E = rhoE/rho; diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H index 4d7bb43fc95905006ce40a9f6350601784f6b7ef..54ac7d6db901265c216b8922c99ff9b26683262d 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H @@ -46,70 +46,180 @@ volScalarField DT if (thermalStress) { - volScalarField C + + autoPtr<volScalarField> CPtr; + + IOobject CIO ( - IOobject - ( - "C", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "C", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimensionSet(0, 2, -2 , -1, 0), 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); const dictionary& CDict(thermalProperties.subDict("C")); - word CType(CDict.lookup("C")); - if (CType == "CInf") + word CType(CDict.lookup("type")); + if (CType == "uniform") + { + scalar CValue(readScalar(CDict.lookup("value"))); + + CPtr.reset + ( + new volScalarField + ( + CIO, + mesh, + dimensionedScalar + ( + "C", + dimensionSet(0, 2, -2 , -1, 0), + CValue + ), + zeroGradientFvPatchField<scalar>::typeName + ) + ); + + } + else if(CType == "field") + { + CIO.readOpt() = IOobject::MUST_READ; + + CPtr.reset + ( + new volScalarField + ( + CIO, + mesh + ) + ); + } + else { - C = CDict.lookup("CInf"); + FatalErrorIn + ( + "readThermalProperties.H" + ) << "Valid type entries are uniform or field for C" + << abort(FatalError); } + volScalarField& C = CPtr(); + + autoPtr<volScalarField> rhoKPtr; - volScalarField rhoK + IOobject rhoKIO ( - IOobject - ( - "k", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "k", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimensionSet(1, 1, -3 , -1, 0), 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); const dictionary& kDict(thermalProperties.subDict("k")); - word kType(kDict.lookup("k")); - if (kType == "kInf") + word kType(kDict.lookup("type")); + if (kType == "uniform") + { + scalar rhoKValue(readScalar(kDict.lookup("value"))); + + rhoKPtr.reset + ( + new volScalarField + ( + rhoKIO, + mesh, + dimensionedScalar + ( + "rhoK", + dimensionSet(1, 1, -3 , -1, 0), + rhoKValue + ), + zeroGradientFvPatchField<scalar>::typeName + ) + ); + + } + else if (kType == "field") { - rhoK = kDict.lookup("kInf"); + rhoKIO.readOpt() = IOobject::MUST_READ; + + rhoKPtr.reset + ( + new volScalarField + ( + rhoKIO, + mesh + ) + ); } + else + { + FatalErrorIn + ( + "readThermalProperties.H" + ) << "Valid type entries are uniform or field for K" + << abort(FatalError); + } + + volScalarField& rhoK = rhoKPtr(); + + autoPtr<volScalarField> alphaPtr; - volScalarField alpha + IOobject alphaIO ( - IOobject - ( - "alpha", - runTime.timeName(0), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), + "alpha", + runTime.timeName(0), mesh, - dimensionedScalar("0", dimensionSet(0, 0, 0 , -1, 0), 0.0) + IOobject::NO_READ, + IOobject::NO_WRITE ); + const dictionary& alphaDict(thermalProperties.subDict("alpha")); - word alphaType(alphaDict.lookup("alpha")); + word alphaType(alphaDict.lookup("type")); - if (alphaType == "alphaInf") + if (alphaType == "uniform") { - alpha = alphaDict.lookup("alphaInf"); + scalar alphaValue(readScalar(alphaDict.lookup("value"))); + alphaPtr.reset + ( + new volScalarField + ( + alphaIO, + mesh, + dimensionedScalar + ( + "alpha", + inv(dimTemperature), + alphaValue + ), + zeroGradientFvPatchField<scalar>::typeName + ) + ); } + else if (alphaType == "field") + { + alphaIO.readOpt() = IOobject::MUST_READ; + + alphaPtr.reset + ( + new volScalarField + ( + alphaIO, + mesh + ) + ); + } + else + { + FatalErrorIn + ( + "readThermalProperties.H" + ) << "Valid type entries are uniform or field for alpha" + << abort(FatalError); + } + + volScalarField& alpha = alphaPtr(); Info<< "Normalising k : k/rho\n" << endl; volScalarField k = rhoK/rho; diff --git a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C index 8aff8879e7200a53f5da730302196390ecbc2178..47a20059928bba9d2d8e92b613e35b56dded2009 100644 --- a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C +++ b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/tractionDisplacementCorrection/tractionDisplacementCorrectionFvPatchVectorField.C @@ -150,13 +150,18 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs() "mechanicalProperties" ); - dimensionedScalar rho(mechanicalProperties.lookup("rho")); - dimensionedScalar rhoE(mechanicalProperties.lookup("E")); - dimensionedScalar nu(mechanicalProperties.lookup("nu")); + const fvPatchField<scalar>& rho = + patch().lookupPatchField<volScalarField, scalar>("rho"); - dimensionedScalar E = rhoE/rho; - dimensionedScalar mu = E/(2.0*(1.0 + nu)); - dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); + const fvPatchField<scalar>& rhoE = + patch().lookupPatchField<volScalarField, scalar>("E"); + + const fvPatchField<scalar>& nu = + patch().lookupPatchField<volScalarField, scalar>("nu"); + + scalarField E = rhoE/rho; + scalarField mu = E/(2.0*(1.0 + nu)); + scalarField lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); Switch planeStress(mechanicalProperties.lookup("planeStress")); @@ -175,8 +180,8 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs() gradient() = ( - (traction_ + pressure_*n)/rho.value() - (n & (sigmaD + sigmaExp)) - )/(2.0*mu + lambda).value(); + (traction_ + pressure_*n)/rho - (n & (sigmaD + sigmaExp)) + )/(2.0*mu + lambda); fixedGradientFvPatchVectorField::updateCoeffs(); } diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties index c92d02a0f7d43d03d8a7a03776cb74b317baaa3a..e12a69e08dfce9f56d9ef72a20feb7ef5d8f434f 100644 --- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties +++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | +| \\ / O peration | Version: 2.0.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -17,20 +17,20 @@ FoamFile rho { - rho rhoInf; - rhoInf rhoInf [ 1 -3 0 0 0 0 0 ] 7854; + type uniform; + value 7854; } nu { - nu nuInf; - nuInf nuInf [ 0 0 0 0 0 0 0 ] 0.3; + type uniform; + value 0.3; } E { - E EInf; - EInf EInf [ 1 -1 -2 0 0 0 0 ] 2e+11; + type uniform; + value 2e+11; } planeStress yes; diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties index f68549dbba9a3c552ce22a71ee8fb3336c4fedbe..e5e8e1e21d65515f1761648ef8a888c3e552326c 100644 --- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties +++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | +| \\ / O peration | Version: 2.0.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -17,20 +17,20 @@ FoamFile C { - C CInf; - CInf CInf [ 0 2 -2 -1 0 0 0 ] 434; + type uniform; + value 434; } k { - k kInf; - kInf kInf [ 1 1 -3 -1 0 0 0 ] 60.5; + type uniform; + value 60.5; } alpha { - alpha alphaInf; - alphaInf alphaInf [ 0 0 0 -1 0 0 0 ] 1.1e-05; + type uniform; + value 1.1e-05; } thermalStress no; diff --git a/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/mechanicalProperties b/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/mechanicalProperties index f14ecc2556972ac31ca79e56cdb31cd8ec05a853..8e28bddeb6223977f258e31f1050c4cc1db6ca7d 100644 --- a/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/mechanicalProperties +++ b/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/mechanicalProperties @@ -15,13 +15,24 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -rho rho [ 1 -3 0 0 0 0 0 ] 7854; +rho +{ + type uniform; + value 7854; +} -E E [ 1 -1 -2 0 0 0 0 ] 2e+11; +nu +{ + type uniform; + value 0.0; +} -nu nu [ 0 0 0 0 0 0 0 ] 0; +E +{ + type uniform; + value 2e+11; +} planeStress yes; - // ************************************************************************* // diff --git a/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/thermalProperties b/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/thermalProperties index 9d09fa79015d53d74ddd4f78ce3837f80eb55bc6..77f422aca4da98c5b92147a8330c7c8922fbd3f9 100644 --- a/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/thermalProperties +++ b/tutorials/stressAnalysis/solidEquilibriumDisplacementFoam/beamEndLoad/constant/thermalProperties @@ -15,11 +15,23 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -C C [ 0 2 -2 -1 0 0 0 ] 434; +C +{ + type uniform; + value 434; +} -k k [ 1 1 -3 -1 0 0 0 ] 60.5; +k +{ + type uniform; + value 60.5; +} -alpha alpha [ 0 0 0 -1 0 0 0 ] 1.1e-05; +alpha +{ + type uniform; + value 1.1e-05; +} thermalStress no;