Skip to content

Create an OpenFOAM mesh with length 1 and n^3 cells without any IO

License

Notifications You must be signed in to change notification settings

JanGaertner/unitMesh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IO-Free Unit Mesh and Object Registry

For writing unit and/or integration tests in OpenFOAM it is useful to avoid IO calls as much as possible to be independent of the state of the case files. Creating a mesh and object registry without IO is however not possible by default in OpenFOAM. This repository provides a library with which a cubed, structured mesh with $n^3$ cells is created without any IO calls. Further, the library provides an independent object registry for creation of GeometricFields.

Compilation

Source your OpenFOAM environment and execute wmake in the src folder

Usage

#include "unitMesh.H"

int main()
{
    // start of your case
    ...

    // create the object uMesh with 10^3 cells
    // Optional: provide a path to where objects are written if write()
    //           is called. (Defaults to: rootPath='./')
    fileName rootPath = "PATH_TO_MY_TESTS";
    // Optional case name. By default empty
    word caseName;
    unitMesh uMesh(10,rootPath,caseName);
    
    // Get the mesh
    const fvMesh& mesh = uMesh.mesh();

    // Create a volScalarField on that mesh
    volScalarField testField
    (
        IOobject
        (
            "test",
            uMesh.runTime().timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh,
        dimensionedScalar("test",dimless,1E+5)
    );
}

About

Create an OpenFOAM mesh with length 1 and n^3 cells without any IO

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published