circle_as_generalised_element.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-2024 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#ifndef CIRCLE_AS_GEN_ELEMENT_HEADER
27#define CIRCLE_AS_GEN_ELEMENT_HEADER
28
29#include "circle.h"
30
31
32namespace oomph
33{
34
35/// ///////////////////////////////////////////////////////////////////////
36/// ///////////////////////////////////////////////////////////////////////
37/// ///////////////////////////////////////////////////////////////////////
38
39
40//===========start_of_general_circle=========================================
41/// GeneralCircle "upgraded" to a GeneralisedElement: Circular
42/// ring whose position is given by
43/// \f[ x = X_c + R \cos(\zeta) \f]
44/// \f[ y = Y_c + R \sin(\zeta) \f]
45/// The ring's vertical position \f$ Y_c \f$ is
46/// determined by "pseudo elasticity":
47/// \f[
48/// 0 = f_{load} - Y_c \ k_{stiff}
49/// \f]
50/// This simulates the case where the centre of the ring is mounted on
51/// an elastic spring of stiffness \f$ k_{stiff} \f$ and loaded by
52/// the force \f$ f_{load}. \f$ The "load" is specified by the
53/// Data object \c load_pt().
54//=========================================================================
56 public GeneralCircle
57{
58
59public:
60
61 /// Constructor: Build ring from doubles that describe
62 /// the geometry: x and y positions of centre and the radius.
63 /// Initialise stiffness to 1.0. By default, no load is set.
64 ElasticallySupportedRingElement(const double& x_c, const double& y_c,
65 const double& r) :
66 GeneralCircle(x_c,y_c,r), K_stiff(1.0), Load_data_has_been_set(false)
67 {
68 // The geometric data is internal to the element -- we copy the pointers
69 // to the GeomObject's geometric data to the element's internal
70 // data to ensure that any unknown values of geometric data are
71 // given global equation numbers. The add_internal_data(...)
72 // function returns the index by which the added Data item
73 // is accessible from internal_data_pt(...).
75
76 // Geometric Data for the GeomObject has been set up (and pinned) in
77 // constructor for geometric object. Now free the y-position
78 // of the centre because we want to determine it as an unknown
80
81 // Change cleanup responsibilities: The GeomData will now be killed
82 // by the GeneralisedElement when it wipes its internal Data
83 Must_clean_up=false;
84 }
85
86
87 /// Destructor:
89 {
90 // The GeomObject's GeomData is mirrored in the element's
91 // Internal Data and therefore gets wiped in the
92 // destructor of GeneralisedElement --> No need to kill it here
93 }
94
95
96 /// Set pointer to Data object that specifies the "load"
97 /// on the ElasticallySupportedRingElement
99 {
100#ifdef PARANOID
101 if (load_pt->nvalue()!=1)
102 {
103 std::ostringstream error_stream;
104 error_stream << "The data object that stores the load on the "
105 << "ElasticallySupportedRingElement\n"
106 << "should only contain a single data value\n"
107 << "This one contains " << load_pt->nvalue() << std::endl;
108
109 throw OomphLibError(error_stream.str(),
112 }
113#endif
114
115 // Add load to the element's external data and store
116 // its index within that storage scheme: Following this assignment,
117 // the load Data is accessible from
118 // GeneralisedElement::external_data_pt(External_load_index)
120
121 // Load has now been set
123
124 } // end of set_load_pt(...)
125
126
127 /// "Load" acting on the ring
128 double load()
129 {
130 // Return the load if it has been set
132 {
133 return external_data_pt(External_load_index)->value(0);
134 }
135 // ...otherwise return zero load
136 else
137 {
138 return 0.0;
139 }
140 } // end of load()
141
142
143 /// Access function for the spring stiffness
144 double& k_stiff() {return K_stiff;}
145
146
147 /// Pin the vertical displacement
148 void pin_yc()
149 {
150 // Vertical position of centre is stored as value 1 in the
151 // element's one and only internal Data object.
153 }
154
155
156 /// Unpin the vertical displacement
157 void unpin_yc()
158 {
159 // Vertical position of centre is stored as value 1 in the
160 // element's one and only internal Data object.
162
163 } // end of unpin_yc()
164
165
166 /// Compute element residual vector (wrapper)
168 {
169 //Initialise residuals to zero
170 residuals.initialise(0.0);
171 //Create a dummy matrix
173 //Call the generic residuals function with flag set to 0
175 }
176
177
178 /// Compute element residual Vector and element Jacobian matrix (wrapper)
181 {
182 //Initialise residuals to zero
183 residuals.initialise(0.0);
184 //Initialise the jacobian matrix to zero
185 jacobian.initialise(0.0);
186 //Call the generic routine with the flag set to 1
188
189 } // end of get_jacobian(...)
190
191
192 protected:
193
194
195 /// Compute element residual Vector (only if flag=0) and also
196 /// the element Jacobian matrix (if flag=1)
199 unsigned flag)
200 {
201 //Find out how may dofs there are in the element
202 unsigned n_dof = ndof();
203 //If everything is pinned return straight away
204 if (n_dof==0) return;
205
206 // Pseudo-elastic force balance to determine the position of the
207 // ring's centre for a given load.
208
209 // What's the local equation number of the force balance equation
210 // [It's the equation that "determines" the value of the internal
211 // dof, y_c, which is stored as the second value of the one-and-only
212 // internal data object in this element]
215
216 // Add residual to appropriate entry in the element's residual
217 // vector:
219
220 // Work out Jacobian:
221 if (flag)
222 {
223 // Derivative of residual w.r.t. the internal dof, i.e. the vertical
224 // position of the ring's centre: d residual[0]/d y_c
226
227
228 // Derivative with respect to external dof, i.e. the applied
229 // load: d residual[0]/d load -- but only if the load is an unknown
230 if (n_dof==2)
231 {
232 // What's the local equation number of the load parameter?
233 // It's stored as the 0th value in the the element's
234 // one-and-only external data item:
237
238#ifdef PARANOID
240 {
241 throw OomphLibError(
242 "Load is pinned and yet n_dof=2?\n This is very fishy!\n",
245 }
246#endif
247
248 // Add entry into element Jacobian
250 }
251 }
252 } // end of get_residuals_generic(...)
253
254
255private:
256
257 /// Stiffness of the ring's "elastic" support
258 double K_stiff;
259
260 /// Index of the location of the load Data in the element's
261 /// array of external data
262 unsigned External_load_index;
263
264 /// Index of the location of the geometric Data in the element's
265 /// array of internal data
267
268 /// Flag to indicate that load data has been set
270
271};
272
273}
274
275#endif
void demo_fish_poisson(const string &directory_name)
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
Definition circle.h:34