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/)
-   -   Custom boundary condition : type instantiation (https://www.cfd-online.com/Forums/openfoam-programming-development/206063-custom-boundary-condition-type-instantiation.html)

Benben August 29, 2018 05:34

Custom boundary condition : type instantiation
 
Hello,

I am using OpenFoam 6.
I am trying to compile a boundary condition made to calculates a species mass fraction. (I want to set the mass fraction in order to impose a partial pressure "P_ref" of species in the gas).
I created a class that inherits from "FixedValuefvPatchField".
My mass fraction is roughly calculated as :
Code:

(*this)[faceID] = P_ref * M / (Rho[faceID] * R * T[faceID])
With the right term of the equation beeing a scalar.

However, when compiling my class, i get the error :
Code:

evaporatingZinc_RDMP/evaporatingZinc_RDMPFvPatchField.C: In instantiation of 'void Foam::evaporatingZinc_RDMPFvPatchField<Type>::updateCoeffs() [with Type = Foam::Vector<double>]':
evaporatingZinc_RDMP/evaporatingZinc_RDMPFvPatchFields.C:41:1:  required from here
evaporatingZinc_RDMP/evaporatingZinc_RDMPFvPatchField.C:153:18: error: no match for 'operator=' (operand types are 'Foam::Vector<double>' and 'double')

Which means that, when the type of my class is instantiated as a "Vector<scalar>", affecting a scalar to it raises an error.

I want to use this boundary condition on scalars only (species mass fractions ...). Is there any way to prevent this instantiation to be made ?

Benben August 30, 2018 04:47

This was due to the fact that i tried to copy and modify the "fixedValueFvPatchField" folder instead of using the utility "FoamNewBC -f -s myBoundaryCondition" (type "foamNewBC -h" for informations on how to use).


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