This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/applications/solvers/solidMechanics/viscoElasticSolidFoam/calcInitialState.H

89 lines
2.3 KiB
C
Raw Normal View History

{
Info<< "Time: " << runTime.timeName() << nl << endl;
# include "readSolidMechanicsControls.H"
volScalarField mu = rheology.mu(0);
volScalarField lambda = rheology.lambda(0);
Info << "mu = " << average(mu.internalField()) << endl;
Info << "lambda = " << average(lambda.internalField()) << endl;
int iCorr = 0;
lduMatrix::solverPerformance solverPerf;
scalar initialResidual = 0;
scalar err = GREAT;
do
{
DU.storePrevIter();
fvVectorMatrix DUEqn
(
fvm::laplacian(2*mu+lambda, DU, "laplacian(DDU,DU)")
+ fvc::div
(
mu*gradDU.T()
+ lambda*(I*tr(gradDU))
- (mu + lambda)*gradDU,
"div(sigma)"
)
);
solverPerf = DUEqn.solve();
DU.relax();
if(iCorr == 0)
{
initialResidual = solverPerf.initialResidual();
}
gradDU = fvc::grad(DU);
}
while
(
solverPerf.initialResidual() > convergenceTolerance
&& ++iCorr < nCorr
);
Info << "Solving for " << DU.name() << " using "
<< solverPerf.solverName() << " solver"
<< ", Initial residula = " << initialResidual
<< ", Final residual = " << solverPerf.initialResidual()
<< ", No outer iterations " << iCorr
<< ", Relative error: " << err << endl;
U += DU;
# include "calculateDSigma.H"
sigma += DSigma;
{
DSigmaCorr =
dimensionedSymmTensor
(
"zero",
dimForce/dimArea,
symmTensor::zero
);
scalar t = runTime.value();
scalar tNext = t + runTime.deltaT().value();
DSigmaCorr += 2.0*rheology.mu(tNext)*Depsilon
+ rheology.lambda(tNext)*(I*tr(Depsilon));
DSigmaCorr -= sigma;
}
# include "calculateStress.H"
# include "writeHistory.H"
Depsilon.write();
Info<< "ExecutionTime = "
<< runTime.elapsedCpuTime()
<< " s\n\n" << endl;
}