Questions tagged [c++]
For questions about writing C++ computational code or utilizing libraries written with C++.
335
questions
0
votes
0
answers
97
views
Numerically integrating photon wavelength undergoing gravitational time dilation
I am trying to integrate the wavelength of a photon that is undergoing gravitational redshift.
The formula that I'm trying to emulate is:
\begin{equation}
\lambda_{i} = \lambda_{e} \frac{ \sqrt{...
15
votes
5
answers
2k
views
Ensuring IEEE 754 Compliance and Numerical Precision in C++ HPC Projects
I'm currently engaged in a large-scale C++ HPC project focused on numerical simulation, particularly Finite Element Method (FEM) simulations. Our project spans various Linux-based platforms and ...
7
votes
1
answer
192
views
Unexpected result when summing sorted (and unsorted) positive floating point numbers
I am exploring Higham's excellent Accuracy and Stability of Numerical Algorithms and chapter 4 is dedicated to summation.
So I decided to test the most basic thing. Summing positive random numbers ...
1
vote
1
answer
62
views
How to calculate the force of solid applied by fluid? Using finite difference method, DNS, staggered grid, SIMPLE algorithm, immersive boundary
Problem
I am using finite difference method to solve classic problem of flow around cylinder, for validation of my group's immersive boundary method.
The common way to validate numerical method is ...
2
votes
1
answer
286
views
Why do my satellites fall out of orbit?
I have set up Newtonian Gravity in my Game Engine, allowing me to simulate the gravitational attraction between celestial bodies.
I have the following variables defined:
...
1
vote
1
answer
134
views
c++ software packages to solve linear systems subject to constraints
I have a finite element project based on deal.II and cmake/make as build system.
I am aware of popular libraries such as deal.II, trilinos, petsc, mumps, superlu_dist,... to solve large sparse linear ...
2
votes
1
answer
197
views
Speeding up 3 body problem acceleration calculation
I want to find optimizations to my code for the 3BP, and more specifically computing accelerations. I'm using a data-driven approach, so I have a bodies structure ...
3
votes
2
answers
745
views
C++ Run-time parameter constants
I am developing a code to simulate a Non-Volatile Memory (NVM). For that, I need several constants (memory dimensions, feature size, temperature etc.).
Until then, all my constants were defined at ...
2
votes
0
answers
74
views
Efficiently retrieiving indices from lattice with periodic boundary conditions
This is something I've never thought too much about because it seemed like an unnecessary micro-optimization, but I've come across a situation where this computation is actually the primary bottleneck ...
0
votes
0
answers
64
views
Where should we compute `Energy` and `Trajectory` in this listing?
Suppose, I have the following listing for a barebone MD simulation:
...
1
vote
1
answer
77
views
Computing LJ force from LJ potential, or not?
Lennard-Jones force can be computed in two different ways:
Version #1:
Here, the force computation is a self-contained routine.
...
1
vote
1
answer
105
views
How can I write a unit test for this routine?
The first routine instantiates numAtoms number of atoms and distributes them in a 6*6*6 grid.
The second routine populates the ...
2
votes
2
answers
1k
views
Understanding leapfrog integration algorithm
The leapfrog.cpp is an implementation of leapfrog integration algorithm where f() function is being integrated:
leapfrog.cpp
<...
0
votes
1
answer
223
views
How to efficiently fill in, in parallel, a PETSc matrix from a COO sparse matrix?
Considering the following COO sparse matrix format, with repeated indices:
...
0
votes
0
answers
97
views
How to use a surface mesh parameterization?
I'm currently playing with the surface mesh parameterizations of the C++ library CGAL.
For a mesh with a boundary, the computed uv-space (parameterization domain) is either a disk or a square, and so ...