CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to change mesh size at runtime (https://www.cfd-online.com/Forums/openfoam/76089-how-change-mesh-size-runtime.html)

benk May 13, 2010 14:21

How to change mesh size at runtime
 
In my model I want to be able to specify the length scales of my mesh at run time so that I don't always have to change the blockMesh file and run "blockMesh -case xyz" just to change my mesh size.

So what I want to do is use blockmesh to make my mesh with unit length and then at runtime just multiply the grid spacing by my actual length. Is this possible to do?

I'm thinking that all I would have to do is find a way to multiply the mesh.deltaCoeffs() by my desired lengths. How can I do this?

eugene May 14, 2010 04:27

pointField newPoints = mesh.points();

//modify newPoints

mesh.movePoints(newPoints);

benk May 14, 2010 12:17

Thanks eugene, this worked in changing my mesh, but when I use it I'm now getting an error at runtime that says:

Code:

V0 is not available

    From function fvMesh::V0() const
    in file fvMesh/fvMeshGeometry.C at line 338.

fvMeshGeometry.C at line 338 looks like this:

Code:

const volScalarField::DimensionedInternalField& fvMesh::V0() const
{
    if (!V0Ptr_)
    {
        FatalErrorIn("fvMesh::V0() const")
            << "V0 is not available"
            << abort(FatalError);
    }

    return *V0Ptr_;
}

Any guidance on how to fix this?


PS. To change my mesh all I did was:
Code:

 
    pointField newPoints = mesh.points();
    forAll(newPoints,i) {
        newPoints[i].component(0) = newPoints[i].component(0)*Length0;
        newPoints[i].component(1) = newPoints[i].component(1)*Length1;
        newPoints[i].component(2) = newPoints[i].component(2)*Length2;
    }

    mesh.movePoints(newPoints);


eugene May 16, 2010 19:31

It appears the fvMesh now either requires that you set up a field V0 or a field meshPhi (in which case V0 is calculated automatically).

A bit irretating really. The only reasonable way to make this work without extra coding is to specify a flux field meshPhi in your starting time directory. Just use phi as a template and set everything to 0.


All times are GMT -4. The time now is 19:59.