28 #include <oomph-lib-config.h>
37 #ifndef OOMPH_TREE_TEMPLATE_CC
38 #define OOMPH_TREE_TEMPLATE_CC
60 template<
class ELEMENT>
67 "Can't split non-leaf elements (or at least I can't see\n";
69 "why you would want me to... If you're sure, then hack me... \n";
72 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
77 std::stringstream error_message;
79 <<
"No object defined in split_if_required. Father nodes:\n";
82 unsigned nnod = el_pt->
nnode();
83 for (
unsigned j = 0; j < nnod; j++)
86 unsigned n = nod_pt->
ndim();
87 for (
unsigned i = 0;
i < n;
i++)
89 error_message << nod_pt->
x(
i) <<
" ";
91 error_message <<
"\n";
94 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
108 unsigned n_sons = new_elements_pt.size();
114 for (
unsigned i_son = 0; i_son < n_sons; i_son++)
119 Son_pt[i_son]->object_pt()->initial_setup();
148 template<
class ELEMENT>
155 "Can't p-refine non-leaf elements (or at least I can't see\n";
157 "why you would want me to... If you're sure, then hack me... \n";
160 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
165 std::stringstream error_message;
167 <<
"No object defined in p_refine_if_required. Father nodes:\n";
170 unsigned nnod = el_pt->
nnode();
171 for (
unsigned j = 0; j < nnod; j++)
174 unsigned n = nod_pt->
ndim();
175 for (
unsigned i = 0;
i < n;
i++)
177 error_message << nod_pt->
x(
i) <<
" ";
179 error_message <<
"\n";
182 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
192 if (p_ref_obj_pt == 0)
195 OOMPH_CURRENT_FUNCTION,
196 OOMPH_EXCEPTION_LOCATION);
206 ELEMENT* clone_pt =
new ELEMENT();
209 clone_pt->initial_setup(
this);
213 for (
unsigned j = 0; j < clone_pt->nnode(); j++)
215 clone_pt->node_pt(j) = p_ref_obj_pt->
node_pt(j);
224 p_ref_obj_pt->
p_refine(1, mesh_pt, clone_pt);
231 p_ref_obj_pt->
p_refine(-1, mesh_pt, clone_pt);
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
unsigned nnode() const
Return the number of nodes.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
double & x(const unsigned &i)
Return the i-th nodal coordinate.
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
An OomphLibError object which should be thrown when an run-time error is encountered....
/////////////////////////////////////////////////////////////////// /////////////////////////////////...
bool to_be_p_unrefined()
Has the element been selected for p-unrefinement?
virtual void p_refine(const int &inc, Mesh *const &mesh_pt, GeneralisedElement *const &clone_pt)=0
p-refine the element
bool to_be_p_refined()
Has the element been selected for refinement?
RefineableElements are FiniteElements that may be subdivided into children to provide a better local ...
void split(Vector< ELEMENT * > &son_pt) const
Split the element into the number of sons to be constructed and return a vector of pointers to the so...
bool to_be_refined()
Has the element been selected for refinement?
A generalised tree base class that abstracts the common functionality between the quad- and octrees u...
Tree * Father_pt
Pointer to the Father of the Tree.
RefineableElement * object_pt() const
Return the pointer to the object (RefineableElement) represented by the tree.
virtual Tree * construct_son(RefineableElement *const &object_pt, Tree *const &father_pt, const int &son_type)=0
A function that constructs a specific type of tree. This MUST be overloaded for each specific tree ty...
Tree * father_pt() const
Return pointer to father: NULL if it's a root node.
RefineableElement * Object_pt
Pointer to the object represented by the tree.
void p_refine_if_required(Mesh *&mesh_pt)
If required, p-refine the leaf – criterion: bool object_pt()-> to_be_p_refined() = true or bool objec...
void split_if_required()
If required, split the leaf and create its sons – criterion: bool object_pt()-> to_be_refined() = tru...
Vector< Tree * > Son_pt
Vector of pointers to the sons of the Tree.
A slight extension to the standard template vector class so that we can include "graceful" array rang...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...