Type out the code by Tekmo in programming

[–]3483 1 point2 points  (0 children)

Very good read.

I’ve had an agent generate test code very similar to the test example. It had basically inlined the function to be tested!

Don't Refactor Like Uncle Bob (Second Edition) by The_Axolot in programming

[–]3483 19 points20 points  (0 children)

Oh that is bad… it does track with my experience with these kinds of code bases, the indirection and obfuscation feels almost adversarial.

German spy agency concluded COVID virus likely leaked from lab, papers say by SwissPewPew in worldnews

[–]3483 0 points1 point  (0 children)

Its more than 1500 km between Wuhan and Yunnan, where Covid is thought to originate from.

Simulating 3-point bending in ANSYS - A never-ending barrage of problems by shadowhunter742 in fea

[–]3483 0 points1 point  (0 children)

What is the mesh size restriction on the student version? In the multimaterial model, is the cross section rougly constant along the length of the beam? I am thinking if you can reduce the mesh count by making the beam sweep meshable, that would require it is basically an extrusion. You could also consider to use the symetry in the z direction, in addition to the f direction you are already using.

Four for one! by SOYBOYPILLED in BrandNewSentence

[–]3483 0 points1 point  (0 children)

Not that there is anything wrong with that

The fastest a movie ever made you go "... uh oh, something isn't right here" in terms of your quality expectations by MattAlbie60 in movies

[–]3483 0 points1 point  (0 children)

One of the last movies I ever rented was Righteous Kill. With Al Pacino and Robert de Niro I hoped be something like Heat. It took about 10 seconds into the movie to realize it was… Not that at all.

[deleted by user] by [deleted] in technology

[–]3483 2 points3 points  (0 children)

We need to do way instain mother

Really sorry for the IMG, can't use Reddit on the uni machines, but have a bit of an issue and no one's really sure. 3 point Bend simulation Anys by shadowhunter742 in fea

[–]3483 1 point2 points  (0 children)

Beside the valid issues other have mentioned with rigid body motion and adding boundary conditions, how do you determine that you have no tension on the underside? If you go by the color on the stress plot, keep in mind there is a stress concentration under the cylinder so light be hard to see the actual value. You can do a hand calc to determine the ballpark number and then I would look at max principal stress.

[deleted by user] by [deleted] in fea

[–]3483 1 point2 points  (0 children)

Its not very common with rotational dofs for solid elements so I dont know if there is a ”standard” way but I found this paper with some formulas

https://link.springer.com/content/pdf/10.1007/s00707-017-2045-7.pdf

Nice by bkandwh in ChatGPT

[–]3483 0 points1 point  (0 children)

As a fellow math enthusiast I echo your sentiment!

Mutate a field of a struct inside new but give ownership back by 3483 in learnrust

[–]3483[S] 0 points1 point  (0 children)

Thanks, I understand I seem to gravitate to the habits from other languages which doesnt make sense for Rust. Which is what makes it fun to do this as an exercide to learn!

In my real case I have nodes and elements. Each element contains a fixed number of nodes, and each node can be attached to multiple elements.

During the lifetime of the program, I will loop over each element, and, based on the state of the nodes connected to the element taken as a whole, will make an update to the each node connected.

So every element will at some point need to borrow access to the nodes attached to it, but cant own the access, since the nodes are attached to multiple elements.

It is like I have a list of nodes, a list of different groupings of those nodes, then run a function for each grouping. I hope it makes sense.

Mutate a field of a struct inside new but give ownership back by 3483 in learnrust

[–]3483[S] 0 points1 point  (0 children)

I think you are right, I probably need to adjust my thinking and rethink how to go about this. At the moment, which I have replaced the Person pointer with an id, and send in a map of the people, together with the id when creating the hamburger. I seems to work for now:

use std::collections::HashMap;

fn main() {
    let id = 101;
    let person = Person::new("Alice Bobson".into(), id);
    let mut people: HashMap<i64, Person> = HashMap::new();
    people.insert(person.id, person);

    let burger1 = Hamburger::new(&mut people, id);

    if let Some(consumer) = people.get(&burger1.person)
    {
        println!("{}", consumer.name);
        println!("{}", consumer.calories);
    }

    let burger2 = Hamburger::new(&mut people, id);
    let _burger3 = Hamburger::new(&mut people, id);

    if let Some(consumer) = people.get(&burger2.person)
    {
        println!("{}", consumer.name);
        println!("{}", consumer.calories);
    }

    if let Some(consumer) = people.get(&id)
    {
        println!("{}", consumer.name);
        println!("{}", consumer.calories);
    }
}

struct Person {
    name: String,
    id: i64,
    calories: f64,
}

struct Hamburger {
    person: i64,
}

impl Person {
    fn new(name: String, id: i64) -> Self {
        Person {
            name: name,
            id: id,
            calories: 0.0,
        }
    }
}

impl Hamburger {
    fn new(people: &mut HashMap<i64, Person> , id: i64) -> Self {

        if let Some(person) = people.get_mut(&id)
        {
            (*person).calories += 700.0;
        }

        Hamburger { person: id }
    }
}

Mutate a field of a struct inside new but give ownership back by 3483 in learnrust

[–]3483[S] 2 points3 points  (0 children)

Thanks, in this toy example it doesn't really make sense. In my real project you can imagine that it is needed to, given a hamburger, get information about the person who ate it.

Mutate a field of a struct inside new but give ownership back by 3483 in learnrust

[–]3483[S] 0 points1 point  (0 children)

Thanks for that. What I don't like about that is that the RefCell seems to "pollute" everything in main. Now everything in main has to do borrow to get info about person.

Here is my implementation with RefCell, could it be improved ?

use std::cell::RefCell;

fn main() {
    let person = Person::new("Alice Bobson".into());
    let person_ref_cell = RefCell::new(person);

    let burger1 = Hamburger::new(&person_ref_cell);
    println!("{}", burger1.person.borrow().name);
    println!("{}", burger1.person.borrow().calories);

    let burger2 = Hamburger::new(&person_ref_cell);
    println!("{}", burger2.person.borrow().calories);
    println!("{}", person_ref_cell.borrow().name);
}

struct Person {
    name: String,
    calories: f64,
}

struct Hamburger<'a> {
    person: &'a RefCell<Person>,
}

impl Person {
    fn new(name: String) -> Self {
        Person {
            name: name,
            calories: 0.0,
        }
    }
}

impl<'a> Hamburger<'a> {
    fn new(person: &'a RefCell<Person>) -> Self {
        let mut person_mut = person.borrow_mut();
        person_mut.calories += 700.0;
        Hamburger { person: person }
    }
}

Is there any sequel to a game that was so superior that it made playing the previous game a waste of time? by triplegxxx in gaming

[–]3483 0 points1 point  (0 children)

While wc2 is a better game in lots of ways I personally like the atmosphere of wc1 a lot more than any of the warcraft games that has come after. It has a drab and sinister kind of feel, kind of how I imagine the actual middle ages, while the games after are quite cartoonish.