Forward compatibility: flex
[foam-extend-3.2.git] / applications / solvers / solidMechanics / viscoElasticSolidFoam / calculateSigma.H
blob6e972a9106354a6b3fd19c57fc46b4570fa72b36
2     Info << "\nCalculate total stress" << endl;
4     scalar t = runTime.value();
5     scalar tNext = t + runTime.deltaT().value();
7     instantList Times = runTime.times();
9 //     Info << "Number of times: " << Times.size() << endl;
11     sigma = dimensionedSymmTensor("zero", dimForce/dimArea, symmTensor::zero);
12     DSigmaCorr =
13         dimensionedSymmTensor
14         (
15             "zero",
16             dimForce/dimArea,
17             symmTensor::zero
18         );
20     for (label i=1; i<Times.size(); i++)
21     {
22         runTime.setTime(Times[i], i);
24         if(runTime.timeIndex() != i)
25         {
26             FatalErrorIn(args.executable())
27                 << "The strain increment Depsilon must be stored for "
28                     << "each calculated time step. "
29                     << exit(FatalError);
30         }
32         IOobject DepsilonHeader
33         (
34             "Depsilon",
35             runTime.timeName(),
36             mesh,
37             IOobject::MUST_READ
38         );
40         // Check Depsilon exists
41         if (DepsilonHeader.headerOk())
42         {
43             volSymmTensorField DepsilonOld(DepsilonHeader, mesh);
45             scalar tau = runTime.value() - m*runTime.deltaT().value();
47             if(tau < 0)
48             {
49                 sigma += 2.0*rheology.mu(t)*DepsilonOld
50                     + rheology.lambda(t)*(I*tr(DepsilonOld));
52                 DSigmaCorr += 2.0*rheology.mu(tNext)*DepsilonOld
53                     + rheology.lambda(tNext)*(I*tr(DepsilonOld));
54             }
55             else
56             {
57                 sigma += 2.0*rheology.mu(t - tau)*DepsilonOld
58                     + rheology.lambda(t - tau)*(I*tr(DepsilonOld));
60                 DSigmaCorr += 2.0*rheology.mu(tNext - tau)*DepsilonOld
61                     + rheology.lambda(tNext - tau)*(I*tr(DepsilonOld));
62             }
63         }
64         else
65         {
66             Info << "No Depsilon" << endl;
67         }
68     }
70     if(Times.size()>=2)
71     {
72         runTime++;
73     }
75     scalar tau = runTime.value() - m*runTime.deltaT().value();
77     sigma += 2.0*rheology.mu(t - tau)*Depsilon
78         + rheology.lambda(t - tau)*(I*tr(Depsilon));
80     DSigmaCorr += 2.0*rheology.mu(tNext - tau)*Depsilon
81         + rheology.lambda(tNext - tau)*(I*tr(Depsilon));
83     DSigmaCorr -= sigma;
85     //Info << "Current time = " << runTime.timeName() << endl;