|
[Sponsors] |
September 6, 2013, 18:26 |
Help with if statement
|
#1 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
Hello,
I am trying to modify the k-omega model to implement Wilcox 2006 version. I want to use an if statement to assign a value to a constant, "alplhad", depending on the sign of partial(k)/partial(x_j)*partial(omega)/partial(x_j) but I keep on getting compile errors caused by the if statement. I know that the solution has to be quite simple but I just can't figure it out! Please help! Below is my definition of alphadCheck and that for the if statement. I have also attached copies of my .C and .H files Code:
const volScalarField alphadCheck ( mag(fvc::grad(k_) & fvc::grad(omega_)) ); //Added to check alphad Code:
if ( alphadCheck <= scalar(0.0)) { alphad_=alphado_ ; } Code:
/kOmega2006Changes2$ wmake libso Making dependency list for source file kOmega2006C2.C SOURCE=kOmega2006C2.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/turbulenceModels -I/opt/openfoam220/src/transportModels -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/meshTools/lnInclude -I/opt/openfoam220/src/turbulenceModels/incompressible/RAS/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/kOmega2006C2.o kOmega2006C2.C: In member function ‘virtual void Foam::incompressible::RASModels::kOmega2006C2::correct()’: kOmega2006C2.C:300:31: error: no match for ‘operator<=’ in ‘alphadCheck <= 0.0’ kOmega2006C2.C:300:31: note: candidates are: /opt/openfoam220/src/OpenFOAM/lnInclude/UList.C:224:6: note: bool Foam::UList<T>::operator<=(const Foam::UList<T>&) const [with T = double] /opt/openfoam220/src/OpenFOAM/lnInclude/UList.C:224:6: note: no known conversion for argument 1 from ‘double’ to ‘const Foam::UList<double>&’ /opt/openfoam220/src/OpenFOAM/lnInclude/VectorSpaceI.H:693:13: note: template<class Form, class Cmpt, int nCmpt> bool Foam::operator<=(const Foam::VectorSpace<Form, Cmpt, nCmpt>&, const Foam::VectorSpace<Form, Cmpt, nCmpt>&) make: *** [Make/linux64GccDPOpt/kOmega2006C2.o] Error 1 |
|
September 9, 2013, 13:50 |
|
#2 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
Anyone please?
|
|
September 10, 2013, 03:21 |
|
#3 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
What are you trying to do? Your are comparing a volScalarField with a scalar. Looks like that is not defined in OpenFOAM.
|
|
September 10, 2013, 04:16 |
|
#4 |
Senior Member
|
Maybe you have forgotten to wrap a loop over all cells around the if statement and compare each cell individually?
|
|
September 10, 2013, 06:39 |
|
#5 | |
Senior Member
|
Quote:
Code:
alphad_ = 0.5*(1 - sign(alphaCheck))*alphado_ + 0.5*(1 + sign(alphaCheck))*alphad_; Code:
forAll(alphad_, cellI)) { if ( alphadCheck[cellI] <= scalar(0.0)) { alphad_[cellI]=alphado_[cellI]; } } |
||
September 10, 2013, 20:49 |
|
#6 | |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
Thank you for replying!
Quote:
I am trying to add a routine that checks the sign of partial(k)/partial(x_j)*partial(omega)/partial(x_j) and assigns a value to "alphad" according on the result of the sign check. However, I have never modified OpenFOAM so I don't know where to place the extra code. Now I understand why I was getting an error comparing the volScalaraField to the scalar though! Jens Höpken's idea to loop over all cells was in fact missing from my routine!! I added the following: Code:
forAll(alphad_, celli) { if ( alphadCheck[celli] <= scalar(0.0)) //check this! { alphad_[celli]=alphado_[celli] ; } } Code:
Making dependency list for source file kOmega2006C2.C SOURCE=kOmega2006C2.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/turbulenceModels -I/opt/openfoam220/src/transportModels -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/meshTools/lnInclude -I/opt/openfoam220/src/turbulenceModels/incompressible/RAS/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/kOmega2006C2.o kOmega2006C2.C: In member function ‘virtual void Foam::incompressible::RASModels::kOmega2006C2::correct()’: kOmega2006C2.C:284:26: error: ‘celli’ was not declared in this scope kOmega2006C2.C:301:1: error: ‘Foam::dimensionedScalar’ has no member named ‘size’ In file included from /opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedType.H:309:0, from /opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedScalar.H:38, from /opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedTypes.H:31, from /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.H:43, from /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricScalarField.H:38, from /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricFields.H:34, from /opt/openfoam220/src/finiteVolume/lnInclude/volFields.H:37, from /opt/openfoam220/src/finiteVolume/lnInclude/nearWallDist.H:39, from /opt/openfoam220/src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H:51, from /opt/openfoam220/src/turbulenceModels/incompressible/RAS/lnInclude/RASModel.H:47, from kOmega2006C2.H:65, from kOmega2006C2.C:26: /opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedType.C: In member function ‘Foam::dimensioned<typename Foam::pTraits<T>::cmptType> Foam::dimensioned<Type>::component(Foam::direction) const [with Type = double, typename Foam::pTraits<T>::cmptType = double, Foam::direction = unsigned char]’: /opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedType.C:344:23: instantiated from ‘Foam::dimensioned<typename Foam::pTraits<T>::cmptType> Foam::dimensioned<Type>::operator[](Foam::direction) const [with Type = double, typename Foam::pTraits<T>::cmptType = double, Foam::direction = unsigned char]’ kOmega2006C2.C:305:21: instantiated from here /opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedType.C:236:5: error: request for member ‘component’ in ‘((const Foam::dimensioned<double>*)this)->Foam::dimensioned<double>::value_’, which is of non-class type ‘const double’ make: *** [Make/linux64GccDPOpt/kOmega2006C2.o] Error 1 sebastian@navier1:~/OpenFOAM/sebastian-2.2.0/src/turbulenceModels/incompressible/RAS/kOmega2006Changes2$ The modified .C and .H files are attached if that's of any help. |
||
September 11, 2013, 02:18 |
|
#7 | |
Senior Member
|
Quote:
Code:
alphad_ ( dimensioned<scalar>::lookupOrAddToDict ( "alphad", coeffDict_, 0.125 //sigma_d=1/8 in 2006 ) ), alphado_ ( dimensioned<scalar>::lookupOrAddToDict ( "alphado", coeffDict_, 0.0 //sigma_d=0 in if statement of 2006 *** ) ), |
||
September 12, 2013, 15:54 |
|
#8 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
@alexym
Thank you for your suggestion! Changing them to a VolScalarField solved the error but I have now created new ones... I have some questions that, if answered, may point me in the right direction instead of blindly trying to fix the errors: 1. How should I define a volScalarField? For example, for alphadCheck, I have defined it as : Code:
const volScalarField alphadCheck ( mag(fvc::grad(k_) & fvc::grad(omega_)) ); In order for alphadCheck to go through each cell in the domain, it should be placed within the forAll(alphad_, celli) loop, but first I have to define it somehow, which is where I'm stuck. Should I be defining these volScalarFields in the "void kOmega::correct()" section or outside of it? 2. I want to be able to change the value of alphad_ on each cell (if necessary), depending on the result of alphadCheck. Should alphad_ be defined as a volScalarField since there will be a corresponding alphad_ value for each cell? If so, how can I initialize alphad_ (all of the components should be set equal to .125 for the first iteration and then changed according to results from alphadCheck (if necessary))? 3. How do I define the index for the forAll loop (i.e.: celli)? I would like to use a forAll loop in the following way: Code:
forAll(alphad_,celli) { if ( sign(alphaCheck[celli]) #IS NEGATIVE ) { alphad_[celli]=scalar(0.0) ; } } The most recent .C and .H files are attached |
|
September 12, 2013, 17:34 |
|
#9 |
Senior Member
|
1. Well, you can try to create it as you've described it in the post. Though I'm not quite sure that mag(...) can be negative. Do I get it right and you'd like to check sign of scalar product of two gradient vectors? Then you can define it as volScalarField alphaCheck_(fvc::grad(k_) & fvc::grad(omega_)) or volScalarField alphaCheck_(sign(fvc::grad(k_) & fvc::grad(omega_))). Though as you'll check alphaCheck_[cellI] then maybe additional call to sign is not necessary.
You can define this variables (alphaCheck_ and alphad_) as a private properties of kOmega2006 and create then in constructor. Or as alphaCheck_ is recalculated on every update call you can create it in update method as const volScalarField& alphaCheck_(fvc::grad(k_) & fvc::grad(omega_)). 2. Surely there are more correct ways but for alphad_ you can try to use something like volScalarField alphad_(0.125 + 0.0*nut_). 3. You don't need to define index variable as forAll is the macro (documentation) and it will define index variable for you. So you can just use Code:
forAll(alphad_, cellI) { ...something using cellI... } Code:
for (Foam::label cellI=0; cellI<(alphad_).size(); cellI++) { ...something using cellI... } |
|
September 12, 2013, 19:40 |
|
#10 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
@alexeym
Thank you for replying quickly! You are correct: I want to check the sign of the scalar product of two gradient vectors. I have defined alphaCheck_ and alphad_ as you suggested: Code:
const volScalarField alphadCheck_ ( fvc::grad(k_) & fvc::grad(omega_) ); //Added to check alphad const volScalarField alphad_ ( 0.125+0.0*nut_ ); I have also implemented the forAll as: Code:
forAll(alphad_, cellI) { if ( neg(alphadCheck_[cellI]) ) { alphad_[cellI]=scalar(0.0) ; } } Below are the errors I am still getting: Code:
sebastian@navier1:~/OpenFOAM/sebastian-2.2.0/src/turbulenceModels/incompressible/RAS/kOmega2006Changes3$ wmake libso Making dependency list for source file kOmega2006C2.C SOURCE=kOmega2006C2.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/turbulenceModels -I/opt/openfoam220/src/transportModels -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/meshTools/lnInclude -I/opt/openfoam220/src/turbulenceModels/incompressible/RAS/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/kOmega2006C2.o kOmega2006C2.C: In constructor ‘Foam::incompressible::RASModels::kOmega2006C2::kOmega2006C2(const volVectorField&, const surfaceScalarField&, Foam::transportModel&, const Foam::word&, const Foam::word&)’: kOmega2006C2.C:160:5: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’ kOmega2006C2.C:160:5: note: candidates are: /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: candidate expects 4 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: candidate expects 3 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: candidate expects 1 argument, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: candidate expects 1 argument, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dictionary&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: candidate expects 3 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::Field<TypeR>&, const Foam::PtrList<PatchField<Type> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: candidate expects 4 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: candidate expects 4 arguments, 0 provided kOmega2006C2.C:160:5: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’ kOmega2006C2.C:160:5: note: candidates are: /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: candidate expects 4 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: candidate expects 3 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: candidate expects 1 argument, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: candidate expects 1 argument, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dictionary&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: candidate expects 3 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::Field<TypeR>&, const Foam::PtrList<PatchField<Type> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: candidate expects 4 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: candidate expects 4 arguments, 0 provided kOmega2006C2.C: In member function ‘virtual void Foam::incompressible::RASModels::kOmega2006C2::correct()’: kOmega2006C2.C:294:33: error: assignment of read-only location ‘alphad_.Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::<anonymous>.Foam::DimensionedField<double, Foam::volMesh>::<anonymous>.Foam::Field<double>::<anonymous>.Foam::List<double>::<anonymous>.Foam::UList<T>::operator[] [with T = double, Foam::label = int](cellI)’ make: *** [Make/linux64GccDPOpt/kOmega2006C2.o] Error 1 sebastian@navier1:~/OpenFOAM/sebastian-2.2.0/src/turbulenceModels/incompressible/RAS/kOmega2006Changes3$ |
|
September 13, 2013, 03:12 |
|
#11 |
Senior Member
|
Well...
1. As you'd like to change alphad_ it should not be declared as const. This will fix the last error. 2. On the other hand if you create alphad_ as Code:
volScalarField alphad_ ( 0.125+0.0*nut_ ); Code:
... alphad_ ( IOobject ( "alphad_", runTime_.timeName(), mesh_, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh_, dimless ) { bound(k_, kMin_); ... 3. And finally the error with very long description. For some strange reason I wasn't able to build library from your source files. So I've taken original kOmega model and added modifications from your source files. After this I was able to compile library. You can find archive with source files and wmake configuration attached to the message. To build library you just run 'wmake libso' in the folder. |
|
September 13, 2013, 14:06 |
|
#12 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
Thank you! That definitely fixed the last error.
I went through line by line and compared all of the files that you kindly sent to me and I found a few differences which may explain why yours is compiling and mine isn't. Below you'll find segments of your code with comments of how it differs from mine: In kOmega2006.C: Code:
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(kOmega, 0); addToRunTimeSelectionTable(RASModel, kOmega, dictionary); Code:
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // tmp<volSymmTensorField> kOmega::R() const { return tmp<volSymmTensorField> ( new volSymmTensorField ( IOobject ( "R", runTime_.timeName(), mesh_, IOobject::NO_READ, IOobject::NO_WRITE ), ((2.0/3.0)*I)*k_ - nut_*twoSymm(fvc::grad(U_)), k_.boundaryField().types() ) ); . . . On line 262, your file has Code:
volScalarField G(GName(), nut_*2*magSqr(symm(fvc::grad(U_)))); volScalarField G(type() + ".G", nut_*2*magSqr(symm(fvc::grad(U_)))); In kOmega2006.H: Again, I have changed all of my instances from kOmega to kOmega2006 Our files and options in Make are the same. The error that was generated this time around was: Code:
:~/OpenFOAM/sebastian-2.2.0/src/turbulenceModels/incompressible/RAS/kOmega2006Changes3$ wmake libso wmakeLnInclude: linking include files to ./lnInclude Making dependency list for source file kOmega2006C2.C SOURCE=kOmega2006C2.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/turbulenceModels -I/opt/openfoam220/src/transportModels -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/meshTools/lnInclude -I/opt/openfoam220/src/turbulenceModels/incompressible/RAS/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/kOmega2006C2.o kOmega2006C2.C: In constructor ‘Foam::incompressible::RASModels::kOmega2006C2::kOmega2006C2(const volVectorField&, const surfaceScalarField&, Foam::transportModel&, const Foam::word&, const Foam::word&)’: kOmega2006C2.C:173:5: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’ kOmega2006C2.C:173:5: note: candidates are: /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: candidate expects 4 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: candidate expects 3 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: candidate expects 1 argument, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: candidate expects 1 argument, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dictionary&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: candidate expects 3 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: candidate expects 2 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::Field<TypeR>&, const Foam::PtrList<PatchField<Type> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: candidate expects 4 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: candidate expects 5 arguments, 0 provided /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh] /opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: candidate expects 4 arguments, 0 provided make: *** [Make/linux64GccDPOpt/kOmega2006C2.o] Error 1 :~/OpenFOAM/sebastian-2.2.0/src/turbulenceModels/incompressible/RAS/kOmega2006Changes3$ I have attached my version of your last attachment. |
|
September 13, 2013, 18:14 |
|
#13 |
Senior Member
|
You are right, I forgot to change the name in all places. This time I've fixed it.
I don't know why, there's no major differences between our file sets (diff -u kOmega2006.* kOmega2006C2.* gives only lines with names of the classes). Also difference in Code:
volScalarField G(GName(), nut_*2*magSqr(symm(fvc::grad(U_)))); Code:
volScalarField G(type() + ".G", nut_*2*magSqr(symm(fvc::grad(U_)))); As I don't know the reason for error while compiling your sources, so I just attach my variant (with added 2006 in the name, and I think I've changed the name of the class in all necessary places). Hope this will help. |
|
September 17, 2013, 13:58 |
|
#14 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
alexeym,
IT FINALLY COMPILED!!! :0 I found out why I was having problems... In the .C file, I was missing the first "&" in Code:
const volScalarField& alphadCheck_(fvc::grad(k_) & fvc::grad(omega_)); Code:
volScalarField alphaCheck_; Can you explain why you don't have it? |
|
September 17, 2013, 15:03 |
|
#15 | |
Senior Member
|
Quote:
Code:
const volScalarField& alphaCheck_(fvc::grad(k_) & fvc::grad(omega_)); Code:
alphaCheck_ = fvc::grad(k_) & fvc::grad(omega_); |
||
September 18, 2013, 19:29 |
|
#16 |
Member
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13 |
Got it!
alexeym, Thank you so much for all of your help!! I am going to run a few test cases and I will share the results and the source code for the slightly modified model. |
|
August 22, 2021, 04:13 |
how to put if statement in between volScalarField and dimensionedScalar
|
#17 |
New Member
Sourav Hossain
Join Date: Mar 2019
Posts: 25
Rep Power: 7 |
Hi Foamers,
I have to put a if statement in between a volScalarField and dimensionedScalar. The part of the code is : ////////////////////////////////////////////////////////////// volScalarField y = mesh.C().component(vector::Y); volScalarField u = ustar*(((1.0-Y0)/(Y0-Foam::log(Y0)-1.0))*Foam::log(y)/(h*Y0))); if(y >= Y0*h && y <= h ) { u = ustar*(((1.0-Y0)/(Y0-Foam::log(Y0)-1.0))*Foam::log(y/(h*Y0))); } else { u = 0.0; } dimensionedScalar Y0 ( transportProperties.lookup("Y0") ); dimensionedScalar h ( transportProperties.lookup("h") ); ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// After running the code I'm getting this error : .C:82:24: error: no match for ‘operator<=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::dimensionedScalar {aka Foam::dimensioned<double>}’) if(y >= Y0*h && y <= h ) |
|
August 22, 2021, 04:14 |
|
#18 | |
New Member
Sourav Hossain
Join Date: Mar 2019
Posts: 25
Rep Power: 7 |
Quote:
Hi, I have to put a if statement in between a volScalarField and dimensionedScalar. The part of the code is : ////////////////////////////////////////////////////////////// volScalarField y = mesh.C().component(vector::Y); volScalarField u = ustar*(((1.0-Y0)/(Y0-Foam::log(Y0)-1.0))*Foam::log(y)/(h*Y0))); if(y >= Y0*h && y <= h ) { u = ustar*(((1.0-Y0)/(Y0-Foam::log(Y0)-1.0))*Foam::log(y/(h*Y0))); } else { u = 0.0; } dimensionedScalar Y0 ( transportProperties.lookup("Y0") ); dimensionedScalar h ( transportProperties.lookup("h") ); ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// After running the code I'm getting this error : .C:82:24: error: no match for ‘operator<=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::dimensionedScalar {aka Foam::dimensioned<double>}’) if(y >= Y0*h && y <= h ) |
||
Tags |
openfoam-2.2.0 |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
USING IF statement in a UDF for defining Velocity profile at Inlet | amir2920 | Fluent UDF and Scheme Programming | 3 | May 24, 2013 00:46 |
Restricting area in if statement | Blackhawks84 | Fluent UDF and Scheme Programming | 4 | July 22, 2012 17:50 |
If statement question | mariam.sara | CFX | 3 | May 24, 2012 03:33 |
Weak statement for Galerkin Method | rugabug | Main CFD Forum | 0 | March 26, 2010 20:19 |
Problem Statement | balkrishna | Main CFD Forum | 0 | October 7, 2009 00:55 |