node_element_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_ELEMENT_CONSTRAINT_ELEMENTS_HEADER
6 #define NODE_ELEMENT_CONSTRAINT_ELEMENTS_HEADER
7 
8 #include "constraint_elements.h"
9 
10 namespace oomph
11 {
12  // It's difficult to write a general interface to interpolate values in an element.
13  // So we only implement solid dof only mortaring element.
14  // Mortars the position of a node to a local coordinate in an element.
16  {
17  public:
20  Local_Coord(s),
21  Node_pt(node_pt),
22  Element_pt(elem_pt),
23  Dim(node_pt->ndim())
24  {
25  if(Dim != elem_pt->dim())
26  {
27  throw OomphLibError("Mortaring element and node do not have the same number of dimensions " + std::to_string(Dim) + " " + std::to_string(elem_pt->dim()),
30  }
31  // Build the lagrange multipliers
34  }
35  // We know exactly how to fill in the residual and jacobian
37  {
39  }
41  {
43  }
44 
46  {
47  // The number of nodes in the element
48  const unsigned n_node = Element_pt->nnode();
49 
50  // The shape function
51  Shape psi(n_node);
53 
54  // Get the interpolated element coordinate
55  for(unsigned i=0; i<Dim; i++)
56  {
57  x[i] = 0.0;
58  for(unsigned l=0; l<n_node; l++)
59  {
60  // Get the coordinate of the node
61  x[i] += psi[l] * ext_data_pt(1+l)->value(i);
62  }
63  }
64  }
65 
66  // Used for when pruning redundant mortaring elements from the mesh
68  {
69  return Node_pt;
70  }
71 
72  private:
73  // Fill in rsidual and jacobian generic
75  {
76  // The number of nodes in the element
77  const unsigned n_node = Element_pt->nnode();
78 
79  // The shape function
80  Shape psi(n_node);
82 
83  // Loop over the dimensions
84  for(unsigned i=0; i<Dim; i++)
85  {
86  // eqn numbers
87  const int lambda_eqn = lagrange_eqn(i);
88  const int node_eqn = ext_eqn(0,i);
89  Vector<int> element_node_eqn(n_node);
90 
91  // Get the lagrange multiplier value
92  const double lambda = lagrange_multiplier()->value(i);
93 
94  // The node coordinate
95  const double x_node = ext_data_pt(0)->value(i);
96 
97  // Get the interpolated element coordinate
98  double x_elem = 0.0;
99  for(unsigned l=0;l<n_node;l++)
100  {
101  // Get the eqn number
102  element_node_eqn[l] = ext_eqn(1+l, i);
103  // Get the coordinate of the node
104  x_elem += psi[l] * ext_data_pt(1+l)->value(i);
105  }
106 
107  // Fill in the residuals and jacobian entries
108 
109  // Lambda residual
110  if(lambda_eqn>=0)
111  {
112  residuals[lambda_eqn] += (x_node - x_elem);
113  if(flag)
114  {
115  if(node_eqn>=0)
116  {
117  jacobian(lambda_eqn, node_eqn) += 1.0;
118  }
119  for(unsigned l=0;l<n_node;l++)
120  {
121  if(element_node_eqn[l]>=0)
122  {
123  jacobian(lambda_eqn, element_node_eqn[l]) -= psi[l];
124  }
125  }
126  }
127  }
128 
129  // Node residual
130  if(node_eqn>=0)
131  {
132  residuals[node_eqn] += lambda;
133  if(flag)
134  {
135  if(lambda_eqn>=0)
136  {
137  jacobian(node_eqn, lambda_eqn) += 1.0;
138  }
139  }
140  }
141 
142  // Element node residual
143  for(unsigned l=0;l<n_node;l++)
144  {
145  if(element_node_eqn[l]>=0)
146  {
147  residuals[element_node_eqn[l]] -= lambda*psi[l];
148  if(flag)
149  {
150  if(lambda_eqn>=0)
151  {
152  jacobian(element_node_eqn[l], lambda_eqn) -= psi[l];
153  }
154  }
155  }
156  }
157  }
158  }
159 
160 
161  // Get the vector of data from the node and the finite element
163  {
164  const unsigned n_node_element = elem_pt->nnode();
165  Vector<Data*> data_pt(1 + n_node_element);
166  data_pt[0] = node_pt->variable_position_pt();
167  for(unsigned i=0; i<n_node_element; i++)
168  {
169  data_pt[i+1] = dynamic_cast<SolidNode*>(elem_pt->node_pt(i))->variable_position_pt();
170  }
171  return data_pt;
172  }
173 
174  private:
178  unsigned Dim;
179  };
180 } // End namespace
181 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
cout<< "The eigenvalues of A are:"<< endl<< ces.eigenvalues()<< endl;cout<< "The matrix of eigenvectors, V, is:"<< endl<< ces.eigenvectors()<< endl<< endl;complex< float > lambda
Definition: ComplexEigenSolver_compute.cpp:9
Definition: constraint_elements.h:82
unsigned Num_Constraints
Definition: constraint_elements.h:180
Data * lagrange_multiplier()
Definition: constraint_elements.h:131
const int lagrange_eqn(const unsigned &i)
Definition: constraint_elements.h:135
unsigned Lagrange_Multiplier_Index
Definition: constraint_elements.h:178
const int ext_eqn(const unsigned &i, const unsigned &j)
Definition: constraint_elements.h:160
Data * ext_data_pt(const unsigned &i)
Definition: constraint_elements.h:148
Definition: nodes.h:86
double value(const unsigned &i) const
Definition: nodes.h:293
Definition: elements.h:1313
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
virtual void shape(const Vector< double > &s, Shape &psi) const =0
unsigned dim() const
Definition: elements.h:2611
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
static DenseMatrix< double > Dummy_matrix
Definition: elements.h:227
unsigned add_internal_data(Data *const &data_pt, const bool &fd=true)
Definition: elements.cc:62
Definition: node_element_constraint_elements.h:16
Vector< double > Local_Coord
Definition: node_element_constraint_elements.h:175
unsigned Dim
Definition: node_element_constraint_elements.h:178
static Vector< Data * > node_and_vector_to_data_pt(SolidNode *node_pt, FiniteElement *elem_pt)
Definition: node_element_constraint_elements.h:162
SolidNode * solid_node_pt()
Definition: node_element_constraint_elements.h:67
FiniteElement * Element_pt
Definition: node_element_constraint_elements.h:177
void position_in_element(Vector< double > &x)
Definition: node_element_constraint_elements.h:45
NodeElementSolidOnlyMortaringElement(SolidNode *node_pt, FiniteElement *elem_pt, Vector< double > &s)
Definition: node_element_constraint_elements.h:18
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian) override
Definition: node_element_constraint_elements.h:40
void fill_in_contribution_to_residuals(Vector< double > &residuals) override
Definition: node_element_constraint_elements.h:36
SolidNode * Node_pt
Definition: node_element_constraint_elements.h:176
void fill_in_contribution_to_jacobian_mortared_nodes(Vector< double > &residuals, DenseMatrix< double > &jacobian, const bool &flag)
Definition: node_element_constraint_elements.h:74
Definition: oomph_definitions.h:222
Definition: shape.h:76
Definition: nodes.h:1686
Data *const & variable_position_pt() const
Pointer to variable_position data (const version)
Definition: nodes.h:1765
RealScalar s
Definition: level1_cplx_impl.h:130
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
list x
Definition: plotDoE.py:28
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86