CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Mesh Utilities

mirrorMesh and undoing the joining of patches

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 2 Post By chegdan

Reply
 
LinkBack Thread Tools Display Modes
Old   September 7, 2011, 18:46
Default mirrorMesh and undoing the joining of patches
  #1
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 535
Rep Power: 18
chegdan will become famous soon enough
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 is offline   Reply With Quote

Old   September 8, 2011, 16:44
Default [Solved] mirrorMesh and undoing the joining of patches
  #2
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 535
Rep Power: 18
chegdan will become famous soon enough
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 is offline   Reply With Quote

Old   November 30, 2011, 20:10
Default
  #3
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 535
Rep Power: 18
chegdan will become famous soon enough
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.
Cyp and CoSponge like this.
__________________
Dan

Find me on twitter @dancombest and LinkedIn
chegdan is offline   Reply With Quote

Reply

Tags
mirrormesh

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 20:09.