CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Mesh Utilities (http://www.cfd-online.com/Forums/openfoam-meshing-utilities/)
-   -   mirrorMesh and undoing the joining of patches (http://www.cfd-online.com/Forums/openfoam-meshing-utilities/92254-mirrormesh-undoing-joining-patches.html)

chegdan September 7, 2011 18:46

mirrorMesh and undoing the joining of patches
 
Hello All,

I used mirrorMesh to mirror a mesh (yes I know that's wierd) and it did a wonderful job at joining patches and such. However now I have a problem. Imagine joining a meshed pipe to make a new pipe twice as long as the original. The original had an inlet an outlet and walls. After reflecting, the inlet was removed and I have two outlets (one patch)...one at the top and one at the bottom of type patch. How can I split this outlet patch to get an inlet patch again?

Thanks in advance.

Dan

chegdan September 8, 2011 16:44

[Solved] mirrorMesh and undoing the joining of patches
 
So to fix this I used the following steps

1. faceSet to extract the faces from the outlet patch into a set called outletPatch.
2. made of copy of the outletPatch set named inletPatch
3. Used setSet with the command setSet -batch createInletSet.setSet

where createInletSet.setSet was a text file with the line:

faceSet inletPatch delete normalToFace (0 0 1) 0.01

4. Used setSet with the command setSet -batch createOutletSet.setSet

where createOUtletSet.setSet was a text file with the line:

faceSet outletPatch delete normalToFace (0 0 -1) 0.01

5. used createPatch with the lines

Code:

    {
        name inlet;

        // Type of new patch
        dictionary
        {
            type patch;
        }

        constructFrom set;

        patches ();

        set inletPatch;

    }

    {
        name outlet;

        // Type of new patch
        dictionary
        {
            type patch;
        }

        constructFrom set;

        patches ();

        set outletPatch;

    }

in a createPatchDict. That was it and it took me all day to do that. Hope this helps someone else.

Dan

chegdan November 30, 2011 20:10

I had an even simpler method that starts from a combined patch, in my case it was called "outlet".

1. use faceSet and create a set for your combined "outlet" patch, call it "inletOutletSet"
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      faceSetDict;
}

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

// Name of set to operate on
name inletOutletSet;

// One of clear/new/invert/add/delete|subset/list
action new;

// Actions to apply to pointSet. These are all the topoSetSource's ending
// in ..ToFace (see the meshTools library).
topoSetSources
(
 
    // All faces of patch
    patchToFace
    {
        name "outlet";      // Name of patch, regular expressions allowed
    }

 
);

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

2. now just go to constant/polyMesh/sets and copy the inletOutletSet to a set called inletSet and then rename the existing inletOutletSet to outletSet (leaving two separate and identical sets called inletSet and outletSet)

3. now subtract out the faces from the inletSet and outletSet you don't need using faceSet again. This was relatively easy since my inlet and outlet patches had normal vectors in opposite direction. For my case, to remove the remove the outlet patch faces from the inletSet i used a faceSetDict like

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      faceSetDict;
}

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

// Name of set to operate on
name inletSet;

// One of clear/new/invert/add/delete|subset/list
action delete;

// Actions to apply to pointSet. These are all the topoSetSource's ending
// in ..ToFace (see the meshTools library).
topoSetSources
(
      // Faces with normal to within certain angle aligned with vector.
    normalToFace
    {
        normal (0 0 1);    // Vector
        cos    0.01;      // Tolerance (max cos of angle)
    }
);

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

and for my outletSet I used a faceSetDict like

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      faceSetDict;
}

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

// Name of set to operate on
name outletSet;

// One of clear/new/invert/add/delete|subset/list
action delete;

// Actions to apply to pointSet. These are all the topoSetSource's ending
// in ..ToFace (see the meshTools library).
topoSetSources
(
      // Faces with normal to within certain angle aligned with vector.
    normalToFace
    {
        normal (0 0 -1);    // Vector
        cos    0.01;      // Tolerance (max cos of angle)
    }
);

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


4. Now use createPatch to create separate patches from your inletSet and outletSet sets using a createPatchDict similar to

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      createPatchDict;
}

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

// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
//  a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
//  is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.

// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
//  and centre to make matching easier
// - pointSync true to guarantee points to line up.

// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
//  "face 0 area does not match neighbour 2 by 0.0100005%"
//  " -- possible face ordering problem."
// - change patch type from 'cyclic' to 'patch' in the polyMesh/boundary file.
// - loosen match tolerance to get case to load
// - regenerate cyclic as above


// Tolerance used in matching faces. Absolute tolerance is span of
// face times this factor. To load incorrectly matches meshes set this
// to a higher value.
matchTolerance 1E-3;

// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
//      with transformations.
pointSync true;

// Patches to create.
patchInfo
(
    {
        name inlet;

        // Type of new patch
        dictionary
        {
            type patch;
        }

        constructFrom set;

        //patches ("inlet");

        set inletSet;

    }


);

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

that should be it. I didn't use these dict files exactly, so there could be subtle errors....but, you get the picture.

KateEisenhower October 21, 2015 08:09

Dear Daniel,

Thanks for this post. It helped me a lot. However I think this method doesn't work with OpenFOAM 2.3.1. Here are my suggestions:
Quote:

Originally Posted by chegdan (Post 334217)
I had an even simpler method that starts from a combined patch, in my case it was called "outlet".

1. use faceSet and create a set for your combined "outlet" patch, call it "inletOutletSet"
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      faceSetDict;
}

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

// Name of set to operate on
name inletOutletSet;

// One of clear/new/invert/add/delete|subset/list
action new;

// Actions to apply to pointSet. These are all the topoSetSource's ending
// in ..ToFace (see the meshTools library).
topoSetSources
(
 
    // All faces of patch
    patchToFace
    {
        name "outlet";      // Name of patch, regular expressions allowed
    }

 
);

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


1*:
Code:

setSet
faceSet inletOutletSet new patchToFace outlet
quit

Quote:

2. now just go to constant/polyMesh/sets and copy the inletOutletSet to a set called inletSet and then rename the existing inletOutletSet to outletSet (leaving two separate and identical sets called inletSet and outletSet)
This remains the same.

Quote:

3. now subtract out the faces from the inletSet and outletSet you don't need using faceSet again. This was relatively easy since my inlet and outlet patches had normal vectors in opposite direction. For my case, to remove the remove the outlet patch faces from the inletSet i used a faceSetDict like

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      faceSetDict;
}

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

// Name of set to operate on
name inletSet;

// One of clear/new/invert/add/delete|subset/list
action delete;

// Actions to apply to pointSet. These are all the topoSetSource's ending
// in ..ToFace (see the meshTools library).
topoSetSources
(
      // Faces with normal to within certain angle aligned with vector.
    normalToFace
    {
        normal (0 0 1);    // Vector
        cos    0.01;      // Tolerance (max cos of angle)
    }
);

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

and for my outletSet I used a faceSetDict like

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      faceSetDict;
}

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

// Name of set to operate on
name outletSet;

// One of clear/new/invert/add/delete|subset/list
action delete;

// Actions to apply to pointSet. These are all the topoSetSource's ending
// in ..ToFace (see the meshTools library).
topoSetSources
(
      // Faces with normal to within certain angle aligned with vector.
    normalToFace
    {
        normal (0 0 -1);    // Vector
        cos    0.01;      // Tolerance (max cos of angle)
    }
);

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


3*:
Code:

setSet
faceSet inletSet delete normalToFace (0 0 1) 0.01
faceSet outletSet delete normalToFace (0 0 -1) 0.01
quit

0.01 is the tolerance, which is defined as the cos of the angle between the specified normal ((0 0 1) in this case) and the face normal. E.g. 0.01 is approximately 90 degrees.


Quote:

4. Now use createPatch to create separate patches from your inletSet and outletSet sets using a createPatchDict similar to

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      createPatchDict;
}

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

// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
//  a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
//  is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.

// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
//  and centre to make matching easier
// - pointSync true to guarantee points to line up.

// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
//  "face 0 area does not match neighbour 2 by 0.0100005%"
//  " -- possible face ordering problem."
// - change patch type from 'cyclic' to 'patch' in the polyMesh/boundary file.
// - loosen match tolerance to get case to load
// - regenerate cyclic as above


// Tolerance used in matching faces. Absolute tolerance is span of
// face times this factor. To load incorrectly matches meshes set this
// to a higher value.
matchTolerance 1E-3;

// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
//      with transformations.
pointSync true;

// Patches to create.
patchInfo
(
    {
        name inlet;

        // Type of new patch
        dictionary
        {
            type patch;
        }

        constructFrom set;

        //patches ("inlet");

        set inletSet;

    }


);

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

that should be it. I didn't use these dict files exactly, so there could be subtle errors....but, you get the picture.
4*:
Set up the following createPatchDict:
Code:

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

// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
//  a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
//  is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.
// - always: remove zero-sized (non-coupled) patches (that were not added)

// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
//  and centre to make matching easier
// - always create both halves in one invocation with correct 'neighbourPatch'
//  setting.
// - optionally pointSync true to guarantee points to line up.

// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
//  "face 0 area does not match neighbour 2 by 0.0100005%"
//  " -- possible face ordering problem."
// - in polyMesh/boundary file:
//      - loosen matchTolerance of all cyclics to get case to load
//      - or change patch type from 'cyclic' to 'patch'
//        and regenerate cyclic as above

// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
//      with transformations (i.e. cyclics).
pointSync false;

// Patches to create.
patches
(
    {
        // Name of new patch
        name inlet;

        // Dictionary to construct new patch from
        patchInfo
        {
            type patch;

            // Optional: explicitly set transformation tensor.
            // Used when matching and synchronising points.
            //transform rotational;
            //rotationAxis (1 0 0);
            //rotationCentre (0 0 0);
            // transform translational;
            // separationVector (1 0 0);

            // Optional non-default tolerance to be able to define cyclics
            // on bad meshes
            //matchTolerance 1E-2;
        }

        // How to construct: either from 'patches' or 'set'
        constructFrom set;

        // If constructFrom = patches : names of patches. Wildcards allowed.
        patches (periodic1);

        // If constructFrom = set : name of faceSet
        set inletSet;
    }
    {
        // Name of new patch
        name outlet;

        // Dictionary to construct new patch from
        patchInfo
        {
            type patch;

            // Optional: explicitly set transformation tensor.
            // Used when matching and synchronising points.
            //transform rotational;
            //rotationAxis (1 0 0);
            //rotationCentre (0 0 0);
            // transform translational;
            // separationVector (1 0 0);
        }

        // How to construct: either from 'patches' or 'set'
        constructFrom set;

        // If constructFrom = patches : names of patches. Wildcards allowed.
        patches (periodic2);

        // If constructFrom = set : name of faceSet
        set outletSet;
    }
);

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

Run:
Code:

createPatch
Best regards,

Kate


All times are GMT -4. The time now is 05:33.