https://linen.dev logo
Join Discord
Powered by
# programming
  • k

    kandelabr

    04/18/2025, 11:19 AM
    https://tenor.com/view/sweats-gif-25346666
  • m

    Moose

    04/18/2025, 11:47 AM
    the .org version is very usefull for cht because of it's structure
  • j

    Jeeemieee

    04/22/2025, 8:47 PM
    Hi everyone, is there some magic trick to stopping and restarting a pimple time run in an outer while loop? I'm trying to program a selective frequency damping code that iteratively determines the correct control coefficients (by rerunning a transient simulation for a couple of times) and applying them, but when I set the endTime to the current time (with runTime.setEndTime()), I get errors in MPI. Alternatively, if I add function objects, it keeps on running without printing or exporting anything. I had expected and hoped using this endTime function would be similar to just modifying endTime in the controlDict during a transient run.
  • s

    slopezcastano

    04/23/2025, 8:54 AM
    use
    Copy code
    GOTO
    or
    Copy code
    BREAK
    statements
  • k

    kandelabr

    04/23/2025, 9:06 AM
    https://tenor.com/view/sweats-gif-25346666
  • k

    kandelabr

    04/23/2025, 9:07 AM
    not sure if you're serious
  • s

    slopezcastano

    04/23/2025, 9:19 AM
    I am serious. He's trying to stop the outerIteration cycle by forcing a Time (=endTime) that's already running (so you are already at endTime + deltaTime). It is simpler to just use an if ... break or GOTO statement to get out of the inner cycle (outerIteration). Once things work, you can always create a new Time class with the desired effects. Boomer programming is not necessarily bad programming
  • j

    JasonS

    04/23/2025, 9:20 AM
    it usually is if you use
    goto
  • j

    JasonS

    04/23/2025, 9:20 AM
    break
    is fine though
  • s

    slopezcastano

    04/23/2025, 9:20 AM
    Why?
  • j

    JasonS

    04/23/2025, 9:20 AM
    I mean,
    goto
    can be fine, but the big problem is that it's very easy to use it in a very not fine way and modern programmers don't like that
  • s

    slopezcastano

    04/23/2025, 9:20 AM
    So dont use it in a "very non fine way"
  • j

    JasonS

    04/23/2025, 9:21 AM
    the attitude has changed from "just don't mess up" to "you will mess up, so just use a system where that's harder to do and the problems are easier to spot"
  • j

    JasonS

    04/23/2025, 9:22 AM
    goto
    spaghetti code is a debugging nightmare
  • j

    JasonS

    04/23/2025, 9:22 AM
    break
    is predictable
  • s

    slopezcastano

    04/23/2025, 9:35 AM
    So don't write spagghetti code. GOTO doesn't produce spagghetti, bad programmers do. Besides, from what I understand from the original question, the guy wants to jump from inner to outer to again inner iterations according to some parameters he/she monitors: break helps you out, but doesn't bring you back in....
  • j

    JasonS

    04/23/2025, 9:36 AM
    and subverting existing flow control solutions with
    goto
    is exactly how spaghetti code begins
  • j

    JasonS

    04/23/2025, 9:37 AM
    the only reasonable use for
    goto
    is if your language of choice doesn't provide
    break
    , or else if you need to break out of multiple nested blocks
  • k

    kandelabr

    04/23/2025, 9:56 AM
    There's also a
    comefrom
    statement https://entrian.com/goto/
  • j

    Jeeemieee

    04/23/2025, 10:45 AM
    Thank you all for the quick replies! It seems I solved the problem... Last night I was sure this was the problem, but this morning I figured out it was how I reset my velocity field 🙃 For now it seems to work by just using the last results
  • q

    qr

    04/23/2025, 10:47 AM
    Just for the sake of completeness, can you exactly describe the working solution?
  • j

    Jeeemieee

    04/23/2025, 10:51 AM
    Of course; Within the time loop I still set the end time using runTime.setEndTime() and it properly stops at the specified time. After the time loop, in the outer loop, I initially reset the velocity field using the field stored before the run. I commented that out and now the run does not stagnate or crash. Hope it helps 😄
  • q

    qr

    04/23/2025, 10:52 AM
    But your velocity does not reset, where you wanted it to reset in the original version? How do you achieve that bit now?
  • j

    Jeeemieee

    04/23/2025, 10:54 AM
    Sadly I'm not able to reset the field at this point, but it was not a necessity. For now my paper deadline is more important that figuring that out.
  • t

    tkeskita

    05/01/2025, 9:41 AM
    https://tenor.com/view/coyote-pushing-rock-gif-25122147
  • t

    tkeskita

    05/01/2025, 9:41 AM
    Pro tip: If you don't code for a while, be prepared to burn some extra calories to get the stone rolling again.
  • t

    tkeskita

    05/02/2025, 7:05 AM
    Let me know if there is a better data structure for this https://cdn.discordapp.com/attachments/814043123810304041/1367758836064194622/image.png?ex=6815c02e&is=68146eae&hm=395f3a25a85f1531895231f501f538709b25c9f1b2b001f645d3622d148f30e4&
  • s

    slopezcastano

    05/02/2025, 7:18 AM
    LabelLabelList
  • t

    tkeskita

    05/02/2025, 7:24 AM
    Isn't going through a list gonna be slower? 🤔 Although, list is not too large, so maybe does not matter..
  • t

    tkeskita

    05/03/2025, 12:18 PM
    Today I learned that
    sortedOrder()
    can't sort a
    List<double>
    . Use
    SortList.indices()
    to get the indices of sorted list items.