face_element_as_geometric_object.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2023 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 // Header file for a class that is used to extract the faces of bulk
27 // elements and represent them as geometric objects, primarily for use
28 // in FSI problems
29 
30 // Include guards to prevent multiple inclusion of the header
31 #ifndef OOMPH_FACE_ELEMENT_AS_GEOMETRIC_OBJECT_HEADER
32 #define OOMPH_FACE_ELEMENT_AS_GEOMETRIC_OBJECT_HEADER
33 
34 // Config header generated by autoconfig
35 #ifdef HAVE_CONFIG_H
36 #include <oomph-lib-config.h>
37 #endif
38 
39 #include <algorithm>
40 
41 // Include the geometric object header file
42 #include "geom_objects.h"
43 #include "shape.h"
44 #include "multi_domain.h"
45 
46 namespace oomph
47 {
48  //=======================================================================
49  /// Class that is used to create FaceElement from bulk elements and to
50  /// provide these FaceElement with a geometric object representation.
51  /// The local coordinates of the FaceElements are used as the intrinisic
52  /// coordinates for its GeomObject representation.
53  ///
54  /// These elements are used primarily to set up the interaction terms
55  /// in FSI problems and are expected to be created from meshes so
56  /// that they lie on a particular boundary of the mesh.
57  //=======================================================================
58  template<class ELEMENT>
59  class FaceElementAsGeomObject : public virtual FaceGeometry<ELEMENT>,
60  public virtual FaceElement,
61  public virtual ElementWithExternalElement
62  {
63  public:
64  /// Constructor which takes a pointer to a "bulk" element,
65  /// to which this element is attached. The face index, indicates
66  /// the face (of the bulk element) that is to be constructed.
67  /// Note that this element tends to be constructed
68  /// by the doubly templated Mesh::build_face_mesh() and therefore
69  /// has to have the same interface as the the generic FaceElement
70  /// constructor. Hence the boundary number (within the mesh) on which this
71  /// element is located must be setup afterwards!
73  const int& face_index)
74  : FaceGeometry<ELEMENT>(),
75  FaceElement(),
76  // The geometric object has an intrinsic dimension one less than
77  // the "bulk" element, but the actual dimension of the problem remains
78  // the same
79  // GeomObject(element_pt->dim()-1,element_pt->nodal_dimension()),
81  {
82  // Attach the geometrical information to the element. N.B. This function
83  // also assigns nbulk_value from the required_nvalue of the bulk element
84  element_pt->build_face_element(face_index, this);
85  GeomObject::set_nlagrangian_and_ndim(element_pt->dim() - 1,
86  element_pt->nodal_dimension());
87  }
88 
89 
90  /// Broken copy constructor
92 
93  /// Broken assignment operator
94  // Commented out broken assignment operator because this can lead to a
95  // conflict warning when used in the virtual inheritence hierarchy.
96  // Essentially the compiler doesn't realise that two separate
97  // implementations of the broken function are the same and so, quite
98  // rightly, it shouts.
99  /*void operator=(const FaceElementAsGeomObject&) = delete;*/
100 
101  /// The "global" intrinsic coordinate of the element when
102  /// viewed as part of a geometric object should be given by
103  /// the FaceElement representation, by default
104  double zeta_nodal(const unsigned& n,
105  const unsigned& k,
106  const unsigned& i) const
107  {
108  return FaceElement::zeta_nodal(n, k, i);
109  }
110 
111 
112  /// How many items of Data does the shape of the object depend on?
113  /// None! We're dealing with a pure geometric FiniteElement!
114  unsigned ngeom_data() const
115  {
116  return 0;
117  }
118 
119  /// Return pointer to the j-th Data item that the object's
120  /// shape depends on. Object doesn't depend on any geom Data
121  /// so we die if this gets called.
122  Data* geom_data_pt(const unsigned& j)
123  {
124  std::ostringstream error_message;
125  error_message
126  << "FaceElementAsGeomObject::geom_data_pt() is deliberately broken\n"
127  << "as it does not depend on any geometric Data" << std::endl;
128  throw OomphLibError(
129  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
130  // Dummy return
131  return 0;
132  }
133 
134  /// Override fill in contribution to jacobian, nothing should be done
136  DenseMatrix<double>& jacobian)
137  {
138  std::ostringstream warn_message;
139  warn_message << "Warning: You have just called the empty function \n"
140  << "fill_in_contribution_to_jacobian() for a "
141  "FaceElementAsGeometricObject.\n"
142  << "These Elements should only be used to setup "
143  "interactions, so should\n"
144  << "not be included in any jacobian calculations\n";
145 
147  warn_message.str(),
148  "FaceElementAsGeometricObject::fill_in_contribution_to_jacobian()",
149  OOMPH_EXCEPTION_LOCATION);
150  }
151 
152  /// Function to describe the local dofs of the element. The ostream
153  /// specifies the output stream to which the description
154  /// is written; the string stores the currently
155  /// assembled output that is ultimately written to the
156  /// output stream by Data::describe_dofs(...); it is typically
157  /// built up incrementally as we descend through the
158  /// call hierarchy of this function when called from
159  /// Problem::describe_dofs(...)
160  void describe_local_dofs(std::ostream& out,
161  const std::string& current_string) const
162  {
163  // Call the ElementWithExternalElement's describe function
165  }
166 
167  /// Unique final overrider needed for assign_all_generic_local_eqn_numbers
168  void assign_all_generic_local_eqn_numbers(const bool& store_local_dof_pt)
169  {
170  // Call the ElementWithExternalElement's assign function
172  store_local_dof_pt);
173  }
174  };
175 
176 
177  //============================================================================
178  /// A class to do comparison of the elements by lexicographic
179  /// ordering, based on the boundary coordinates at the element's first node.
180  //============================================================================
181  template<class ELEMENT>
183  {
184  public:
185  /// The actual comparison operator
186  int operator()(GeneralisedElement* const& element1_pt,
187  GeneralisedElement* const& element2_pt)
188  {
189  // OK Dynamic cast the elements
190  FaceElementAsGeomObject<ELEMENT>* cast_element1_pt =
191  dynamic_cast<FaceElementAsGeomObject<ELEMENT>*>(element1_pt);
192  FaceElementAsGeomObject<ELEMENT>* cast_element2_pt =
193  dynamic_cast<FaceElementAsGeomObject<ELEMENT>*>(element2_pt);
194 
195 #ifdef PARANOID
196  if (cast_element1_pt == 0)
197  {
198  std::ostringstream error_message;
199  error_message
200  << "Failed to cast element1_pt to a FaceElementAsGeomObject"
201  << std::endl;
202  throw OomphLibError(error_message.str(),
203  OOMPH_CURRENT_FUNCTION,
204  OOMPH_EXCEPTION_LOCATION);
205  }
206 
207  if (cast_element2_pt == 0)
208  {
209  std::ostringstream error_message;
210  error_message
211  << "Failed to cast element2_pt to a FaceElementAsGeomObject"
212  << std::endl;
213  throw OomphLibError(error_message.str(),
214  OOMPH_CURRENT_FUNCTION,
215  OOMPH_EXCEPTION_LOCATION);
216  }
217 #endif
218 
219 
220  // Warning that this still needs to be generalised to higher
221  // dimensions (don't want to implement it until I can test it
222  // -- at the moment, the ordering isn't particularly important
223  // anyway...
224  // if (cast_element1_pt->dim()!=1)
225  // {
226  // std::ostringstream warn_message;
227  // warn_message
228  // << "Warning: Ordering of elements is currently based on their
229  // \n"
230  // << "zero-th surface coordinate. This may not be appropriate
231  // for\n"
232  // << cast_element1_pt->dim() << "-dimensional elements. \n";
233  // OomphLibWarning(warn_message.str(),
234  // "CompareBoundaryCoordinate::()",
235  // OOMPH_EXCEPTION_LOCATION);
236  // }
237 
238 
239  return cast_element1_pt->zeta_nodal(0, 0, 0) <
240  cast_element2_pt->zeta_nodal(0, 0, 0);
241  }
242  };
243 
244 
245 } // namespace oomph
246 
247 #endif
cstr elem_len * i
Definition: cfortran.h:603
A class to do comparison of the elements by lexicographic ordering, based on the boundary coordinates...
int operator()(GeneralisedElement *const &element1_pt, GeneralisedElement *const &element2_pt)
The actual comparison operator.
A class that represents a collection of data; each Data object may contain many different individual ...
Definition: nodes.h:86
This is a base class for all elements that require external sources (e.g. FSI, multi-domain problems ...
void describe_local_dofs(std::ostream &out, const std::string &curr_string) const
Function to describe the local dofs of the element. The ostream specifies the output stream to which ...
Class that is used to create FaceElement from bulk elements and to provide these FaceElement with a g...
void describe_local_dofs(std::ostream &out, const std::string &current_string) const
Function to describe the local dofs of the element. The ostream specifies the output stream to which ...
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Override fill in contribution to jacobian, nothing should be done.
FaceElementAsGeomObject(const FaceElementAsGeomObject &)=delete
Broken copy constructor.
void assign_all_generic_local_eqn_numbers(const bool &store_local_dof_pt)
Unique final overrider needed for assign_all_generic_local_eqn_numbers.
unsigned ngeom_data() const
How many items of Data does the shape of the object depend on? None! We're dealing with a pure geomet...
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Broken assignment operator.
FaceElementAsGeomObject(FiniteElement *const &element_pt, const int &face_index)
Constructor which takes a pointer to a "bulk" element, to which this element is attached....
Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on. Object doesn't depend on any...
FaceElements are elements that coincide with the faces of higher-dimensional "bulk" elements....
Definition: elements.h:4338
int & face_index()
Index of the face (a number that uniquely identifies the face in the element)
Definition: elements.h:4626
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
In a FaceElement, the "global" intrinsic coordinate of the element along the boundary,...
Definition: elements.h:4497
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
Definition: elements.h:4998
A general Finite Element class.
Definition: elements.h:1313
virtual void assign_all_generic_local_eqn_numbers(const bool &store_local_dof_pt)
Overloaded version of the calculation of the local equation numbers. If the boolean argument is true ...
Definition: elements.h:2164
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
Definition: elements.h:2611
virtual void build_face_element(const int &face_index, FaceElement *face_element_pt)
Function for building a lower dimensional FaceElement on the specified face of the FiniteElement....
Definition: elements.cc:5132
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
Definition: elements.h:2484
A Generalised Element class.
Definition: elements.h:73
void set_nlagrangian_and_ndim(const unsigned &n_lagrangian, const unsigned &n_dim)
Set # of Lagrangian and Eulerian coordinates.
Definition: geom_objects.h:183
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...