Hi, I wrote a script that warps a reference plane to a surface and keeps off-planar nodes perpendicular to this surface - a pictures is worth more than a thousand words:
This way I can create a simple mesh using the move/copy mesh tool and warp this in the desired shape.
I made this fully parametric now so that I can also model surfaces that cannot be expressed as z=f(x,y), e.g. a cylinder. I attach the scripts for a cylinder, hypar and paraboloid as examples. I also attach the base grid again, but now properly put at z=0.0 so it will work out of the box.
Thanks again harryvanlangen!! Yesterday I was thinking that this tool could be phenomenal to fillet corners . ¿Do you think that could be possible? I would say the final shape should be the cilinder after selecting a set of nodes in the corner. Probably the normal at that point can be very hard to solve as there are too planes involved.
That's fantastic @harryvanlangen. I notice it seems to preserve the equal sizes of the elements, so it it kind of "wrapping" the mesh over the surface without stretching it more than it has to?
@disla - yes filleting would be among the applications, but will require a dedicated script with a parametric description of the fillet surface.
@Victor - how the reference plane gets stretched all depends on its parametric description. The off-plane nodes remain perpendicular to the surface and at their original distance to it.
This scripts does a semiautomatic adaptive mesh refinement for models with all quad8 elements. Each refinement has to be solved manually and then run the scrips that estimates the error on each element from Zienkiewicz-Zhu Von Mises stress and makes a selection to be refined with elements exceeding a tolerance. Then Menu Mesh Tools > Refine > x3 should be used, and the refined mesh may be smoothed and begin the process again.
In the picture you can see 6 refinements of a Kirsch problem. Blue elements are the elements selected to refine.
Unfortunately in this example convergence is slow due to bad shape of the elements on the right side. In the next picture there are not problem of element bad shapes.
Preocess could be further automated if there were an api command to do x3 refinement and if there were somehow to know using command mw.solve() if solver ends OK or not.
I have a named selection of elements to be refined and I want to refine them x3 in a script, but mw.refine_x3 requires the node_ids list. How can I get the list of node_id of the nodes belonging to the elements in a named elements selection or to a list of elements?
I found this way, but perhaps there is an easier way:
nodosref=[] for e in mw.named_selection("Refine"): for n in mw.nodes(e): if n not in nodosref: nodosref.append(n)
@German it's OK to have duplicates for refine_x3() so you could omit the if n not in nodosref: line. Or if you need no duplicates for something else, use a dictionary with node numbers as keys like:
nodosref={}
for e in mw.named_selection("Refine"):
for n in mw.nodes(e):
nodosref[n] = None
mw.refine_x3(nodosref.keys())
@German You can use the Python import functionality. I would think this sort of helper function makes more sense as a user-defined thing like that to keep the core API simpler.
You can't use Numpy arrays but you can use a list of lists. Eg. to create a 4x3 "array" initialized to all zeros: a = [[0] * 4 for i in range(3)] and index it like a[0][0] = 3
I improved the adaptive mesh refinement script. Now, before refinex3 is applied, it improves the list of nodes to be refined, adding those vertex that have 2 neighbor vertex (from different elements) to be refined. This avoids the generation of high valence vertex (and highly distorted elements) during refinement. Compare the old refinement sequence.
with the new sequence
Note the nodes that are added to be refined that didn't belong to the original elements to be refined.
Im attaching 2 scrips. One works with CCX solver and uses ZZ error estimation. The other works with internal solver ald usas VM stress difference at nodes as error estimation.
FLIPLINE2: A Line2 coordinate ranking script to adjust U-axis directions. A time-saving alternative to Invert Tool requiring less selection scrutiny.
Any constructed mesh might result in random alignments of element axis (through construction order, mirroring, extrusion direction, etc). If (U,V,W) output vectors are of interest, it is best to align the element axis.
Notably, Line2 element U-axis directions are not changeable thru Element Properties (U-axis locked out). Fortunately, the Invert (Mesh) Tool will reverse selected elements. However, as beam arrays grow larger so does the time to selectively pick out the random "backward" elements.
FlipLine2 aims to save time by aligning blanket selections of elements at once, regardless of initial orientation, thereby eliminating the selective pick. For every Line2 element selected, this script geometrically ranks the end-node coordinates w.r.t. a chosen Global Axis, and re-assigns their order to reflect a positive U-axis direction.
RECAP: Invert Tool will reverse EVERY element selected. FlipLine2 will ONLY reverse the "backward" elements (per chosen direction), leaving the other elements in the selection untouched.
Test out the script on the included file below. Pre-select ALL the elements.
HOLEADJUST: Adjust node spacing uniformly along a circle. Re-posting script to repository here from Forum discussion RE: "Generate a circular surface area around the hole".
In the method of forming a washer perimetry with Mecway Hole-Tool and then creating a washer surface by extruding inward, bad elements can be formed due to irregular spacing of edge nodes. HoleAdjust.py is an optional tool for conditioning the hole edge spacing before executing Extrusion command, thereby creating a uniform washer surface mesh.
Works on any plane in 3D space. Transitions to the parent mesh can further be softened with the Smooth Tool. Some choices of 12:00 & 3:00 input positions will skew the transition elements more, so select the more obvious, symmetrical starting positions produced by Hole-Tool.
Superimposition of solutions I wrote a python script that can superimpose stresses of different solutions. I wanted to apply thermal stresses to a safety valve under pressure, but didn't want the thermal expansion of the material to be constrained by the displacement boundary condition at the attachment point of the valve to the plant. I have therefore created two load cases which are solved separately and whose solutions (only stresses) are read out from by a script, superimposed and then written to a new .liml file.
The two load cases need to be solved and saved in separate files, and there may only be one configuration per file. Make sure the field variable "stresses" is present in the solution branch in the outline tree.
Comments
This way I can create a simple mesh using the move/copy mesh tool and warp this in the desired shape.
It sames to manage Shells and Solids too. !! It is like a super "project into surface".
I can't wait to try on cicular platforms/handrails.
Yesterday I was thinking that this tool could be phenomenal to fillet corners . ¿Do you think that could be possible? I would say the final shape should be the cilinder after selecting a set of nodes in the corner. Probably the normal at that point can be very hard to solve as there are too planes involved.
@Victor - how the reference plane gets stretched all depends on its parametric description. The off-plane nodes remain perpendicular to the surface and at their original distance to it.
Each refinement has to be solved manually and then run the scrips that estimates the error on each element from Zienkiewicz-Zhu Von Mises stress and makes a selection to be refined with elements exceeding a tolerance.
Then Menu Mesh Tools > Refine > x3 should be used, and the refined mesh may be smoothed and begin the process again.
In the picture you can see 6 refinements of a Kirsch problem.
Blue elements are the elements selected to refine.
Unfortunately in this example convergence is slow due to bad shape of the elements on the right side.
In the next picture there are not problem of element bad shapes.
Preocess could be further automated if there were an api command to do x3 refinement and if there were somehow to know using command mw.solve() if solver ends OK or not.
https://hvlanalysis.blogspot.com/2023/07/principal-stress-plots-with-mecway-and.html
Example:
https://hvlanalysis.blogspot.com/2023/07/reinforcement-of-concrete-structures.html
Example:
How can I get the list of node_id of the nodes belonging to the elements in a named elements selection or to a list of elements?
I found this way, but perhaps there is an easier way:
nodosref=[]
for e in mw.named_selection("Refine"):
for n in mw.nodes(e):
if n not in nodosref:
nodosref.append(n)
mw.refine_x3(nodosref)
refine_x3()
so you could omit theif n not in nodosref:
line. Or if you need no duplicates for something else, use a dictionary with node numbers as keys like:Is it possible to run a script from another script?
Regards.
a = [[0] * 4 for i in range(3)]
and index it like
a[0][0] = 3
Now, before refinex3 is applied, it improves the list of nodes to be refined, adding those vertex that have 2 neighbor vertex (from different elements) to be refined. This avoids the generation of high valence vertex (and highly distorted elements) during refinement.
Compare the old refinement sequence.
with the new sequence
Note the nodes that are added to be refined that didn't belong to the original elements to be refined.
One works with CCX solver and uses ZZ error estimation.
The other works with internal solver ald usas VM stress difference at nodes as error estimation.
Any constructed mesh might result in random alignments of element axis (through construction order, mirroring, extrusion direction, etc). If (U,V,W) output vectors are of interest, it is best to align the element axis.
Notably, Line2 element U-axis directions are not changeable thru Element Properties (U-axis locked out). Fortunately, the Invert (Mesh) Tool will reverse selected elements. However, as beam arrays grow larger so does the time to selectively pick out the random "backward" elements.
FlipLine2 aims to save time by aligning blanket selections of elements at once, regardless of initial orientation, thereby eliminating the selective pick. For every Line2 element selected, this script geometrically ranks the end-node coordinates w.r.t. a chosen Global Axis, and re-assigns their order to reflect a positive U-axis direction.
RECAP: Invert Tool will reverse EVERY element selected. FlipLine2 will ONLY reverse the "backward" elements (per chosen direction), leaving the other elements in the selection untouched.
Test out the script on the included file below. Pre-select ALL the elements.
Re-posting script to repository here from Forum discussion RE: "Generate a circular surface area around the hole".
In the method of forming a washer perimetry with Mecway Hole-Tool and then creating a washer surface by extruding inward, bad elements can be formed due to irregular spacing of edge nodes. HoleAdjust.py is an optional tool for conditioning the hole edge spacing before executing Extrusion command, thereby creating a uniform washer surface mesh.
Works on any plane in 3D space. Transitions to the parent mesh can further be softened with the Smooth Tool. Some choices of 12:00 & 3:00 input positions will skew the transition elements more, so select the more obvious, symmetrical starting positions produced by Hole-Tool.
I wrote a python script that can superimpose stresses of different solutions.
I wanted to apply thermal stresses to a safety valve under pressure, but didn't want the thermal expansion of the material to be constrained by the displacement boundary condition at the attachment point of the valve to the plant. I have therefore created two load cases which are solved separately and whose solutions (only stresses) are read out from by a script, superimposed and then written to a new .liml file.
The two load cases need to be solved and saved in separate files, and there may only be one configuration per file. Make sure the field variable "stresses" is present in the solution branch in the outline tree.