MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
level_set_elem_base.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 // MAST includes
25 #include "base/parameter.h"
28 #include "base/nonlinear_system.h"
29 #include "base/assembly_base.h"
30 #include "mesh/fe_base.h"
31 #include "mesh/geom_elem.h"
34 
35 
38  const MAST::GeomElem& elem):
39 MAST::ElementBase(sys, elem),
40 _phi_vel (nullptr),
41 _if_propagation (true) {
42 
43 }
44 
45 
46 
48 
49 }
50 
51 
52 
53 void
56 
57  libmesh_assert(!_if_propagation);
58  _ref_sol = sol;
59 }
60 
61 
62 
63 bool
65  RealVectorX& f,
66  RealMatrixX& jac) {
67 
68  libmesh_assert(_phi_vel);
69 
70  std::unique_ptr<MAST::FEBase> fe(_elem.init_fe(true, false,
71  _system.system().extra_quadrature_order));
72 
73  const std::vector<Real>& JxW = fe->get_JxW();
74  const std::vector<libMesh::Point>& xyz = fe->get_xyz();
75  const unsigned int
76  n_phi = fe->n_shape_functions(),
77  dim = _elem.dim();
78 
80  eye = RealMatrixX::Identity(1, 1),
81  tau = RealMatrixX::Zero( 1, 1),
82  mat1_n1n2 = RealMatrixX::Zero( 1, n_phi),
83  mat2_n1n2 = RealMatrixX::Zero( 1, n_phi),
84  mat_n2n2 = RealMatrixX::Zero(n_phi, n_phi);
86  vec1_n1 = RealVectorX::Zero(1),
87  vec2_n1 = RealVectorX::Zero(1),
88  vec2_n2 = RealVectorX::Zero(n_phi),
89  flux = RealVectorX::Zero(1),
90  vel = RealVectorX::Zero(dim);
91  Real
92  dc = 0.,
93  source = 0.;
94 
95  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
97 
98 
99  for (unsigned int qp=0; qp<JxW.size(); qp++) {
100 
101  // initialize the Bmat operator for this term
102  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
103 
104  _velocity_and_source(qp, xyz[qp], _time, Bmat, dBmat, vel, source);
105  _tau(*fe, qp, Bmat, dBmat, vel, tau);
106  _dc_operator(*fe, qp, dBmat, vel, dc);
107 
108  // calculate the flux for each dimension and add its weighted
109  // component to the residual
110  flux.setZero();
111  mat2_n1n2.setZero();
112  for (unsigned int j=0; j<dim; j++) {
113 
114  dBmat[j].right_multiply(vec1_n1, _sol); // dphi_dx_j
115  flux += vel(j) * vec1_n1; // v_j dphi_dx_j
116  dBmat[j].left_multiply(mat1_n1n2, eye); // dBmat
117  mat2_n1n2 += mat1_n1n2 * vel(j); // dBmat V_j
118  }
119 
120  // add to the residual vector
121  flux(0) -= source; // V.grad(phi) - s
122  Bmat.vector_mult_transpose(vec2_n2, flux);
123  f += JxW[qp] * vec2_n2; // int_omega u (V.grad(phi)-s)
124  f += JxW[qp] * mat2_n1n2.transpose() * tau * flux; // int_omega V.grad(u) tau (V.grad(phi)-s)
125 
126  // discontinuity capturing
127  for (unsigned int j=0; j<dim; j++) {
128 
129  dBmat[j].vector_mult(vec1_n1, _sol);
130  dBmat[j].vector_mult_transpose(vec2_n2, vec1_n1);
131  f += JxW[qp] * dc * vec2_n2;
132  }
133 
134 
135  if (request_jacobian) {
136 
137  for (unsigned int j=0; j<dim; j++) {
138 
139  Bmat.right_multiply_transpose(mat_n2n2, dBmat[j]);
140  jac += JxW[qp] * vel(j) * mat_n2n2; // int_omega u V.grad(phi)
141 
142  // discontinuity capturing term
143  dBmat[j].right_multiply_transpose(mat_n2n2, dBmat[j]); // dB_i^T dc dB_i
144  jac += JxW[qp] * dc * mat_n2n2;
145  }
146 
147  jac += JxW[qp] * mat2_n1n2.transpose() * tau * mat2_n1n2; // int_omega V.grad(u) tau (V.grad(phi))
148  }
149  }
150 
151  return request_jacobian;
152 }
153 
154 
155 
156 
157 
158 bool
160  RealVectorX& f,
161  RealMatrixX& jac_xdot,
162  RealMatrixX& jac) {
163 
164  libmesh_assert(_phi_vel);
165 
166  std::unique_ptr<MAST::FEBase> fe(_elem.init_fe(true, false,
167  _system.system().extra_quadrature_order));
168 
169  const std::vector<Real>& JxW = fe->get_JxW();
170  const std::vector<libMesh::Point>& xyz = fe->get_xyz();
171  const unsigned int
172  n_phi = fe->n_shape_functions(),
173  dim = _elem.dim();
174 
176  eye = RealMatrixX::Identity(1, 1),
177  tau = RealMatrixX::Zero( 1, 1),
178  mat1_n1n2 = RealMatrixX::Zero( 1, n_phi),
179  mat2_n1n2 = RealMatrixX::Zero( 1, n_phi),
180  mat_n2n1 = RealMatrixX::Zero(n_phi, 1),
181  mat_n2n2 = RealMatrixX::Zero(n_phi, n_phi);
183  vec1_n1 = RealVectorX::Zero(1),
184  vec2_n2 = RealVectorX::Zero(n_phi),
185  flux = RealVectorX::Zero(1),
186  vel = RealVectorX::Zero(dim);
187  Real
188  source = 0.;
189 
190  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
192 
193 
194  for (unsigned int qp=0; qp<JxW.size(); qp++) {
195 
196  // initialize the Bmat operator for this term
197  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
198 
199  _velocity_and_source(qp, xyz[qp], _time, Bmat, dBmat, vel, source);
200  _tau(*fe, qp, Bmat, dBmat, vel, tau);
201 
202  // calculate the flux for each dimension and add its weighted
203  // component to the residual
204  mat2_n1n2.setZero();
205  for (unsigned int j=0; j<dim; j++) {
206 
207  dBmat[j].left_multiply(mat1_n1n2, eye); // dBmat
208  mat2_n1n2 += mat1_n1n2 * vel(j); // dBmat_j V_j
209  }
210 
211  // add to the residual vector
212  Bmat.right_multiply(vec1_n1, _vel); // dphi/dt
213  Bmat.vector_mult_transpose(vec2_n2, vec1_n1);
214  f += JxW[qp] * vec2_n2; // int_omega u dphi/dt
215  f += JxW[qp] * mat2_n1n2.transpose() * tau * vec1_n1; // int_omega V.grad(u) tau dphi/dt
216 
217  if (request_jacobian) {
218 
219  Bmat.right_multiply_transpose(mat_n2n2, Bmat);
220  jac_xdot += JxW[qp] * mat_n2n2; // int_omega u dphi/dt
221 
222  mat_n2n1 = mat2_n1n2.transpose()*tau;
223  Bmat.left_multiply(mat_n2n2, mat_n2n1);
224  jac_xdot += JxW[qp] * mat_n2n2; // int_omega V.grad(u) tau dphi/dt
225  }
226  }
227 
228  return request_jacobian;
229 }
230 
231 
232 
233 
234 bool
236 side_external_residual (bool request_jacobian,
237  RealVectorX& f,
238  RealMatrixX& jac,
239  std::multimap<libMesh::boundary_id_type, MAST::BoundaryConditionBase*>& bc) {
240 
241  libmesh_assert(false);
242  return false;
243 }
244 
245 
246 
247 
248 
249 bool
251 volume_external_residual (bool request_jacobian,
252  RealVectorX& f,
253  RealMatrixX& jac,
254  std::multimap<libMesh::subdomain_id_type, MAST::BoundaryConditionBase*>& bc) {
255 
256  libmesh_assert(false);
257  return false;
258 }
259 
260 
261 
262 bool
264 side_external_residual_sensitivity (bool request_jacobian,
265  RealVectorX& f,
266  RealMatrixX& jac,
267  std::multimap<libMesh::boundary_id_type, MAST::BoundaryConditionBase*>& bc) {
268 
269  libmesh_assert(false);
270  return false;
271 }
272 
273 
274 
275 
276 bool
279  RealVectorX& f,
280  RealMatrixX& jac,
281  std::multimap<libMesh::subdomain_id_type, MAST::BoundaryConditionBase*>& bc) {
282 
283  libmesh_assert(false);
284  return false;
285 }
286 
287 
288 
289 
290 bool
292 internal_residual_sensitivity (bool request_jacobian,
293  RealVectorX& f,
294  RealMatrixX& jac) {
295 
296  libmesh_assert(false); // should not get called
297  return request_jacobian;
298 }
299 
300 
301 
302 bool
304 velocity_residual_sensitivity (bool request_jacobian,
305  RealVectorX& f,
306  RealMatrixX& jac) {
307 
308  libmesh_assert(false); // should not get called.
309  return request_jacobian;
310 }
311 
312 
313 
314 Real
316 
317  std::unique_ptr<MAST::FEBase> fe(_elem.init_fe(true, false,
318  _system.system().extra_quadrature_order));
319 
320  const std::vector<Real>& JxW = fe->get_JxW();
321  const unsigned int
322  dim = _elem.dim();
323 
325  phi = RealVectorX::Zero(1);
326 
327  Real
328  vol = 0.;
329 
330  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
332 
333 
334  for (unsigned int qp=0; qp<JxW.size(); qp++) {
335 
336  // initialize the Bmat operator for this term
337  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
338  Bmat.right_multiply(phi, _sol);
339  if (phi(0) > 0.) vol += JxW[qp];
340  }
341 
342  return vol;
343 }
344 
345 
346 Real
348 
349  std::unique_ptr<MAST::FEBase> fe(_elem.init_fe(true, false,
350  _system.system().extra_quadrature_order));
351 
352  const std::vector<Real>& JxW = fe->get_JxW();
353  const unsigned int
354  dim = _elem.dim();
355 
357  phi = RealVectorX::Zero(1);
358 
359  Real
360  pi = acos(-1.),
361  heav = 0.,
362  vol = 0.;
363 
364  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
366 
367 
368  for (unsigned int qp=0; qp<JxW.size(); qp++) {
369 
370  // initialize the Bmat operator for this term
371  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
372  Bmat.right_multiply(phi, _sol);
373  vol += JxW[qp];
374  heav += .5 * (1. + 2./pi * atan(phi(0)/delta)) * JxW[qp];
375  }
376 
377  return heav/vol;
378 }
379 
380 
381 
382 Real
384 
385  std::unique_ptr<MAST::FEBase> fe(_elem.init_fe(true, false,
386  _system.system().extra_quadrature_order));
387 
388  const std::vector<Real>& JxW = fe->get_JxW();
389  const unsigned int
390  dim = _elem.dim();
391 
393  phi = RealVectorX::Zero(1),
394  dphidp = RealVectorX::Zero(1);
395 
396  Real
397  pi = acos(-1.),
398  heav = 0.,
399  vol = 0.;
400 
401  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
403 
404 
405  for (unsigned int qp=0; qp<JxW.size(); qp++) {
406 
407  // initialize the Bmat operator for this term
408  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
409  Bmat.right_multiply(phi, _sol);
410  Bmat.right_multiply(dphidp, _sol_sens);
411  vol += JxW[qp];
412  heav += 1./pi/delta/(1.+pow(phi(0)/delta, 2)) * dphidp(0) * JxW[qp];
413  }
414 
415  return heav/vol;
416 }
417 
418 
419 
420 Real
422 
423  std::unique_ptr<MAST::FEBase> fe(_elem.init_fe(true, false,
424  _system.system().extra_quadrature_order));
425 
426  const std::vector<Real>& JxW = fe->get_JxW();
427  const unsigned int
428  dim = _elem.dim();
429 
431  phi = RealVectorX::Zero(1);
432 
433  Real
434  pi = acos(-1.),
435  per = 0.;
436 
437  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
439 
440 
441  for (unsigned int qp=0; qp<JxW.size(); qp++) {
442 
443  // initialize the Bmat operator for this term
444  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
445  Bmat.right_multiply(phi, _sol);
446  per += 1./pi/d/(1.+pow(phi(0)/d, 2)) * JxW[qp];
447  }
448 
449  return per;
450 }
451 
452 
453 Real
455 
456  std::unique_ptr<MAST::FEBase> fe(_elem.init_fe(true, false,
457  _system.system().extra_quadrature_order));
458 
459  const std::vector<Real>& JxW = fe->get_JxW();
460  const unsigned int
461  dim = _elem.dim();
462 
464  phi = RealVectorX::Zero(1),
465  dphidp = RealVectorX::Zero(1);
466 
467  Real
468  pi = acos(-1.),
469  dper_dp = 0.;
470 
471  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
473 
474 
475  for (unsigned int qp=0; qp<JxW.size(); qp++) {
476 
477  // initialize the Bmat operator for this term
478  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
479  Bmat.right_multiply(phi, _sol);
480  Bmat.right_multiply(dphidp, _sol_sens);
481  dper_dp -= 2.*phi(0)/pi/pow(d,3)/pow(1.+pow(phi(0)/d, 2),2) * dphidp(0) * JxW[qp];
482  }
483 
484  return dper_dp;
485 }
486 
487 
488 
489 
490 Real
492 
493  std::unique_ptr<MAST::FEBase> fe(_elem.init_side_fe(s, true, false));
494 
495  const std::vector<Real>& JxW = fe->get_JxW();
496  const unsigned int
497  dim = _elem.dim();
498 
500  phi = RealVectorX::Zero(1),
501  gradphi = RealVectorX::Zero(dim),
502  dphidp = RealVectorX::Zero(1),
503  vel = RealVectorX::Zero(dim);
504 
505  Real
506  vn = 0.,
507  dvoldp = 0.;
508 
509  std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
511 
512 
513  for (unsigned int qp=0; qp<JxW.size(); qp++) {
514 
515  // initialize the Bmat operator for this term
516  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
517 
518  // first calculate gradient of phi
519  for (unsigned int i=0; i<dim; i++) {
520  dBmat[i].right_multiply(phi, _sol);
521  gradphi(i) = phi(0);
522  }
523 
524  // initialize the Bmat operator for this term
525  _initialize_fem_operators(qp, *fe, Bmat, dBmat);
526  Bmat.right_multiply(phi, _sol);
527  Bmat.right_multiply(dphidp, _sol_sens);
528 
529  // at boundary, phi(x) = 0
530  // so, dphi/dp + grad(phi) . V = 0
531  // dphi/dp + grad(phi) . (-grad(phi)/|grad(phi)| Vn) = 0 [since V = -grad(phi)/|grad(phi)| Vn]
532  // dphi/dp -(grad(phi) . grad(phi))/|grad(phi)| Vn = 0
533  // Vn = (dphi/dp) |grad(phi)| / |grad(phi)|^2 = (dphi/dp) / |grad(phi)|
534  vn = dphidp(0) / gradphi.norm();
535 
536  // vol = int_omega dOmega
537  // dvol/dp = int_Gamma Vn dGamma
538  dvoldp += vn * JxW[qp];
539  }
540 
541  return dvoldp;
542 }
543 
544 
545 
546 void
548  const libMesh::Point& p,
549  const Real t,
550  const MAST::FEMOperatorMatrix& Bmat,
551  const std::vector<MAST::FEMOperatorMatrix>& dBmat,
552  RealVectorX& vel,
553  Real& source) {
554 
555  const unsigned int
556  dim = _elem.dim();
557 
559  v = RealVectorX::Zero(1),
560  grad_phi = RealVectorX::Zero(dim);
561 
562  // first initialize grad(phi)
563  for (unsigned int i=0; i<dim; i++) {
564 
565  dBmat[i].right_multiply(v, _sol);
566  grad_phi(i) = v(0);
567  }
568 
569  if (_if_propagation) {
570 
571  // now, initialize the velocity vector
572  Real
573  Vn = 0.;
574 
575  (*_phi_vel)(p, t, Vn);
576  vel = grad_phi * (-Vn/grad_phi.norm());
577  source = 0.;
578  }
579  else {
580 
581  libmesh_assert_equal_to(_ref_sol.size(), _sol.size());
582 
583  Bmat.right_multiply(v, _ref_sol);
584 
585  Real
586  tol = 1.e-6,
587  ref_phi = v(0),
588  grad_phi_norm = grad_phi.norm();
589 
590  source = ref_phi/pow(pow(ref_phi,2)+ tol*pow(grad_phi_norm,2), 0.5);
591 
592  if (grad_phi_norm > tol)
593  vel = grad_phi * source/grad_phi.norm();
594  else
595  vel.setZero();
596  }
597 }
598 
599 
600 void
602  unsigned int qp,
603  const MAST::FEMOperatorMatrix& Bmat,
604  const std::vector<MAST::FEMOperatorMatrix>& dBmat,
605  const RealVectorX& vel,
606  RealMatrixX& tau) {
607 
608  const std::vector<std::vector<libMesh::RealVectorValue> >& dphi = fe.get_dphi();
609  const unsigned int n_phi = (unsigned int)fe.n_shape_functions();
611  phi = RealVectorX::Zero(n_phi);
612 
613  Real
614  tol = 1.e-6,
615  val1 = 0.,
616  val2 = 0.,
617  vel_l2 = vel.norm();
618 
619  libMesh::Point
620  nvec;
621 
622  if (vel_l2 > tol) {
623  for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ ) {
624 
625  nvec = dphi[i_nd][qp];
626  val2 = 0.;
627  for (unsigned int i_dim=0; i_dim<_elem.dim(); i_dim++)
628  val2 += nvec(i_dim) * vel(i_dim);
629 
630  val1 += std::fabs(val2);
631  }
632 
633  tau(0,0) = 1./val1;
634  }
635  else
636  tau(0,0) = 0.;
637 }
638 
639 
640 
641 
642 void
644  const unsigned int qp,
645  const std::vector<MAST::FEMOperatorMatrix>& dB_mat,
646  const RealVectorX& vel,
647  Real& dc) {
648 
649  unsigned int
650  dim = _elem.dim();
651 
653  dphi = RealVectorX::Zero(dim),
654  vec1 = RealVectorX::Zero(1),
655  dflux = RealVectorX::Zero(1);
656 
658  dxi_dX = RealMatrixX::Zero(dim, dim);
659 
660 
661  _calculate_dxidX(fe, qp, dxi_dX);
662 
663  for (unsigned int i=0; i<dim; i++) {
664 
665  dB_mat[i].vector_mult(vec1, _sol); // dphi/dx_i
666  dflux(0) += vel(i) * vec1(0); // V.grad(phi)
667  dphi(i) = vec1(0); // grad(phi)
668  }
669 
670  Real
671  val1 = 1.0e-6;
672 
673  for (unsigned int i=0; i<dim; i++) {
674 
675  vec1.setZero();
676 
677  for (unsigned int j=0; j<dim; j++)
678  vec1(0) += dxi_dX(i, j) * dphi(j);
679 
680  // calculate the value of denominator
681  val1 += pow(vec1.norm(), 2);
682  }
683 
684  dc = 0.5*dflux.norm()/pow(val1, 0.5);
685 }
686 
687 
688 
689 void
692  const unsigned int qp,
693  RealMatrixX& dxi_dX) {
694 
695 
696  // initialize dxi_dX and dX_dxi
697  unsigned int
698  dim = _elem.dim();
699  Real
700  val = 0.;
701  dxi_dX.setZero();
702 
703  for (unsigned int i_dim=0; i_dim<dim; i_dim++)
704  for (unsigned int j_dim=0; j_dim<dim; j_dim++)
705  {
706  switch (i_dim)
707  {
708  case 0:
709  {
710  switch (j_dim)
711  {
712  case 0:
713  val = fe.get_dxidx()[qp];
714  break;
715  case 1:
716  val = fe.get_dxidy()[qp];
717  break;
718  case 2:
719  val = fe.get_dxidz()[qp];
720  break;
721  }
722  }
723  break;
724  case 1:
725  {
726  switch (j_dim)
727  {
728  case 0:
729  val = fe.get_detadx()[qp];
730  break;
731  case 1:
732  val = fe.get_detady()[qp];
733  break;
734  case 2:
735  val = fe.get_detadz()[qp];
736  break;
737  }
738  }
739  break;
740  case 2:
741  {
742  switch (j_dim)
743  {
744  case 0:
745  val = fe.get_dzetadx()[qp];
746  break;
747  case 1:
748  val = fe.get_dzetady()[qp];
749  break;
750  case 2:
751  val = fe.get_dzetadz()[qp];
752  break;
753  }
754  }
755  break;
756  }
757  dxi_dX(i_dim, j_dim) = val;
758  }
759 }
760 
761 
762 
763 void
765 _initialize_fem_operators(const unsigned int qp,
766  const MAST::FEBase& fe,
768  std::vector<MAST::FEMOperatorMatrix>& dBmat) {
769 
770  const std::vector<std::vector<Real> >& phi_fe = fe.get_phi();
771  const std::vector<std::vector<libMesh::RealVectorValue> >& dphi = fe.get_dphi();
772 
773  const unsigned int n_phi = (unsigned int)phi_fe.size();
774 
776  phi = RealVectorX::Zero(n_phi);
777 
778  // shape function values
779  // N
780  for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ )
781  phi(i_nd) = phi_fe[i_nd][qp];
782 
783  Bmat.reinit(1, phi);
784 
785  // now set the shape function derivatives
786  for (unsigned int i_dim=0; i_dim<_elem.dim(); i_dim++) {
787 
788  phi.setZero();
789  for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ )
790  phi(i_nd) = dphi[i_nd][qp](i_dim);
791  dBmat[i_dim].reinit(1, phi); // dT/dx_i
792  }
793 
794 }
795 
796 
virtual bool internal_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)
internal force contribution to system residual
void _calculate_dxidX(const MAST::FEBase &fe, const unsigned int qp, RealMatrixX &dxi_dX)
MAST::NonlinearSystem & system()
virtual const std::vector< Real > & get_dxidy() const
Definition: fe_base.cpp:279
virtual const std::vector< Real > & get_dzetadz() const
Definition: fe_base.cpp:335
const MAST::GeomElem & _elem
geometric element for which the computations are performed
Definition: elem_base.h:205
virtual const std::vector< Real > & get_dxidz() const
Definition: fe_base.cpp:287
const MAST::FieldFunction< Real > * _phi_vel
element property
void reinit(unsigned int n_interpolated_vars, unsigned int n_discrete_vars, unsigned int n_discrete_dofs_per_var)
this initializes the operator for number of rows and variables, assuming that all variables has the s...
bool volume_external_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac, std::multimap< libMesh::subdomain_id_type, MAST::BoundaryConditionBase *> &bc)
volume external force contribution to system residual
const RealVectorX & sol(bool if_sens=false) const
Definition: elem_base.cpp:51
virtual const std::vector< Real > & get_detadz() const
Definition: fe_base.cpp:311
LevelSetElementBase(MAST::SystemInitialization &sys, const MAST::GeomElem &elem)
Constructor.
virtual const std::vector< Real > & get_dzetady() const
Definition: fe_base.cpp:327
virtual bool velocity_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac_xdot, RealMatrixX &jac)
inertial force contribution to system residual
void _tau(const MAST::FEBase &fe, unsigned int qp, const MAST::FEMOperatorMatrix &Bmat, const std::vector< MAST::FEMOperatorMatrix > &dBmat, const RealVectorX &vel, RealMatrixX &tau)
initializes the tau operator
RealVectorX _vel
local velocity
Definition: elem_base.h:260
virtual unsigned int n_shape_functions() const
Definition: fe_base.cpp:239
libMesh::Real Real
RealVectorX _ref_sol
reference solution for reinitialization of the level set
Real volume_boundary_velocity_on_side(unsigned int s)
MAST::SystemInitialization & _system
SystemInitialization object associated with this element.
Definition: elem_base.h:200
virtual const std::vector< std::vector< libMesh::RealVectorValue > > & get_dphi() const
Definition: fe_base.cpp:255
virtual const std::vector< std::vector< Real > > & get_phi() const
Definition: fe_base.cpp:247
void set_reference_solution_for_initialization(const RealVectorX &sol)
For reinitialization to , the solution before initialization is used to calculate the source and velo...
virtual std::unique_ptr< MAST::FEBase > init_fe(bool init_grads, bool init_second_order_derivative, int extra_quadrature_order=0) const
initializes the finite element shape function and quadrature object with the order of quadrature rule...
Definition: geom_elem.cpp:148
bool volume_external_residual_sensitivity(bool request_jacobian, RealVectorX &f, RealMatrixX &jac, std::multimap< libMesh::subdomain_id_type, MAST::BoundaryConditionBase *> &bc)
sensitivity of the volume external force contribution to system residual
Matrix< Real, Dynamic, Dynamic > RealMatrixX
void right_multiply(T &r, const T &m) const
[R] = [this] * [M]
virtual bool velocity_residual_sensitivity(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)
sensitivity of the damping force contribution to system residual
void vector_mult_transpose(T &res, const T &v) const
res = v^T * [this]
Matrix< Real, Dynamic, 1 > RealVectorX
RealVectorX _sol_sens
local solution sensitivity
Definition: elem_base.h:231
void right_multiply_transpose(T &r, const T &m) const
[R] = [this]^T * [M]
RealVectorX _sol
local solution
Definition: elem_base.h:225
Real perimeter(Real delta=0.1)
Approximates the integral of the Dirac delta function to approximate the perimeter.
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
Definition: geom_elem.h:59
unsigned int dim() const
Definition: geom_elem.cpp:91
virtual const std::vector< Real > & get_dzetadx() const
Definition: fe_base.cpp:319
Real homogenized_volume_fraction(Real delta=0.1)
Approximates the volume fraction of the element based on integration of approximated Heaviside functi...
bool side_external_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac, std::multimap< libMesh::boundary_id_type, MAST::BoundaryConditionBase *> &bc)
side external force contribution to system residual
virtual std::unique_ptr< MAST::FEBase > init_side_fe(unsigned int s, bool init_grads, bool init_second_order_derivative, int extra_quadrature_order=0) const
initializes the finite element shape function and quadrature object for the side with the order of qu...
Definition: geom_elem.cpp:165
bool _if_propagation
this can operate in one of two modes: propagation of level set given Vn, or reinitialization of level...
void _initialize_fem_operators(const unsigned int qp, const MAST::FEBase &fe, MAST::FEMOperatorMatrix &Bmat, std::vector< MAST::FEMOperatorMatrix > &dBmat)
When mass = false, initializes the FEM operator matrix to the shape functions as ...
#define pi
virtual const std::vector< Real > & get_detady() const
Definition: fe_base.cpp:303
void left_multiply(T &r, const T &m) const
[R] = [M] * [this]
virtual const std::vector< Real > & get_detadx() const
Definition: fe_base.cpp:295
Real homogenized_volume_fraction_sensitivity(Real delta=0.1)
Sensitivity of the homogenized volume fraction for the specified level set value and its sensitivity...
const Real & _time
time for which system is being assembled
Definition: elem_base.h:219
bool side_external_residual_sensitivity(bool request_jacobian, RealVectorX &f, RealMatrixX &jac, std::multimap< libMesh::boundary_id_type, MAST::BoundaryConditionBase *> &bc)
sensitivity of the side external force contribution to system residual
virtual const std::vector< Real > & get_dxidx() const
Definition: fe_base.cpp:271
void _velocity_and_source(const unsigned int qp, const libMesh::Point &p, const Real t, const MAST::FEMOperatorMatrix &Bmat, const std::vector< MAST::FEMOperatorMatrix > &dBmat, RealVectorX &vel, Real &source)
calculates the velocity at the quadrature point
Real perimeter_sensitivity(Real delta=0.1)
computes the partial derivative of the integral of the Dirac delta function using the solution and se...
virtual bool internal_residual_sensitivity(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)
sensitivity of the internal force contribution to system residual
void _dc_operator(const MAST::FEBase &fe, const unsigned int qp, const std::vector< MAST::FEMOperatorMatrix > &dB_mat, const RealVectorX &vel, Real &dc)
This is the base class for elements that implement calculation of finite element quantities over the ...
Definition: elem_base.h:72