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)

34  :
35  Constituent_mesh_pt(solid_mesh_pt) {
36  // Copy all nodes
37  unsigned n_mesh = solid_mesh_pt.size();
38  unsigned total_nnode = 0;
39  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
40  total_nnode += solid_mesh_pt[i_mesh]->nnode();
41  }
42  Node_pt.resize(total_nnode);
43 
44  unsigned node_count = 0;
45  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
46  unsigned nnode = solid_mesh_pt[i_mesh]->nnode();
47  for (unsigned j = 0; j < nnode; j++) {
48  Node_pt[node_count] = solid_mesh_pt[i_mesh]->node_pt(j);
49  node_count++;
50  }
51  }
52 
53  // Copy all elements
54  unsigned total_nel = 0;
55  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
56  total_nel += solid_mesh_pt[i_mesh]->nelement();
57  }
58  Element_pt.resize(total_nel);
59 
60  unsigned el_count = 0;
61  for (unsigned i_mesh = 0; i_mesh < n_mesh; i_mesh++) {
62  unsigned nel = solid_mesh_pt[i_mesh]->nelement();
63  for (unsigned e = 0; e < nel; e++) {
64  Element_pt[el_count] = solid_mesh_pt[i_mesh]->element_pt(e);
65  el_count++;
66  }
67  }
68  }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Vector< SolidMesh * > Constituent_mesh_pt
Definition: glued_mesh_stuff.h:28
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References e(), and j.

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.

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

References b, Constituent_mesh_pt, e(), i, j, nb, oomph::oomph_info, and sqrt().

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: