5#ifndef ONED_TVDLF_MESH_H
6#define ONED_TVDLF_MESH_H
21 typedef std::vector<OneD_TVDLF_Elt> vector_of_elts;
22 typedef vector_of_elts::const_iterator celt_iter;
23 typedef vector_of_elts::iterator elt_iter;
58 double update(
const double& CFL,
const double& max_dt = std::numeric_limits<long double>::max());
63 void update_to(
const double& CFL,
const double& t_end);
71 elt_iter er = RED_ELTS.begin();
72 while(er != RED_ELTS.end()) {
73 er -> set_Q_mid(er -> contributed_Q() / er -> get_dx());
81 elt_iter eb = BLACK_ELTS.begin();
82 first_dt = eb -> get_max_dt();
84 while(eb != BLACK_ELTS.end()) {
85 first_dt = std::min(first_dt, eb -> get_max_dt());
90 if(first_dt > max_dt) {
94 calc_slopes(&RED_ELTS);
99 elt_iter er = RED_ELTS.begin();
103 er -> contributed_flux_in_left(first_dt, flux_in_left, MESH_TIME);
104 while(er != RED_ELTS.end()) {
106 er -> contributed_flux_out_right(first_dt, flux_out_right, MESH_TIME);
111 double x_mid(er -> get_x(0.0));
114 q_mid += (er -> get_source_fn(0.0)
115 - er -> get_Jac_flux_fn(0.0).multiply(slope)) * 0.5 * first_dt;
117 er -> system_ptr -> source_fn(x_mid, q_mid, slope, r_mid);
118 deltaQ += r_mid * first_dt;
120 er -> set_Q_mid(er -> get_Q(0.0) + deltaQ);
122 flux_in_left = flux_out_right;
128 calc_slopes(&RED_ELTS);
129 MESH_TIME += first_dt;
136 elt_iter eb = BLACK_ELTS.begin();
137 while(eb != BLACK_ELTS.end()) {
138 eb -> set_Q_mid(eb -> contributed_Q() / eb -> get_dx());
145 elt_iter er = RED_ELTS.begin();
146 second_dt = er -> get_max_dt();
148 while(er != RED_ELTS.end()) {
149 second_dt = std::min(second_dt, er -> get_max_dt());
154 if(second_dt > max_dt) {
158 calc_slopes(&BLACK_ELTS);
163 elt_iter eb = BLACK_ELTS.begin();
167 eb -> contributed_flux_in_left(second_dt, flux_in_left, MESH_TIME);
168 while(eb != BLACK_ELTS.end()) {
170 eb -> contributed_flux_out_right(second_dt, flux_out_right, MESH_TIME);
175 double x_mid(eb -> get_x(0.0));
178 q_mid += (eb -> get_source_fn(0.0)
179 - eb -> get_Jac_flux_fn(0.0).multiply(slope)) * 0.5 * second_dt;
181 eb -> system_ptr -> source_fn(x_mid, q_mid, slope, r_mid);
182 deltaQ += r_mid * second_dt;
184 eb -> set_Q_mid(eb -> get_Q(0.0) + deltaQ);
186 flux_in_left = flux_out_right;
193 calc_slopes(&BLACK_ELTS);
194 MESH_TIME += second_dt;
217 vector_of_elts* elts(get_elts_from_colour(
"black"));
221 for(std::size_t i = 0; i < X.
size(); ++i) {
234 void set_boundary_Q(vector_of_elts* elts);
240 vector_of_elts* get_elts_from_colour(std::string mesh_colour);
246 void calc_slopes(vector_of_elts* elt_vector);
273 double minmod(
double a,
double b);
281 double maxmod(
double a,
double b);
302 std::size_t ORDER_OF_SYSTEM;
305 vector_of_elts BLACK_ELTS;
307 vector_of_elts RED_ELTS;
A specification for a one dimensional mesh object.
Specification of a one dimensional linear element for use in a TVD Lax-Friedrichs scheme.
An DenseVector class – a dense vector object.
std::size_t size() const
A pass-thru definition to get the size of the vector.
A class to represent a one dimensional hyperbolic system of equations.
A one dimensional mesh utility object.
void set_nodes_vars(const std::size_t node, const DenseVector< _Type > &u)
Set the variables stored at A SPECIFIED node.
void update_to(const double &CFL, const double &t_end)
Update all the elements in this mesh to a USER SPECIFIED time step.
const double & get_time() const
Get a const reference to the time value for the current mesh.
OneD_Node_Mesh< double > get_soln(std::string location="centre", std::string colour="black")
Get a OneD_Mesh<double> object containing the one dimensional data in the usual format.
double update_to_black(const double &CFL, const double &max_dt)
double update_to_red(const double &CFL, const double &max_dt)
~OneD_TVDLF_Mesh()
Empty desctructor.
double update(const double &CFL, const double &max_dt=std::numeric_limits< long double >::max())
Update all the elements in this mesh to a new time step.
DenseVector< double > get_mid_node_vector() const
Get the nodal positions in the middle of each element.
void set_limiter(unsigned id)
Set the limiter type to be applied in the slope values.
DenseVector< double > integrate() const
Integrate the concentration values across the entire mesh.
OneD_Node_Mesh< double > get_slope()
DenseVector< double > get_face_pos_vector() const
Get the positions of the element faces.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...