26 #ifndef OOMPH_OCTREE_HEADER
27 #define OOMPH_OCTREE_HEADER
31 #include <oomph-lib-config.h>
189 bool& in_neighbouring_tree)
const;
248 const unsigned& i_root_edge_neighbour,
249 unsigned& nroot_edge_neighbour,
254 int& diff_level)
const;
275 std::ofstream& neighbours_file,
276 std::ofstream& neighbours_txt_file,
288 std::ofstream& neighbours_file,
289 std::ofstream& no_true_edge_file,
290 std::ofstream& neighbours_txt_file,
300 const unsigned& nnode1d,
307 const unsigned& nnode1d);
313 const unsigned& nnode1d);
319 const int& new_right,
325 static int rotate(
const int& new_up,
const int& new_right,
const int& dir);
375 static std::map<std::pair<std::pair<int, int>, std::pair<int, int>>,
384 throw OomphLibError(
"Don't call empty constructor for OcTree!",
385 OOMPH_CURRENT_FUNCTION,
386 OOMPH_EXCEPTION_LOCATION);
441 bool& in_neighbouring_tree,
481 const unsigned& i_root_edge_neighbour,
482 unsigned& nroot_edge_neighbour,
492 OcTree* edge_neighb_pt)
const;
516 const unsigned& nnode1d);
649 "Static member data hasn't been setup yet.\n";
650 error_message +=
"Call OcTree::setup_static_data() before creating\n";
651 error_message +=
"any OcTreeRoots\n";
654 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
671 using namespace OcTreeNames;
672 if ((edge_direction !=
LB) && (edge_direction !=
RB) &&
673 (edge_direction !=
DB) && (edge_direction !=
UB) &&
674 (edge_direction !=
LD) && (edge_direction !=
RD) &&
675 (edge_direction !=
LU) && (edge_direction !=
RU) &&
676 (edge_direction !=
LF) && (edge_direction !=
RF) &&
677 (edge_direction !=
DF) && (edge_direction !=
UF))
679 std::ostringstream error_stream;
680 error_stream <<
"Wrong edge_direction: "
683 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
696 using namespace OcTreeNames;
697 if ((edge_direction !=
LB) && (edge_direction !=
RB) &&
698 (edge_direction !=
DB) && (edge_direction !=
UB) &&
699 (edge_direction !=
LD) && (edge_direction !=
RD) &&
700 (edge_direction !=
LU) && (edge_direction !=
RU) &&
701 (edge_direction !=
LF) && (edge_direction !=
RF) &&
702 (edge_direction !=
DF) && (edge_direction !=
UF))
704 std::ostringstream error_stream;
705 error_stream <<
"Wrong edge_direction: "
708 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
717 const unsigned& edge_direction)
720 using namespace OcTreeNames;
721 if ((edge_direction !=
LB) && (edge_direction !=
RB) &&
722 (edge_direction !=
DB) && (edge_direction !=
UB) &&
723 (edge_direction !=
LD) && (edge_direction !=
RD) &&
724 (edge_direction !=
LU) && (edge_direction !=
RU) &&
725 (edge_direction !=
LF) && (edge_direction !=
RF) &&
726 (edge_direction !=
DF) && (edge_direction !=
UF))
728 std::ostringstream error_stream;
729 error_stream <<
"Wrong edge_direction: "
732 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
816 using namespace OcTreeNames;
896 for (
int dir =
LB; dir <=
UF; dir++)
899 unsigned n_neigh = edge_neigh_pt.size();
900 for (
unsigned e = 0;
e < n_neigh;
e++)
902 if (edge_neigh_pt[
e] == octree_root_pt)
937 throw OomphLibError(
"Don't call empty constructor for OcTreeForest!",
938 OOMPH_CURRENT_FUNCTION,
939 OOMPH_EXCEPTION_LOCATION);
957 void check_all_neighbours(
DocInfo& doc_info);
961 void open_hanging_node_files(
DocInfo& doc_info,
985 using namespace OcTreeNames;
986 if ((direction !=
U) && (direction !=
D) && (direction !=
F) &&
987 (direction !=
B) && (direction !=
L) && (direction !=
R))
989 std::ostringstream error_stream;
990 error_stream <<
"Wrong edge_direction: "
993 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
996 return dynamic_cast<OcTreeRoot*
>(Trees_pt[
i]->neighbour_pt(direction));
1010 void construct_up_right_equivalents();
1014 void find_neighbours();
Information for documentation of results: Directory and file number to enable output in the form RESL...
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
OcTreeForest()
Default constructor (empty and broken)
OcTreeForest(const OcTreeForest &dummy)=delete
Broken copy constructor.
Vector< TreeRoot * > oc_edge_neigh_pt(const unsigned &i, const int &direction)
Given the number i of the root octree in this forest, return the vector of pointers to the true edge ...
OcTreeRoot * oc_face_neigh_pt(const unsigned &i, const int &direction)
Given the number i of the root octree in this forest, return pointer to its face neighbour in the spe...
OcTreeRoot * octree_pt(const unsigned &i) const
Return pointer to i-th OcTree in forest (Performs a dynamic cast from the TreeRoot to a OcTreeRoot).
virtual ~OcTreeForest()
Destructor: Delete the constituent octrees (and thus the associated objects!)
void operator=(const OcTreeForest &)=delete
Broken assignment operator.
OcTreeRoot is a OcTree that forms the root of a (recursive) octree. The "root node" is special as it ...
std::map< TreeRoot *, int > Up_equivalent
Map giving the Up equivalent of the neighbour specified by pointer: When viewed from the current octr...
OcTreeRoot(const OcTreeRoot &dummy)=delete
Broken copy constructor.
int right_equivalent(TreeRoot *tree_root_pt)
The same thing as up_equivalent, but for the right direction: When viewed from the current octree nei...
OcTreeRoot(RefineableElement *const &object_pt)
Constructor for the root octree: Pass pointer to the RefineableQElement<3> that is represented by the...
void operator=(const OcTreeRoot &)=delete
Broken assignment operator.
int direction_of_neighbour(TreeRoot *octree_root_pt)
If octree_root_pt is a neighbour, return the direction [faces L/R/F/B/U/D or edges DB/UP/....
std::map< TreeRoot *, int > Right_equivalent
Map giving the Right equivalent of the neighbour specified by pointer: When viewed from the current o...
void set_up_equivalent(TreeRoot *tree_root_pt, const int &dir)
Set up equivalent of the neighbours specified by pointer: When viewed from the current octree's neigh...
void add_edge_neighbour_pt(TreeRoot *oc_tree_root_pt, const unsigned &edge_direction)
Add pointer to the edge-neighbouring [Oc]TreeRoot in the (enumerated) (edge) direction – maintains un...
int up_equivalent(TreeRoot *tree_root_pt)
Return up equivalent of the neighbours specified by pointer: When viewed from the current octree's ne...
void set_right_equivalent(TreeRoot *tree_root_pt, const int &dir)
The same thing as up_equivalent, but for the right direction: When viewed from the current octree nei...
Vector< TreeRoot * > edge_neighbour_pt(const unsigned &edge_direction)
Return vector of pointers to the edge-neighbouring TreeRoots in the (enumerated) (edge) direction.
unsigned nedge_neighbour(const unsigned &edge_direction)
Return number of edge-neighbouring OcTreeRoot in the (enumerated) (edge) direction.
std::map< int, Vector< TreeRoot * > > Edge_neighbour_pt
Map of pointers to the edge-neighbouring [Oc]TreeRoots: Edge_neighbour_pt[direction] is Vector to the...
OcTree class: Recursively defined, generalised octree.
static DenseMatrix< double > S_step_edge
Each edge of the RefineableQElement<3> that is represented by the octree is parametrised by one (of t...
static Vector< std::string > Colour
Colours for neighbours in various directions.
static DenseMatrix< double > S_base
s_base(i,direction): Initial value for coordinate s[i] on the face indicated by direction (L/R/U/D/F/...
static DenseMatrix< double > S_directhi
Relative to the left/down/back vertex in any (father) octree, the corresponding vertex in the son spe...
void operator=(const OcTree &)=delete
Broken assignment operator.
static DenseMatrix< bool > Is_adjacent
Array of direction/octant adjacency scheme: Is_adjacent(direction,octant): Is face/edge direction adj...
static Vector< int > rotate(const int &new_up, const int &new_right, const Vector< int > &dir)
If U[p] becomes new_up and R[ight] becomes new_right then the direction vector dir becomes rotate(new...
static Vector< int > faces_of_common_edge(const int &edge)
Function that, given an edge, returns the two faces on which it.
OcTree(RefineableElement *const &object_pt)
Constructor for empty (root) tree: no father, no sons; just pass a pointer to its object (a Refineabl...
OcTree(const OcTree &dummy)=delete
Broken copy constructor.
static Vector< std::string > Direct_string
Translate (enumerated) directions into strings.
static DenseMatrix< double > S_directlo
Relative to the left/down/back vertex in any (father) octree, the corresponding vertex in the son spe...
Tree * construct_son(RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)
Overload the function construct_son to ensure that the son is a specific OcTree and not a general Tre...
static int node_number_to_vertex(const unsigned &n, const unsigned &nnode1d)
Return the vertex [LDB,RDB,...] of local (vertex) node n in an element with nnode1d nodes in each coo...
static void mult_mat_vect(const DenseMatrix< int > &mat, const Vector< int > &vect1, Vector< int > &vect2)
Helper function: Performs the operation : vect2 = mat*vect1.
static DenseMatrix< int > Common_face
Determine common face of edges or octants. Slightly bizarre lookup scheme from Samet's book.
static Vector< int > Reflect_face
Get opposite face, e.g. Reflect_face[L]=R.
static Vector< int > Sini
Entry in rotation matrix sin(i*90)
virtual ~OcTree()
Destructor. Note: Deleting a octree also deletes the objects associated with all non-leaf nodes!
static void setup_static_data()
Setup the static data, rotation and reflection schemes, etc.
unsigned self_test()
Self-test: Check all neighbours. Return success (0) if the max. distance between corresponding points...
OcTree * gteq_face_neighbour(const int &direction, Vector< unsigned > &translate_s, Vector< double > &s_sw, Vector< double > &s_ne, int &face, int &diff_level, bool &in_neighbouring_tree) const
Find (pointer to) ‘greater-or-equal-sized face neighbour’ in given direction (L/R/U/D/F/B)....
static Vector< int > vertex_node_to_vector(const unsigned &n, const unsigned &nnode1d)
Returns the vector of the coordinate directions of vertex node number n in an element with nnode1d el...
static void doc_true_edge_neighbours(Vector< Tree * > forest_nodes_pt, std::ofstream &neighbours_file, std::ofstream &no_true_edge_file, std::ofstream &neighbours_txt_file, double &max_error)
Doc/check all true edge neighbours of octree (nodes) contained in the Vector forest_node_pt....
static std::map< std::pair< std::pair< int, int >, std::pair< int, int > >, std::pair< int, int > > Up_and_right_equivalent_for_pairs_of_vertices
Storage for the up/right-equivalents corresponding to two pairs of vertices along an element edge:
static DenseMatrix< double > S_base_edge
S_base_edge(i,edge): Initial value for coordinate s[i] on the specified edge (LF/RF/....
static Vector< int > Cosi
Entry in rotation matrix: cos(i*90)
static DenseMatrix< int > Reflect
Reflection scheme: Reflect(direction,octant): Get mirror of octant/edge in specified direction....
static int get_the_other_face(const unsigned &n1, const unsigned &n2, const unsigned &nnode1d, const int &face)
If an edge is bordered by the nodes whose local numbers are n1 and n2 in an element with nnode1d node...
OcTree * gteq_true_edge_neighbour(const int &direction, const unsigned &i_root_edge_neighbour, unsigned &nroot_edge_neighbour, Vector< unsigned > &translate_s, Vector< double > &s_lo, Vector< double > &s_hi, int &edge, int &diff_level) const
Find (pointer to) ‘greater-or-equal-sized true edge neighbour’ in the given direction (LB,...
bool edge_neighbour_is_face_neighbour(const int &edge, OcTree *edge_neighb_pt) const
Is the edge neighbour (for edge "edge") specified via the pointer also a face neighbour for one of th...
OcTree * gteq_edge_neighbour(const int &direction, const unsigned &i_root_edge_neighbour, unsigned &nroot_edge_neighbour, double &s_diff, int &diff_level, int max_level, OcTreeRoot *orig_root_pt) const
Find ‘greater-or-equal-sized edge neighbour’ in given direction (LB,RB,DB,UB [the back edges],...
OcTree()
Default constructor (empty and broken)
static DenseMatrix< double > S_direct_edge
Relative to the left/down/back vertex in any (father) octree, the corresponding vertex in the son spe...
static Vector< int > Reflect_vertex
Get opposite vertex, e.g. Reflect_vertex[LDB]=RUF.
static Vector< Vector< int > > Vertex_at_end_of_edge
Vector of vectors containing the two vertices for each edge, e.g. Vertex_at_end_of_edge[LU][0]=LUB an...
static void construct_rotation_matrix(int &axis, int &angle, DenseMatrix< int > &mat)
This constructs the rotation matrix of the rotation around the axis axis with an angle of angle*90.
static void mult_mat_mat(const DenseMatrix< int > &mat1, const DenseMatrix< int > &mat2, DenseMatrix< int > &mat3)
Helper function: Performs the operation : mat3=mat1*mat2.
static bool Static_data_has_been_setup
Bool indicating that static member data has been setup.
static DenseMatrix< double > S_stephi
If we're located on face face [L/R/F/B/U/D], then an increase in s_hi from -1 to +1 corresponds to a ...
static Vector< Vector< int > > Direction_to_vector
For each direction, i.e. a son_type (vertex), a face or an edge, this defines a vector that indicates...
static Vector< int > Reflect_edge
Get opposite edge, e.g. Reflect_edge[DB]=UF.
static std::map< Vector< int >, int > Vector_to_direction
Each vector representing a direction can be translated into a direction, either a son type (vertex),...
static DenseMatrix< double > S_steplo
Each face of the RefineableQElement<3> that is represented by the octree is parametrised by two (of t...
static unsigned vertex_to_node_number(const int &vertex, const unsigned &nnode1d)
Return the local node number of given vertex [LDB,RDB,...] in an element with nnode1d nodes in each c...
OcTree(RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)
Constructor for tree that has a father: Pass it the pointer to its object, the pointer to its father ...
static void doc_face_neighbours(Vector< Tree * > forest_nodes_pt, std::ofstream &neighbours_file, std::ofstream &neighbours_txt_file, double &max_error)
Doc/check all face neighbours of octree (nodes) contained in the Vector forest_node_pt....
An OomphLibError object which should be thrown when an run-time error is encountered....
RefineableElements are FiniteElements that may be subdivided into children to provide a better local ...
A TreeForest consists of a collection of TreeRoots. Each member tree can have neighbours in various e...
TreeRoot is a Tree that forms the root of a (recursive) tree. The "root node" is special as it holds ...
std::map< int, TreeRoot * > Neighbour_pt
Map of pointers to the neighbouring TreeRoots: Neighbour_pt[direction] returns the pointer to the Tre...
A generalised tree base class that abstracts the common functionality between the quad- and octrees u...
RefineableElement * object_pt() const
Return the pointer to the object (RefineableElement) represented by the tree.
Tree * father_pt() const
Return pointer to father: NULL if it's a root node.
int son_type() const
Return son type.
static const int OMEGA
Default value for an unassigned neighbour.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
double angle(const Vector< double > &a, const Vector< double > &b)
Get the angle between two vector.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...