50 using namespace BinaryTreeNames;
54 const unsigned n_node = nnode_1d();
57 Father_bound[n_node].resize(n_node, 2);
60 for (
unsigned n = 0; n < n_node; n++)
62 for (
unsigned ison = 0; ison < 2; ison++)
72 Father_bound[n_node](0,
L) =
L;
80 Father_bound[n_node](n_node - 1,
R) =
R;
94 using namespace BinaryTreeNames;
97 int edge_in_current =
OMEGA;
100 if (s_fraction[0] == 0.0)
104 if (s_fraction[0] == 1.0)
111 if (edge_in_current ==
OMEGA)
117 int edge_in_neighbour;
128 bool in_neighbouring_tree;
141 in_neighbouring_tree);
144 if (neighbour_pt != 0)
150 Node* neighbour_node_pt =
157 if (neighbour_node_pt == 0)
160 "Problem: an element claims to have had its nodes built, yet\n";
161 error_message +=
"it is missing (a least) a node at its edge.\n";
163 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
170 if (in_neighbouring_tree)
173 is_periodic = binary_tree_pt()->root_pt()->is_neighbour_periodic(
177 return neighbour_node_pt;
214 bool& was_already_built,
215 std::ofstream& new_nodes_file)
217 using namespace BinaryTreeNames;
221 const unsigned n_node = nnode_1d();
224 if (Father_bound[n_node].nrow() == 0)
226 setup_father_bounds();
231 dynamic_cast<BinaryTree*
>(binary_tree_pt()->father_pt());
235 const int son_type = Tree_pt->
son_type();
247 "Something fishy here: I have no father and yet \n";
248 error_message +=
"I have no nodes. Who has created me then?!\n";
251 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
256 was_already_built =
false;
268 const unsigned ntstorage = time_stepper_pt->ntstorage();
275 throw OomphLibError(
"Can't handle generalised nodal positions (yet).",
276 OOMPH_CURRENT_FUNCTION,
277 OOMPH_EXCEPTION_LOCATION);
316 0.5 * (s_left[0] + 1.0) *
320 0.5 * (s_right[0] + 1.0) *
325 if (father_el_pt->
node_pt(0) == 0)
328 "Trouble: father_el_pt->node_pt(0)==0\n Can't build son element!\n",
329 OOMPH_CURRENT_FUNCTION,
330 OOMPH_EXCEPTION_LOCATION);
344 for (
unsigned n = 0; n < n_node; n++)
348 s_fraction[0] = local_one_d_fraction_of_node(n, 0);
351 s_in_father[0] = s_left[0] + (s_right[0] - s_left[0]) * s_fraction[0];
354 bool node_done =
false;
358 Node* created_node_pt =
365 if (created_node_pt != 0)
368 node_pt(n) = created_node_pt;
376 for (
unsigned t = 0;
t < ntstorage;
t++)
382 t, s_in_father, prev_values);
386 unsigned n_val_at_node = created_node_pt->
nvalue();
387 unsigned n_val_from_function = prev_values.size();
390 unsigned n_var = n_val_at_node < n_val_from_function ?
395 for (
unsigned k = 0; k < n_var; k++)
397 created_node_pt->
set_value(
t, k, prev_values[k]);
415 bool is_periodic =
false;
417 node_created_by_neighbour(s_fraction, is_periodic);
420 if (created_node_pt != 0)
423 node_pt(n) = created_node_pt;
436 "node_created_by_neighbour returns a node which claims\n";
437 error_message +=
"to be periodic. In a 1D mesh any periodic "
438 "nodes must exist\n";
439 error_message +=
"in the initial (coarse) mesh.";
442 OOMPH_CURRENT_FUNCTION,
443 OOMPH_EXCEPTION_LOCATION);
460 created_node_pt = construct_node(n, time_stepper_pt);
463 new_node_pt.push_back(created_node_pt);
476 for (
unsigned t = 0;
t < ntstorage;
t++)
483 father_el_pt->
get_x(
t, s_in_father, x_prev);
486 created_node_pt->
x(
t, 0) = x_prev[0];
498 t, s_in_father, prev_values);
501 const unsigned n_value = created_node_pt->
nvalue();
504 for (
unsigned v = 0; v < n_value; v++)
506 created_node_pt->
set_value(
t, v, prev_values[v]);
533 node_pt(n), s_in_father, father_el_pt);
538 if ((!node_done) && (new_nodes_file.is_open()))
540 new_nodes_file << node_pt(n)->x(0) << std::endl;
552 if (father_m_el_pt != 0)
566 "Failed to cast to MacroElementNodeUpdateElementBase*\n";
568 "Strange -- if the father is a MacroElementNodeUpdateElement\n";
569 error_message +=
"the son should be too....\n";
572 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
588 tree_pt()->father_pt()->object_pt()->non_halo_proc_ID();
603 if (aux_father_el_pt == 0)
606 "Failed to cast to ElementWithMovingNodes*\n";
608 "Strange -- if the son is a ElementWithMovingNodes\n";
609 error_message +=
"the father should be too....\n";
612 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
619 ->are_dresidual_dnodal_coordinates_always_evaluated_by_fd())
631 ->is_fill_in_jacobian_from_geometric_data_bypassed())
648 was_already_built =
true;
664 outfile <<
"ZONE I=2,J=2, C=" <<
colour << std::endl;
669 outfile << vertex[0] <<
" " <<
Number << std::endl;
674 outfile << vertex[0] <<
" " <<
Number << std::endl;
676 outfile <<
"TEXT CS = GRID, X = " << vertex[0]
677 <<
", HU = GRID, H = 0.01, AN = MIDCENTER, T =\"" <<
Number <<
"\""
688 using namespace BinaryTreeNames;
691 const unsigned n_node = nnode_1d();
695 const unsigned n_time = 1;
700 double max_error_val = 0.0;
704 edge_in_current[0] =
L;
705 edge_in_current[1] =
R;
708 for (
unsigned edge_counter = 0; edge_counter < 2; edge_counter++)
723 int edge_in_neighbour;
731 bool in_neighbouring_tree;
748 in_neighbouring_tree);
755 bool is_periodic =
false;
756 if (in_neighbouring_tree)
760 edge_in_current[edge_counter]);
764 Node* local_node_pt = 0;
766 switch (edge_counter)
772 local_node_pt = node_pt(0);
779 local_node_pt = node_pt(n_node - 1);
784 s_in_current[0] = -1.0 + 2.0 * s_fraction[0];
790 for (
unsigned t = 0;
t < n_time;
t++)
797 t, s_in_neighbour, x_in_neighbour);
800 if (is_periodic ==
false)
803 double err = std::fabs(local_node_pt->
x(
t, 0) - x_in_neighbour[0]);
809 << local_node_pt->
x(
t, 0) <<
" " << x_in_neighbour[0]
812 oomph_info <<
"at " << local_node_pt->
x(0) << std::endl;
817 if (err > max_error_x[0])
819 max_error_x[0] = err;
829 t, s_in_neighbour, values_in_neighbour);
835 get_interpolated_values(
t, s_in_current, values_in_current);
838 const unsigned num_val =
842 for (
unsigned ival = 0; ival < num_val; ival++)
846 std::fabs(values_in_current[ival] - values_in_neighbour[ival]);
852 <<
"erru " << err <<
" " << ival <<
" "
853 << get_node_number(local_node_pt) <<
" "
854 << values_in_current[ival] <<
" "
855 << values_in_neighbour[ival] << std::endl;
860 if (err > max_error_val)
870 max_error = max_error_x[0];
871 if (max_error_val > max_error)
873 max_error = max_error_val;
877 if (max_error > 1
e-9)
879 oomph_info <<
"\n#------------------------------------ \n#Max error ";
880 oomph_info << max_error_x[0] <<
" " << max_error_val << std::endl;
881 oomph_info <<
"#------------------------------------ \n " << std::endl;
////////////////////////////////////////////////////////////////////
void setup_algebraic_node_update(Node *&node_pt, const Vector< double > &s_father, FiniteElement *father_el_pt) const
Set up node update info for (newly created) algebraic node: I.e. work out its node update information...
BinaryTree class: Recursively defined, generalised binary tree.
BinaryTree * gteq_edge_neighbour(const int &direction, Vector< double > &s_in_neighbour, int &edge, int &diff_level, bool &in_neighbouring_tree) const
Return pointer to greater or equal-sized edge neighbour in specified direction; also provide info reg...
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
void set_value(const unsigned &i, const double &value_)
Set the i-th stored data value to specified value. The only reason that we require an explicit set fu...
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
void enable_bypass_fill_in_jacobian_from_geometric_data()
Bypass the call to fill_in_jacobian_from_geometric_data.
int & method_for_shape_derivs()
Access to method (enumerated flag) for determination of shape derivs.
void enable_always_evaluate_dresidual_dnodal_coordinates_by_fd()
Insist that shape derivatives are always evaluated by fd (using FiniteElement::get_dresidual_dnodal_c...
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
virtual Node * get_node_at_local_coordinate(const Vector< double > &s) const
If there is a node at this local coordinate, return the pointer to the node.
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
MacroElement * Macro_elem_pt
Pointer to the element's macro element (NULL by default)
void get_x(const Vector< double > &s, Vector< double > &x) const
Global coordinates as function of local coordinates. Either via FE representation or via macro-elemen...
////////////////////////////////////////////////////////////////////
Vector< GeomObject * > & geom_object_pt()
Vector of (pointers to) geometric objects involved in node update function.
virtual void set_node_update_info(const Vector< GeomObject * > &geom_object_pt)=0
Set node update information: Pass the vector of (pointers to) the geometric objects that affect the n...
void add_node_pt(Node *const &node_pt)
Add a (pointer to a) node to the mesh.
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 nposition_type() const
Number of coordinate types needed in the mapping between local and global coordinates.
An OomphLibError object which should be thrown when an run-time error is encountered....
double & s_macro_ll(const unsigned &i)
Access fct to the i-th coordinate of the element's "lower left" vertex in the associated MacroElement...
double & s_macro_ur(const unsigned &i)
Access fct to the i-th coordinate of the element's "upper right" vertex in the associated MacroElemen...
virtual bool nodes_built()
Return true if all the nodes have been built, false if not.
virtual unsigned ncont_interpolated_values() const =0
Number of continuously interpolated values. Note: We assume that they are located at the beginning of...
virtual void get_interpolated_values(const Vector< double > &s, Vector< double > &values)
Get all continously interpolated function values in this element as a Vector. Note: Vector sets is ow...
Refineable version of QElement<1,NNODE_1D>.
A class that is used to template the refineable Q elements by dimension. It's really nothing more tha...
////////////////////////////////////////////////////////////////////// //////////////////////////////...
bool is_neighbour_periodic(const int &direction)
Return whether the neighbour in the particular direction is periodic.
RefineableElement * object_pt() const
Return the pointer to the object (RefineableElement) represented by the tree.
int son_type() const
Return son type.
static const int OMEGA
Default value for an unassigned neighbour.
TreeRoot *& root_pt()
Return pointer to root of the tree.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
unsigned Number
The unsigned.
Vector< std::string > colour
Tecplot colours.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...