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/)
-   -   how to change boundaryType in volScalarField (https://www.cfd-online.com/Forums/openfoam-programming-development/194474-how-change-boundarytype-volscalarfield.html)

gaza October 16, 2017 15:18

how to change boundaryType in volScalarField
 
Hi All,
In constructor of GeometricField class we have
Code:

GeometricField            (          const IOobject &            io,                             
         
          const Mesh &            mesh,                             
         
          const dimensioned< Type > &            dt,                             
         
          const word &            patchFieldType = PatchField<Type>::calculatedType()                             
          )

where default boundaryType is calculatedType.

How can I define GeometricField with zeroGradient patchFieldType??

alexeym October 17, 2017 15:41

Hi,

You can use just "zeroGradient" string or zeroGradientFvPatchField<Type>::typeName if you would like to be sure your modification survives rename of zeroGradient.

gaza October 19, 2017 15:30

Quote:

Originally Posted by alexeym (Post 668243)
Hi,

You can use just "zeroGradient" string or zeroGradientFvPatchField<Type>::typeName if you would like to be sure your modification survives rename of zeroGradient.

Hi Alexeym,
It tells me that zeroGradient was not declared in this scope...

alexeym October 19, 2017 17:24

Hi,

To use zeroGradientFvPatchField you have to include zeroGradientFvPatchFields.H. If you do not want to bother, use string "zeroGradient".

gaza October 20, 2017 05:20

Hi Alexeym,
I added zeroGradientFvPatchFields.H but it still tells that zeroGradient was not declared in this scope.
My code is (in constructor)
Code:

A
(
    IOobject
    (
        "A",
        U.mesh().time().timeName(),
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    U.mesh(),
    dimensionedScalar("A", dimTemperature, 0.0),
    zeroGradient
),


alexeym October 20, 2017 07:16

Hi,

You could try to use more conventional C++ syntax (first one uses string, second uses static field):

Code:

A
(
    IOobject
    (
        "A",
        U.mesh().time().timeName(),
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    U.mesh(),
    dimensionedScalar("A", dimTemperature, 0.0),
    "zeroGradient"
),

or

Code:

A
(
    IOobject
    (
        "A",
        U.mesh().time().timeName(),
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    U.mesh(),
    dimensionedScalar("A", dimTemperature, 0.0),
    zeroGradientFvPatchScalarField::typeName
),


gaza October 20, 2017 07:35

Now it works :)
Thank you so much Alexeym.


All times are GMT -4. The time now is 18:45.