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

Calculate a quantity based on another quantity solved by Openfoam.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 23, 2012, 13:26
Question Calculate a quantity based on another quantity solved by Openfoam.
  #1
Senior Member
 
Join Date: Nov 2012
Posts: 171
Rep Power: 13
hz283 is on a distinguished road
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
hz283 is offline   Reply With Quote

Old   December 23, 2012, 18:13
Default
  #2
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
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
fumiya is offline   Reply With Quote

Old   December 23, 2012, 18:18
Default
  #3
Senior Member
 
Join Date: Nov 2012
Posts: 171
Rep Power: 13
hz283 is on a distinguished road
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
hz283 is offline   Reply With Quote

Old   December 23, 2012, 18:33
Default
  #4
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
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
fumiya is offline   Reply With Quote

Old   December 23, 2012, 18:42
Default
  #5
Senior Member
 
Join Date: Nov 2012
Posts: 171
Rep Power: 13
hz283 is on a distinguished road
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<double>&, Foam::UList<double> const&, Foam::UList<double> const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libOpenFOAM.so"
#4 void Foam::divide<Foam::fvsPatchField>(Foam::FieldField <Foam::fvsPatchField, double>&, Foam::FieldField<Foam::fvsPatchField, double> const&, Foam::FieldField<Foam::fvsPatchField, double> const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libcompressibleRASModels.so"
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> > Foam:perator/<Foam::fvsPatchField, Foam::surfaceMesh>(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> > const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libcompressibleRASModels.so"
#6 Foam::fv::backwardDdtScheme<Foam::Vector<double> >::fvcDdtPhiCorr(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) in "/users/abc/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64Gcc45DPOpt/lib/libfiniteVolume.so"
#7 Foam::tmp<Foam::GeometricField<Foam::flux<Foam::Ve ctor<double> >::type, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::fvc::ddtPhiCorr<Foam::Vector<double> >(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::flux<Foam::Vector<doubl e> >::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
hz283 is offline   Reply With Quote

Old   December 23, 2012, 18:54
Default
  #6
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
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
fumiya is offline   Reply With Quote

Old   December 23, 2012, 19:00
Default
  #7
Senior Member
 
Join Date: Nov 2012
Posts: 171
Rep Power: 13
hz283 is on a distinguished road
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
hz283 is offline   Reply With Quote

Old   December 23, 2012, 19:30
Default
  #8
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
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
fumiya is offline   Reply With Quote

Old   December 24, 2012, 08:36
Default
  #9
Senior Member
 
Join Date: Nov 2012
Posts: 171
Rep Power: 13
hz283 is on a distinguished road
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
hz283 is offline   Reply With Quote

Old   December 26, 2012, 14:17
Default
  #10
Senior Member
 
Join Date: Nov 2012
Posts: 171
Rep Power: 13
hz283 is on a distinguished road
Quote:
Originally Posted by fumiya View Post
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::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
0.1*mag(fvc::grad(c))*mag(fvc::grad(c))
);


But If I donot have the following lines in the time loop:
vc = 0.1*mag(fvc::grad(c))*mag(fvc::grad(c));

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.

hz283 is offline   Reply With Quote

Old   December 27, 2012, 01:47
Default
  #11
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
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
fumiya 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
Phase Field modeling in OpenFOAM adona058 OpenFOAM Running, Solving & CFD 35 November 16, 2021 00:16
OpenFOAM Live USB based on openSUSE 11.1 created with SUSE Studio alberto OpenFOAM 40 May 23, 2010 16:15
OpenFOAM 1.5.x package - CentOS 5.3 x86_64 linnemann OpenFOAM Installation 7 July 30, 2009 03:14
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 05:56
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07


All times are GMT -4. The time now is 16:22.