CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[mesh manipulation] Add / Remove faces from patch , create new

Register Blogs Community New Posts Updated Threads Search

Like Tree38Likes
  • 35 Post By djh2
  • 2 Post By otaolafr
  • 1 Post By Yann

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 7, 2014, 11:18
Default Add / Remove faces from patch , create new
  #1
New Member
 
David H.
Join Date: Oct 2013
Posts: 25
Rep Power: 12
djh2 is on a distinguished road
I have been trying to create a circular patch as an inlet to my domain, however it is important that I keep the grid structured with all hexes.

A workaround was to apply velocity by face, which did a good job at resolving a circle based on the X, Y, location of each face.

However, I'm going to need more complicated inlet boundaries than a constant prescribed inlet velocity.

One option I'd like to pursue is creating a patch from an existing patch, building from a base blockMesh of a simple 6 sided domain.

I have looked into autoPatch and might be able to modify it, however some of the code is beyond what I was able to understand working on it yesterday.

I was wondering if anyone had experience reassigning faces from one patch to another?

My plan is something similar to what I used for the velocity, access all faces on a patch (inlet base patch), and for all faces within a prescribed radius, create a new patch with these faces.

I'm concerned about the face numbering assignment, because I noticed several functions relating to this in the autoPatch source.

Many thanks in advance for your help
djh2 is offline   Reply With Quote

Old   April 8, 2014, 17:46
Default
  #2
New Member
 
David H.
Join Date: Oct 2013
Posts: 25
Rep Power: 12
djh2 is on a distinguished road
The best method I've found so far for this without code change is as follows:

Use topoSet to create a geometry and use the boolean operations with the patches to obtain the desired faceSet. Use this faceSet with createPatch to create a new patch from the set of faces. If the old patch is consumed, createPatch removes it for you.

1) Create a base blockMesh
2) Define a topoSetDict to create face sets for the patch in question
3) Define a createPatchDict to create a patch from the faceSet

This took an "inlet" patch, and created a "jet" and "bluff" patch. The leftover cutout "inlet" is the resulting co-flow inlet velocity. Now I can specify a standard boundary condition for each inlet: Jet and co-flow, as well as the bluff (wall). If you are following my posts, you can see I've had several stabs at this - but I think this is the best way to move forward for this case.

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
    {
        name    inletFaces;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name "inlet";
        }
    }

    {
        name    jetCells;
        type    cellSet;
        action  new;
        source  cylinderToCell;
        sourceInfo
        {
            p1      (0 0 0);
	    	p2      (0 0 1);
            radius  0.0018;
        }
    }

    {
        name    jetFaces;
        type    faceSet;
        action  new;
        source  cellToFace;
        sourceInfo
        {
            set     jetCells;
            option  all;
        }
    }

 	{
        name    bluffCells;
        type    cellSet;
        action  new;
        source  cylinderAnnulusToCell;
        sourceInfo
        {
            p1      (0 0 0);
            p2      (0 0 1);
            outerRadius  0.025; 
			innerRadius  0.0018;

        }
 	}

 	{
        name    bluffFaces;
        type    faceSet;
        action  new;
        source  cellToFace;
        sourceInfo
        {
            set     bluffCells;
            option  all;
        }
    }


 	{
        name    coFlowPatchFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set inletFaces;  		// Start with entire inlet face
        }
    }

 	{
        name    coFlowPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set bluffFaces;  		// Remove Bluff faces
        }
    }

	{
        name    coFlowPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set jetFaces; 			// Remove Jet faces
        }
    }

 	{
        name    bluffPatchFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set inletFaces; 		// Start with entire inlet face
        }
    }

 	{
        name    bluffPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set coFlowPatchFaces;  // Remove Bluff faces
        }
    }

 	{
        name    bluffPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set jetFaces;  			// Remove Jet Faces
        }
    }

 	{
        name    jetPatchFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set inletFaces;  		// Start with entire inlet face
        }
    }

 	{
        name    jetPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set coFlowPatchFaces; 	// Remove coflow faces
        }
    }

 	{
        name    jetPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set bluffFaces;  		// Remove bluff faces
        }
    }

);

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

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

pointSync false;

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

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

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

        // If constructFrom = set : name of faceSet
        set jetPatchFaces;
    }

 {
        // Name of new patch
        name bluff;

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

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

        // If constructFrom = set : name of faceSet
        set bluffPatchFaces;
    }

);

// ************************************************************************* //
Hope this helps someone else along the way.

-Dave

Last edited by djh2; April 8, 2014 at 19:24.
djh2 is offline   Reply With Quote

Old   October 22, 2014, 12:04
Default
  #3
Senior Member
 
Join Date: Feb 2010
Posts: 213
Rep Power: 17
vaina74 is on a distinguished road
Hi Dave, thanks for sharing your experience about topoSet and createPatch tools. I'm trying to set an easier case but something is wrong and maybe I didn't understand your explanations. Could you take a look, please?
vaina74 is offline   Reply With Quote

Old   April 23, 2015, 11:23
Default
  #4
Member
 
Gareth
Join Date: Jun 2010
Posts: 56
Rep Power: 16
bullmut is on a distinguished road
Hi all

I am creating a single patch from 4 previous patches. I am doing this to enact refineWallLayer over all the patches at the same time (maybe there is a better solution) but in creating the single patch creatPatch removes my orignial patches.
Is there a way around this?
I orginally tried to recreate the original patches in my createPatchDict but that caused issues with the newly made single patch.

Any ideas on a work around?
Thanks in advance
bullmut is offline   Reply With Quote

Old   April 28, 2020, 03:00
Default topoSet in STL model?
  #5
Senior Member
 
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 6
otaolafr is on a distinguished road
Quote:
Originally Posted by djh2 View Post
The best method I've found so far for this without code change is as follows:

Use topoSet to create a geometry and use the boolean operations with the patches to obtain the desired faceSet. Use this faceSet with createPatch to create a new patch from the set of faces. If the old patch is consumed, createPatch removes it for you.

1) Create a base blockMesh
2) Define a topoSetDict to create face sets for the patch in question
3) Define a createPatchDict to create a patch from the faceSet

This took an "inlet" patch, and created a "jet" and "bluff" patch. The leftover cutout "inlet" is the resulting co-flow inlet velocity. Now I can specify a standard boundary condition for each inlet: Jet and co-flow, as well as the bluff (wall). If you are following my posts, you can see I've had several stabs at this - but I think this is the best way to move forward for this case.

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
    {
        name    inletFaces;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name "inlet";
        }
    }

    {
        name    jetCells;
        type    cellSet;
        action  new;
        source  cylinderToCell;
        sourceInfo
        {
            p1      (0 0 0);
	    	p2      (0 0 1);
            radius  0.0018;
        }
    }

    {
        name    jetFaces;
        type    faceSet;
        action  new;
        source  cellToFace;
        sourceInfo
        {
            set     jetCells;
            option  all;
        }
    }

 	{
        name    bluffCells;
        type    cellSet;
        action  new;
        source  cylinderAnnulusToCell;
        sourceInfo
        {
            p1      (0 0 0);
            p2      (0 0 1);
            outerRadius  0.025; 
			innerRadius  0.0018;

        }
 	}

 	{
        name    bluffFaces;
        type    faceSet;
        action  new;
        source  cellToFace;
        sourceInfo
        {
            set     bluffCells;
            option  all;
        }
    }


 	{
        name    coFlowPatchFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set inletFaces;  		// Start with entire inlet face
        }
    }

 	{
        name    coFlowPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set bluffFaces;  		// Remove Bluff faces
        }
    }

	{
        name    coFlowPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set jetFaces; 			// Remove Jet faces
        }
    }

 	{
        name    bluffPatchFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set inletFaces; 		// Start with entire inlet face
        }
    }

 	{
        name    bluffPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set coFlowPatchFaces;  // Remove Bluff faces
        }
    }

 	{
        name    bluffPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set jetFaces;  			// Remove Jet Faces
        }
    }

 	{
        name    jetPatchFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set inletFaces;  		// Start with entire inlet face
        }
    }

 	{
        name    jetPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set coFlowPatchFaces; 	// Remove coflow faces
        }
    }

 	{
        name    jetPatchFaces;
        type    faceSet;
        action  delete;
        source  faceToFace;
        sourceInfo
        {
			set bluffFaces;  		// Remove bluff faces
        }
    }

);

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

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

pointSync false;

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

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

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

        // If constructFrom = set : name of faceSet
        set jetPatchFaces;
    }

 {
        // Name of new patch
        name bluff;

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

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

        // If constructFrom = set : name of faceSet
        set bluffPatchFaces;
    }

);

// ************************************************************************* //
Hope this helps someone else along the way.

-Dave
Hello Dave,
i found your guide for topoSet with a video tutorial of snappy, first fo all thanks for the great description, i have one question,in the video the person use the topoSet after the snappying of the STL model to the blockMesh, so in this order:
1.blockMesh
2.surfaceFeatureExtract
3.snappyHexMesh
4.topoSet
5.createPatch
my question is, is not possible to do the topoSet and the createPatch with the STL mesh? before snappying it? so follow this order:
1.topoSet
2.createPatch
3.blockMesh
4.surfaceFeatureExtract
5.snappyHexMesh

this should help for the detection of the patches as the edges in the stl we are sure that they are "sharp".
is it possible?
best regards.
franco
openfoam_aero and mega1 like this.
otaolafr is offline   Reply With Quote

Old   April 28, 2020, 03:35
Default
  #6
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,148
Rep Power: 27
Yann will become famous soon enough
Hello Franco,

No, you cannot use toposet and createPatch the way you want to. And you certainly cannot use it before running blockMesh since these tools need a mesh to work on. (the initial mesh being created by blockMesh, then refined, snapped, etc with snappyHexMesh)

I may have missed something, but AFAIK there is no tools in OpenFOAM to create new patches in a STL file.

What you can do, however, is to modify your STL file (or create several ones) in the software you used to generate your STL in order to have the proper surfaces / patches to mesh with snappy. This way you will be able to properly snap sharp edges or patches geometries.

Cheers,
Yann
Yann is offline   Reply With Quote

Old   April 28, 2020, 04:51
Default
  #7
Senior Member
 
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 6
otaolafr is on a distinguished road
Quote:
Originally Posted by Yann View Post
Hello Franco,

No, you cannot use toposet and createPatch the way you want to. And you certainly cannot use it before running blockMesh since these tools need a mesh to work on. (the initial mesh being created by blockMesh, then refined, snapped, etc with snappyHexMesh)

I may have missed something, but AFAIK there is no tools in OpenFOAM to create new patches in a STL file.

What you can do, however, is to modify your STL file (or create several ones) in the software you used to generate your STL in order to have the proper surfaces / patches to mesh with snappy. This way you will be able to properly snap sharp edges or patches geometries.

Cheers,
Yann
hello yann, thanks for the quick answer!.
yes, I thought about this workflow, my issue is for example that the geometry that I was working with, have a patch for a plane that is "cut" in several small planes due to this plane been intersected by a structure if you want something like my plane is in the middle of a metal mesh (so this patch would be composed of all the small "squares" planes that were created from the intersection of the plane with the metal mesh), and as so, it is harder the workflow to select all the "squares" without losing any of them.
aside from this issue, if I successfully find a workaround this "issue" from the CAD part. after this, the workflow to do this would be:
1.export each desired patch as a separates STLs
2.use cat command in the terminal to merge/combine all the surfaces.STLs to the real model.STL
3.how I would create patches from here? (I don't know how should I proceed after merging the .STL model to have the desired patches after doing the snappyHexMesh to have the final volumic mesh for the simulation)
best regards, and thanks for the help
otaolafr is offline   Reply With Quote

Old   April 28, 2020, 05:58
Default
  #8
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,148
Rep Power: 27
Yann will become famous soon enough
It depends a lot on which CAD software you use to create your STL files.

A STL file can contains several named surfaces, and snappy can work with it: it will create patches named after these surfaces and you can also control the refinement of these surfaces using the "regions" sub-dictionary in refinementSurfaces. You can run the motorBike tutorial and open the mesh in ParaView to see the different patches (for the different parts of the bike) created by snappy and named after the STL region names.

Some CAD softwares are able to conserve named surfaces when exporting geometries in STL format. In this case, you can just use your STL in snappy and you'll have the proper patches in your final mesh.

If this is not the case, you can either use several STL files in snappyHexMesh, or as you suggested, concatenate your different surface files in one single file.

Whatever technique you choose, you might run into problems if your STL mesh is not conformal at the interfaces between your surfaces (if the nodes at the interface are not matching). The file will not be watertight and it can lead to meshing issues in snappy (depending on your refinement settings)

Again, it depends a lot on your CAD software and how it deals with creating STL files. After concatenating the files, utilities such as surfaceHookUp might help you to stitch the surfaces together, and surfaceCheck can help to test the quality of your file and detect issues such as open edges, volume not closed, etc.

Yann
otaolafr likes this.

Last edited by Yann; April 28, 2020 at 06:11. Reason: typos
Yann is offline   Reply With Quote

Old   April 28, 2020, 06:04
Default
  #9
Senior Member
 
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 6
otaolafr is on a distinguished road
Quote:
Originally Posted by Yann View Post
It depends a lot on which CAD software you use to create your STL files.

A STL file can contains several named surfaces, and snappy can work with it: it will create patches named after these surfaces and you can also control the refinement of these surfaces using the "regions" sub-dictionary in refinementSurfaces. You can run the motorBike tutorial and open the mesh in ParaView to see the different patches (for the different parts of the bikes) created by snappy and named after the STL region names.

Some CAD software are able to conserve named surfaces when exporting geometries in STL format. In this case, you can just use your STL in snappy and you'll have the proper patches in your final mesh.

If this is not the case, you can either use several STL files in snappyHexMesh, or as you suggested, concatenate your different surface files in one single file.

Whatever technique you choose, you might run into problems if your STL mesh is not conformal at the interfaces between your surfaces (if the nodes at the interface are not matching). The file will not be watertight and it can lead to meshing issues in snappy (depending on your refinement settings)

Again, it depends a lot on your CAD software and how it deals with creating STL files. After concatenating the files, utilities such as surfaceHookUp might help you to stitch the surfaces together, and surfaceCheck can help to test the quality of your file and detect issues such as open edges, volume not closed, etc.

Yann
Wow so much to have a look , thanks a loot! I will see what can i get done
otaolafr is offline   Reply With Quote

Old   November 8, 2020, 16:30
Default using stl file for toposet
  #10
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 205
Rep Power: 7
farzadmech is on a distinguished road
Dear friends
Do I need to mesh stl file before doing toposet action? can anybody give me an example stl file so I can make my own based on that? it must be binary or ascii?


Thanks,
Farzad
farzadmech is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] Wedge patch '*' is not planar LilumDaru OpenFOAM Meshing & Mesh Conversion 6 January 12, 2021 05:55
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 05:38
[snappyHexMesh] Layers not growing at all zonda OpenFOAM Meshing & Mesh Conversion 12 June 6, 2020 11:28
Problem with cyclic boundaries in Openfoam 1.5 fs82 OpenFOAM 36 January 7, 2015 00:31
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 11:55


All times are GMT -4. The time now is 21:16.