agustinvo |
November 6, 2015 11:07 |
Hello,
once this library is working, I want to implement a polynomial expression for alpha, in the same way I did it already for nu. It was just a copy and paste, and replacements of nu, viscosity ... for their equivalents.
But I get this error when I compile:
Code:
Making dependency list for source file thermalDiffusivityModels/TempPolyLaw/TempPolyLaw.C
thermalDiffusivityModels/TempPolyLaw/TempPolyLaw.dep:489: warning: overriding recipe for target `Make/linux64Gcc48DPOpt/TempPolyLaw.o'
viscosityModels/TempPolyLaw/TempPolyLaw.dep:489: warning: ignoring old recipe for target `Make/linux64Gcc48DPOpt/TempPolyLaw.o'
SOURCE=thermalDiffusivityModels/TempPolyLaw/TempPolyLaw.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/transportModels/incompressible/lnInclude -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/transportModels/incompressible/twoPhaseMixture/lnInclude -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/OpenFOAM/lnInclude -I/software/alternate/openfoam/fc20/2.3.1/OpenFOAM-2.3.1/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc48DPOpt/TempPolyLaw.o
TempPolyLaw.o:(.bss+0x18): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::typeName'
TempPolyLaw.o:(.bss+0x18): first defined here
TempPolyLaw.o:(.bss+0x10): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::debug'
TempPolyLaw.o:(.bss+0x10): first defined here
TempPolyLaw.o:(.bss+0x8): multiple definition of `Foam::thermalDiffusivityModels::addTempPolyLawToDebug_'
TempPolyLaw.o:(.bss+0x8): first defined here
TempPolyLaw.o:(.bss+0x0): multiple definition of `Foam::thermalDiffusivityModels::addTempPolyLawdictionaryConstructorTothermalDiffusivityModelTable_'
TempPolyLaw.o:(.bss+0x0): first defined here
TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::calcAlpha() const':
TempPolyLaw.C:(.text+0x880): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::calcAlpha() const'
TempPolyLaw.o:TempPolyLaw.C:(.text+0x880): first defined here
TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)':
TempPolyLaw.C:(.text+0xb60): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)'
TempPolyLaw.o:TempPolyLaw.C:(.text+0xb60): first defined here
TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)':
TempPolyLaw.C:(.text+0xb60): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&)'
TempPolyLaw.o:TempPolyLaw.C:(.text+0xb60): first defined here
TempPolyLaw.o: In function `Foam::thermalDiffusivityModels::TempPolyLaw::read(Foam::dictionary const&)':
TempPolyLaw.C:(.text+0x1100): multiple definition of `Foam::thermalDiffusivityModels::TempPolyLaw::read(Foam::dictionary const&)'
TempPolyLaw.o:TempPolyLaw.C:(.text+0x1100): first defined here
collect2: error: ld returned 1 exit status
make: *** [/students/phd_ea/villaortiz/OpenFOAM/villaortiz-2.3.1/platforms/linux64Gcc48DPOpt/lib/libmyIncompressibleTransportModels.so] Error 1
Has someone had this error before? It seems there is something already defined over there, but I am not able to see it. I tried to change the name of my model (TempPolyLaw) but it does not work.
file.C
Code:
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "TempPolyLaw.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace thermalDiffusivityModels
{
defineTypeNameAndDebug(TempPolyLaw, 0);
addToRunTimeSelectionTable
(
thermalDiffusivityModel,
TempPolyLaw,
dictionary
);
}
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::thermalDiffusivityModels::TempPolyLaw::calcAlpha() const
{
const volScalarField& T= U_.mesh().lookupObject<volScalarField>("T");
//const volScalarField& rho= U_.mesh().lookupObject<volScalarField>("rho");
return (base_+slope_*T+slope2_*pow(T,2.0)+slope3_*pow(T,3.0));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::thermalDiffusivityModels::TempPolyLaw::TempPolyLaw
(
const word& name,
const dictionary& thermalDiffusivityProperties,
const volVectorField& U,
const surfaceScalarField& phi
)
:
thermalDiffusivityModel(name, thermalDiffusivityProperties, U, phi),
TempPolyLawCoeffs_(thermalDiffusivityProperties.subDict(typeName + "Coeffs")),
base_(TempPolyLawCoeffs_.lookup("base")),
slope_(TempPolyLawCoeffs_.lookup("slope")),
slope2_(TempPolyLawCoeffs_.lookup("slope2")),
slope3_(TempPolyLawCoeffs_.lookup("slope3")),
alpha_
(
IOobject
(
name,
U_.time().timeName(),
U_.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
calcAlpha()
)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::thermalDiffusivityModels::TempPolyLaw::read
(
const dictionary& thermalDiffusivityProperties
)
{
thermalDiffusivityModel::read(thermalDiffusivityProperties);
TempPolyLawCoeffs_ = thermalDiffusivityProperties.subDict(typeName + "Coeffs");
TempPolyLawCoeffs_.lookup("base") >> base_;
TempPolyLawCoeffs_.lookup("slope") >> slope_;
TempPolyLawCoeffs_.lookup("slope2") >> slope2_;
TempPolyLawCoeffs_.lookup("slope3") >> slope3_;
return true;
}
// ************************************************************************* //
file.H
Code:
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Class
Foam::viscosityModels::TempPolyLaw
Description
Standard polynomial-law non-Newtonian viscosity model.
mu=a0+a1*T+a2*T2+...
SourceFiles
TempPolyLaw.C
\*---------------------------------------------------------------------------*/
#ifndef TempPolyLaw_H
#define TempPolyLaw_H
#include "thermalDiffusivityModel.H"
#include "dimensionedScalar.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace thermalDiffusivityModels
{
/*---------------------------------------------------------------------------*\
Class TempPolyLaw Declaration
\*---------------------------------------------------------------------------*/
class TempPolyLaw
:
public thermalDiffusivityModel
{
// Private data
dictionary TempPolyLawCoeffs_;
dimensionedScalar base_;
dimensionedScalar slope_;
dimensionedScalar slope2_;
dimensionedScalar slope3_;
volScalarField alpha_;
// Private Member Functions
//- Calculate and return the laminar viscosity
tmp<volScalarField> calcAlpha() const;
public:
//- Runtime type information
TypeName("TempPolyLaw");
// Constructors
//- Construct from components
TempPolyLaw
(
const word& name,
const dictionary& thermalDiffusivityProperties,
const volVectorField& U,
const surfaceScalarField& phi
);
//- Destructor
~TempPolyLaw()
{}
// Member Functions
//- Return the laminar viscosity
tmp<volScalarField> alpha() const
{
return alpha_;
}
//- Return the laminar viscosity for patch
tmp<scalarField> alpha(const label patchi) const
{
return alpha_.boundaryField()[patchi];
}
//- Correct the laminar viscosity
void correct()
{
alpha_ = calcAlpha();
}
//- Read transportProperties dictionary
bool read(const dictionary& thermalDiffusivityProperties);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace viscosityModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
SOLVED
I was using the same fileName.C for the polynomial of nu() and alpha, so there was a conflict with the internal functions (the only difference between both files are the viscosity and thermal diffusivity references, not the C++ and functions ones). I changed the names, so I have
Quote:
viscosityModels/TempPolyLaw/TempPolyLaw.C
thermalDiffusivityModels/TempPolyLaw/thermalTempPolyLaw.C
|
and they are present in corresponding *.o files. Before they have the same *.o file name.
Now it is possible to implement the same functions for each diffusion term (nu and alpha), just be sure the names are different!
|