CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Two volScalarField created,Want to compute third volScalarField from pervious two

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Sereff

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 11, 2024, 01:54
Default Two volScalarField created,Want to compute third volScalarField from pervious two
  #1
New Member
 
Waleed Khalid
Join Date: Nov 2017
Posts: 14
Rep Power: 8
Waleed Khalid is on a distinguished road
Hi,

I have created two volScalarField,
volScalarField MAXprincipalstress
(
IOobject
(
"MAXprincipalstress",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
(0.5 * (sigmaxx + sigmayy) + sqrt( sqr((sigmaxx- sigmayy) * 0.5 ) + sqr(sigmaxy)))

);

volScalarField Minprincipalstress
(
IOobject
(
"Minprincipalstress",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
(0.5 * (sigmaxx + sigmayy) - sqrt( sqr((sigmaxx- sigmayy) * 0.5 ) + sqr(sigmaxy)))

);


Now i want to compute third volScalarField from these two that are already created here. I am doing it like this.
volScalarField EquivalentStress
(
IOobject
(
"EquivalentStress",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqrt(MAXprincipalstress(MAXprincipalstress - Minprincipalstress) * 0.5 )

);

But i am getting an error while compiling the code.
Error:
error: no match for call to ‘(Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}) (Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’ 171 | sqrt(MAXprincipalstress(MAXprincipalstress - Minprincipalstress) * 0.5 ) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
Waleed Khalid is offline   Reply With Quote

Old   March 11, 2024, 07:55
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Try using a dimensionedScalar instead of the 0.5 and see if that helps.
olesen is offline   Reply With Quote

Old   March 25, 2024, 09:16
Default
  #3
Member
 
Sereff
Join Date: Jan 2019
Posts: 48
Rep Power: 7
Sereff is on a distinguished road
maybe try simply use:
sqrt((MAXprincipalstress - Minprincipalstress) * 0.5 )

instead of:
sqrt(MAXprincipalstress(MAXprincipalstress - Minprincipalstress) * 0.5 )
Sereff is offline   Reply With Quote

Old   March 26, 2024, 05:39
Default
  #4
New Member
 
Waleed Khalid
Join Date: Nov 2017
Posts: 14
Rep Power: 8
Waleed Khalid is on a distinguished road
Thanks, it work well But why this does not work?
sqrt(MAXprincipalstress(MAXprincipalstress - Minprincipalstress) * 0.5 )
Waleed Khalid is offline   Reply With Quote

Old   March 26, 2024, 05:43
Default
  #5
New Member
 
Waleed Khalid
Join Date: Nov 2017
Posts: 14
Rep Power: 8
Waleed Khalid is on a distinguished road
May be Open-foam, doesn't do arithmetic operations on more than two arrays? am i right?
Waleed Khalid is offline   Reply With Quote

Old   March 26, 2024, 05:50
Default
  #6
New Member
 
Waleed Khalid
Join Date: Nov 2017
Posts: 14
Rep Power: 8
Waleed Khalid is on a distinguished road
Here is the final code it works well thanks Sereff
volScalarField principalstress
(
IOobject
(
"principalstress",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
(0.5 * (sigmaxx + sigmayy) + 0.5 * sqrt( sqr(sigmaxx- sigmayy) + 4 * sqr(sigmaxy)))

);

volScalarField MAXprincipalstress
(
IOobject
(
"MAXprincipalstress",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
(0.5 * (sigmaxx + sigmayy) + sqrt( sqr((sigmaxx- sigmayy) * 0.5 ) + sqr(sigmaxy)))

);

volScalarField Minprincipalstress
(
IOobject
(
"Minprincipalstress",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
(0.5 * (sigmaxx + sigmayy) - sqrt( sqr((sigmaxx- sigmayy) * 0.5 ) + sqr(sigmaxy)))

);

volScalarField sigma_L
(
IOobject
(
"sigma_L",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
(MAXprincipalstress - Minprincipalstress)

);

volScalarField EquivalentStress
(
IOobject
(
"EquivalentStress",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqrt((MAXprincipalstress * sigma_L) * 0.5 )

);
Waleed Khalid is offline   Reply With Quote

Old   March 26, 2024, 06:36
Default
  #7
Member
 
Sereff
Join Date: Jan 2019
Posts: 48
Rep Power: 7
Sereff is on a distinguished road
the error message
Code:
no match for call to ‘(Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}) (Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’ 171 | sqrt(MAXprincipalstress(MAXprincipalstress - Minprincipalstress) * 0.5 ) |
implies that the class you are invoking doesnt have a member function that matches the argument you are trying to pass, so in this case you are calling the constructor
Code:
MAXprincipalstress(some arguements)
and the argument you are passing along is
Code:
(MAXprincipalstress - Minprincipalstress) * 0.5  <--  some arguement
and this is of type
Code:
Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>>
which I guess does not match with the constructors defined for volScalarField class
Waleed Khalid likes this.
Sereff is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message Bruno_Jorge Main CFD Forum 1 February 5, 2019 11:12
namespace Foam Argen OpenFOAM 4 February 5, 2019 08:55
Adding new member function to GidaspowErgunWenYu.C of dragModel kiang OpenFOAM Programming & Development 0 June 21, 2017 05:23
execFlowFunctionObjects - unknown field problem Toorop OpenFOAM Post-Processing 16 March 14, 2016 03:25
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16


All times are GMT -4. The time now is 14:29.