CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Problem with compilation of new Boundary Conditions (http://www.cfd-online.com/Forums/openfoam-programming-development/108349-problem-compilation-new-boundary-conditions.html)

arvind3008 October 20, 2012 16:55

Problem with compilation of new Boundary Conditions
 
2 Attachment(s)
Dear readers

I am new to Open foam, so please bear with me if the question is trivial. I am trying to create new BC based on advectiveFvPatchField and using rhoPimpleFoam solver.

Following standard procedure, I copied the solver files and advectiveFvPatchField.h and .C to a folder and tried to compile I am getting the following error:

Making dependency list for source file advectiveFvPatchField.C
Making dependency list for source file rhoPimpleFoam.C
SOURCE=rhoPimpleFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam211/src/turbulenceModels/compressible/turbulenceModel -I/opt/openfoam211/src/finiteVolume/cfdTools -I/opt/openfoam211/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/rhoPimpleFoam.o
SOURCE=advectiveFvPatchField.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam211/src/turbulenceModels/compressible/turbulenceModel -I/opt/openfoam211/src/finiteVolume/cfdTools -I/opt/openfoam211/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/advectiveFvPatchField.o
advectiveFvPatchField.C:38:1: error: redefinition of ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&)’
advectiveFvPatchField.C:38:1: error: ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&)’ previously declared here
advectiveFvPatchField.C:57:1: error: redefinition of ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::advectiveFvPatchField<Type1>&, const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::fvPatchFieldMapper&)’
advectiveFvPatchField.C:57:1: error: ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::advectiveFvPatchField<Type1>&, const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::fvPatchFieldMapper&)’ previously declared here
advectiveFvPatchField.C:74:1: error: redefinition of ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::dictionary&)’
advectiveFvPatchField.C:74:1: error: ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::dictionary&)’ previously declared here
advectiveFvPatchField.C:126:1: error: redefinition of ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::advectiveFvPatchField<Type1>&)’
advectiveFvPatchField.C:126:1: error: ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::advectiveFvPatchField<Type1>&)’ previously declared here
advectiveFvPatchField.C:140:1: error: redefinition of ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::advectiveFvPatchField<Type1>&, const Foam::DimensionedField<Type, Foam::volMesh>&)’
advectiveFvPatchField.C:140:1: error: ‘Foam::advectiveFvPatchField<Type1>::advectiveFvPa tchField(const Foam::advectiveFvPatchField<Type1>&, const Foam::DimensionedField<Type, Foam::volMesh>&)’ previously declared here
advectiveFvPatchField.C:158:1: error: redefinition of ‘Foam::tmp<Foam::Field<double> > Foam::advectiveFvPatchField<Type1>::advectionSpeed () const’
advectiveFvPatchField.C:158:1: error: ‘virtual Foam::tmp<Foam::Field<double> > Foam::advectiveFvPatchField<Type1>::advectionSpeed () const’ previously declared here
advectiveFvPatchField.C:188:6: error: redefinition of ‘void Foam::advectiveFvPatchField<Type1>::updateCoeffs() ’
advectiveFvPatchField.C:188:6: error: ‘virtual void Foam::advectiveFvPatchField<Type1>::updateCoeffs() ’ previously declared here
advectiveFvPatchField.C:303:6: error: redefinition of ‘void Foam::advectiveFvPatchField<Type1>::write(Foam::Os tream&) const’
advectiveFvPatchField.C:303:6: error: ‘virtual void Foam::advectiveFvPatchField<Type1>::write(Foam::Os tream&) const’ previously declared here
make: *** [Make/linux64GccDPOpt/advectiveFvPatchField.o] Error 1

I think the error has more to do with C++ template definitions. I tried reading up on it and tried a couple of things by changing the template type name etc... but nothing has worked so far. Any help would be appreciated. I have attached the relevant files.

This is my make file settings:
rhoPimpleFoam.C
advectiveFvPatchField.C
EXE = $(FOAM_USER_APPBIN)/myRhoPimpleFoam

Thank you
arvind3008

marupio October 22, 2012 09:57

This is a template problem. I think you need to create another file to instantiate the types, and only include that one. See other fvPatchFields... the ones that have an extra couple of files ending with "s". (Also, it is generally undesirable to tie a solver to a boundary condition... but I've done it myself.)

arvind3008 October 22, 2012 16:13

Thanks That solved the problem :).. although I am not sure why this is the case:confused:

Also, I am unable to compile without a solver as I get the error of unreferenced function main() which is true as there is not main function. I assume that in this case we can compile only as a static library then?

marupio October 22, 2012 17:08

You have to compile it to a static library with "wmake libso". You can link your solver to it directly if you want when you compile that, or you could load it with the controlDict at runTime.

-Dave


All times are GMT -4. The time now is 09:49.