GluedSolidMesh Class Reference

#include <glued_mesh_stuff.h>

+ Inheritance diagram for GluedSolidMesh:

Public Member Functions

 GluedSolidMesh (Vector< SolidMesh * > solid_mesh_pt)
 
void glue (const Vector< Node * > glue_node_pt, const unsigned &i_mesh_replace)
 

Private Attributes

Vector< SolidMesh * > Constituent_mesh_pt
 

Detailed Description

Glued mesh; created by replacing pointers to spatially co-located nodes of multiple constituent meshes. The constituent meshes stay alive because they're used to identify mesh boundaries etc. Their boundary lookup schemes etc. are updated to account for the "glued" nodes. hierher currently only for SolidMesh; should be generalised before the machinery is moved into Src/generic. hierher search for collocated nodes currently brute forced. Could be optimised with cgal's tree-based search.

Constructor & Destructor Documentation

◆ GluedSolidMesh()

GluedSolidMesh::GluedSolidMesh ( Vector< SolidMesh * >  solid_mesh_pt)
inline

Constructor: Pass vector of source meshes. Co-lated nodes can be glued together (by re-allocating pointers)

29  :
30  Constituent_mesh_pt(solid_mesh_pt) {
31  // Copy all nodes
32  unsigned n_mesh = solid_mesh_pt.size();
33  unsigned total_nnode = 0;
34  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
35  total_nnode += solid_mesh_pt[i_mesh]->nnode();
36  }
37  Node_pt.resize(total_nnode);
38 
39  unsigned node_count = 0;
40  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
41  unsigned nnode = solid_mesh_pt[i_mesh]->nnode();
42  for (unsigned j = 0; j < nnode; j++) {
43  Node_pt[node_count] = solid_mesh_pt[i_mesh]->node_pt(j);
44  node_count++;
45  }
46  }
47 
48  // Copy all elements
49  unsigned total_nel = 0;
50  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
51  total_nel += solid_mesh_pt[i_mesh]->nelement();
52  }
53  Element_pt.resize(total_nel);
54 
55  unsigned el_count = 0;
56  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
57  unsigned nel = solid_mesh_pt[i_mesh]->nelement();
58  for (unsigned e = 0; e < nel; e++) {
59  Element_pt[el_count] = solid_mesh_pt[i_mesh]->element_pt(e);
60  el_count++;
61  }
62  }
63  }
Vector< SolidMesh * > Constituent_mesh_pt
Definition: glued_mesh_stuff.h:23

Member Function Documentation

◆ glue()

void GluedSolidMesh::glue ( const Vector< Node * >  glue_node_pt,
const unsigned &  i_mesh_replace 
)
inline

Glue specified nodes to co-located nodes in consituent mesh i_mesh_replace. i.e pointers to nodes in constituent mesh i_mesh_replace are replaced by pointers to colocated nodes (in glue_node_pt). Original nodes are then deleted and the boundary lookup schemes of constituent mesh i_mesh_replace are updated.

73  {
74  double t_start = TimingHelpers::timer();
75 
76  // Make input parameter
77  double tol = 1.0e-10;
78 
79  // Map from original to replacement node:
80  // Usage: replacement_node_pt[replaced_node_pt]=nod_pt
81  std::map<Node *, Node *> replacement_node_pt;
82 
83  // Brute force it:
84  //================
85  unsigned nnod_glue = glue_node_pt.size();
86  for (unsigned j = 0; j < nnod_glue; j++) {
87  Node *nod_pt = glue_node_pt[j];
88  unsigned dim = nod_pt->ndim();
89  Node *node_to_be_replaced_pt = 0;
90  unsigned jj_replace_index = 0;
91  unsigned nnod_candidate = Constituent_mesh_pt[i_mesh_replace]->nnode();
92  for (unsigned jj = 0; jj < nnod_candidate; jj++) {
93  Node *nod_alt_pt = Constituent_mesh_pt[i_mesh_replace]->node_pt(jj);
94  double dist_squared = 0.0;
95  for (unsigned i = 0; i < 3; i++) {
96  dist_squared +=
97  (nod_alt_pt->x(i) - nod_pt->x(i)) *
98  (nod_alt_pt->x(i) - nod_pt->x(i));
99  }
100  if (sqrt(dist_squared) < tol) {
101  node_to_be_replaced_pt = nod_alt_pt;
102  jj_replace_index = jj;
103  break;
104  }
105  }
106  if (node_to_be_replaced_pt == 0) {
107  oomph_info << "ERROR: Not found a replacement node for node at ";
108  for (unsigned i = 0; i < dim; i++) {
109  oomph_info << nod_pt->x(i) << " ";
110  }
111  oomph_info << std::endl;
112  // hierher throw proper error
113  abort();
114  }
115 
116  // Replace node in constituent mesh
117  Node *replaced_node_pt =
118  Constituent_mesh_pt[i_mesh_replace]->node_pt(jj_replace_index);
119  dynamic_cast<Mesh *>(Constituent_mesh_pt[i_mesh_replace])->
120  node_pt(jj_replace_index) = nod_pt;
121  replacement_node_pt[replaced_node_pt] = nod_pt;
122 
123  // Replace node in elements
124  unsigned nel = Constituent_mesh_pt[i_mesh_replace]->nelement();
125  for (unsigned e = 0; e < nel; e++) {
126  FiniteElement *fe_pt =
127  Constituent_mesh_pt[i_mesh_replace]->finite_element_pt(e);
128  unsigned nod_el = fe_pt->nnode();
129  for (unsigned j_in_el = 0; j_in_el < nod_el; j_in_el++) {
130  if (fe_pt->node_pt(j_in_el) == node_to_be_replaced_pt) {
131  fe_pt->node_pt(j_in_el) = nod_pt;
132  }
133  }
134  }
135 
136  // Replace node in original mesh's boundary lookup scheme
137  unsigned nb = Constituent_mesh_pt[i_mesh_replace]->nboundary();
138  for (unsigned b = 0; b < nb; b++) {
139  unsigned nnod = Constituent_mesh_pt[i_mesh_replace]->nboundary_node(b);
140  for (unsigned j = 0; j < nnod; j++) {
141  Node *potentially_replaced_node_pt =
142  Constituent_mesh_pt[i_mesh_replace]->boundary_node_pt(b, j);
143  std::map<Node *, Node *>::iterator it;
144  it = replacement_node_pt.find(potentially_replaced_node_pt);
145  if (it == replacement_node_pt.end()) {
146  //oomph_info << "Node in boundary lookup scheme was not replaced\n";
147  } else {
148  // oomph_info << "Replace node "
149  // << potentially_replaced_node_pt << " at: "
150  // << (it->second)->x(0) << " "
151  // << (it->second)->x(1) << " "
152  // << (it->second)->x(2) << " "
153  // << "with " << it->second
154  // << std::endl;
155 
156  // hierher: SolidMesh needs an overload of the read/write version
157  // to this function
158  dynamic_cast<Mesh *>(Constituent_mesh_pt[i_mesh_replace])->
159  boundary_node_pt(b, j) = it->second;
160  }
161  }
162  }
163 
164 
165  // Remove it from the glued mesh's compound Node_pt vector:
166  Vector<Node *> tmp_node_pt(Node_pt);
167  unsigned nnod = tmp_node_pt.size();
168  Node_pt.resize(nnod - 1);
169  unsigned count = 0;
170  for (unsigned jj = 0; jj < nnod; jj++) {
171  if (tmp_node_pt[jj] != node_to_be_replaced_pt) {
172  Node_pt[count] = tmp_node_pt[jj];
173  count++;
174  }
175  }
176 
177  // Now kill node
178  // hierher REINSTATE deletion
179  delete node_to_be_replaced_pt;
180  }
181 
182  // oomph_info << "After gluing glued mesh has " << Node_pt.size()
183  // << " nodes" << std::endl;
184 
185 
186  // Tell us how bad it was; do you fancy implementing the optimised
187  // search scheme?
188  double t_end = TimingHelpers::timer();
189  oomph_info << "Time for (inefficient!) mesh gluing: "
190  << t_end - t_start << std::endl;
191 
192 
193  }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References Constituent_mesh_pt, and constants::i.

Member Data Documentation

◆ Constituent_mesh_pt

Vector<SolidMesh *> GluedSolidMesh::Constituent_mesh_pt
private

Vector of pointers to (still existing) constituent meshes; we retain them for access to their boundary enumerations

Referenced by glue().


The documentation for this class was generated from the following file: