Calculate a quantity based on another quantity solved by Openfoam.
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 |
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 |
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 |
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)); fumiya |
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::printStack(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::operator/<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 |
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,
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 |
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 |
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 |
Quote:
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. |
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 |
All times are GMT -4. The time now is 04:20. |