42 _if_propagation (true) {
71 std::unique_ptr<MAST::FEBase> fe(
_elem.
init_fe(
true,
false));
73 const std::vector<Real>& JxW = fe->get_JxW();
74 const std::vector<libMesh::Point>& xyz = fe->get_xyz();
76 n_phi = fe->n_shape_functions(),
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);
95 std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
99 for (
unsigned int qp=0; qp<JxW.size(); qp++) {
105 _tau(*fe, qp, Bmat, dBmat, vel, tau);
112 for (
unsigned int j=0; j<dim; j++) {
114 dBmat[j].right_multiply(vec1_n1,
_sol);
115 flux += vel(j) * vec1_n1;
116 dBmat[j].left_multiply(mat1_n1n2, eye);
117 mat2_n1n2 += mat1_n1n2 * vel(j);
123 f += JxW[qp] * vec2_n2;
124 f += JxW[qp] * mat2_n1n2.transpose() * tau * flux;
127 for (
unsigned int j=0; j<dim; j++) {
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;
135 if (request_jacobian) {
137 for (
unsigned int j=0; j<dim; j++) {
140 jac += JxW[qp] * vel(j) * mat_n2n2;
143 dBmat[j].right_multiply_transpose(mat_n2n2, dBmat[j]);
144 jac += JxW[qp] * dc * mat_n2n2;
147 jac += JxW[qp] * mat2_n1n2.transpose() * tau * mat2_n1n2;
151 return request_jacobian;
166 std::unique_ptr<MAST::FEBase> fe(
_elem.
init_fe(
true,
false));
168 const std::vector<Real>& JxW = fe->get_JxW();
169 const std::vector<libMesh::Point>& xyz = fe->get_xyz();
171 n_phi = fe->n_shape_functions(),
175 eye = RealMatrixX::Identity(1, 1),
176 tau = RealMatrixX::Zero( 1, 1),
177 mat1_n1n2 = RealMatrixX::Zero( 1, n_phi),
178 mat2_n1n2 = RealMatrixX::Zero( 1, n_phi),
179 mat_n2n1 = RealMatrixX::Zero(n_phi, 1),
180 mat_n2n2 = RealMatrixX::Zero(n_phi, n_phi);
182 vec1_n1 = RealVectorX::Zero(1),
183 vec2_n2 = RealVectorX::Zero(n_phi),
184 flux = RealVectorX::Zero(1),
185 vel = RealVectorX::Zero(dim);
189 std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
193 for (
unsigned int qp=0; qp<JxW.size(); qp++) {
199 _tau(*fe, qp, Bmat, dBmat, vel, tau);
204 for (
unsigned int j=0; j<dim; j++) {
206 dBmat[j].left_multiply(mat1_n1n2, eye);
207 mat2_n1n2 += mat1_n1n2 * vel(j);
213 f += JxW[qp] * vec2_n2;
214 f += JxW[qp] * mat2_n1n2.transpose() * tau * vec1_n1;
216 if (request_jacobian) {
219 jac_xdot += JxW[qp] * mat_n2n2;
221 mat_n2n1 = mat2_n1n2.transpose()*tau;
223 jac_xdot += JxW[qp] * mat_n2n2;
227 return request_jacobian;
238 std::multimap<libMesh::boundary_id_type, MAST::BoundaryConditionBase*>& bc) {
240 libmesh_assert(
false);
253 std::multimap<libMesh::subdomain_id_type, MAST::BoundaryConditionBase*>& bc) {
255 libmesh_assert(
false);
266 std::multimap<libMesh::boundary_id_type, MAST::BoundaryConditionBase*>& bc) {
268 libmesh_assert(
false);
280 std::multimap<libMesh::subdomain_id_type, MAST::BoundaryConditionBase*>& bc) {
282 libmesh_assert(
false);
295 libmesh_assert(
false);
296 return request_jacobian;
307 libmesh_assert(
false);
308 return request_jacobian;
316 std::unique_ptr<MAST::FEBase> fe(
_elem.
init_fe(
true,
false));
318 const std::vector<Real>& JxW = fe->get_JxW();
323 phi = RealVectorX::Zero(1);
328 std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
332 for (
unsigned int qp=0; qp<JxW.size(); qp++) {
337 if (phi(0) > 0.) vol += JxW[qp];
347 std::unique_ptr<MAST::FEBase> fe(
_elem.
init_fe(
true,
false));
349 const std::vector<Real>& JxW = fe->get_JxW();
354 phi = RealVectorX::Zero(1);
361 std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
365 for (
unsigned int qp=0; qp<JxW.size(); qp++) {
370 per += 1./pi/d/(1.+pow(phi(0)/d, 2)) * JxW[qp];
380 std::unique_ptr<MAST::FEBase> fe(
_elem.
init_fe(
true,
false));
382 const std::vector<Real>& JxW = fe->get_JxW();
387 phi = RealVectorX::Zero(1),
388 dphidp = RealVectorX::Zero(1);
395 std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
399 for (
unsigned int qp=0; qp<JxW.size(); qp++) {
405 dper_dp -= 2.*phi(0)/pi/pow(d,3)/pow(1.+pow(phi(0)/d, 2),2) * dphidp(0) * JxW[qp];
419 const std::vector<Real>& JxW = fe->get_JxW();
424 phi = RealVectorX::Zero(1),
425 gradphi = RealVectorX::Zero(dim),
426 dphidp = RealVectorX::Zero(1),
427 vel = RealVectorX::Zero(dim);
433 std::vector<MAST::FEMOperatorMatrix> dBmat(dim);
437 for (
unsigned int qp=0; qp<JxW.size(); qp++) {
443 for (
unsigned int i=0; i<dim; i++) {
444 dBmat[i].right_multiply(phi,
_sol);
458 vn = dphidp(0) / gradphi.norm();
462 dvoldp += vn * JxW[qp];
472 const libMesh::Point& p,
475 const std::vector<MAST::FEMOperatorMatrix>& dBmat,
483 v = RealVectorX::Zero(1),
484 grad_phi = RealVectorX::Zero(dim);
487 for (
unsigned int i=0; i<dim; i++) {
489 dBmat[i].right_multiply(v,
_sol);
499 (*_phi_vel)(p, t, Vn);
500 vel = grad_phi * (-Vn/grad_phi.norm());
512 grad_phi_norm = grad_phi.norm();
514 source = ref_phi/pow(pow(ref_phi,2)+ tol*pow(grad_phi_norm,2), 0.5);
516 if (grad_phi_norm > tol)
517 vel = grad_phi * source/grad_phi.norm();
528 const std::vector<MAST::FEMOperatorMatrix>& dBmat,
532 const std::vector<std::vector<libMesh::RealVectorValue> >& dphi = fe.
get_dphi();
535 phi = RealVectorX::Zero(n_phi);
547 for (
unsigned int i_nd=0; i_nd<n_phi; i_nd++ ) {
549 nvec = dphi[i_nd][qp];
551 for (
unsigned int i_dim=0; i_dim<
_elem.
dim(); i_dim++)
552 val2 += nvec(i_dim) * vel(i_dim);
554 val1 += std::fabs(val2);
568 const unsigned int qp,
569 const std::vector<MAST::FEMOperatorMatrix>& dB_mat,
577 dphi = RealVectorX::Zero(dim),
578 vec1 = RealVectorX::Zero(1),
579 dflux = RealVectorX::Zero(1);
582 dxi_dX = RealMatrixX::Zero(dim, dim);
587 for (
unsigned int i=0; i<dim; i++) {
589 dB_mat[i].vector_mult(vec1,
_sol);
590 dflux(0) += vel(i) * vec1(0);
597 for (
unsigned int i=0; i<dim; i++) {
601 for (
unsigned int j=0; j<dim; j++)
602 vec1(0) += dxi_dX(i, j) * dphi(j);
605 val1 += pow(vec1.norm(), 2);
608 dc = 0.5*dflux.norm()/pow(val1, 0.5);
616 const unsigned int qp,
627 for (
unsigned int i_dim=0; i_dim<dim; i_dim++)
628 for (
unsigned int j_dim=0; j_dim<dim; j_dim++)
681 dxi_dX(i_dim, j_dim) = val;
692 std::vector<MAST::FEMOperatorMatrix>& dBmat) {
694 const std::vector<std::vector<Real> >& phi_fe = fe.
get_phi();
695 const std::vector<std::vector<libMesh::RealVectorValue> >& dphi = fe.
get_dphi();
697 const unsigned int n_phi = (
unsigned int)phi_fe.size();
700 phi = RealVectorX::Zero(n_phi);
704 for (
unsigned int i_nd=0; i_nd<n_phi; i_nd++ )
705 phi(i_nd) = phi_fe[i_nd][qp];
710 for (
unsigned int i_dim=0; i_dim<
_elem.
dim(); i_dim++) {
713 for (
unsigned int i_nd=0; i_nd<n_phi; i_nd++ )
714 phi(i_nd) = dphi[i_nd][qp](i_dim);
715 dBmat[i_dim].reinit(1, phi);
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)
virtual const std::vector< Real > & get_detadz() const
void vector_mult_transpose(T &res, const T &v) const
res = v^T * [this]
virtual const std::vector< Real > & get_dzetadx() const
const RealVectorX & sol(bool if_sens=false) const
const MAST::GeomElem & _elem
geometric element for which the computations are performed
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...
virtual const std::vector< Real > & get_dxidy() const
virtual const std::vector< Real > & get_dxidz() const
virtual const std::vector< Real > & get_detadx() const
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
void right_multiply(T &r, const T &m) const
[R] = [this] * [M]
Real perimeter()
Approximates the integral of the Dirac delta function to approximate the perimeter.
Real perimeter_sensitivity()
computes the partial derivative of the integral of the Dirac delta function using the solution and se...
RealVectorX _ref_sol
reference solution for reinitialization of the level set
virtual const std::vector< Real > & get_dzetady() const
Real volume_boundary_velocity_on_side(unsigned int s)
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 const std::vector< Real > & get_dzetadz() const
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
virtual ~LevelSetElementBase()
Matrix< Real, Dynamic, Dynamic > RealMatrixX
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 unsigned int n_shape_functions() const
virtual bool velocity_residual_sensitivity(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)
sensitivity of the damping force contribution to system residual
Matrix< Real, Dynamic, 1 > RealVectorX
RealVectorX _sol_sens
local solution sensitivity
virtual std::unique_ptr< MAST::FEBase > init_side_fe(unsigned int s, bool init_grads, int extra_quadrature_order=0) const
initializes the finite element shape function and quadrature object for the side with the order of qu...
RealVectorX _sol
local solution
virtual const std::vector< Real > & get_detady() const
virtual const std::vector< Real > & get_dxidx() const
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
virtual const std::vector< std::vector< libMesh::RealVectorValue > > & get_dphi() const
void right_multiply_transpose(T &r, const T &m) const
[R] = [this]^T * [M]
void left_multiply(T &r, const T &m) const
[R] = [M] * [this]
bool _if_propagation
this can operate in one of two modes: propagation of level set given Vn, or reinitialization of level...
virtual const std::vector< std::vector< Real > > & get_phi() const
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 ...
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...
const Real & _time
time for which system is being assembled
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
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
LevelSetElementBase(MAST::SystemInitialization &sys, MAST::AssemblyBase &assembly, const MAST::GeomElem &elem)
Constructor.
virtual bool internal_residual_sensitivity(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)
sensitivity of the internal force contribution to system residual
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
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 ...