55 using namespace BinaryTreeNames;
59 const unsigned n_node = nnode_1d();
62 Father_bound[n_node].resize(n_node,2);
65 for(
unsigned n=0;n<n_node;n++)
67 for(
unsigned ison=0;ison<2;ison++)
77 Father_bound[n_node](0,
L) =
L;
85 Father_bound[n_node](n_node-1,
R) =
R;
100 using namespace BinaryTreeNames;
103 int edge_in_current =
OMEGA;
106 if(s_fraction[0]==0.0) { edge_in_current =
L; }
107 if(s_fraction[0]==1.0) { edge_in_current =
R; }
111 if(edge_in_current==
OMEGA) {
return 0; }
114 int edge_in_neighbour;
125 bool in_neighbouring_tree;
134 neighbour_pt = binary_tree_pt()->
135 gteq_edge_neighbour(edge_in_current,s_in_neighbour,edge_in_neighbour,
136 diff_level,in_neighbouring_tree);
145 Node* neighbour_node_pt =
151 if(neighbour_node_pt==0)
154 "Problem: an element claims to have had its nodes built, yet\n";
156 "it is missing (a least) a node at its edge.\n";
158 OOMPH_CURRENT_FUNCTION,
159 OOMPH_EXCEPTION_LOCATION);
166 if(in_neighbouring_tree)
170 binary_tree_pt()->root_pt()->is_neighbour_periodic(edge_in_current);
173 return neighbour_node_pt;
210 bool& was_already_built,
211 std::ofstream &new_nodes_file)
213 using namespace BinaryTreeNames;
217 const unsigned n_node = nnode_1d();
220 if(Father_bound[n_node].nrow()==0) { setup_father_bounds(); }
224 =
dynamic_cast<BinaryTree*
>(binary_tree_pt()->father_pt());
228 const int son_type = Tree_pt->
son_type();
240 "Something fishy here: I have no father and yet \n";
242 "I have no nodes. Who has created me then?!\n";
245 OOMPH_CURRENT_FUNCTION,
246 OOMPH_EXCEPTION_LOCATION);
251 was_already_built =
false;
262 const unsigned ntstorage = time_stepper_pt->ntstorage();
270 "Can't handle generalised nodal positions (yet).",
271 OOMPH_CURRENT_FUNCTION,
272 OOMPH_EXCEPTION_LOCATION);
310 0.5*(s_left[0]+1.0)*(father_el_pt->
s_macro_ur(0)-
313 0.5*(s_right[0]+1.0)*(father_el_pt->
s_macro_ur(0)-
318 if(father_el_pt->
node_pt(0)==0)
321 "Trouble: father_el_pt->node_pt(0)==0\n Can't build son element!\n",
322 OOMPH_CURRENT_FUNCTION,
323 OOMPH_EXCEPTION_LOCATION);
337 for(
unsigned n=0;n<n_node;n++)
341 s_fraction[0] = local_one_d_fraction_of_node(n,0);
344 s_in_father[0] = s_left[0] + (s_right[0]-s_left[0])*s_fraction[0];
347 bool node_done =
false;
351 Node* created_node_pt
358 if(created_node_pt!=0)
361 node_pt(n) = created_node_pt;
369 for(
unsigned t=0;
t<ntstorage;
t++)
378 unsigned n_val_at_node = created_node_pt->
nvalue();
379 unsigned n_val_from_function = prev_values.size();
382 unsigned n_var = n_val_at_node < n_val_from_function ?
383 n_val_at_node : n_val_from_function;
386 for(
unsigned k=0;k<n_var;k++)
388 created_node_pt->
set_value(
t,k,prev_values[k]);
406 bool is_periodic =
false;
407 created_node_pt = node_created_by_neighbour(s_fraction,is_periodic);
410 if(created_node_pt!=0)
413 node_pt(n) = created_node_pt;
426 "node_created_by_neighbour returns a node which claims\n";
428 "to be periodic. In a 1D mesh any periodic nodes must exist\n";
430 "in the initial (coarse) mesh.";
433 OOMPH_CURRENT_FUNCTION,
434 OOMPH_EXCEPTION_LOCATION);
451 created_node_pt = construct_node(n,time_stepper_pt);
454 new_node_pt.push_back(created_node_pt);
467 for(
unsigned t=0;
t<ntstorage;
t++)
474 father_el_pt->
get_x(
t,s_in_father,x_prev);
477 created_node_pt->
x(
t,0) = x_prev[0];
491 const unsigned n_value = created_node_pt->
nvalue();
494 for(
unsigned v=0;v<n_value;v++)
496 created_node_pt->
set_value(
t,v,prev_values[v]);
528 if((!node_done) && (new_nodes_file.is_open()))
530 new_nodes_file << node_pt(n)->x(0) << std::endl;
542 if(father_m_el_pt!=0)
556 "Failed to cast to MacroElementNodeUpdateElementBase*\n";
558 "Strange -- if the father is a MacroElementNodeUpdateElement\n";
559 error_message +=
"the son should be too....\n";
562 OOMPH_CURRENT_FUNCTION,
563 OOMPH_EXCEPTION_LOCATION);
573 m_el_pt->set_node_update_info(geom_object_pt);
579 tree_pt()->father_pt()->object_pt()->non_halo_proc_ID();
594 if(aux_father_el_pt==0)
597 "Failed to cast to ElementWithMovingNodes*\n";
599 "Strange -- if the son is a ElementWithMovingNodes\n";
600 error_message +=
"the father should be too....\n";
603 OOMPH_CURRENT_FUNCTION,
604 OOMPH_EXCEPTION_LOCATION);
611 ->are_dresidual_dnodal_coordinates_always_evaluated_by_fd())
614 enable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
623 ->is_fill_in_jacobian_from_geometric_data_bypassed())
640 was_already_built =
true;
656 outfile <<
"ZONE I=2,J=2, C=" << colour << std::endl;
661 outfile << vertex[0] <<
" " <<
Number << std::endl;
666 outfile << vertex[0] <<
" " <<
Number << std::endl;
668 outfile <<
"TEXT CS = GRID, X = " << vertex[0] <<
669 ", HU = GRID, H = 0.01, AN = MIDCENTER, T =\"" 670 <<
Number <<
"\"" << std::endl;
680 using namespace BinaryTreeNames;
683 const unsigned n_node = nnode_1d();
687 const unsigned n_time=1;
692 double max_error_val = 0.0;
696 edge_in_current[0] =
L;
697 edge_in_current[1] =
R;
700 for(
unsigned edge_counter=0;edge_counter<2;edge_counter++)
715 int edge_in_neighbour;
723 bool in_neighbouring_tree;
735 neighbour_pt = binary_tree_pt()->
736 gteq_edge_neighbour(edge_in_current[edge_counter],s_in_neighbour,
737 edge_in_neighbour,diff_level,in_neighbouring_tree);
744 bool is_periodic =
false;
745 if(in_neighbouring_tree)
748 is_periodic = tree_pt()->root_pt()
749 ->is_neighbour_periodic(edge_in_current[edge_counter]);
753 Node* local_node_pt = 0;
761 local_node_pt = node_pt(0);
768 local_node_pt = node_pt(n_node-1);
773 s_in_current[0] = -1.0 + 2.0*s_fraction[0];
779 for(
unsigned t=0;
t<n_time;
t++)
789 if(is_periodic==
false)
792 double err = std::fabs(local_node_pt->
x(
t,0) - x_in_neighbour[0]);
798 << local_node_pt->
x(
t,0)
799 <<
" " << x_in_neighbour[0]<< std::endl;
801 oomph_info <<
"at " << local_node_pt->
x(0) << std::endl;
806 if(err>max_error_x[0]) { max_error_x[0]=err; }
821 get_interpolated_values(
t,s_in_current,values_in_current);
824 const unsigned num_val
828 for(
unsigned ival=0;ival<num_val;ival++)
831 double err = std::fabs(values_in_current[ival]
832 - values_in_neighbour[ival]);
838 <<
"erru " << err <<
" " << ival <<
" " 839 << get_node_number(local_node_pt) <<
" " 840 << values_in_current[ival]
841 <<
" " << values_in_neighbour[ival] << std::endl;
846 if (err>max_error_val) { max_error_val=err; }
853 max_error = max_error_x[0];
854 if(max_error_val>max_error) { max_error = max_error_val; }
859 oomph_info <<
"\n#------------------------------------ \n#Max error " ;
861 <<
" " << max_error_val << std::endl;
862 oomph_info <<
"#------------------------------------ \n " << std::endl;
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...
virtual unsigned ncont_interpolated_values() const =0
Number of continuously interpolated values. Note: We assume that they are located at the beginning of...
A policy class that serves to establish the common interfaces for elements that contain moving nodes...
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 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...
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
unsigned Number
The unsigned.
void add_node_pt(Node *const &node_pt)
Add a (pointer to a) node to the mesh.
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...
double & x(const unsigned &i)
Return the i-th nodal coordinate.
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
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 nposition_type() const
Number of coordinate types needed in the mapping between local and global coordinates.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Vector< GeomObject * > & geom_object_pt()
Vector of (pointers to) geometric objects involved in node update function.
virtual bool nodes_built()
Return true if all the nodes have been built, false if not.
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...
static const int OMEGA
Default value for an unassigned neighbour.
Base class for elements that allow MacroElement-based node update.
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
Vector< std::string > colour
Tecplot colours.
int & method_for_shape_derivs()
Access to method (enumerated flag) for determination of shape derivs.
int son_type() const
Return son type.
RefineableElement * object_pt() const
Return the pointer to the object (RefineableElement) represented by the tree.
void enable_bypass_fill_in_jacobian_from_geometric_data()
Bypass the call to fill_in_jacobian_from_geometric_data.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
MacroElement * Macro_elem_pt
Pointer to the element's macro element (NULL by default)
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...