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