CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [surface handling] Decomposing Faces after Extrude2DMesh with autoPatch (https://www.cfd-online.com/Forums/openfoam-meshing/239466-decomposing-faces-after-extrude2dmesh-autopatch.html)

JEBland November 7, 2021 18:07

Decomposing Faces after Extrude2DMesh with autoPatch
 
2 Attachment(s)
I've been attempting to mesh a 3d object based on 2d surface data (over the zx-plane) displaced through some distance (in the y-direction).



In attempting to follow the tutorial from Tobias Holzmann, https://www.youtube.com/watch?v=gP36M3IyCdU, I found that the default region for the faces doesn't break up the way I would hope. Naming, I get a "ring" between the original face an the extruded face without it being properly decomposed by autoPatch when I use it.



I did

  • symbolic link from my .pbj to the MeshedSurface.obj
  • extrude2DMesh MeshedSurface -overwrite
  • autoPatch {number}
Depending on the number I put in, I get different but always incorrect results. The file should have 36000 faces each for the original surface and extruded opposite face, two sides with 500 faces, and two sides with 900 faces... but the one side never seems to decompose correctly using autoPatch. For instance, autoPatch 45 gives me four patches: top and bottom along with one connecting side (72900 faces), three separate sides (with two 500 face patches and one 900 face patch). autoPatch 39 gives better results with 36900, 36000, 500, 900, 500 faces for their patches. But with autoPatch 37 and below, it starts decomposing the original and extruded surfaces and not the one side.



I would assume that is has to do with some faces on the surface being sharply inclined, but is there a good way to separate out the patches from the extrude2DMesh? I've attached the extrude2DMeshDict and surface.obj file in the .zip folder on this post.



Any guidance would be appreciated.

JEBland November 9, 2021 14:15

I think the topoSet and createPatch tools ought to be able to handle this even if the autoPatch tool . The normalToFace option in the topoSetDict should be able to create the necessary faces for the desired patches: https://www.openfoam.com/documentati...malToFace.html .


As I understand it, the normalToFace can inherit the faces from the "default" patch created by extrude2DMesh.



I'll update this thread with what I come up with either way (hopefully it'll work).

JEBland November 9, 2021 21:38

Okay, so I've attempted to follow a tutorial on using topoSet to create the desired patches from already defined faces, but my topoSetDict file produces an error despite the tutorial in $FOAM_TUTORIALS/mesh/foamyHexMesh/blob example having the same form for the boxToCell. The idea is to create boxes that exclude the faces of interest, copy the default patch to the <newPatchName> then remove the faces that undesired for that particular patch. Since the normals face the +/- x-direction and +/- z-direction, I've cleverly come up with a naming convention like xP for the positive x-direction face.



So the goal is to create a list of cells inside the box, then the faceSet of the faces on those cells in the cellSet, then subtract the faceSets from the default in order to produce a new patch. The goal will be to run the flow along the x- and z-directions, so keeping the names based on the normals to those patches is beneficial.



The error says "Not implemented". What does that mean?



Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  8
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      binary;
    class      dictionary;
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// bounding box is (-5 -0.34039 -9) (5 1.14071 9)
// size between patches on .obj is 0.1

actions
(
    {
        name        facesFromDefaultPatch;
        type        faceSet;
        action        new;
        source        patchToFace;
        sourceInfo   
        {
            name "default";
        }
    }
    // Create the faces for the four directions of interest
   
    { // xPFaceSet
    name    xPFaceSet;
    type    faceSet;
    action    new;   
    source    faceToFace;
    sourceInfo
    {
        set    facesFromDefaultPatch;
    }
    } // xPFaceSet
    { // xNFaceSet
    name    xNFaceSet;
    type    faceSet;
    action    new;   
    source    faceToFace;
    sourceInfo
    {
        set    facesFromDefaultPatch;
    }
    } // xNFaceSet
    { // zPFaceSet
    name    zPFaceSet;
    type    faceSet;
    action    new;
    source    faceToFace;
    sourceInfo
    {
        set    facesFromDefaultPatch;
    }
    } // zPFaceSet
    { // zNFaceSet
    name    zNFaceSet;
    type    faceSet;
    action    new;
    source    faceToFace;
    sourceInfo
    {
        set    facesFromDefaultPatch;
    }
    } // zNFaceSet
   
   
    ////
    //
    // Create negative cells to remove
    //
    ////
// bounding box is (-5 -0.34039 -9) (5 1.14071 9)
// size between patches on .obj is 0.1   
    {
        name        xPNegCellSet;
        type        cellSet;
        action        new;
        source        boxToCell;
        sourceInfo   
        {
            box (-10 -2 -10)(4.99 2 10) ;
        }
    }
   
    {
        name        xNNegCellSet;
        type        cellSet;
        action        new;
        source        boxToCell;
        sourceInfo   
        {
            box (-4.99 -2 -10)(10 2 10) ;
        }
    }
    {
        name        zPNegCellSet;
        type        cellSet;
        action        new;
        source        boxToCell;
        sourceInfo   
        {
            box (-10 -2 -8.99)(10 2 10) ;
        }
    }
    {
        name        zNNegCellSet;
        type        cellSet;
        action        new;
        source        boxToCell;
        sourceInfo   
        {
            box (-10 -2 -10)(10 2 8.99) ;
        }
    }
   
); // actions

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

Just the boxToCell stuff fails, but here is the rest of the topoSetDict that I'd like to implement once I can figure out why the cellSets from the boxToCell are failing:
Code:

    ////
    //
    // Create faces from negative cells to remove
    //
    ////   
    {
        name        xPNegFaceSet;
        type        faceSet;
        action        new;
        source        cellToFace;
        sourceInfo   
        {
            set    xPNegCellSet;
            option    all;
        }
    }
    {
        name        xNNegFaceSet;
        type        faceSet;
        action        new;
        source        cellToFace;
        sourceInfo   
        {
            set    xNNegCellSet;
            option    all;
        }
    }
    {
        name        zPNegFaceSet;
        type        faceSet;
        action        new;
        source        cellToFace;
        sourceInfo   
        {
            set    zPNegCellSet;
            option    all;
        }
    }
    {
        name        zNNegFaceSet;
        type        faceSet;
        action        new;
        source        cellToFace;
        sourceInfo   
        {
            set    zNNegCellSet;
            option    all;
        }
    }
   
   
   
   
   
   
   
    { // xPFaceSet
    name    xPFaceSet;
    type    faceSet;
    action    delete;   
    source    faceToFace;
    sourceInfo
    {
        set    xPNegFaceSet;
    }
    } // xPFaceSet
   
    { // xNFaceSet
    name    xNFaceSet;
    type    faceSet;
    action    delete;   
    source    faceToFace;
    sourceInfo
    {
        set    xNNegFaceSet;
    }
    } // xNFaceSet
   
    { // zPFaceSet
    name    zPFaceSet;
    type    faceSet;
    action    delete;   
    source    faceToFace;
    sourceInfo
    {
        set    zPNegFaceSet;
    }
    } // zPFaceSet
   
    { // zNFaceSet
    name    zNFaceSet;
    type    faceSet;
    action    delete;   
    source    faceToFace;
    sourceInfo
    {
        set    zNNegFaceSet;
    }
    } // zNFaceSet

Edit: Does this (likely) mean that there's some issue in my installation?


Edit2: It seems that the boxToCell and boxToFace are not implemented in my version of OpenFOAM (OpenFoam-8 from the OpenFoam.org source). It is in the online documentation: https://cpp.openfoam.org/v3/a02625.h...c44149cee260be

When I try the normalToFace, this works, but creates the oversized sets. When I tried to do use things like



Code:

    { // xPFaceSet
    // Mandatory (inhereted) entries
    name    xPFaceSetOversized;
    type    faceSet;
    action    new;   
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set    facesFromDefaultPatch;
        normal    (1 0 0);
        cos        0.01;
    }
   
    } // xPFaceSet


    { // xPFaceSet
    // Mandatory (inhereted) entries
    name    xPFaceSet;
    type    faceSet;
    action    subset;   
    // Mandatory entries
    source    boundaryToFace;
    sourceInfo
    {
        set    xPFaceSetOversized;
    }
   
    } // xPFaceSet

for all four faces (pos/neg x/z), it just created one non-empty patch after calling createPatch. The 2d array that I extrude using extrude2DMesh is over a rectangle in the zx-plane. I don't get why I can't take the subset of the faceSet generated from the normalToFace source that is in the boundary (it just assigns the entire 'default' patch's faceSet). When I do this for all four faceSets, then generate the patches using createPatch, whichever is created last is the only non-empty patch of those four.


~~~~~~~~~~~~~~~~~~~~



Edit3: Okay, got it working.


~~~~~~~~~~~~~~~~~~~~




This seems to produce the four face separately and correctly. Will try to do the fluid flow next. Working files below.


topoSetDict:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  8
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      binary;
    class      dictionary;
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// bounding box is (-5 -0.34039 -9) (5 1.14071 9)
// size between patches on .obj is 0.1

actions
(
    {
        name        facesFromDefaultPatch;
        type        faceSet;
        action        new;
        source        patchToFace;
        sourceInfo   
        {
            name "default";
        }
    }
    {
        name        facesFromFrontPatch;
        type        faceSet;
        action        new;
        source        patchToFace;
        sourceInfo   
        {
            name "front";
        }
    }
    {
        name        facesFromBackPatch;
        type        faceSet;
        action        new;
        source        patchToFace;
        sourceInfo   
        {
            name "back";
        }
    }
   
   
   
    // Create the faces for the four directions of interest
   
   
   
    { // xPFaceSet
    // Mandatory (inhereted) entries
    name    xPFaceSet;
    type    faceSet;
    action    new;   
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set    facesFromDefaultPatch;
        normal    (1 0 0);
        cos        0.01;
    }
   
    } // xPFaceSet
   
   
    { // xNFaceSet
    // Mandatory (inhereted) entries
    name    xNFaceSet;
    type    faceSet;
    action    new;   
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set facesFromDefaultPatch;
        normal    (-1 0 0);
        cos        0.01;
    }
    } // xNFaceSet
           
   
    { // zPFaceSet
    // Mandatory (inhereted) entries
    name    zPFaceSet;
    type    faceSet;
    action    new;
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set facesFromDefaultPatch;
        normal    (0 0 1);
        cos        0.01;
    }
    } // zPFaceSet
   
   
    { // zNFaceSet
    // Mandatory (inhereted) entries
    name    zNFaceSet;
    type    faceSet;
    action    new;
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set facesFromDefaultPatch;
        normal    (0 0 -1);
        cos        0.01;
    }
    } // zNFaceSet
   
    //
    //    Take subset of oversized initial faceSets
    //
   
    // bounding box is (-5 -0.34039 -9) (5 1.14071 9)
    { // xPFaceSet
    name    xPFaceSet;
    type    faceSet;
    action    subset;   
    source    boundaryToFace;
    sourceInfo
    {
    }
    } // xPFaceSet
   
    { // xNFaceSet
    name    xNFaceSet;
    type    faceSet;
    action    subset;   
    source    boundaryToFace;
    sourceInfo
    {
    }
    } // xNFaceSet
   
   
    { // zPFaceSet
    name    zPFaceSet;
    type    faceSet;
    action    subset;
    source    boundaryToFace;
    sourceInfo
    {
    }
    } // zPFaceSet
   
    { // zNFaceSet
    name    zNFaceSet;
    type    faceSet;
    action    subset;
    source    boundaryToFace;
    sourceInfo
    { 
    }
    } // zNFaceSet
   
); // actions

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

createPatchDict:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  8
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      binary;
    class      dictionary;
    object      createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

pointSync    false;

patches // Patches to create.
(
    { // xPPatch
        // Name of new patch
        name    xPPatch;
        // Type of new patch
        patchInfo
        {
            type patch;
        }
        // How to construct: eiter from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set xPFaceSet;
    } // xPPatch
   
    { // xNPatch
        // Name of new patch
        name    xNPatch;
        // Type of new patch
        patchInfo
        {
            type patch;
        }
        // How to construct: eiter from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set xNFaceSet;
    } // xNPatch
   
    { // zPPatch
        // Name of new patch
        name    zPPatch;
        // Type of new patch
        patchInfo
        {
            type patch;
        }
        // How to construct: eiter from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set zPFaceSet;
    } // zPPatch
   
    { //zNPatch
        // Name of new patch
        name    zNPatch;
        // Type of new patch
        patchInfo
        {
            type patch;
        }
        // How to construct: eiter from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set zNFaceSet;
    } // zNPatch
   
); // patches

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


JEBland November 12, 2021 10:48

Still not quite correct
 
2 Attachment(s)
I've had issues with the flow blowing up. In looking back at the meshing, it seems that the faces at the cells on the +/-x faces (used as in/out for this case) are not correctly mapped using the normalToFace and subset operations. Could this (help) cause the simulation blowing up?



Here is the extrude2DMeshDict (I've tried different distances and number of layers)

Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  8
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
   
    class    dictionary;
    object    extrude2DMeshDict;
}

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


extrudeModel    linearDirection;
// extrudeModel        wedge;

patchType        patch;
// patchType    wedge;

//nLayers            5;
nLayers            20; // number of layers across total distance

expansionRatio    1.0;

linearDirectionCoeffs
{
    direction (0 -1 0);
    thickness 4; // total distance
}

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




topoSetDict:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  8
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      binary;
    class      dictionary;
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 

actions
(
    {
        name        facesFromDefaultPatch;
        type        faceSet;
        action        new;
        source        patchToFace;
        sourceInfo   
        {
            name "default";
        }
    }
    {
        name        facesFromFrontPatch;
        type        faceSet;
        action        new;
        source        patchToFace;
        sourceInfo   
        {
            name "front";
        }
    }
    {
        name        facesFromBackPatch;
        type        faceSet;
        action        new;
        source        patchToFace;
        sourceInfo   
        {
            name "back";
        }
    }
   
   
   
    // Create the faces for the four directions of interest
   
   
   
    { // xPFaceSet
    // Mandatory (inhereted) entries
    name    xPFaceSet;
    type    faceSet;
    action    new;   
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set    facesFromDefaultPatch;
        normal    (1 0 0);
        cos        0.001;
    }
   
    } // xPFaceSet
   
   
    { // xNFaceSet
    // Mandatory (inhereted) entries
    name    xNFaceSet;
    type    faceSet;
    action    new;   
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set facesFromDefaultPatch;
        normal    (-1 0 0);
        cos        0.001;
    }
    } // xNFaceSet
           
   
    { // zPFaceSet
    // Mandatory (inhereted) entries
    name    zPFaceSet;
    type    faceSet;
    action    new;
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set facesFromDefaultPatch;
        normal    (0 0 1);
        cos        0.001;
    }
    } // zPFaceSet
   
   
    { // zNFaceSet
    // Mandatory (inhereted) entries
    name    zNFaceSet;
    type    faceSet;
    action    new;
    // Mandatory entries
    source    normalToFace;
    sourceInfo   
    {
        set facesFromDefaultPatch;
        normal    (0 0 -1);
        cos        0.001;
    }
    } // zNFaceSet
   
    //
    //    Take subset of oversized initial faceSets
    //
   
    // bounding box is (-5 -0.34039 -9) (5 1.14071 9)
    { // xPFaceSet
    name    xPFaceSet;
    type    faceSet;
    action    subset;   
    source    boundaryToFace;
    sourceInfo
    {
    }
    } // xPFaceSet
   
    { // xNFaceSet
    name    xNFaceSet;
    type    faceSet;
    action    subset;   
    source    boundaryToFace;
    sourceInfo
    {
    }
    } // xNFaceSet
   
   
    { // zPFaceSet
    name    zPFaceSet;
    type    faceSet;
    action    subset;
    source    boundaryToFace;
    sourceInfo
    {
    }
    } // zPFaceSet
   
    { // zNFaceSet
    name    zNFaceSet;
    type    faceSet;
    action    subset;
    source    boundaryToFace;
    sourceInfo
    { 
    }
    } // zNFaceSet
   
); // actions

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




And the createPatchDict:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  8
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      binary;
    class      dictionary;
    object      createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

pointSync    false;

patches // Patches to create.
(
    { // xPPatch
        // Name of new patch
        name    xPPatch;
        // Type of new patch
        patchInfo
        {
            type patch;
        }
        // How to construct: either from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set xPFaceSet;
    } // xPPatch
   
    { // xNPatch
        // Name of new patch
        name    xNPatch;
        // Type of new patch
        patchInfo
        {
            type patch;
        }
        // How to construct: either from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set xNFaceSet;
    } // xNPatch
   
    { // zPPatch
        // Name of new patch
        name    zPPatch;
        // Type of new patch
        patchInfo
        {
            type wall;
            // type patch;
        }
        // How to construct: either from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set zPFaceSet;
    } // zPPatch
   
    { //zNPatch
        // Name of new patch
        name    zNPatch;
        // Type of new patch
        patchInfo
        {
            type wall;
            // type patch;
        }
        // How to construct: either from 'patches' of  'set'
        constructFrom set;
        // If constructFrom = set : name of faceSet
        set zNFaceSet;
    } // zNPatch
   
   
    { //yNPatch
        // Name of new patch
        name    yNPatch;
        // Type of new patch
        patchInfo
        {
            type wall;
        }
        // How to construct: either from 'patches' of  'set'
        constructFrom patches;
        // If constructFrom = set : name of faceSet
        patches (back);
    } // yNPatch
   
    { //yPPatch
        // Name of new patch
        name    yPPatch;
        // Type of new patch
        patchInfo
        {
            type wall;
        }
        // How to construct: either from 'patches' of  'set'
        constructFrom patches;
        // If constructFrom = set : name of faceSet
        patches (front);
    } // yPPatch
   
); // patches

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


JEBland December 2, 2021 19:32

Any extrudeMesh2D/topoSet experts able to weigh in on this?

sqek December 6, 2021 07:28

I'd suggest using ParaFoam to visualise your patches, so you can see if anything's gone wrong and where, rather than just looking at the statistics.

Run paraFoam, then in the properties window:
tick Use VTK Polyhedron
tick Show Patch Names
Under Mesh Parts:
Tick all of your patches (names like "inlet - patch"), untick things like "wall - group" and internalMesh

Then click apply, and set the dropdown at the top to vtkBlockColours
This should give each patch a different colour, with a name in the middle - any faces in the wrong patch will immediately stand out
Setting the other dropdown to "Surface With Edges" can be useful as well, if it's coarse enough, so you can see the individual cells

Also run checkMesh and see if there's anything dodgy on there


All times are GMT -4. The time now is 23:51.