# Create a scalar from a volScalarField

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

 November 19, 2015, 06:45 Create a scalar from a volScalarField #1 Senior Member   Agustín Villa Join Date: Apr 2013 Location: Brussels Posts: 118 Rep Power: 5 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&, Foam::UList const&, Foam::UList const&) at ??:? #4 Foam::operator*(Foam::UList const&, Foam::tmp > const&) at ??:? #5 Foam::nonUniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs() at ??:? #6 Foam::GeometricField::GeometricBoundaryField::updateCoeffs() at ??:? #7 Foam::fvMatrix::fvMatrix(Foam::GeometricField const&, Foam::dimensionSet const&) at ??:? #8 Foam::fv::gaussLaplacianScheme::fvmLaplacianUncorrected(Foam::GeometricField const&, Foam::GeometricField const&, Foam::GeometricField const&) at ??:? #9 Foam::fv::gaussLaplacianScheme::fvmLaplacian(Foam::GeometricField const&, Foam::GeometricField 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("g"); const volScalarField& rho_ = db().lookupObject("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!

 November 20, 2015, 19:18 #2 Senior Member   Hassan Kassem Join Date: May 2010 Location: UK Posts: 231 Rep Power: 10 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

 November 24, 2015, 11:33 #3 Senior Member   Agustín Villa Join Date: Apr 2013 Location: Brussels Posts: 118 Rep Power: 5 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.

 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 zqlhzx OpenFOAM Running, Solving & CFD 4 July 13, 2016 15:53 cwl STAR-CCM+ 1 October 3, 2014 08:05 immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 02:27 audrich FLUENT 0 September 21, 2009 07:06 audrich FLUENT 3 August 4, 2009 01:07

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