I am dealing with a system where I have one sphere inside of a larger one and I work with the radial vector for the distance between the outer shell and the inner shell. I have nodes spaced equally around the outer shell and there is the same number of nodes corresponding to the outer nodes with exactly the same spacings on the inner shell.
For a outer node, I have to evaluate a function which produces a scalar which goes into the first element of a matrix as A. The function has as its input the magnitude of the radial vector for the distance from the outer node to one of the inner nodes, and I then have to sum the contributions when I evaluate the function inputting the distance from the outer node to each of the inner nodes (so if I chose 10 nodes on the outer shell, that's 10 terms for the 1 outer node and the distance from it to the 10 corresponding inner nodes). Then, there is a second function (also just depending on the distance from the outer to the inner node) to get the element B, and another to get element C for the first row of the matrix (really the same function every time but for the Cartesian components of a force vector). A further 6 functions at the outer node give us the next two rows of the matrix, so we end up with a system of 3 linear equations when combined with the boundary conditions.
The aim is then to repeat this for every outer node to create a system of 3N equations. I think there is a brute force way of doing this where you loop over all the outer nodes, and then loop over each inner node for every outer node, but I was wondering if there is a more efficient way of doing this and building the matrix, as it seems like trial and error to somehow get the dimensions of everything to line up correctly. I can explain in more detail if necessary or post bits of the code if that helps, if anyone can help I would appreciate it as I am getting into a mess with this.