element_with_mortaring_status_at_nodes.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 ELEMENT_WITH_MORTARING_STATUS_AT_NODES_HEADER
6 #define ELEMENT_WITH_MORTARING_STATUS_AT_NODES_HEADER
7 
8 #include "generic.h"
9 
10 namespace oomph
11 {
12 // Stores an additional double at each node
13 // The value of the double represents if the node is marked for mortaring/has been mortared or not
14 // The mortared status is interpolated during mesh refinement
15 // Mortared status must be pinned before newton solve is called since it has no residual/jacobian fill-in
16 //TODO
17 // Generalise a little - replace set_mortared and set_not_mortared with set_mortared_status
18 // The mortared status can represent whatever the user wants it to
19 // Remove references to mortaring
20 // add general number of values
21 // allows for whatever quantities to be set by the user and interpolated automatically.
22 // Doees the mortaring status need to be a dof? It could just be stored in an array of sizse number of nodes
23 // and interpolated from the nodes of the parent element during refinement by taking the value from this vector.
24 // This will remove the need to pin the mortared status dof.
25 // It will prevent the mortaring status from being derived from some set of equations, but if the user wants
26 // To do this then they can implement that themselves.
27 template<class ELEMENT>
28 class ElementWithMortaringStatusAtNodes : public virtual ELEMENT
29 {
30 public:
32  Output_Mortared_Status(false) {}
33 
35  {
37  }
39  {
40  Output_Mortared_Status = false;
41  }
42  // Add 1 dof to each node to represent the mortared status
43  unsigned required_nvalue(const unsigned &n) const override
44  {
45  return ELEMENT::required_nvalue(n) + 1;
46  }
47 
48  unsigned mortared_dof_index(const unsigned &n) const
49  {
50  return required_nvalue(n) - 1;
51  }
52 
53  // Mortared status of nth node
54  double mortared_status(const unsigned &n) const
55  {
56  return this->node_pt(n)->value(mortared_dof_index(n));
57  }
58 
59  // Set a node to be mortared or not mortared
60  // this can also be set directly on the node by assigning a value to the (nvalue()-1)th dof of the node
61  void set_mortared(const unsigned&n, const double& mortared_status = 1.0)
62  {
63  return this->node_pt(n)->set_value(mortared_dof_index(n), mortared_status);
64  }
65  void set_not_mortared(const unsigned&n, const double& mortared_status = 0.0)
66  {
67  return this->node_pt(n)->set_value(mortared_dof_index(n), mortared_status);
68  }
69 
70  // Pin all mortared status dofs in the nodes. Must be pinned since these dofs intentionally have no
71  // residual or jacobian
73  {
74  for(unsigned n=0; n<this->nnode(); n++)
75  {
76  this->node_pt(n)->pin(mortared_dof_index(n));
77  }
78  }
79 
80  unsigned ncont_interpolated_values() const
81  {
82  return ELEMENT::ncont_interpolated_values() + 1;
83  }
84 
86  {
87  double value = 0.0;
88  // Find out how many nodes there are
89  unsigned n_node = this->nnode();
90 
91  // Shape functions
92  Shape psif(n_node);
93  this->shape(s, psif);
94  for (unsigned l = 0; l < n_node; l++)
95  {
96  value += this->mortared_status(l) * psif[l];
97  }
98  return value;
99  }
101  Vector<double>& values)
102  {
103  ELEMENT::get_interpolated_values(s,values);
104  values.push_back(get_interpolated_mortared_status(s));
105  }
106 
107  void get_interpolated_values(const unsigned& t,
108  const Vector<double>& s,
109  Vector<double>& values)
110  {
111  ELEMENT::get_interpolated_values(t, s,values);
112  values.push_back(get_interpolated_mortared_status(s));
113  }
114 
115  void output(std::ostream& outfile, const unsigned& nplot)
116  {
118  {
119  // vector of local coordinates
120  Vector<double> s(this->dim());
121 
122  // Tecplot header info
123  outfile << this->tecplot_zone_string(nplot);
124 
125  // Loop over plot points
126  unsigned num_plot_points = this->nplot_points(nplot);
127  for (unsigned iplot = 0; iplot < num_plot_points; iplot++)
128  {
129  // Get local coordinates of plot point
130  this->get_s_plot(iplot, nplot, s);
131 
132  for (unsigned i = 0; i < this->dim(); i++)
133  {
134  outfile << this->interpolated_x(s, i) << " ";
135  }
136 
138  outfile << std::endl;
139  }
140  outfile << std::endl;
141  // Write tecplot footer (e.g. FE connectivity lists)
142  this->write_tecplot_zone_footer(outfile, nplot);
143  }
144  else
145  {
146  ELEMENT::output(outfile, nplot);
147  }
148  }
149 
150  // Call the underlying element further build and then pass forward the Output_Mortared_Status flag
152  {
153  ELEMENT::further_build();
155  }
156 
157 protected:
158  const double get_output_mortared_status() const
159  {
160  return Output_Mortared_Status;
161  }
162 private:
163  // When true output will output the mortared status of each node
165 };
166 
167 // When a face geometry is required, just return a face geometry of the underling element
168 template<class ELEMENT>
169 class FaceGeometry<ElementWithMortaringStatusAtNodes<ELEMENT>> : public virtual FaceGeometry<ELEMENT>
170 {
171 public:
172  FaceGeometry() : FaceGeometry<ELEMENT>() {}
173 };
174 
175 }//End namespace
176 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Definition: element_with_mortaring_status_at_nodes.h:29
bool Output_Mortared_Status
Definition: element_with_mortaring_status_at_nodes.h:164
void further_build()
Definition: element_with_mortaring_status_at_nodes.h:151
void get_interpolated_values(const unsigned &t, const Vector< double > &s, Vector< double > &values)
Definition: element_with_mortaring_status_at_nodes.h:107
void output(std::ostream &outfile, const unsigned &nplot)
Definition: element_with_mortaring_status_at_nodes.h:115
void set_mortared(const unsigned &n, const double &mortared_status=1.0)
Definition: element_with_mortaring_status_at_nodes.h:61
void pin_mortared_status_of_all_nodes()
Definition: element_with_mortaring_status_at_nodes.h:72
unsigned required_nvalue(const unsigned &n) const override
Definition: element_with_mortaring_status_at_nodes.h:43
void set_not_mortared(const unsigned &n, const double &mortared_status=0.0)
Definition: element_with_mortaring_status_at_nodes.h:65
void set_output_mortared_status()
Definition: element_with_mortaring_status_at_nodes.h:34
unsigned ncont_interpolated_values() const
Definition: element_with_mortaring_status_at_nodes.h:80
double get_interpolated_mortared_status(const Vector< double > &s)
Definition: element_with_mortaring_status_at_nodes.h:85
void set_do_not_output_mortared_status()
Definition: element_with_mortaring_status_at_nodes.h:38
double mortared_status(const unsigned &n) const
Definition: element_with_mortaring_status_at_nodes.h:54
void get_interpolated_values(const Vector< double > &s, Vector< double > &values)
Definition: element_with_mortaring_status_at_nodes.h:100
ElementWithMortaringStatusAtNodes()
Definition: element_with_mortaring_status_at_nodes.h:31
const double get_output_mortared_status() const
Definition: element_with_mortaring_status_at_nodes.h:158
unsigned mortared_dof_index(const unsigned &n) const
Definition: element_with_mortaring_status_at_nodes.h:48
FaceGeometry()
Definition: element_with_mortaring_status_at_nodes.h:172
Definition: elements.h:4998
Definition: shape.h:76
RealScalar s
Definition: level1_cplx_impl.h:130
squared absolute value
Definition: GlobalFunctions.h:87
void shape(const double &s, double *Psi)
Definition: shape.h:564
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
t
Definition: plotPSD.py:36
void output(std::ostream &outfile, const unsigned &nplot)
Overload output function.
Definition: overloaded_element_body.h:490