27#ifndef OOMPH_ADV_DIFF_REACT_ELEMENTS_HEADER
28#define OOMPH_ADV_DIFF_REACT_ELEMENTS_HEADER
33#include <oomph-lib-config.h>
51 template<
unsigned NREAGENT,
unsigned DIM>
129 for (
unsigned t = 0;
t < n_time;
t++)
147 for (
unsigned r = 0; r < NREAGENT; r++)
158 double weight[n_time];
159 for (
unsigned t = 0;
t < n_time;
t++)
165 for (
unsigned r = 0; r < NREAGENT; r++)
170 for (
unsigned t = 0;
t < n_time;
t++)
204 void output(std::ostream& outfile,
const unsigned& nplot);
216 void output(FILE* file_pt,
const unsigned& n_plot);
221 const unsigned& nplot,
228 std::ostream& outfile,
229 const unsigned& nplot,
233 throw OomphLibError(
"There is no time-dependent output_fct() for "
234 "Advection Diffusion elements",
235 OOMPH_CURRENT_FUNCTION,
236 OOMPH_EXCEPTION_LOCATION);
258 "No time-dependent compute_error() for Advection Diffusion elements",
259 OOMPH_CURRENT_FUNCTION,
260 OOMPH_EXCEPTION_LOCATION);
349 for (
unsigned r = 0; r < NREAGENT; r++)
357 (*Source_fct_pt)(x, source);
374 for (
unsigned i = 0;
i < DIM;
i++)
385 (*Wind_fct_pt)(time, x, wind);
402 for (
unsigned r = 0; r < NREAGENT; r++)
410 (*Reaction_fct_pt)(C, R);
425 for (
unsigned r = 0; r < NREAGENT; r++)
427 for (
unsigned p = 0; p < NREAGENT; p++)
446 for (
unsigned p = 0; p < NREAGENT; p++)
449 double old_var = C_local[p];
451 C_local[p] += fd_step;
453 (*Reaction_fct_pt)(C_local, R_plus);
456 C_local[p] = old_var;
458 C_local[p] -= fd_step;
460 (*Reaction_fct_pt)(C_local, R_minus);
463 for (
unsigned r = 0; r < NREAGENT; r++)
465 dRdC(r, p) = (R_plus[r] - R_minus[r]) / (2.0 * fd_step);
469 C_local[p] = old_var;
475 (*Reaction_deriv_fct_pt)(C, dRdC);
484 const unsigned n_node =
nnode();
488 DShape dpsidx(n_node, DIM);
494 for (
unsigned j = 0; j < DIM * NREAGENT; j++)
500 for (
unsigned r = 0; r < NREAGENT; r++)
505 for (
unsigned j = 0; j < DIM; j++)
507 unsigned index = r * DIM + j;
509 for (
unsigned l = 0; l < n_node; l++)
511 flux[index] +=
nodal_value(l, c_nodal_index) * dpsidx(l, j);
551 residuals, jacobian, mass_matrix, 2);
557 const unsigned&
i)
const
560 unsigned n_node =
nnode();
572 double interpolated_c = 0.0;
575 for (
unsigned l = 0; l < n_node; l++)
577 interpolated_c +=
nodal_value(l, c_nodal_index) * psi[l];
580 return (interpolated_c);
602 DShape& dtestdx)
const = 0;
611 DShape& dtestdx)
const = 0;
660 template<
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
662 :
public virtual QElement<DIM, NNODE_1D>,
700 void output(std::ostream& outfile,
const unsigned& n_plot)
716 void output(FILE* file_pt,
const unsigned& n_plot)
725 const unsigned& n_plot,
729 outfile, n_plot, exact_soln_pt);
737 const unsigned& n_plot,
742 outfile, n_plot, time, exact_soln_pt);
775 template<
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
784 double J = this->dshape_eulerian(
s, psi, dpsidx);
788 for (
unsigned i = 0;
i < NNODE_1D;
i++)
791 for (
unsigned j = 0; j < DIM; j++)
793 dtestdx(
i, j) = dpsidx(
i, j);
808 template<
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
817 double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
839 template<
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
842 :
public virtual QElement<DIM - 1, NNODE_1D>
860 template<
unsigned NREAGENT,
unsigned NNODE_1D>
874 template<
class ADR_ELEMENT>
885 unsigned nnod = this->
nnode();
889 for (
unsigned j = 0; j < nnod; j++)
892 data_values[j] = std::make_pair(this->
node_pt(j), fld);
902 return this->N_reagent;
925 unsigned n_dim = this->
dim();
926 unsigned n_node = this->
nnode();
928 DShape dpsidx(n_node, n_dim), dtestdx(n_node, n_dim);
929 double J = this->dshape_and_dtest_eulerian_adv_diff_react(
930 s, psi, dpsidx, test, dtestdx);
942 unsigned c_nodal_index = this->c_index_adv_diff_react(fld);
945 unsigned n_node = this->
nnode();
952 double interpolated_c = 0.0;
955 for (
unsigned l = 0; l < n_node; l++)
957 interpolated_c += this->
nodal_value(t, l, c_nodal_index) * psi[l];
959 return interpolated_c;
966 return this->
nnode();
973 const unsigned c_nodal_index = this->c_index_adv_diff_react(fld);
983 template<
class ELEMENT>
996 template<
class ELEMENT>
A class for all elements that solve the Advection Diffusion Reaction equations using isoparametric el...
Vector< double > *& diff_pt()
Pointer to vector of diffusion coefficients.
AdvectionDiffusionReactionEquations()
Constructor: Initialise the Source_fct_pt, Wind_fct_pt, Reaction_fct_pt to null and initialise the di...
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
virtual void get_reaction_deriv_adv_diff_react(const unsigned &ipt, const Vector< double > &C, DenseMatrix< double > &dRdC) const
Get the derivatives of the reaction terms with respect to the concentration variables....
AdvectionDiffusionReactionWindFctPt wind_fct_pt() const
Access function: Pointer to reaction function. Const version.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
AdvectionDiffusionReactionSourceFctPt Source_fct_pt
Pointer to source function:
bool ALE_is_disabled
Boolean flag to indicate if ALE formulation is disabled when time-derivatives are computed....
AdvectionDiffusionReactionSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
virtual double dshape_and_dtest_eulerian_adv_diff_react(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
Shape/test functions and derivs w.r.t. to global coords at local coord. s; return Jacobian of mapping...
AdvectionDiffusionReactionReactionDerivFctPt Reaction_deriv_fct_pt
Pointer to reaction derivatives.
virtual void get_source_adv_diff_react(const unsigned &ipt, const Vector< double > &x, Vector< double > &source) const
Get source term at (Eulerian) position x. This function is virtual to allow overloading in multi-phys...
const Vector< double > & diff() const
Vector of diffusion coefficients.
virtual void get_wind_adv_diff_react(const unsigned &ipt, const Vector< double > &s, const Vector< double > &x, Vector< double > &wind) const
Get wind at (Eulerian) position x and/or local coordinate s. This function is virtual to allow overlo...
void(* AdvectionDiffusionReactionWindFctPt)(const double &time, const Vector< double > &x, Vector< double > &wind)
Function pointer to wind function fct(x,w(x)) – x is a Vector!
unsigned self_test()
Self-test: Return 0 for OK.
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Add the element's contribution to its residual vector and the element Jacobian matrix (wrapper)
void(* AdvectionDiffusionReactionSourceFctPt)(const Vector< double > &x, Vector< double > &f)
Function pointer to source function fct(x,f(x)) – x is a Vector!
void dc_dt_adv_diff_react(const unsigned &n, Vector< double > &dc_dt) const
dc/dt at local node n. Uses suitably interpolated value for hanging nodes.
AdvectionDiffusionReactionReactionFctPt reaction_fct_pt() const
Access function: Pointer to reaction function. Const version.
AdvectionDiffusionReactionReactionFctPt & reaction_fct_pt()
Access function: Pointer to reaction function.
void get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: .
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
static const unsigned N_reagent
Vector< double > * Tau_pt
Pointer to global timescales.
virtual void fill_in_generic_residual_contribution_adv_diff_react(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, unsigned flag)
Add the element's contribution to its residual vector only (if flag=and/or element Jacobian matrix.
AdvectionDiffusionReactionReactionDerivFctPt & reaction_deriv_fct_pt()
Access function: Pointer to reaction derivatives function.
AdvectionDiffusionReactionSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
void output(std::ostream &outfile)
Output with default number of plot points.
void(* AdvectionDiffusionReactionReactionFctPt)(const Vector< double > &c, Vector< double > &R)
Function pointer to reaction terms.
void integrate_reagents(Vector< double > &C) const
Return the integrated reagent concentrations.
void enable_ALE()
(Re-)enable ALE, i.e. take possible mesh motion into account when evaluating the time-derivative....
double interpolated_c_adv_diff_react(const Vector< double > &s, const unsigned &i) const
Return FE representation of function value c_i(s) at local coordinate s.
AdvectionDiffusionReactionWindFctPt Wind_fct_pt
Pointer to wind function:
AdvectionDiffusionReactionReactionDerivFctPt reaction_deriv_fct_pt() const
Access function: Pointer to reaction function. Const version.
Vector< double > *& tau_pt()
Pointer to vector of dimensionless timescales.
void operator=(const AdvectionDiffusionReactionEquations &)=delete
Broken assignment operator.
static Vector< double > Default_dimensionless_number
Static default value for the dimensionless numbers.
void output(FILE *file_pt)
C_style output with default number of plot points.
void disable_ALE()
Disable ALE, i.e. assert the mesh is not moving – you do this at your own risk!
virtual void output_fct(std::ostream &outfile, const unsigned &nplot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at nplot^DIM plot points (dummy time-dependent versio...
virtual double dshape_and_dtest_eulerian_at_knot_adv_diff_react(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
Shape/test functions and derivs w.r.t. to global coords at integration point ipt; return Jacobian of ...
void compute_norm(double &norm)
Compute norm of the solution: sum of squares of the L2 norm for each reagent.
virtual unsigned c_index_adv_diff_react(const unsigned &i) const
Return the index at which the unknown i-th reagent is stored. The default value, i,...
AdvectionDiffusionReactionEquations(const AdvectionDiffusionReactionEquations &dummy)=delete
Broken copy constructor.
AdvectionDiffusionReactionWindFctPt & wind_fct_pt()
Access function: Pointer to wind function.
double dc_dt_adv_diff_react(const unsigned &n, const unsigned &r) const
dc_r/dt at local node n. Uses suitably interpolated value for hanging nodes.
AdvectionDiffusionReactionReactionFctPt Reaction_fct_pt
Pointer to reaction function.
void fill_in_contribution_to_jacobian_and_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix)
Add the element's contribution to its residuals vector, jacobian matrix and mass matrix.
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at nplot^DIM plot points.
void(* AdvectionDiffusionReactionReactionDerivFctPt)(const Vector< double > &c, DenseMatrix< double > &dRdC)
Function pointer to derivative of reaction terms.
Vector< double > * Diff_pt
Pointer to global diffusion coefficients.
const Vector< double > & tau() const
Vector of dimensionless timescales.
virtual void get_reaction_adv_diff_react(const unsigned &ipt, const Vector< double > &C, Vector< double > &R) const
Get reaction as a function of the given reagent concentrations This function is virtual to allow over...
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
unsigned ntstorage() const
Return total number of doubles stored per value to record time history of each value (one for steady ...
Class for dense matrices, storing all the values of the matrix as a pointer to a pointer with assorte...
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement.
FaceGeometry class definition: This policy class is used to allow construction of face elements that ...
A general Finite Element class.
double nodal_value(const unsigned &n, const unsigned &i) const
Return the i-th value stored at local node n. Produces suitably interpolated values for hanging nodes...
virtual void shape(const Vector< double > &s, Shape &psi) const =0
Calculate the geometric shape functions at local coordinate s. This function must be overloaded for e...
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...
unsigned nnode() const
Return the number of nodes.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
double dshape_eulerian(const Vector< double > &s, Shape &psi, DShape &dpsidx) const
Compute the geometric shape functions and also first derivatives w.r.t. global coordinates at local c...
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
static double Default_fd_jacobian_step
Double used for the default finite difference step in elemental jacobian calculations.
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
TimeStepper *& time_stepper_pt()
Access function for pointer to time stepper: Null if object is not time-dependent.
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
An OomphLibError object which should be thrown when an run-time error is encountered....
Point element has just a single node and a single shape function which is identically equal to one.
AdvectionDiffusionReaction upgraded to become projectable.
unsigned nfields_for_projection()
Number of fields to be projected: Just one.
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
unsigned nhistory_values_for_projection(const unsigned &fld)
Number of history values to be stored for fld-th field (includes current value!)
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
double get_field(const unsigned &t, const unsigned &fld, const Vector< double > &s)
Return interpolated field fld at local coordinate s, at time level t (t=0: present; t>0: history valu...
double jacobian_and_shape_of_field(const unsigned &fld, const Vector< double > &s, Shape &psi)
Return Jacobian of mapping and shape functions of field fld at local coordinate s.
unsigned nhistory_values_for_coordinate_projection()
Number of positional history values (Note: count includes current value!)
Vector< std::pair< Data *, unsigned > > data_values_of_field(const unsigned &fld)
Specify the values associated with field fld. The information is returned in a vector of pairs which ...
Wrapper class for projectable elements. Adds "projectability" to the underlying ELEMENT.
QAdvectionDiffusionReactionElement elements are linear/quadrilateral/brick-shaped Advection Diffusion...
double dshape_and_dtest_eulerian_at_knot_adv_diff_react(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. at integration point ipt....
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for an exact solution: x,y,u_exact or x,y,z,u_exact at n_plot^DIM plot points.
void output(FILE *file_pt)
C-style output function: x,y,u or x,y,z,u.
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function: x,y,u or x,y,z,u at n_plot^DIM plot points.
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
unsigned required_nvalue(const unsigned &n) const
Required # of ‘values’ (pinned or dofs) at node n.
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: x,y,u or x,y,z,u at n_plot^DIM plot points.
double dshape_and_dtest_eulerian_adv_diff_react(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
void operator=(const QAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D > &)=delete
Broken assignment operator.
void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Output function for a time-dependent exact solution. x,y,u_exact or x,y,z,u_exact at n_plot^DIM plot ...
QAdvectionDiffusionReactionElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
QAdvectionDiffusionReactionElement(const QAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
unsigned ntstorage() const
Return the number of doubles required to represent history (one for steady)
virtual double weight(const unsigned &i, const unsigned &j) const
Access function for j-th weight for the i-th derivative.
Time *const & time_pt() const
Access function for the pointer to time (const version)
bool is_steady() const
Flag to indicate if a timestepper has been made steady (possibly temporarily to switch off time-depen...
double & time()
Return the current value of the continuous time.
A slight extension to the standard template vector class so that we can include "graceful" array rang...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).