31 #ifndef OOMPH_POISSON_ELEMENTS_HEADER 32 #define OOMPH_POISSON_ELEMENTS_HEADER 37 #include <oomph-lib-config.h> 43 #include "../generic/projection.h" 44 #include "../generic/nodes.h" 45 #include "../generic/Qelements.h" 46 #include "../generic/oomph_utilities.h" 62 template <
unsigned DIM>
110 unsigned dim=s.size();
116 for (
unsigned i=0;
i<
dim;
i++)
135 const unsigned& nplot)
const 140 std::stringstream error_stream;
142 <<
"Poisson elements only store a single field so i must be 0 rather" 143 <<
" than " << i << std::endl;
146 OOMPH_CURRENT_FUNCTION,
147 OOMPH_EXCEPTION_LOCATION);
152 for(
unsigned j=0;j<local_loop;j++)
172 std::stringstream error_stream;
174 <<
"Poisson elements only store a single field so i must be 0 rather" 175 <<
" than " << i << std::endl;
178 OOMPH_CURRENT_FUNCTION,
179 OOMPH_EXCEPTION_LOCATION);
183 return "Poisson solution";
191 const unsigned& nplot,
199 std::stringstream error_stream;
201 <<
"Poisson equation has only one field. Can't call " 202 <<
"this function for value " << i << std::endl;
205 OOMPH_CURRENT_FUNCTION,
206 OOMPH_EXCEPTION_LOCATION);
221 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
230 (*exact_soln_pt)(x,exact_soln);
233 file_out << exact_soln[0] << std::endl;
241 const unsigned n_plot=5;
247 void output(std::ostream &outfile,
const unsigned &n_plot);
252 const unsigned n_plot=5;
258 void output(FILE* file_pt,
const unsigned &n_plot);
261 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
267 virtual void output_fct(std::ostream &outfile,
const unsigned &n_plot,
273 "There is no time-dependent output_fct() for Poisson elements ",
274 OOMPH_CURRENT_FUNCTION,
275 OOMPH_EXCEPTION_LOCATION);
285 double& error,
double& norm);
291 const double& time,
double& error,
double& norm)
294 "There is no time-dependent compute_error() for Poisson elements",
295 OOMPH_CURRENT_FUNCTION,
296 OOMPH_EXCEPTION_LOCATION);
320 double& source)
const 327 (*Source_fct_pt)(x,source);
351 double source_pls=0.0;
353 for (
unsigned i=0;
i<DIM;
i++)
357 gradient[
i]=(source_pls-source)/eps_fd;
364 (*Source_fct_gradient_pt)(x,gradient);
375 const unsigned n_node =
nnode();
382 DShape dpsidx(n_node,DIM);
388 for(
unsigned j=0;j<DIM;j++)
394 for(
unsigned l=0;l<n_node;l++)
397 for(
unsigned j=0;j<DIM;j++)
399 flux[j] += this->
nodal_value(l,u_nodal_index)*dpsidx(l,j);
411 const unsigned n_node =
nnode();
415 DShape dpsidx(n_node,DIM);
421 for(
unsigned i=0;
i<DIM;
i++)
423 for(
unsigned j=0;j<n_node;j++)
425 dflux_dnodal_u[
i][j] = dpsidx(j,
i);
457 const unsigned n_node =
nnode();
469 double interpolated_u = 0.0;
472 for(
unsigned l=0;l<n_node;l++)
474 interpolated_u += this->
nodal_value(l,u_nodal_index)*psi[l];
477 return(interpolated_u);
486 dresidual_dnodal_coordinates);
528 const unsigned& flag);
553 template <
unsigned DIM,
unsigned NNODE_1D>
587 {
return Initial_Nvalue;}
597 void output(std::ostream &outfile,
const unsigned &n_plot)
609 void output(FILE* file_pt,
const unsigned &n_plot)
615 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
624 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
674 template<
unsigned DIM,
unsigned NNODE_1D>
702 template<
unsigned DIM,
unsigned NNODE_1D>
732 template<
unsigned DIM,
unsigned NNODE_1D>
746 djacobian_dX,d_dpsidx_dX);
751 d_dtestdx_dX = d_dpsidx_dX;
771 template<
unsigned DIM,
unsigned NNODE_1D>
773 public virtual QElement<DIM-1,NNODE_1D>
792 template<
unsigned NNODE_1D>
815 template<
class POISSON_ELEMENT>
831 std::stringstream error_stream;
833 <<
"Poisson elements only store a single field so fld must be 0 rather" 834 <<
" than " << fld << std::endl;
837 OOMPH_CURRENT_FUNCTION,
838 OOMPH_EXCEPTION_LOCATION);
843 unsigned nnod=this->
nnode();
847 for (
unsigned j=0;j<nnod;j++)
850 data_values[j]=std::make_pair(this->
node_pt(j),fld);
870 std::stringstream error_stream;
872 <<
"Poisson elements only store a single field so fld must be 0 rather" 873 <<
" than " << fld << std::endl;
876 OOMPH_CURRENT_FUNCTION,
877 OOMPH_EXCEPTION_LOCATION);
899 std::stringstream error_stream;
901 <<
"Poisson elements only store a single field so fld must be 0 rather" 902 <<
" than " << fld << std::endl;
905 OOMPH_CURRENT_FUNCTION,
906 OOMPH_EXCEPTION_LOCATION);
909 unsigned n_dim=this->
dim();
910 unsigned n_node=this->
nnode();
912 DShape dpsidx(n_node,n_dim), dtestdx(n_node,n_dim);
929 std::stringstream error_stream;
931 <<
"Poisson elements only store a single field so fld must be 0 rather" 932 <<
" than " << fld << std::endl;
935 OOMPH_CURRENT_FUNCTION,
936 OOMPH_EXCEPTION_LOCATION);
943 unsigned n_node=this->
nnode();
950 double interpolated_u = 0.0;
953 for(
unsigned l=0;l<n_node;l++)
955 interpolated_u += this->
nodal_value(l,u_nodal_index)*psi[l];
957 return interpolated_u;
969 std::stringstream error_stream;
971 <<
"Poisson elements only store a single field so fld must be 0 rather" 972 <<
" than " << fld << std::endl;
975 OOMPH_CURRENT_FUNCTION,
976 OOMPH_EXCEPTION_LOCATION);
979 return this->
nnode();
990 std::stringstream error_stream;
992 <<
"Poisson elements only store a single field so fld must be 0 rather" 993 <<
" than " << fld << std::endl;
996 OOMPH_CURRENT_FUNCTION,
997 OOMPH_EXCEPTION_LOCATION);
1011 template<
class ELEMENT>
1024 template<
class ELEMENT>
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
PoissonEquations()
Constructor (must initialise the Source_fct_pt to null)
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
virtual void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &shifted_to_interior=false) const
Get cector of local coordinates of plot point i (when plotting nplot points in each "coordinate direc...
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-...
static const unsigned Initial_Nvalue
Static int that holds the number of variables at nodes: always the same.
void scalar_value_paraview(std::ofstream &file_out, const unsigned &i, const unsigned &nplot) const
Write values of the i-th scalar field at the plot points. Needs to be implemented for each new specif...
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 ...
virtual void get_source_poisson(const unsigned &ipt, const Vector< double > &x, double &source) const
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
virtual unsigned nplot_points_paraview(const unsigned &nplot) const
Return the number of actual plot points for paraview plot with parameter nplot. Broken virtual; can b...
void get_dflux_dnodal_u(const Vector< double > &s, Vector< Vector< double > > &dflux_dnodal_u) const
unsigned required_nvalue(const unsigned &n) const
Required # of `values' (pinned or dofs) at node n.
PoissonSourceFctGradientPt & source_fct_gradient_pt()
Access function: Pointer to gradient of source function.
void output(FILE *file_pt)
C_style output with default number of plot points.
A general Finite Element class.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as ...
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
virtual void fill_in_generic_residual_contribution_poisson(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Compute element residual Vector only (if flag=and/or element Jacobian matrix.
QPoissonElement()
Constructor: Call constructors for QElement and Poisson equations.
unsigned nhistory_values_for_coordinate_projection()
Number of positional history values (Note: count includes current value!)
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.
double dshape_and_dtest_eulerian_at_knot_poisson(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.
void operator=(const PoissonEquations &)
Broken assignment operator.
QPoissonElement(const QPoissonElement< DIM, NNODE_1D > &dummy)
Broken copy constructor.
void output(std::ostream &outfile)
Output with default number of plot points.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
virtual unsigned u_index_poisson() const
Return the index at which the unknown value is stored. The default value, 0, is appropriate for singl...
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...
unsigned nhistory_values_for_projection(const unsigned &fld)
Number of history values to be stored for fld-th field (includes current value!)
PoissonEquations(const PoissonEquations &dummy)
Broken copy constructor.
virtual void get_source_gradient_poisson(const unsigned &ipt, const Vector< double > &x, Vector< double > &gradient) const
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_dresidual_dnodal_coordinates(RankThreeTensor< double > &dresidual_dnodal_coordinates)
Compute derivatives of elemental residual vector with respect to nodal coordinates. Overwrites default implementation in FiniteElement base class. dresidual_dnodal_coordinates(l,i,j) = d res(l) / dX_{ij}.
void point_output_data(const Vector< double > &s, Vector< double > &data)
Output solution in data vector at local cordinates s: x,y [,z], u.
void operator=(const QPoissonElement< DIM, NNODE_1D > &)
Broken assignment operator.
PoissonSourceFctGradientPt Source_fct_gradient_pt
Pointer to gradient of source function.
void(* PoissonSourceFctPt)(const Vector< double > &x, double &f)
Function pointer to source function fct(x,f(x)) – x is a Vector!
double dshape_and_dtest_eulerian_poisson(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 compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
void scalar_value_fct_paraview(std::ofstream &file_out, const unsigned &i, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt) const
Write values of the i-th scalar field at the plot points. Needs to be implemented for each new specif...
std::string scalar_name_paraview(const unsigned &i) const
Name of the i-th scalar field. Default implementation returns V1 for the first one, V2 for the second etc. Can (should!) be overloaded with more meaningful names in specific elements.
virtual void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at n_plot^DIM plot points (dummy time-dependent versi...
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)
unsigned ntstorage() const
Return total number of doubles stored per value to record time history of each value (one for steady ...
void get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: flux[i] = du/dx_i.
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
PoissonSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
virtual double interpolated_u_poisson(const Vector< double > &s) const
Return FE representation of function value u_poisson(s) at local coordinate s.
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
void output(FILE *file_pt)
C-style output function: x,y,u or x,y,z,u.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
PoissonSourceFctGradientPt source_fct_gradient_pt() const
Access function: Pointer to gradient source function. Const version.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
unsigned nfields_for_projection()
Number of fields to be projected: Just one.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
unsigned nscalar_paraview() const
Number of scalars/fields output by this element. Reimplements broken virtual function in base class...
void(* PoissonSourceFctGradientPt)(const Vector< double > &x, Vector< double > &gradient)
Function pointer to gradient of source function fct(x,g(x)) – x is a Vector!
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 ...
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.
PoissonSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
Poisson upgraded to become projectable.
unsigned nnode() const
Return the number of nodes.
virtual double dshape_and_dtest_eulerian_poisson(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...
virtual double dshape_and_dtest_eulerian_at_knot_poisson(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 solution: square of the L2 norm.
static double Default_fd_jacobian_step
Double used for the default finite difference step in elemental jacobian calculations.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at n_plot^DIM plot points.
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.
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...
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...
PoissonSourceFctPt Source_fct_pt
Pointer to source function:
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
unsigned self_test()
Self-test: Return 0 for OK.
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...