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/viscoElasticSolidFoam.C

147 lines
4.2 KiB
C
Raw Normal View History

2012-09-11 15:42:55 +00:00
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-6 H. Jasak All rights reserved
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Application
viscoElasticStressedFoam
Description
Transient/steady-state segregated finite-volume solver for small strain
visco elastic solid bodies.
Displacement increment field DU is solved for using a total Lagrangian
approach, also generating the strain tensor field epsilon and stress
tensor field sigma.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "rheologyModel.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
2012-09-11 15:42:55 +00:00
# include "createTime.H"
2012-09-11 15:42:55 +00:00
# include "createMesh.H"
2012-09-11 15:42:55 +00:00
# include "createFields.H"
2012-09-11 15:42:55 +00:00
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating displacement field\n" << endl;
2012-09-11 15:42:55 +00:00
lduMatrix::debug = 0;
scalar m = 0.5;
for (runTime++; !runTime.end(); runTime++)
2012-09-11 15:42:55 +00:00
{
Info<< "Time: " << runTime.timeName() << nl << endl;
# include "readStressedFoamControls.H"
2012-09-11 15:42:55 +00:00
volScalarField mu =
rheology.mu(m*runTime.deltaT().value());
volScalarField lambda =
rheology.lambda(m*runTime.deltaT().value());
Info << "mu = " << average(mu.internalField()) << endl;
Info << "lambda = " << average(lambda.internalField()) << endl;
int iCorr = 0;
lduMatrix::solverPerformance solverPerf;
scalar initialResidual = 0;
scalar residual = GREAT;
do
2012-09-11 15:42:55 +00:00
{
DU.storePrevIter();
fvVectorMatrix DUEqn
2012-09-11 15:42:55 +00:00
(
fvm::d2dt2(rho,DU)
==
fvm::laplacian(2*mu+lambda, DU, "laplacian(DDU,DU)")
+ fvc::div
(
mu*gradDU.T()
+ lambda*(I*tr(gradDU))
- (mu + lambda)*gradDU
+ DSigmaCorr,
"div(sigma)"
)
);
solverPerf = DUEqn.solve();
DU.relax();
if(iCorr == 0)
2012-09-11 15:42:55 +00:00
{
initialResidual = solverPerf.initialResidual();
2012-09-11 15:42:55 +00:00
}
gradDU = fvc::grad(DU);
# include "calculateDEpsilonDSigma.H"
2012-09-11 15:42:55 +00:00
}
while
2012-09-11 15:42:55 +00:00
(
solverPerf.initialResidual() > convergenceTolerance
&& ++iCorr < nCorr
);
Info << "Solving for " << DU.name() << " using "
<< solverPerf.solverName() << " solver"
<< ", Initial residual = " << initialResidual
<< ", Final residual = " << solverPerf.initialResidual()
<< ", No outer iterations " << iCorr
<< ", Relative error: " << residual << endl;
U += DU;
2012-09-11 15:42:55 +00:00
epsilon += DEpsilon;
# include "calculateSigmaDSigmaCorr.H"
2012-09-11 15:42:55 +00:00
# include "writeFields.H"
2012-09-11 15:42:55 +00:00
Info<< "ExecutionTime = "
<< runTime.elapsedCpuTime()
<< " s\n\n" << endl;
2012-09-11 15:42:55 +00:00
}
Info<< "End\n" << endl;
return(0);
2012-09-11 15:42:55 +00:00
}
// ************************************************************************* //