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/)
-   -   Run Time Selection table pointer error (https://www.cfd-online.com/Forums/openfoam-programming-development/180173-run-time-selection-table-pointer-error.html)

jmf November 18, 2016 06:31

Using Run Time Selection : table pointer error at run time
 
Hi

I attempt to write a custom solid body motion solver. The external force management is massively inspired from "sixDoFRigidBodyMotion" (many thanks to the author), and uses the Run Time Selection mechanism.

The problem is that the RTS table pointer is not found and throw an error at run time.

Here's the skeleton of my code and the run error message.

I've been struggling with that bug for days.
I probably miss something big, too big to be seen ?

Dear RTS specialists, I would appreciate your help so much

Jean-Michel

Code:

/* solver.C
 */
    Info<< "Create bodyMotion" << nl << endl;
    bodyMotion motion(mesh, bodyFluidDict);

Code:

/* bodyMotion.C
 */

// * * * * * * * * * * Constructors * * * * * * * * *

Foam::bodyMotion::bodyMotion
(
    fvMesh& mesh,
    const dictionary& bodyFluidDict
)
{
    // Add all the external actions
    createAllExternActions(bodyFluidDict);
}

// * * * * * * * * * * Public * * * * * * * * * * *

void Foam::bodyMotion::createAllExternActions
(
    const dictionary& bodyFluidDict
)
{
    if (bodyFluidDict.found("externalActions"))
    {
        const dictionary& actionsDict = bodyFluidDict.subDict("externalActions");
        label iAction = 0;
        externActionsPtrList_.setSize(actionsDict.size());

        // Loop for reading each sub-sub-dictionary of actionsDict
        forAllConstIter(IDLList<entry>, actionsDict, iter)
        {
            if (iter().isDict())
            {
                externActionsPtrList_.set
                (
                    iAction++,
                    bodyExternActions::New
                    (
                        iter().keyword(),
                        iter().dict()
                    )
                );
            }
        }
        externActionsPtrList_.setSize(iAction);
    }
}

Code:

/* bodyExternActionsNew.C
 * Copy from sixDoFRigidBodyMotionRestraint::New()
 */

Foam::autoPtr<Foam::bodyExternActions> Foam::bodyExternActions::New
(
    const word& customName,
    const dictionary& actionDict
)
{
    const word actionType
    (
        actionDict.lookup("externalAction")
    );

    if (!dictionaryConstructorTablePtr_)
    {
        FatalErrorIn
        (
            "bodyExternActions::New(customName, actionDict)"
        )
        << exit(FatalError);
///////////////////// FATAL ERROR /////////////////////////////////////////////
    }
}

Code:

/*  bodyExternActions.C
 *  Copy from sixDoFRigidBodyMotionRestraint.C
 */

#include "bodyExternActions.H"

namespace Foam
{
    defineTypeNameAndDebug(bodyExternActions, 0);
    defineRunTimeSelectionTable(bodyExternActions, dictionary);
}

Code:

/*  bodyExternActions.H:
 *  Copy from sixDoFRigidBodyMotionRestraint.H
 */

// Forward declaration of classes
class bodyMotion;

class bodyExternActions
{

public:
    //- Runtime type information
    TypeName("bodyExternActions");

    // Declare run-time constructor selection table
        declareRunTimeSelectionTable
        (
            autoPtr,
            bodyExternActions,
            dictionary,
            (const word& name, const dictionary& actionsDict),
            (name, actionsDict)
        );

    // Constructors
        //- Construct from the actionsDict dictionary
        bodyExternActions
        (
            const word& name,
            const dictionary& actionsDict
        );

        //- Construct and return a clone
        virtual autoPtr<bodyExternActions> clone() const = 0;

    // Selectors
        //- Select constructed from the actionsDict dictionary
        static autoPtr<bodyExternActions> New
        (
            const word& name,
            const dictionary& actionsDict
        );
};
}

Code:

/* bodySpring.C
 * Copy from linearSpring.C
 */
 
#include "bodySpring.H"
#include "addToRunTimeSelectionTable.H"
#include "bodyMotion.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace bodyExternActions
{
    defineTypeNameAndDebug(bodySpring, 0);

    addToRunTimeSelectionTable
    (
        bodyExternActions,
        bodySpring,
        dictionary
    );
}
}

Code:

/* bodyFluidDict
 */
externalActions
{
    spring1
    {
        externalAction      bodySpring;
        anchor              ( 0.0  -0.0    0.0);
        refAttachmentPt    (-0.0    0.0    0.0);
        stiffness          1000;
        damping            1000;
        restLength          0;
    }
}

The run error message :

Code:

Create bodyMotion

> Creates new bodyExternActions:
spring1
{
    externalAction  bodySpring;
    anchor          ( 0 -0 0 );
    refAttachmentPt ( -0 0 0 );
    stiffness      1000;
    damping        1000;
    restLength      0;
}

#0  Foam::error::printStack(Foam::Ostream&) at ~/OpenFOAM/OpenFOAM-2.4.0/src/OSspecific/POSIX/printStack.C:219
#1  Foam::sigSegv::sigHandler(int) at ~/OpenFOAM/OpenFOAM-2.4.0/src/OSspecific/POSIX/signals/sigSegv.C:56
#2  ? in "/lib64/libc.so.6"
#3  Foam::HashTable<Foam::autoPtr<Foam::bodyExternActions> (*)(Foam::word const&, Foam::dictionary const&), Foam::word, Foam::string::hash>::find(Foam::word const&) at ~/OpenFOAM/OpenFOAM-2.4.0/src/OpenFOAM/lnInclude/HashTable.C:143
#4  Foam::bodyExternActions::New(Foam::word const&, Foam::dictionary const&) at ~/OpenFOAM/OpenFOAM-2.4.0/src/bodyFluid/bodyMotion/bodyExternActionsNew.C:39
#5  Foam::bodyMotion::createAllExternActions(Foam::dictionary const&) at ~/OpenFOAM/OpenFOAM-2.4.0/src/bodyFluid/bodyMotion/bodyMotion.C:258 (discriminator 1)
#6  Foam::bodyMotion::bodyMotion(Foam::fvMesh&, Foam::dictionary const&) at ~/OpenFOAM/OpenFOAM-2.4.0/src/bodyFluid/bodyMotion/bodyMotion.C:73
#7  ? at ~/OpenFOAM/OpenFOAM-2.4.0/applications/solvers/multiphase/bodyWaveFoam/bodyWaveFoam.C:47
#8  __libc_start_main in "/lib64/libc.so.6"
#9  ? at /home/abuild/rpmbuild/BUILD/glibc-2.18/csu/../sysdeps/x86_64/start.S:125



All times are GMT -4. The time now is 23:28.