26 #ifndef OOMPH_RAVIART_THOMAS_DARCY_HEADER
27 #define OOMPH_RAVIART_THOMAS_DARCY_HEADER
31 #include <oomph-lib-config.h>
34 #include "../generic/elements.h"
35 #include "../generic/shape.h"
36 #include "../generic/error_estimator.h"
37 #include "../generic/projection.h"
46 template<
unsigned DIM>
93 for (
unsigned i = 0;
i <
n;
i++)
101 (*Source_fct_pt)(
x,
b);
117 (*Mass_source_fct_pt)(
x,
b);
148 virtual double q_edge(
const unsigned&
n)
const = 0;
152 const unsigned&
j)
const = 0;
185 Shape& q_basis)
const = 0;
190 Shape& div_q_basis_ds)
const = 0;
195 const unsigned n_node = this->
nnode();
197 const unsigned n_q_basis = this->
nq_basis();
198 Shape q_basis_local(n_q_basis,
DIM);
216 const unsigned& edge,
const unsigned&
n)
const = 0;
230 virtual double p_value(
const unsigned&
n)
const = 0;
253 const Shape& q_basis_local,
255 Shape& q_basis)
const;
280 for (
unsigned i = 0;
i <
DIM;
i++)
283 for (
unsigned l = 0; l < n_q_basis_edge; l++)
287 for (
unsigned l = n_q_basis_edge; l < n_q_basis; l++)
304 for (
unsigned l = 0; l < n_q_basis_edge; l++)
306 q_i +=
q_edge(l) * q_basis(l,
i);
308 for (
unsigned l = n_q_basis_edge; l < n_q_basis; l++)
310 q_i +=
q_internal(l - n_q_basis_edge) * q_basis(l,
i);
323 unsigned n_node =
nnode();
324 const unsigned n_q_basis =
nq_basis();
328 Shape div_q_basis_ds(n_q_basis);
348 for (
unsigned l = 0; l < n_q_basis_edge; l++)
350 div_q += 1.0 / det * div_q_basis_ds(l) *
q_edge(l);
355 for (
unsigned l = n_q_basis_edge; l < n_q_basis; l++)
357 div_q += 1.0 / det * div_q_basis_ds(l) *
q_internal(l - n_q_basis_edge);
381 Shape p_basis(n_p_basis);
390 for (
unsigned l = 0; l < n_p_basis; l++)
431 void output(std::ostream& outfile,
const unsigned& nplot);
437 const unsigned& nplot,
444 const unsigned& nplot,
480 Shape& div_q_basis_ds,
481 Shape& div_q_test_ds)
const = 0;
492 Shape& div_q_basis_ds,
493 Shape& div_q_test_ds)
const = 0;
516 template<
class DARCY_ELEMENT>
534 std::stringstream error_stream;
535 error_stream <<
"Darcy elements only store 2 fields so fld = " << fld
548 Data* dat_pt = this->p_data_pt();
549 unsigned nvalue = dat_pt->
nvalue();
550 for (
unsigned i = 0;
i < nvalue;
i++)
552 data_values.push_back(std::make_pair(dat_pt,
i));
558 unsigned n = edge_dat_pt.size();
559 for (
unsigned j = 0;
j <
n;
j++)
561 unsigned nvalue = edge_dat_pt[
j]->nvalue();
562 for (
unsigned i = 0;
i < nvalue;
i++)
564 data_values.push_back(std::make_pair(edge_dat_pt[
j],
i));
567 if (this->nq_basis_internal() > 0)
569 Data* int_dat_pt = this->q_internal_data_pt();
570 unsigned nvalue = int_dat_pt->
nvalue();
571 for (
unsigned i = 0;
i < nvalue;
i++)
573 data_values.push_back(std::make_pair(int_dat_pt,
i));
595 std::stringstream error_stream;
596 error_stream <<
"Darcy elements only store two fields so fld = " << fld
621 std::stringstream error_stream;
622 error_stream <<
"Darcy elements only store two fields so fld = " << fld
632 const unsigned n_dim = this->
dim();
633 const unsigned n_node = this->
nnode();
634 const unsigned n_q_basis = this->nq_basis();
635 const unsigned n_p_basis = this->np_basis();
639 Shape psi_geom(n_node), q_basis(n_q_basis, n_dim),
640 q_test(n_q_basis, n_dim), p_basis(n_p_basis), p_test(n_p_basis),
641 div_q_basis_ds(n_q_basis), div_q_test_ds(n_q_basis);
642 double J = this->shape_basis_test_local(
s,
653 unsigned n = p_basis.nindex1();
654 for (
unsigned i = 0;
i <
n;
i++)
662 unsigned n = q_basis.nindex1();
663 unsigned m = q_basis.nindex2();
664 for (
unsigned i = 0;
i <
n;
i++)
666 for (
unsigned j = 0;
j <
m;
j++)
668 psi(
i,
j) = q_basis(
i,
j);
686 std::stringstream error_stream;
687 error_stream <<
"Darcy elements only store two fields so fld = " << fld
694 double return_value = 0.0;
699 this->interpolated_p(
s, return_value);
718 std::stringstream error_stream;
719 error_stream <<
"Darcy elements only store two fields so fld = " << fld
726 unsigned return_value = 0;
729 return_value = this->np_basis();
733 return_value = this->nq_basis();
746 std::stringstream error_stream;
747 error_stream <<
"Darcy elements only store two fields so fld = " << fld
754 int return_value = 0;
758 return_value = this->p_local_eqn(
j);
762 unsigned nedge = this->nq_basis_edge();
765 return_value = this->q_edge_local_eqn(
j);
769 return_value = this->q_internal_local_eqn(
j - nedge);
777 void output(std::ostream& outfile,
const unsigned& nplot)
785 return std::max(this->Initial_Nvalue[
n],
unsigned(1));
795 for (
unsigned j = 0;
j < 3;
j++)
806 const unsigned& flag)
811 unsigned n_dim = this->
dim();
820 const unsigned n_node = this->
nnode();
831 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
834 for (
unsigned i = 0;
i < n_dim;
i++)
850 int local_eqn = 0, local_unknown = 0;
858 if (solid_el_pt == 0)
860 throw OomphLibError(
"Trying to project Lagrangian coordinates in "
861 "non-SolidElement\n",
867 Shape psi(n_node, n_position_type);
882 double interpolated_xi_bar =
887 for (
unsigned l = 0; l < n_node; ++l)
890 for (
unsigned k = 0;
k < n_position_type; ++
k)
900 residuals[local_eqn] +=
901 (interpolated_xi_proj - interpolated_xi_bar) * psi(l,
k) *
907 for (
unsigned l2 = 0; l2 < n_node; l2++)
910 for (
unsigned k2 = 0; k2 < n_position_type; k2++)
914 if (local_unknown >= 0)
916 jacobian(local_eqn, local_unknown) +=
917 psi(l2, k2) * psi(l,
k) *
W;
933 Shape psi(n_node, n_position_type);
944 double interpolated_x_proj = 0.0;
946 if (solid_el_pt != 0)
948 interpolated_x_proj =
954 interpolated_x_proj = this->
get_field(0, fld,
s);
962 for (
unsigned l = 0; l < n_node; ++l)
965 for (
unsigned k = 0;
k < n_position_type; ++
k)
968 if (solid_el_pt != 0)
982 if (n_position_type != 1)
985 "positions not in SolidElement\n",
996 residuals[local_eqn] +=
997 (interpolated_x_proj - interpolated_x_bar) * psi(l,
k) *
W;
1002 for (
unsigned l2 = 0; l2 < n_node; l2++)
1005 for (
unsigned k2 = 0; k2 < n_position_type; k2++)
1008 if (solid_el_pt != 0)
1018 if (local_unknown >= 0)
1020 jacobian(local_eqn, local_unknown) +=
1021 psi(l2, k2) * psi(l,
k) *
W;
1050 double interpolated_value_proj = this->
get_field(now, fld,
s);
1053 double interpolated_value_bar =
1057 for (
unsigned l = 0; l < n_value; l++)
1063 residuals[local_eqn] +=
1064 (interpolated_value_proj - interpolated_value_bar) *
1070 for (
unsigned l2 = 0; l2 < n_value; l2++)
1073 if (local_unknown >= 0)
1075 jacobian(local_eqn, local_unknown) +=
1076 psi[l2] * psi[l] *
W;
1087 Shape psi(n_value, n_dim);
1098 this->interpolated_q(
s, q_proj);
1102 cast_el_pt->interpolated_q(other_s, q_bar);
1107 std::stringstream error_stream;
1108 error_stream <<
"Darcy elements are steady!\n";
1116 for (
unsigned l = 0; l < n_value; l++)
1122 for (
unsigned i = 0;
i < n_dim;
i++)
1125 residuals[local_eqn] +=
1126 (q_proj[
i] - q_bar[
i]) * psi(l,
i) *
W;
1131 for (
unsigned l2 = 0; l2 < n_value; l2++)
1134 if (local_unknown >= 0)
1136 jacobian(local_eqn, local_unknown) +=
1137 psi(l2,
i) * psi(l,
i) *
W;
1148 "Wrong field specified. This should never happen\n",
1157 throw OomphLibError(
"Wrong type specificied in Projection_type. "
1158 "This should never happen\n",
1174 template<
class ELEMENT>
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
RowVector3d w
Definition: Matrix_resize_int.cpp:3
float * p
Definition: Tutorial_Map_using.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
Definition: darcy_elements.h:49
virtual unsigned required_nvalue(const unsigned &n) const =0
Number of values required at node n.
MassSourceFctPt mass_source_fct_pt() const
Access function: Pointer to mass source function (const version)
Definition: darcy_elements.h:79
MassSourceFctPt Mass_source_fct_pt
Pointer to the mass source function.
Definition: darcy_elements.h:504
virtual unsigned nq_basis_edge() const =0
Return the number of edge basis functions for q.
virtual int q_internal_local_eqn(const unsigned &n) const =0
Return the equation number of the n-th internal degree of freedom.
double interpolated_div_q(const Vector< double > &s)
Calculate the FE representation of div q and return it.
Definition: darcy_elements.h:362
virtual void edge_flux_interpolation_point_global(const unsigned &j, Vector< double > &x) const =0
virtual unsigned np_basis() const =0
Return the total number of pressure basis functions.
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Definition: darcy_elements.cc:202
virtual void scale_basis(Shape &basis) const =0
Scale the edge basis to allow arbitrary edge mappings.
virtual unsigned q_edge_index(const unsigned &n) const =0
Return the nodal index at which the nth edge unknown is stored.
void output_with_projected_flux(std::ostream &outfile, const unsigned &nplot, const Vector< double > unit_normal)
Output FE representation of soln: x,y,q1,q2,div_q,p,q \cdot n.
Definition: darcy_elements.cc:98
double interpolated_q(const Vector< double > &s, const unsigned i) const
Calculate the FE representation of the i-th component of q.
Definition: darcy_elements.h:295
virtual void fill_in_generic_residual_contribution(Vector< double > &residuals, DenseMatrix< double > &jacobian, bool flag)
Fill in residuals and, if flag==true, jacobian.
Definition: darcy_elements.cc:346
virtual int p_local_eqn(const unsigned &n) const =0
Return the equation number of the n-th pressure degree of freedom.
virtual double shape_basis_test_local(const Vector< double > &s, Shape &psi, Shape &q_basis, Shape &q_test, Shape &p_basis, Shape &p_test, Shape &div_q_basis_ds, Shape &div_q_test_ds) const =0
SourceFctPt Source_fct_pt
Pointer to body force function.
Definition: darcy_elements.h:501
virtual double shape_basis_test_local_at_knot(const unsigned &ipt, Shape &psi, Shape &q_basis, Shape &q_test, Shape &p_basis, Shape &p_test, Shape &div_q_basis_ds, Shape &div_q_test_ds) const =0
virtual void edge_flux_interpolation_point_global(const unsigned &edge, const unsigned &n, Vector< double > &x) const =0
void get_q_basis(const Vector< double > &s, Shape &q_basis) const
Returns the transformed basis at local coordinate s.
Definition: darcy_elements.h:193
virtual unsigned nedge_flux_interpolation_point() const =0
virtual int q_edge_local_eqn(const unsigned &n) const =0
Return the equation number of the n-th edge (flux) degree of freedom.
double interpolated_p(const Vector< double > &s) const
Calculate the FE representation of p and return it.
Definition: darcy_elements.h:397
DarcyEquations()
Constructor.
Definition: darcy_elements.h:58
void get_Z2_flux(const Vector< double > &s, Vector< double > &flux)
Z2 flux (use actual flux)
Definition: darcy_elements.h:465
void interpolated_q(const Vector< double > &s, Vector< double > &q) const
Calculate the FE representation of q.
Definition: darcy_elements.h:272
SourceFctPt source_fct_pt() const
Access function: Pointer to body force function (const version)
Definition: darcy_elements.h:67
virtual void set_q_edge(const unsigned &n, const double &value)=0
Set the values of the edge (flux) degree of freedom.
virtual void face_local_coordinate_of_flux_interpolation_point(const unsigned &edge, const unsigned &n, Vector< double > &s) const =0
virtual void pin_q_internal_value(const unsigned &n)=0
Pin the nth internal q value.
virtual unsigned face_index_of_q_edge_basis_fct(const unsigned &j) const =0
Return the face index associated with edge flux degree of freedom.
virtual double p_value(const unsigned &n) const =0
Return the nth pressure value.
virtual void pin_superfluous_darcy_dofs()
Definition: darcy_elements.h:413
double transform_basis(const Vector< double > &s, const Shape &q_basis_local, Shape &psi, Shape &q_basis) const
Definition: darcy_elements.cc:35
virtual void set_p_value(const unsigned &n, const double &value)=0
Set the nth pressure value.
void interpolated_p(const Vector< double > &s, double &p) const
Calculate the FE representation of p.
Definition: darcy_elements.h:375
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Fill in contribution to residuals for the Darcy equations.
Definition: darcy_elements.h:258
unsigned num_Z2_flux_terms()
Number off flux terms for Z2 error estimator (use actual flux)
Definition: darcy_elements.h:459
virtual unsigned q_internal_index() const =0
virtual unsigned q_edge_node_number(const unsigned &n) const =0
Return the number of the node where the nth edge unknown is stored.
virtual void pin_p_value(const unsigned &n)=0
Pin the nth pressure value.
virtual Data * q_internal_data_pt() const =0
Return pointer to the Data object that stores the internal flux values.
virtual void set_q_internal(const unsigned &n, const double &value)=0
Set the values of the internal degree of freedom.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, Vector< double > &error, Vector< double > &norm)
Definition: darcy_elements.cc:254
virtual void get_p_basis(const Vector< double > &s, Shape &p_basis) const =0
Return the pressure basis.
virtual double q_edge(const unsigned &n) const =0
Return the values of the n-th edge (flux) degree of freedom.
void interpolated_div_q(const Vector< double > &s, double &div_q) const
Calculate the FE representation of div q.
Definition: darcy_elements.h:317
void(* MassSourceFctPt)(const Vector< double > &x, double &f)
Mass source function pointer typedef.
Definition: darcy_elements.h:55
unsigned nq_basis() const
Return the total number of computational basis functions for q.
Definition: darcy_elements.h:172
SourceFctPt & source_fct_pt()
Access function: Pointer to body force function.
Definition: darcy_elements.h:61
MassSourceFctPt & mass_source_fct_pt()
Access function: Pointer to mass source function.
Definition: darcy_elements.h:73
void output(std::ostream &outfile)
Output with default number of plot points.
Definition: darcy_elements.h:423
void source(const Vector< double > &x, Vector< double > &b) const
Definition: darcy_elements.h:86
virtual Vector< Data * > q_edge_data_pt() const =0
virtual unsigned nq_basis_internal() const =0
Return the number of internal basis functions for q.
virtual void get_div_q_basis_local(const Vector< double > &s, Shape &div_q_basis_ds) const =0
void(* SourceFctPt)(const Vector< double > &x, Vector< double > &f)
Source function pointer typedef.
Definition: darcy_elements.h:52
unsigned self_test()
Self test – empty for now.
Definition: darcy_elements.h:417
virtual Data * p_data_pt() const =0
Return pointer to the Data object that stores the pressure values.
void mass_source(const Vector< double > &x, double &b) const
Definition: darcy_elements.h:107
virtual unsigned face_index_of_edge(const unsigned &j) const =0
Return the face index associated with specified edge.
virtual void get_q_basis_local(const Vector< double > &s, Shape &q_basis) const =0
Returns the local form of the q basis at local coordinate s.
virtual Vector< double > edge_flux_interpolation_point(const unsigned &edge, const unsigned &n) const =0
virtual double q_internal(const unsigned &n) const =0
Return the values of the internal degree of freedom.
void pin(const unsigned &i)
Pin the i-th stored variable.
Definition: nodes.h:385
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
Definition: nodes.h:483
unsigned ntstorage() const
Definition: nodes.cc:879
Vector< double > & external_element_local_coord(const unsigned &interaction_index, const unsigned &ipt)
Definition: element_with_external_element.h:136
FiniteElement *& external_element_pt(const unsigned &interaction_index, const unsigned &ipt)
Definition: element_with_external_element.h:107
Definition: error_estimator.h:79
FaceGeometry()
Definition: darcy_elements.h:1179
Definition: elements.h:4998
Definition: elements.h:1313
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
unsigned nnodal_position_type() const
Definition: elements.h:2463
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
Definition: elements.cc:3962
virtual void shape(const Vector< double > &s, Shape &psi) const =0
unsigned dim() const
Definition: elements.h:2611
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Definition: elements.h:1759
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
Definition: elements.h:1963
virtual double local_to_eulerian_mapping(const DShape &dpsids, DenseMatrix< double > &jacobian, DenseMatrix< double > &inverse_jacobian) const
Definition: elements.h:1508
virtual void dshape_local(const Vector< double > &s, Shape &psi, DShape &dpsids) const
Definition: elements.h:1981
virtual double J_eulerian(const Vector< double > &s) const
Definition: elements.cc:4103
static DenseMatrix< double > Dummy_matrix
Definition: elements.h:227
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point.
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
Definition: nodes.h:1022
Definition: oomph_definitions.h:222
Darcy upgraded to become projectable.
Definition: darcy_elements.h:520
Vector< std::pair< Data *, unsigned > > data_values_of_field(const unsigned &fld)
Definition: darcy_elements.h:529
double jacobian_and_shape_of_field(const unsigned &fld, const Vector< double > &s, Shape &psi)
Definition: darcy_elements.h:614
unsigned nhistory_values_for_coordinate_projection()
Definition: darcy_elements.h:607
void output(std::ostream &outfile, const unsigned &nplot)
Output FE representation of soln as in underlying element.
Definition: darcy_elements.h:777
double get_field(const unsigned &t, const unsigned &fld, const Vector< double > &s)
Definition: darcy_elements.h:679
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld.
Definition: darcy_elements.h:713
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
Definition: darcy_elements.h:741
void pin_superfluous_darcy_dofs()
Definition: darcy_elements.h:792
unsigned nhistory_values_for_projection(const unsigned &fld)
Definition: darcy_elements.h:590
void residual_for_projection(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Definition: darcy_elements.h:804
ProjectableDarcyElement()
Definition: darcy_elements.h:524
unsigned required_nvalue(const unsigned &n) const
Overload required_nvalue to return at least one value.
Definition: darcy_elements.h:783
unsigned nfields_for_projection()
Number of fields to be projected: 2 (pressure and flux)
Definition: darcy_elements.h:583
Template-free Base class for projectable elements.
Definition: projection.h:55
unsigned Projected_lagrangian
Definition: projection.h:78
Projection_Type Projection_type
Definition: projection.h:83
unsigned Time_level_for_projection
Time level we are projecting (0=current values; >0: history values)
Definition: projection.h:70
@ Value
Definition: projection.h:63
@ Lagrangian
Definition: projection.h:62
@ Coordinate
Definition: projection.h:61
unsigned Projected_field
Field that is currently being projected.
Definition: projection.h:67
unsigned Projected_coordinate
Definition: projection.h:74
virtual double get_field(const unsigned &time, const unsigned &fld, const Vector< double > &s)=0
Definition: projection.h:183
Definition: elements.h:3561
int position_local_eqn(const unsigned &n, const unsigned &k, const unsigned &j) const
Definition: elements.h:4137
unsigned ntstorage() const
Definition: timesteppers.h:601
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
#define max(a, b)
Definition: datatypes.h:23
RealScalar s
Definition: level1_cplx_impl.h:130
int * m
Definition: level2_cplx_impl.h:294
char char char int int * k
Definition: level2_impl.h:374
#define DIM
Definition: linearised_navier_stokes_elements.h:44
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019
squared absolute value
Definition: GlobalFunctions.h:87
void flux(const double &time, const Vector< double > &x, double &flux)
Get flux applied along boundary x=0.
Definition: pretend_melt.cc:59
int error
Definition: calibrate.py:297
@ W
Definition: quadtree.h:63
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
void output(std::ostream &outfile, const unsigned &nplot)
Overload output function.
Definition: overloaded_element_body.h:490
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2