CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Adding constant temperture scalar value in stressAnalyisis solver (https://www.cfd-online.com/Forums/openfoam-programming-development/117567-adding-constant-temperture-scalar-value-stressanalyisis-solver.html)

Sargam05 May 10, 2013 15:05

Adding constant temperture scalar value in stressAnalyisis solver
 
Hello all,

I am using solidDisplacementFoam solver for the thermal stress analysis. I do not want to solve ddt equation for the temperature. I need to give a constant scalar value of temperature, T (e.g. 1073 K) for every cell id instead of solving ddt equation. Therefore I have made following changes in solidDisplacementFoam.C file :

#include "fvCFD.H"
#include "Switch.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#include "setRootCase.H"

#include "createTime.H"
#include "createMesh.H"
#include "readMechanicalProperties.H"
#include "readThermalProperties.H"
#include "readSolidDisplacementFoamControls.H"
#include "createFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nCalculating displacement field\n" << endl;

while (runTime.loop())
{
Info<< "Iteration: " << runTime.value() << nl << endl;

#include "readSolidDisplacementFoamControls.H"

int iCorr = 0;
scalar initialResidual = 0;

do
{
if (thermalStress)

{
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh,
dimensionedScalar Onethousandseventyfive
(
"Onethousandseventyfive",
dimensionSet(0, 0, 0, -1, 0, 0 ,0),
1075
)
);
forAll(mesh.C(),celli)
{
T[celli]=1073;

}

{
fvVectorMatrix DEqn
(
fvm::d2dt2(D)
==
fvm::laplacian(2*mu + lambda, D, "laplacian(DD,D)")
+ divSigmaExp
);

if (thermalStress)
{
const volScalarField& T = Tptr();
DEqn += fvc::grad(threeKalpha*T);
}

//DEqn.setComponentReference(1, 0, vector::X, 0);
//DEqn.setComponentReference(1, 0, vector::Z, 0);

initialResidual = DEqn.solve().initialResidual();

if (!compactNormalStress)
{
divSigmaExp = fvc::div(DEqn.flux());
}
}

{
volTensorField gradD = fvc::grad(D);
sigmaD = mu*twoSymm(gradD) + (lambda*I)*tr(gradD);

if (compactNormalStress)
{
divSigmaExp = fvc::div
(
sigmaD - (2*mu + lambda)*gradD,
"div(sigmaD)"
);
}
else
{
divSigmaExp += fvc::div(sigmaD);
}
}

} while (initialResidual > convergenceTolerance && ++iCorr < nCorr);

#include "calculateStress.H"

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return 0;
}

But following error is coming during compilation:

Making dependency list for source file tractionDisplacement/tractionDisplacementFvPatchVectorField.C
Making dependency list for source file solidDisplacementFoam.C
SOURCE=tractionDisplacement/tractionDisplacementFvPatchVectorField.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/opt/openfoam171/src/finiteVolume/lnInclude -ItractionDisplacement/lnInclude -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/tractionDisplacementFvPatchVectorField.o
SOURCE=solidDisplacementFoam.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/opt/openfoam171/src/finiteVolume/lnInclude -ItractionDisplacement/lnInclude -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/solidDisplacementFoam.o
solidDisplacementFoam.C: In function ‘int main(int, char**)’:
solidDisplacementFoam.C:82: error: expected primary-expression before ‘Onethousandseventyfive’
solidDisplacementFoam.C:154: error: expected ‘while’ before ‘Info’
solidDisplacementFoam.C:154: error: expected ‘(’ before ‘Info’
solidDisplacementFoam.C:154: error: expected ‘)’ before ‘;’ token
readSolidDisplacementFoamControls.H:3: warning: unused variable ‘nCorr’
readSolidDisplacementFoamControls.H:4: warning: unused variable ‘convergenceTolerance’
solidDisplacementFoam.C:157: error: expected ‘}’ at end of input
make: *** [Make/linuxGccDPOpt/solidDisplacementFoam.o] Error 1

Does anyone have any idea why this error is coming during compilation of solver? I appreciate if you would help me to fix it!

Best regards,
Sangeeta

kmooney May 11, 2013 12:14

I would just follow what the compiler errors say and check your brackets, particularly around the 'while' statement. That's what the compiler errors are for...

If you don't follow due diligence when posting problems or questions to this forum a lot of people will ignore the post. I'm not trying to be mean or cold but its the truth.

Sargam05 May 11, 2013 13:35

Hi Kyle,

Thank you for your straight-forward comment. Actually I was supposed to include a note to ignore the bracket error but I forgot to do that.

Now I have corrected the bracket error but only error which is coming is:

solidDisplacementFoam.C:82: error: expected primary-expression before ‘Onethousandseventyfive’

I really appreciate if any member of has any suggestion about this error.


All times are GMT -4. The time now is 20:50.