Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8496419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:51:00+00:00 2026-06-10T23:51:00+00:00

I want to run a Barnes Hut N-body simulation ( Wikipedia article ). I

  • 0

I want to run a Barnes Hut N-body simulation (Wikipedia article). I know how much memory a single node of the octree will occupy, but I can’t figure out what a worst case memory usage scenario would be for a given number of particles. In short, I’m wondering how many nodes could possibly exist in the octree for a given number of particles. I need to know this to know how much memory to allocate for the octree.

Edit:

Oh, and I’m writing in C if anybody wants to give me code instead of just and explanation.

I have this, which is way worse than a worst case scenario. But it’s guaranteed to AT LEAST allocate enough memory. I’m hoping somebody can give me something a little more memory efficient.

int KBH_worstcase(int particles)
{ // returns number of nodes required to store a number of particles in a worst case scenario
    int worst;
    unsigned int n;
    worst=1;
    n=1;
    while(n<particles)
    {
        n=n<<3;
        worst+=n;
    }
    return worst;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:51:02+00:00Added an answer on June 10, 2026 at 11:51 pm

    I’m not sure if such a suitable criterion exists. The octree takes into account the particles distribution which is likely to change during the simulation. So the effective depth of the tree cannot rely only on the number of particles.

    One spurious solution could be to define a bound on the tree depth (or on the number of nodes). In such a case you could group more particles in a single cell (the leaves of the octree) and fall back to the body-body interaction.
    But if you want more control on the tree structure, maybe is better to have the ability to allocate new nodes when necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run an update query. The query will be run against multiple
I want to run a jar file in editplus3 but I dont´n know how
I want to run a php script that will send out a bunch of
I want performant run-time memory metrics so I wrote a memory tracker based on
In c program, I want run c++ library function(s), but I don't know how
I want to run this issue by those who know more about PL/SQL and
I want run all script from the directory . Like , The directory contains
I want run a script as follows: runner: ssh 'java program &' ssh 'java
Why this code don't work,when i want run this code vwd 2008 express show
I have written php program and uploaded on server. I want run this program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.