29 #ifndef OOMPH_DISCONTINUOUS_GALERKIN_SPACETIME_FLUID_TRACTION_ELEMENTS_HEADER
30 #define OOMPH_DISCONTINUOUS_GALERKIN_SPACETIME_FLUID_TRACTION_ELEMENTS_HEADER
34 #include <oomph-lib-config.h>
50 template<
class ELEMENT>
51 class NavierStokesSpaceTimeTractionElement
52 :
public virtual FaceGeometry<ELEMENT>,
53 public virtual FaceElement
58 const Vector<double>& x,
59 const Vector<double>& n,
60 Vector<double>& result);
68 const bool& called_from_refineable_constructor =
false)
78 if (!called_from_refineable_constructor)
81 if (element_pt->
dim() == 3)
94 std::ostringstream error_message_stream;
98 <<
"This flux element will not work correctly "
99 <<
"if nodes are hanging" << std::endl;
103 OOMPH_CURRENT_FUNCTION,
104 OOMPH_EXCEPTION_LOCATION);
151 residuals, jacobian, 1);
163 void output(std::ostream& outfile,
const unsigned& nplot)
174 const unsigned& flag);
182 const unsigned&
i)
const
214 const unsigned el_dim =
dim();
220 for (
unsigned i = 0;
i < el_dim;
i++)
231 "Can only deal with 2D space-time traction elements!",
232 OOMPH_CURRENT_FUNCTION,
233 OOMPH_EXCEPTION_LOCATION);
255 for (
unsigned j = 0; j <
nnode_1d; j++)
261 test[index] = test_values[0][
i] * test_values[1][j];
284 for (
unsigned i = 0;
i <
Dim - 1;
i++)
294 (*Traction_fct_pt)(time, x, n, result);
311 template<
class ELEMENT>
314 Vector<double>& residuals,
315 DenseMatrix<double>& jacobian,
316 const unsigned& flag)
319 unsigned n_node = nnode();
328 unsigned n_intpt = integral_pt()->nweight();
334 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
337 double w = integral_pt()->weight(ipt);
341 double J = shape_and_test_at_knot(ipt, psif, testf);
347 double interpolated_t = 0.0;
350 Vector<double> interpolated_x(
Dim - 1, 0.0);
353 Vector<double> interpolated_spacetime_n(
Dim, 0.0);
356 Vector<double> interpolated_n(
Dim - 1, 0.0);
359 Vector<double> traction(
Dim - 1, 0.0);
362 for (
unsigned l = 0; l < n_node; l++)
365 interpolated_t += raw_nodal_position(l,
Dim - 1) * psif(l);
368 for (
unsigned i = 0;
i <
Dim - 1;
i++)
371 interpolated_x[
i] += nodal_position(l,
i) * psif(l);
376 outer_unit_normal(ipt, interpolated_spacetime_n);
381 if (std::fabs(interpolated_spacetime_n[
Dim - 1]) > 1.0e-15)
384 std::ostringstream error_message_stream;
388 <<
"The component of the outer unit normal in the "
389 <<
"time-direction\nshould be zero but the actual "
390 <<
"value is: " << interpolated_spacetime_n[
Dim - 1] << std::endl;
393 throw OomphLibError(error_message_stream.str(),
394 OOMPH_CURRENT_FUNCTION,
395 OOMPH_EXCEPTION_LOCATION);
400 for (
unsigned i = 0;
i <
Dim - 1;
i++)
403 interpolated_n[
i] = interpolated_spacetime_n[
i];
407 get_traction(interpolated_t, interpolated_x, interpolated_n, traction);
412 for (
unsigned l = 0; l < n_node; l++)
415 for (
unsigned i = 0;
i <
Dim - 1;
i++)
418 local_eqn = u_local_eqn(l,
i);
424 residuals[local_eqn] += traction[
i] * testf[l] *
W;
448 template<
class ELEMENT>
449 class RefineableNavierStokesSpaceTimeTractionElement
450 :
public virtual NavierStokesSpaceTimeTractionElement<ELEMENT>,
451 public virtual NonRefineableElementWithHangingNodes
490 residuals, jacobian, 1);
500 const unsigned& flag);
511 template<
class ELEMENT>
516 const unsigned& flag)
519 unsigned u_nodal_index[this->Dim - 1];
522 for (
unsigned i = 0;
i < this->Dim - 1;
i++)
526 dynamic_cast<ELEMENT*
>(this->bulk_element_pt())->u_index_nst(
i);
530 unsigned n_node = nnode();
539 unsigned n_intpt = integral_pt()->nweight();
545 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
548 double w = integral_pt()->weight(ipt);
552 double J = this->shape_and_test_at_knot(ipt, psif, testf);
558 double interpolated_t = 0.0;
561 Vector<double> interpolated_x(this->Dim - 1, 0.0);
564 Vector<double> interpolated_spacetime_n(this->Dim, 0.0);
567 Vector<double> interpolated_n(this->Dim - 1, 0.0);
570 Vector<double> traction(this->Dim - 1, 0.0);
573 for (
unsigned l = 0; l < n_node; l++)
576 interpolated_t += raw_nodal_position(l, this->Dim - 1) * psif(l);
579 for (
unsigned i = 0;
i < this->Dim - 1;
i++)
582 interpolated_x[
i] += this->nodal_position(l,
i) * psif(l);
587 this->outer_unit_normal(ipt, interpolated_spacetime_n);
592 if (std::fabs(interpolated_n[this->Dim - 1]) > 1.0e-15)
595 std::ostringstream error_message_stream;
598 error_message_stream <<
"The component of the outer unit normal in the "
599 <<
"time-direction\nshould be zero but the actual "
600 <<
"value is: " << interpolated_n[this->Dim - 1]
604 throw OomphLibError(error_message_stream.str(),
605 OOMPH_CURRENT_FUNCTION,
606 OOMPH_EXCEPTION_LOCATION);
611 for (
unsigned i = 0;
i < this->Dim - 1;
i++)
614 interpolated_n[
i] = interpolated_spacetime_n[
i];
619 interpolated_t, interpolated_x, interpolated_n, traction);
624 unsigned n_master = 1;
627 double hang_weight = 1.0;
630 HangInfo* hang_info_pt = 0;
634 for (
unsigned l = 0; l < n_node; l++)
637 bool is_node_hanging = this->node_pt(l)->is_hanging();
643 hang_info_pt = this->node_pt(l)->hanging_pt();
646 n_master = hang_info_pt->nmaster();
656 for (
unsigned m = 0; m < n_master; m++)
659 for (
unsigned i = 0;
i < this->Dim - 1;
i++)
667 local_eqn = this->local_hang_eqn(hang_info_pt->master_node_pt(m),
671 hang_weight = hang_info_pt->master_weight(m);
677 local_eqn = this->nodal_local_eqn(l, u_nodal_index[
i]);
687 residuals[local_eqn] += traction[
i] * testf[l] *
W * hang_weight;
FaceElements are elements that coincide with the faces of higher-dimensional "bulk" elements....
int & face_index()
Index of the face (a number that uniquely identifies the face in the element)
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
In a FaceElement, the "global" intrinsic coordinate of the element along the boundary,...
FiniteElement *& bulk_element_pt()
Pointer to higher-dimensional "bulk" element.
double J_eulerian_at_knot(const unsigned &ipt) const
Return the Jacobian of the mapping from local to global coordinates at the ipt-th integration point O...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
A general Finite Element class.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
virtual void output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing.
int nodal_local_eqn(const unsigned &n, const unsigned &i) const
Return the local equation number corresponding to the i-th value at the n-th local node.
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
virtual void build_face_element(const int &face_index, FaceElement *face_element_pt)
Function for building a lower dimensional FaceElement on the specified face of the FiniteElement....
virtual unsigned nnode_1d() const
Return the number of nodes along one edge of the element Default is to return zero — must be overload...
virtual void shape_at_knot(const unsigned &ipt, Shape &psi) const
Return the geometric shape function at the ipt-th integration point.
bool has_hanging_nodes() const
Return boolean to indicate if any of the element's nodes are geometrically hanging.
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point.
A class for elements that allow the imposition of an applied traction to the Navier–Stokes equations ...
virtual int u_local_eqn(const unsigned &n, const unsigned &i)
Access function that returns the local equation numbers for velocity components. u_local_eqn(n,...
unsigned Dim
The highest dimension of the problem.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
This function returns just the residuals.
NavierStokesSpaceTimeTractionElement(FiniteElement *const &element_pt, const int &face_index, const bool &called_from_refineable_constructor=false)
Constructor, which takes a "bulk" element and the value of the index and its limit.
void output(std::ostream &outfile, const unsigned &nplot)
Output function: x,y,[z],u,v,[w],p in tecplot format.
double shape_and_test_at_knot(const unsigned &ipt, Shape &psi, Shape &test) const
Function to compute the shape and test functions and to return the Jacobian of mapping.
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
This function returns the residuals and the jacobian.
void output(std::ostream &outfile)
Overload the output function.
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
The "global" intrinsic coordinate of the element when viewed as part of a geometric object should be ...
~NavierStokesSpaceTimeTractionElement()
Destructor should not delete anything.
void fill_in_generic_residual_contribution_fluid_traction(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
This function returns the residuals for the traction function. flag=1(or 0): do (or don't) compute th...
void(* Traction_fct_pt)(const double &time, const Vector< double > &x, const Vector< double > &n, Vector< double > &result)
Pointer to an imposed traction function.
void get_traction(const double &time, const Vector< double > &x, const Vector< double > &n, Vector< double > &result)
Function to calculate the traction applied to the fluid.
void(*&)(const double &t, const Vector< double > &x, const Vector< double > &n, Vector< double > &result) traction_fct_pt()
Access function for the imposed traction pointer.
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
An OomphLibError object which should be thrown when an run-time error is encountered....
RefineableElements are FiniteElements that may be subdivided into children to provide a better local ...
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
This function returns the residuals and the Jacobian.
RefineableNavierStokesSpaceTimeTractionElement(FiniteElement *const &element_pt, const int &face_index)
Constructor, which takes a "bulk" element and the face index.
void refineable_fill_in_generic_residual_contribution_fluid_traction(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
This function returns the residuals for the traction function. flag=1(or 0): do (or don't) compute th...
~RefineableNavierStokesSpaceTimeTractionElement()
Destructor should not delete anything.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
This function returns just the residuals.
unsigned ncont_interpolated_values() const
Number of continuously interpolated values are the same as those in the bulk element.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
unsigned Dim
Dimension of zeta tuples (set by get_dim_helper) – needed because we store the scalar coordinates in ...
void shape< 3 >(const double &s, double *Psi)
1D shape functions specialised to quadratic order (3 Nodes)
void shape< 3 >(const double &s, double *Psi)
1D shape functions specialised to quadratic order (3 Nodes)
//////////////////////////////////////////////////////////////////// ////////////////////////////////...