CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Problem while compiling a turbulence model in OF 4.1

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By clapointe

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 11, 2018, 10:38
Default Problem while compiling a turbulence model in OF 4.1
  #1
Member
 
Alejandro Valeije
Join Date: Nov 2014
Location: Spain
Posts: 52
Rep Power: 11
alexvaleije is on a distinguished road
Hi everybody,

I am having some problems compiling a modified k-epsilon turbulence model in OpenFoam 4.1

To be sure I'm not writing anything wrong in the files, I have copied the original files of the model and I have changed all of the "kEpsilon" terms for "mykEpsilon" and nothing else.

My Make/files has the following:

Quote:
mykEpsilon.C

LIB = $(FOAM_USER_LIBBIN)/libmyIncompressibleRASModels
and my Make/options is:

Quote:
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude

LIB_LIBS = \
-lfiniteVolume \
-lmeshTools
Despite of that, the error when I try to compile is this:

Quote:
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam4/src/finiteVolume/lnInclude -I/opt/openfoam4/src/meshTools/lnInclude -I/opt/openfoam4/src/TurbulenceModels/turbulenceModels/lnInclude -IlnInclude -I. -I/opt/openfoam4/src/OpenFOAM/lnInclude -I/opt/openfoam4/src/OSspecific/POSIX/lnInclude -fPIC -c mykEpsilon.C -o Make/linux64GccDPInt32Opt/mykEpsilon.o
mykEpsilon.C:40:6: error: redefinition of \u2018void Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :correctNut()\u2019
void mykEpsilon<BasicTurbulenceModel>::correctNut()
^
In file included from mykEpsilon.H:213:0,
from mykEpsilon.C:26:
mykEpsilon.C:40:6: error: \u2018virtual void Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :correctNut()\u2019 previously declared here
void mykEpsilon<BasicTurbulenceModel>::correctNut()
^
mykEpsilon.C:51:21: error: redefinition of \u2018Foam::tmp<Foam::fvMatrix<double> > Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :kSource() const\u2019
tmp<fvScalarMatrix> mykEpsilon<BasicTurbulenceModel>::kSource() const
^
In file included from mykEpsilon.H:213:0,
from mykEpsilon.C:26:
mykEpsilon.C:51:21: error: \u2018virtual Foam::tmp<Foam::fvMatrix<double> > Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :kSource() const\u2019 previously declared here
tmp<fvScalarMatrix> mykEpsilon<BasicTurbulenceModel>::kSource() const
^
mykEpsilon.C:66:21: error: redefinition of \u2018Foam::tmp<Foam::fvMatrix<double> > Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :epsilonSource() const\u2019
tmp<fvScalarMatrix> mykEpsilon<BasicTurbulenceModel>::epsilonSource() const
^
In file included from mykEpsilon.H:213:0,
from mykEpsilon.C:26:
mykEpsilon.C:66:21: error: \u2018virtual Foam::tmp<Foam::fvMatrix<double> > Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :epsilonSource() const\u2019 previously declared here
tmp<fvScalarMatrix> mykEpsilon<BasicTurbulenceModel>::epsilonSource() const
^
mykEpsilon.C:83:1: error: redefinition of \u2018Foam::RASModels::mykEpsilon<BasicTurbulenceM odel>::mykEpsilon(const alphaField&, const rhoField&, const volVectorField&, const surfaceScalarField&, const surfaceScalarField&, const transportModel&, const Foam::word&, const Foam::word&)\u2019
mykEpsilon<BasicTurbulenceModel>::mykEpsilon
^
In file included from mykEpsilon.H:213:0,
from mykEpsilon.C:26:
mykEpsilon.C:83:1: error: \u2018Foam::RASModels::mykEpsilon<BasicTurbulenceM odel>::mykEpsilon(const alphaField&, const rhoField&, const volVectorField&, const surfaceScalarField&, const surfaceScalarField&, const transportModel&, const Foam::word&, const Foam::word&)\u2019 previously declared here
mykEpsilon<BasicTurbulenceModel>::mykEpsilon
^
mykEpsilon.C:200:6: error: redefinition of \u2018bool Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :read()\u2019
bool mykEpsilon<BasicTurbulenceModel>::read()
^
In file included from mykEpsilon.H:213:0,
from mykEpsilon.C:26:
mykEpsilon.C:200:6: error: \u2018virtual bool Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :read()\u2019 previously declared here
bool mykEpsilon<BasicTurbulenceModel>::read()
^
mykEpsilon.C:221:6: error: redefinition of \u2018void Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :correct()\u2019
void mykEpsilon<BasicTurbulenceModel>::correct()
^
In file included from mykEpsilon.H:213:0,
from mykEpsilon.C:26:
mykEpsilon.C:221:6: error: \u2018virtual void Foam::RASModels::mykEpsilon<BasicTurbulenceModel>: :correct()\u2019 previously declared here
void mykEpsilon<BasicTurbulenceModel>::correct()
^
make: *** [Make/linux64GccDPInt32Opt/mykEpsilon.o] Error 1
Since I have not redefined anything, I don't know why is this happening. Could anybody help me with this?
Thank you very much!!
Alex
alexvaleije is offline   Reply With Quote

Old   May 14, 2018, 00:13
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 14
clapointe is on a distinguished road
I've been able to compile my own turbulence models by creating the necessary .H and .C files. Then using an (eg) makeTurbulenceModel.C to create the new library. I've included example code for a new les model in 4.x -- it will hopefully work for you in 4.1. I've found that I get warnings at run time about various duplicates, but the new model works (once the new library is included in the control dict). I believe I originally pulled code to do this from here : http://hassankassem.me/posts/newturbulencemodel/.

Code:
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2013-2016 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.
    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/

#include "CompressibleTurbulenceModel.H"
#include "compressibleTransportModel.H"
#include "fluidThermo.H"
#include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H"

#include "ThermalDiffusivity.H"
#include "EddyDiffusivity.H"

#include "laminar.H"
#include "RASModel.H"
#include "LESModel.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

makeBaseTurbulenceModel
(
    geometricOneField,
    volScalarField,
    compressibleTurbulenceModel,
    CompressibleTurbulenceModel,
    ThermalDiffusivity,
    fluidThermo
);

#define makeLESModel(Type)                                                     \
    makeTemplatedTurbulenceModel                                               \
    (fluidThermoCompressibleTurbulenceModel, LES, Type)

// -------------------------------------------------------------------------- //
// LES models
// -------------------------------------------------------------------------- //

#include "customModel.H"
makeLESModel(customModel);

// ************************************************************************* //
alexvaleije likes this.
clapointe is offline   Reply With Quote

Old   May 14, 2018, 12:26
Default
  #3
Member
 
Alejandro Valeije
Join Date: Nov 2014
Location: Spain
Posts: 52
Rep Power: 11
alexvaleije is on a distinguished road
Thank you very much!!!

When I first read that post you referenced I didn't understand it, but now thanks to you and reading it calmly, I could be able to compile my model.

I had to do some minor changes, though, because I haven't copied the entire turbulence library, so I had to change some of the directions of the includes, but the important thing is that it works

Thanks again
alexvaleije is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
about choosing Turbulence model for multiphase flow problem. Near FLUENT 5 April 11, 2019 04:24
Help Selecting Turbulence Model for VOF Problem NavierIsStoked FLUENT 0 November 1, 2013 11:27
K - epsilon VS SST turbulence model Maicol Main CFD Forum 0 November 30, 2012 16:25
problem compiling spalart allmaras model bababanamzdaalma OpenFOAM 0 April 4, 2012 20:13
Centrifugal Pump and Turbulence Model Michiel CFX 12 January 25, 2010 03:20


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