Solid models update: clean-up

This commit is contained in:
Hrvoje Jasak 2014-02-23 10:54:20 +00:00
parent 3810b29f37
commit bb03a935fa
11 changed files with 224 additions and 211 deletions

View file

@ -16,7 +16,6 @@
( (
DU.internalField() DU.internalField()
- DU.prevIter().internalField() - DU.prevIter().internalField()
) )/magDU
/magDU
); );
} }

View file

@ -24,7 +24,7 @@
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
mesh, mesh,
dimensionedVector("zero", dimLength, vector::zero) dimensionedVector("zero", dimLength, vector::zero)
); );
volSymmTensorField DEpsilon volSymmTensorField DEpsilon

View file

@ -79,7 +79,7 @@ int main(int argc, char *argv[])
# include "calculateDivDSigmaExp.H" # include "calculateDivDSigmaExp.H"
//- linear momentum equation // Linear momentum equation
fvVectorMatrix DUEqn fvVectorMatrix DUEqn
( (
fvm::d2dt2(rho, DU) fvm::d2dt2(rho, DU)
@ -127,7 +127,8 @@ int main(int argc, char *argv[])
&& ++iCorr < nCorr && ++iCorr < nCorr
); );
Info<< nl << "Time " << runTime.value() << ", Solving for " << DU.name() Info<< nl << "Time " << runTime.value()
<< ", Solving for " << DU.name()
<< ", Initial residual = " << initialResidual << ", Initial residual = " << initialResidual
<< ", Final residual = " << solverPerf.initialResidual() << ", Final residual = " << solverPerf.initialResidual()
<< ", Relative residual = " << relativeResidual << ", Relative residual = " << relativeResidual

View file

@ -1,9 +1,22 @@
//- how explicit component of sigma is to be calculated const dictionary& stressControl =
word divDSigmaExpMethod(mesh.solutionDict().subDict("solidMechanics").lookup("divSigmaExp")); mesh.solutionDict().subDict("solidMechanics");
Info << "Selecting divSigmaExp calculation method " << divDSigmaExpMethod << endl;
if(divDSigmaExpMethod != "standard" && divDSigmaExpMethod != "surface" && divDSigmaExpMethod != "decompose" && divDSigmaExpMethod != "laplacian") // Read how explicit component of sigma is to be calculated
{ word divDSigmaExpMethod(stressControl.lookup("divSigmaExp"));
FatalError << "divSigmaExp method " << divDSigmaExpMethod << " not found!" << nl
<< "valid methods are:\nstandard\nsurface\ndecompose\nlaplacian" Info<< "Selecting divSigmaExp calculation method: "
<< exit(FatalError); << divDSigmaExpMethod << endl;
}
if
(
divDSigmaExpMethod != "standard"
&& divDSigmaExpMethod != "surface"
&& divDSigmaExpMethod != "decompose"
&& divDSigmaExpMethod != "laplacian"
)
{
FatalErrorIn(args.executable())
<< "divSigmaExp method " << divDSigmaExpMethod << " not found! "
<< "valid methods are:\nstandard\nsurface\ndecompose\nlaplacian"
<< exit(FatalError);
}

View file

@ -1,36 +1,34 @@
if (runTime.outputTime()) if (runTime.outputTime())
{ {
volScalarField epsilonEq volScalarField epsilonEq
( (
IOobject IOobject
( (
"epsilonEq", "epsilonEq",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
sqrt((2.0/3.0)*magSqr(dev(epsilon))) sqrt((2.0/3.0)*magSqr(dev(epsilon)))
); );
Info<< "Max epsilonEq = " << max(epsilonEq).value() Info<< "Max epsilonEq = " << max(epsilonEq).value() << endl;
<< endl;
volScalarField sigmaEq volScalarField sigmaEq
( (
IOobject IOobject
( (
"sigmaEq", "sigmaEq",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
sqrt((3.0/2.0)*magSqr(dev(sigma))) sqrt((3.0/2.0)*magSqr(dev(sigma)))
); );
Info<< "Max sigmaEq = " << max(sigmaEq).value() Info<< "Max sigmaEq = " << max(sigmaEq).value() << endl;
<< endl;
runTime.write(); runTime.write();
} }

View file

@ -25,11 +25,11 @@
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
mesh, mesh,
dimensionedSymmTensor("zero", dimless, symmTensor::zero) dimensionedSymmTensor("zero", dimless, symmTensor::zero)
); );
//- second Piola-Kirchhoff stress tensor //- Second Piola-Kirchhoff stress tensor
volSymmTensorField sigma volSymmTensorField sigma
( (
IOobject IOobject

View file

@ -44,21 +44,21 @@ Author
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
# include "createMesh.H" # include "createMesh.H"
# include "createFields.H" # include "createFields.H"
# include "createSolidInterfaceNonLin.H" # include "createSolidInterfaceNonLin.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl; Info<< "\nStarting time loop\n" << endl;
while(runTime.loop()) while(runTime.loop())
{ {
Info<< "Time: " << runTime.timeName() << nl << endl; Info<< "Time: " << runTime.timeName() << nl << endl;
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
scalar initialResidual = 0; scalar initialResidual = 0;
@ -70,36 +70,40 @@ int main(int argc, char *argv[])
{ {
U.storePrevIter(); U.storePrevIter();
surfaceTensorField shearGradU = surfaceTensorField shearGradU
((I - n*n)&fvc::interpolate(gradU)); (
"shearGradU",
(I - sqr(n)) & fvc::interpolate(gradU)
);
fvVectorMatrix UEqn fvVectorMatrix UEqn
(
fvm::d2dt2(rho, U)
==
fvm::laplacian(2*muf + lambdaf, U, "laplacian(DU,U)")
// + fvc::div
// (
// -(mu + lambda)*gradU
// + mu*gradU.T()
// + mu*(gradU & gradU.T())
// + lambda*tr(gradU)*I
// + 0.5*lambda*tr(gradU & gradU.T())*I
// + (sigma & gradU),
// "div(sigma)"
// )
+ fvc::div
( (
fvm::d2dt2(rho, U) mesh.magSf()*
== (
fvm::laplacian(2*muf + lambdaf, U, "laplacian(DU,U)") - (muf + lambdaf)*(fvc::snGrad(U) & (I - n*n))
// + fvc::div( + lambdaf*tr(shearGradU & (I - n*n))*n
// -( (mu + lambda) * gradU ) + muf*(shearGradU & n)
// + ( mu * gradU.T() ) + muf*(n & fvc::interpolate(gradU & gradU.T()))
// + ( mu * (gradU & gradU.T()) ) + 0.5*lambdaf*(n*tr(fvc::interpolate(gradU & gradU.T())))
// + ( lambda * tr(gradU) * I ) + (n & fvc::interpolate(sigma & gradU))
// + ( 0.5 * lambda * tr(gradU & gradU.T()) * I ) )
// + ( sigma & gradU ), )
// "div(sigma)" );
// )
+ fvc::div(
mesh.magSf()
*(
- (muf + lambdaf)*(fvc::snGrad(U)&(I - n*n))
+ lambdaf*tr(shearGradU&(I - n*n))*n
+ muf*(shearGradU&n)
+ muf * (n & fvc::interpolate(gradU & gradU.T()))
+ 0.5*lambdaf
*(n * tr(fvc::interpolate(gradU & gradU.T())))
+ (n & fvc::interpolate( sigma & gradU ))
)
)
);
if (solidInterfaceCorr) if (solidInterfaceCorr)
{ {
@ -153,9 +157,9 @@ int main(int argc, char *argv[])
<< " s\n\n" << endl; << " s\n\n" << endl;
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;
return(0); return(0);
} }

View file

@ -1,15 +1,16 @@
if(moveMeshMethod == "inverseDistance") if(moveMeshMethod == "inverseDistance")
{ {
# include "moveMeshInverseDistance.H" # include "moveMeshInverseDistance.H"
} }
else if(moveMeshMethod == "leastSquares") else if(moveMeshMethod == "leastSquares")
{ {
# include "moveMeshLeastSquares.H" # include "moveMeshLeastSquares.H"
} }
else else
{ {
FatalError << "move mesh method " << moveMeshMethod << " not recognised" << nl FatalErrorIn(args.executable())
<< "move mesh method " << moveMeshMethod << " not recognised" << nl
<< "available methods are:" << nl << "available methods are:" << nl
<< "inverseDistance" << nl << "inverseDistance" << nl
<< "leastSquares" << exit(FatalError); << "leastSquares" << exit(FatalError);
} }

View file

@ -1,4 +1,4 @@
// aitken acceleration // aitken acceleration
aitkenDelta.storePrevIter(); aitkenDelta.storePrevIter();
@ -7,26 +7,26 @@ aitkenDelta = (U - U.prevIter()) / aitkenInitialRes;
// update relaxation factor // update relaxation factor
if(iCorr == 0) if(iCorr == 0)
{ {
aitkenTheta = 0.1; aitkenTheta = 0.1;
} }
else else
{ {
vectorField b = aitkenDelta.internalField() - aitkenDelta.prevIter().internalField(); vectorField b = aitkenDelta.internalField()
// scalar sumMagB = gSum(mag(b)); - aitkenDelta.prevIter().internalField();
scalar sumMagB = gSum(magSqr(b));
if(sumMagB < SMALL) scalar sumMagB = gSum(magSqr(b));
{ if(sumMagB < SMALL)
// Warning << "Aitken under-relaxation: denominator less then SMALL" {
// << endl; // Warning << "Aitken under-relaxation: denominator less then SMALL"
sumMagB += SMALL; // << endl;
} sumMagB += SMALL;
}
aitkenTheta = -aitkenTheta*
gSum(aitkenDelta.prevIter().internalField() & b) aitkenTheta = -aitkenTheta*
/ gSum(aitkenDelta.prevIter().internalField() & b)/
sumMagB; sumMagB;
} }
// correction to the latest U // correction to the latest U
U += aitkenTheta*aitkenDelta*aitkenInitialRes; U += aitkenTheta*aitkenDelta*aitkenInitialRes;

View file

@ -12,21 +12,20 @@
mesh mesh
); );
// volTensorField gradU = fvc::grad(U);
volTensorField gradU volTensorField gradU
( (
IOobject IOobject
( (
"grad(U)", "grad(U)",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh,
dimensionedTensor("zero", dimless, tensor::zero) dimensionedTensor("zero", dimless, tensor::zero)
); );
//surfaceVectorField snGradU = fvc::snGrad(U);
surfaceVectorField snGradU surfaceVectorField snGradU
( (
IOobject IOobject
@ -38,7 +37,7 @@
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh,
dimensionedVector("zero", dimless, vector::zero) dimensionedVector("zero", dimless, vector::zero)
); );
volVectorField V volVectorField V
@ -85,19 +84,19 @@
dimensionedSymmTensor("zero", dimForce/dimArea, symmTensor::zero) dimensionedSymmTensor("zero", dimForce/dimArea, symmTensor::zero)
); );
volVectorField divSigmaExp volVectorField divSigmaExp
( (
IOobject IOobject
( (
"divSigmaExp", "divSigmaExp",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh,
dimensionedVector("zero", dimForce/dimVolume, vector::zero) dimensionedVector("zero", dimForce/dimVolume, vector::zero)
); );
constitutiveModel rheology(sigma, U); constitutiveModel rheology(sigma, U);
@ -127,18 +126,20 @@
// for aitken relaxation // for aitken relaxation
volVectorField aitkenDelta volVectorField aitkenDelta
( (
IOobject IOobject
( (
"aitkenDelta", "aitkenDelta",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh,
dimensionedVector("zero", dimLength, vector::zero) dimensionedVector("zero", dimLength, vector::zero)
); );
// aitken relaxation factor // aitken relaxation factor
scalar aitkenInitialRes = 1.0; scalar aitkenInitialRes = 1.0;
scalar aitkenTheta = 0.1; scalar aitkenTheta = 0.1;

View file

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
Info<< "\nStarting time loop\n" << endl; Info<< "\nStarting time loop\n" << endl;
while(runTime.loop()) while(runTime.loop())
{ {
Info<< "Time: " << runTime.timeName() << nl << endl; Info<< "Time: " << runTime.timeName() << nl << endl;
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
@ -74,84 +74,80 @@ int main(int argc, char *argv[])
lduMatrix::debug = 0; lduMatrix::debug = 0;
if (predictor) if (predictor)
{ {
Info << "\nPredicting U, gradU and snGradU based on V," Info<< "\nPredicting U, gradU and snGradU based on V,"
<< "gradV and snGradV\n" << endl; << "gradV and snGradV\n" << endl;
U += V*runTime.deltaT(); U += V*runTime.deltaT();
gradU += gradV*runTime.deltaT(); gradU += gradV*runTime.deltaT();
snGradU += snGradV*runTime.deltaT(); snGradU += snGradV*runTime.deltaT();
} }
do do
{ {
U.storePrevIter(); U.storePrevIter();
# include "calculateDivSigmaExp.H" # include "calculateDivSigmaExp.H"
// linear momentum equation // linear momentum equation
fvVectorMatrix UEqn fvVectorMatrix UEqn
( (
rho*fvm::d2dt2(U) rho*fvm::d2dt2(U)
== ==
fvm::laplacian(2*muf + lambdaf, U, "laplacian(DU,U)") fvm::laplacian(2*muf + lambdaf, U, "laplacian(DU,U)")
+ divSigmaExp + divSigmaExp
); );
if (solidInterfaceCorr) if (solidInterfaceCorr)
{ {
solidInterfacePtr->correct(UEqn); solidInterfacePtr->correct(UEqn);
} }
// if (relaxEqn) solverPerf = UEqn.solve();
// {
// UEqn.relax();
// }
solverPerf = UEqn.solve(); if (iCorr == 0)
{
initialResidual = solverPerf.initialResidual();
aitkenInitialRes = gMax(mag(U.internalField()));
}
if (iCorr == 0) if (aitkenRelax)
{ {
initialResidual = solverPerf.initialResidual();
aitkenInitialRes = gMax(mag(U.internalField()));
}
if (aitkenRelax)
{
# include "aitkenRelaxation.H" # include "aitkenRelaxation.H"
} }
else else
{ {
U.relax(); U.relax();
} }
gradU = fvc::grad(U); gradU = fvc::grad(U);
# include "calculateRelativeResidual.H" # include "calculateRelativeResidual.H"
if (iCorr % infoFrequency == 0) if (iCorr % infoFrequency == 0)
{ {
Info<< "\tTime " << runTime.value() Info<< "\tTime " << runTime.value()
<< ", Corrector " << iCorr << ", Corrector " << iCorr
<< ", Solving for " << U.name() << ", Solving for " << U.name()
<< " using " << solverPerf.solverName() << " using " << solverPerf.solverName()
<< ", res = " << solverPerf.initialResidual() << ", res = " << solverPerf.initialResidual()
<< ", rel res = " << relativeResidual; << ", rel res = " << relativeResidual;
if (aitkenRelax)
{ if (aitkenRelax)
Info<< ", aitken = " << aitkenTheta; {
} Info<< ", aitken = " << aitkenTheta;
Info<< ", inner iters = " << solverPerf.nIterations() << endl; }
} Info<< ", inner iters = " << solverPerf.nIterations() << endl;
} }
}
while while
( (
iCorr++ == 0 iCorr++ == 0
|| || (
(solverPerf.initialResidual() > convergenceTolerance solverPerf.initialResidual() > convergenceTolerance
//relativeResidual > convergenceTolerance //relativeResidual > convergenceTolerance
&& && iCorr < nCorr
iCorr < nCorr) )
); );
Info<< nl << "Time " << runTime.value() << ", Solving for " << U.name() Info<< nl << "Time " << runTime.value() << ", Solving for " << U.name()
<< ", Initial residual = " << initialResidual << ", Initial residual = " << initialResidual
@ -178,9 +174,9 @@ int main(int argc, char *argv[])
<< " s\n\n" << endl; << " s\n\n" << endl;
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;
return(0); return(0);
} }