#include <grid/dof_constraints.h>
-#include <fstream.h>
+#include <fstream>
#include <cmath>
-extern "C" {
-# include <stdlib.h>
-}
-
-extern TriaActiveIterator<1,CellAccessor<1> > x;
-extern TriaActiveIterator<2,CellAccessor<2> > y;
+#include <cstdlib>
template <int dim>
void TestCases<dim>::declare_parameters (ParameterHandler &prm) {
if (dim>=2)
- prm.declare_entry ("Test run", "zoom in", "zoom in\\|ball\\|curved line\\|random");
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("zoom in|ball|curved line|random"));
else
- prm.declare_entry ("Test run", "zoom in", "zoom in\\|random");
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("zoom in|random"));
prm.declare_entry ("Grid file", "grid.1");
prm.declare_entry ("Sparsity file", "sparsity.1");
prm.declare_entry ("Condensed sparsity file", "sparsity.c.1");
cout << " Making grid..." << endl;
- String test = prm.get ("Test run");
+ string test = prm.get ("Test run");
unsigned int test_case;
if (test=="zoom in") test_case = 1;
else
// output the grid
cout << " Writing grid..." << endl;
- ofstream out(prm.get("Grid file"));
+ ofstream out(prm.get("Grid file").c_str());
tria->print_gnuplot (out);
int unconstrained_bandwidth = sparsity.bandwidth();
cout << " Writing sparsity pattern... (This may take a while)" << endl;
- ofstream sparsity_out (prm.get("Sparsity file"));
+ ofstream sparsity_out (prm.get("Sparsity file").c_str());
sparsity.print_gnuplot (sparsity_out);
constraints.condense (sparsity);
cout << " Writing condensed sparsity pattern... (This may take a while)" << endl;
- ofstream c_sparsity_out (prm.get("Condensed sparsity file"));
+ ofstream c_sparsity_out (prm.get("Condensed sparsity file").c_str());
sparsity.print_gnuplot (c_sparsity_out);
template <int dim>
void PoissonProblem<dim>::declare_parameters (ParameterHandler &prm) {
prm.declare_entry ("Test case", "Gauss shape",
- "Gauss shape\\|Singular\\|Kink");
+ Patterns::Sequence("Gauss shape|Singular|Kink"));
prm.declare_entry ("Initial refinement", "2",
- ParameterHandler::RegularExpressions::Integer);
+ Patterns::Integer());
prm.declare_entry ("Refinement criterion", "estimated error",
- "global\\|true error\\|estimated error");
+ Patterns::Sequence("global|true error|estimated error"));
prm.declare_entry ("Refinement fraction", "0.3",
- ParameterHandler::RegularExpressions::Double);
+ Patterns::Double());
prm.declare_entry ("Maximum cells", "3000",
- ParameterHandler::RegularExpressions::Integer);
+ Patterns::Integer());
prm.declare_entry ("Output base filename", "");
- prm.declare_entry ("Output format", "ucd"
- "ucd\\|gnuplot");
+ prm.declare_entry ("Output format", "ucd",
+ Patterns::Sequence("ucd|gnuplot"));
};
out.add_data_vector (h1_error_per_dof, "H1-Error");
out.add_data_vector (estimated_error_per_dof, "Estimated Error");
out.add_data_vector (error_ratio, "Ratio True:Estimated Error");
- String filename = prm.get ("Output base filename");
+ string filename = prm.get ("Output base filename");
switch (refine_mode)
{
case global:
filename += ".gnuplot";
cout << " Writing error plots to <" << filename << ">..." << endl;
- ofstream outfile(filename);
+ ofstream outfile(filename.c_str());
if (prm.get("Output format")=="ucd")
out.write_ucd (outfile);
else
++refine_step;
};
- String filename = prm.get ("Output base filename");
+ string filename = prm.get ("Output base filename");
switch (refine_mode)
{
case global:
filename += "finest_mesh.gnuplot";
cout << " Wrinting finest grid to <" << filename << ">... " << endl;
- ofstream finest_mesh (filename);
+ ofstream finest_mesh (filename.c_str());
tria->print_gnuplot (finest_mesh);
finest_mesh.close();
template <int dim>
void PoissonProblem<dim>::print_history (const ParameterHandler &prm,
const RefineMode refine_mode) const {
- String filename(prm.get("Output base filename"));
+ string filename(prm.get("Output base filename"));
filename += "history.";
switch (refine_mode)
{
cout << endl << "Printing convergence history to <" << filename << ">..."
<< endl;
- ofstream out(filename);
+ ofstream out(filename.c_str());
out << "# n_dofs l2_error linfty_error "
<< "h1_error estimated_error"
<< endl;
const Triangulation<2>::cell_iterator &) const {
const vector<vector<Point<2> > >&gradients = fe_values.get_shape_grads ();
const dFMatrix &values = fe_values.get_shape_values ();
- vector<double> rhs_values;
+ vector<double> rhs_values (fe_values.n_quadrature_points);
const vector<double> &weights = fe_values.get_JxW_values ();
right_hand_side.value_list (fe_values.get_quadrature_points(), rhs_values);
*/
virtual void value_list (const vector<Point<dim> > &points,
vector<double> &values) const {
+ Assert (values.size() == points.size(),
+ ExcVectorHasWrongSize(values.size(), points.size()));
for (unsigned int i=0; i<points.size(); ++i)
- values.push_back (cos(2*3.1415926536*points[i](0)) *
- cos(2*3.1415926536*points[i](1)));
+ values[i] = (cos(2*3.1415926536*points[i](0)) *
+ cos(2*3.1415926536*points[i](1)));
};
};
void PoissonProblem<dim>::declare_parameters (ParameterHandler &prm) {
if (dim>=2)
prm.declare_entry ("Test run", "zoom in",
- "tensor\\|zoom in\\|ball\\|curved line\\|random\\|jump\\|L-region");
+ Patterns::Sequence("tensor|zoom in|ball|curved line|"
+ "random|jump|L-region"));
else
- prm.declare_entry ("Test run", "zoom in", "tensor\\|zoom in\\|random");
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("tensor|zoom in|random"));
prm.declare_entry ("Global refinement", "0",
- ParameterHandler::RegularExpressions::Integer);
+ Patterns::Integer());
prm.declare_entry ("Right hand side", "zero",
- "zero\\|constant\\|trigpoly\\|poly");
+ Patterns::Sequence("zero|constant|trigpoly|poly"));
prm.declare_entry ("Boundary values", "zero",
- "zero\\|sine\\|jump");
+ Patterns::Sequence("zero|sine|jump"));
prm.declare_entry ("Output file", "gnuplot.1");
};
template <int dim>
bool PoissonProblem<dim>::make_grid (ParameterHandler &prm) {
- String test = prm.get ("Test run");
+ string test = prm.get ("Test run");
unsigned int test_case;
if (test=="zoom in") test_case = 1;
else
template <int dim>
bool PoissonProblem<dim>::set_right_hand_side (ParameterHandler &prm) {
- String rhs_name = prm.get ("Right hand side");
+ string rhs_name = prm.get ("Right hand side");
if (rhs_name == "zero")
rhs = new ZeroFunction<dim>();
template <int dim>
bool PoissonProblem<dim>::set_boundary_values (ParameterHandler &prm) {
- String bv_name = prm.get ("Boundary values");
-
+ string bv_name = prm.get ("Boundary values");
+
if (bv_name == "zero")
boundary_values = new ZeroFunction<dim> ();
else
else
if (bv_name == "jump")
boundary_values = new BoundaryValuesJump<dim> ();
- else
- return false;
+ else
+ {
+ cout << "Unknown boundary value function " << bv_name << endl;
+ return false;
+ };
if (boundary_values != 0)
return true;
<< endl;
DataOut<dim> out;
- String o_filename = prm.get ("Output file");
- ofstream gnuplot(o_filename);
+ string o_filename = prm.get ("Output file");
+ ofstream gnuplot(o_filename.c_str());
fill_data (out);
out.write_gnuplot (gnuplot);
gnuplot.close ();
#include <grid/dof_constraints.h>
-#include <fstream.h>
+#include <fstream>
#include <cmath>
-extern "C" {
-# include <stdlib.h>
-}
-
-extern TriaActiveIterator<1,CellAccessor<1> > x;
-extern TriaActiveIterator<2,CellAccessor<2> > y;
+#include <cstdlib>
template <int dim>
void TestCases<dim>::declare_parameters (ParameterHandler &prm) {
if (dim>=2)
- prm.declare_entry ("Test run", "zoom in", "zoom in\\|ball\\|curved line\\|random");
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("zoom in|ball|curved line|random"));
else
- prm.declare_entry ("Test run", "zoom in", "zoom in\\|random");
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("zoom in|random"));
prm.declare_entry ("Grid file", "grid.1");
prm.declare_entry ("Sparsity file", "sparsity.1");
prm.declare_entry ("Condensed sparsity file", "sparsity.c.1");
cout << " Making grid..." << endl;
- String test = prm.get ("Test run");
+ string test = prm.get ("Test run");
unsigned int test_case;
if (test=="zoom in") test_case = 1;
else
// output the grid
cout << " Writing grid..." << endl;
- ofstream out(prm.get("Grid file"));
+ ofstream out(prm.get("Grid file").c_str());
tria->print_gnuplot (out);
int unconstrained_bandwidth = sparsity.bandwidth();
cout << " Writing sparsity pattern... (This may take a while)" << endl;
- ofstream sparsity_out (prm.get("Sparsity file"));
+ ofstream sparsity_out (prm.get("Sparsity file").c_str());
sparsity.print_gnuplot (sparsity_out);
constraints.condense (sparsity);
cout << " Writing condensed sparsity pattern... (This may take a while)" << endl;
- ofstream c_sparsity_out (prm.get("Condensed sparsity file"));
+ ofstream c_sparsity_out (prm.get("Condensed sparsity file").c_str());
sparsity.print_gnuplot (c_sparsity_out);
template <int dim>
void PoissonProblem<dim>::declare_parameters (ParameterHandler &prm) {
prm.declare_entry ("Test case", "Gauss shape",
- "Gauss shape\\|Singular\\|Kink");
+ Patterns::Sequence("Gauss shape|Singular|Kink"));
prm.declare_entry ("Initial refinement", "2",
- ParameterHandler::RegularExpressions::Integer);
+ Patterns::Integer());
prm.declare_entry ("Refinement criterion", "estimated error",
- "global\\|true error\\|estimated error");
+ Patterns::Sequence("global|true error|estimated error"));
prm.declare_entry ("Refinement fraction", "0.3",
- ParameterHandler::RegularExpressions::Double);
+ Patterns::Double());
prm.declare_entry ("Maximum cells", "3000",
- ParameterHandler::RegularExpressions::Integer);
+ Patterns::Integer());
prm.declare_entry ("Output base filename", "");
- prm.declare_entry ("Output format", "ucd"
- "ucd\\|gnuplot");
+ prm.declare_entry ("Output format", "ucd",
+ Patterns::Sequence("ucd|gnuplot"));
};
out.add_data_vector (h1_error_per_dof, "H1-Error");
out.add_data_vector (estimated_error_per_dof, "Estimated Error");
out.add_data_vector (error_ratio, "Ratio True:Estimated Error");
- String filename = prm.get ("Output base filename");
+ string filename = prm.get ("Output base filename");
switch (refine_mode)
{
case global:
filename += ".gnuplot";
cout << " Writing error plots to <" << filename << ">..." << endl;
- ofstream outfile(filename);
+ ofstream outfile(filename.c_str());
if (prm.get("Output format")=="ucd")
out.write_ucd (outfile);
else
++refine_step;
};
- String filename = prm.get ("Output base filename");
+ string filename = prm.get ("Output base filename");
switch (refine_mode)
{
case global:
filename += "finest_mesh.gnuplot";
cout << " Wrinting finest grid to <" << filename << ">... " << endl;
- ofstream finest_mesh (filename);
+ ofstream finest_mesh (filename.c_str());
tria->print_gnuplot (finest_mesh);
finest_mesh.close();
template <int dim>
void PoissonProblem<dim>::print_history (const ParameterHandler &prm,
const RefineMode refine_mode) const {
- String filename(prm.get("Output base filename"));
+ string filename(prm.get("Output base filename"));
filename += "history.";
switch (refine_mode)
{
cout << endl << "Printing convergence history to <" << filename << ">..."
<< endl;
- ofstream out(filename);
+ ofstream out(filename.c_str());
out << "# n_dofs l2_error linfty_error "
<< "h1_error estimated_error"
<< endl;
const Triangulation<2>::cell_iterator &) const {
const vector<vector<Point<2> > >&gradients = fe_values.get_shape_grads ();
const dFMatrix &values = fe_values.get_shape_values ();
- vector<double> rhs_values;
+ vector<double> rhs_values (fe_values.n_quadrature_points);
const vector<double> &weights = fe_values.get_JxW_values ();
right_hand_side.value_list (fe_values.get_quadrature_points(), rhs_values);
*/
virtual void value_list (const vector<Point<dim> > &points,
vector<double> &values) const {
+ Assert (values.size() == points.size(),
+ ExcVectorHasWrongSize(values.size(), points.size()));
for (unsigned int i=0; i<points.size(); ++i)
- values.push_back (cos(2*3.1415926536*points[i](0)) *
- cos(2*3.1415926536*points[i](1)));
+ values[i] = (cos(2*3.1415926536*points[i](0)) *
+ cos(2*3.1415926536*points[i](1)));
};
};
void PoissonProblem<dim>::declare_parameters (ParameterHandler &prm) {
if (dim>=2)
prm.declare_entry ("Test run", "zoom in",
- "tensor\\|zoom in\\|ball\\|curved line\\|random\\|jump\\|L-region");
+ Patterns::Sequence("tensor|zoom in|ball|curved line|"
+ "random|jump|L-region"));
else
- prm.declare_entry ("Test run", "zoom in", "tensor\\|zoom in\\|random");
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("tensor|zoom in|random"));
prm.declare_entry ("Global refinement", "0",
- ParameterHandler::RegularExpressions::Integer);
+ Patterns::Integer());
prm.declare_entry ("Right hand side", "zero",
- "zero\\|constant\\|trigpoly\\|poly");
+ Patterns::Sequence("zero|constant|trigpoly|poly"));
prm.declare_entry ("Boundary values", "zero",
- "zero\\|sine\\|jump");
+ Patterns::Sequence("zero|sine|jump"));
prm.declare_entry ("Output file", "gnuplot.1");
};
template <int dim>
bool PoissonProblem<dim>::make_grid (ParameterHandler &prm) {
- String test = prm.get ("Test run");
+ string test = prm.get ("Test run");
unsigned int test_case;
if (test=="zoom in") test_case = 1;
else
template <int dim>
bool PoissonProblem<dim>::set_right_hand_side (ParameterHandler &prm) {
- String rhs_name = prm.get ("Right hand side");
+ string rhs_name = prm.get ("Right hand side");
if (rhs_name == "zero")
rhs = new ZeroFunction<dim>();
template <int dim>
bool PoissonProblem<dim>::set_boundary_values (ParameterHandler &prm) {
- String bv_name = prm.get ("Boundary values");
-
+ string bv_name = prm.get ("Boundary values");
+
if (bv_name == "zero")
boundary_values = new ZeroFunction<dim> ();
else
else
if (bv_name == "jump")
boundary_values = new BoundaryValuesJump<dim> ();
- else
- return false;
+ else
+ {
+ cout << "Unknown boundary value function " << bv_name << endl;
+ return false;
+ };
if (boundary_values != 0)
return true;
<< endl;
DataOut<dim> out;
- String o_filename = prm.get ("Output file");
- ofstream gnuplot(o_filename);
+ string o_filename = prm.get ("Output file");
+ ofstream gnuplot(o_filename.c_str());
fill_data (out);
out.write_gnuplot (gnuplot);
gnuplot.close ();