CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

How to create a new patch in an STL file ?

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 2 Post By Yann
  • 2 Post By Bloerb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 8, 2022, 11:42
Default How to create a new patch in an STL file ?
  #1
New Member
 
Join Date: May 2022
Posts: 29
Rep Power: 3
cfd_saad is on a distinguished road
Hi foamers,

I have been struggling to extract a surface as a patch in an STL file in snappyHexMesh.

I explain myself, I am studying a breakwater and I want to compute the force in specific locations in the crownwall which I import as an STL file (crownwall.stl).

I am using the following code to compute the forces and I need to indicate a patch for the pressure integration :

Code:
force1
    {
	type forces ;
	functionObjectLibs ( "libforces.so" );
	patches (SurfaceOfInterest);
	rho rhoInf;
	rhoInf 1;
	CofR (523.5 15 30.693);
	writeControl timeStep;
	writeInterval 1;
	pName p;
	UName U;
	log true;
I don't know if I can do it with just snappyHexMesh or do I have to use TopoSet ?

Iif so I don't know how to use TopoSet, is there a template/model I can use as a basis ?

I have attached the picture of the crownwall with the pink surfaces I want to create to use as a patch for the forces. It's just two squares.

Thanks!
Attached Images
File Type: png crownwall_patches.PNG (2.4 KB, 17 views)

Last edited by cfd_saad; July 8, 2022 at 14:56.
cfd_saad is offline   Reply With Quote

Old   July 11, 2022, 09:25
Default
  #2
New Member
 
Join Date: May 2022
Posts: 29
Rep Power: 3
cfd_saad is on a distinguished road
any ideas ?
cfd_saad is offline   Reply With Quote

Old   July 12, 2022, 03:30
Default
  #3
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,066
Rep Power: 26
Yann will become famous soon enough
Hi Saad,

There are 2 ways to achieve this:
  1. Having a STL containing named surfaces, where you could have your squares already defined.Then you will be able to use it in snappyHexMesh and you will be able to use the patch name for the force function object.
  2. Creating the square patches after the mesh creation, using topoSet and createPatch.

With the first method, you will get patches in your mesh with the extact same size as the squares your defined.
With the second method, topoSet can only select faces already existing in the mesh, but it does not cut or create new faces/cells. Depending on your mesh refinement, it might lead to creating patches which are not exactly the size of the squares you defined.

Up to you to decide what is the best choice for your case depending on your goal and constraints.

There is an example of topoSet+createPatch to create new patches in the heatTransfer/buoyantSimpleFoam/comfortHotRoom tutorial. This is not the only way to achieve it, but it could be a good starting point.

Regards,
Yann
frantov and cfd_saad like this.
Yann is offline   Reply With Quote

Old   July 12, 2022, 11:29
Default
  #4
Senior Member
 
Join Date: Sep 2013
Posts: 353
Rep Power: 20
Bloerb will become famous soon enough
This is what an stl file looks like:

Code:
solid patch0
 facet normal -0.694597 -0.144938 -0.704647
  outer loop
   vertex -87.5526 -320.229 -68.3269
   vertex -87.688 -321.843 -67.8616
   vertex -87.688 -320.203 -68.1988
  endloop
 endfacet
...
endsolid patch0
So it is just one big solid/endsolid block with lots of triangle vertex information in the middle. It's just a big list of triangles.

To create different patches from one stl file in snappyHexMesh simply save two stls and combine them into one. Just copy the entire content of one stl file at the end of another one. Like this:
Code:
solid patch0
 facet normal -0.694597 -0.144938 -0.704647
  outer loop
   vertex -87.5526 -320.229 -68.3269
   vertex -87.688 -321.843 -67.8616
   vertex -87.688 -320.203 -68.1988
  endloop
 endfacet
...
endsolid patch0
solid patch1
 facet normal -0.694597 -0.144938 -0.704647
  outer loop
   vertex -87.5526 -320.229 -68.3269
   vertex -87.688 -321.843 -67.8616
   vertex -87.688 -320.203 -68.1988
  endloop
 endfacet
...
endsolid patch1
A quick one liner in linux to do so:

Code:
 cat file1.stl file2.stl > new_file.stl

You must however note, that this can create leaks. If you are saving multiple surfaces as stl files separately in your application of choice, they may not align at their shared border. And if these holes are big enough it may lead to snappy failing.



The easiest way is to use a preprocessor like ansa to create those regions and export them to stl. Or use the export features of your CAD programm.
You can also load your stl file in paraview and use for example a clip (with crinkle clip selected) to save one part of stl and afterwards inverse it to save the other half. If you do not use crinkle clip you might have to use a triangulate or extract surface filter to save the result as an stl again.
Yann and cfd_saad like this.
Bloerb is offline   Reply With Quote

Old   July 20, 2022, 22:53
Default
  #5
New Member
 
Anis Hanani
Join Date: May 2022
Posts: 6
Rep Power: 3
Anis Hanani is on a distinguished road
Hi Yann,

Can you explain what do you mean by inversing the clip from stl file in paraview? I am trying to create a new patch from my stl file too, to set for a different boundary conditions.

Thank you!
Anis Hanani is offline   Reply With Quote

Old   July 21, 2022, 06:00
Default
  #6
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,066
Rep Power: 26
Yann will become famous soon enough
Hi Anis,

I think you are referring to Bloerb's post.
He was talking about the "Invert" option in ParaView's clip filter. This parameter allows to invert which side of the geometry is clipped.

Cheers,
Yann
Yann 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
Custom Thermophysical Properties wsmith02 OpenFOAM 4 June 1, 2023 14:30
Using PengRobinsonGas EoS with sprayFoam Jabo OpenFOAM Running, Solving & CFD 35 April 29, 2022 15:35
steadyUniversalMRFFoam Tutorial fails in MixingPlane HenrikJohansson OpenFOAM Bugs 0 February 14, 2019 04:48
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 10:59
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 05:18


All times are GMT -4. The time now is 02:10.