26 #ifndef SCALECOUPLEDELEMENT_H
27 #define SCALECOUPLEDELEMENT_H
36 template<
class ELEMENT>
102 DenseMatrix<double> &jacobian,
103 const unsigned& flag)
override
107 const unsigned DIM = this->dim();
110 if (this->Solid_ic_pt!=0)
112 this->fill_in_residuals_for_solid_ic(residuals);
117 const unsigned n_node = this->nnode();
120 const unsigned n_position_type = this->nnodal_position_type();
123 Shape psi(n_node,n_position_type);
124 DShape dpsidxi(n_node,n_position_type,DIM);
127 const unsigned n_intpt = this->integral_pt()->nweight();
130 Vector<double> s(DIM);
133 double lambda_sq = this->lambda_sq();
136 double time_factor=0.0;
139 time_factor=this->node_pt(0)->position_time_stepper_pt()->weight(2,0);
146 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
149 for(
unsigned i=0;
i<DIM;++
i) {s[
i] = this->integral_pt()->knot(ipt,
i);}
152 double w = this->integral_pt()->weight(ipt);
155 double J = this->dshape_lagrangian_at_knot(ipt,psi,dpsidxi);
158 double coupling_w = 0;
160 for (
unsigned l = 0; l < n_node; l++) {
161 double psi_ = psi(l);
168 DenseMatrix<double> interpolated_G(DIM);
171 Vector<double> accel(DIM);
174 for(
unsigned i=0;
i<DIM;
i++)
178 for(
unsigned j=0;j<DIM;j++)
180 interpolated_G(
i,j) = 0.0;
185 Vector<double> interpolated_xi(DIM,0.0);
188 for(
unsigned l=0;l<n_node;l++)
191 for(
unsigned k=0;k<n_position_type;k++)
193 double psi_ = psi(l,k);
195 for(
unsigned i=0;
i<DIM;
i++)
198 interpolated_xi[
i] += this->lagrangian_position_gen(l,k,
i)*psi_;
201 if ((lambda_sq>0.0)&&(this->Unsteady))
203 accel[
i] += this->dnodal_position_gen_dt(2,l,k,
i)*psi_;
207 for(
unsigned j=0;j<DIM;j++)
209 interpolated_G(j,
i) +=
210 this->nodal_position_gen(l,k,
i)*dpsidxi(l,k,j);
218 this->get_isotropic_growth(ipt,s,interpolated_xi,
gamma);
222 Vector<double> b(DIM);
223 this->body_force(interpolated_xi,b);
228 double diag_entry=pow(
gamma,2.0/
double(DIM));
229 DenseMatrix<double> g(DIM);
230 for(
unsigned i=0;
i<DIM;
i++)
232 for(
unsigned j=0;j<DIM;j++)
234 if(
i==j) {g(
i,j) = diag_entry;}
241 double W =
gamma*w*(1.0-coupling_w)*J;
244 DenseMatrix<double> G(DIM);
247 for(
unsigned i=0;
i<DIM;
i++)
250 for(
unsigned j=
i;j<DIM;j++)
255 for(
unsigned k=0;k<DIM;k++)
257 G(
i,j) += interpolated_G(
i,k)*interpolated_G(j,k);
261 for(
unsigned j=0;j<
i;j++)
268 DenseMatrix<double> sigma(DIM);
269 ELEMENT::get_stress(g,G,sigma);
272 for(
unsigned i=0;
i<DIM;
i++)
274 for(
unsigned j=0;j<DIM;j++)
276 sigma(
i,j) += this->prestress(
i,j,interpolated_xi);
284 RankFourTensor<double> d_stress_dG(DIM,DIM,DIM,DIM,0.0);
286 RankFiveTensor<double> d_G_dX(n_node,n_position_type,DIM,DIM,DIM,0.0);
296 for (
unsigned ll=0;ll<n_node;ll++)
298 for (
unsigned kk=0;kk<n_position_type;kk++)
300 for (
unsigned ii=0;ii<DIM;ii++)
302 for (
unsigned aa=0;aa<DIM;aa++)
304 for (
unsigned bb=aa;bb<DIM;bb++)
306 d_G_dX(ll,kk,ii,aa,bb)=
307 interpolated_G(aa,ii)*dpsidxi(ll,kk,bb)+
308 interpolated_G(bb,ii)*dpsidxi(ll,kk,aa);
317 this->get_d_stress_dG_upper(g,G,sigma,d_stress_dG);
323 for(
unsigned l=0;l<n_node;l++)
326 for(
unsigned k=0;k<n_position_type;k++)
329 const unsigned offset5=dpsidxi.offset(l ,k);
332 for(
unsigned i=0;
i<DIM;
i++)
335 local_eqn = this->position_local_eqn(l,k,
i);
344 sum+=(lambda_sq*accel[
i]-b[
i])*psi(l,k);
347 for(
unsigned a=0;a<DIM;a++)
349 unsigned count=offset5;
350 for(
unsigned b=0;b<DIM;b++)
353 sum+=sigma(a,b)*interpolated_G(a,
i)*
354 dpsidxi.raw_direct_access(count);
358 residuals[local_eqn] += W*sum;
364 const unsigned offset1=d_G_dX.offset( l, k,
i);
367 for(
unsigned ll=0;ll<n_node;ll++)
370 for(
unsigned kk=0;kk<n_position_type;kk++)
373 for(
unsigned ii=0;ii<DIM;ii++)
376 int local_unknown = this->position_local_eqn(ll,kk,ii);
379 if(local_unknown >= 0)
382 const unsigned offset2=d_G_dX.offset( ll, kk, ii);
383 const unsigned offset4=dpsidxi.offset(ll, kk);
388 unsigned count1=offset1;
389 for(
unsigned a=0;a<DIM;a++)
394 for(
unsigned b=a;b<DIM;b++)
396 double factor=d_G_dX.raw_direct_access(count1);
397 if (a==b) factor*=0.5;
400 unsigned offset3=d_stress_dG.offset(a,b);
401 unsigned count2=offset2;
402 unsigned count3=offset3;
404 for(
unsigned aa=0;aa<DIM;aa++)
412 for(
unsigned bb=aa;bb<DIM;bb++)
415 d_stress_dG.raw_direct_access(count3)*
416 d_G_dX.raw_direct_access(count2);
428 jacobian(local_eqn,local_unknown)+=sum*W;
432 if((
i==ii) && (local_unknown >= local_eqn))
438 sum+=lambda_sq*time_factor*psi(ll,kk)*psi(l,k);
441 unsigned count4=offset4;
442 for(
unsigned a=0;a<DIM;a++)
446 dpsidxi.raw_direct_access(count4);
449 unsigned count5=offset5;
450 for(
unsigned b=0;b<DIM;b++)
452 sum+=sigma(a,b)*factor*
453 dpsidxi.raw_direct_access(count5);
458 jacobian(local_eqn,local_unknown) += sum*W;
460 if(local_eqn != local_unknown)
462 jacobian(local_unknown,local_eqn) += sum*W;
482 DenseMatrix<double> &jacobian,
483 const unsigned& flag)
489 const unsigned n_node = this->nnode();
490 const unsigned DIM = this->dim();
493 unsigned n_position_type = this->nnodal_position_type();
499 for(
unsigned l=0;l<n_node;l++)
502 for(
unsigned k=0; k<n_position_type; k++)
505 for(
unsigned i=0;
i<DIM;
i++)
508 int local_eqn = this->position_local_eqn(l,k,
i);
522 for(
unsigned ll=0;ll<n_node;ll++)
525 for(
unsigned kk=0;kk<n_position_type;kk++)
528 for(
unsigned ii=0;ii<DIM;ii++)
531 int local_unknown = this->position_local_eqn(ll,kk,ii);
533 if ((local_unknown >= 0) && (
i==ii) && (local_unknown >= local_eqn))
537 if(local_eqn != local_unknown)
568 template<
class ELEMENT>
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
Wrapper class for solid elements to be coupled with discrete solid particles on the surfaces.
Definition: ScaleCoupledElement.h:37
void set_coupling_jacobian(Vector< Vector< double >> &jacobian)
Sets the coupling residual.
Definition: ScaleCoupledElement.h:62
void add_internal_coupling_forces_to_residuals(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Add the point source contribution to the residual vector.
Definition: ScaleCoupledElement.h:481
double get_coupling_weight(const unsigned &n)
Sets the coupling weight.
Definition: ScaleCoupledElement.h:72
Vector< Vector< double > > coupling_jacobian
Contribution of coupling to jacobian (jacobian(local_eqn,local_unknown) += coupling_jacobian[node0][n...
Definition: ScaleCoupledElement.h:560
void clear_coupling_residual()
Empties the coupling residual.
Definition: ScaleCoupledElement.h:41
void fill_in_contribution_to_residuals(Vector< double > &residuals) override
Adds the elements contribution to its residual vector (wrapper)
Definition: ScaleCoupledElement.h:77
void set_coupling_weight(Vector< double > &weight)
Sets the coupling weight.
Definition: ScaleCoupledElement.h:67
Vector< Vector< double > > coupling_residual
Contribution of coupling to residual (residuals[local_eqn] += coupling_residual[node][dim];)
Definition: ScaleCoupledElement.h:555
void set_coupling_residual(Vector< Vector< double >> &residual)
Sets the coupling residual.
Definition: ScaleCoupledElement.h:46
void fill_in_generic_contribution_to_residuals_pvd(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag) override
\TW I think this just addes the coupling weight
Definition: ScaleCoupledElement.h:101
double get_coupling_residual(const unsigned &n, const unsigned &d)
Returns the coupling residual.
Definition: ScaleCoupledElement.h:51
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian) override
Add the elements contribution to its residual vector and Jacobian matrix (wrapper)
Definition: ScaleCoupledElement.h:89
Vector< double > coupling_weight
Nodal coupling weight (interpolated to compute coupling weight at integration points)
Definition: ScaleCoupledElement.h:563
void clear_coupling_jacobian()
Empties the coupling Jacobian.
Definition: ScaleCoupledElement.h:57
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble gamma(Mdouble gamma_in)
This is the gamma function returns the true value for the half integer value.
Definition: ExtendedMath.cc:137
Definition: AnisotropicHookean.h:31