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

Create a scalar from a volScalarField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 19, 2015, 05:45
Default Create a scalar from a volScalarField
  #1
Senior Member
 
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 313
Rep Power: 15
agustinvo is on a distinguished road
Hello

I want to modify a boundary condition, where you have to give the density as a scalar, but since in my case, the density will change, I want to use my own density.

I thought it was ok like this, but in my simulation I got this error:
Code:
Starting time loop

Time = 1

DILUPBiCG:  Solving for Ux, Initial residual = 1, Final residual = 1.723949e-12, No Iterations 3
DILUPBiCG:  Solving for Uy, Initial residual = 1, Final residual = 4.017873e-11, No Iterations 1
aqui
DILUPBiCG:  Solving for T, Initial residual = 1, Final residual = 6.385874e-11, No Iterations 4
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  
 at sigaction.c:?
#3  Foam::multiply(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#4  Foam::operator*(Foam::UList<double> const&, Foam::tmp<Foam::Field<double> > const&) at ??:?
#5 Foam::nonUniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs() at ??:?
#6  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::updateCoeffs() at ??:?
#7  Foam::fvMatrix<double>::fvMatrix(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensionSet const&) at ??:?
#8  Foam::fv::gaussLaplacianScheme<double, double>::fvmLaplacianUncorrected(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#9  Foam::fv::gaussLaplacianScheme<double, double>::fvmLaplacian(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#10  
 at ??:?
#11  
 at ??:?
#12  
 at ??:?
#13  __libc_start_main at ??:?
#14  
 at ??:?
Segmentation fault
So I went there to check what is going on.

There, I have:
Code:
void Foam::nonUniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs()
{
    if (updated())
    {
        return;
    }

    const uniformDimensionedVectorField& g =
        db().lookupObject<uniformDimensionedVectorField>("g");
 
    const volScalarField& rho_ =
        db().lookupObject<volScalarField>("rho"); 


    operator==
    (
        pRefValue_
      + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_))
    );

    fixedValueFvPatchScalarField::updateCoeffs();
}
But in the non-modified BC, rho_ is declared as a scalar, and I am using a volScalarField.

Do you know how can I change this, it means, create a scalar from a volScalarField?

Thank you everybody!
agustinvo is offline   Reply With Quote

Old   November 20, 2015, 18:18
Default
  #2
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 17
hk318i is on a distinguished road
I am afraid that your question is not clear for me. However based on this code, you are reading the complete density field rho_ and using it to calculate the BC. I am really surprised that you managed to compile this code. If you would like to read a rho value as scalar try to read it as scalar from the BC dictionary and use it in your calculations.

Bw,
Hassan
hk318i is offline   Reply With Quote

Old   November 24, 2015, 10:33
Default
  #3
Senior Member
 
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 313
Rep Power: 15
agustinvo is on a distinguished road
Hi Hassan,

as you say I am reading all the rho field, as a volScalar. I don't know how to take from there the scalar values of the boundary, in order to use them in the code.
agustinvo 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
FATAL ERROR:Maximum number of iterations exceeded zqlhzx OpenFOAM Running, Solving & CFD 4 July 13, 2016 15:53
Abnormal (?) Passive Scalar behaviour cwl STAR-CCM+ 1 October 3, 2014 08:05
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 01:27
Actuator disk model audrich FLUENT 0 September 21, 2009 07:06
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 01:07


All times are GMT -4. The time now is 00:39.