32 #include <oomph-lib-config.h> 41 #ifndef OOMPH_TREE_TEMPLATE_CC 42 #define OOMPH_TREE_TEMPLATE_CC 66 template<
class ELEMENT>
75 "Can't split non-leaf elements (or at least I can't see\n";
77 "why you would want me to... If you're sure, then hack me... \n";
80 OOMPH_CURRENT_FUNCTION,
81 OOMPH_EXCEPTION_LOCATION);
86 std::stringstream error_message;
87 error_message <<
"No object defined in split_if_required. Father nodes:\n";
90 unsigned nnod=el_pt->
nnode();
91 for (
unsigned j=0;j<nnod;j++)
94 unsigned n=nod_pt->
ndim();
95 for (
unsigned i=0;
i<n;
i++)
97 error_message << nod_pt->
x(
i) <<
" ";
99 error_message <<
"\n";
102 OOMPH_CURRENT_FUNCTION,
103 OOMPH_EXCEPTION_LOCATION);
117 unsigned n_sons = new_elements_pt.size();
123 for(
unsigned i_son=0;i_son<n_sons;i_son++)
129 Son_pt[i_son]->object_pt()->initial_setup();
158 template<
class ELEMENT>
167 "Can't p-refine non-leaf elements (or at least I can't see\n";
169 "why you would want me to... If you're sure, then hack me... \n";
172 OOMPH_CURRENT_FUNCTION,
173 OOMPH_EXCEPTION_LOCATION);
178 std::stringstream error_message;
179 error_message <<
"No object defined in p_refine_if_required. Father nodes:\n";
182 unsigned nnod=el_pt->
nnode();
183 for (
unsigned j=0;j<nnod;j++)
186 unsigned n=nod_pt->
ndim();
187 for (
unsigned i=0;
i<n;
i++)
189 error_message << nod_pt->
x(
i) <<
" ";
191 error_message <<
"\n";
194 OOMPH_CURRENT_FUNCTION,
195 OOMPH_EXCEPTION_LOCATION);
208 OOMPH_CURRENT_FUNCTION,
209 OOMPH_EXCEPTION_LOCATION);
219 ELEMENT* clone_pt =
new ELEMENT();
222 clone_pt->initial_setup(
this);
226 for(
unsigned j=0; j<clone_pt->nnode(); j++)
228 clone_pt->node_pt(j) = p_ref_obj_pt->node_pt(j);
233 if (p_ref_obj_pt->to_be_p_refined())
237 p_ref_obj_pt->p_refine(1,mesh_pt,clone_pt);
240 else if (p_ref_obj_pt->to_be_p_unrefined())
244 p_ref_obj_pt->p_refine(-1,mesh_pt,clone_pt);
Vector< Tree * > Son_pt
Vector of pointers to the sons of the Tree.
RefineableElement * Object_pt
Pointer to the object 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...
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Tree * Father_pt
Pointer to the Father of the Tree.
bool to_be_refined()
Has the element been selected for refinement?
Tree * father_pt() const
Return pointer to father: NULL if it's a root node.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
p-refineable version of RefineableElement
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 obje...
RefineableElement * object_pt() const
Return the pointer to the object (RefineableElement) represented by the tree.
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...
unsigned nnode() const
Return the number of nodes.
void split_if_required()
If required, split the leaf and create its sons – criterion: bool object_pt()-> to_be_refined() = tr...