ladybug-tools / butterfly

:butterfly: A light python API for creating and running OpenFoam cases for CFD simulation.
http://ladybug-tools.github.io/butterfly.html
GNU General Public License v3.0
249 stars 71 forks source link

Using pure 2D mesh #323

Open gamemakerh opened 6 years ago

gamemakerh commented 6 years ago

Hi. long time I did not saw any activity. maybe this is over ?

Still I have some questions / suggestions / requirements.

At this moment BF have 2D mesh ability. But actually what BF offers is pseudo 2D mesh. Don't you think this would be more convievent using pure 2D mesh ? Because now you have to waste huge amounts of computational resources using 2D mesh because it's still 3D'ish ( because of snappyHexMesh).

I think BF should obtain pure 2D mesh feature implementing extrudeMesh function. This utility feature basically takes one patch (symmetry) and extrudes by one cell. all cells of different level became only one cell in Z direction. you can save cell count in order of magnitudes.

The workflow would be like this

  1. blockMesh
  2. snappyHexMesh
  3. extrudeMesh
  4. solver

To implement Extrude Mesh functionality you only need to provide extrudeMeshDict

I'm as king this, because some times I need refinement levels up to 11 (to capture small features) and using 3D'ish mesh is basically waste of time and resources. after manual implementation of extrudeMesh functionality I got way better results

TheodoreGalanos commented 6 years ago

Hi @gamemakerh first of all yes, Butterfly is certainly a live project, one in progress as you can see.

extrudeMesh is one of the amazing functionalities in OF that we could allow for. I've been thinking about it but due to the fact I'm not doing many 2D simulations it never moved forward.

I think it might take a bit more than allowing a dictionary, given the fair number of choices a user can make when extruding. Maybe a separate component would be in order for this. Let us know if you would like to help develop this. In the meantime I'll add it to the enhancements!

Kind regards, Theodore.

gamemakerh commented 6 years ago

Nice to hear that @TheodoreGalanos

I would like to share my implementation of pure 2D mesh.

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  5.x                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      extrudeMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// What to extrude:
//      patch   : from patch of another case ('sourceCase')
//      mesh    : as above but with original case included
//      surface : from externally read surface

//constructFrom mesh;
constructFrom patch; //----------------------------
//constructFrom surface;

// If construct from patch/mesh:
sourceCase "."; //--------------------------------------------
sourcePatches (Symmetry_0); //-----------------++++++++++++++++++
// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName Symmetry_1; //--------------+++++++++++++++++
// If construct from surface:
surface ""; //--------------------------------------

// Flip surface normals before usage. Valid only for extrude from surface or
// patch.
flipNormals false;

//- Linear extrusion in point-normal direction
extrudeModel        linearNormal; //------------------------------------------

//- Linear extrusion in specified direction
//extrudeModel        linearDirection;

//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
//extrudeModel        wedge;

//- Extrudes into sphere around (0 0 0)
//extrudeModel        linearRadial;

//- Extrudes into sphere around (0 0 0) with specified radii
//extrudeModel        radial;

//- Extrudes into sphere with grading according to pressure (atmospherics)
//extrudeModel        sigmaRadial;

nLayers             1;

expansionRatio      1.0;    //0.9;

wedgeCoeffs
{
    axisPt      (0 0.1 -0.05);
    axis        (-1 0 0);
    angle       360;  // For nLayers=1 assume symmetry so angle/2 on each side
}

linearNormalCoeffs
{
    thickness       0.45; //-------------------------------------------------------------
}

linearDirectionCoeffs
{
    direction       (0 1 0);
    thickness       0.05;
}

linearRadialCoeffs
{
    R               0.1;
    // Optional inner radius
    Rsurface        0.01;
}

radialCoeffs
{
    // Radii specified through interpolation table
    R               table ((0 0.01)(3 0.03)(10 0.1));
}

sigmaRadialCoeffs
{
    RTbyg           1;
    pRef            1;
    pStrat          1;
}

// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces false;   //true;

// Merge small edges. Fraction of bounding box.
mergeTol 0;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

The thing is that this implementation is actually very simple. you only need to describe 2 patches.

image

http://www.wolfdynamics.com/wiki/meshing_OF_SHM.pdf

Only one problem is that BF create case 2D block using different approach making those Pseudo 2D cases possible. My point is I can't create pure 2D mesh using mesh generated from BF because it creates not the "symmetry (empty)" boundaries but "boundingbox_empty.

Now I'm trying to implement pure 2D mesh using BF 2D mesh approach, but unfortunately BF used to "delete" symmetry patches. image image

You need to create faceSets when extract them and create new patches. everything becomes very complex.

Up to this moment I'm still trying to implement pure 2D mesh using BF 2D mesh. I was successfully converted BF 3D mesh into pure 2D mesh, but problem is you have to use at least 2 cells across Z axis ant this doubles cell count in snappyHexMesh stage.