5 #ifndef MORTARING_HELPERS_HEADER
6 #define MORTARING_HELPERS_HEADER
11 using namespace oomph;
40 const unsigned n_mesh = solid_mesh_pt.size();
43 unsigned n_boundary = 0;
44 for(
unsigned m=0;
m<n_mesh;
m++)
46 n_boundary += solid_mesh_pt[
m]->nboundary();
47 if(
m==n_mesh-1)
continue;
48 Boundary_shift[
m+1] = solid_mesh_pt[
m]->nboundary();
50 this->set_nboundary(n_boundary);
51 Boundary_element_pt.resize(n_boundary);
52 Face_index_at_boundary.resize(n_boundary);
54 for(
unsigned m=0;
m<n_mesh;
m++)
56 const unsigned n_node = solid_mesh_pt[
m]->nnode();
57 for (
unsigned nd = 0; nd < n_node; nd++)
59 Node* nd_pt = solid_mesh_pt[
m]->node_pt(nd);
63 std::set<unsigned>* boundaries_pt;
67 std::set<unsigned>::const_iterator it;
68 for (it = boundaries_pt->begin(); it != boundaries_pt->end(); it++)
70 Boundary_node_pt[*it + Boundary_shift[
m]].push_back(nd_pt);
76 for(
unsigned b=0;
b<solid_mesh_pt[
m]->nboundary();
b++)
79 Vector<int> boundary_faces(solid_mesh_pt[
m]->nboundary_element(
b));
80 for(
unsigned e=0;
e<solid_mesh_pt[
m]->nboundary_element(
b);
e++)
82 boundary_elements[
e] = solid_mesh_pt[
m]->boundary_element_pt(
b,
e);
83 boundary_faces[
e] = solid_mesh_pt[
m]->face_index_at_boundary(
b,
e);
85 Boundary_element_pt[Boundary_shift[
m]+
b] = boundary_elements;
86 Face_index_at_boundary[Boundary_shift[
m]+
b] = boundary_faces;
111 double knot(
const unsigned&
i,
const unsigned&
j)
const
135 this->set_dimension(coord.size());
137 this->set_ninteraction(n_interaction);
139 this->set_integration_scheme(&Interface_default_integration_scheme);
143 for(
unsigned i=0;
i<coord.size();
i++)
145 node_pt->
x(
i) = coord[
i];
151 PointIntegralScheme PointElementWithExternalElement::Interface_default_integration_scheme;
168 template<
class NodeNodeConstra
intClass,
class NodeElementConstra
intClass,
class ELEMENTTYPE>
172 const bool& accept_failure =
false)
178 const unsigned dim = node_pt[0][0]->ndim();
185 node_was_matched[0].resize(n_node[0], 0);
186 node_was_matched[1].resize(n_node[1], 0);
189 unsigned n_matched_nodes = 0;
190 for(
unsigned i=0;
i<n_node[0];
i++)
193 for(
unsigned j=0;
j<n_node[1];
j++)
196 if(node_was_matched[1][
j])
continue;
201 double distance = 0.0;
202 for(
unsigned d=0; d<dim; d++)
204 distance += (node_0_pt->
xi(d) - node_1_pt->
xi(d))*
205 (node_0_pt->
xi(d) - node_1_pt->
xi(d));
212 if(node_0_pt == node_1_pt)
continue;
214 node_was_matched[0][
i] = 1;
215 node_was_matched[1][
j] = 1;
218 constraint_element_pt.push_back(
new NodeNodeConstraintClass(node_0_pt, node_1_pt));
227 if((n_node[0] - n_matched_nodes) == 0 && (n_node[1] - n_matched_nodes) == 0 )
return constraint_element_pt;
232 if(mesh_pt[0] == mesh_pt[1])
234 throw OomphLibError(
"Mortaring failed - meshes are the same and node-node mortaring has not captured all nodes",
239 const bool Previous_Accept_failed_locate_zeta_in_setup_multi_domain_interaction
246 n_node[1] - n_matched_nodes};
248 for(
unsigned m : {0,1})
250 if(n_unmatched_nodes[
m] == 0)
continue;
255 for(
unsigned i=0;
i<n_node[
m];
i++)
257 if(!node_was_matched[
m][
i])
259 unmatched_node_pt[count++] = node_pt[
m][
i];
267 for(
unsigned i=0;
i<n_unmatched_nodes[
m];
i++)
270 for(
unsigned d=0; d<dim; d++)
272 x[d] =
dynamic_cast<SolidNode*
>(unmatched_node_pt[
i])->xi(d);
280 Multi_domain_functions::setup_multi_domain_interaction<ELEMENTTYPE>(problem_pt,
282 mesh_pt[
unsigned(1-
m)],
286 for(
unsigned i=0;
i<n_unmatched_nodes[
m];
i++)
290 if(locating_elements_pt[
i]->external_element_pt(0,0) ==
nullptr)
continue;
291 constraint_element_pt.push_back(
new NodeElementConstraintClass(
dynamic_cast<SolidNode*
>(unmatched_node_pt[
i]),
292 locating_elements_pt[
i]->external_element_pt(0,0),
293 locating_elements_pt[
i]->external_element_local_coord(0,0)));
298 return constraint_element_pt;
319 template<
class NodeNodeConstra
intElementType>
321 Node* parent_node_pt,
322 std::map<
Node*,
Vector<std::pair<NodeNodeConstraintElementType*, Node*>>>& tree,
323 std::map<Node*, Colour>& colours,
327 colours[node_pt] =
GREY;
331 for (
auto& branch : branches)
333 Node* next_node = branch.second;
334 NodeNodeConstraintElementType* element = branch.first;
337 if (std::find(pruned_branches.begin(), pruned_branches.end(), element) != pruned_branches.end())
343 if (colours[next_node] ==
GREY && next_node != parent_node_pt)
345 pruned_branches.push_back(element);
348 else if (colours[next_node] ==
WHITE)
350 dfs(next_node, node_pt, tree, colours, pruned_branches);
355 colours[node_pt] =
BLACK;
359 template<
class NodeNodeConstra
intElementType>
363 std::map<Node*, Vector<std::pair<NodeNodeConstraintElementType*, Node*>>> tree;
364 for (
auto& element : element_pt)
366 Node* node1 = element->solid_node_pt(0);
367 Node* node2 = element->solid_node_pt(1);
368 tree[node1].push_back(std::make_pair(element, node2));
369 tree[node2].push_back(std::make_pair(element, node1));
375 std::map<Node*, Colour> colours;
378 for (
auto& node_branches : tree)
380 Node* root_node = node_branches.first;
381 if (colours[root_node] ==
WHITE)
384 dfs(root_node,
nullptr, tree, colours, pruned_branches);
388 return pruned_branches;
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Scalar * b
Definition: benchVecAdd.cpp:17
Definition: mortaring_helpers.h:30
MergedSolidMesh(Vector< SolidMesh * > solid_mesh_pt)
Definition: mortaring_helpers.h:32
Definition: mortaring_helpers.h:126
PointElementWithExternalElement(const Vector< double > &coord, const unsigned &n_interaction=1)
Definition: mortaring_helpers.h:132
static PointIntegralScheme Interface_default_integration_scheme
Definition: mortaring_helpers.h:129
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: mortaring_helpers.h:149
Definition: mortaring_helpers.h:93
PointIntegralScheme(const PointIntegralScheme &dummy)=delete
Broken copy constructor.
unsigned nweight() const
Number of integration points of the scheme.
Definition: mortaring_helpers.h:105
double knot(const unsigned &i, const unsigned &j) const
Return coordinate.
Definition: mortaring_helpers.h:111
void operator=(const PointIntegralScheme &)=delete
Broken assignment operator.
PointIntegralScheme()
Default constructor (empty)
Definition: mortaring_helpers.h:96
double weight(const unsigned &i) const
Return weight of integration point i.
Definition: mortaring_helpers.h:117
Definition: element_with_external_element.h:56
Definition: integral.h:49
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
void add_element_pt(GeneralisedElement *const &element_pt)
Add a (pointer to) an element to the mesh.
Definition: mesh.h:617
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
virtual bool is_on_boundary() const
Definition: nodes.h:1373
virtual void get_boundaries_pt(std::set< unsigned > *&boundaries_pt)
Definition: nodes.h:1365
Definition: oomph_definitions.h:222
Definition: elements.h:3439
Definition: problem.h:151
double & xi(const unsigned &i)
Reference to i-th Lagrangian position.
Definition: nodes.h:1883
Definition: timesteppers.h:231
int * m
Definition: level2_cplx_impl.h:294
Definition: mortaring_helpers.h:25
Vector< NodeNodeConstraintElementType * > find_redundant_constraint_elements(Vector< NodeNodeConstraintElementType * > element_pt)
Definition: mortaring_helpers.h:360
static double Mortaring_Constraints_Distance_Tolerance
Definition: mortaring_helpers.h:162
Vector< ConstraintElement * > setup_constraint_elements_at_nodes(Problem *problem_pt, Vector< Vector< Node * >> node_pt, Vector< SolidMesh * > mesh_pt, const bool &accept_failure=false)
Definition: mortaring_helpers.h:169
void dfs(Node *node_pt, Node *parent_node_pt, std::map< Node *, Vector< std::pair< NodeNodeConstraintElementType *, Node * >>> &tree, std::map< Node *, Colour > &colours, Vector< NodeNodeConstraintElementType * > &pruned_branches)
Definition: mortaring_helpers.h:320
Colour
Definition: mortaring_helpers.h:316
@ WHITE
Definition: mortaring_helpers.h:316
@ BLACK
Definition: mortaring_helpers.h:316
@ GREY
Definition: mortaring_helpers.h:316
bool Accept_failed_locate_zeta_in_setup_multi_domain_interaction
Definition: multi_domain.cc:56
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
#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