CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   SRF pointer usage (https://www.cfd-online.com/Forums/openfoam-programming-development/96494-srf-pointer-usage.html)

otm January 24, 2012 11:10

SRF pointer usage
 
Hello!

I'm trying to modify the settlingFoam solver so that it can be used within a rotating frame of reference. I have more or less tried to copy what is done in the SRFPimpleFoam solver. However, some additional modifications are necessary also in e.g. the drift velocity definitions and in the calculation of the hydrostatic pressure. And this is where I run into problems (related to my very limited C++ experience).

I tried to modify the drift velocity so that it reads:
Code:


    Vdj = mag(V0)*(SRF->Fcentrifugal())/mag(g)*
    (
        exp(-a*max(alpha - alphaMin, scalar(0)))
      - exp(-a1*max(alpha - alphaMin, scalar(0)))
    );

But that gives me the compilation error:
Code:


calcVdj.H:7: error: no match for ?operator*? in ?Foam::operator/(const Foam::tmp<Foam::DimensionedField<Type, GeoMesh> >&, const Foam::dimensioned<double>&) [with Type = Foam::Vector<double>, GeoMesh = Foam::volMesh](((const Foam::dimensioned<double>&)((const Foam::dimensioned<double>*)(& Foam::mag(const Foam::dimensioned<Type>&) [with Type = Foam::Vector<double>]())))) * Foam::operator-(const Foam::tmp<Foam::GeometricField<TypeR, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type1, PatchField, GeoMesh> >&) [with Type1 = double, Type2 = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::exp(const Foam::tmp<Foam::GeometricField<double, PatchField, GeoMesh> >&) [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]()))))?

In other places of the code I get similar errors when I try to form,
Code:

)mag(SRF->Fcentrifugal())
I'm obviuosly using SRF->Fcentrifugal() in the wrong way. But how should I write to make the code do what I want it to do??

BR
Olle :confused:

otm January 25, 2012 08:55

Hello again!

Still trying to understand/solve this problem.

I think the problem could be related to types being incompatible.

The member function returning the centrifugal force is defined in SRFModel.C as a DimensionedField<vector, volMesh>, see below:

Code:

Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh> >
Foam::SRF::SRFModel::Fcentrifugal() const
{
  return tmp<DimensionedField<vector, volMesh> >
  (
      new DimensionedField<vector, volMesh>
      (
          IOobject
          (
              "Fcentrifugal",
              mesh_.time().timeName(),
              mesh_,
              IOobject::NO_READ,
              IOobject::NO_WRITE
          ),
          omega_ ^ (omega_ ^ mesh_.C())
      )
  );
}

My problems occur when I try to use this DimensionedField to calculate something of type volScalarField or volVectorField.

The DimensionedField can be used as a term in the momentum equations (see e.g. UrelEqn.H in SRFPimpleFoam) but it seems not to be possible to use it in algebraic expressions used to define a volScalarField or volVectorField.

If someone with deeper knowledge cold tell me how to resolve this problem I would be very grateful.

BR
Olle

marupio January 25, 2012 10:01

The DimensionedField is only defined over the internal field. A GeometricField is defined over the internal field and the boundary surfaces. It's a little like trying to add a vector and a scalar... one has three values, the other has only one... how do you want me to add them?

So you need to decide what happens on the boundary field. If nothing happens, you can define your algebraic exrpession in terms of the internal field only:

Code:

// U is a volVectorField
    U.dimensionedField() = srfModel.FCentrifugal() / mass * ... etc.



All times are GMT -4. The time now is 02:21.