CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Native Meshers: blockMesh (http://www.cfd-online.com/Forums/openfoam-meshing-blockmesh/)
-   -   Generating nonuniform meshes with sizefunction (http://www.cfd-online.com/Forums/openfoam-meshing-blockmesh/61812-generating-nonuniform-meshes-sizefunction.html)

alberto April 12, 2006 15:13

Is it possible to generate non
 
Is it possible to generate non-uniform grids with nodes positioned following a distribution expressed by an analitical function?

Regards,
Alberto

hjasak April 12, 2006 15:17

Yes. Generate a uniform mesh
 
Yes. Generate a uniform mesh and then move the points :-)

Hrv

hjasak April 12, 2006 15:19

Yes. Generate a uniform mesh
 
Yes. Generate a uniform mesh and then move the points :-)

Hrv

alberto April 12, 2006 15:54

Do you mean with the moveMesh
 
Do you mean with the moveMesh solver?
I gave a look, but it doesn't seem I can use a user defined function but only linear, quadratic and exponential (I need an hyperbolic tangent).

Alberto

hjasak April 12, 2006 16:07

How about just doing a little
 
How about just doing a little custom code like this:

pointField newPoints = mesh.points();

forAll (newPoints, i)
{
// Your code here, calculate the point position
}

mesh.movePoints(newPoints);

mesh.write();


Hrv

alberto April 13, 2006 05:40

Thanks Hrv. It works! :-)
 
Thanks Hrv. It works! :-)

lr103476 March 28, 2007 05:43

Hi Alberto, Could you possi
 
Hi Alberto,

Could you possibly give an example of how to move the internal points of a uniform mesh? (Just the few lines within the forAll(newPoints,i){} )

Thanks, Frank

alberto March 29, 2007 14:49

Check your mail :-) A.
 
Check your mail :-)

A.

ehsanyasari December 23, 2007 12:41

Hi I want to solve channel f
 
Hi
I want to solve channel flow with hyperbolic mesh in one direction. i am new in O-F, how can i generate hyperbolic mesh in O-F?
Regards
Thanks for your help

alberto December 25, 2007 20:14

Hello Ehsan, the trick is exa
 
Hello Ehsan,
the trick is exactly the one explained by Hrvoje in this thread.

Create a uniform mesh, with the number of nodes you need in the three directions. Then write a small utility which:

- Reads the mesh (see how this is done in all solvers or mesh manipulation utilities).

- Does

pointField newPoints = mesh.points();

forAll (newPoints, i)
{
// Your code here, calculate the point position
}

mesh.movePoints(newPoints);

mesh.write();

using an analytical expression to relate the position of a node in a uniform grid to the new position (this is commonly done to generate grids for channel flow simulations).

Regards,
Alberto

ehsanyasari December 26, 2007 08:09

Hello Alberto Thank you very
 
Hello Alberto
Thank you very much for your guide.
Could you possibly give your code? And tell me where should I add this code?
Excuse me for my basic question because I am new in O_F.
Best regards

ehsanyasari December 30, 2007 14:02

hello Alberto Thank you very
 
hello Alberto
Thank you very much for your help,it works well.
Best Regards.

alberto December 31, 2007 14:09

You're welcome :-) Happy ne
 
You're welcome :-)

Happy new year,
Alberto

ehsanyasari January 4, 2008 11:56

Happw new year Alberto I am
 
Happw new year Alberto

I am going to run a channel395 with channel oodles solver, when i choose mixedsmagorinskey model and laplace filter, after some iteration, courant number diverged. but when i used simple filter it works,and also when i changed the mesh into uniform mesh, it works.

Do you have any idea about this problem?
Best Regards.

asaha January 9, 2008 00:55

Hello Alberto, Thanks for y
 
Hello Alberto,

Thanks for your hyperbolicSpacingChannel code. It works well with the given channel395 case.

Thanks.

johndeas July 15, 2009 12:14

Hi, I would like to output the polyMesh in a new time directory. I tried to add
Code:

runTime++;
   
mesh.write();

Unfortunately, at runtime I get:

Code:

Requested field U does not exist in the database


    From function Foam::fieldAverage::initialise()
    in file fieldAverage/fieldAverage.C at line 108.

FOAM exiting

So how can I output in a new time directory, the same way renumberMesh or snappyHexMesh do ?

johndeas July 15, 2009 12:25

To be more accurate, here is my new code

Code:

#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "transformField.H"

#include "fvMesh.H"

using namespace Foam;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//  Main program:

int main(int argc, char *argv[])
{
#  include "setRootCase.H"
#  include "createTime.H"
#  include "createMesh.H"

    pointField points=mesh.points();
   
    // Reading non-uniform grid parameters

    Info<< "Reading hyperbolicSpacingProperties\n" << endl;

    IOdictionary hyperbolicSpacingProperties
    (
        IOobject
        (
            "hyperbolicSpacingProperties",
            runTime.constant(),
            polyMesh::meshSubDir,
            runTime,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );

    Info<< "Reading A coefficient\n" << endl;

    dimensionedScalar A
    (
        hyperbolicSpacingProperties.lookup("A")
    );

    Info<< "A = " << A.value() << endl << endl;
   
    Info<< "Reading B coefficient\n" << endl;
   
    dimensionedScalar B
    (
        hyperbolicSpacingProperties.lookup("B")
    );
   
    Info<< "B = " << B.value() << endl << endl;
   
    // Adapting the grid
   
    points.replace(vector::Y, A.value()*points.component(vector::Y) +
                (1.0 - A.value())*(1.0 - Foam::tanh(B.value()*(1.0 -
                points.component(vector::Y)))/(Foam::tanh(B.value()))));

   
    // Setting the default precision of the points data to 10
    IOstream::defaultPrecision(10);
   
    mesh.movePoints(points);
   
    runTime++;
   
    mesh.write();
   
    //Writing points
    // Info << "Writing points into directory " << points.path() << nl << endl;
    // points.write();

    return(0);
}

It might be very naive, but I have still not completely grasped how data is organized in OpenFOAM.

henrik July 15, 2009 13:35

Dear John,

this error is not at all obvious ;-)

My bet is that you have a functionObject (fieldAverage to be precise) which I asking for U, but cannot find it.

Comment it and all will be fine - I hope :o

Henrik

johndeas July 15, 2009 15:23

I think one day I saw a piece of code which deactivated functionObjects, but I can not find it again. Do you see what I am refering to ?

-EDIT-

Just found it, it seems to be the
Code:

functionObjectlist::off()
method. I'll try this next time I have a grip on a work station.

henrik July 15, 2009 15:37

Dear John,

the keyword is "active_" ...

$FOAM_SRC/postProcessing/forces/lnInclude/forces.H

Henrik


All times are GMT -4. The time now is 08:58.