CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Setting boundaryField for a volScalarField (http://www.cfd-online.com/Forums/openfoam-programming-development/93712-setting-boundaryfield-volscalarfield.html)

Hisham October 24, 2011 13:59

Setting boundaryField for a volScalarField
 
Dear Foamers,

I try to set the value for a volScalarField like this:

Code:

forAll( alpha1.boundaryField()[myWaterWaves.patchID], facei)
{
  alpha1.boundaryField()[myWaterWaves.patchID][facei].operator=(1.);
}

It generates this error:

Code:

calcWaterWaves.H:39:63: error: request for member ‘operator=’ in ‘((Foam::fvPatchField<double>*)((Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField*)alpha1.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]())->Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::<anonymous>.Foam::FieldField<Foam::fvPatchField, double>::<anonymous>.Foam::PtrList<T>::operator[] [with T = Foam::fvPatchField<double>, Foam::label = int](myWaterWaves.Foam::waterWaves::patchID))->Foam::fvPatchField<double>::<anonymous>.Foam::Field<double>::<anonymous>.Foam::List<double>::<anonymous>.Foam::UList<T>::operator[] [with T = double, Foam::label = int](facei)’, which is of non-class type ‘double’
/opt/openfoam200/src/finiteVolume/lnInclude/readTimeControls.H:38:8: warning: unused variable ‘maxDeltaT’
make: *** [Make/linux64GccDPOpt/waveTankFoam.o] Error 1

The method I posted was successful for a volVectorField. However, no luck for me with understanding what is wrong here?

Regards,
Hisham

kathrin_kissling October 25, 2011 02:32

Hi,

can you just try to skip ".operator"

Code:

forAll( alpha1.boundaryField()[myWaterWaves.patchID], facei)
{
  alpha1.boundaryField()[myWaterWaves.patchID][facei]=(1.);
}

Then it will set these values to 1.

Best

Kathrin

Hisham October 25, 2011 06:50

Hi Kathrin,

Thanks a lot!

It has compiled without the (.operator). However, it does not behave as I've expected (the value is not applied at the BC). The "==" compiles as well (which is the forced assignment I believe), but it does not set the boundary neither.

Any Clue??

Regards
Hisham

kathrin_kissling October 25, 2011 07:43

Hey,

can you try to print out the boundary field directly after setting it?
Within which routine is this calculation?

Best

Kathrin

Hisham October 25, 2011 08:07

for
Code:

forAll( alpha1.boundaryField()[myWaterWaves.patchID], facej)
{
  alpha1.boundaryField()[myWaterWaves.patchID][facej]=(1.);
}


Info << "Boundary =" <<  alpha1.boundaryField()[myWaterWaves.patchID].patchInternalField() <<endl;

I get

Code:

....
Courant Number mean: 0.0160722 max: 0.160925
Interface Courant Number mean: 0.00119692 max: 0.0651188
deltaT = 0.00437063

Calculating Water Waves!

Boundary =7(1 0.0003235 3.23137e-07 1 1.00001 2.25737e-06 0.708186)
Time = 6

MULES: Solving for alpha1
Liquid phase volume fraction = 0.509359  Min(alpha1) = -3.17553e-30  Max(alpha1) = 1.00001
......

I am trying to control the VOF value at boundary for surface wave simulations. I think it is done at boundary because it is done like so in groovyBC. Or should I try to impose it on cells next to boundary?

Hisham October 25, 2011 08:54

Hi

For some strange reason, that has to do with values of another boundaryField at the same patch, it was not behaving as expected.

Now, it is working fine as expected with the mentioned code. Thanks again!

Regards
Hisham


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