View Issue Details

IDProjectCategoryView StatusLast Update
0001684OpenFOAMBugpublic2015-05-21 16:12
Reporteruser281Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSUbuntuOS Version14.10
Summary0001684: Adding New basicChemistryModel Results in Crash at Compile
DescriptionYou cannot add an additional basic solid chemistry model for using other gasThermoPhysics models. It seems that each solid thermophysics type can only be used once in the expansion macro for basicSolidChemistryModels.C.
Steps To ReproduceInsert additional solid chemistry model for using constant gas thermophysics in basicSolidChemistryModels.C such that:

makeSolidChemistryModel
(
    solidChemistryModel,
    pyrolysisChemistryModel,
    basicSolidChemistryModel,
    hConstSolidThermoPhysics,
    constGasHThermoPhysics
);
TagsNo tags attached.

Activities

user281

2015-05-06 12:52

  ~0004722

Error message at compile time:

OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/className.H:103:38: error: redefinition of ‘const Foam::word Foam::solidChemistryModel<Foam::basicSolidChemistryModel, Foam::constIsoSolidTransport<Foam::species::thermo<Foam::hConstThermo<Foam::rhoConst<Foam::specie> >, Foam::sensibleEnthalpy> > >::typeName’

wyldckat

2015-05-17 20:32

updater  

basicSolidChemistryModels.C (3,215 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2013-2013 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/>.

InClass
    Foam::basicSolidChemistryModel

Description
    Creates solid chemistry model instances templated on the type of
    solid thermodynamics

\*---------------------------------------------------------------------------*/

#include "makeSolidChemistryModel.H"

#include "pyrolysisChemistryModel.H"
#include "basicSolidChemistryModel.H"
#include "solidChemistryModel.H"
#include "solidThermoPhysicsTypes.H"
#include "thermoPhysicsTypes.H"

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

namespace Foam
{
    // hConstSolidThermoPhysics
    makeCoreSolidChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hConstSolidThermoPhysics
    );

    makeSolidGasChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hConstSolidThermoPhysics,
        gasHThermoPhysics
    );

    makeSolidGasChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hConstSolidThermoPhysics,
        constGasHThermoPhysics
    );

    // hExponentialSolidThermoPhysics
    makeCoreSolidChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hExponentialSolidThermoPhysics
    );

    makeSolidGasChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hExponentialSolidThermoPhysics,
        gasHThermoPhysics
    );

    // hExpKappaConstSolidThermoPhysics ------------------------------------
    makeCoreSolidChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hExpKappaConstSolidThermoPhysics
    );

    makeSolidGasChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hExpKappaConstSolidThermoPhysics,
        gasHThermoPhysics
    );

}

// ************************************************************************* //
basicSolidChemistryModels.C (3,215 bytes)   

wyldckat

2015-05-17 20:33

updater  

makeSolidChemistryModel.H (3,442 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2012-2013 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/>.

Description
    Macros for instantiating solid chemistry models

\*---------------------------------------------------------------------------*/

#ifndef makeSolidChemistryModel_H
#define makeSolidChemistryModel_H

#include "addToRunTimeSelectionTable.H"
#include "solidChemistryModel.H"

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

namespace Foam
{

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

#define makeCoreSolidChemistryModel(sChemistry, SS, Comp, SThermo)            \
                                                                              \
    typedef sChemistry<Comp, SThermo> sChemistryl##Comp##SThermo;             \
                                                                              \
    defineTemplateTypeNameAndDebugWithName                                    \
    (                                                                         \
        sChemistryl##Comp##SThermo,                                           \
        (word(sChemistry::typeName_()) + "<"#Comp"," + SThermo::typeName() +  \
        + ">").c_str(),                                                       \
        0                                                                     \
    );

#define makeSolidGasChemistryModel(sChemistry, SS, Comp, SThermo, GThermo)    \
                                                                              \
    typedef SS<Comp, SThermo, GThermo> SS##Comp##SThermo##GThermo;            \
                                                                              \
    defineTemplateTypeNameAndDebugWithName                                    \
    (                                                                         \
        SS##Comp##SThermo##GThermo,                                           \
        (word(SS::typeName_()) + "<"#Comp"," + SThermo::typeName() + "," +    \
        GThermo::typeName() + ">").c_str(),                                   \
        0                                                                     \
    );
    

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

} // End namespace Foam

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

#endif

// ************************************************************************* //
makeSolidChemistryModel.H (3,442 bytes)   

wyldckat

2015-05-17 20:43

updater   ~0004770

@LWhitson2: You've diagnosed it right, the "core" solid typesets were being defined more than once, if we were to use the same solid model more than once.


@Henry:
Attached are these two files:
  - src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModels.C
  - src/thermophysicalModels/solidChemistryModel/makeSolidChemistryModel.H

they have been tested with a recent commit of 2.3.x (fdfc1248489).


The modified files provided are almost identical to the original files, except that instead of using "makeSolidChemistryModel", it now uses "makeCoreSolidChemistryModel" and "makeSolidGasChemistryModel", where the first one only needs to be used once per solid model and the second one can be used for any and all gas models.


This piece of code:

    makeSolidGasChemistryModel
    (
        solidChemistryModel,
        pyrolysisChemistryModel,
        basicSolidChemistryModel,
        hConstSolidThermoPhysics,
        constGasHThermoPhysics
    );

is essentially what LWhitson2 wants to use, therefore I don't know if you want to add it in to OpenFOAM 2.3.x/dev yet.

In addition, due to the somewhat big change to how these macros are used (the original macro simply disappears), I think it's best to apply this only to OpenFOAM-dev.


If this is to be added to 2.3.x as well, then I suggest that instead of these specific files, only the macro "makeSolidGasChemistryModel" is appended to "makeSolidChemistryModel.H" in 2.3.x and then the additional piece of code can be used safely, since the first call to "makeSolidChemistryModel" already defines the current models.

Best regards,
Bruno

henry

2015-05-17 22:10

manager   ~0004772

@Bruno: Thanks for the patch
I agree with your change but I had to rework it quite a bit for OpenFOAM-dev in which I had already substantially changed the macro:
commit 4aed56e67da8a340473154e1525a28aec355d662

I have only instantiated the original set of solid-gas models but the macros should now allow the instantiation of other combinations as you demonstrated.

user281

2015-05-21 15:35

  ~0004782

Thanks for looking into this guys. I will simply utilize my modified file that doesn't utilize the variable properties until -dev becomes the new -2.X.X. I hope my bug report helped as well.

Issue History

Date Modified Username Field Change
2015-05-06 12:52 user281 New Issue
2015-05-06 12:52 user281 Note Added: 0004722
2015-05-17 20:32 wyldckat File Added: basicSolidChemistryModels.C
2015-05-17 20:33 wyldckat File Added: makeSolidChemistryModel.H
2015-05-17 20:43 wyldckat Note Added: 0004770
2015-05-17 22:10 henry Note Added: 0004772
2015-05-21 15:35 user281 Note Added: 0004782
2015-05-21 16:12 henry Status new => resolved
2015-05-21 16:12 henry Resolution open => fixed
2015-05-21 16:12 henry Assigned To => henry