31 #ifndef OOMPH_ADV_DIFF_REACT_ELEMENTS_HEADER 32 #define OOMPH_ADV_DIFF_REACT_ELEMENTS_HEADER 37 #include <oomph-lib-config.h> 41 #include "../generic/nodes.h" 42 #include "../generic/Qelements.h" 43 #include "../generic/oomph_utilities.h" 60 template <
unsigned NREAGENT,
unsigned DIM>
139 const unsigned n_time = time_stepper_pt->
ntstorage();
141 for(
unsigned t=0;
t<n_time;
t++)
158 for(
unsigned r=0;r<NREAGENT;r++) {dc_dt[r] = 0.0;}
164 const unsigned n_time = time_stepper_pt->
ntstorage();
166 double weight[n_time];
167 for(
unsigned t=0;
t<n_time;
t++)
168 {weight[
t] = time_stepper_pt->
weight(1,
t);}
171 for(
unsigned r=0;r<NREAGENT;r++)
176 for(
unsigned t=0;
t<n_time;
t++)
210 void output(std::ostream &outfile,
const unsigned &nplot);
222 void output(FILE* file_pt,
const unsigned &n_plot);
226 void output_fct(std::ostream &outfile,
const unsigned &nplot,
233 virtual void output_fct(std::ostream &outfile,
const unsigned &nplot,
238 "There is no time-dependent output_fct() for Advection Diffusion elements",
239 OOMPH_CURRENT_FUNCTION,
240 OOMPH_EXCEPTION_LOCATION);
247 exact_soln_pt,
double& error,
double& norm);
254 const double& time,
double& error,
double& norm)
257 "No time-dependent compute_error() for Advection Diffusion elements",
258 OOMPH_CURRENT_FUNCTION,
259 OOMPH_EXCEPTION_LOCATION);
320 for(
unsigned r=0;r<NREAGENT;r++){source[r] = 0.0;}
325 (*Source_fct_pt)(x,source);
342 for(
unsigned i=0;
i<DIM;
i++) {wind[
i]= 0.0;}
350 (*Wind_fct_pt)(time,x,wind);
367 for(
unsigned r=0;r<NREAGENT;r++) {R[r]= 0.0;}
372 (*Reaction_fct_pt)(C,
R);
387 for(
unsigned r=0;r<NREAGENT;r++)
389 for(
unsigned p=0;p<NREAGENT;p++)
408 for(
unsigned p=0;p<NREAGENT;p++)
411 double old_var = C_local[p];
413 C_local[p] += fd_step;
415 (*Reaction_fct_pt)(C_local,R_plus);
418 C_local[p] = old_var;
420 C_local[p] -= fd_step;
422 (*Reaction_fct_pt)(C_local,R_minus);
425 for(
unsigned r=0;r<NREAGENT;r++)
427 dRdC(r,p) = (R_plus[r] - R_minus[r])/(2.0*fd_step);
431 C_local[p] = old_var;
437 (*Reaction_deriv_fct_pt)(C,dRdC);
446 const unsigned n_node =
nnode();
450 DShape dpsidx(n_node,DIM);
456 for(
unsigned j=0;j<DIM*NREAGENT;j++) {flux[j] = 0.0;}
459 for(
unsigned r=0;r<NREAGENT;r++)
464 for(
unsigned j=0;j<DIM;j++)
466 unsigned index = r*DIM + j;
468 for(
unsigned l=0;l<n_node;l++)
470 flux[index] +=
nodal_value(l,c_nodal_index)*dpsidx(l,j);
514 const unsigned &
i)
const 517 unsigned n_node =
nnode();
529 double interpolated_u = 0.0;
532 for(
unsigned l=0;l<n_node;l++)
534 interpolated_u +=
nodal_value(l,c_nodal_index)*psi[l];
537 return(interpolated_u);
618 template <
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
620 public virtual QElement<DIM,NNODE_1D>,
657 void output(std::ostream &outfile,
const unsigned &n_plot)
670 void output(FILE* file_pt,
const unsigned &n_plot)
677 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
688 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
694 output_fct(outfile,n_plot,time,exact_soln_pt);
729 template<
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
742 for(
unsigned i=0;
i<NNODE_1D;
i++)
745 for(
unsigned j=0;j<DIM;j++)
747 dtestdx(
i,j) = dpsidx(
i,j);
763 template<
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
796 template<
unsigned NREAGENT,
unsigned DIM,
unsigned NNODE_1D>
799 public virtual QElement<DIM-1,NNODE_1D>
820 template<
unsigned NREAGENT,
unsigned NNODE_1D>
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...
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
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...
void output(FILE *file_pt)
C_style output with default number of plot points.
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
virtual double dshape_eulerian_at_knot(const unsigned &ipt, Shape &psi, DShape &dpsidx) const
Return the geometric shape functions and also first derivatives w.r.t. global coordinates at the ipt-...
AdvectionDiffusionReactionEquations(const AdvectionDiffusionReactionEquations &dummy)
Broken copy constructor.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
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 integrate_reagents(Vector< double > &C) const
Return the integrated reagent concentrations.
QAdvectionDiffusionReactionElement elements are linear/quadrilateral/brick-shaped Advection Diffusion...
AdvectionDiffusionReactionReactionDerivFctPt Reaction_deriv_fct_pt
Pointer to reaction derivatives.
void(* AdvectionDiffusionReactionReactionDerivFctPt)(const Vector< double > &c, DenseMatrix< double > &dRdC)
Function pointer to derivative of reaction terms.
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
bool ALE_is_disabled
Boolean flag to indicate if ALE formulation is disabled when time-derivatives are computed...
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...
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. If no explicit function pointer is set, these will be calculated by finite differences.
A general Finite Element class.
void dc_dt_adv_diff_react(const unsigned &n, Vector< double > &dc_dt) const
dc/dt at local node n.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as ...
void output(std::ostream &outfile)
Output with default number of plot points.
AdvectionDiffusionReactionSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
AdvectionDiffusionReactionReactionFctPt & reaction_fct_pt()
Access function: Pointer to reaction function.
void operator=(const AdvectionDiffusionReactionEquations &)
Broken assignment operator.
void fill_in_contribution_to_jacobian_and_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix)
double dc_dt_adv_diff_react(const unsigned &n, const unsigned &r) const
dc_r/dt at local node n.
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, is appropriate for single-physics problems, when there are only i variables, the values that satisfies the advection-diffusion-reaction equation. In derived multi-physics elements, this function should be overloaded to reflect the chosen storage scheme. Note that these equations require that the unknown is always stored at the same index at each node.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
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...
AdvectionDiffusionReactionReactionDerivFctPt & reaction_deriv_fct_pt()
Access function: Pointer to reaction derivatives function.
void disable_ALE()
Disable ALE, i.e. assert the mesh is not moving – you do this at your own risk!
AdvectionDiffusionReactionEquations()
Constructor: Initialise the Source_fct_pt, Wind_fct_pt, Reaction_fct_pt to null and initialise the di...
TimeStepper *& time_stepper_pt()
Access function for pointer to time stepper: Null if object is not time-dependent.
AdvectionDiffusionReactionSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
unsigned self_test()
Self-test: Return 0 for OK.
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...
void enable_ALE()
(Re-)enable ALE, i.e. take possible mesh motion into account when evaluating the time-derivative. Note: By default, ALE is enabled, at the expense of possibly creating unnecessary work in problems where the mesh is, in fact, stationary.
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...
void(* AdvectionDiffusionReactionReactionFctPt)(const Vector< double > &c, Vector< double > &R)
Function pointer to reaction terms.
A class for all elements that solve the Advection Diffusion Reaction equations using isoparametric el...
AdvectionDiffusionReactionWindFctPt & wind_fct_pt()
Access function: Pointer to wind function.
unsigned required_nvalue(const unsigned &n) const
Required # of `values' (pinned or dofs) at node n.
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!
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.
AdvectionDiffusionReactionWindFctPt Wind_fct_pt
Pointer to wind function:
AdvectionDiffusionReactionReactionDerivFctPt reaction_deriv_fct_pt() const
Access function: Pointer to reaction function. Const version.
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...
Vector< double > *& tau_pt()
Pointer to vector of dimensionless timescales.
void output(FILE *file_pt)
C-style output function: x,y,u or x,y,z,u.
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 get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: .
static Vector< double > Default_dimensionless_number
Static default value for the dimensionless numbers.
Vector< double > * Diff_pt
Pointer to global diffusion coefficients.
double & time()
Return the current value of the continuous time.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
AdvectionDiffusionReactionSourceFctPt Source_fct_pt
Pointer to source function:
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...
unsigned ntstorage() const
Return the number of doubles required to represent history (one for steady)
QAdvectionDiffusionReactionElement(const QAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D > &dummy)
Broken copy constructor.
QAdvectionDiffusionReactionElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
AdvectionDiffusionReactionWindFctPt wind_fct_pt() const
Access function: Pointer to reaction function. Const version.
const Vector< double > & tau() const
Vector of dimensionless timescales.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
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(* AdvectionDiffusionReactionSourceFctPt)(const Vector< double > &x, Vector< double > &f)
Function pointer to source function fct(x,f(x)) – x is a Vector!
const Vector< double > & diff() const
Vector of diffusion coefficients.
Vector< double > * Tau_pt
Pointer to global timescales.
Time *const & time_pt() const
Access function for the pointer to time (const version)
Vector< double > *& diff_pt()
Pointer to vector of diffusion coefficients.
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
AdvectionDiffusionReactionReactionFctPt reaction_fct_pt() const
Access function: Pointer to reaction function. Const version.
void operator=(const QAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D > &)
Broken assignment operator.
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. Return Jacobian.
bool is_steady() const
Flag to indicate if a timestepper has been made steady (possibly temporarily to switch off time-depen...
AdvectionDiffusionReactionReactionFctPt Reaction_fct_pt
Pointer to reaction function.
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.
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 ...
unsigned nnode() const
Return the number of nodes.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
virtual double weight(const unsigned &i, const unsigned &j) const
Access function for j-th weight for the i-th derivative.
static double Default_fd_jacobian_step
Double used for the default finite difference step in elemental jacobian calculations.
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.
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...
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
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.