Remove trailing whitespace systematically
[foam-extend-3.2.git] / applications / solvers / solidMechanics / elasticNonLinTLSolidFoam / elasticNonLinTLSolidFoam.C
blobc6479e3cd87a3a28257b719becdaa262a3229417
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     |
5     \\  /    A nd           | For copyright notice see file Copyright
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Application
25     elasticNonLinTLSolidFoam
27 Description
28     Finite volume structural solver employing a total strain total
29     Lagrangian approach.
31     Valid for finite strains, finite displacements and finite rotations.
33 Author
34     Micheal Leonard
35     Philip Cardiff
37 \*---------------------------------------------------------------------------*/
39 #include "fvCFD.H"
40 #include "constitutiveModel.H"
41 #include "solidInterface.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 int main(int argc, char *argv[])
47 #   include "setRootCase.H"
48 #   include "createTime.H"
49 #   include "createMesh.H"
50 #   include "createFields.H"
51 #   include "createSolidInterfaceNonLin.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55     Info<< "\nStarting time loop\n" << endl;
57     while(runTime.loop())
58     {
59         Info<< "Time: " << runTime.timeName() << nl << endl;
61 #       include "readSolidMechanicsControls.H"
63       int iCorr = 0;
64       scalar initialResidual = 0;
65       lduMatrix::solverPerformance solverPerf;
66       scalar relativeResidual = 1.0;
67       lduMatrix::debug = 0;
69       do
70       {
71           U.storePrevIter();
73           surfaceTensorField shearGradU
74           (
75               "shearGradU",
76               (I - sqr(n)) & fvc::interpolate(gradU)
77           );
79           fvVectorMatrix UEqn
80           (
81               fvm::d2dt2(rho, U)
82            ==
83               fvm::laplacian(2*muf + lambdaf, U, "laplacian(DU,U)")
84 //             + fvc::div
85 //               (
86 //                   -(mu + lambda)*gradU
87 //                   + mu*gradU.T()
88 //                   + mu*(gradU & gradU.T())
89 //                   + lambda*tr(gradU)*I
90 //                   + 0.5*lambda*tr(gradU & gradU.T())*I
91 //                   + (sigma & gradU),
92 //                   "div(sigma)"
93 //               )
94             + fvc::div
95               (
96                   mesh.magSf()*
97                   (
98                       - (muf + lambdaf)*(fvc::snGrad(U) & (I - n*n))
99                       + lambdaf*tr(shearGradU & (I - n*n))*n
100                       + muf*(shearGradU & n)
101                       + muf*(n & fvc::interpolate(gradU & gradU.T()))
102                       + 0.5*lambdaf*(n*tr(fvc::interpolate(gradU & gradU.T())))
103                       + (n & fvc::interpolate(sigma & gradU))
104                   )
105               )
106           );
108           if (solidInterfaceCorr)
109           {
110               solidInterfacePtr->correct(UEqn);
111           }
113           solverPerf = UEqn.solve();
115           if (iCorr == 0)
116           {
117               initialResidual = solverPerf.initialResidual();
118           }
120           U.relax();
122           //gradU = solidInterfacePtr->grad(U);
123           gradU = fvc::grad(U);
125 #         include "calculateEpsilonSigma.H"
126 #         include "calculateRelativeResidual.H"
128           Info<< "\tTime " << runTime.value()
129               << ", Corrector " << iCorr
130               << ", Solving for " << U.name()
131               << " using " << solverPerf.solverName()
132               << ", residual = " << solverPerf.initialResidual()
133               << ", relative residual = " << relativeResidual
134               << ", inner iterations " << solverPerf.nIterations() << endl;
135       }
136       while
137           (
138               solverPerf.initialResidual() > convergenceTolerance
139               //relativeResidual > convergenceTolerance
140               &&
141               ++iCorr < nCorr
142               );
144       Info<< nl << "Time " << runTime.value() << ", Solving for " << U.name()
145           << ", Initial residual = " << initialResidual
146           << ", Final residual = " << solverPerf.initialResidual()
147           << ", Relative residual = " << relativeResidual
148           << ", No outer iterations " << iCorr
149           << nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
150           << "  ClockTime = " << runTime.elapsedClockTime() << " s"
151           << endl;
153 #     include "writeFields.H"
155       Info<< "ExecutionTime = "
156           << runTime.elapsedCpuTime()
157           << " s\n\n" << endl;
158     }
160     Info<< "End\n" << endl;
162     return(0);
166 // ************************************************************************* //