CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [CAD formats] Clean / Repair STL file with multiple regions on command line (https://www.cfd-online.com/Forums/openfoam-meshing/171739-clean-repair-stl-file-multiple-regions-command-line.html)

matthiasd May 15, 2016 20:30

Clean / Repair STL file with multiple regions on command line
 
Hi,

I have a STL file, which I later want to process via snappyHexMesh. But first I have to "clean" the file and fill some holes in it.
My problem is: The file is very large! So when I try tools with a GUI (like salome, netfabb-basic, ...), they usually crash or are very slow and tedious to work with. Therefor I am looking for a command line solution.

I found "admesh", which is easy to use and does a great job. The only downside: I did not manage to use admesh on a STL file with multiple regions.
As I am not sure if regions is the correct term here, what I mean are several solid blocks within one file:
Code:

solid region1
...
endsolid region1
solid region2
...
endsolid region 2

I use those regions mainly for two reasons:
1. I want to different refinement levels within SHM for those regions
2. I can later apply different material properties (in my case heating rates) to those regions.

But as I said: So far I was not able to do this with admesh, as it produces an error when reading a multi region STL file.

Do you either know a way to make this work with admesh? Or do you maybe know of a command line tool, which is capable of the described tasks?


Additionally I want to add: I am quite new to CFD and OpenFOAM. So if you have comments on my general approach, this is also much appreciated:
1. I generate the STL-files from GeoTiff-files.
2. I cat the different STL-files together in one big file.
3. This works pretty well so far. The STL-surface looks good and there is no gap where two regions touch.
4. Now I would like to clean/repair the one big file with the different regions.


I hope you can help me and I appreciate every hint or suggestion!

Thank you very much in advance,
Matthias

Antimony May 15, 2016 21:07

Hi,

Since you generate the different STL files separately and then cat them together, perhaps you could run adMesh on the individual STL files first before combining them together?

Or you could leave it as separate STL files specify refinement levels individually in SHM?

Cheers,
Antimony

matthiasd May 15, 2016 23:01

Hi Antimony,

thanks for your reply!
I forgot to mention it, but I tried this already.
Problem here is: The different regions are kind of patchy. So there are some irregular fields here and there.
When I use admesh on the single region it alters the shape. I am not really sure what and why, but it gets kind of smoother. I think admesh is connecting some edges with other ones.
But after that I can/should not remerge those regions.

Is there a way to use admesh in a way it won't do that?

Cheers,
Matthias

Antimony May 16, 2016 20:45

Hi,

The more I think about it, the more unsure I am that any code that lets you amend the geometry will allow for multiple solids in the same STL file. From my point of view, any changes that the code makes (let us say introducing new faces/vertices), there is uncertainty as to which solid region it should belong to.

I could be wrong, but those are my thoughts on it.

Also, you can check out the VTK library, to see if it has anything that you can use, as an alternative to or to be used in conjunction with adMesh.

Hope this helps.

Cheers,
Antimony

matthiasd May 19, 2016 06:18

Hi Antimony,

thanks for your thoughts on that issue. And this does sound kind of reasonable to me.

So maybe I should alter my approach here and try to get the STL-file as good as possible with one region only. And then specify my different regions afterwards in some way.
I guess I can skip the first reason for using a multi region STL-file, which was doing refinements based on them. I can do this with refinement boxes as well.

But I do need those regions to apply different heating rates. Can you think of an alternative way to do this?
I found the OpenFOAM tool "surfaceToPatch", but so far I am not really sure how/when it is used and if it suits my needs.

I am open for every advice!

Thanks a lot and have a nice day,
Matthias

Antimony May 19, 2016 08:56

Hi Matthias,

Do you have a specific example/case that we can look at? I think trying to formulate a rule for a generic case is a little difficult and there might be some shortcuts/tricks that are applicable in a more specific one.

Cheers,
Antimony

matthiasd May 24, 2016 06:51

1 Attachment(s)
Quote:

Originally Posted by Antimony (Post 600745)
Hi Matthias,

Do you have a specific example/case that we can look at? I think trying to formulate a rule for a generic case is a little difficult and there might be some shortcuts/tricks that are applicable in a more specific one.

Cheers,
Antimony

Hi Antimony,

sorry for my late response, but thanks for your willingness to help!

As my specific case is rather large, I attached a small sample case consisting of a small island surrounded by ocean. The STL-file consists of those two regions island and ocean. I also attached the blockMeshDict and the snappyHexMeshDict.

This sample case does work for me. Although surfaceCheck gives me a couple of problems:
Code:

/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.x                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.3.x-2f9138f6f49f
Exec  : surfaceCheck kleineinsel.stl
Date  : May 24 2016
Time  : 12:47:13
Host  : "login"
PID    : 19530
Case  : /gpfs/gpfs1/scratch/c7071010/v2/insel_tobi/stl_insel/constant/triSurface
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Reading surface from "kleineinsel.stl" ...

Statistics:
Triangles    : 9576
Vertices    : 4930
Bounding Box : (0 0 0) (2850.05 4200.07 383.807)

Region    Size
------    ----
ocean    6186
insel    3390


Surface has no illegal triangles.

Triangle quality (equilateral=1, collapsed=0):
    0 .. 0.05  : 0
    0.05 .. 0.1  : 0
    0.1 .. 0.15  : 0
    0.15 .. 0.2  : 0
    0.2 .. 0.25  : 0
    0.25 .. 0.3  : 0
    0.3 .. 0.35  : 0
    0.35 .. 0.4  : 0.000313283
    0.4 .. 0.45  : 0.00093985
    0.45 .. 0.5  : 0.00177527
    0.5 .. 0.55  : 0.00449039
    0.55 .. 0.6  : 0.0123225
    0.6 .. 0.65  : 0.0121136
    0.65 .. 0.7  : 0.0163952
    0.7 .. 0.75  : 0.049812
    0.75 .. 0.8  : 0.767335
    0.8 .. 0.85  : 0.0455305
    0.85 .. 0.9  : 0.0385338
    0.9 .. 0.95  : 0.0344612
    0.95 .. 1  : 0.0159774

    min 0.392694 for triangle 7858
    max 0.999437 for triangle 8539

Edges:
    min 50.0005 for edge 171 points (50.0009 4150.07 0)(50.0009 4100.07 0)
    max 121.084 for edge 11719 points (1500.03 1650.03 147.975)(1450.03 1700.03 246.266)

Checking for points less than 1e-6 of bounding box ((2850.05 4200.07 383.807) metre) apart.
Found 0 nearby points.

Surface is not closed since not all edges connected to two faces:
    connected to one face : 282
    connected to >2 faces : 0
Conflicting face labels:282
Dumping conflicting face labels to "problemFaces"
Paste this into the input for surfaceSubset

Number of unconnected parts : 1

Number of zones (connected area with consistent normal) : 1


End


However, my real case does not work. And I suspect the stl-surface to be part of the problem. Which is why I want to refine and improve it as much as possible!

All the best,
Matthias


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