# Calculate a quantity based on another quantity solved by Openfoam.

 Register Blogs Members List Search Today's Posts Mark Forums Read

 December 23, 2012, 14:26 Calculate a quantity based on another quantity solved by Openfoam. #1 Senior Member   Join Date: Nov 2012 Posts: 168 Rep Power: 7 Dear All, I would like to calculate and output a quantity based on a scalar and added the following lines in createFields.H: volScalarField vc ( IOobject ( "vc", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), 0.1*mag(fvc::grad(c))*mag(fvc::grad(c)) ); I added several lines to solve the goeverning equation to obtain the scalar fields c. I can confirm that the solutions of c is correct. However, for vc, I found that the above lines did not work at all. Does anybody know what is the problem behind it? Thank you very much. h

 December 23, 2012, 19:13 #2 Senior Member   Fumiya Nozaki Join Date: Jun 2010 Location: Yokohama, Japan Posts: 217 Blog Entries: 1 Rep Power: 11 Hi, Do you update the vc value at each time or iteration? vc = 0.1*mag(fvc::grad(c))*mag(fvc::grad(c)); Best regards, fumiya

 December 23, 2012, 19:18 #3 Senior Member   Join Date: Nov 2012 Posts: 168 Rep Power: 7 Hi, that quantity should be calculated each time step, but I found that its value always failed to be updated suing the expression. I did not figure it out about this. Thank you very much. best regards, h

 December 23, 2012, 19:33 #4 Senior Member   Fumiya Nozaki Join Date: Jun 2010 Location: Yokohama, Japan Posts: 217 Blog Entries: 1 Rep Power: 11 Hi, I think you can update the vc field at each time step if you add the following line in the time loop. Code: `vc = 0.1*mag(fvc::grad(c))*mag(fvc::grad(c));` Best regards, fumiya

 December 23, 2012, 19:42 #5 Senior Member   Join Date: Nov 2012 Posts: 168 Rep Power: 7 Hi, Thank you very much for your suggestion. If I adopt your method, but if I still want to output this quantity, maybe I need to add the following lines in createFields.H: volScalarField vc ( IOobject ( "vc", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh ); But When I do this, compilation is successful, but when I run the code, some error information appears as follows: #0 Foam::error:rintStack(Foam::Ostream&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libOpenFOAM.so" #1 Foam::sigFpe::sigHandler(int) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libOpenFOAM.so" #2 ?? in "/lib64/libc.so.6" #3 Foam::divide(Foam::Field&, Foam::UList const&, Foam::UList const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libOpenFOAM.so" #4 void Foam::divide(Foam::FieldField &, Foam::FieldField const&, Foam::FieldField const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libcompressibleRASModels.so" #5 Foam::tmp > Foam:perator/(Foam::GeometricField const&, Foam::tmp > const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libcompressibleRASModels.so" #6 Foam::fv::backwardDdtScheme >::fvcDdtPhiCorr(Foam::GeometricField const&, Foam::GeometricField const&, Foam::GeometricField, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libfiniteVolume.so" #7 Foam::tmp >::type, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::fvc::ddtPhiCorr >(Foam::GeometricField const&, Foam::GeometricField const&, Foam::GeometricField, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField >::type, Foam::fvsPatchField, Foam::surfaceMesh> const&) in "/users/abc/OpenFOAM/abc-2.1.1/platforms/linux64Gcc45DPOpt/bin/cmcPimpleFoam" #8 main in "/users/abc/OpenFOAM/abc-2.1.1/platforms/linux64Gcc45DPOpt/bin/cmcPimpleFoam" #9 __libc_start_main in "/lib64/libc.so.6" #10 Foam::UOPstream::write(char) in "/users/abc/OpenFOAM/abc-2.1.1/platforms/linux64Gcc45DPOpt/bin/cmcPimpleFoam" Floating point exception

 December 23, 2012, 19:54 #6 Senior Member   Fumiya Nozaki Join Date: Jun 2010 Location: Yokohama, Japan Posts: 217 Blog Entries: 1 Rep Power: 11 Hi, How about if you use the code in your post #1 with my suggestion? In the createFields.H volScalarField vc ( IOobject ( "vc", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), 0.1*mag(fvc::grad(c))*mag(fvc::grad(c)) ); and in the time loop vc = 0.1*mag(fvc::grad(c))*mag(fvc::grad(c)); Best regards, fumiya

 December 23, 2012, 20:00 #7 Senior Member   Join Date: Nov 2012 Posts: 168 Rep Power: 7 Hi fumiya, I tried the method mentioned post #6, but the error info is totally the same as those in post #5. I do know why these errors appear. Do you have further suggestions? best h

 December 23, 2012, 20:30 #8 Senior Member   Fumiya Nozaki Join Date: Jun 2010 Location: Yokohama, Japan Posts: 217 Blog Entries: 1 Rep Power: 11 Hi hz283, I have confirmed that the scalarTransportFoam added the lines in the post #6 runs well without error. If you can post the solver and case, I think you will get further suggestions. Best regards, fumiya

 December 24, 2012, 09:36 #9 Senior Member   Join Date: Nov 2012 Posts: 168 Rep Power: 7 Hi fumiya, In the createFields.H, if I use the following instead of IOobject, the code can run successfully: volScalarFields("vc", 0.1*mag(fvc::grad(c))*mag(fvc::grad(c))). This indicates that the Input/Output is not correct. But I still do not know about the cause. Merry Xmas. h

December 26, 2012, 15:17
#10
Senior Member

Join Date: Nov 2012
Posts: 168
Rep Power: 7
Quote:
 Originally Posted by fumiya Hi, How about if you use the code in your post #1 with my suggestion? In the createFields.H volScalarField vc ( IOobject ( "vc", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), 0.1*mag(fvc::grad(c))*mag(fvc::grad(c)) ); and in the time loop vc = 0.1*mag(fvc::grad(c))*mag(fvc::grad(c)); Best regards, fumiya
Hi fumiya,

If I add the following lines in createFields.H:
volScalarField vc
(
IOobject
(
"vc",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
);

But If I donot have the following lines in the time loop:

It seems that the quantity will only calculated once just in the beginning and will not be updated with the time advancement. Is my understanding correct about this?

Thanks.

 December 27, 2012, 02:47 #11 Senior Member   Fumiya Nozaki Join Date: Jun 2010 Location: Yokohama, Japan Posts: 217 Blog Entries: 1 Rep Power: 11 Hi hz283, I think you are correct. We have to add the following line vc = 0.1*mag(fvc::grad(c))*mag(fvc::grad(c)); in the time loop in order to update the value vc. fumiya

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post adona058 OpenFOAM Running, Solving & CFD 28 June 22, 2016 14:21 alberto OpenFOAM 40 May 23, 2010 16:15 linnemann OpenFOAM Installation 7 July 30, 2009 03:14 pete Site News & Announcements 0 June 29, 2009 05:56 mirko OpenFOAM Installation 2 August 12, 2008 18:07

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