31 template<
class MESH1,
class MESH2>
34 int *addmesh_map_boundary,
35 int total_boundaries,
unsigned spine_flag)
39 std::map<Node*,Node*> map_bound_node;
41 std::map<Spine*, Spine*> map_spines;
44 for(
unsigned i = 0;
i<addmesh_pt->nboundary();
i++)
46 if(addmesh_map_boundary[
i] == -1)
54 throw OomphLibError(
"Error setting the shared boundary conditions",
62 if(addmesh_pt->nboundary_node(bound2) != mesh_pt->nboundary_node(bound1) )
64 std::ostringstream error_stream;
66 <<
"Error: different number of nodes in the shared boundaries:"
67 <<
"Boundary "<<bound1<<
" in the original mesh has "
68 <<mesh_pt->nboundary_node(bound1)<<
" nodes "<<std::endl<<
69 "and Boundary "<<bound2<<
" in the added mesh has "
70 <<addmesh_pt->nboundary_node(bound2)<<
" nodes."<<std::endl;
85 unsigned dim = addmesh_pt->node_pt(0)->ndim();
87 unsigned long nodecounter;
91 for(
unsigned long i = 0;
i< addmesh_pt->nboundary_node(bound2);
i++)
98 for(
unsigned int k=0;
k<dim;
k++)
100 d += (addmesh_pt->boundary_node_pt(bound2,
i)->x(
k) - mesh_pt->boundary_node_pt(bound1,nodecounter)->x(
k) )*
101 (addmesh_pt->boundary_node_pt(bound2,
i)->x(
k) - mesh_pt->boundary_node_pt(bound1,nodecounter)->x(
k) );
108 }
while((nodecounter < mesh_pt->nboundary_node(bound1)) && (d>1
E-10));
110 if((nodecounter == mesh_pt->nboundary_node(bound1)) && (d>1
E-10))
112 std::ostringstream error_stream;
114 <<
"Error doing the mapping between shared boundaries:\n"<<
115 "it could not be found minimum distance in node "<<
i<<
"\n"
116 <<
"Minimum found distance = "<<
sqrt(
dmin)<<
"\n"
117 <<
"Position in the added mesh = "
118 <<addmesh_pt->boundary_node_pt(bound2,
i)->x(0)
119 <<
" "<<addmesh_pt->boundary_node_pt(bound2,
i)->x(1)<<
" "
120 <<addmesh_pt->boundary_node_pt(bound2,
i)->x(2)<<
"\n";
130 map_bound_node[addmesh_pt->boundary_node_pt(bound2,
i)] = mesh_pt->boundary_node_pt(bound1,nodecounter-1);
132 SpineNode *add_spinenode =
dynamic_cast<SpineNode*
>(addmesh_pt->boundary_node_pt(bound2,
i));
133 SpineNode *org_spinenode =
dynamic_cast<SpineNode*
>( mesh_pt->boundary_node_pt(bound1,nodecounter-1) );
136 if(add_spinenode ==0)
139 "There are nodes on the shared boundary of the added mesh which are not Spine Nodes\n",
144 if(org_spinenode ==0)
147 "There are nodes on the shared boundary of the original mesh which are not Spine Nodes\n",
158 if(map_spines[add_spine] == 0)
160 map_spines[add_spine] = org_spine;
166 if( map_spines[add_spine] != org_spine )
169 "The spines map could not be performed because the shared spines are pointing to different nodes\n",
187 for(
unsigned int i = 0;
i< addmesh_pt->nbulk();
i++ )
193 for(
unsigned j =0;
j< el_pt->
nnode();
j++)
197 if(map_bound_node[ el_pt->
node_pt(
j) ] != 0)
207 for(
unsigned int i = 0;
i< addmesh_pt->ninterface_element();
i++ )
213 for(
unsigned j =0;
j< surfel_pt->
nnode();
j++)
217 if(map_bound_node[ surfel_pt->
node_pt(
j) ] != 0)
229 unsigned long n_nodes_addmesh = addmesh_pt->nnode();
230 unsigned int zaehler = 0;
231 for(
unsigned j=0;
j<n_nodes_addmesh;
j++)
233 if( map_bound_node[ addmesh_pt->node_pt(
j)] == 0)
235 addmesh_pt->node_pt(
j)->node_update_fct_id() = spine_flag;
236 addmesh_pt->node_pt(
j)->spine_mesh_pt() = mesh_pt;
237 mesh_pt->add_node_pt( addmesh_pt->node_pt(
j) );
247 unsigned long n_spines_addmesh = addmesh_pt->nspine();
248 for(
unsigned j=0;
j<n_spines_addmesh;
j++)
250 if( map_spines[ addmesh_pt->spine_pt(
j)] == 0)
251 mesh_pt->add_spine_pt(addmesh_pt->spine_pt(
j));
258 if(zaehler != addmesh_pt->nboundary_node(bound2))
260 std::ostringstream error_stream;
262 <<
"Error: you have added "
263 <<(zaehler-addmesh_pt->nboundary_node(bound2))
264 <<
" nodes too much to the mesh.\n"
265 <<
"(This control should be removed in case we do not want to copy all the nodes of the shared boundaries)\n";
280 for(
unsigned i = 0;
i< addmesh_pt->nelement();
i++)
282 mesh_pt->add_element_pt(addmesh_pt->element_pt(
i));
289 mesh_pt->remove_boundary_nodes(bound1);
293 mesh_pt->set_nboundary(total_boundaries);
298 for(
int i=0;
i<(
int)(addmesh_pt->nboundary());
i++)
301 for(
unsigned long j =0;
j<addmesh_pt->nboundary_node(
i);
j++)
308 Node* node_pt = addmesh_pt->boundary_node_pt(
i,
j);
311 bool alr_included = 0;
312 for(
unsigned k =0;
k<mesh_pt->nboundary_node(
i);
k++)
314 if(node_pt == mesh_pt->boundary_node_pt(
i,
k) )
321 if( map_bound_node[node_pt] == 0)
323 mesh_pt->add_boundary_node( addmesh_map_boundary[
i], node_pt );
328 Node* map_node_pt = map_bound_node[node_pt];
330 mesh_pt->add_boundary_node(addmesh_map_boundary[
i], map_node_pt );
340 for(
unsigned j=0;
j<n_spines_addmesh;
j++)
342 if( map_spines[ addmesh_pt->spine_pt(
j)] != 0)
343 delete addmesh_pt->spine_pt(
j);
350 for(
unsigned long j =0;
j<addmesh_pt->nboundary_node(bound2);
j++)
351 delete addmesh_pt->boundary_node_pt(bound2,
j);
357 for(
unsigned i = 0;
i<mesh_pt->nboundary();
i ++)
359 std::cout<<
"Boundary "<<
i<<
" has "<<mesh_pt->nboundary_node(
i)<<
" nodes."<<std::endl;
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Definition: elements.h:1313
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
virtual bool is_on_boundary() const
Definition: nodes.h:1373
virtual void remove_from_boundary(const unsigned &b)
Definition: nodes.cc:2350
Definition: oomph_definitions.h:222
Spine *& spine_pt()
Access function to spine.
Definition: spines.h:372
#define dmin(a, b)
Definition: datatypes.h:24
char char char int int * k
Definition: level2_impl.h:374
double E
Elastic modulus.
Definition: TwenteMeshGluing.cpp:68
void merge_spine_meshes(MESH1 *mesh_pt, unsigned bound1, MESH2 *addmesh_pt, int *addmesh_map_boundary, int total_boundaries, unsigned spine_flag)
Definition: merge_meshes.h:32
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2