Accessing adjacne tlement state variable during subroutine - subroutine

I’m currently trying to simulate laser ablation processes using Abaqus.
I want to achieve something similar to the below using Abaqus.
https://www.sciencedirect.com/science/article/abs/pii/S0927025614001049
I have made an Abaqus model using dflux and element deletion using umatht subroutines, and the model runs okay however since the element is deleted, the dflux is no longer applied to the element underneath the deleted element.
And I think that the convective Boundary condition applied at the initial top surface is gone too.
I was just thinking, is there any way to know if the element has an exposed surface or no neighbouring element during the subroutine?
if so I was thinking of selecting all elements top surface and applying dflux first, then controlling it via some variable to multiply 1 or 0 depending on if the element has another element above or not.
i’ve been struggling with this for a long time, any help/ideas are much appreciated

Related

Finding a better method to identify points exist "inside" of a cube in swift

I want to find a way to check if points(vectors) in my scene are contained within a SCNBox I have displayed on screen. Currently I have an array of about 83000 SCNVector3's. So far, I do this by simply running a for loop on each point and checking against the SCNBox bounding box. If it falls within that bounding box I save the point to a separate array. My goal however is not 1 bounding box. I further subdivide the bounding box into equal sections. For each of those I then have to check each individual point again to see if they fall into each one of those individual bounding boxes. If they do, I save those boxes so that when I go to subdivide them again, I am not subdividing boxes that contain no points. This helps performance a little bit as large sections of boxes that don't have points are not needlessly checked. This works okay for a small amount of boxes however I need to subdivide the boxes into much larger amounts, sometimes in the hundreds to thousands of boxes. As you can imagine, it takes a long time to check all the boxes. Currently I am having to iterate through all the points every time for each box. Is there a faster approach to this?
Your question says is there a better way, so using the physics engine would be a more 'standard' approach IMO, but performance wise I wouldn't know without trying it myself. It seems you either check manually, or let the physics engine check it for you.
Try this post - it's similar and there are some examples. [67575481].
The physics engine checks nodes for nodes and it may have changed since I did this, but I had to generate node names for my nodes and check it that way. There may be other options now.
My example is a moving 'missile' that collides with a moving node containing 'some monster', so I wasn't dealing with the size you are.
83000 vectors, dunno, that seems like a lot. You'll still have to do the checks you do now, just differently.
Hope that helps...

How do I make a Maze Generator on Scratch?

I am currently in High School, and I am in an APCSP (AP Computer Science Principles) class, which in my case is learning in Scratch programming. I am confused and have practically no idea what I'm doing. Scratch is very confusing and I feel like it's pointless to learn.
My question is this: Can anyone help me on how to make a Maze Generator on Scratch, as this is my project and it's giving me struggles.
Thank you.
It's actually possible to build with scratch but depends on what you are looking for. I assume you want to generate a simple maze like in old fashioned 8-bit games like boulder dash.
First decide on the size of your maze: for example 5 x 5 blocks.
If you want to create a maze, imagine drawing it on a grid on paper. Blocks are either "empty" or filled in. Our maze can be represented by numbers. The empty blocks are represented by a 0 and the filled blocks with a 1.
You could visualize that matrix like this if all blocks are empty:
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0
Adding a border wall while keeping the inside empty would look like:
1,1,1,1,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,1,1,1,1
Using a "list" variable to store this information would fit best within the possibilities of MIT Scratch.
In this case, you need to understand that each block in our maze is represented by a position in above matrix. You could draw numbers on a piece of paper in the shape and size of your grid / matrix as a reference to remember the position of each block if that makes it easier.
We also need to look at how our maze will relate to the Stage size. The width and height in pixels of a default scratch project is 480x360.
A 5 x 5 maze is divided in blocks of 480 / 5 = 96 width and 360 / 5 = 72 height. In other words, a block needs to be 96x72 pixels, based on a full screen maze.
Next step, is creating a sprite representing the visualization of the blocks of the maze. I would keep the first "costume" of our block sprite empty, and create a fully filled block to represent the walls of the maze.
After that, we need to programmatically create our maze. I made an example you can explore of random drawing of the blocks of a maze:
https://scratch.mit.edu/projects/278731659/
(You can change the rows & columns value to see it scale up, but remember the limit to the amount of clones the block sprite can have is 300)
This is just to get you started and by no means a complete solution. I just hope this helps you think in the right direction.
You can make this more advanced, by adding a function to explore and correct our randomly drawn grid to generate a walkable path from position x to position y. A rule you can program is for example: Every empty position in the grid should have at least two other empty positions in the spaces above, below, left and right of it.
There are many different ways to do this; whether this is with sprites and stamp or 2D lists and pen. Either way, the main component is the algorithm. This wikipedia page gives details on how maze generation works and few different algorithms. There is also a video series by The Coding Train here where he creates a maze generator with the 2D list method from above (this method is a bit harder on scratch, however). Either way, the best thing to do is to look at examples others have made, figure out how they work, and try to recreate them or make them better. Here's a good place to get started.
Scratch IS truly pointless! A simple maze generator would have you use the pen to draw predefined shapes (Such as a long hallway or intersection). You should also make (invisible) squares to separate everything and have the program draw in the squares.
I will put a link later that leads to a sample project that has the code.
Check out this video by griffpatch
https://www.youtube.com/watch?v=22Dpi5e9uz8
This was one of my projects, and the instructor provided this video for everyone to follow and expand from.

How to make objects spawn in a place at random times and move to a direction after spawning

How can i make a rootnode of a scene spawn duplicates of itself in a position (For example: x: 10,y: 10,z: 10)
then move in a direction until they are completely off screen and then dissappear.
I'm not asking for code, but i am asking for how to do this(For example what do i use for duplicating a rootnode?
How do i make that node disappear?
How do i generate a random number between 1 and 10 that will determine when to spawn the duplicate?)
And How do i make my post meet the quality standards?
You'll want to use a generalized class of nodes and spawn instances randomly.
Here's an answer on how to make random numbers in Swift. Use that to make three different random numbers between 1 and 10, and use the node class constructor with the three random numbers as input.
Finally, to move the node in a random direction, you need to have some movement function in the node class and feed it random numbers.
This is how you ask a good question.
Here is an answer:
You could:
First copy the rootnode using "node.clone" or "node.copy".
Clone duplicates the whole node tree (the node and children) whereas copy duplicates just that node.
Next assign the copy to a variable (so you can access it).
Then add any actions if you need to (refer below).
Then in your spawning loop or whatever you use to spawn objects, make a clone of the clone (the variable we made in step 2) and set it's position, with a random number.
To generate a random number that can be positive or negative use something like:
((((Float(arc4random()) / Float(UINT32_MAX))*2)-1)*5)//five is the important
//number here because it means you will get a number ranging from
// -5 to 5
Then add any actions you need to (refer below).
Finaly call scene.rootNode.addChildNode(theNodeYouJustPositioned)
To remove a node call node.removeFromParentNode.
Actions:
Alternitavely, to deleting the node yourself, and positioning the node yourself in a loop or such, and moving the node yourself, you could use SCNAction.
To use SCNAction simply call node.runAction(SCNAction).
There are many different ways of using SCNAction so please visit the docs for a whole list.
To make your node position itself (sort of) try running a runblock:^node:SCNNode{} and setting the node's position to a random number in there.
The node now positions it self so you can skip step 4.
Now if you want to move the node by a fixed direction (I mean "not random") you could just add a moveBy:xyz action in step 3.
But if it had to be a random direction you could do this action in step 5 and feed random numbers into it.
To delete you nodes using a time delay you could use a sequence: action and feed in an array containing, first, a waitForDuration:Seconds action, and last, a removeFromParentNode action.
Please visit the docs for SCNAction and any other class I mentioned that you may not have understood.
I don't know swift (at all) so I am sure there are a few syntax errors in the code. (sorry)
Post comments below if your confused.
Thanks!

Tracking 'objects' and labelling with the same labels between images/arrays in MATLAB

This is essentially a question about blob/feature tracking in MATLAB.
I have a series of sequential arrays (for simplicity, say 5 at this stage) with a background of 0 values, and then multiple objects (blobs) within each array. This is in MATLAB. These blobs can change position and size, and appear or disappear altogether, between arrays.
I'd like to label any of the blobs that are in the same position between arrays with the same ID (either a number or a letter).
Also need to incorporate functionality so that if a new pixel is added to the edge of a blob in a previous image, then it would be given the same ID.
And some functionality so that if a blob appeared in any previous array (say it was in array 1, disappeared in arrays 2 and 3, and then reappeared in 4 and 5), then it would be given the same ID as it originally had in the 1st array.
I've currently been trying to use the bwlabel function in MATLAB to do this but obviously each sequential array is labelled independently of the previous ones, so there is no 'tracking' of blobs from one image to another, and the numbers for each blob change based on how many blobs there are in that array and their positions.
Would be very grateful of any thoughts/comments on how to do this. If further clarification is required on this question, please also let me know. Many thanks in advance.
There is functionality for object tracking in the Computer Vision System Toolbox. There is an implementation of the Kalman filter (vision.KalmanFilter) that you can use to predict the location of an object in the next video frame, and a function called assignDetectionsToTracks that you can use to associate the objects across frames. See the Motion-Based Multiple Object Tracking example.

Jelly physics 3d

I want to ask about jelly physics ( http://www.youtube.com/watch?v=I74rJFB_W1k ), where I can find some good place to start making things like that ? I want to make simulation of cars crash and I want use this jelly physics, but I can't find a lot about them. I don't want use existing physics engine, I want write my own :)
Something like what you see in the video you linked to could be accomplished with a mass-spring system. However, as you vary the number of masses and springs, keeping your spring constants the same, you will get wildly varying results. In short, mass-spring systems are not good approximations of a continuum of matter.
Typically, these sorts of animations are created using what is called the Finite Element Method (FEM). The FEM does converge to a continuum, which is nice. And although it does require a bit more know-how than a mass-spring system, it really isn't too bad. The basic idea, derived from the study of continuum mechanics, can be put this way:
Break the volume of your object up into many small pieces (elements), usually tetrahedra. Let's call the entire collection of these elements the mesh. You'll actually want to make two copies of this mesh. Label one the "rest" mesh, and the other the "world" mesh. I'll tell you why next.
For each tetrahedron in your world mesh, measure how deformed it is relative to its corresponding rest tetrahedron. The measure of how deformed it is is called "strain". This is typically accomplished by first measuring what is known as the deformation gradient (often denoted F). There are several good papers that describe how to do this. Once you have F, one very typical way to define the strain (e) is:
e = 1/2(F^T * F) - I. This is known as Green's strain. It is invariant to rotations, which makes it very convenient.
Using the properties of the material you are trying to simulate (gelatin, rubber, steel, etc.), and using the strain you measured in the step above, derive the "stress" of each tetrahdron.
For each tetrahedron, visit each node (vertex, corner, point (these all mean the same thing)) and average the area-weighted normal vectors (in the rest shape) of the three triangular faces that share that node. Multiply the tetrahedron's stress by that averaged vector, and there's the elastic force acting on that node due to the stress of that tetrahedron. Of course, each node could potentially belong to multiple tetrahedra, so you'll want to be able to sum up these forces.
Integrate! There are easy ways to do this, and hard ways. Either way, you'll want to loop over every node in your world mesh and divide its forces by its mass to determine its acceleration. The easy way to proceed from here is to:
Multiply its acceleration by some small time value dt. This gives you a change in velocity, dv.
Add dv to the node's current velocity to get a new total velocity.
Multiply that velocity by dt to get a change in position, dx.
Add dx to the node's current position to get a new position.
This approach is known as explicit forward Euler integration. You will have to use very small values of dt to get it to work without blowing up, but it is so easy to implement that it works well as a starting point.
Repeat steps 2 through 5 for as long as you want.
I've left out a lot of details and fancy extras, but hopefully you can infer a lot of what I've left out. Here is a link to some instructions I used the first time I did this. The webpage contains some useful pseudocode, as well as links to some relevant material.
http://sealab.cs.utah.edu/Courses/CS6967-F08/Project-2/
The following link is also very useful:
http://sealab.cs.utah.edu/Courses/CS6967-F08/FE-notes.pdf
This is a really fun topic, and I wish you the best of luck! If you get stuck, just drop me a comment.
That rolling jelly cube video was made with Blender, which uses the Bullet physics engine for soft body simulation. The bullet documentation in general is very sparse and for soft body dynamics almost nonexistent. You're best bet would be to read the source code.
Then write your own version ;)
Here is a page with some pretty good tutorials on it. The one you are looking for is probably in the (inverse) Kinematics and Mass & Spring Models sections.
Hint: A jelly can be seen as a 3 dimensional cloth ;-)
Also, try having a look at the search results for spring pressure soft body model - they might get you going in the right direction :-)
See this guy's page Maciej Matyka, topic of soft body
Unfortunately 2d only but might be something to start with is JellyPhysics and JellyCar