https://linen.dev logo
k
Give me an hour or so
Lunchtime!
f
No rush thanks for the help
I am now on a break till 13;00 CEST
o
you are going to block decompose an helix @kandelabr ?
i coulnd not get my head around on how to do it....
k
no no, I'll just make a cylinder inside a block
o
oh
ahaha
k
snappy will do the rest, hopefully
o
@finn are you limit in ram consomption? how is you 'far mesh' look? you have really different level of refinements? or your complete mesh is same level?
if you are not using levels of refinement, i would test this: https://github.com/fprotais/marchinghex
f
Ram limit ah not really like 128GB
Or 256 is also possible
I am using levels of refinement that is the procedure one of previous students found to be good and is publishing. But I can try new things
But ofcourse I am open for things to try
Ill try the easier things first
ahahah sorry i coulnt contain myself ahahah
then do not go that route for the moment marchinghex uses a single level of refinement, all the cells have the same level everywhere. so it does not help you :/
f
No that would not help, the quantity actually decreases exponentially, so at the surface very large gradients but more in the center almost none.
So levels important
Love some maxwell equations
I assume snappy will smooth out the difference between cell sizes
f
Ill give it a go,the queue is currently full so give it a moment, I can mesh it running the simulation will take about 8 hours to get a feeling if it truely is converging. Note I am meshing in parallel not sure if that makes a difference
Do you also have the classy blocks script so I can later adjust the background size and the cylinder sizes
f
Yes but the script you used to create this one, shape you send me
k
this comes from here. mind that there was a bug I fixed along the way and have to push it to master branch first o.0
Copy code
import os

import classy_blocks as cb


class SmoothWrappedDisk(cb.WrappedDisk):
    def add_edges(self):
        super().add_edges()
        for i in range(4):
            self.faces[0].add_edge(i, cb.Origin(self.center, flatness=2))


mesh = cb.Mesh()

geo_x1 = -0.045
geo_x2 = 0.045

geo_y1 = -0.045
geo_y2 = 0.045

geo_z1 = -0.050
geo_z2 = 0.070

cylinder_radius = 19.920e-3
outer_radius = (geo_x1**2 + geo_y1**2) ** 0.5

axis_point_1 = [0, 0, geo_z1]
axis_point_2 = [0, 0, geo_z2]
radius_point_1 = [cylinder_radius, 0, geo_z1]

block_start = SmoothWrappedDisk(axis_point_1, [geo_x1, geo_y1, geo_z1], cylinder_radius, [0, 0, 1])
block = cb.ExtrudedShape(block_start, geo_z2 - geo_z1)
mesh.add(block)


# Chop and grade
cell_size = 1e-3
for axis in (0, 1, 2):
    block.operations[0].chop(axis, start_size=cell_size)

block.operations[1].chop(0, start_size=cell_size)
block.operations[5].chop(0, start_size=cell_size, end_size=cell_size * (outer_radius / cylinder_radius))


mesh.write(os.path.join("..", "case", "system", "blockMeshDict"), debug_path="debug.vtk")
f
grape, only quickly have to set the boundary
Copy code
boundary
(
    infinity
    {
        type patch;
        faces
        (
            ( 0 1 3 2 )
            ( 5 4 6 7 )
            ( 0 4 6 2 )
            ( 1 5 7 3 )
            ( 0 1 5 4 )
            ( 2 3 7 6 )
        );
    }
);
now I need to see these vertices in your current state
k
just add the default patch, one second
Copy code
defaultPatch
{
        name infinity;
        type patch;
}
in python:
mesh.set_default_patch("infinity", "patch")
(just before mesh.write())
f
Nice forgot that was a thing
k
and I forgot to use it
Looks good
ill mesh it
k
oooh it's so tiny! wait, don't
f
it is small
k
the background's cylinder should be exactly where the STL lies
now it's in the core which is again just cartesian
f
yes I said the axial length 🙂
no worries
it is a cylinder lying in the center (little up in the z-direction)
axial length for buffer is 16.258e-3m, diameter 19.920e-3m, with buffer I mean the cylinder we are doing now in the blockmesh. Now you made the blocks go in radial direction only, but we also need them in the axial direction
f
ow you want it right on the radius
k
so that snappy only has to adjust the z-coordinates of the cells
f
okay I though would be nice to perhaps only have the cylinder, but but I like it actually more if it is axially keep going, as later this will become fluid
k
I can do another thing that I also thought about
f
Ill give you the real radius, maybe it needs little bit of spacing
k
expand this cylinder with a ring up to your purple radius
so, cylinder, ring, then block
f
the radius is 8.25 mm
not sure what this means, but ok
it is also not clear from the script how I can control the background mesh size $h$
f
what the helli
k
cell_size = 1e-3
wait a second, I'll push the bugfix and you can play too
hAHHA
k
yup
but it loves you
with all its heart
f
hahaha, great imagination
k
damn, I'm dealing with some dark forces here, might take a few minutes more
meanwhile, you can tell me the exact radius of the helix
f
....
f
you mean then that the cylinders surface is placed on the most inner ring right,
k
yes, so that snappy doesn't have to deal with weird angles in all directions
f
curious how that will end
k
I'm trying to make cells a bit prettier, getting there
f
no worries I am reading about jump conditions, fluxes being Lipschitz even and Hölder continuous. Somethings I have no clue about
Yeah it is probably the origin of all errors
k
[if only these gifs weren't so annoying]
f
how is it going boss
k
pushing a new version
f
where do you push it on do i have to clone somewhere, pip install -update?
k
tadaa, there it is
just do pip install --update
then this script
hope it's allright now
f
Ah what version you pushed?
k
1.9.5
f
because i have the
stable_version
Copy code
Successfully installed classy_blocks-1.9.2
lel
You pushing to master?
k
pushed to pypi
also, updated master and all
1.9.2 is like, ancient (from a few months ago)
f
so I should get it from master okay
k
try
pip install --upgrade classy_blocks
I just did and it downloaded a fresh 1.9.5
f
Copy code
Successfully installed classy_blocks-1.9.5
just cloning the master works maybe
k
aah, yes
f
lets see
pip install git+https://github.com/damogranlabs/classy_blocks.git@master
iif this is the branch you last pushed to
k
you don't have to exercise with github
but it will work just as well
f
I will try the old script first to check if it resolved the nice heart
good
is a lot coarser though
and in the z-direction you dont have cubes
ah ig that is somewhat fine
SHM it now lets see, ah I am in the HPC queue
k
they grow nicely on diagonals and are compressed a bit here; either that or vice versa
I made it coarser but you can change cell_size as you wish; I'd start with a coarser one because I'm impatient
f
I saw
Ah Coarse background, but level is 5 🙂
might be that finer will be somewhat better as I mesh with 16 cores
Yes this will never mesh everyone throws there stuff in the queue to run it over weekend let me see if I can SHM it on the login nodes, don't tell anyone
k
can you do it on your local computer?
f
IO have to transfer everything
I could let me do that then
but later I have to move it over to HPC to run simulation
k
well yeah, life is complicated 🙂
anyway, I gotta run
let me know when stuff blows up or if it doesn't
f
sure will be done shortly moved it to local machine, also soon will start my weekend. Thanks for the help
as the background mesh isnt square in that region
I prefer it to be I think
Copy code
`blocks
(
    hex ( 0 1 5 4 2 3 7 6 ) background ( 100 100 120 ) simpleGrading ( 1.0 1.0 1.0 ) // # 0
);
`
is there a way in your python lib to make it renamed cellZone background. Just for ease of use in postProcessing
I now just renamed all mesh processing from background to domain0 but later would be nice to get that back to background
Curious for you if you can make classic blocks work with Frénet frames, then pretty much you have the all in one tool for monotonic continuous surfaces
It might have helped though I can always try and run see if it diverges that will take over the weekend
I am sending all the crap now
Copy code
Overall number of cells of each type:
    hexahedra:     2065024
    prisms:        0
    wedges:        0
    pyramids:      0
    tet wedges:    0
    tetrahedra:    0
    polyhedra:     222841
    Breakdown of polyhedra by number of faces:
        faces   number of cells
            6   15311
            9   187399
           12   16196
           15   3863
           18   72
and then concave cells it takes pretty much everything probalby checkMesh tolerance
k
non-squares are an issue for snapping but as long as it's close to cubes it's fine. away from the coil it gets a lot worse but you're not snapping there
to block a coil is trivial but you also need to block everything around it, that's a no-no with tools at hand
(with about any tool actually)
Copy code
python
for op in mesh.operations:
  op.set_cell_zone("background")
Well yeah, it's almost the same as all your previous attempts but it really shouldn't be. I guess it must be something else then.
f
so it might be the stl but I had many tries with that from the one that sends me the stl files from inventor... Ah whatever
k
get a STEP and mesh it in SALOME
a pinch of NETGEN might help
f
nope
need hexahedrals
k
just the surface to get a proper STL, I mean
FreeCAD would do just as fine
f
but the stl should be proper but maybe I could try that never used Salome I have it installed
yes but I believe the stl cant be the problem
I switched them up, added more points on edges
But it is always good to get these discussions going, for some thoughts that might help. I will see whatever I can do.
k
I guess it's the aspect ratio of the triangles that's bugging snappy
have you tried with simple remeshing in blender?
f
I had to tweak the face pyramid volume to two orders smaller then the smallest feature volume
that is what I found to get a "correct" mesh
does this alter where the vertices are placed?
k
not sure, also depends on the algorithm
f
I can try I refined adding more vertices but not necessarily replacing them
Ill put it on the list
The list is something like 20 points already hahaha
Thought might aswel be something to do with decomposition method during solving that causes the divergence
A lot of things to test
f
that could work
I would like to learn to do it in Salome, so I will try. I have asked for the step file
f
Get some STEP files of the geometries of interest. I will work on it this afternoon so you will get some updates from me. First have some other things on the agenda
k
take your time, a year spent in meshing is... peanuts
f
i have no year
it is finishing this graduation project and then getting some money
althoughh first an internship
But i just keep chugging at it I have like 4/5 more months to work on it and see how far I can bring it. It is just a bummer to how much I try it doesnt seem to work. As I reflect back to my bachelor end project where I got graded a 10/10 I did vaguely less work with more results. This is I guess welcome to a world of numerical methods
k
Are you going into academia or industry/engineering?
f
This project lead me to not proceed into acedemia
with the potential of later doing so
But I will be more likely to go into something like R&D
As when I did not work in such an enviroment the management of my previous "student" job couldnt see the potential
labeled "student", as I setup a RANS simulation in Ansys Fluent for the for a exhaust system for gas turbines, that matched consultancy results
But to be honest anything that earns me money is good at the start
I think I will get offered to go into acedemia, but most likely decline. I see a challange, but I think the loneliness isn't worth it for me
k
Then... be prepared to see more of "doesn't seem to work" 😄
f
Oh yes sure, that is fine
But the thing now is that I am given a solver from a paper from 2016, that doesnt work.
As a previous student worked on it, but after now carefully reading his report, it is wonky
It should have been a red flag from the start if there is no mesh independence study performed
k
mesh independence is a farce
the only true way would be to have a 100% hexa mesh and refine it 2x2x2
you do this refinement 2 or 3 times and everything else stays the same
f
I know but I have to get some feeling the values he is getting are reasonable
as the parameters he used are wonky
k
mesh independence with snappy is ridiculous at best
f
it worked for me on some cylinders
just doing some h-refinement
Like this not really mesh independence but atleast gives me a clear view that the error I am getting here is not by the mesh size.... https://cdn.discordapp.com/attachments/1431198883936993300/1432289293090689024/image.png?ex=690082da&is=68ff315a&hm=d80523dd2128ea0a4e520c9081afa02fab99138ccfcab0efb87a8ac21af3d282&
Haha so these things drive me mental
But whatever
k
hehe
f
different topic
everything ruled out
k
I wouldn't even allow an article to be accepted if it didn't have an experimental validation
f
ow I have qualitative experimental data with IR camera
but I havent coupled fluid dynamics and solid heating to electromagnetics solver
k
I'm not talking about you, just ranting a bit 🙂
f
Or I actually have coded that up with my own solid thermophysical library
but verification is a pain in the bum
k
you're doing the strangest stuff IMO
f
what is strange
triple coupled physics
k
for a start, yes 🙂
I cannot clarify for what it is used..... So go think about it
NDA...
k
nah, I'm not digging any further, it's alright
you do your magic - and good luck!
f
what is so strange
intensified heating applications ever heard of those
k
nope
f
A chemical engineer only cares about two things, heat and mass transport. So those fields are of interest. Which of both of these requires FD, as reactions mostly occur in fluid phase or on walls which is convected again. Conventional heating is done by heating walls, so you get a temperature profile which is not the best if you have a reaction as this leads to a distribution of reacted and unreacted species, you would like to have a homogeneous temperature profile
k
aaaah, so you're a chemical guy
f
I am everything
no but yes chemical engineer, with many mechanical engineer courses, except solids, solid mechanics not for me
but that is also like a PDE so yeah whatever
k
I meant "strange" as in "strange to me", hope I didn't offend you or anything
I'm a single-phase-incompressible guy. Wrestling quite enough with that already
f
Nono I curious what you find strange, there might be a thing you say you would have done differently. That is all okay, always open for critique dont worry
mmmm yeah chemistry aint that.
Always a DEM or multiphase flow, and often compressible due to large pressure drop
or in my case large temperature differences, as to which boussinesq dont work no more
Although I am inexperienced to some extend with turbulence modelling
Still on my bucket list to do a LES
This part has to wait a moment, I thought I fixed the solver under parallel excecution
but I clearly didnt
So I have to work back for a moment now before proceeding further
so how does one do this from a STEP file because I found the problem of all my problems and is probably the stl
:)_))))
Ah I actually just did it 🙂 not that hard, just some indian voice in my head showing me how to do it
I tried doing the helix with 1D-2D Netgen @kandelabr @otaolafr but it creates these faces between the swirls. So I did GMesh and that does seem to work which is a bit strange. Is there some Netgen setting I should switch> Let me generate it for some pictures, the solid cylinder was quite easy
The surface meshing takes also quiet long for Netgen compared to Gmesh (but gmesh is not fine around the edges)
I will rock with GMesh for now then
quite happy with this now, the edges here are square again because of some blender stuff cutting I have to do. I might have to switch that up https://cdn.discordapp.com/attachments/1431198883936993300/1433762559625789490/image.png?ex=6905def0&is=69048d70&hm=c50ca5898010df54215726445d7d71e0bfc60c1488ea8e817ee8dd326035f68d&
k
you probably have a too large max_length or something in netgen
o
I use always netgen but gmsh is Okey also.
k
and it wants to connect 'neighbor' points to triangles but neighbours are on different levels of your helix
use Netgen 1D-2D-3D and try with different min/max lengths
o
As @kandelabr said, it is a problem of your max size. I imagine you did a next next next Okey approach ( not judging) and it found a too large max size. And maybe too small size also
k
size matters
o
1d-2d only. He needs surface mesh. You are doing a volumetric meshing for nothing 😅
f
yes exact
o
Anyway gmsh is as fine as netgen. And might be faster so keep it like that
f
Yes it is okay, I am not touching it currently
now first I have to figure out why using the salome geometry and swithing to OF10 meshing the shit crashes so that is first on the list. That is for myself to figure out
k
ah, yes. oops
o
also now that i think about it, test that @finn use a salome volumetric mesh to test if thats your issue (mesh) or not
f
What?
For the edges or what?
o
for your solver, do the same sim but with a tetra mesh generated in salome, you will get a quality mesh from it just to test
f
I have resolved some decomposition errors in the mean time that gave weird values. It might be attributed to that so whenever I get to it I will check that first. After doing that. As my cylinder also has some edges curved
I will do that if everything fails that is currently in schedule
I now try the new blockMesh excited what it will bring :)))) In the end might not use it but always a fun result to show 😉
THis is a solid cylinder, but I cannot say much still on this NDA type shit
where in your script do you set the z grading?
as I want them more square, in the core
k
flatness > 1 increases radius of arc edges;
f
Okay yeah so that doenst make sence I thought was the core ratio
k
.chop_radial(), chop_axial(), chop_tangential() can take an additional argument
take="max"/ "min"
try both and see what it does
just changes block's reference length in that direction (default is average of all 4 edges in that direction)
f
it would need to then be chop axial right?
inner_cylinder.chop_tangential(start_size=cell_size) so this computes some average?
Ah no it is taking cell_size I see, not sure if that in the end will work. Ah I see that will not work, I will just have to accept this
Copy code
def chop(self, axis: DirectionType, **kwargs) -> None:
        """Chops operations along given axis.
        Only axis 0 and 1 are allowed as defined in sketch_1"""
        if axis == 2:
            self.operations[0].chop(2, **kwargs)
        else:
            for index in self.sketch_1.chops[axis]:
                self.operations[index].chop(axis, **kwargs)
MMMM, it is probably some class thing otherwise this look very recursive
Great
inner_cylinder.chop_tangential(start_size=cell_size, take="min")
For your end it would be nicer if the code documentation would take me to it. Although understand hobby project etc 🙂 See the definition of chop
k
well this is the thing with structured meshing, your cell sizes (and count) is fixed and defined with one of the blocks
you choose which one
I understand, do you have type hints? autocomplete/intellisense?
f
Yes that is the thing why I said it wouldnt work, but it does work now in the most centered core there more cubes
I just go the defenition through euhm idk what it is called, some VSCode (default) thing
k
try increasing
nSmoothInternal
to like 100 or 300 or even 1000; this will smooth blocks before snapping
f
Using .org, but it is okay
If it does work with snapping I will need to cite you, that is all fair for also the next person working on this. Have you thought on a way you would like classy blocks to be cited? As it is not in your README.MD @User
f
I have higher hopes for snapping the boundary, the edges I have seen is something with feature snapping not feeling it. Good thanks, did not see that one
Jup the cylinder mesh did not resolve problems also increasing the nSmoothPatch to something like 100 did not do it, people have more often this problem for very fine levels. Anyways the problem is somewhat resolved just using the square blockMesh. Anyways thanks for the help though. I do see this meshing technique very useful. I will be doing some "fun" project on our pond fountain. As I need to 3D print or buy an adapter on it. Would be fun to see the mixing effect of air water with something like VOF. As I then Have a pipe I can usee that for that specific section. Good.
k
Once I have some time I'll try snappying this myself. It's ridiculous how simple the geometry is and how many problems you had
given that you have refinement levels up to 8-or-so, have you tried lowering mergeTolerance?
f
no did not touch, it you can do whatever you like. I may not give more information due to NDA
in othewords I would like to give your more information but I cannot
k
nah no biggie, I'll make my own helix, it's a two-minute job
f
Should be easier then exploiting maxwell's equations in openfoam
not an electrical engineer btw
k
just the mesh, then I drop the mic
f
Are there books on meshing? Or has no one taking the time to actually write a good book on meshing
k
nothing directly useful
just a lot of theory, then they mesh a bunny and write a conclusion
f
It is also strictly a problem in FVM right? FEM isn't that big a of a deal with Taylor-Hood elements
at least I am not the biggest FEM person but when I did simulation of an artery I found P1-P2 elements to be fine, then you just triangulate everything
and in fluent I used to use always polyhedras
k
tetras in FVM work but very poorly, flow-aligned hexas are the holy grail
it converges much faster and with better results with lower cell count
maybe if your flow isn't turbulent you might try Netgen 1D-2D-3D and just run the thing with tetras
(not sure if turbulence models drive this meshing obsession)
f
Now just orthogonality, is always better doing hexahedralz
https://www.cfd-online.com/Forums/openfoam-meshing/94413-snappy-multi-region-meshing-3.html Might still use the blockMesh, to remove the few gap cells I am left with now for tthe more complex workpiece, Was not needed for the cylinder. Will update if that helps splitMeshRegions
Actually currently found out making the STL even finer resolved the issue
t
what? Please show
f
Not the rippling of the edge, but rather the splitMeshRegion problem with undefined zones
NHope I am now back on the helix figuring out. Cannot get convergence. It keeps oscillation around 0.1 to 1 for the coupled system. And the onyl difference is the geometry thus the mesh that it now does not converge anymore. It aren't that many more cells. It might be aswell the size of the background being to small, so that is something for me to figure out still. Or to large? Can it also be caused by the decomposition perhaps.
I think it must be as the mesh is quite decent
I switched now from self made deflatedPCG with DIC to PCG with FDIC
I might be in a null mode, or atleast I need to look up more what that actually means
Copy code
Checking topology...
    Boundary definition OK.
    Cell to face addressing OK.
    Point usage OK.
    Upper triangular ordering OK.
    Face vertices OK.
    Number of regions: 1 (OK).

Checking patch topology for multiply connected surfaces...
                   Patch    Faces   Points                  Surface topology
                infinity    59400    59402      ok (closed singly connected)

Checking faceZone topology for multiply connected surfaces...
                FaceZone    Faces   Points                  Surface topology
               conductor  3893106  3892948  multiply connected (shared edge)
  <<Writing 201 conflicting points to set nonManifoldPoints

Checking basic cellZone addressing...
                CellZone        Cells       Points       VolumeBoundingBox
             background     12741586     16852806 0.0009706923 (-0.045 -0.045 -0.05) (0.045 0.045 0.07)
              conductor     10390076     13984509 1.3077039e-06 (-0.0082581476 -0.0082582492 0) (0.0082581487 0.0082582416 0.021677405)

Checking geometry...
    Overall domain bounding box (-0.045 -0.045 -0.05) (0.045 0.045 0.07)
    Mesh has 3 geometric (non-empty/wedge) directions (1 1 1)
    Mesh has 3 solution (non-empty) directions (1 1 1)
    Boundary openness (9.2978978e-16 -1.4667645e-16 -2.3243497e-16) OK.
    Max cell openness = 4.3770866e-16 OK.
    Max aspect ratio = 18.231251 OK.
    Minimum face area = 2.2331171e-11. Maximum face area = 1.0012957e-06.  Face area magnitudes OK.
    Min volume = 7.5168724e-16. Max volume = 1.0015381e-09.  Total volume = 0.000972.  Cell volumes OK.
    Mesh non-orthogonality Max: 65.108276 average: 11.639177
    Non-orthogonality check OK.
    Face pyramids OK.
    Max skewness = 1.3612775 OK.
    Coupled point location match (average 0) OK.

Mesh OK.

End
You think it can be caused by non manifold points
My solid cylinder does not have these nonManifoldPoints
Afterdoing a surfaceCheck in my stl file:
Copy code
Reading surface from "conductor.stl" ...

Statistics:
Triangles    : 1232994
Vertices     : 616441
Bounding Box : (-0.00825815 -0.00825825 0) (0.00825815 0.00825825 0.0216762)

Region  Size
------  ----
conductor_thermal_wall  153746
conductor_internal      1079248


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  : 1.62207e-06
    0.4 .. 0.45  : 2.10869e-05
    0.45 .. 0.5  : 5.27172e-05
    0.5 .. 0.55  : 0.000253043
    0.55 .. 0.6  : 0.000815089
    0.6 .. 0.65  : 0.00254097
    0.65 .. 0.7  : 0.00539094
    0.7 .. 0.75  : 0.0101736
    0.75 .. 0.8  : 0.0210358
    0.8 .. 0.85  : 0.0473806
    0.85 .. 0.9  : 0.111
    0.9 .. 0.95  : 0.295018
    0.95 .. 1  : 0.506317

    min 0.397117 for triangle 940374
    max 1 for triangle 430954

Edges:
    min 4.15968e-05 for edge 315416 points (-0.00417961 0.00510405 0.00255896)(-0.00418013 0.00510386 0.00260056)
    max 0.000117908 for edge 1841648 points (0.00348903 0.00147509 0.0215927)(0.00355474 0.00150287 0.0214988)

Checking for points less than 1e-6 of bounding box ((0.0165163 0.0165165 0.0216762) metre) apart.
Found 0 nearby points.

Surface is closed. All edges connected to two faces.

Number of unconnected parts : 1

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


End
Copy code
Checking geometry...
    Overall domain bounding box (-0.045 -0.045 -0.05) (0.045 0.045 0.07)
    Mesh has 3 geometric (non-empty/wedge) directions (1 1 1)
    Mesh has 3 solution (non-empty) directions (1 1 1)
    Boundary openness (9.2978978e-16 -1.4667645e-16 -2.3243497e-16) OK.
    Max cell openness = 4.3770866e-16 OK.
    Max aspect ratio = 18.231251 OK.
    Minimum face area = 2.2331171e-11. Maximum face area = 1.0012957e-06.  Face area magnitudes OK.
    Min volume = 7.5168724e-16. Max volume = 1.0015381e-09.  Total volume = 0.000972.  Cell volumes OK.
    Mesh non-orthogonality Max: 65.108276 average: 11.639177
    Non-orthogonality check OK.
    Face pyramids OK.
    Max skewness = 1.3612775 OK.
    Coupled point location match (average 0) OK.
 ***Error in face tets: 232 faces with low quality or negative volume decomposition tets.
  <<Writing 232 faces with low quality or negative volume decomposition tets to set lowQualityTetFaces
    Min/max edge length = 1.016591e-06 0.0010008544 OK.
   *There are 1561 faces with concave angles between consecutive edges. Max concave angle = 64.571731 degrees.
  <<Writing 1561 faces with concave angles to set concaveFaces
    Face flatness (1 = flat, 0 = butterfly) : min = 0.54932709  average = 0.99963761
   *There are 47 faces with ratio between projected and actual area < 0.8
    Minimum ratio (minimum flatness, maximum warpage) = 0.54932709
  <<Writing 47 warped faces to set warpedFaces
    Cell determinant (wellposedness) : minimum: 0.001033164 average: 1.9221911
    Cell determinant check OK.
 ***Concave cells (using face planes) found, number of cells: 1492193
  <<Writing 1492193 concave cells to set concaveCells
    Face interpolation weight : minimum: 0.050986011 average: 0.46693162
    Face interpolation weight check OK.
    Face volume ratio : minimum: 0.04404975 average: 0.83378992
    Face volume ratio check OK.
Ah there we have some more info now ignore hte concaveCells as they are always a problem then we still have faces will lowQualityTetFaces. I have turned this off during meshing, as well as some cells have very low determinant but ok, may that become a problem?
It is sharp
Things I have changed:
Copy code
strictRegionSnap true; from false
minFaceWeight 0.2; from 0.01
minTetQuality 1e-8; from -1e-30
minDeterminant 0.02; from 0.001
maxBoundarySkewness 10; from 20
maxInternalSkewness 2; from 5
Where I think strictly the first one is actually the resolution
But I think the solver does not converge probably has to do with nonManifoldPoints it created
Might need to still smooth outh the moving edge nSmoothPatch crank up might try
maybe increase the number of mesh discplacement relaxations so we can get a smoother mesh on the surfaces?
t
Since you've now dived deeply into testing Snappy parameters, you might want to check the videos of how different parameter values affect the results here top https://github.com/tkeskita/snappyLayerTests/blob/main/test_result_analysis.md e.g. the clay video
f
Yes I do not use any layering, but thanks I think the general concept still holds. From your point of view increasing nSmoothPatch should not do the trick. I will see if further decreasing the maxInternalSkewness and maxBoundarySkewness will help
Can non-Manifold points occur during reconstructParMesh?
t
Yes if they are on the processor boundary. But non-manifold points are not any issue for numerics. It just means that the point is shared between non-continuous surfaces.
I didn't read everything above, but this thing does not look like you're using the cylindrical background mesh for Snappy..? In theory you should get good snapping if the background mesh is aligned to the circumference of the spiral region..
f
I am now not using the cylinderical background mesh
Yes I am now just testing some things out as it is not converging the solution, I will return back to the o-grid type mesh.
all in the middle circles so could be due to proc boundaries? No, would be weird
mergeTolerance perhaps (was not it checked it by lowering it).
Copy code
Converting 3893106 baffles back into zoned faces ...
Edge intersection testing:
    Number of edges             : 73207023
    Number of edges to retest   : 3893106
    Number of intersected edges : 3890592
Converted baffles in = 17.413733 s


Repatching faces according to nearest surface ...
Repatched 0 faces in = 1.924268 s


Edge intersection testing:
    Number of edges             : 73207023
    Number of edges to retest   : 2738203
    Number of intersected edges : 3890627
Merging 0 sets of faces.

No faces merged ...

Merging all points on surface that
- are used by only two boundary faces and
- make an angle with a cosine of more than -0.5.

No straight edges simplified and no points removed ...

Removing zero-sized patches:
    conductor_conductor_thermal_wall type wall at position 1
    conductor_conductor_thermal_wall_slave type wall at position 2
    conductor_conductor_internal type wall at position 3
    conductor_conductor_internal_slave type wall at position 4
can it be something in here with these edges but this does in the end not end up to the number of manifold points
Found out about
orientFaceZone
will try tomorrow.
t
I think you could use this kind of a structured background mesh for your case which would match the cross-section features? Model the profile in Blender, then use extrudeMesh to generate the background mesh for Snappy. Disclaimer: I have never tested this kind of thing with Snappy. https://cdn.discordapp.com/attachments/1431198883936993300/1436628001021366342/image.png?ex=69104b96&is=690efa16&hm=d8cf9004e98e137c9bec2ce59b8ce8caeb534458e677612bc9de18b756d3e300&
f
we have tried this already and I have that already, to test
It will still do face splits on the edge, that are still not as smooth, but this was for a different geometry and different meshing setup (not as stricit). Therefore I can still resort to testing this later.
But I ran a lower frequency case which means a matrix more diagonally dominant and that one seems to be converging. It is just that I am solving for 2 variables a full Neumann problem which is singular. I am still to test if I get the same results if I pin the variable in a cell, for instance done for pressure 🙂 which is also this neumann ish variable for instance in square cavity. This did converge before but had spikes on the surface (I did some things on resolving issues in parallel runs thus might be now resolved)
But to be fair i would like to get some more information on null spaces and semi definitess of the stiffness matrix
@tkeskita
Maybe I do something wrong with concave angels
In the rings
I increased maxConcave now from 25 to 40 And minFaceWeight from 0.2 to 0.05.
t
I'll try to make a dummy test at my end
f
what setting do you think is causing it
t
dunno
So I want to resolve this, the solver is very strict on surfaces
But this was older settings where i didnt get any holes, so when this is fixed I am quite confident
t
Which regions are you modelling? The spiral inside, outside and rods?
f
it is a spiral with holes inside
t
Ok here's what I got. I think it's impossible to get any better results with Snappy by using cartesian background mesh. You need to use the custom profile I suggested above to get better results. The red areas show failure to snap to edges due to no continuous edges in the background mesh. The blue areas is due to terracing in the background mesh. https://cdn.discordapp.com/attachments/1431198883936993300/1437082530133184583/image.png?ex=6911f2e6&is=6910a166&hm=6d140ea2f45cc35db564d5ad63e620fef08cd54fad5093f5cbb2ee20eeb6c68a&
f
Copy I have a cylinderical background mesh will probably use that
t
Note that the terraces are unavoidable in any case
f
I can get my outer edges to snap pretty good
But the edges is not the bigger issue, I just had some concaver cells I think inside the holes
The little rounded edge not biggest problem
t
No it's not concaveness problem, just snapping problem
Because here it is pretty good at it
It got worse then before
I was remeshing now to see if changing few parameters helped
t
Here's my case for your reference [DELETED], good luck!
f
Thanks I will figure it out, plenty of time
Just not the most keen guy on swapping parameters and waiting
t
Don't wait, make smaller case for testing
f
yes but the smaller the cells the bigger the problem actually becomes
I need small enough cells to capture the features
As you see there arent that many cells here actually
t
No you can't refine your problems away, sorry
Because of the roundness
I was thinking of the tolerance having effect on this but mm
ICEM meshing with boundary layers better? Perhaps, with a block around it then create multiregions from cellSets? I am not sure if I want to invest my time into that
I will also check to make the STL even finer, as the mesh sizes are really small
On the edge we get these cells due to snapping, it will not split the face on the arrow, because you cannot instruct it to do so, therefore I think we always get this kindoff cells. Or these is some option I am missing. Occuring in both radial and axial direction
This will always occur nevertheless of using a different background mesh
Might be able to get the axial ones out with changing the O-grid blockmesh
Might play around a bit with nSmoothpatch, issue only occurs when the mesh gets finer
o
have you tested the smoother from tkeskita?
also, this? i mean having the 3 things on the blockmesh itslef (center hole, internal holes and the external wall)
f
I was just on the site
HAHA
I would not easily understand how to make a blockmesh with the holes
Like I would have an ogrid with ogrids inside itself? I thought this would warp a bunch of things. I wanted to try this with @User , but I probably need guidance onto doing this nicely.
o
give me the sizes and i can make it for you. so external blocksize, internal radius, external radius position to the center of the holes and diameter of the holes
f
Will you make it from classy_blocks?
o
no, with my own tool i will give you the output of it which is a blockmeshdict
f
Yes but that will not help me, whenever I have different geometries
Therefore I like the classy_blocks approach and understanding it more, then I can myself use it nicely
The problem might be with @tkeskita mesh smoother if it can do it on internal boundaries.
Does not (yet) support meshes with baffles, periodic boundaries or multiple regions in the mesh.
Ah I see now on your github it does not support it.
Thanks for the option.
@kandelabr let me know when you have some time (or want to spend some time) on working out O-grids in O-grids, or even if that is possible. And then we probably need to some some mesh smoothing. Let's say we can call it a shell-in-tube heatexchanger 🙂
The thing is that it isn't a cylinder (only in the center) in a cylinder but rather multiple patterned, but most of quantity I solve for (sorry cannot be to descriptive here) is on the center hole https://cdn.discordapp.com/attachments/1431198883936993300/1438146579298127915/image.png?ex=6915d1df&is=6914805f&hm=509a5f43bb6fa9713a2816f35730b9de6b29c656904708f7889b4da17aedea2c&
o
the proyection is a big circle with 5 holes, you can do this in block mesh, and use this, the spiral it will be snappy that captures this
f
yes that is the idea, but I would not have a clue how to do it
k
@otaolafr @tkeskita you're late to the party
f
I will need to do the O-grid inside aswell. So the holes I have should also be O-grids. I had a look into how to do it in classy_blocks but it was a bit ambitious for me to work it out. It was not clear how the connectivity would work out
k
a MappedSketch with this layout, then ExtrudedShape from it
o
@kandelabr not exactly 😅
k
Because the problem was on the inner and outer helix edges and I can't see why making a more sophisticated background would improve anything. Those edges will remain the same
f
it is more the structure inside
k
It may help if you'll get nicer cubes with better blocking
o
the inflation layer during the sanppying does not solve this? normally it should for this kind of geometry.
it is the exact tool for this kind of problem (not sure to what point it will work) but it is made for this
f
I do not use any inflation layers due to breaking around edges
o
no i dont mean inflation layers, i mean the buffer layer
it is supposed to be the exact tool for what your issue is.
f
I will look into it and the implementation, thanks for the help
o
@slopezcastano there is nothing like this in extend no? do you know if there is any particular improvements of snappy in extend in comparation to com or org?
f
I can use any meshing
I switcched from com to org due to bug, that was fixed only in OF10 onwards, but this might be eleviated by new stl I use.
extend doesnt have additional snappy features.
Additionally com version has mesh smoothers so might revert back to that. Let me revert some changes so that it can work in the different version now.
o
the only one that has currently a smoother (i dont know if it works with snappy, as the library it is based on is mesquite and it does not support polyhedral cells) is extend, if you dont count the tkeskita work.
f
Copy code
// Choice of mesh motion algorithm to inflate layers (only used for mode
    // castellatedBufferLayer)

        //solver  displacementPointSmoothing;
        //displacementPointSmoothingCoeffs
        //{
        //    // Use laplacian to untangle problem areas
        //    pointSmoother           laplacian;
        //    nPointSmootherIter      10;
        //}
Is this not what you also mean or this is something different?
o
1. bufferlayer is between castellated and snappying it is not the layer addition step this is only in ESI 2. at least dont know the others, ESI has internal smoothers in snappyhexmesh 3. there are external smoother, ie., applications that you use after creating the mesh in snappy, that are the one in extend, mesquite and the one tkeskita is developing
k
nSmoothInternal
is the keyword that doesn't work with the foundation version
f
What I get from using Openfoam V2506 (and I used to get this before I switched), that I get internal boundaries that dont exist, or shouldnt exist during parallel meshing. But this is resolved in OpenFOAM10.... So it is like it there was a combination of the two it would be the best
I already reduced the
mergeTolerance 1E-6;
Copy code
// Optional: switch off topological test for cells to-be-squashed
    //           and use geometric test instead
    //useTopologicalSnapDetection false;

 // Optional: delete any region smaller than below fraction of the overall
    //           size (on a per-zone basis). This is occasionally useful
    //           when generating meshes with faceZones as baffles or boundary
    //           faces.
    //minCellFraction 0.001;
    // Optional: same but in absolute number of cells. Default is 0.
    //nMinCells 100;
might just use something with
nMinCells
although i dont tihnk it is the prettiest
Copy code
Adding buffer layers ...

Handling points with inconsistent layer specification ...
dupNonManifoldPoints : Found : 3913992 non-manifold points (out of 27370909)
Edge intersection testing:
    Number of edges             : 77100095
    Number of edges to retest   : 0
    Number of intersected edges : 7787628

patch                            faces    layers thickness[m]
-----                            -----    ------ ------------
conductor_conductor_thermal_wall 0        1      3.13e-06
conductor_conductor_internal     112      1      3.13e-06
background_to_conductor          3893070  1      3.13e-06
conductor_to_background          3893070  1      3.13e-06


Adding in total 0 inter-processor patches to handle extrusion of non-manifold processor boundaries.
Edge intersection testing:
    Number of edges             : 100458849
    Number of edges to retest   : 27440984
    Number of intersected edges : 10864493
Edge intersection testing:
    Number of edges             : 100458849
    Number of edges to retest   : 0
    Number of intersected edges : 10864493
Inflating buffer layers ...
Selecting motion solver: displacementPointSmoothing
Applying motion to entire mesh
Selecting pointSmoother type laplacian
technically conductor_conductor_internal should have 0 faces, it is a region in my stl I want to supress.
In Openfoam10 it just does:
Copy code
Adding patches for surface regions
----------------------------------

Patch Type                Region
----- ----                ------
conductor:

1     wall                conductor
2     wall                conductor_slave

coil:

3     wall                coil
4     wall                coil_slave

Added patches in = 0.00337 s
s
I dont think people in extend want to deal with the snappy codebase. They have their own thing going with cfMesh anyway
o
They modified cfmesh? Or is the same stock one since forever?🤔
f
Found the issue regarding the internal boundaries, the solution is to make the planarAngle 180!
So I have both tried castellated buffer mesh (it helped many spots but not all!) and increasing the internal smoothing to large numbers, both did not result into resolving of the cells that would go into the surface. I did not do castellated buffer mesh and smoothing
@kandelabr sorry for the tag, but how would one make a o-grid in an ogrid in classy_blocks I have been following through your tutorial but myself would not get a clue how to arange the blocks so the outside of the o-grid will be conformal to a next one? Or should we do something with rings>
k
if it's just an extruded mesh, it would be best if you just make or reuse a sketch
f
So i will need to make my own block configuration to draw that okay
there is nothing that says I can do an o-grid in an o-grid
I was thinking of if I just have a single hole, I can do o-grid with rings
k
you can do
cb.ExtrudedRing.expand(inner_cylinder, thickness)
if you only need a cylinder with a ring
you can also expand the ring multiple times
f
yes so that would work with 1 hole, and that is what I will try for now aswel if this is the problem leading to convergence issues and unphysical results (as I believe it is indeed the mesh). So that I will test coming weeks on just a helix no holes
o
so it works?
so if i undersand it correctly to make it work it was: 1. structured o-grid like mesh as base 2. buffer layer from ESI version 3. internal smoothing with large numbers
f
everything except point 3, but highly likely that point 1 was the solution points 2 is an added benefit I am thinking ( I would need to run a test without the buffer layer).
o
but the 3. was helpful also, no? maybe try if you can also to report back?
f
I tried that but it did not make any change
on the teras sites.
o
?
f
the diamond shapes on the surface
o
oh yeah yeah, but was curious if it improved the simulation.
f
It is I think according to discussion with prof, to do with the aspect ratio. If the internal smoothing would help the aspect ratio to be lower then perhaps.
o
also surpriced about that 1. solved as even then you are getting the diamond cells anyways, no? as it is still regular shaped on the Z axis
f
it is regular in z
let me make a visualization
I used a o-grid in the center, a ring to the edge of the helical and then another ring as a sort of buffer in the background. Then the o-grid in the center is tangentialy chopped (so that is how fine the circle actually is) with background cell size / 4 (so these cells might be even finer then before. But it was ballpark the same number of cells for the total mesh, which was was going for.
What do you think these diamond shapes do in terms of the matrix equation? Is it something to do with aspect ratio? Or what are you guessing or knowing?
o
i thought your issue were the diamond cells on the surface of the spiral and not the cylindrical one
f
Yes it is, but nicely meshing the outer surface will not hurt anyone, diamond cells in the inner holes are the issue.
After all this time, I might still need to switch to a commercial mesher, as a single hole geomtry it convergences just fine multiholes still not convergence. I think it is easier aswell as later I will get coils around it etc, it might becomes to difficult. As I now trying to do with the coils is snap on some layers but still it is not getting much smoother, can defenitly be that I am not using the correct settings for that.
@kandelabr
Copy code
axis_point_3 =  [offset, 0, geo_z1]
axis_point_4 = [offset, 0, geo_z2]
radius_point_1 = [cylinder_radius * 2**0.5 / 2 + offset, cylinder_radius * 2**0.5 / 2, geo_z1]


cylinder_two = OneCoreCylinder(axis_point_3, axis_point_4, radius_point_1)

b1 = cylinder_one.sketch_1.faces[4].points[1].position
b2 = cylinder_two.sketch_1.faces[2].points[1].position
b3 = cylinder_two.sketch_1.faces[2].points[2].position
b4 = cylinder_one.sketch_1.faces[4].points[2].position

# For top face
t1 = cylinder_one.sketch_2.faces[4].points[1].position
t2 = cylinder_two.sketch_2.faces[2].points[1].position
t3 = cylinder_two.sketch_2.faces[2].points[2].position
t4 = cylinder_one.sketch_2.faces[4].points[2].position


bottom_face_points = np.array([b1, b2, b3, b4], dtype=np.float64)
top_face_points = np.array([t1, t2, t3, t4], dtype=np.float64)

bottom_face = cb.Face(bottom_face_points, None)
top_face = cb.Face(top_face_points, None)

loft = cb.Loft(bottom_face, top_face)
loft.chop(2, start_size=cell_size)
loft.chop(0, start_size=cell_size)


mesh.add(cylinder_one)
mesh.add(cylinder_two)
mesh.add(loft)

#loft = cb.Loft(bottom_face, top_face)


for cyl in [cylinder_one, cylinder_two]:
    cyl.chop_radial(start_size=cell_size)
    cyl.chop_axial(start_size=cell_size)
    cyl.chop_tangential(start_size=cell_size)
I am trying to draw a loft as such: note that it is a cylinder so i draw top and bottom faces of the created cylinder as points. https://cdn.discordapp.com/attachments/1431198883936993300/1442848408045097051/image.png?ex=6926eccb&is=69259b4b&hm=a9e36195688f7713b7f746dd25df61d762f7fbd1225163b987185b9eeac699d6&
Ah I think it is the way my face is setup is incorrect.
k
you can also do:
Copy code
cb.Loft(cylinder_one.operations[4].get_face('right'), cylinder_two.operations[2].get_face('left').invert())
so you don't fiddle with each point
or even:
Copy code
mid_points = cylinder_one.sketch_1.positions[4:6] + cylinder_two.positions[6:8]
mid_face = cb.Face(mid_points)
mid_extrude = cb.Extrude(mid_face, dir)
There's also
Copy code
mid_loft = cb.Connector(cylinder_one.operations[4], cylinder_two.operations[2])
but I'm not sure if that works. Some idiot wrote that years ago
f
or i can create the size of the wrappedDisk the same as the offset so it will be all squares someway maybe
Copy code
for cyl in cylinderList:
    cyl.chop_radial(start_size=cell_size)
    cyl.chop_axial(start_size=cell_size)
    cyl.chop_tangential(start_size=cell_size)
somewaty to chop this so it gets the same number of cells as if it would have when it was like the cube, only would work when offset> radius
k
you'll have to split the 4 blocks and make their corners coincident with other corners
The purple is the box corners
and then after that an additional 3 boxes for each, so each of these split up in 4's
After making it like a cube i can add some rings
k
You can make a single quarter and then copy and rotate it, then add the center
You can also create a custom MappedSketch and .merge() it with a WrappedDisk
I am just using blocks and looping
I could but i didnt 🙂
now I can use offsI need to do this but to be honest MappedSketch scares me quite a bit
just do your thing, if it works, it works
f
yes but it is many lines.... I dont like the code I am writing haha
Copy code
for i in range(n_connectors):
    # current and next connector counter-clockwise
    b1_i, t3_i = connectorList[i]
    b1_j, t3_j = connectorList[(i + 1) % n_connectors]

    # choose corner for this step
    corner_idx = i % 4
    # bottom corner of i
    corners_xy = np.array([
    [b1_i[0], b1_i[1]],  # BL
    [t3_i[0], b1_i[1]],  # BR
    [t3_i[0], t3_i[1]],  # TR
    [b1_i[0], t3_i[1]]   # TL
    ])

    corners_xy_next = np.array([
        [b1_j[0], b1_j[1]],  # BL
        [t3_j[0], b1_j[1]],  # BR
        [t3_j[0], t3_j[1]],  # TR
        [b1_j[0], t3_j[1]]   # TL
    ])

    corner_idx = i % 4

    corner_low = np.array([*corners_xy[corner_idx], b1_i[2]]) # bottom corner of current
    corner_high = np.array([*corners_xy_next[corner_idx], t3_j[2]]) # top corner of next

    # create Box
    filler_box = cb.Box(corner_low, corner_high)
    mesh.add(filler_box)
    filler_box.chop(0, start_size=cell_size)
    filler_box.chop(1, start_size=cell_size)
    filler_box.chop(2, start_size=cell_size)
connecting them up
some hard coded corner selection, just purely as I am not have much know how of the package I endup using raw points
Now is there a smart way to create the corner or is it again I need to make 3 aditional blocks, or just use a sketch for once
On a side note i see myself using this:
Copy code
for cyl in cylinderList:
    cyl.chop_radial(start_size=cell_size / 4)
    cyl.chop_axial(start_size=cell_size)
    cyl.chop_tangential(start_size=cell_size / 4)
to make the curvature better, but is there not a better way to do this?
The upcoming connectors are translated rotated copies of the previous connectors.
Getting block corners in this matter:
Copy code
# Compute axis-aligned bounding box corners
    b1_block = np.min(block_pts, axis=0)  # bottom-left (min x, min y, min z)
    t3_block = np.max(block_pts, axis=0)  # top-right (max x, max y, max z)


    # Now define corners in a consistent order:
    block_corners = np.array([
        [b1_block[0], b1_block[1], b1_block[2]],  # BL
        [t3_block[0], b1_block[1], b1_block[2]],  # BR
        [t3_block[0], t3_block[1], b1_block[2]],  # TR
        [b1_block[0], t3_block[1], b1_block[2]]   # TL
    ])
k
I'm writing a feature to grade individual edges right now. Don't know if it will help in your case
f
How does one now wrap a cylinder around this, so i can extrude some rings, and the use the wrapped disc to make it a cube:
Copy code
OuterCylinder= OneCoreCylinder(axis_point_bottom, axis_point_top, radius_point)
for op in OuterCylinder.operations[2:]:
    mesh.add(op)
OuterCylinder.operations[2].chop(0, start_size=cell_size)
OuterCylinder.operations[2].chop(1, start_size=cell_size)
OuterCylinder.operations[2].chop(2, start_size=cell_size)
I was thinking of taking only the outer part of the cylinder, still fiddling with that. https://cdn.discordapp.com/attachments/1431198883936993300/1443168383620218953/image.png?ex=692816cb&is=6926c54b&hm=6136de8f7c62b51222f310e8c22124fde6988b9faee174c56c3bdad93e2c2fde&
k
so you need to wrap all those 5 cylinders in a new, outer 'shell'?
f
Just this box, I now created a box. so now I want to wrap this in a cylinder, is that to difficult with all the different edge gradings?
k
you now have 5x5 'cores' so you can't use the stock WrappedDisk
f
Okay
k
take outer faces of each outer box, copy them and move/correct their points to a circle
then make lofts between each pair of faces
use
cb.Origin
to set round edges
f
okay that sounds quite complex, I get what you mean then all outer edges are evenly spaced
k
just take a point, convert to polar, move to your radius, then convert back
hint hint:
Copy code
from classy_blocks.util import functions as f

f.to_polar(...)
f.to_cartesian(...)
f
but wont you skew the cells
k
a tiny bit on the inside but outer will be pretty nice
f
Can you draw with arrows what you mean?
Atleat I have my cube which a good starting point
if you worked with sketches (define everything in 2D first since this is a 2.5D thingy) you could use SketchOptimizer and SketchSmoother to bring blocks to minimum non-ortho and inner angles
f
yes
I kind realized that
but then now then the o-grid on the bottom end wont they skew all the way out, ig not
Now i Have 200 lines of point selection and creating boxes 🙂
k
that's okayish, i guess
f
it is bad
as now I have to also do a face selection
isntead of doing a simple sketch and then rotating copying it
k
you can use `orient = loft.get_closest_side(far_point)`; it will return key to
loft.get_face(orient)
f
wow
Copy code
for i in range(n_connectors):
    # current and next connector counter-clockwise
    b1_i, t3_i = outerBoxList[i]
    b1_j, t3_j = topBoxList[i]

    # bottom corner of i
    corners_xy = np.array([
    [t3_i[0], b1_i[1]],  # BL
    [b1_i[0], t3_i[1]],  # BR
    [t3_i[0], b1_i[1]],  # TR
    [b1_i[0], t3_i[1]]   # TL
    ])

    corners_xy_next = np.array([
        [b1_j[0], t3_j[1]],  # BL
        [t3_j[0], b1_j[1]],  # BR
        [b1_j[0], t3_j[1]],  # TR
        [t3_j[0], b1_j[1]]   # TL
    ])

    corner_low = np.array([*corners_xy[i], b1_i[2]]) # bottom corner of current
    corner_high = np.array([*corners_xy_next[i], t3_j[2]]) # top corner of next
this is how I have been doing it
k
you'll still need the 'far point' but I guess with 4 points you'll find all others
f
I have everything ordered to outer normal, so then the farside can just be looped as a list of points
f
Yes it is absolte shit
I said it was the worse code I have written
Purely that I do not understand the package functionalities yet
Copy code
py
        orient = connector.get_closest_side(farPointList[i-1])
        outerFace = connector.get_face(orient)
        outerFacePoints = outerFace.point_array   
        movedOutFacePoints = np.empty_like(outerFacePoints)
        for j, point in enumerate(outerFacePoints):
            polarPoint = f.to_polar(point, axis="z")
            polarPoint[0] = outerRadius
            movedOutFacePoints[j] = f.to_cartesian(polarPoint, axis="z")
how do you now replace the face then? This should be more easy code to read
I do not understand yet how to create the curved loft. I get we have now two faces, but how I need to supply edges and how I need to supply chopping.
Okay I kinda get now what you meant,I have to do some checking as I think something goes wrong with some of the faces, I selected https://cdn.discordapp.com/attachments/1431198883936993300/1443182844967911545/image.png?ex=69282443&is=6926d2c3&hm=3d4a92ba5d95e137a56bc5991b6121c5f79fd47e15955a1d9b1602fb994fe996&
Copy code
python
        connector = cb.Box(b1, t3)

        orient = connector.get_closest_side(farPointList[i-1])
        outerFace = connector.get_face(orient)
        outerFacePoints = outerFace.point_array   
        movedOutFacePoints = np.empty_like(outerFacePoints)
        for j, point in enumerate(outerFacePoints):
            polarPoint = f.to_polar(point, axis="z")
            polarPoint[0] = outerRadius
            movedOutFacePoints[j] = f.to_cartesian(polarPoint, axis="z")
        edges = [cb.Origin([0,0,0], flatness=5) for _ in range(outerFacePoints.shape[0])]

        movedOutFace = cb.Face(movedOutFacePoints, edges)
        extrudedRing = cb.Loft(outerFace, movedOutFace)
        mesh.add(extrudedRing)
        mesh.add(connector)

        connector.chop(0, start_size=cell_size)
        connector.chop(1, start_size=cell_size)
        connector.chop(2, start_size=cell_size)

        extrudedRing.chop(2, start_size=cell_size)
This how I create the loft, might have some regards on the
edges
k
you do
Copy code
movedOutFace.add_edge(0, cb.Origin(center_1))
movedOutFace.add_edge(2, cb.Origin(center_2))
Make sure that center is moved to the same z-coord as the point. Also I'm not sure edges 0 and 2 are the right ones but you'll figure that out quickly
f
what do you mean with same z-coord as the point? that is unclear to me, which point. You mean the entire center_1 is the point? or center from point to point
ah also now I have to this for the
Copy code
block = cb.ExtrudedShape(block_start, geo_z2 - geo_z1)
, which get_closest_side is not easy i guess
as extruded shapes do not get its faces written that is why is also used points...
k
you only need 4 points, say, north, south, east west, far away from the center. then run .get_face(get_closest_side(...)) for each outer block and you'll get a new face. You can then .copy() it and move its points to perimeter.
when you specify
Origin(center)
edge, the center has to be in the same plane as the edge you're creating. That's all
f
yes but, cb.ExtrudedShape has no attributed to get_face. Besides I am struggling on selecting the correct faces even when using a far away point (THis was a skill issue)
Great this is something, i will do the edge grading after
k
ExtrudedShape has an
.operations
property and each operation has this .get_face() method. So you'll have to do
shape.operations[i].get_face()
or something
f
Can I yank them all in a list, and then do the operation on that probably not.
k
nope
f
because then you get the issue of I need the block on the correct side, and then the face of that block. I will have to see for those non-boxes
I currently do get:
Copy code
--> FOAM FATAL IO ERROR:
Block hex (131 69 68 130 132 133 134 135) background (6 21 5) simpleGrading (1(1) 1(1) 1(1)) is inside-out

file: /home/finn/foam/finn-5.0/run/test_coils/system/blockMeshDict/blocks at line 270.

    From function void Foam::blockDescriptor::check(const Foam::Istream&)
    in file blockDescriptor/blockDescriptor.C at line 100.

FOAM exiting
So I have somewhere a wrong face setup
Copy code
py

def createCircle(boxObject, sideIndex):
    orient = boxObject.get_closest_side(farPointList[sideIndex])
    outerFace = boxObject.get_face(orient)
    outerFacePoints = outerFace.point_array   
    movedOutFacePoints = np.empty_like(outerFacePoints)
    for j, point in enumerate(outerFacePoints):
        polarPoint = f.to_polar(point, axis="z")
        polarPoint[0] = outerRadius
        movedOutFacePoints[j] = f.to_cartesian(polarPoint, axis="z")

    movedOutFace = cb.Face(movedOutFacePoints)
    # for edge_idx in [0, 2]:
    #     pt = movedOutFace.point_array[edge_idx]
    #     edge_center = center.copy()
    #     edge_center[2] = pt[2]  # align Z with the point
    #     movedOutFace.add_edge(edge_idx, cb.Origin(edge_center, flatness=5))
    extrudedRing = cb.Loft(movedOutFace, outerFace)
    return extrudedRing
Okay is is some of them that get the issue
yep I was correct
I can just hack your function:
Copy code
python
    def get_closest_side(self, point: PointType) -> OrientType:
        """Returns side (bottom/top/left/right/front/back) of the closest face to given point"""
        point = np.array(point)
        all_faces = self.get_all_faces()
        sides = list(all_faces.keys())
        faces = list(all_faces.values())
        centers = np.array([f.norm(point - face.center) for face in faces])

        return sides[np.argmin(centers)]

    def get_closest_face(self, point: PointType) -> Face:
        """Returns a Face that has a center nearest to given point"""
        return self.get_face(self.get_closest_side(point))
to just instead of get_all_faces I give it all faces of all operatons 🙂
k
face.invert()
and if blocks are twisted,
face.shift(n)
, n probably 2
No I did it much dirtier:
Copy code
if blockUsed:
        extrudedRing = cb.Loft(outerFace, movedOutFace)
    else:
        if sideIndex < 2:
            extrudedRing = cb.Loft(movedOutFace, outerFace)
        else:
            extrudedRing = cb.Loft(outerFace, movedOutFace)
And for the wrappedDisks I did:
Copy code
blockAllFaces = []
        for op in block.operations:
            faces = list(op.get_all_faces().values())
            blockAllFaces.extend(faces)
Just put them all in a list
Copy code
def get_closest_side_block(all_faces, point):
    """Returns side (bottom/top/left/right/front/back) of the closest face to given point"""
    point = np.array(point)
    centers = np.array([f.norm(point - face.center) for face in all_faces])
    return np.argmin(centers)
Give the index with smallest distance, and then that index can be again used on
blockAllFaces
Now the problem only is that the edges are always different depending how I made all the previous work 🙂
What am I doing now wrong on the edges?
Copy code
python
    movedOutFace = cb.Face(movedOutFacePoints)
    
    for edge_idx in range(4): 

        corner_1 = movedOutFace.point_array[edge_idx][2]
        corner_2 = movedOutFace.point_array[(edge_idx + 1) % 4][2]

        if (corner_1 == geo_z1 and corner_2 == geo_z1) or (corner_1 == geo_z2 and corner_2 == geo_z2):
            movedOutFace.add_edge(edge_idx, cb.Origin(movedOutFace.center, flatness=1))
https://cdn.discordapp.com/attachments/1431198883936993300/1443230425203085483/image.png?ex=69285093&is=6926ff13&hm=0814eb679f924757127e4f38fa426547b7aa6d6897049c959e471bbb521b6b08&
It is now going up and down
Or should I place origin on the radiusI would like it to be
Copy code
for edge_idx in range(4): 

        corner_1 = movedOutFace.point_array[edge_idx][2]
        corner_2 = movedOutFace.point_array[(edge_idx + 1) % 4][2]

        if (corner_1 == geo_z1 and corner_2 == geo_z1) or (corner_1 == geo_z2 and corner_2 == geo_z2):
            polarCenter = f.to_polar(movedOutFace.center, axis="z")
            polarCenter[0] = outerRadius
            center = f.to_cartesian(polarCenter, axis="z")
            if (corner_1 == geo_z1 and corner_2 == geo_z1):
                center[2] = geo_z1
            if (corner_1 == geo_z2 and corner_2 == geo_z2):
                center[2] = geo_z2
                
            movedOutFace.add_edge(edge_idx, cb.Origin(center, flatness=5))
https://cdn.discordapp.com/attachments/1431198883936993300/1443232790597337149/image.png?ex=692852c7&is=69270147&hm=76beb4e4f00c02ab2e9af81b29682d8a07c0685d43152e31e173dcf33b72f975&
Or do you mean it should be the origin the center so (0 0, edgeheight).
Sorry this is more me documenting everything I do.
Now some mesh smoothing...
k
Copy code
python
mesh.assemble()

optimizer = cb.MeshOptimizer(mesh)

for point in optimize_points: # corners of each corner box
    clamp = cb.PlaneClamp(point, point, [0, 0, 1]) # point to optimize and normal of the plane
    optimizer.add_clamp(clamp)

optimizer.optimize(method="Nelder-Mead")
if your blocks are terribly long compared to other two dimensions, the optimizer might struggle
so you might want to create the blocks thin (cube-ish), optimize, then move the vertices to appropriate z-coords
f
And how about mesh smoothing because I found the documentation not yet clear enough
should I also not clamp the holes?
k
by default, points are fixed unless you release them with a clamp
f
Ahhh okay
Yes so now I have to see how to select points because optimize_points is still not clear, should it be all points
or should I append all the shapes I have that I dont mind being changed that is all shapes except the o-grid, and then append all those points.
k
just take the 4 boxes that create thin cells at borders
other points are fine, I guess
f
Okay I agree
So what should I then get of these boxes all its points?
you can use
cb.LineClamp(point_to_optimize, rim_point, center_point)
to save time
f
Okay so that would then be the line propegating in the z direction of the corner of the boxes
Copy code
corner_box = cb.Box(corner_low, corner_high)
I would have this object now then I still do not fully get what I should get from it
Copy code
py  
def __init__(
        self, position: PointType, point_1: PointType, point_2: PointType, bounds: Optional[tuple[float, float] = None
    ):
        position = np.array(position)
        point_1 = np.array(point_1)
        point_2 = np.array(point_2)
This a bit the fucntion you proive so it is just 3 points on the line.
so it can be bottom middle top for instance, if I am correct
Copy code
py
mesh.assemble()

optimizer = cb.MeshOptimizer(mesh)

for i, (bl, tr) in enumerate(cornerBoxList): # corners of each corner box
    corners_xy = np.array([
        [bl[0], tr[1], bl[2]],  # BL
        [tr[0], bl[1], bl[2]],  # BR
        [bl[0], tr[1], bl[2]],  # TR
        [tr[0], bl[1], bl[2]]   # TL
    ])
    
    base = corners_xy[i]

    lowPoint = base.copy()
    lowPoint[2] = bl[2]

    highPoint = base.copy()
    highPoint[2] = tr[2]

    midPoint = base.copy()
    midPoint[2] = 0.5 * (bl[2] + tr[2])
        

    clamp = cb.LineClamp(lowPoint, highPoint, midPoint)
    optimizer.add_clamp(clamp)

optimizer.optimize(method="Nelder-Mead")
Copy code
result = scipy.optimize.minimize(
   180   8.844e+05           0   8.844e+05 Rollback (No improvement)
   188   8.844e+05           0   8.844e+05 Rollback (No improvement)
   176   8.844e+05           0   8.844e+05 Rollback (No improvement)
   184   8.844e+05           0   8.844e+05 Rollback (No improvement)
Iteration 0 finished. Improvement: 0 (8.844e+05 > 8.844e+05)
Relative tolerance reached, stopping optimization.
Improvement: 8.844e+05 > 8.844e+05 (0%)
Duration: 0 s
Incorrect syntax?
I need to grab a real point
not sure how I will get the vertice
Perhaps I try
finder.find_in_sphere
Copy code
py


mesh.assemble()

finder = cb.GeometricFinder(mesh)
optimizer = cb.MeshOptimizer(mesh)

for i, (bl, tr) in enumerate(cornerBoxList): # corners of each corner box
    corners_xy = np.array([
        [bl[0], tr[1], bl[2]],  # BL
        [tr[0], bl[1], bl[2]],  # BR
        [bl[0], tr[1], bl[2]],  # TR
        [tr[0], bl[1], bl[2]]   # TL
    ])
    
    base = corners_xy[i]

    lowPoint = base.copy()
    lowPoint[2] = bl[2]

    vertice = list(finder.find_in_sphere(lowPoint, 1e-8))[0]
    print(vertice)

    highPoint = base.copy()
    highPoint[2] = tr[2]

    clamp = cb.LineClamp(vertice, lowPoint, highPoint)
    optimizer.add_clamp(clamp)

optimizer.optimize(method="Nelder-Mead", tolerance=1e-5)
Vertex not supported
k
this is obsolete I have just figured
f
Okay Yes that do not work
It is as in the tutorial
k
the LineClamp limits point movement to a line between two points
f
But i have to give 3 points and when I give the point coordinates it does not work
k
so your points must lie in the same plane as the one you're optimizing
f
I draw the line in the z direction
k
but you don't want to move points in z-dir
you want to move them towards center
Yes that is right
k
in the same plane
Should I release these points then?
for all z
k
oui, but maybe start just with the farthest corner
just so you can see doing it something
f
select a single corner you mean? Side note, I should stil select it for all z coorindates then>
k
yes
those corners
you can add other corners later if you're not satisfied
f
Yes but is that if I draw a line is that then for all z
for instance now I do it only for z = 0.1 then it will only do it for the points that lie in the z=0.1 (local plane)
not for any z
k
yes, a Clamp only adds the specific point you pass it
But we should
k
no
why do you have so many blocks in z-dir? one should be enough
yes indeed
f
this is just axial chop i can do only 1 axial chop do it later
!!!
k
therefore, you optimize a single point and 'drag' the others with it
like this
f
We can chop later
Can we optimize first then chop?
k
yes, that's the way to go. also, don't know how did you switch to chopping all of a sudden
f
Ow I always had this
Copy code
cyl.chop_axial(start_size=cell_size)
k
you don't even have to, just use
Copy code
grader = cb.SimpleGrader(mesh, cell_size)
grader.grade()
mesh.write(...)
this has nothing to do with blocking and optimization
f
Is it a problem if a chop and assemble or not?
k
you have a single block which you chop to cells; it's still a single block in blockMesh
f
Yes I agree copy, then I can just use two lines, let me quickly find them
k
no but if you chop and optimize, you might get a suboptimal number of cells - it will set counts based on original, not optimized geometry
Copy code
python
clamp = cb.LineClamp(point, line_start, line_end)
link = cb.TranslationLink(point, linked_point)

optimizer.add_clamp(clamp)
optimizer.add_link(link)
so you move a single point and another point is being translated with it
you only need (already have?) a single block in z-dir so one clamp and a linked point should do
it not, just add more links that refer to the point you're optimizing
f
for my understanding right can point be line_start?
k
yes. you certainly don't want to move those points farther away from center, so a good spec would be
LineClamp(point, center, point)
.
or even, if you manage to locate box diagonals,
point, diagonal, point
but it will work either way
just make sure the center is the same as the one you used for
Origin
edge
damn I need to write a GUI for this
f
You confused me now even more
Okay lets look at this edge
red is for instance my start, and orange is my end
then can I do:
Copy code
clamp = cb.LineClamp(start, start, end)
k
yes but this will move point
start
between
start
and
end
f
okay
k
aah, ok, I see what's the problem
LineClamp
doesn't mean you're moving a line
f
no the points on that line I thought
k
you're moving a point along the line, defined by two points
f
okay
so now i can move the start point between start and end? Right is there something wrong with this
or should i draw the diagonal also not a problem
Do you want this
k
move it along the diagonal so that it moves towards the center
to increase the size of block at the rim
k
eegsactly
f
start red, end orange
gotcha
Copy code
def __init__(
        self, position: PointType, point_1: PointType, point_2: PointType, bounds: Optional[tuple[float, float]] = None
    ):
Can you fix this documentation on this what position, point_1 and point_2 means or it might be just me that does not get it
k
Copy code
"""Clamp that restricts point movement
    during optimization to a line, defined by 2 points;"""
so how would you write that?
f
no I need to do the other corners and then still put some extruded rings around it and a wrappedDisk
I am not done
I write my variable explanation always like this
Copy code
Attributes
    ----------
    allCellCollection : list
        Collection of 2D points per face (polyhedra) or per cell (hexahedra)
        to be drawn with matplotlib LineCollection.
    colors : list
        List of colors corresponding to `allCellCollection` segments.
    nCells : int
        Number of cells in the mesh.
    points : ndarray
        Array of mesh points (coordinates).
    connectivity : ndarray
        Cell connectivity array (point indices per cell).
    offsets : ndarray
        Offsets into the connectivity array per cell.
    cellTypes : ndarray
        Array of VTK cell types.
    sliceCoordinate : float
        Coordinate along `normalPlaneDirection` defining the slicing plane.
    faces : ndarray
        Array of face definitions for polyhedral cells.
    faceOffsets : ndarray
        Offsets into the `faces` array per cell.
    edges : tuple
        Hardcoded hexahedral edges.
    """
k
indeed I'll have to decide on a format for documentation
capture outer faces and make a cb.Shell
f
Will look at that, first need to fix some of my points for the optimization
Copy code
outerRadius = ((cylinder_radius * np.sqrt(2) + offset) * np.sqrt(2)) * 1.00001 # Some additional padding
now I can make my padding super small and it still looks great 🙂
as if I conincide it with the corner I had some issues there
So what is the reason I now need to use cb.Shell and cannot use something like
Copy code
ring_workpiece = cb.ExtrudedRing.expand(inner_cylinder, ring_radius_workpiece - cylinder_radius)
has it to do with the how the cells are conformal
Like for instance this:
Copy code
class Shell(
    faces: list[Face],
    amount: float
)
it is like,
amount
, I have no clue what it means, but looking the code it is how far it is offset
Copy code
py

def createCircle(boxObject, sideIndex, blockUsed=False):
    if blockUsed:        
        orient = get_closest_side_block(boxObject, farPointList[sideIndex])
        outerFace = boxObject[orient]
    else:
        orient = boxObject.get_closest_side(farPointList[sideIndex])
        outerFace = boxObject.get_face(orient)
    outerFacePoints = outerFace.point_array   
    movedOutFacePoints = np.empty_like(outerFacePoints)
    for j, point in enumerate(outerFacePoints):
        polarPoint = f.to_polar(point, axis="z")
        polarPoint[0] = outerRadius
        movedOutFacePoints[j] = f.to_cartesian(polarPoint, axis="z")

    movedOutFace = cb.Face(movedOutFacePoints)
    
    for edge_idx in range(4): 
        corner_1 = movedOutFace.point_array[edge_idx][2]
        corner_2 = movedOutFace.point_array[(edge_idx + 1) % 4][2]
        if (corner_1 == geo_z1 and corner_2 == geo_z1):
            movedOutFace.add_edge(edge_idx, cb.Origin((0, 0, geo_z1), flatness=1))
        if (corner_1 == geo_z2 and corner_2 == geo_z2):
            movedOutFace.add_edge(edge_idx, cb.Origin((0, 0, geo_z2), flatness=1))

    if blockUsed:
        extrudedRing = cb.Loft(outerFace, movedOutFace)
    else:
        if sideIndex < 2:        
            outerFace.invert()
            outerFace.shift(1)
            movedOutFace.shift(3)
            extrudedRing = cb.Loft(outerFace, movedOutFace)
        else:
            extrudedRing = cb.Loft(outerFace, movedOutFace)
    outerFaces.append(movedOutFace)


    return extrudedRing
as can be seen the -x values are wrong that is because the loft is written the wrong way around. so that has to be fixed but getting when I switch around, the VTK looks fine but when mesh says inside out. So it might be to do with polar cartersian?
Copy code
shell = cb.Shell(outerFaces, shellOffset)
mesh.add(shell)
shell.chop(start_size=cell_size)


ring_workpiece = cb.ExtrudedRing.expand(shell, (shellOffset + outerRadius) - workpiece_radius)
mesh.add(ring_workpiece)


-----------
  File "C:\Users\finne\AppData\Local\Programs\Python\Python311\Lib\site-packages\classy_blocks\construct\shapes\rings.py", line 63, in expand
    sketch_1 = source.sketch_1
               ^^^^^^^^^^^^^^^
AttributeError: 'Shell' object has no attribute 'sketch_1'
or will it never be possible to have now square background domain anymore? Not th e biggest deal
but I would like to make some rings, or is that the shell? Now also the shell must be smooth, add_edge would now be strange to use? I tried to access those faces but was unable for some reason, i was only able to add_edge to the connecting face, it prints out 20 faces, which I have 20 of these segments, i would think I would have had 40, so there must be a better way to smooth it.
k
all
shell.operations
are oriented so that their
bottom_face
is inside and
top_face
is outside; so you just add two Origin edges to each op's top_face
also if you want a square domain, collect all top faces of the shell, copy them and move them radially far, far away
then just clip their x and y coordinates to your bounding box
a.k.a. make another Shell with an insane
amount
f
Okay sounds interesting, see if i am able to do that
Okay so i will also have to use shell for extrudedrings in this case?
k
ExtrudedRing is way out of your scope, it is a pretty rudimentary thing, 8 blocks of equal size. plus, you can't .expand() anything but a Cylinder and ExtrudedRing
yes
although on second thought, this won't create a very nice domain, blocks at the corners will have 45-degree angles; it would be better if you move specific faces outwards and clip to bounding box, then fill the remaining corner boxes like
f
ah extruding will never give you a nice circle as it is a constant extrude per face...
Copy code
shell = cb.Shell(outerFaces, shellOffset)
so I will never capture the outside but okay
Then again I should do a copy of the faces etc and place them polar coordinate etc, that jazz
so I guess I have to write somewhat of a function called polarShell?
k
don't think so, just copy and move faces #YOLO
just the convert to polar etc type
Is there an easy way to set the scale of the entire mesh??? Or do I have to do it as:
Copy code
for op in mesh.operations:
  op.scale(scaleup)
No it does not give me the result i hoped for
Copy code
cylinder_radius = 1.546875e-3# 0.0015`
I have for instance everything scaled up by 1.03125, my radius etc from nice numbers. Like offset is 5mm, but in real life it is 1.03125 times bigger
it does not like the weird numbers for the offset, due to how the cells are created
k
I think your problem with this mesh from the very beginning is that you work on scales of very different orders of magnitude
what is wrong?
f
Copy code
### the scaleup was 1.03125

scaleup = 1.03125

geo_z1 = -0.01#-0.05
geo_z2 = 0.01#0.07
cell_size = 1e-3
cylinder_radius = 0.0015# 0.0015#1.546875e-3# 1.546875e-3# 0.0015 original helixes, #  1.03125e-3 #0.001 orginal for flat
workpiece_radius = 8.00e-3 # 8.25e-3 before # 50e-3
offset = 0.005 #5.15625e-3 # distance from outer circ to outer circ 2mm, radius 1.5mm, offset = 2*1.5 + 2 = 5mm. scalup = 5 * 1.03125 = 5.15625e-3 m
shellOffset = 0.01
Kindoff what I want to explain here is that I have these cylinder I can use nice numbers, but in the real world it is a little bit scaled up. so all the
cylinder_radius
,
workpiece_radius
and
offset
get 1.03125 bigger, but if I fill that in as a variable I get the following: With the main issue being that the offset is a non nice number it crashed if for instance I use:
offset = 5.15625e-3
Copy code
File "C:\Users\finne\AppData\Local\Programs\Python\Python311\Lib\site-packages\classy_blocks\items\wires\axis.py", line 130, in check_consistency
    raise InconsistentGradingsError(f"Axis Wires have different counts! {counts} {self}")
classy_blocks.base.exceptions.InconsistentGradingsError: Axis Wires have different counts! {10, 11} Axis 2 (Wire 0-4 (164-216)|Wire 1-5 (187-229)|Wire 2-6 (186-228)|Wire 3-7 (165-217))
Haha if I use:
offset = 5.15625001e-3
then there is no problem
k
how do you set gradings? with a SimpleGrader() or manually?
f
Manual chop
Start=cell_size
k
you defined two blocks separately but they are connected a.k.a. in the same 'row'
with your previous sizes the count is the same but this is just a coincidence; now you changed the dimensions and one count is off
only define counts for a single block in the same floor
or just use
Copy code
grader = cb.SimpleGrader(mesh, cell_size)
grader.grade()
and if you want to control specific blocks, set counts manually before calling a grader
f
Okay so i can just manual chop for the cylinder e.g and then use the SimpleGrader for all the blocks
k
if you specify the inner cylinder completely, you're almost good
try that and see what happens
f
No get a lot of issues there now then, that is why I was chopping. Is there an order for chopping that is important no right?
k
...like?
f
I do the blocks first then the cylinders that is how I choose it
but simpleGrader just works
k
then there's no reason to fix that 🙂
f
it even helped the corner region
k
interesting... I'm not used to things working properly
f
Ow well welcome to my graduation project where nothing works
Meshing multiregion bodies with slip boundaries (thus need smooth mesh even on baffles), internal external type flows. seems not the best deal to do fully opensource
But still unsure if it is a mesh issue... With convergence
k
maybe you could think of a simplified case so that you can validate everything without the mesh-kung-fu
f
Did that done that
Everything works except one geometry
But it has probably to do with the matrix being singular in that case
Pretty hard to prove that though
In electromagnetic there are no fixed boundary conditions to some extent which makes life fun
Anyways wont trauma dump here, thanks for the help with the mesh
k
fingers crossed!
f
For the single hole case, when I go somewhat coarse then the curvature is not nicely captured automatically. Do I have to manually do add_edge? https://cdn.discordapp.com/attachments/1431198883936993300/1443583934536618026/image.png?ex=692999ce&is=6928484e&hm=3534ab735b277f0ff56a2854b871bc88bd68eb2b757d34268d6c4212a40080ce&
k
you can try grader.grade(take='min') or take='max'
it will find the shortest/longest edge in the row and set cell count according to that
f
no but more like this:
Copy code
ring_workpiece = cb.ExtrudedRing.expand(inner_cylinder, ring_radius_workpiece - cylinder_radius)
for op in ring_workpiece.operations:
    op.top_face.add_edge(1, cb.Origin((0, 0, geo_z1), flatness=0.2))
    op.top_face.add_edge(3, cb.Origin((0, 0, geo_z2), flatness=0.2))
isnt the edge just not round?
I was thinking the issue is that the edge is not roun, it is flat
now did flatness 0.2 it makes it easier to visualize dw.
k
if you use flatness != 1 then the edges won't be round
f
yes just to visualize it
I use 1 in the end
So adding edge should work, do you know if the outer surface is top/bottom face? for ExtrudedRing
Copy code
ring_workpiece = cb.ExtrudedRing.expand(inner_cylinder, ring_radius_workpiece - cylinder_radius) 
for op in ring_workpiece.operations: 
    face = op.top_face
    for edge_idx in range(4): 
        corner_1 = face.point_array[edge_idx][2]
        corner_2 = face.point_array[(edge_idx + 1) % 4][2]
        if (corner_1 == geo_z1 and corner_2 == geo_z1):
            face.add_edge(edge_idx, cb.Origin((0, 0, geo_z1), flatness=1))
        if (corner_1 == geo_z2 and corner_2 == geo_z2):
            face.add_edge(edge_idx, cb.Origin((0, 0, geo_z2), flatness=1))
this gives me some issue. Like NaN values
Ah topFace is on the top now and not outside.
Copy code
py
for op in ring_workpiece.operations: 
    top_face = op.top_face
    bottom_face = op.bottom_face

    for edge_idx in range(4): 
        
        corner_top = top_face.point_array[edge_idx]
        polarPoint = f.to_polar(corner_top, axis="z")
        print(f"{polarPoint =}")
    print("\n")
        #corner_2 = face.point_array[(edge_idx + 1) % 4][2]


    top_face.add_edge(1, cb.Origin((0, 0, geo_z2), flatness=1)) 
    bottom_face.add_edge(1, cb.Origin((0, 0, geo_z1), flatness=1))
Logs:
Copy code
polarPoint =array([0.00154688, 0.78539816, 0.07      ])
polarPoint =array([0.00825   , 0.78539816, 0.07      ])
polarPoint =array([0.00825   , 2.35619449, 0.07      ])
polarPoint =array([1.54687500e-03, 2.35619449e+00, 7.00000000e-02])


polarPoint =array([1.54687500e-03, 2.35619449e+00, 7.00000000e-02])
polarPoint =array([0.00825   , 2.35619449, 0.07      ])
polarPoint =array([ 0.00825   , -2.35619449,  0.07      ])
polarPoint =array([ 1.54687500e-03, -2.35619449e+00,  7.00000000e-02])


polarPoint =array([ 1.54687500e-03, -2.35619449e+00,  7.00000000e-02])
polarPoint =array([ 0.00825   , -2.35619449,  0.07      ])
polarPoint =array([ 0.00825   , -0.78539816,  0.07      ])
polarPoint =array([ 0.00154688, -0.78539816,  0.07      ])


polarPoint =array([ 0.00154687, -0.78539816,  0.07      ])
polarPoint =array([ 0.00825   , -0.78539816,  0.07      ])
polarPoint =array([0.00825   , 0.78539816, 0.07      ])
polarPoint =array([0.00154688, 0.78539816, 0.07      ])
Does seem to do any change to the mesh let me see removing second buffer helps.
For the mulithole (sorry for switching much) a linker would be nice, as now when I enhance the z direction we get some less optimal results
Adding the link helped but does not give the exact same result, here is the image of large z coordinate, I do like how it places it I could then technically also reduce the radius further 🙂, Or i just plot the block there as if the radius was there and let the block optimization skew the corner blocks so it still fits inside https://cdn.discordapp.com/attachments/1431198883936993300/1443603497525313666/image.png?ex=6929ac06&is=69285a86&hm=542182c33b8c4c6b4170134d033233539d28d78279815c2a575a742f346404ee&
I have them and their faces, so if I adjust their face points again after optimization would that work
In terms I want to assmble the mesh, optimize it, and use this optimized one to the the rings around 🙂, or even update some of the blocks in the first assembly
Copy code
py

vertices = mesh.vertices.copy()
blocks   = mesh.blocks.copy()

mesh = cb.Mesh()
mesh.blocks = blocks
mesh.vertices = vertices
thought of doing something like this but is not allowed.
k
just optimize, then do mesh.backport() and you'll get updated positions in all shapes and whatnot
f
ahhh mesh.backport() not clear okay I will look into it if I can reposition some face points
k
what do you mean, not perfect? all points are exactly on the circle
optimization shouldn't move anything but the exact points you gave clamps for
f
yeah the points are on in bug the face edge is not
k
well you only have a first-order mesh so if this is what you mean... ?
f
No I will move the manually after optimization, I am not sure how that works out
yes I got that yesterday that isnt possible
k
don't refer to operations' points and move them because moving one won't move others and it's a pain finding out which are coincident
f
What I now would like to try is move these faces I extruded back in (then I wont do this bigger buffer around it that goes away), but I am scared that I am undoing pretty much the optimization I did before https://cdn.discordapp.com/attachments/1431198883936993300/1443891985516724224/image.png?ex=692ab8b3&is=69296733&hm=7f0e629be305357800c9de5fa530d904e6d0b8e63083e472f3bc30f840bc49fa&
k
rather find mesh vertices on those positions and move them, directly changing all blocks defined by them
f
yes that is not really a problem I can just later add the outer rings around it, they points I will be moving are in this case then outer boundaries, so no the biggest problem
k
so after optimization, use cb.GeometricFinder and look up vertices by their position
f
but they will be radial points
let me draw it
So it dont have the sweep around it yet, then the points are easy to be found and then I can add the extra ring around it, that was my idea. Instead of moving vertices
k
ahem, I still don't get it. why don't you make this radius in the beginning? why move now?
f
Because the corner blocks coincide it
it is inside the block structure, and now it is not anymore
In other words it is first limited by
Copy code
outerRadius = ((cylinder_radius * np.sqrt(2) + offset) * np.sqrt(2)) * 1.00001 # Some additional padding, sharp corner fixed in optimization
But I am bit scared that then now the new points will reskew those edges further, so it is a bit of yeah idk. not the best maybe. as now I just deal with not being conformal to my outisde
k
you can start with this geometry and: - use LineClamps for points on diagonals - use PlaneClamps for points inside (whatever you're allowed to move will improve the worst blocks) - use RadialClamp for points that should be on the radius but are not - they will be moved to the circle specified in the clamp
RadialClamp will destroy blocks on the first iterations so you can do optimizer.config.relaxation_start = 0.2 optimizer.config.relaxation_iterations = 10
f
the planeClamps I do not get, but the Radial clamp I might get.
Get something like this
k
yep, you can try with radial first
f
So for me understanding quickly what the RadialClamp variables are as there is not tutorial on it right.
Copy code
def __init__(
        self, position: PointType, center: PointType, normal: VectorType, bounds: Optional[list[float]] = None
    ):
Position
is the point I want to move, so the point I want to go to to the wanted radius.
Center
is the center of the circle here
(0 0 0)
and
normal
is the radial position
(r 0 0)
k
no, the circle is defined by center and normal so your circle normal would be [0, 0, 1]
f
ah okay so this is cylinder axial direction
but how do i define the radius then? I want the point to move too
k
ah, damn, it will just take the default radius
ok, you'll have to use a CurveClamp and for the curve you can use a Circle
cb.CurveClamp and cb.CircleCurve
f
Copy code
py

all_points = []

for face in outerFacesOriginal:
    facePoints = face.point_array
    all_points.append(facePoints)

all_points = np.vstack(all_points)
all_points = np.round(all_points, decimals=8)

unique_points = np.unique(all_points, axis=0)

for i in range(0, len(unique_points), 2):
    print(i)
    pointBottom = unique_points[i]
    pointTop = unique_points[i+1]
    circleBase = cb.CircleCurve((0, 0, 0), (workpiece_radius, 0, 0), (0, 0, 1))
    circleClamp = cb.CurveClamp(pointBottom, circleBase)
    optimizer.add_clamp(circleClamp)
    link = cb.TranslationLink(pointBottom, pointTop)
    optimizer.add_link(link)
Also added a linker but it is not doing much 🙂 Holdup forgot to add the link
It is pulling the bottom z face to the upper z, without linking I just got dimples in the bottom and no extrusion on the top. So I think something is wrong with my curve maybe https://cdn.discordapp.com/attachments/1431198883936993300/1443903203539288064/image.png?ex=692ac326&is=692971a6&hm=970f1cf8d0d4ebaf5cdb2ef52675ae6c66d9929905dc0196c8721215e35f2303&
maybe center of circle needs to be where the points are too
Selecting them separately did help (so using no linker), but it is not being conform to the wanted cylinder, it still does optimization but I want it to be on it. This is better, but some of the faces will not work. It only now does the edges of the blocks
It might be that I did not select them I will look at it after lunch, the smaller the distance I make in the z-coordinate the better it looks 🙂 https://cdn.discordapp.com/attachments/1431198883936993300/1443907590382948495/image.png?ex=692ac73c&is=692975bc&hm=8add38fc9287699552dd7daf93893205bd962fcd3fbd21cf56e67dc1cdcacaa2&
k
looks like death metal
f
why are the points connected to the wrapped discs not moving, when I plot the points it does seem as if they are correctly selected, or is it something with junction? I think it is already a good block so it doesnt minize it further but how do I force it. Or is there some constrain to those points? Can't I just move vertices and then optimize so it can move along the circle line those points? I cannot give some weight somehow?
Even with the plane clamp it is like those wrapped disc points are just stuck, so there is something keeping them stuck perhaps you know? Do i need to select more points for those to move
I now was thinking of moving the face of the wrappedDisk but then I get problems that the connectivity is lost so that is not a clean way.
So instead I will do it by vertices how do I update it to a new position:
Copy code
mesh.assemble()
print(cylinderPointsOld)
cylinderPointsOld = np.array(cylinderPointsOld).reshape(-1, 3)

finder = cb.GeometricFinder(mesh)
for point in cylinderPointsOld:
    vertex_bottom = finder.find_in_sphere(point, 1e-8)
    topPoint = point.copy()
    topPoint[2] = geo_z2
    vertex_top = finder.find_in_sphere(topPoint, 1e-8)
    print(vertex_top)
Btw another remark why my meshing procedure was crashing this is probably a bug:
Copy code
grader = cb.SimpleGrader(mesh, cell_size)
grader.grade(take="min")

for op in mesh.operations:
  op.set_cell_zone("background")
When doing this it will not write background anymore, if i do it the other way around it is fine
k
you make a mesh in two steps, first create all operations, then add them to mesh and create vertices and blocks from them (a.k.a. assembled mesh). once you do that, previous shapes and operations don't matter any more and however you change them won't reflect in the assembled mesh
Copy code
vertex = list(finder.find_in_sphere(point, 1e-8))[0]
vertex.position = [new_pos]
or vertex.move_to()
or vertex.translate() or whatever
f
😭😭😭
Python abstract is sometimes nice sometimes it is a pain. Give me pointers 😅 I will look into the vertex moving in a little
Get some weird clipping now and in the end it is complaining about, like the face is wrongly constructed
Copy code
--> FOAM FATAL IO ERROR:
Block hex (33 41 44 36 35 43 45 37) (1 2 2) simpleGrading (1(1) 1(1) 1(1)) is inside-out
https://cdn.discordapp.com/attachments/1431198883936993300/1443979377456054522/image.png?ex=692b0a17&is=6929b897&hm=b970be558cdaa4ea92df03ffeb60074b0ea7e594c0ba46b740a8e18ada43adba&
I am guessing the LLM gives me a decent anwser here that probably is the issue:
after movement, the face ordering is NO LONGER planar or convex:
.
translate
only did something but didnt do it the right way I wanted it to do, it seems like there is some internal connectivity of sort therefore it also is weird because you would think the cylinder itself would not move. I use a cylinder OneCoreDisk, and then wrapped disk with 5: around that. (ah it is because I messed up translate definition, but the other ones replacing the coordinate or using move_to both had this weird outside face created) or could be thast I put points radially away and therefore gets some issues that the vertices are not on the same x,y line anymore but diverge from each other https://cdn.discordapp.com/attachments/1431198883936993300/1443984827899445269/image.png?ex=692b0f2a&is=6929bdaa&hm=c13ecb9b615766c2e54d0e7aed224b63f74aeb4fc66945e08fc61442da71f2cb&
Let me know if you have some ideas 🙂
Besides it is weird that it moves these internal faces although I think I do not tell it to do that, I might be wrong in my point selection, I will check to be sure. Because that is I think giving the problem https://cdn.discordapp.com/attachments/1431198883936993300/1443999787191111750/image.png?ex=692b1d19&is=6929cb99&hm=398ab980c314210f93b7e68446d2f5315ad6574c7591b8b6fed8afcbe3d26a2f&
As you can see I have to force it as it is some local minima, as now I get one corner correctly extruded see bottom right: https://cdn.discordapp.com/attachments/1431198883936993300/1444001238050934875/image.png?ex=692b1e73&is=6929ccf3&hm=1295b793c27858e795e6663772e7ce4c5b11ee42470168b7d270042e4bf558e2&
Okay I might be selecting the inner points oopsie. I quick debug plotted the points and I am selecting all points on the face, I forgot it was the bottom.
Okay good got it now nicely expanded, not i do not optimize these points because they make a mess of everytinng. How can I make the mesh first very short in z and then after optimization bring back the new z-coordinates keep the chop https://cdn.discordapp.com/attachments/1431198883936993300/1444033098554806382/image.png?ex=692b3c1f&is=6929ea9f&hm=48222a8444d60152cc724ec88fadd87b0be9eea765e9fda24f2ac0f1c8a4c674&
Ig just grab all the bottom/top vertices and yank em down/up 🙂
Copy code
finder = cb.GeometricFinder(mesh)
vertex_bottom = list(finder.find_on_plane((0, 0, geo_z1_start), (0, 0, -1)))
for vertex in vertex_bottom:
    newPosition = vertex.copy().position
    newPosition[2] = geo_z1
    vertex.move_to(newPosition)

vertex_top = list(finder.find_on_plane((0, 0, geo_z2_start), (0, 0, -1)))
for vertex in vertex_top:
    newPosition = vertex.copy().position
    newPosition[2] = geo_z2
    vertex.move_to(newPosition)
Doing this, but then i lose all my chopping and edges
need to update the edges origin 🙂, no clue how to do that from mesh
k
🤔
that's a tricky one, one sec
go through edges in mesh.dump.edge_list.edges
and check
Copy code
from classy_blocks.items.edges.arcs.origin import OriginEdge
if isinstance(edge, OriginEdge):
    edge.origin[2] = <z>
in our language we say something like "reach the pocket around the butt"
a.k.a., you'll get there but a simple sketch would simplify just about any step you took to get to this point
f
I 100% agree, but i rather stay in my rabbit hole
❤️
k
a.k.a. snappy
and now the beast
f
yes that is the biggest pain, outside my control, some aspect ratio thing issue, I have to make fine z, so the h-grids are more nicely square. So in the end still quite some cells, but o well best I can do. Something to figure out on monday
I get now in the issue of aspect ratio, the internal structure is much slimmer then the outside the aspect ratios get screwed with 🙂 So i have to better chop, and look into a bit how I want to chop, might want to chop the internal structure cellsize/2 or 4 and the outside just cellsize
for some reason it also didnt do the internal smoothing bits now, for another mesh it did even when I set it to 0 so o well
This is a bit better, to just make it the same, although more coarse from the start thus less round, except for the cell on the inside as it does not have its face move to the outside edge. Perhaps it would be better when i grade it after i move the vertice or does that does not make a change in the block in the end how it is written, I guess it would as it is a sperate block. several non-orthogonal cells >65 degrees https://cdn.discordapp.com/attachments/1431198883936993300/1444973909408612433/image.png?ex=692ea852&is=692d56d2&hm=b54fe5bd9aaafd84a89e9efba8c7ad719af09d3a5a82967b3b84626a88947462&
k
you can try with directional chops first, ESI snappy can do that
f
I used to chop tangential and radial by cellsize / 4, and then axial cellsize / 2, but still create to large aspect ratios in the center.
k
try changing the core size - in the beginning of your script, add
Copy code
from classy_blocks.construct.flat.sketches.disk import OneCoreDisk
OneCoreDisk.core_ratio = 0.8 # try some different numbers
f
I did 0.6 to be the best for the single hole
for the best aspect ratio
I can perhaps tweak with it for the multihole... But I think that is a bit analogous
k
I'd really try to add snappy regions where the cylinders are and refine in z-direction only
f
I do not get what you mean with that, what do you mean by regions. Are you saying something like this:
As to say like we would have background, the 'conductor' and the inverse of it (for me that is the fluid) but does not matter what it actually means
Or do you mean the following:
you can chop blocks in one direction only, in this case you can decrease your AR twofold
f
AR?
k
aspect ratio
f
The issue is that I need a boundary layer with usage of levels
In this case I would creaste boundary layers by using the block on it own by means of chopping
Which is an intersting strategy
Because then I cannot use any levels anymore. I want the surface up to level 5, in all directions. If I use this strategy then in a sense I need to get that level 5 by means of using the wrapped disc, and chop that up to level 5 and then expand to cell size. Or you disagree? You can only not chop the cylinder from start to end_size which is logical. As I am mainly interested in what is outside the cylinder
k
not sure what you mean by levels, you first chop your background however you think is appropriate, then refine in z-dir only what causes problems with snappying
f
yes, I need refinement around this let me draw it rq
something like this but then ofcourse it will be more local, but it need to expand the mensh size as the gradient is only very local steep, even steeper then in turbulent boundaries 🙂 https://cdn.discordapp.com/attachments/1431198883936993300/1444998038366978089/image.png?ex=692ebecb&is=692d6d4b&hm=e3ca2ce85275356a58144097e3e176a31325e8a2bd1c0619ccc4b9edd92cc1d9&
Copy code
for cyl in cylinderList:
    cyl.chop_radial(start_size=cell_size)
    cyl.chop_axial(start_size=cell_size)
    cyl.chop_tangential(start_size=cell_size)

for block in blockList:
    block.operations[5].chop(0, start_size=cell_size_local, end_size=cell_size)
lets say I have a refined cellSize
cell_size_local
and the background size:
cell_size
and I am still using:
Copy code
grader = cb.SimpleGrader(mesh, cell_size)
grader.grade()
Some chops I change have no influence in the end on the mesh probably because of neighbours
k
grader shouldn't override anything you specified manually and should let you know something is not consistent
f
wait i made a small oopsie
I was saving it in a different dir, then where I blockMesh in so I was using an old one...
k
But of course. No biggie
f
It is time to make blockMesh run in parallel now haha
k
hope someone hears you
This works fine except there is the issue of the workpiece radius which also needs refined levels
IN essence we also need this that is why SHM would be nice, but is your contour argument then to just use different regions for that in one stl? Is that possible. To do the directional meshing only for one sub region (meaning the inner walls) of an stl? I do not think so https://cdn.discordapp.com/attachments/1431198883936993300/1445004620572131489/image.png?ex=692ec4ec&is=692d736c&hm=0a6a6e89c338a788138e38f25c9b80eb75b6f452c6b600c71ff0a12635dabbc5&
It would have worked lovely if my holes were not so dang close to the walls. Otherwise I could get away with using some rings (or in my case my more custom rings that I then can grow), llets say two sets of these. But that is not possible unfortuntely
Besides the cells far away from the conductor will keep AR issue, or you have to also divide those which results in high cell counts. So I think this strategy although on paper might be nice is not the simplist to get the results I think. But it is something to be considered later perhaps. Besides I also have top surfaces that needs refinement and that is not done now, so that would be in the axial direction I do need some cell growth.
It probably would work really well for a single hole case as i can put the rings around it
k
f
Mmm could look into it later, perhaps makes it even less trivial
My graduation project is a pure failure at this point, still not able to get any converging results for these meshes on some I am able some I am not, which gives the reason of plausible mesh issues still. So at this point I am severely upset. This is part 1/3 that I should have done, down the road is a lot of verification on CFD while this is only part of electromagnetics
Planning for myself was to be done with this 2 months ago
My thesis will just be writing about failures😭
It is also difficult to investigate where it goed wrong. There is an indirect slip condition. So wherever the mesh is not smooth you get issues, but it does not explain some other results.
A simple cylinder is no problem
I might give ICHEM a shot and hope it can nicely write cellZones I can split, from -writeSets
k
This all still sounds suspicious to me. Mesh IS usually the problem but as long as it's okay-ish you'll at least get results, not explosions... Poor accuracy like +/-10 or 20% could be the mesh but when it's all okay and still no convergence at all... IDK
f
Some do converge some dont
I would then expect immediate divergence which doesnt occur
I agree
However when I made small alteration to the background mesh and the mesh was still adequately orthogonal it did not converge anymore. I did have convergence on mesh that wouldnt converge with PCG and reference value. Checked the geometry and have high artificial spikes on the surface. deflatedPCG with any precondtioner did not converge
o
at this point try marchingHex and algoHex to see if you can get a usable mesh.
f
I need surface refinement
May aswel then use ICHEM
Do some boundary layers
o
marchingHex will give you fully hex snapped you could try then using snappy for the layers and other.
f
Ow so marchingHex as sort of blockMesh
o
no, it is unstructured mesher
think of it as snappy but that it goes to snapp stage, and the snappying cells will be hexas.
also with way less possiblities, such as level refinement.
f
Yes but then you use this as input to SHM to do the castellation?
And is that code even possible to do baffles
From quick glance it is not, nvm i see bimaterial
It can only do 2 materials as I will have 3 or 4, then I will need to let snappy do the other two “less” important results
It is strange just that with less coupling there is no issues
So from the given medit output how does one make it go to openfoam
Running the example cases I do not get anywhere near the same mesh results as shown on the repo.
Okay the bimaterial meshes look good, I try input vtk generated from stl in paraview but it does not like them, even when I remove the sub regions in it. I used meshio to convert it from stl to a vtk file.
o
I think it might be due to the library using the old legacy vtk format. And paraview might export in newer one.
I found that a lot of libraries around use legacy vtk, and some programs do not export. You can in gmsh of the popular ones but not Salome or paraview (if I remember correctly )
I don't think it supports .ore than 2 materials but do not hesitate to open issues I know François he is super nice folk and he is super happy to improve his tool
f
I dont know anymore I tried so much everything fails
I dont really have time to tinker around and try make things work. Like i did the last 5 months. I will have a discussion with my postdoc
k
Maybe you try and borrow a commercial mesher just to confirm the mesh is actually the culprit. At least then you'll know what to work on
f
I can use ICHEM it will take some time to build the mesh there
I have a free slip condition, n*j = 0, but I do not directly solve for j, but the boundary condition is derived from j. Now I am showing the recombined variable of j from what I solved and these edges are like small corners
Addditioanlly they only occur on these edges and not on the inside edges
k
what the.?!
f
ow that text should been for myself
k
your snappy has snapped
f
I only do 30 smoothing displacements
yeah I have no clue anymore
life is not converging anymore
that is going to be my new quote
k
f
no i am not stretching, the only thing I am streching is my hair
Copy code
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

debug 0;
mergeTolerance 1E-8;

type castellatedBufferLayer;

castellatedMesh true;
snap            true; 
addLayers       false;

geometry
{
    conductor.stl
    {
        type triSurfaceMesh;
        name conductor;

        regions
        {
            conductor_thermal_wall 
            {
                name conductor;
            }
            conductor_internal
            {
                name conductor;
            }
        }
    }

};

castellatedMeshControls
{

    maxLocalCells 3000000;
    maxGlobalCells 50000000;
    minRefinementCells 10;
    nCellsBetweenLevels 2;

    features
    (
        {file "conductor.eMesh"; level 5;}
    );

    refinementSurfaces 
    {
        conductor
        {
            level (5 5);
            faceZone        conductor;
            cellZone        conductor;
            cellZoneInside  insidePoint;
            insidePoint     (-0.00087 0.00505845 0.0224474);
            faceType            internal;
            addBufferLayers     true;
        }



    }

    resolveFeatureAngle 120;
    planarAngle         180;

    refinementRegions
    {
        conductor
        {
            mode inside;
            levels ((0 0));
        }

    }

    locationInMesh (1e-13 1e-13 0.04);

    faceZoneControls
    {
        conductor_to_background
        {
            faceType internal;
        }
        background_to_conductor
        {
            faceType internal;
        }
    }

    allowFreeStandingZoneFaces no;
}

#include "snappyHexMeshDict.include.meshQualityControls"
#include "snappyHexMeshDict.include.snapControls"

addLayersControls
{
}
k
this shouldn't happen in any case, something is terribly wrong - looks like cells are snapped before castellation
f
most trivial SHM
yeah I am now doing castellation and snapping seperate not using -overwrite to see what the helly is going on
can be the castellated buffer mesh
would nSmoothPosition help though... mmm maybe
For the surface issues I can probably increase nSmoothPatch, but then lose a bit of my corners...
I feel like i am wandering on some track going nowhere lol
k
no, I think you should throw out all bells and whistles and just go with vanilla snappy
smoothPatch is a scam
1 to 3 iterations tops, then it ruins the mesh if it's not already smooth enough - actually just moves points on surfaces and leaves the ones below fixed - imagine what this can do to the first cell layer on the surface
f
Copy code
actually just moves points on surfaces and leaves the ones below fixed
what do you mean with that nSmoothInternal? Or displacement
I am doing as vanilla as Ican
except the buffer so I can try turn that off
k
nSmoothPatch is the vanilla keyword and is mostly useless
nSmoothInternal is an ESI thing and could help but in your case it looks like something like smoothing is ruining your mesh
f
I have nSmoothPatch as 1
nSmoothInternal as 0
k
plain internal smoothing (that's 3D!) wants to equalize cell sizes and in your case it looks like it's making more refined cells bigger, pushing them away while the larger ones stay put
f
ESI also does make polhedrals isntead of using hexehedrals on transition
k
they all become polyhedral but with 4 coplanar faces
f
but I do not use any internal smoothing btw
k
nSmoothInternal, try turning that off
f
it is off
it is 0
i can set it to -1 but I think that wont change anything right?
anyways time for lunch
k
An Ylvis song comes to me mind On a scale from 1 to 10, my friend, you're fucked
f
I learned a lot lets keep it at that. Not that the above people care
at this point I am like lets just ony castellate HAH
lets do nSmoothPatch -1
It also the blockMesh has some skewed faces, because of the transition from round to square. But that can be resolved with just using round.
It is the castellatedBuffer mesh giving the issues so far
Maybe something with the laplacian point smoothing
k
most probably that, yes
f
No buffer meshies for me
Been doing now something in Ansys fast octree mesher which is pretty much SHM, the exact same mesh to some extent still verified (but showing same level, snapped boundary layer, and square background mesh) 21 million cells in 169 seconds on 16 cores nice just nice
Quite wild tool, but i have research license so I will exploit it for now
But not reasonable for anyone in small corporation
Fluenbt creates more something like this, but this is for now only internal meshing. I am not yet able to do both internal and external meshing https://cdn.discordapp.com/attachments/1431198883936993300/1450097417939849388/image.png?ex=69414bf5&is=693ffa75&hm=89448b67b014dd0af01e48d49448642d013e21921a382cbec44affe69edc6412&
But I think it is not able to do multiple bodies...
k
it doesn't snap to feature edges - which you can also try but AFAIK you need sharp edges, right?
f
yes it probably can I just didnt do it correctly
but i rather have these type of edges then the jagged ones I get from SHM. I think generally this is a bit better
k
then just do
explicitFeatureSnap false;
also implicit
f
but it should still follow the geometry
but I am quite scared it wont do it nicely, I can try
Copy code
A known limitation of the Rapid Octree mesher is that defeaturing can occur at inlets, outlets, interior boundaries, and so on, such that the surface area of a generated boundary does not exactly match that of the original geometry. You can attempt to minimize such defeaturing by assigning boundary types, refining the mesh, and/or defining boundary conditions (as described in Limitations of the Rapid Octree Mesher). If such attempts are not sufficient, as part of the Boundary Projection treatment method you can enable the Improve Geometry Resolution option. This option applies an iterative projection of boundary faces onto the geometry, with the goal of minimizing the distance of the boundary face centroid to the geometry. This “face projection” is then internally iterated with mesh smoothing steps to improve the cell quality.
This is with Ansys
k
it will snap to surfaces but not force edge cells to snap to actual edges
which is that ansys thingy exactly
f
wont that lead to even more jagged edges
I will try it
k
not sure, probably not (but also depends on snapping tolerance)
f
that is 1
it I increase it will it be more smooth>
k
less
f
isnt 1 the lowest?
k
I'd use something like 0.5
f
okay I will try that aswell
k
no, you can use any number, you'll get warnings that no surface was found within point+tolerance
those points will just remain in place during snapping
f
okay job is submitted lets see
I might think it is caused by being first order mesh it cannot do it nicely
it i make the tangential chop to fine i might run into issue regarding how thin the cells become there. I can also adjust the core ratio. Let me know if you have any advice or could it be due to it being too fine
Yep coarse is better in this case... (this is still with feature snapping enabled besides the other without feature snapping seemed to be not really helping https://cdn.discordapp.com/attachments/1431198883936993300/1450130978453458954/image.png?ex=69416b37&is=694019b7&hm=bbd97adea68c0f17ce0fe859ba4cf4a46bb69aac72ab15154b5bd14c809c5ef0&
Because I want to do a mesh sensitivity analysis this kinda sucks.
I am now not even sure if it help to have a hole tehre lol
or it some sort of snapping setting I am missing
k
that looks like your snapping tolerance is too low (?) but yeah, now the edges look more like that mesh fron ansys
what does this have to do with mesh sensitivity? you'll rack up cell count and a sharp edge is a sharp edge regardless of your cell size - local situation is the same
f
so that is not the case as it refines how the hole is being captured and it then leads ot that, ill try snap tolerance tomrrow to 4
tolerance 4
might be a bit extravigant
It is sitll a bit iffy might be that I turned off explicitFeature snapping the edges cell are not going to the feature. So I turn that on again and see if it helps. We are getting somewhere https://cdn.discordapp.com/attachments/1431198883936993300/1450418712170598516/image.png?ex=69427730&is=694125b0&hm=89cac40d73a0f2ad40e0b0832107ffa3e9d783fbad395203acacb44a40acaafd&
o
so why not to instead of this, give a fillet to the geometry even if it is small one
f
I have asked, good one.
I will have to see the edge effect is really important thing in electromagnetic induction
o
À really small fille will help and in reality you would have this in practice
f
Yes when we scale it up indeed
I will have to capture it in the stl reminder for myself
I guess adding layers that collapes on the outlet patch make my life hard. Can be with the applied boundary condition it is somewhat a velocity field maybe creates large values there, also a tolerance type of issue
snapping to this boundary line I get ba quality mesh although the inlet is not fixed as I do not use any snapping anymore https://cdn.discordapp.com/attachments/1431198883936993300/1450511810083160094/image.png?ex=6942cde4&is=69417c64&hm=791b4c25e2cc4764b0e148204703d8d782b901fb02d2199556d9a222cdc95da4&
The orthogonality is quite poor
snapping layers work except when it starts to hit the inlet it gets issues I can perhaps use some errosion so it does not occur directly on the inlet. Like ngrow 1 instead of 0
wait it is internal smoothing oopsie
I cranked it from 4->6
not really a difference
I was able to converge one of the finer mesh but literally on of these cells stucking out of the surface give huge problems. I had to underrelax the solution and then still this pont gives much larger values. It is likely mesh finer it can more easily snap out of place? Any setting anyone would recommend. This cell at an edge so probably not much that can be done https://cdn.discordapp.com/attachments/1431198883936993300/1453360191125979229/image.png?ex=694d2aa7&is=694bd927&hm=fe7a6376191ccc4f0445463d45bade3008e790a40a6ffe349c76d9ee6795752e&
so close to the edge
I might have used tolerance of 40 maybe not so nice
t
I made a Snappy test with this extrudeMesh approach. I modelled the extrusion profile in Blender to body-fit surfaces on the extrusion direction, like this https://cdn.discordapp.com/attachments/1431198883936993300/1454018719276732467/image.png?ex=694f8ff5&is=694e3e75&hm=d08e8d29a607c7dfd435d70631cb770dd462ea12f90dd00adbde7cc338df8495&
The problem is that Snappy is unable to smoothen the terraces much. Here's snapped result at the same location as above. https://cdn.discordapp.com/attachments/1431198883936993300/1454019941215899650/image.png?ex=694f9118&is=694e3f98&hm=c8edd1a93d71b96c517cbaaf639c2c1b844dd7e7049b950dbfad5b4fc2930c05&
Conclusion: This approach would work only if you can live with the castellated mesh.
The only way I can think of to create a fully body-fit orthogonal and conformal mesh at the region interfaces is to manually hexa block the thing in 3D. Massive job.
f
the simulation works fine for coarser grids. It is just that that given cell does not have any neighbors. Pretty much best would be if all cells on the surface have a neighbour, in the sense on the boundary not into the internal mesh. Your mesh has that so that is great, that is pretty much where it goes wrong when going fine.
that is outside the scope. I considered it before for 3 minutes but that is difficult to block that out.
The current thing we are looking at btw, is just a single hole in the center no side holes, made it myself a bit easier.
So I want to get rid of these badly snapped cells, and that these edges just are more straight, in other words just have neighbors. The staircasing is not a problem. Just for the boundary issue you have to think I am using a free slip boundary. I even have issues with these kindoff cells in a Poisson equation, for the source term \nabla^2 phi = \nabla \cdot \mathbf{u}. In a sense \mathbf{u} can take on slip or free slip, free slip becomes an issue when it doesnt have any neighbors on the surface. https://cdn.discordapp.com/attachments/1431198883936993300/1454022974310191177/image.png?ex=694f93eb&is=694e426b&hm=593c3b957f8764ee9687fdcdebc8735b61359331ca8cfe074f3f1e2763619ff5&
t
I don't understand what you mean by given cell not having neighbors. All of these cells in the castellated mesh have neighbors except at outer walls.
f
Btw I use a body conformal background mesh, it is just for a single hole an O-grid.
like this one seconnd
I think when the cell has all it faces for free slip, it gets a very high unphysical value, as it if would the surface be smooth then it would never be alone, this leads to convergence issues. Or atleast I am quite certain it does
With some underrelaxation I was able to get it to converge (finally), the finer mesh, the coarser mesh did not have this issue as it is easier to then snap the cells together, or it will automatically do instead of more locally. I dont really have the correct words, to put it.
But by any means I do not fully get why it is causing an issue around those cells. Along the surface when I go to finer meshes, the mesh becomes more and more conformal the finer the background mesh I choose.
Beside the mesh you showed has no level refinement, besides I am not sure if you have the coupled mesh to the background, because the mesh your made with extrude mesh does not confine a box around it.
tkeskita, totally different topic, I was thinking about (probably never will happen), can't you just given a geometry, make a good boundary layer code, to just for instance snap 1 layer, not restrictions on the a background mesh. Then introduce the background mesh, and move vertices to the snapped layers in someway. Then you can even do this on the sides of a surface, and you will get the most conformal meshes there are right? I think the only issue in the part of making the mesh connect just to hexahedrals, fluent does it with polyhedral layer, but I do not like those balloon shaped polyhedrals. Does this sound dumb? It is probably way more complex then it sounds here. Moreover, I had the idea, you can also just do some sort of IBM you will need some extra cells on the other side of geometries, but then you can just use a structured grid and let interpolation do its thing. Would even be cheap because those boundaries are stationary. (I think it is as in this paper from 2016 https://hal.science/hal-01319421/file/journée_openfoam.pdf, https://arxiv.org/abs/1609.04364)
t
If you got rid of the side holes, then you could theoretically extrudeMesh a vertical cross-section around the center axis with elevation, like the Screw Modified in Blender. That would result in perfect conformal orthogonal mesh.
f
Okay I think it is not clear to you, but I also need external mesh. It is both internal and external. In other words I need the inverse, let me open my blender
Copy code
snapControls
{
    //- Number of patch smoothing iterations before finding correspondence
    //  to surface
    nSmoothPatch 1;

    // Number of smoothing of internal points on refinement interfaces
    nSmoothInternal -1;

    //- Relative distance for points to be attracted by surface feature point
    //  or edge. True distance is this factor times local
    //  maximum edge length.
    tolerance 4; // changed from 4 09/10/2025 19:45

    //- Number of mesh displacement relaxation iterations.
    nSolveIter 30;

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
    nRelaxIter 30; // changed from 20

    //- Highly experimental and wip: number of feature edge snapping
    //  iterations. Leave out altogether to disable.
    nFeatureSnapIter 8; // changed from 10

    //- Detect (geometric only) features by sampling the surface
    //  (default=false).
    implicitFeatureSnap false;

    //- Use castellatedMeshControls::features (default = true)
    explicitFeatureSnap true;

    //- Detect points on multiple surfaces (only for explicitFeatureSnap)
    multiRegionFeatureSnap false;

    releasePoints          true; // new test
    avoidDiagonal          true; // new test
    minAreaRatio           0.8; // new test
    concaveAngle           25; // new test
    strictRegionSnap       true; // new test
    nFaceSplitInterval     5; // new test
}

// ************************************************************************* //
I think it might have to do with minArea Ratio and concaveAngle that might helped with it a bit
I think it might have to do nothing with them, jsut that I increase nRelaxIter so it can resolve these skewed cells, although it is really slow.
Copy code
Iteration 55

    faces with skewness > 1.5 (internal) or 2   (boundary) : 6956


Iteration 56

    faces with skewness > 1.5 (internal) or 2   (boundary) : 6931
just a slow process ig.
t
How does your castellated mesh look like here, for comparison? I'm guessing those weird islands are there because castellated mesh has holes.
f
Yes I think so, I will have a look, what I currently test is increasing nRelaxIter to a large amount helps, but it needs more then 130 relaxation iterations at some point. If it is the issue in castellation, there is not much I can do right? I get more holes when my inner hole in the blockmesh is more nicely refined.
t
Castellation result is a matter of tolerance between bg mesh and Snappy surfaces. Need to play with those to get it right.
f
So the thing is...
I have classy_blocks script. It works for 1.2e-3 1.1e-3 1.0e-3, 0.8e-3 gets issues. For mesh senstitivity study I rather not tweak around with the blockMesh, it is a bit inconsistent.
Higher tolerance is more better, but it needs more relaxation iterations from my understanding. Otherwise it is worse
I am instead going to rewrite my solver partially (I think it is loading in a lib and probably some minor code tweaks), to solve it in terms of the immersed boundary method, and use a structured grid. Opensource hexahedral meshing of curved sharp geometries are a no go after 4 months of struggle. The only thing I am a bit sceptical about is contstructing a CHT BC in IBM, in short duration of time. Anyways that is kindoff my idea currently.
t
Is that still for your master's, or have you gone over the edge to starting PhD? Why start another completely different approach?
(Sorry for negative tone, I don't know how hard that would be actually)
f
No still busy with my thesis
The reason why is that I cannot mesh the boundary conform, making my solutions not converge on various meshes and geometried. And the equations I am solving get very high values near the walls controversial to fluid dynamics. Simple geometries do converge, but have low benefit in real world applications.
I just wanted to quickly have a check if it possible to do it with IBM before the next person gives it a try. I cannot simulate a coil even at a fine grid. Little bit of underrelaxation helps but still get various spikes of a variable on the surface which are mesh artifacts
t
How much calendar time you've got left?
I'd say you've already got covered quite a lot, tested a lot. Just saying that this clearly isn't an easy topic, so it's OK if you don't fully solve it in a masters thesis work.
f
2 months
I understand you completely, but now it just mish mash of fluid dynamics and electromagnetics without a clear quantitative validation. For myself it is still quite a failure 🙂
Let alone a chemical reaction is still missing. But to be fair a multiphysics conjugate heat transfer reactive (immersed boundary method) CFD is maybe a bit much to do in 7 months. Although if meshing wasnt a problem I would have pulled it off, wrote the entire code for it to do the multiphysics coupling in a month or so. But that mesh is just so annoying and out of my field to fix
Everything is dependent on the mesh that quite literally cannot be done better with SHM, if you first add a layer and then do the castellation would be much nicer for the boundary conformity without any sunken in or pushed out cells/islands.
Besides if I do a PHD has diverged quite a lot. I do not know if my passion is there, as well as I am quite burned out from all the information and constant failing during this MSc, I think largely due to no one closely having any expertise in what I am researching which leads me to solving not anticipated hard problems.
Including the IBM seems not too hard to implement although I would need to start on it, I have to change some calculated boundaries within the code. But the rest is nicely incorporated in foam-extend, by just loading a lib you get the BC needed. Additionally I will need a lot of storage for all the sub regions which will just take the entire region now (or I need some method to have select a boundary around the stl outside and select 10 or so cells cut that off, can be done with something like a buffer stl and not define any boundaries on it so it doenst refine, but okay for layer). But I am unsure if it will work together with fvBlockMatrix ,although it is just a makeshift fvMatrix which has some nice functionality, so it might just work.
t
For a PhD to succeed, the person needs someone with relevant expertise both as a supervisor and as an advisor/instructor. If this is not the case, then I can't recommend that route for anyone.
f
Yes there is some expertise in the fluidized bed but not in the regeneration using electricity. But the project at the same time had 26 institutions and 4 universities, but inhouse there is not much expertise.