From 8ebd4925956d52a738f858bb1703a9ea692b67cd Mon Sep 17 00:00:00 2001 From: Sergio Ferraris Date: Tue, 25 Oct 2011 17:40:30 +0100 Subject: [PATCH] ENH: Changing mechanical and thermal properties to volScalarFields --- .../readMechanicalProperties.H | 80 ++++++++-- .../readThermalProperties.H | 148 +++++++++++++----- .../tractionDisplacementFvPatchVectorField.C | 30 ++-- .../plateHole/constant/mechanicalProperties | 18 ++- .../plateHole/constant/thermalProperties | 18 ++- .../plateHole/system/fvSchemes | 5 + 6 files changed, 234 insertions(+), 65 deletions(-) diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H index 9f256bd689..c8e3ccba56 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readMechanicalProperties.H @@ -12,18 +12,80 @@ ) ); - dimensionedScalar rho(mechanicalProperties.lookup("rho")); - dimensionedScalar rhoE(mechanicalProperties.lookup("E")); - dimensionedScalar nu(mechanicalProperties.lookup("nu")); + const dictionary& rhoDict(mechanicalProperties.subDict("rho")); + word rhoType(rhoDict.lookup("rho")); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimMass/dimVolume, 0.0) + ); + + if (rhoType == "rhoInf") + { + rho = rhoDict.lookup("rhoInf"); + } + + volScalarField rhoE + ( + IOobject + ( + "E", + runTime.timeName(0), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("0", dimMass/dimLength/sqr(dimTime), 0.0) + ); + + const dictionary& EDict(mechanicalProperties.subDict("E")); + word EType(EDict.lookup("E")); + if (EType == "EInf") + { + rhoE = EDict.lookup("EInf"); + } + + + volScalarField nu + ( + IOobject + ( + "nu", + runTime.timeName(0), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("0", dimless, 0.0) + ); + + const dictionary& nuDict(mechanicalProperties.subDict("nu")); + word nuType(nuDict.lookup("nu")); + + if (nuType == "nuInf") + { + nu = nuDict.lookup("nuInf"); + } Info<< "Normalising E : E/rho\n" << endl; - dimensionedScalar E = rhoE/rho; + volScalarField E = rhoE/rho; Info<< "Calculating Lame's coefficients\n" << endl; - dimensionedScalar mu = E/(2.0*(1.0 + nu)); - dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); - dimensionedScalar threeK = E/(1.0 - 2.0*nu); + volScalarField mu = E/(2.0*(1.0 + nu)); + volScalarField lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); + volScalarField threeK = E/(1.0 - 2.0*nu); Switch planeStress(mechanicalProperties.lookup("planeStress")); @@ -38,7 +100,3 @@ { Info<< "Plane Strain\n" << endl; } - - Info<< "mu = " << mu.value() << " Pa/rho\n"; - Info<< "lambda = " << lambda.value() << " Pa/rho\n"; - Info<< "threeK = " << threeK.value() << " Pa/rho\n"; diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H index 12e10a607b..4d7bb43fc9 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readThermalProperties.H @@ -1,46 +1,122 @@ - Info<< "Reading thermal properties\n" << endl; +Info<< "Reading thermal properties\n" << endl; - IOdictionary thermalProperties +IOdictionary thermalProperties +( + IOobject + ( + "thermalProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) +); + +Switch thermalStress(thermalProperties.lookup("thermalStress")); + +volScalarField threeKalpha +( + IOobject + ( + "threeKalpha", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("0", dimensionSet(0, 2, -2 , -1, 0), 0.0) +); + + +volScalarField DT +( + IOobject + ( + "DT", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("0", dimensionSet(0, 2, -1 , 0, 0), 0.0) +); + + +if (thermalStress) +{ + volScalarField C ( IOobject ( - "thermalProperties", - runTime.constant(), + "C", + runTime.timeName(0), mesh, - IOobject::MUST_READ_IF_MODIFIED, + IOobject::READ_IF_PRESENT, IOobject::NO_WRITE - ) + ), + mesh, + dimensionedScalar("0", dimensionSet(0, 2, -2 , -1, 0), 0.0) ); - Switch thermalStress(thermalProperties.lookup("thermalStress")); - - dimensionedScalar threeKalpha - ( - "threeKalpha", - dimensionSet(0, 2, -2 , -1, 0), - 0 - ); - - dimensionedScalar DT - ( - "DT", - dimensionSet(0, 2, -1 , 0, 0), - 0 - ); - - if (thermalStress) + const dictionary& CDict(thermalProperties.subDict("C")); + word CType(CDict.lookup("C")); + if (CType == "CInf") { - dimensionedScalar C(thermalProperties.lookup("C")); - dimensionedScalar rhoK(thermalProperties.lookup("k")); - dimensionedScalar alpha(thermalProperties.lookup("alpha")); - - Info<< "Normalising k : k/rho\n" << endl; - dimensionedScalar k = rhoK/rho; - - Info<< "Calculating thermal coefficients\n" << endl; - - threeKalpha = threeK*alpha; - DT.value() = (k/C).value(); - - Info<< "threeKalpha = " << threeKalpha.value() << " Pa/rho\n"; + C = CDict.lookup("CInf"); } + + + volScalarField rhoK + ( + IOobject + ( + "k", + runTime.timeName(0), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("0", dimensionSet(1, 1, -3 , -1, 0), 0.0) + ); + + const dictionary& kDict(thermalProperties.subDict("k")); + word kType(kDict.lookup("k")); + if (kType == "kInf") + { + rhoK = kDict.lookup("kInf"); + } + + volScalarField alpha + ( + IOobject + ( + "alpha", + runTime.timeName(0), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("0", dimensionSet(0, 0, 0 , -1, 0), 0.0) + ); + + const dictionary& alphaDict(thermalProperties.subDict("alpha")); + word alphaType(alphaDict.lookup("alpha")); + + if (alphaType == "alphaInf") + { + alpha = alphaDict.lookup("alphaInf"); + } + + Info<< "Normalising k : k/rho\n" << endl; + volScalarField k = rhoK/rho; + + Info<< "Calculating thermal coefficients\n" << endl; + + threeKalpha = threeK*alpha; + DT = k/C; + +} diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C b/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C index 85f3c67b38..b24239c0f8 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C @@ -149,14 +149,20 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs() const dictionary& thermalProperties = db().lookupObject("thermalProperties"); - dimensionedScalar rho(mechanicalProperties.lookup("rho")); - dimensionedScalar rhoE(mechanicalProperties.lookup("E")); - dimensionedScalar nu(mechanicalProperties.lookup("nu")); - dimensionedScalar E = rhoE/rho; - dimensionedScalar mu = E/(2.0*(1.0 + nu)); - dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); - dimensionedScalar threeK = E/(1.0 - 2.0*nu); + const fvPatchField& rho = + patch().lookupPatchField("rho"); + + const fvPatchField& rhoE = + patch().lookupPatchField("E"); + + const fvPatchField& nu = + patch().lookupPatchField("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)); + scalarField threeK = E/(1.0 - 2.0*nu); Switch planeStress(mechanicalProperties.lookup("planeStress")); @@ -166,7 +172,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs() threeK = E/(1.0 - nu); } - scalar twoMuLambda = (2*mu + lambda).value(); + scalarField twoMuLambda = (2*mu + lambda); vectorField n(patch().nf()); @@ -175,7 +181,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs() gradient() = ( - (traction_ + pressure_*n)/rho.value() + (traction_ + pressure_*n)/rho + twoMuLambda*fvPatchField::snGrad() - (n & sigmaD) )/twoMuLambda; @@ -183,13 +189,13 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs() if (thermalStress) { - dimensionedScalar alpha(thermalProperties.lookup("alpha")); - dimensionedScalar threeKalpha = threeK*alpha; + const fvPatchField& threeKalpha= + patch().lookupPatchField("threeKalpha"); const fvPatchField& T = patch().lookupPatchField("T"); - gradient() += n*threeKalpha.value()*T/twoMuLambda; + gradient() += n*threeKalpha*T/twoMuLambda; } fixedGradientFvPatchVectorField::updateCoeffs(); diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties index 9ae921391c..c92d02a0f7 100644 --- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties +++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/mechanicalProperties @@ -15,11 +15,23 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -rho rho [ 1 -3 0 0 0 0 0 ] 7854; +rho +{ + rho rhoInf; + rhoInf rhoInf [ 1 -3 0 0 0 0 0 ] 7854; +} -nu nu [ 0 0 0 0 0 0 0 ] 0.3; +nu +{ + nu nuInf; + nuInf nuInf [ 0 0 0 0 0 0 0 ] 0.3; +} -E E [ 1 -1 -2 0 0 0 0 ] 2e+11; +E +{ + E EInf; + EInf EInf [ 1 -1 -2 0 0 0 0 ] 2e+11; +} planeStress yes; diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties index 9d09fa7901..f68549dbba 100644 --- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties +++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/constant/thermalProperties @@ -15,11 +15,23 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -C C [ 0 2 -2 -1 0 0 0 ] 434; +C +{ + C CInf; + CInf CInf [ 0 2 -2 -1 0 0 0 ] 434; +} -k k [ 1 1 -3 -1 0 0 0 ] 60.5; +k +{ + k kInf; + kInf kInf [ 1 1 -3 -1 0 0 0 ] 60.5; +} -alpha alpha [ 0 0 0 -1 0 0 0 ] 1.1e-05; +alpha +{ + alpha alphaInf; + alphaInf alphaInf [ 0 0 0 -1 0 0 0 ] 1.1e-05; +} thermalStress no; diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/system/fvSchemes b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/system/fvSchemes index 0f667a4132..a7c9b4c8d2 100644 --- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/system/fvSchemes +++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/system/fvSchemes @@ -20,6 +20,11 @@ d2dt2Schemes default steadyState; } +ddtSchemes +{ + default Euler; +} + gradSchemes { default leastSquares;