node_node_constraint_elements.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef NODE_NODE_CONSTRAINT_ELEMENTS_HEADER
6 #define NODE_NODE_CONSTRAINT_ELEMENTS_HEADER
7 
8 #include "constraint_elements.h"
9 
10 // Config header generated by autoconfig
11 #ifdef HAVE_CONFIG_H
12 #include <oomph-lib-config.h>
13 #endif
14 
15 
16 namespace oomph
17 {
18  // Generic for constructing constraints between two nodes.
19  // Must call construct_lagrange_multipliers() in the constructor of any derived class
21  {
22  public:
23  // Pointers to the nodes which own the dofs which are to be pinned
24  NodeNodeConstraintElement(Node* node0_pt, Node* node1_pt) :
26  ConstraintElement({node0_pt, node1_pt})
27  {
28  }
29 
30  // Pointers to the nodes which own the dofs which are to be pinned,
31  // includes additional data pointers for the variational positions
34  ConstraintElement({node0_pt,
35  node1_pt,
36  node0_pt->variable_position_pt(),
37  node1_pt->variable_position_pt()})
38  {
39  }
40 
41  // return a pointer to the i-th node
42  Data* node_pt(const unsigned& i)
43  {
44  #ifdef RANGE_CHECKING
45  if(i!=0 || i!=1)
46  {
47  throw OomphLibError("There are only 2 nodes but you requested node " + std::to_string(i),
50  }
51  #endif
52  return ext_data_pt(i);
53  }
54 
55  // Access the i-th node as a solid node pt
56  SolidNode* solid_node_pt(const unsigned& i)
57  {
58  #ifdef PARANOID
59  if(dynamic_cast<SolidNode*>(ext_data_pt(i)) == nullptr)
60  {
61  throw OomphLibError("Node* cannot be cast to SolidNode*",
64  }
65  #endif
66  return dynamic_cast<SolidNode*>(ext_data_pt(i));
67  }
68  };
69 
70 
71  // A specific reimplementation of NodeNodeConstraintElement which enforces that dofs at
72  // all specified indicies of the nodes passed to the constructor are identical in value
73  // including solid dofs.
75  {
76  public:
77  // Pointers to the nodes which own the dofs which are to be pinned. Pass in the list of indices which are to be mortared
78  NodeNodeMortaringElement(Node* node0_pt, Node* node1_pt,
79  const Vector<int>& mortared_indices = {-1}) :
81  ConstraintElement({node0_pt, node1_pt}),
82  NodeNodeConstraintElement(node0_pt, node1_pt),
83  Mortared_Indices(mortared_indices),
85  {
87  }
88 
89  // Pointers to the nodes which own the dofs which are to be pinned. Pass in the list of indices which are to be mortared and list
90  // of solid dofs which are to be mortared.
91  // var_pos1_pt and var_pos1_pt
93  const Vector<int>& mortared_indices = {-1},
94  const Vector<int>& mortared_solid_indices = {-1}) : // Set to {-1} - this implies we want to mortar all solid dofs
96  ConstraintElement({node0_pt, node1_pt, node0_pt->variable_position_pt(), node1_pt->variable_position_pt()}),
97  NodeNodeConstraintElement(node0_pt, node1_pt),
98  Mortared_Indices(mortared_indices),
99  Mortared_Solid_Indices(mortared_solid_indices)
100  {
102  }
103 
104  // We know precisely how many lagrange multipliers we need and what the residual and jacobian entries are
105  void construct_lagrange_multipliers() override;
106  void fill_in_contribution_to_residuals(Vector<double>& residuals) override;
107  void fill_in_contribution_to_jacobian(Vector<double>& residuals, DenseMatrix<double>& jacobian) override;
108 
109  private:
110  void fill_in_contribution_to_jacobian_mortared_nodes(Vector<double>& residuals, DenseMatrix<double>& jacobian, const bool& flag);
113  };
114 } // End namespace
115 #endif
Matrix< Scalar, Dynamic, Dynamic > DenseMatrix
Definition: BenchSparseUtil.h:23
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Definition: constraint_elements.h:82
ConstraintElement(Vector< Data * > &data_pt)
Definition: constraint_elements.h:85
Data * ext_data_pt(const unsigned &i)
Definition: constraint_elements.h:148
Definition: nodes.h:86
Definition: elements.h:73
GeneralisedElement()
Constructor: Initialise all pointers and all values to zero.
Definition: elements.h:596
Definition: node_node_constraint_elements.h:21
Data * node_pt(const unsigned &i)
Definition: node_node_constraint_elements.h:42
NodeNodeConstraintElement(SolidNode *node0_pt, SolidNode *node1_pt)
Definition: node_node_constraint_elements.h:32
SolidNode * solid_node_pt(const unsigned &i)
Definition: node_node_constraint_elements.h:56
NodeNodeConstraintElement(Node *node0_pt, Node *node1_pt)
Definition: node_node_constraint_elements.h:24
Definition: node_node_constraint_elements.h:75
void fill_in_contribution_to_jacobian_mortared_nodes(Vector< double > &residuals, DenseMatrix< double > &jacobian, const bool &flag)
Definition: node_node_constraint_elements.cc:126
NodeNodeMortaringElement(SolidNode *node0_pt, SolidNode *node1_pt, const Vector< int > &mortared_indices={-1}, const Vector< int > &mortared_solid_indices={-1})
Definition: node_node_constraint_elements.h:92
void fill_in_contribution_to_residuals(Vector< double > &residuals) override
Definition: node_node_constraint_elements.cc:116
void construct_lagrange_multipliers() override
Definition: node_node_constraint_elements.cc:18
Vector< int > Mortared_Solid_Indices
Definition: node_node_constraint_elements.h:112
Vector< int > Mortared_Indices
Definition: node_node_constraint_elements.h:111
NodeNodeMortaringElement(Node *node0_pt, Node *node1_pt, const Vector< int > &mortared_indices={-1})
Definition: node_node_constraint_elements.h:78
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian) override
Definition: node_node_constraint_elements.cc:120
Definition: nodes.h:906
Definition: oomph_definitions.h:222
Definition: nodes.h:1686
Data *const & variable_position_pt() const
Pointer to variable_position data (const version)
Definition: nodes.h:1765
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
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