Skip to content

Instantly share code, notes, and snippets.

@robinknowles
Created April 28, 2023 08:34
Show Gist options
  • Save robinknowles/bc289e9f089de9e09ab990aa277500e8 to your computer and use it in GitHub Desktop.
Save robinknowles/bc289e9f089de9e09ab990aa277500e8 to your computer and use it in GitHub Desktop.
How to rename a patch in OpenFOAM using createPatch

How to rename a patch in OpenFOAM using createPatch

Accompanies OnCFD Newsletter #144: How to change a patch name

Outline

Need to rename a patch in a meshed & decomposed case? Do the following...

  • Copy the dictionary below & save it as /system/createPatchDict
  • Edit the name & patches entries to the required names
  • Run createPatch -overwrite in parallel to make the change

See the accompanying article for more info 👋

/system/createPatchDict

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

pointSync false;

patches
(
    // Example of "renaming" a patch
    // i.e moving faces from an exising patch to a new one
    // repeat this section if you want to "rename" more patches
    {

        // name of our new patch
        name    my_new_patch;

        // build our new patch from an existing one
        constructFrom patches;

        // name of our old patch
        patches (my_old_patch);

        // set basic patch info
        patchInfo
        {
            // patch type for our new patch
            type wall;

            // what groups should our new patch be in (optional)
            inGroups (Group01 Group02);
        }
    }

);

// ************************************************************************* //
@manuelffonseca
Copy link

Thanks Robin, i have installed 2 OF version 2.3 and the last blueCFD version, and i was looking for some like this, avoiding change the patch name manually, I'll try on both version.

@robinknowles
Copy link
Author

robinknowles commented Apr 29, 2023 via email

@MilanR222
Copy link

MilanR222 commented Sep 5, 2024

Hello,
is it possible to use wildcard characters in this skript too?
I habe created Patches by using another skirpt an now i have a lot of patches called: Teil01, Teil 02 , ....
I´´d love to use this skript to rename all "Teil.*" to walls or something.
And is there a possibility to check if it worked correctly?

@robinknowles
Copy link
Author

robinknowles commented Sep 6, 2024 via email

@MilanR222
Copy link

Hello,
i´ll try using groups then. Thanks ypu for that suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment