26 #ifndef CIRCLE_AS_GEN_ELEMENT_HEADER
27 #define CIRCLE_AS_GEN_ELEMENT_HEADER
55 class ElasticallySupportedRingElement :
public GeneralisedElement,
64 ElasticallySupportedRingElement(
const double& x_c,
const double& y_c,
66 GeneralCircle(x_c,y_c,r), K_stiff(1.0), Load_data_has_been_set(false)
74 Internal_geometric_data_index=add_internal_data(Geom_data_pt[0]);
79 internal_data_pt(Internal_geometric_data_index)->unpin(1);
88 virtual ~ElasticallySupportedRingElement()
98 void set_load_pt(Data* load_pt)
101 if (load_pt->nvalue()!=1)
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;
109 throw OomphLibError(error_stream.str(),
110 OOMPH_CURRENT_FUNCTION,
111 OOMPH_EXCEPTION_LOCATION);
119 External_load_index = add_external_data(load_pt);
122 Load_data_has_been_set=
true;
131 if (Load_data_has_been_set)
133 return external_data_pt(External_load_index)->value(0);
144 double& k_stiff() {
return K_stiff;}
152 internal_data_pt(Internal_geometric_data_index)->pin(1);
161 internal_data_pt(Internal_geometric_data_index)->unpin(1);
167 void get_residuals(Vector<double> &residuals)
170 residuals.initialise(0.0);
172 DenseMatrix<double> dummy(1);
174 fill_in_generic_residual_contribution(residuals,dummy,0);
179 void get_jacobian(Vector<double> &residuals,
180 DenseMatrix<double> &jacobian)
183 residuals.initialise(0.0);
185 jacobian.initialise(0.0);
187 fill_in_generic_residual_contribution(residuals,jacobian,1);
197 void fill_in_generic_residual_contribution(Vector<double> &residuals,
198 DenseMatrix<double> &jacobian,
202 unsigned n_dof = ndof();
204 if (n_dof==0)
return;
213 int local_eqn_number_for_yc =
214 internal_local_eqn(Internal_geometric_data_index,1);
218 residuals[local_eqn_number_for_yc]=load()-K_stiff*y_c();
225 jacobian(local_eqn_number_for_yc,local_eqn_number_for_yc) = -K_stiff;
235 int local_eqn_number_for_load =
236 external_local_eqn(External_load_index,0);
239 if (local_eqn_number_for_load<0)
242 "Load is pinned and yet n_dof=2?\n This is very fishy!\n",
243 OOMPH_CURRENT_FUNCTION,
244 OOMPH_EXCEPTION_LOCATION);
249 jacobian(local_eqn_number_for_yc,local_eqn_number_for_load) = 1.0;
262 unsigned External_load_index;
266 unsigned Internal_geometric_data_index;
269 bool Load_data_has_been_set;