text:
I am designing an adaptive mesh refinement algorithm for approximating the solutions to differential equations involving scalar fields in two dimensions.
I have decided to use a "refine-into-fourths" concept. Begin with a square; this is one cell. To refine this cell would give you four cells within it. Then any of those four could be refined. Thus each cell would have a unique address in terms of nesting.
The issue is that the differential equation I am solving (Laplace's) needs to know about each cell's four adjacent cells, which might or might not be at the same level of refinement. So I'd like to be able to pop in and out of levels of refinement in constant time, like in a list.
My idea, then is just to have something like this:
Is there a container that can do most of this for me already? Also, is there a better way to do this?Code:class cell { cell* tl; cell* tr; cell* bl; cell* br; public: enum child_name { top_left, top_right, bottom_left, bottom_right }; cell* child(child_name which); real value() const; bool is_refined() const; };