ENH: Changing mechanical and thermal properties to volScalarFields

This commit is contained in:
Sergio Ferraris 2011-10-25 17:40:30 +01:00
parent 72cc4cd7d8
commit 8ebd492595
6 changed files with 234 additions and 65 deletions

View File

@ -12,18 +12,80 @@
) )
); );
dimensionedScalar rho(mechanicalProperties.lookup("rho")); const dictionary& rhoDict(mechanicalProperties.subDict("rho"));
dimensionedScalar rhoE(mechanicalProperties.lookup("E")); word rhoType(rhoDict.lookup("rho"));
dimensionedScalar nu(mechanicalProperties.lookup("nu"));
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; Info<< "Normalising E : E/rho\n" << endl;
dimensionedScalar E = rhoE/rho; volScalarField E = rhoE/rho;
Info<< "Calculating Lame's coefficients\n" << endl; Info<< "Calculating Lame's coefficients\n" << endl;
dimensionedScalar mu = E/(2.0*(1.0 + nu)); volScalarField mu = E/(2.0*(1.0 + nu));
dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu)); volScalarField lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
dimensionedScalar threeK = E/(1.0 - 2.0*nu); volScalarField threeK = E/(1.0 - 2.0*nu);
Switch planeStress(mechanicalProperties.lookup("planeStress")); Switch planeStress(mechanicalProperties.lookup("planeStress"));
@ -38,7 +100,3 @@
{ {
Info<< "Plane Strain\n" << endl; 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";

View File

@ -14,33 +14,109 @@
Switch thermalStress(thermalProperties.lookup("thermalStress")); Switch thermalStress(thermalProperties.lookup("thermalStress"));
dimensionedScalar threeKalpha volScalarField threeKalpha
(
IOobject
( (
"threeKalpha", "threeKalpha",
dimensionSet(0, 2, -2 , -1, 0), runTime.timeName(),
0 mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimensionSet(0, 2, -2 , -1, 0), 0.0)
); );
dimensionedScalar DT
volScalarField DT
(
IOobject
( (
"DT", "DT",
dimensionSet(0, 2, -1 , 0, 0), runTime.timeName(),
0 mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimensionSet(0, 2, -1 , 0, 0), 0.0)
); );
if (thermalStress) if (thermalStress)
{ {
dimensionedScalar C(thermalProperties.lookup("C")); volScalarField C
dimensionedScalar rhoK(thermalProperties.lookup("k")); (
dimensionedScalar alpha(thermalProperties.lookup("alpha")); IOobject
(
"C",
runTime.timeName(0),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimensionSet(0, 2, -2 , -1, 0), 0.0)
);
const dictionary& CDict(thermalProperties.subDict("C"));
word CType(CDict.lookup("C"));
if (CType == "CInf")
{
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; Info<< "Normalising k : k/rho\n" << endl;
dimensionedScalar k = rhoK/rho; volScalarField k = rhoK/rho;
Info<< "Calculating thermal coefficients\n" << endl; Info<< "Calculating thermal coefficients\n" << endl;
threeKalpha = threeK*alpha; threeKalpha = threeK*alpha;
DT.value() = (k/C).value(); DT = k/C;
Info<< "threeKalpha = " << threeKalpha.value() << " Pa/rho\n";
} }

View File

@ -149,14 +149,20 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
const dictionary& thermalProperties = const dictionary& thermalProperties =
db().lookupObject<IOdictionary>("thermalProperties"); db().lookupObject<IOdictionary>("thermalProperties");
dimensionedScalar rho(mechanicalProperties.lookup("rho"));
dimensionedScalar rhoE(mechanicalProperties.lookup("E"));
dimensionedScalar nu(mechanicalProperties.lookup("nu"));
dimensionedScalar E = rhoE/rho; const fvPatchField<scalar>& rho =
dimensionedScalar mu = E/(2.0*(1.0 + nu)); patch().lookupPatchField<volScalarField, scalar>("rho");
dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
dimensionedScalar threeK = E/(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));
scalarField threeK = E/(1.0 - 2.0*nu);
Switch planeStress(mechanicalProperties.lookup("planeStress")); Switch planeStress(mechanicalProperties.lookup("planeStress"));
@ -166,7 +172,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
threeK = E/(1.0 - nu); threeK = E/(1.0 - nu);
} }
scalar twoMuLambda = (2*mu + lambda).value(); scalarField twoMuLambda = (2*mu + lambda);
vectorField n(patch().nf()); vectorField n(patch().nf());
@ -175,7 +181,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
gradient() = gradient() =
( (
(traction_ + pressure_*n)/rho.value() (traction_ + pressure_*n)/rho
+ twoMuLambda*fvPatchField<vector>::snGrad() - (n & sigmaD) + twoMuLambda*fvPatchField<vector>::snGrad() - (n & sigmaD)
)/twoMuLambda; )/twoMuLambda;
@ -183,13 +189,13 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
if (thermalStress) if (thermalStress)
{ {
dimensionedScalar alpha(thermalProperties.lookup("alpha")); const fvPatchField<scalar>& threeKalpha=
dimensionedScalar threeKalpha = threeK*alpha; patch().lookupPatchField<volScalarField, scalar>("threeKalpha");
const fvPatchField<scalar>& T = const fvPatchField<scalar>& T =
patch().lookupPatchField<volScalarField, scalar>("T"); patch().lookupPatchField<volScalarField, scalar>("T");
gradient() += n*threeKalpha.value()*T/twoMuLambda; gradient() += n*threeKalpha*T/twoMuLambda;
} }
fixedGradientFvPatchVectorField::updateCoeffs(); fixedGradientFvPatchVectorField::updateCoeffs();

View File

@ -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; planeStress yes;

View File

@ -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; thermalStress no;

View File

@ -20,6 +20,11 @@ d2dt2Schemes
default steadyState; default steadyState;
} }
ddtSchemes
{
default Euler;
}
gradSchemes gradSchemes
{ {
default leastSquares; default leastSquares;