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-2022 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  //=======================================================================
57  //=======================================================================
58  template<class ELEMENT>
59  class FaceElementAsGeomObject : public virtual FaceGeometry<ELEMENT>,
60  public virtual FaceElement,
61  public virtual ElementWithExternalElement
62  {
63  public:
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 
92 
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 
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 
114  unsigned ngeom_data() const
115  {
116  return 0;
117  }
118 
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 
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()",
150  }
151 
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 
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  //============================================================================
180  //============================================================================
181  template<class ELEMENT>
183  {
184  public:
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(),
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(),
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
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Definition: face_element_as_geometric_object.h:183
int operator()(GeneralisedElement *const &element1_pt, GeneralisedElement *const &element2_pt)
The actual comparison operator.
Definition: face_element_as_geometric_object.h:186
Definition: nodes.h:86
Definition: element_with_external_element.h:56
void describe_local_dofs(std::ostream &out, const std::string &curr_string) const
Definition: element_with_external_element.cc:205
Definition: face_element_as_geometric_object.h:62
void describe_local_dofs(std::ostream &out, const std::string &current_string) const
Definition: face_element_as_geometric_object.h:160
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Override fill in contribution to jacobian, nothing should be done.
Definition: face_element_as_geometric_object.h:135
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.
Definition: face_element_as_geometric_object.h:168
unsigned ngeom_data() const
Definition: face_element_as_geometric_object.h:114
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Broken assignment operator.
Definition: face_element_as_geometric_object.h:104
FaceElementAsGeomObject(FiniteElement *const &element_pt, const int &face_index)
Definition: face_element_as_geometric_object.h:72
Data * geom_data_pt(const unsigned &j)
Definition: face_element_as_geometric_object.h:122
Definition: elements.h:4338
int & face_index()
Definition: elements.h:4626
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Definition: elements.h:4497
Definition: elements.h:4998
Definition: elements.h:1313
virtual void build_face_element(const int &face_index, FaceElement *face_element_pt)
Definition: elements.cc:5132
virtual void assign_all_generic_local_eqn_numbers(const bool &store_local_dof_pt)
Definition: elements.h:2164
unsigned dim() const
Definition: elements.h:2611
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
Definition: elements.h:2484
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
Definition: oomph_definitions.h:222
Definition: oomph_definitions.h:267
char char char int int * k
Definition: level2_impl.h:374
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
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
std::ofstream out("Result.txt")
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2