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/)
-   -   Getting errors on compiling boundary condition (https://www.cfd-online.com/Forums/openfoam-programming-development/103040-getting-errors-compiling-boundary-condition.html)

shash June 9, 2012 02:32

Getting errors on compiling boundary condition
 
hi,
i am new to openfoam so please bear with me if my doubt is silly. i was trying to use new boundary condition by modifying oscillatingFixedValue , so i copied it to my OpenFoam/shash-2.1.1/run/pitzdaily/ and made a make dir. in which i modified make/files to

newoscillatingFixedValueFvPatchField.C
EXE = $(FOAM_USER_APPBIN)/newoscillatingFixedValueFvPatchField

then

wclean
rm -rf Make/linux*
wmake
but its showing error :

************************************************
Making dependency list for source file newoscillatingFixedValueFvPatchField.C
SOURCE=newoscillatingFixedValueFvPatchField.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/home/shash/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/shash/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude -I/home/shash/OpenFOAM/OpenFOAM-2.1.1/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/newoscillatingFixedValueFvPatchField.o
In file included from newoscillatingFixedValueFvPatchField.H:242:0,
from newoscillatingFixedValueFvPatchField.C:3:
newoscillatingFixedValueFvPatchField.C: In member function ‘virtual void Foam::newoscillatingFixedValueFvPatchField<Type>:: updateCoeffs()’:
newoscillatingFixedValueFvPatchField.C:180:27: error: there are no arguments to ‘patch’ that depend on a template parameter, so a declaration of ‘patch’ must be available [-fpermissive]
newoscillatingFixedValueFvPatchField.C:180:27: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
newoscillatingFixedValueFvPatchField.C:184:38: error: there are no arguments to ‘patch’ that depend on a template parameter, so a declaration of ‘patch’ must be available [-fpermissive]
newoscillatingFixedValueFvPatchField.C: At global scope:
newoscillatingFixedValueFvPatchField.C:14:8: error: redefinition of ‘Foam::scalar Foam::newoscillatingFixedValueFvPatchField<Type>:: currentScale() const’
newoscillatingFixedValueFvPatchField.C:14:8: error: ‘Foam::scalar Foam::newoscillatingFixedValueFvPatchField<Type>:: currentScale() const’ previously declared here
newoscillatingFixedValueFvPatchField.C:27:1: error: redefinition of ‘Foam::newoscillatingFixedValueFvPatchField<Type>: :newoscillatingFixedValueFvPatchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&)’
newoscillatingFixedValueFvPatchField.C:27:1: error: ‘Foam::newoscillatingFixedValueFvPatchField<Type>: :newoscillatingFixedValueFvPatchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&)’ previously declared here
newoscillatingFixedValueFvPatchField.C:46:1: error: redefinition of ‘Foam::newoscillatingFixedValueFvPatchField<Type>: :newoscillatingFixedValueFvPatchField(const Foam::newoscillatingFixedValueFvPatchField<Type>&, const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::fvPatchFieldMapper&)’
newoscillatingFixedValueFvPatchField.C:46:1: error: ‘Foam::newoscillatingFixedValueFvPatchField<Type>: :newoscillatingFixedValueFvPatchField(const Foam::newoscillatingFixedValueFvPatchField<Type>&, const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::fvPatchFieldMapper&)’ previously declared here


can someone please help me what am i doing wrong .

Hisham June 9, 2012 08:28

Hi Shash

First of all I think the question should be under the development section of OF forum (to enhance probability of getting help). Nonetheless, you have a punch of problems:

1. You have not made your homework. You need to read/re-read chapter3 of the user manual.
2. You may need a little brushing on your C++ skills. This place is fantastic. You seem to declare parameters more than once and you need to read about templating a little bit the thing<thingy> thing :D
3. So you need to do the 1st 2 steps then you can have a question that can actually be answered :(

I wish these points help you (you'll know they help when you do them)!

Good luck
Hisham

shash June 10, 2012 05:51

2 Attachment(s)
hi hisham,

thanks for ur quick reply , i hav already read user guide and hav well enough knowledge of templating , i suppose there is some problem with installation of my compiler as -fpermissive is not enabled (shown in error). i am also attaching my modified code could you please hav a look and suggest the mistake.
my task is to develop velocity profile at inlet v=v0(1+ sin(t)) ;v0 being parabolic f(y).

Hisham June 10, 2012 05:59

Why not give the codedFixedValue BC a try. I'll try to look at your BC.

Edit: from the error message and before going into code. You have a object of a class that needs definition of a template. You also have re-declared several variables. The wmake utility makes life much easier (i.e. you do not need to change arguments to your compiler unless you need -pipe to speed compilation for example or you link to some library).

shash June 10, 2012 14:31

hi hisham,
I think coded bc will work in my case , i have read a blog by you and wrote this code snippet, not sure abt suntax of (ux,0,0)

inlet
{
type codedFixedValue;
value uniform (0 0 0);
redirectType para_osc_bc;
code
#{
fixedValueFvPatchVectorField myPatch (*this);
forAll(myPatch, celli)
{
myPatch[celli] =vector((.1*(1-(this->patch().Cf()[celli](1)*this->patch().Cf()[celli](1)/.01))*(1 + sin(this->db().time().value()))),0,0);
}
operator==(myPatch);
#};
}

Hisham June 10, 2012 14:44

Quote:

Originally Posted by shash (Post 365694)
hi hisham,
I think coded bc will work in my case , i have read a blog by you and wrote this code snippet, not sure abt suntax of (ux,0,0)

inlet
{
type codedFixedValue;
value uniform (0 0 0);
redirectType para_osc_bc;
code
#{
fixedValueFvPatchVectorField myPatch (*this);
forAll(myPatch, celli)
{
myPatch[celli] =vector((.1*(1-(this->patch().Cf()[celli](1)*this->patch().Cf()[celli](1)/.01))*(1 + sin(this->db().time().value()))),0,0);
}
operator==(myPatch);
#};
}

Take notice that: this->patch().Cf()[celli][1] is the y-coordinate of each cell face (@ patch) [0] is x and [2] is z.

To get the sin it is better (I think also necessary) to write it as:
Code:

Foam::sin(this->db().time().value())
The expression reads: Ux = (0.1*(1-Y*Y/0.01)*(1+sin(t)))
if this is what you aim then I guess you have done it or else you may need to define some variable or two to make the code easier to read ... e.g:
Code:

scalar helpVariable(1+Foam::sin(...));
Regards

shash June 10, 2012 15:45

hi,
added Foam::sin yet getting this error from it

/home/shash/OpenFOAM/shash-2.1.1/run/pitzDaily/0/U::boundaryField::inlet: In member function ‘virtual void Foam:: para_osc_bcFixedValueFvPatchVectorField::updateCoe ffs()’:
/home/shash/OpenFOAM/shash-2.1.1/run/pitzDaily/0/U::boundaryField::inlet:33:77: error: no match for call to ‘(const Foam::Vector<double>) (int)’
/home/shash/OpenFOAM/shash-2.1.1/run/pitzDaily/0/U::boundaryField::inlet:33:108: error: no match for call to ‘(const Foam::Vector<double>) (int)’

Hisham June 10, 2012 16:26

Quote:

Originally Posted by shash (Post 365707)
hi,
added Foam::sin yet getting this error from it

/home/shash/OpenFOAM/shash-2.1.1/run/pitzDaily/0/U::boundaryField::inlet: In member function ‘virtual void Foam:: para_osc_bcFixedValueFvPatchVectorField::updateCoe ffs()’:
/home/shash/OpenFOAM/shash-2.1.1/run/pitzDaily/0/U::boundaryField::inlet:33:77: error: no match for call to ‘(const Foam::Vector<double>) (int)’
/home/shash/OpenFOAM/shash-2.1.1/run/pitzDaily/0/U::boundaryField::inlet:33:108: error: no match for call to ‘(const Foam::Vector<double>) (int)’

Can you post the U file here

shash June 10, 2012 16:40

hi hisham,
my U file:

FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
inlet
{
type codedFixedValue;
value uniform (0 0 0); //$internalField;
redirectType awsum_bc;
code
#{
scalar U_0 = 0.1, c = .01 , a = 1, f = 1 ; // Values you need
fixedValueFvPatchField<vector> myPatch (*this);
forAll(myPatch, celli)
{
myPatch[celli] = Foam::vector((U_0*(1- this->patch().Cf()[celli](1) * this->patch().Cf()[celli](1)/c)*(1 + a * Foam::sin(f*this->db().time().value())),0,0);
}
operator==(myPatch);
#};
}


outlet
{
type zeroGradient;
}

upperWall
{
type fixedValue;
value uniform (0 0 0);
}

lowerWall
{
type fixedValue;
value uniform (0 0 0);
}

frontAndBack
{
type empty;
}
}

Hisham June 10, 2012 17:03

this->patch().Cf()[celli][1] instead of this->patch().Cf()[celli](1)

shash June 10, 2012 17:21

its working finally :) , THANK YOU HISHAM

Hisham June 10, 2012 17:23

You're welcome ... and good luck with your work :)


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