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/)
-   -   Creating a 2D AMR copying from dynamicRefineFvMesh (https://www.cfd-online.com/Forums/openfoam-programming-development/129425-creating-2d-amr-copying-dynamicrefinefvmesh.html)

chrisb2244 February 5, 2014 01:05

Creating a 2D AMR copying from dynamicRefineFvMesh
 
So, like several other people in this forum, I'm looking at how to try and implement at 2D adaptive mesh refinement.

I'm using the document at http://publications.lib.chalmers.se/...173/174173.pdf for direction, and am currently in the first instance attempting to copy and replace the names of my dynamicRefineFvMesh.{C,H} files. I have so far made no changes to what the files actually do - I'm only seeking to use wmake and get myInterDyMFoam to use the dynamicRefineFvMeshHexRef4.{C,H} (which still depend on HexRef8) to compile and run.

When I try and run the solver on the tutorial damBreakWithObstacle case from the interDyMFoam directory, I get

Code:

--> FOAM FATAL ERROR:
Unknown dynamicFvMesh type dynamicRefineFvMeshHexRef4

Valid dynamicFvMesh types are :

8
(
dynamicInkJetFvMesh
dynamicMotionSolverFvMesh
dynamicRefineFvMesh
movingConeTopoFvMesh
multiSolidBodyMotionFvMesh
rawTopoChangerFvMesh
solidBodyMotionFvMesh
staticFvMesh
)


    From function dynamicFvMesh::New(const IOobject&)
    in file dynamicFvMesh/dynamicFvMeshNew.C at line 81.

FOAM exiting

Looking through dynamicFvMeshNew.C indicates that it opens a library file to get this list of available mesh types. I can avoid this error, and trigger a different one, if I insert a line like

Code:

dynamicFvMeshLibs dynamicRefineFvMeshHexRef4;
into my dynamicMeshDict, however then I have to define dynamicRefineFvMeshHexRef4 as an IOobject, it seems. This line (or rather, its equivalent) is not present in any of the pre-existing dynamicMeshDicts for other mesh types, but I am unable to find where they are defined/read from so as to model my own entry after them.

My first question is, are these meshes defined in libdynamicFvMesh.so, or some similar libXYZ.so, and if so, can I do anything about this? If they are defined somewhere else, could someone please point me in their direction?

It is my current assumption that they are held in a lib.so file, and that I will need to define the mesh type in some way inside my dynamicMeshDict file (or perhaps create copies of many more files to my solver, and make (hopefully minor?) modifications) so as to allow it to read a new mesh type.

Please let me know what I should be trying to do.

chrisb2244 February 5, 2014 01:17

The parts of the files which I expect to be relevant (although clearly I'm wrong) now read:

dynamicRefineFvMeshHexRef4.C
Code:

namespace Foam
{
    defineTypeNameAndDebug(dynamicRefineFvMeshHexRef4, 0);
    addToRunTimeSelectionTable(dynamicFvMesh, dynamicRefineFvMeshHexRef4, IOobject);
}

dynamicRefineFvMeshHexRef4.H
Code:


class dynamicRefineFvMeshHexRef4
:
    public dynamicFvMesh
{
protected:

        //- Mesh cutting engine
        hexRef8 meshCutter_;
...

public:

 //- Runtime type information
    TypeName("dynamicRefineFvMeshHexRef4");
    // Constructors

        //- Construct from IOobject
        explicit dynamicRefineFvMeshHexRef4(const IOobject& io);


    //- Destructor
    virtual ~dynamicRefineFvMeshHexRef4();


    // Member Functions

        //- Direct access to the refinement engine
        const hexRef8& meshCutter() const
        {
            return meshCutter_;
        }
...


chrisb2244 February 5, 2014 02:00

On a side note, and possibly (probably?) related to this - my solver, and the interDyMFoam default solver, have no dependence on the file dynamicFvMeshNew.C, even though it looks quite a lot like the function contained within is called - createDynamicFvMesh.H (which is #included in interDyMFoam.C) calls

Code:

autoPtr<dynamicFvMesh> meshPtr
    (
        dynamicFvMesh::New
        (
            IOobject
            (
                dynamicFvMesh::defaultRegion,
                runTime.timeName(),
                runTime,
                IOobject::MUST_READ
            )
        )
    );

and dynamicFvMesh.{H,C} have no mention of a New.

dynamicFvMeshNew.C opens with some includes, including to a "dlLibraryTable.H", which has an #ifdef NoRepository #include ...TemplateTable, which would seem to be required for the number of arguments being passed later in dynamicFvMeshNew.C
Code:

const_cast<Time&>(io.time()).libs().open
    (
        dict,
        "dynamicFvMeshLibs",
        IOobjectConstructorTablePtr_
    );

Side side note : Where is 'NoRepository' defined? A grep search gave me nothing, but lots of files have an #ifdef NoRepository #include ... block...

Back to the point, dynamicFvMeshNew.C then goes on to iterate through a list of libraries (or something?) returned by the libs().open call in the code above, and when it reaches the end without finding dynamicRefineFvMeshHexRef4, it outputs the error in the initial post (Valid dynamicFvMesh types are : ... "

Any thoughts much appreciated

chrisb2244 February 5, 2014 03:08

Seems I can create an additional library using wmake libso and then link to that in my dynamicMeshDict file. Working on that now.

chrisb2244 February 5, 2014 03:46

Had to move a few things around and change some variables in Make/{files,options} but got wmake libso to work. Linking the library to the solver allowed me to remove the line from controlDict, and allows the case to 'work', so now I can work on changing the library and/or solver.

Apologies for 5 posts of my talking to myself, but seems I can't delete the thread, and maybe others are as stupid as I am and will find this useful.

bigphil December 30, 2014 12:03

Hi Christian,

Were you successful in creating a 2-D version of dynamicRefineFvMesh?

Philip


All times are GMT -4. The time now is 10:31.