Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format prototypes via indentation scripts #1213

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions contrib/utilities/indent
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,29 @@ checks
# Process all source and header files:
#

process_changed "tests include source examples cmake/scripts contrib/python-bindings" ".*\.(cc|h)" format_file
process_changed "tests include source examples prototypes" ".*\.(cc|h)" format_file
process_changed "source" ".*\.inst.in" format_inst

#
# Fix permissions and convert to unix line ending if necessary:
#

process_changed "tests include source examples cmake/scripts contrib/python-bindings" \
process_changed "tests include source examples prototypes" \
".*\.(cc|h|inst.in|output.*|cmake)" fix_permissions

process_changed "tests include source examples cmake/scripts contrib/python-bindings" \
process_changed "tests include source examples prototypes" \
".*\.(cc|h|inst.in|cmake)" dos_to_unix

#
# Removing trailing whitespace
#

process_changed "tests include source examples cmake/scripts contrib/python-bindings doc" \
process_changed "tests include source examples prototypes doc" \
".*\.(cc|h|html|dox|txt)" remove_trailing_whitespace

#
# Ensure only a single newline at end of files
#

process_changed "tests include source examples cmake/scripts contrib/python-bindings doc" \
process_changed "tests include source examples prototypes doc" \
".*\.(cc|h|html|dox|txt)" ensure_single_trailing_newline
10 changes: 5 additions & 5 deletions contrib/utilities/indent-all
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,28 @@ checks
# Process all source and header files:
#

process "tests applications include source" ".*\.(cc|h)" format_file
process "tests include source examples prototypes" ".*\.(cc|h)" format_file

#
# Fix permissions and convert to unix line ending if necessary:
#

process "tests applications include source examples" \
process "tests include source examples prototypes" \
".*\.(cc|h|inst.in|output.*|cmake)" fix_permissions

process "tests applications include source examples" \
process "tests include source examples prototypes" \
".*\.(cc|h|inst.in|cmake)" dos_to_unix

#
# Removing trailing whitespace
#

process "tests applications include source doc" \
process "tests include source examples prototypes doc" \
".*\.(cc|h|html|dox|txt)" remove_trailing_whitespace

#
# Ensure only a single newline at end of files
#

process "tests applications include source doc" \
process "tests include source examples prototypes doc" \
".*\.(cc|h|html|dox|txt)" ensure_single_trailing_newline
118 changes: 64 additions & 54 deletions prototypes/chorin_navier_stokes/boundaryconditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,44 @@ template <int dim>
class RotatingWall : public Function<dim>
{
public:
RotatingWall () : Function<dim>(dim+1) {}
RotatingWall()
: Function<dim>(dim + 1)
{}

virtual double value (const Point<dim> &p,
const unsigned int component ) const;
virtual double
value(const Point<dim> &p, const unsigned int component) const;
};


template <int dim>
double RotatingWall<dim>::value (const Point<dim> &p,
const unsigned int component) const
double
RotatingWall<dim>::value(const Point<dim> &p,
const unsigned int component) const
{
Assert (component < this->n_components,
ExcIndexRange (component, 0, this->n_components))
Assert(component < this->n_components,
ExcIndexRange(component, 0, this->n_components))

if (component==0)
return -p[1];
else if(component==1)
return p[0];
return 0.;
if (component == 0) return -p[1];
else if (component == 1) return p[0];
return 0.;
}

template <int dim>
class PoiseuilleInlet : public Function<dim>
{
public:
PoiseuilleInlet () : Function<dim>(dim+1)
PoiseuilleInlet()
: Function<dim>(dim + 1)
{
y2_=1.;
y1_=0.;
dy_= 0.5*(y2_ + y1_);
vmax_=1./dy_/dy_;
y2_ = 1.;
y1_ = 0.;
dy_ = 0.5 * (y2_ + y1_);
vmax_ = 1. / dy_ / dy_;
};

virtual double value (const Point<dim> &p,
const unsigned int component ) const;
virtual double
value(const Point<dim> &p, const unsigned int component) const;

private:
double y2_;
double y1_;
Expand All @@ -49,84 +52,91 @@ class PoiseuilleInlet : public Function<dim>


template <int dim>
double PoiseuilleInlet<dim>::value (const Point<dim> &p,
const unsigned int component) const
double
PoiseuilleInlet<dim>::value(const Point<dim> &p,
const unsigned int component) const
{
Assert (component < this->n_components,
ExcIndexRange (component, 0, this->n_components));
Assert(component < this->n_components,
ExcIndexRange(component, 0, this->n_components));

double y=p[1];
double y = p[1];

if (component==0)
if (component == 0)
{
return vmax_ *(y-y1_)*(y2_-y);
return vmax_ * (y - y1_) * (y2_ - y);
}
else if(component==1)
return 0.;
else if (component == 1)
return 0.;
return 0.;
}


template <int dim>
class ConstantXInlet : public Function<dim>
{
public:
ConstantXInlet () : Function<dim>(dim+1)
ConstantXInlet()
: Function<dim>(dim + 1)
{
value_=1.;
value_ = 1.;
};

virtual double value (const Point<dim> &p,
const unsigned int component ) const;
virtual double
value(const Point<dim> &p, const unsigned int component) const;

private:
double value_;
double value_;
};


template <int dim>
double ConstantXInlet<dim>::value (const Point<dim> &/*p*/,
const unsigned int component) const
double
ConstantXInlet<dim>::value(const Point<dim> & /*p*/,
const unsigned int component) const
{
Assert (component < this->n_components,
ExcIndexRange (component, 0, this->n_components));
Assert(component < this->n_components,
ExcIndexRange(component, 0, this->n_components));

if (component==0)
if (component == 0)
{
return value_;
return value_;
}
else if(component==1)
return 0.;
else if (component == 1)
return 0.;
return 0.;
}

template <int dim>
class ConstantXSlip : public Function<dim>
{
public:
ConstantXSlip () : Function<dim>(dim+1)
ConstantXSlip()
: Function<dim>(dim + 1)
{
value_=1.;
value_ = 1.;
};

virtual double value (const Point<dim> &p,
const unsigned int component ) const;
virtual double
value(const Point<dim> &p, const unsigned int component) const;

private:
double value_;
double value_;
};


template <int dim>
double ConstantXSlip<dim>::value (const Point<dim> &p,
const unsigned int component) const
double
ConstantXSlip<dim>::value(const Point<dim> &p,
const unsigned int component) const
{
Assert (component < this->n_components,
ExcIndexRange (component, 0, this->n_components));
Assert(component < this->n_components,
ExcIndexRange(component, 0, this->n_components));

if (component==0)
if (component == 0)
{
return value_;
return value_;
}
else if(component==1)
return 0.;
else if (component == 1)
return 0.;
return 0.;
}
10 changes: 5 additions & 5 deletions prototypes/chorin_navier_stokes/chorin_navier_stokes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
#include <deal.II/numerics/solution_transfer.h>
#include <deal.II/numerics/vector_tools.h>

//#include "boundaryconditions.h"
//#include "exactsolutions.h"
//#include "forcingfunctions.h"
// #include "boundaryconditions.h"
// #include "exactsolutions.h"
// #include "forcingfunctions.h"

#include <cmath>
#include <fstream>
Expand Down Expand Up @@ -115,7 +115,7 @@ class MMSSineForcingFunction : public Function<dim>
template <int dim>
void
MMSSineForcingFunction<dim>::vector_value(const Point<dim> &p,
Vector<double> & values) const
Vector<double> &values) const
{
assert(dim == 2);
const double a = M_PI;
Expand Down Expand Up @@ -168,7 +168,7 @@ class ExactSolutionMMS : public Function<dim>
template <int dim>
void
ExactSolutionMMS<dim>::vector_value(const Point<dim> &p,
Vector<double> & values) const
Vector<double> &values) const
{
const double a = M_PI;
double x = p[0];
Expand Down
82 changes: 44 additions & 38 deletions prototypes/chorin_navier_stokes/exactsolutions.h
Original file line number Diff line number Diff line change
@@ -1,58 +1,64 @@
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/function.h>
#include <deal.II/base/quadrature_lib.h>

#include <deal.II/lac/vector.h>

using namespace dealii;

template<int dim>
template <int dim>
class ExactSolutionMMS : public Function<dim>
{
public:
ExactSolutionMMS() : Function<dim>(3) {}
virtual void vector_value(const Point<dim> &p,
Vector<double> &values) const;
ExactSolutionMMS()
: Function<dim>(3)
{}
virtual void
vector_value(const Point<dim> &p, Vector<double> &values) const;
};
template<int dim>
void ExactSolutionMMS<dim>::vector_value(const Point<dim> &p,
Vector<double> &values) const
template <int dim>
void
ExactSolutionMMS<dim>::vector_value(const Point<dim> &p,
Vector<double> &values) const
{
const double a = M_PI;
double x = p[0];
double y = p[1];
values(0) = sin(a*x)*sin(a*x)*cos(a*y)*sin(a*y);
values(1) = -cos(a*x)*sin(a*x)*sin(a*y)*sin(a*y);
values(2) = -2 + x*x + y*y;
const double a = M_PI;
double x = p[0];
double y = p[1];
values(0) = sin(a * x) * sin(a * x) * cos(a * y) * sin(a * y);
values(1) = -cos(a * x) * sin(a * x) * sin(a * y) * sin(a * y);
values(2) = -2 + x * x + y * y;
}

template<int dim>
template <int dim>
class ExactSolutionTaylorCouette : public Function<dim>
{
public:
ExactSolutionTaylorCouette() : Function<dim>(3)
{
eta_=0.25;
ri_=0.25;
}
virtual void vector_value(const Point<dim> &p,
Vector<double> &values) const;
ExactSolutionTaylorCouette()
: Function<dim>(3)
{
eta_ = 0.25;
ri_ = 0.25;
}
virtual void
vector_value(const Point<dim> &p, Vector<double> &values) const;

private:
double eta_;
double ri_=0.25;
double eta_;
double ri_ = 0.25;
};
template<int dim>
void ExactSolutionTaylorCouette<dim>::vector_value(const Point<dim> &p,
Vector<double> &values) const
template <int dim>
void
ExactSolutionTaylorCouette<dim>::vector_value(const Point<dim> &p,
Vector<double> &values) const
{
const double a = M_PI;
double x = p[0];
double y = p[1];
double r= std::sqrt(x*x+y*y);
double theta= std::atan2(y,x);
double A= -(eta_*eta_)/(1.-eta_*eta_);
double B= ri_ * ri_ / (1.-eta_*eta_);
double utheta= A*r + B/r;
values(0) = -std::sin(theta)*utheta;
values(1) = std::cos(theta)*utheta;
values(2) = 0.;
const double a = M_PI;
double x = p[0];
double y = p[1];
double r = std::sqrt(x * x + y * y);
double theta = std::atan2(y, x);
double A = -(eta_ * eta_) / (1. - eta_ * eta_);
double B = ri_ * ri_ / (1. - eta_ * eta_);
double utheta = A * r + B / r;
values(0) = -std::sin(theta) * utheta;
values(1) = std::cos(theta) * utheta;
values(2) = 0.;
}
Loading
Loading