diff --git a/contrib/utilities/indent b/contrib/utilities/indent index 51deef2d08..4965c36f9a 100755 --- a/contrib/utilities/indent +++ b/contrib/utilities/indent @@ -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 diff --git a/contrib/utilities/indent-all b/contrib/utilities/indent-all index 7ae0ab7e9e..7f69c6aaee 100755 --- a/contrib/utilities/indent-all +++ b/contrib/utilities/indent-all @@ -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 diff --git a/prototypes/chorin_navier_stokes/boundaryconditions.h b/prototypes/chorin_navier_stokes/boundaryconditions.h index 5bf65898ef..9f42113c6d 100644 --- a/prototypes/chorin_navier_stokes/boundaryconditions.h +++ b/prototypes/chorin_navier_stokes/boundaryconditions.h @@ -5,41 +5,44 @@ template class RotatingWall : public Function { public: - RotatingWall () : Function(dim+1) {} + RotatingWall() + : Function(dim + 1) + {} - virtual double value (const Point &p, - const unsigned int component ) const; + virtual double + value(const Point &p, const unsigned int component) const; }; template -double RotatingWall::value (const Point &p, - const unsigned int component) const +double +RotatingWall::value(const Point &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 class PoiseuilleInlet : public Function { public: - PoiseuilleInlet () : Function(dim+1) + PoiseuilleInlet() + : Function(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 &p, - const unsigned int component ) const; + virtual double + value(const Point &p, const unsigned int component) const; + private: double y2_; double y1_; @@ -49,21 +52,22 @@ class PoiseuilleInlet : public Function template -double PoiseuilleInlet::value (const Point &p, - const unsigned int component) const +double +PoiseuilleInlet::value(const Point &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.; } @@ -71,62 +75,68 @@ template class ConstantXInlet : public Function { public: - ConstantXInlet () : Function(dim+1) + ConstantXInlet() + : Function(dim + 1) { - value_=1.; + value_ = 1.; }; - virtual double value (const Point &p, - const unsigned int component ) const; + virtual double + value(const Point &p, const unsigned int component) const; + private: - double value_; + double value_; }; template -double ConstantXInlet::value (const Point &/*p*/, - const unsigned int component) const +double +ConstantXInlet::value(const Point & /*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 class ConstantXSlip : public Function { public: - ConstantXSlip () : Function(dim+1) + ConstantXSlip() + : Function(dim + 1) { - value_=1.; + value_ = 1.; }; - virtual double value (const Point &p, - const unsigned int component ) const; + virtual double + value(const Point &p, const unsigned int component) const; + private: - double value_; + double value_; }; template -double ConstantXSlip::value (const Point &p, - const unsigned int component) const +double +ConstantXSlip::value(const Point &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.; } diff --git a/prototypes/chorin_navier_stokes/chorin_navier_stokes.cc b/prototypes/chorin_navier_stokes/chorin_navier_stokes.cc index 9babff3445..1ffc21a2bf 100644 --- a/prototypes/chorin_navier_stokes/chorin_navier_stokes.cc +++ b/prototypes/chorin_navier_stokes/chorin_navier_stokes.cc @@ -60,9 +60,9 @@ #include #include -//#include "boundaryconditions.h" -//#include "exactsolutions.h" -//#include "forcingfunctions.h" +// #include "boundaryconditions.h" +// #include "exactsolutions.h" +// #include "forcingfunctions.h" #include #include @@ -115,7 +115,7 @@ class MMSSineForcingFunction : public Function template void MMSSineForcingFunction::vector_value(const Point &p, - Vector & values) const + Vector &values) const { assert(dim == 2); const double a = M_PI; @@ -168,7 +168,7 @@ class ExactSolutionMMS : public Function template void ExactSolutionMMS::vector_value(const Point &p, - Vector & values) const + Vector &values) const { const double a = M_PI; double x = p[0]; diff --git a/prototypes/chorin_navier_stokes/exactsolutions.h b/prototypes/chorin_navier_stokes/exactsolutions.h index 6565e93fba..9aaf7fa08a 100644 --- a/prototypes/chorin_navier_stokes/exactsolutions.h +++ b/prototypes/chorin_navier_stokes/exactsolutions.h @@ -1,58 +1,64 @@ -#include #include +#include + #include using namespace dealii; -template +template class ExactSolutionMMS : public Function { public: - ExactSolutionMMS() : Function(3) {} - virtual void vector_value(const Point &p, - Vector &values) const; + ExactSolutionMMS() + : Function(3) + {} + virtual void + vector_value(const Point &p, Vector &values) const; }; -template -void ExactSolutionMMS::vector_value(const Point &p, - Vector &values) const +template +void +ExactSolutionMMS::vector_value(const Point &p, + Vector &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 +template class ExactSolutionTaylorCouette : public Function { public: - ExactSolutionTaylorCouette() : Function(3) - { - eta_=0.25; - ri_=0.25; - } - virtual void vector_value(const Point &p, - Vector &values) const; + ExactSolutionTaylorCouette() + : Function(3) + { + eta_ = 0.25; + ri_ = 0.25; + } + virtual void + vector_value(const Point &p, Vector &values) const; private: - double eta_; - double ri_=0.25; + double eta_; + double ri_ = 0.25; }; -template -void ExactSolutionTaylorCouette::vector_value(const Point &p, - Vector &values) const +template +void +ExactSolutionTaylorCouette::vector_value(const Point &p, + Vector &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.; } diff --git a/prototypes/chorin_navier_stokes/forcingfunctions.h b/prototypes/chorin_navier_stokes/forcingfunctions.h index c6196ebcf8..352f1151e0 100644 --- a/prototypes/chorin_navier_stokes/forcingfunctions.h +++ b/prototypes/chorin_navier_stokes/forcingfunctions.h @@ -3,50 +3,54 @@ // Finally, this is as in previous programs: using namespace dealii; -template +template class MMSSineForcingFunction : public Function { public: - MMSSineForcingFunction() : Function(3) {}; - virtual void vector_value(const Point &p, - Vector &values) const; + MMSSineForcingFunction() + : Function(3){}; + virtual void + vector_value(const Point &p, Vector &values) const; }; -template -void MMSSineForcingFunction::vector_value(const Point &p, - Vector &values) const +template +void +MMSSineForcingFunction::vector_value(const Point &p, + Vector &values) const { - assert(dim==2); - const double a = M_PI; - - double x = p[0]; - double y = p[1]; - values(0) = (2*a*a*(-sin(a*x)*sin(a*x) + - cos(a*x)*(cos(a*x)))*sin(a*y)*cos(a*y) - - 4*a*a*sin(a*x)*sin(a*x)*sin(a*y)*cos(a*y) - - 2.0*x)*(-1.) - + a*std::pow(sin(a*x),3.) * std::pow(sin(a*y),2.) * std::cos(a*x); - values(1) = (2*a*a*(sin(a*y)*(sin(a*y)) - cos(a*y)*cos(a*y)) - *sin(a*x)*cos(a*x) + 4*a*a*sin(a*x)*sin(a*y)*sin(a*y) - *cos(a*x) - 2.0*y)*(-1) - + a*std::pow(sin(a*x),2.) * std::pow(sin(a*y),3.) * std::cos(a*y); - + assert(dim == 2); + const double a = M_PI; + double x = p[0]; + double y = p[1]; + values(0) = + (2 * a * a * (-sin(a * x) * sin(a * x) + cos(a * x) * (cos(a * x))) * + sin(a * y) * cos(a * y) - + 4 * a * a * sin(a * x) * sin(a * x) * sin(a * y) * cos(a * y) - 2.0 * x) * + (-1.) + + a * std::pow(sin(a * x), 3.) * std::pow(sin(a * y), 2.) * std::cos(a * x); + values(1) = + (2 * a * a * (sin(a * y) * (sin(a * y)) - cos(a * y) * cos(a * y)) * + sin(a * x) * cos(a * x) + + 4 * a * a * sin(a * x) * sin(a * y) * sin(a * y) * cos(a * x) - 2.0 * y) * + (-1) + + a * std::pow(sin(a * x), 2.) * std::pow(sin(a * y), 3.) * std::cos(a * y); } -template +template class NoForce : public Function { public: - NoForce() : Function(3) {}; - virtual void vector_value(const Point &p, - Vector &values) const; + NoForce() + : Function(3){}; + virtual void + vector_value(const Point &p, Vector &values) const; }; -template -void NoForce::vector_value(const Point &/*p*/, - Vector &values) const +template +void +NoForce::vector_value(const Point & /*p*/, + Vector &values) const { - assert(dim==2); - values(0) = 0.; - values(1) = 0.; - + assert(dim == 2); + values(0) = 0.; + values(1) = 0.; } diff --git a/prototypes/dg_advection_diffusion_equation/dg_advection_diffusion_equation.cc b/prototypes/dg_advection_diffusion_equation/dg_advection_diffusion_equation.cc index ccc197cffd..f7dd42026a 100644 --- a/prototypes/dg_advection_diffusion_equation/dg_advection_diffusion_equation.cc +++ b/prototypes/dg_advection_diffusion_equation/dg_advection_diffusion_equation.cc @@ -73,7 +73,7 @@ enum simCase template struct ScratchData { - ScratchData(const Mapping & mapping, + ScratchData(const Mapping &mapping, const FiniteElement &fe, const unsigned int quadrature_degree, const UpdateFlags update_flags = update_values | @@ -215,7 +215,7 @@ class VelocityFieldMMS : public Function template double -VelocityFieldMMS::value(const Point & p, +VelocityFieldMMS::value(const Point &p, const unsigned int component) const { double x = p(0); @@ -250,7 +250,7 @@ class VelocityFieldSmithHutton : public Function template double -VelocityFieldSmithHutton::value(const Point & p, +VelocityFieldSmithHutton::value(const Point &p, const unsigned int component) const { double x = p(0); @@ -419,16 +419,16 @@ DGAdvectionDiffusion::assemble_system() using Iterator = typename DoFHandler::active_cell_iterator; const BoundaryValues boundary_function; - auto cell_worker = [&](const Iterator & cell, + auto cell_worker = [&](const Iterator &cell, ScratchData &scratch_data, - CopyData & copy_data) { + CopyData ©_data) { const unsigned int n_dofs = scratch_data.fe_values.get_fe().dofs_per_cell; copy_data.reinit(cell, n_dofs); scratch_data.fe_values.reinit(cell); const auto &q_points = scratch_data.fe_values.get_quadrature_points(); - const FEValues & fe_v = scratch_data.fe_values; + const FEValues &fe_v = scratch_data.fe_values; const std::vector &JxW = fe_v.get_JxW_values(); std::vector f(q_points.size()); @@ -470,16 +470,16 @@ DGAdvectionDiffusion::assemble_system() } }; - auto boundary_worker = [&](const Iterator & cell, + auto boundary_worker = [&](const Iterator &cell, const unsigned int &face_no, - ScratchData & scratch_data, - CopyData & copy_data) { + ScratchData &scratch_data, + CopyData ©_data) { scratch_data.fe_interface_values.reinit(cell, face_no); const FEFaceValuesBase &fe_face = scratch_data.fe_interface_values.get_fe_face_values(0); - const auto & q_points = fe_face.get_quadrature_points(); + const auto &q_points = fe_face.get_quadrature_points(); const unsigned int n_facet_dofs = fe_face.get_fe().n_dofs_per_cell(); const std::vector &JxW = fe_face.get_JxW_values(); @@ -609,14 +609,14 @@ DGAdvectionDiffusion::assemble_system() } }; - auto face_worker = [&](const Iterator & cell, + auto face_worker = [&](const Iterator &cell, const unsigned int &f, const unsigned int &sf, - const Iterator & ncell, + const Iterator &ncell, const unsigned int &nf, const unsigned int &nsf, - ScratchData & scratch_data, - CopyData & copy_data) { + ScratchData &scratch_data, + CopyData ©_data) { FEInterfaceValues &fe_iv = scratch_data.fe_interface_values; fe_iv.reinit(cell, f, sf, ncell, nf, nsf); @@ -631,7 +631,7 @@ DGAdvectionDiffusion::assemble_system() copy_data_face.cell_matrix.reinit(n_dofs, n_dofs); - const std::vector & JxW = fe_iv.get_JxW_values(); + const std::vector &JxW = fe_iv.get_JxW_values(); const std::vector> &normals = fe_iv.get_normal_vectors(); std::vector> velocity_list(q_points.size(), diff --git a/prototypes/dg_heat_equation/dg_heat_equation.cc b/prototypes/dg_heat_equation/dg_heat_equation.cc index c5a63858b2..95dccdf902 100644 --- a/prototypes/dg_heat_equation/dg_heat_equation.cc +++ b/prototypes/dg_heat_equation/dg_heat_equation.cc @@ -69,7 +69,7 @@ enum simCase template struct ScratchData { - ScratchData(const Mapping & mapping, + ScratchData(const Mapping &mapping, const FiniteElement &fe, const unsigned int quadrature_degree, const UpdateFlags update_flags = update_values | @@ -318,16 +318,16 @@ DGHeat::assemble_system() using Iterator = typename DoFHandler::active_cell_iterator; const BoundaryValues boundary_function; - auto cell_worker = [&](const Iterator & cell, + auto cell_worker = [&](const Iterator &cell, ScratchData &scratch_data, - CopyData & copy_data) { + CopyData ©_data) { const unsigned int n_dofs = scratch_data.fe_values.get_fe().dofs_per_cell; copy_data.reinit(cell, n_dofs); scratch_data.fe_values.reinit(cell); const auto &q_points = scratch_data.fe_values.get_quadrature_points(); - const FEValues & fe_v = scratch_data.fe_values; + const FEValues &fe_v = scratch_data.fe_values; const std::vector &JxW = fe_v.get_JxW_values(); std::vector f(q_points.size()); @@ -353,16 +353,16 @@ DGHeat::assemble_system() } }; - auto boundary_worker = [&](const Iterator & cell, + auto boundary_worker = [&](const Iterator &cell, const unsigned int &face_no, - ScratchData & scratch_data, - CopyData & copy_data) { + ScratchData &scratch_data, + CopyData ©_data) { scratch_data.fe_interface_values.reinit(cell, face_no); const FEFaceValuesBase &fe_face = scratch_data.fe_interface_values.get_fe_face_values(0); - const auto & q_points = fe_face.get_quadrature_points(); + const auto &q_points = fe_face.get_quadrature_points(); const unsigned int n_facet_dofs = fe_face.get_fe().n_dofs_per_cell(); const std::vector &JxW = fe_face.get_JxW_values(); @@ -420,14 +420,14 @@ DGHeat::assemble_system() } }; - auto face_worker = [&](const Iterator & cell, + auto face_worker = [&](const Iterator &cell, const unsigned int &f, const unsigned int &sf, - const Iterator & ncell, + const Iterator &ncell, const unsigned int &nf, const unsigned int &nsf, - ScratchData & scratch_data, - CopyData & copy_data) { + ScratchData &scratch_data, + CopyData ©_data) { FEInterfaceValues &fe_iv = scratch_data.fe_interface_values; fe_iv.reinit(cell, f, sf, ncell, nf, nsf); @@ -442,7 +442,7 @@ DGHeat::assemble_system() copy_data_face.cell_matrix.reinit(n_dofs, n_dofs); - const std::vector & JxW = fe_iv.get_JxW_values(); + const std::vector &JxW = fe_iv.get_JxW_values(); const std::vector> &normals = fe_iv.get_normal_vectors(); diff --git a/prototypes/direct_gls_navier_stokes/boundaryconditions.h b/prototypes/direct_gls_navier_stokes/boundaryconditions.h index dc0520938e..0f0d9aa583 100644 --- a/prototypes/direct_gls_navier_stokes/boundaryconditions.h +++ b/prototypes/direct_gls_navier_stokes/boundaryconditions.h @@ -5,41 +5,46 @@ template class RotatingWall : public Function { public: - RotatingWall () : Function(dim+1) {} + RotatingWall() + : Function(dim + 1) + {} - virtual double value (const Point &p, - const unsigned int component ) const override; + virtual double + value(const Point &p, const unsigned int component) const override; }; template -double RotatingWall::value (const Point &p, - const unsigned int component) const +double +RotatingWall::value(const Point &p, + const unsigned int component) const { - 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.; + 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.; } template class PoiseuilleInlet : public Function { public: - PoiseuilleInlet () : Function(dim+1) + PoiseuilleInlet() + : Function(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 &p, - const unsigned int component ) const; + virtual double + value(const Point &p, const unsigned int component) const; + private: double y2_; double y1_; @@ -49,21 +54,22 @@ class PoiseuilleInlet : public Function template -double PoiseuilleInlet::value (const Point &p, - const unsigned int component) const +double +PoiseuilleInlet::value(const Point &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.; } @@ -71,62 +77,68 @@ template class ConstantXInlet : public Function { public: - ConstantXInlet () : Function(dim+1) + ConstantXInlet() + : Function(dim + 1) { - value_=1.; + value_ = 1.; }; - virtual double value (const Point &p, - const unsigned int component ) const; + virtual double + value(const Point &p, const unsigned int component) const; + private: - double value_; + double value_; }; template -double ConstantXInlet::value (const Point &/*p*/, - const unsigned int component) const +double +ConstantXInlet::value(const Point & /*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 class ConstantXSlip : public Function { public: - ConstantXSlip () : Function(dim+1) + ConstantXSlip() + : Function(dim + 1) { - value_=1.; + value_ = 1.; }; - virtual double value (const Point &p, - const unsigned int component ) const; + virtual double + value(const Point &p, const unsigned int component) const; + private: - double value_; + double value_; }; template -double ConstantXSlip::value (const Point &p, - const unsigned int component) const +double +ConstantXSlip::value(const Point &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.; } diff --git a/prototypes/direct_gls_navier_stokes/exactsolutions.h b/prototypes/direct_gls_navier_stokes/exactsolutions.h index 2c3a343e9d..14f2dc8f91 100644 --- a/prototypes/direct_gls_navier_stokes/exactsolutions.h +++ b/prototypes/direct_gls_navier_stokes/exactsolutions.h @@ -1,58 +1,64 @@ -#include #include +#include + #include using namespace dealii; -template +template class ExactSolutionMMS : public Function { public: - ExactSolutionMMS() : Function(3) {} - virtual void vector_value(const Point &p, - Vector &values) const override; + ExactSolutionMMS() + : Function(3) + {} + virtual void + vector_value(const Point &p, Vector &values) const override; }; -template -void ExactSolutionMMS::vector_value(const Point &p, - Vector &values) const +template +void +ExactSolutionMMS::vector_value(const Point &p, + Vector &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 +template class ExactSolutionTaylorCouette : public Function { public: - ExactSolutionTaylorCouette() : Function(3) - { - eta_=0.25; - ri_=0.25; - } - virtual void vector_value(const Point &p, - Vector &values) const; + ExactSolutionTaylorCouette() + : Function(3) + { + eta_ = 0.25; + ri_ = 0.25; + } + virtual void + vector_value(const Point &p, Vector &values) const; private: - double eta_; - double ri_=0.25; + double eta_; + double ri_ = 0.25; }; -template -void ExactSolutionTaylorCouette::vector_value(const Point &p, - Vector &values) const +template +void +ExactSolutionTaylorCouette::vector_value(const Point &p, + Vector &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.; } diff --git a/prototypes/direct_gls_navier_stokes/forcingfunctions.h b/prototypes/direct_gls_navier_stokes/forcingfunctions.h index 57e466f2a3..b608a5a6dd 100644 --- a/prototypes/direct_gls_navier_stokes/forcingfunctions.h +++ b/prototypes/direct_gls_navier_stokes/forcingfunctions.h @@ -3,50 +3,54 @@ // Finally, this is as in previous programs: using namespace dealii; -template +template class MMSSineForcingFunction : public Function { public: - MMSSineForcingFunction() : Function(3) {}; - virtual void vector_value(const Point &p, - Vector &values) const override; + MMSSineForcingFunction() + : Function(3){}; + virtual void + vector_value(const Point &p, Vector &values) const override; }; -template -void MMSSineForcingFunction::vector_value(const Point &p, - Vector &values) const +template +void +MMSSineForcingFunction::vector_value(const Point &p, + Vector &values) const { - assert(dim==2); - const double a = M_PI; - - double x = p[0]; - double y = p[1]; - values(0) = (2*a*a*(-sin(a*x)*sin(a*x) + - cos(a*x)*(cos(a*x)))*sin(a*y)*cos(a*y) - - 4*a*a*sin(a*x)*sin(a*x)*sin(a*y)*cos(a*y) - - 2.0*x)*(-1.) - + a*std::pow(sin(a*x),3.) * std::pow(sin(a*y),2.) * std::cos(a*x); - values(1) = (2*a*a*(sin(a*y)*(sin(a*y)) - cos(a*y)*cos(a*y)) - *sin(a*x)*cos(a*x) + 4*a*a*sin(a*x)*sin(a*y)*sin(a*y) - *cos(a*x) - 2.0*y)*(-1) - + a*std::pow(sin(a*x),2.) * std::pow(sin(a*y),3.) * std::cos(a*y); - + assert(dim == 2); + const double a = M_PI; + double x = p[0]; + double y = p[1]; + values(0) = + (2 * a * a * (-sin(a * x) * sin(a * x) + cos(a * x) * (cos(a * x))) * + sin(a * y) * cos(a * y) - + 4 * a * a * sin(a * x) * sin(a * x) * sin(a * y) * cos(a * y) - 2.0 * x) * + (-1.) + + a * std::pow(sin(a * x), 3.) * std::pow(sin(a * y), 2.) * std::cos(a * x); + values(1) = + (2 * a * a * (sin(a * y) * (sin(a * y)) - cos(a * y) * cos(a * y)) * + sin(a * x) * cos(a * x) + + 4 * a * a * sin(a * x) * sin(a * y) * sin(a * y) * cos(a * x) - 2.0 * y) * + (-1) + + a * std::pow(sin(a * x), 2.) * std::pow(sin(a * y), 3.) * std::cos(a * y); } -template +template class NoForce : public Function { public: - NoForce() : Function(3) {}; - virtual void vector_value(const Point &p, - Vector &values) const; + NoForce() + : Function(3){}; + virtual void + vector_value(const Point &p, Vector &values) const; }; -template -void NoForce::vector_value(const Point &/*p*/, - Vector &values) const +template +void +NoForce::vector_value(const Point & /*p*/, + Vector &values) const { - assert(dim==2); - values(0) = 0.; - values(1) = 0.; - + assert(dim == 2); + values(0) = 0.; + values(1) = 0.; } diff --git a/prototypes/direct_steady_navier_stokes/boundaryconditions.h b/prototypes/direct_steady_navier_stokes/boundaryconditions.h index bc1be06bfd..0f0d9aa583 100644 --- a/prototypes/direct_steady_navier_stokes/boundaryconditions.h +++ b/prototypes/direct_steady_navier_stokes/boundaryconditions.h @@ -16,16 +16,16 @@ class RotatingWall : public Function template double -RotatingWall::value(const Point & p, +RotatingWall::value(const Point &p, const unsigned int component) const { Assert(component < this->n_components, ExcIndexRange(component, 0, this->n_components)); - if (component == 0) - return -p[1]; - else if (component == 1) - return p[0]; + if (component == 0) + return -p[1]; + else if (component == 1) + return p[0]; return 0.; } @@ -55,7 +55,7 @@ class PoiseuilleInlet : public Function template double -PoiseuilleInlet::value(const Point & p, +PoiseuilleInlet::value(const Point &p, const unsigned int component) const { Assert(component < this->n_components, @@ -128,7 +128,7 @@ class ConstantXSlip : public Function template double -ConstantXSlip::value(const Point & p, +ConstantXSlip::value(const Point &p, const unsigned int component) const { Assert(component < this->n_components, diff --git a/prototypes/direct_steady_navier_stokes/exactsolutions.h b/prototypes/direct_steady_navier_stokes/exactsolutions.h index e1d76e6897..14f2dc8f91 100644 --- a/prototypes/direct_steady_navier_stokes/exactsolutions.h +++ b/prototypes/direct_steady_navier_stokes/exactsolutions.h @@ -18,7 +18,7 @@ class ExactSolutionMMS : public Function template void ExactSolutionMMS::vector_value(const Point &p, - Vector & values) const + Vector &values) const { const double a = M_PI; double x = p[0]; @@ -48,7 +48,7 @@ class ExactSolutionTaylorCouette : public Function template void ExactSolutionTaylorCouette::vector_value(const Point &p, - Vector & values) const + Vector &values) const { const double a = M_PI; double x = p[0]; diff --git a/prototypes/direct_steady_navier_stokes/forcingfunctions.h b/prototypes/direct_steady_navier_stokes/forcingfunctions.h index fdca8c8e08..9177046f06 100644 --- a/prototypes/direct_steady_navier_stokes/forcingfunctions.h +++ b/prototypes/direct_steady_navier_stokes/forcingfunctions.h @@ -15,7 +15,7 @@ class MMSSineForcingFunction : public Function template void MMSSineForcingFunction::vector_value(const Point &p, - Vector & values) const + Vector &values) const { assert(dim == 2); const double a = M_PI; diff --git a/prototypes/matrix_based_advection_diffusion/matrix_based_advection_diffusion.cc b/prototypes/matrix_based_advection_diffusion/matrix_based_advection_diffusion.cc index f1e82d10bb..02ba188798 100644 --- a/prototypes/matrix_based_advection_diffusion/matrix_based_advection_diffusion.cc +++ b/prototypes/matrix_based_advection_diffusion/matrix_based_advection_diffusion.cc @@ -371,13 +371,13 @@ class BoundaryValues : public Function virtual void value_list(const std::vector> &points, - std::vector & values, + std::vector &values, const unsigned int component = 0) const override; }; template double -BoundaryValues::value(const Point & p, +BoundaryValues::value(const Point &p, const unsigned int component) const { Assert(component == 0, ExcIndexRange(component, 0, 1)); @@ -397,7 +397,7 @@ BoundaryValues::value(const Point & p, template void BoundaryValues::value_list(const std::vector> &points, - std::vector & values, + std::vector &values, const unsigned int component) const { AssertDimension(values.size(), points.size()); @@ -518,7 +518,8 @@ MatrixBasedAdvectionDiffusion::make_grid() switch (parameters.geometry) { - case Settings::hyperball: { + case Settings::hyperball: + { SphericalManifold boundary_manifold; TransfiniteInterpolationManifold inner_manifold; @@ -534,11 +535,13 @@ MatrixBasedAdvectionDiffusion::make_grid() break; } - case Settings::hypercube: { + case Settings::hypercube: + { GridGenerator::hyper_cube(triangulation, -1.0, 1.0, true); break; } - case Settings::hypercube_with_hole: { + case Settings::hypercube_with_hole: + { GridGenerator::hyper_cube_with_cylindrical_hole(triangulation, 0.3, 1.0); @@ -547,7 +550,8 @@ MatrixBasedAdvectionDiffusion::make_grid() triangulation.set_manifold(1, manifold_description); break; } - case Settings::hyperrectangle: { + case Settings::hyperrectangle: + { std::vector repetitions(dim); for (unsigned int i = 0; i < dim - 1; i++) { @@ -1359,7 +1363,8 @@ MatrixBasedAdvectionDiffusion::compute_update() switch (parameters.preconditioner) { - case Settings::amg: { + case Settings::amg: + { TrilinosWrappers::PreconditionAMG preconditioner; TrilinosWrappers::PreconditionAMG::AdditionalData data; @@ -1377,7 +1382,8 @@ MatrixBasedAdvectionDiffusion::compute_update() preconditioner); break; } - case Settings::gmg: { + case Settings::gmg: + { MGTransferPrebuilt mg_transfer(mg_constrained_dofs); mg_transfer.build(dof_handler); @@ -1438,7 +1444,8 @@ MatrixBasedAdvectionDiffusion::compute_update() preconditioner); break; } - case Settings::ilu: { + case Settings::ilu: + { TrilinosWrappers::PreconditionILU preconditioner; TrilinosWrappers::PreconditionILU::AdditionalData data_ilu; preconditioner.initialize(system_matrix, data_ilu); @@ -1793,24 +1800,28 @@ main(int argc, char *argv[]) { switch (parameters.dimension) { - case 2: { + case 2: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixBasedAdvectionDiffusion<2, 1> advection_diffusion_problem(parameters); advection_diffusion_problem.run(); break; } - case 2: { + case 2: + { MatrixBasedAdvectionDiffusion<2, 2> advection_diffusion_problem(parameters); advection_diffusion_problem.run(); break; } - case 3: { + case 3: + { MatrixBasedAdvectionDiffusion<2, 3> advection_diffusion_problem(parameters); advection_diffusion_problem.run(); @@ -1821,24 +1832,28 @@ main(int argc, char *argv[]) break; } - case 3: { + case 3: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixBasedAdvectionDiffusion<3, 1> advection_diffusion_problem(parameters); advection_diffusion_problem.run(); break; } - case 2: { + case 2: + { MatrixBasedAdvectionDiffusion<3, 2> advection_diffusion_problem(parameters); advection_diffusion_problem.run(); break; } - case 3: { + case 3: + { MatrixBasedAdvectionDiffusion<3, 3> advection_diffusion_problem(parameters); advection_diffusion_problem.run(); @@ -1907,4 +1922,4 @@ main(int argc, char *argv[]) } return 0; -} \ No newline at end of file +} diff --git a/prototypes/matrix_based_non_linear_poisson/matrix_based_non_linear_poisson.cc b/prototypes/matrix_based_non_linear_poisson/matrix_based_non_linear_poisson.cc index 8cf5a5f32b..7b8bcc9d70 100644 --- a/prototypes/matrix_based_non_linear_poisson/matrix_based_non_linear_poisson.cc +++ b/prototypes/matrix_based_non_linear_poisson/matrix_based_non_linear_poisson.cc @@ -251,7 +251,7 @@ class SourceTerm : public Function template struct ScratchData { - ScratchData(const Mapping & mapping, + ScratchData(const Mapping &mapping, const FiniteElement &fe, const unsigned int quadrature_degree, const UpdateFlags update_flags) @@ -323,9 +323,9 @@ class MatrixBasedPoissonProblem template void - cell_worker(const Iterator & cell, + cell_worker(const Iterator &cell, ScratchData &scratch_data, - CopyData & copy_data); + CopyData ©_data); void assemble_gmg_meshworker(); @@ -410,7 +410,8 @@ MatrixBasedPoissonProblem::make_grid() switch (parameters.geometry) { - case Settings::hyperball: { + case Settings::hyperball: + { SphericalManifold boundary_manifold; TransfiniteInterpolationManifold inner_manifold; @@ -426,11 +427,13 @@ MatrixBasedPoissonProblem::make_grid() break; } - case Settings::hypercube: { + case Settings::hypercube: + { GridGenerator::hyper_cube(triangulation); break; } - case Settings::hyperrectangle: { + case Settings::hyperrectangle: + { std::vector repetitions(dim); for (unsigned int i = 0; i < dim - 1; i++) { @@ -790,9 +793,9 @@ template template void MatrixBasedPoissonProblem::cell_worker( - const Iterator & cell, + const Iterator &cell, ScratchData &scratch_data, - CopyData & copy_data) + CopyData ©_data) { FEValues &fe_values = scratch_data.fe_values; fe_values.reinit(cell); @@ -849,8 +852,8 @@ MatrixBasedPoissonProblem::assemble_gmg_meshworker() } auto cell_worker = [&](const typename DoFHandler::level_cell_iterator &cell, - ScratchData & scratch_data, - CopyData & copy_data) { + ScratchData &scratch_data, + CopyData ©_data) { this->cell_worker(cell, scratch_data, copy_data); }; @@ -1002,7 +1005,8 @@ MatrixBasedPoissonProblem::compute_update() switch (parameters.preconditioner) { - case Settings::amg: { + case Settings::amg: + { TrilinosWrappers::PreconditionAMG preconditioner; TrilinosWrappers::PreconditionAMG::AdditionalData data; @@ -1017,7 +1021,8 @@ MatrixBasedPoissonProblem::compute_update() preconditioner); break; } - case Settings::gmg: { + case Settings::gmg: + { MGTransferPrebuilt mg_transfer(mg_constrained_dofs); mg_transfer.build(dof_handler); @@ -1369,24 +1374,28 @@ main(int argc, char *argv[]) { switch (parameters.dimension) { - case 2: { + case 2: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixBasedPoissonProblem<2, 1> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 2: { + case 2: + { MatrixBasedPoissonProblem<2, 2> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 3: { + case 3: + { MatrixBasedPoissonProblem<2, 3> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); @@ -1397,24 +1406,28 @@ main(int argc, char *argv[]) break; } - case 3: { + case 3: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixBasedPoissonProblem<3, 1> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 2: { + case 2: + { MatrixBasedPoissonProblem<3, 2> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 3: { + case 3: + { MatrixBasedPoissonProblem<3, 3> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); diff --git a/prototypes/matrix_free_advection_diffusion/matrix_free_advection_diffusion.cc b/prototypes/matrix_free_advection_diffusion/matrix_free_advection_diffusion.cc index 1b0fd9850f..30c848686c 100644 --- a/prototypes/matrix_free_advection_diffusion/matrix_free_advection_diffusion.cc +++ b/prototypes/matrix_free_advection_diffusion/matrix_free_advection_diffusion.cc @@ -372,7 +372,7 @@ AdvectionField::value(const Point &p, template double -AdvectionField::value(const Point & p, +AdvectionField::value(const Point &p, const unsigned int component) const { return value(p, component); @@ -400,13 +400,13 @@ class BoundaryValues : public Function virtual void value_list(const std::vector> &points, - std::vector & values, + std::vector &values, const unsigned int component = 0) const override; }; template double -BoundaryValues::value(const Point & p, +BoundaryValues::value(const Point &p, const unsigned int component) const { Assert(component == 0, ExcIndexRange(component, 0, 1)); @@ -426,7 +426,7 @@ BoundaryValues::value(const Point & p, template void BoundaryValues::value_list(const std::vector> &points, - std::vector & values, + std::vector &values, const unsigned int component) const { AssertDimension(values.size(), points.size()); @@ -438,7 +438,7 @@ BoundaryValues::value_list(const std::vector> &points, // Matrix-free helper function template VectorizedArray -evaluate_function(const Function & function, +evaluate_function(const Function &function, const Point> &p_vectorized) { VectorizedArray result; @@ -455,7 +455,7 @@ evaluate_function(const Function & function, // Matrix-free helper function template Tensor<1, dim, VectorizedArray> -evaluate_function(const Function & function, +evaluate_function(const Function &function, const Point> &p_vectorized) { Tensor<1, dim, VectorizedArray> result; @@ -503,12 +503,12 @@ class AdvectionDiffusionOperator private: virtual void apply_add( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const override; void - local_apply(const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + local_apply(const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, const std::pair &cell_range) const; @@ -573,10 +573,10 @@ AdvectionDiffusionOperator::evaluate_newton_step( template void AdvectionDiffusionOperator::local_apply( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const + const std::pair &cell_range) const { FECellIntegrator phi(data); @@ -673,7 +673,7 @@ AdvectionDiffusionOperator::local_apply( template void AdvectionDiffusionOperator::apply_add( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const { this->data->cell_loop(&AdvectionDiffusionOperator::local_apply, @@ -856,15 +856,15 @@ class MatrixFreeAdvectionDiffusion void evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const; void local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const; + const std::pair &cell_range) const; void assemble_rhs(); @@ -941,7 +941,8 @@ MatrixFreeAdvectionDiffusion::make_grid() switch (parameters.geometry) { - case Settings::hyperball: { + case Settings::hyperball: + { SphericalManifold boundary_manifold; TransfiniteInterpolationManifold inner_manifold; @@ -957,11 +958,13 @@ MatrixFreeAdvectionDiffusion::make_grid() break; } - case Settings::hypercube: { + case Settings::hypercube: + { GridGenerator::hyper_cube(triangulation, -1.0, 1.0, true); break; } - case Settings::hypercube_with_hole: { + case Settings::hypercube_with_hole: + { GridGenerator::hyper_cube_with_cylindrical_hole(triangulation, 0.3, 1.0); @@ -970,7 +973,8 @@ MatrixFreeAdvectionDiffusion::make_grid() triangulation.set_manifold(1, manifold_description); break; } - case Settings::hyperrectangle: { + case Settings::hyperrectangle: + { std::vector repetitions(dim); for (unsigned int i = 0; i < dim - 1; i++) { @@ -1279,7 +1283,7 @@ MatrixFreeAdvectionDiffusion::setup_gmg() template void MatrixFreeAdvectionDiffusion::evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const { auto matrix_free = system_matrix.get_matrix_free(); @@ -1294,10 +1298,10 @@ MatrixFreeAdvectionDiffusion::evaluate_residual( template void MatrixFreeAdvectionDiffusion::local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const + const std::pair &cell_range) const { FEEvaluation phi(data); SourceTerm source_term_function; @@ -1450,7 +1454,8 @@ MatrixFreeAdvectionDiffusion::compute_update() switch (parameters.preconditioner) { - case Settings::amg: { + case Settings::amg: + { TrilinosWrappers::PreconditionAMG preconditioner; TrilinosWrappers::PreconditionAMG::AdditionalData data; @@ -1467,7 +1472,8 @@ MatrixFreeAdvectionDiffusion::compute_update() gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; } - case Settings::gmg: { + case Settings::gmg: + { system_matrix.evaluate_newton_step(solution); mg_transfer.interpolate_to_mg(dof_handler, mg_solution, solution); @@ -1557,7 +1563,8 @@ MatrixFreeAdvectionDiffusion::compute_update() gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; } - case Settings::ilu: { + case Settings::ilu: + { TrilinosWrappers::PreconditionILU preconditioner; TrilinosWrappers::PreconditionILU::AdditionalData data_ilu; preconditioner.initialize( @@ -1898,24 +1905,28 @@ main(int argc, char *argv[]) { switch (parameters.dimension) { - case 2: { + case 2: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixFreeAdvectionDiffusion<2, 1> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 2: { + case 2: + { MatrixFreeAdvectionDiffusion<2, 2> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 3: { + case 3: + { MatrixFreeAdvectionDiffusion<2, 3> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); @@ -1926,24 +1937,28 @@ main(int argc, char *argv[]) break; } - case 3: { + case 3: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixFreeAdvectionDiffusion<3, 1> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 2: { + case 2: + { MatrixFreeAdvectionDiffusion<3, 2> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); break; } - case 3: { + case 3: + { MatrixFreeAdvectionDiffusion<3, 3> non_linear_poisson_problem(parameters); non_linear_poisson_problem.run(); diff --git a/prototypes/matrix_free_mortar_poisson_consistent_integration/matrix_free_mortar_poisson_consistent_integration.cc b/prototypes/matrix_free_mortar_poisson_consistent_integration/matrix_free_mortar_poisson_consistent_integration.cc index 0bfac3f090..ef357e5fec 100644 --- a/prototypes/matrix_free_mortar_poisson_consistent_integration/matrix_free_mortar_poisson_consistent_integration.cc +++ b/prototypes/matrix_free_mortar_poisson_consistent_integration/matrix_free_mortar_poisson_consistent_integration.cc @@ -2,10 +2,10 @@ #include #include -#include #include #include +#include #include #include @@ -153,8 +153,8 @@ compute_quadrature( std::vector> all_points; std::vector all_JxWs; - for (const auto & subsection_0 : subsections_0) - for (const auto & subsection_1 : subsections_1) + for (const auto &subsection_0 : subsections_0) + for (const auto &subsection_1 : subsections_1) { const auto [points, JxWs] = compute_quadrature(subsection_0.first, @@ -191,9 +191,7 @@ class PoissonOperator : public Subscriptor , dof_handler(dof_handler) , constraints(constraints) , quadrature(quadrature) - , panalty_factor( - compute_pentaly_factor(dof_handler.get_fe().degree, - 1.0)) + , panalty_factor(compute_pentaly_factor(dof_handler.get_fe().degree, 1.0)) , valid_system(false) { typename MatrixFree::AdditionalData data; @@ -207,43 +205,42 @@ class PoissonOperator : public Subscriptor const double radius = 0.5; // TODO - const auto compute_penalty_parameter = [&](const auto & cell) - { - const dealii::FiniteElement &fe = - matrix_free.get_dof_handler().get_fe(); - const unsigned int degree = fe.degree; - - dealii::QGauss quadrature(degree + 1); - dealii::FEValues fe_values(mapping, - fe, - quadrature, - dealii::update_JxW_values); - - dealii::QGauss face_quadrature(degree + 1); - dealii::FEFaceValues fe_face_values(mapping, - fe, - face_quadrature, - dealii::update_JxW_values); - - fe_values.reinit(cell); - - Number volume = 0; - for (unsigned int q = 0; q < quadrature.size(); ++q) - volume += fe_values.JxW(q); - - Number surface_area = 0; - for (const auto f : cell->face_indices()) - { - fe_face_values.reinit(cell, f); - const Number factor = - (cell->at_boundary(f) && !cell->has_periodic_neighbor(f)) ? 1. : - 0.5; - for (unsigned int q = 0; q < face_quadrature.size(); ++q) - surface_area += fe_face_values.JxW(q) * factor; - } - - return surface_area / volume; - }; + const auto compute_penalty_parameter = [&](const auto &cell) { + const dealii::FiniteElement &fe = + matrix_free.get_dof_handler().get_fe(); + const unsigned int degree = fe.degree; + + dealii::QGauss quadrature(degree + 1); + dealii::FEValues fe_values(mapping, + fe, + quadrature, + dealii::update_JxW_values); + + dealii::QGauss face_quadrature(degree + 1); + dealii::FEFaceValues fe_face_values(mapping, + fe, + face_quadrature, + dealii::update_JxW_values); + + fe_values.reinit(cell); + + Number volume = 0; + for (unsigned int q = 0; q < quadrature.size(); ++q) + volume += fe_values.JxW(q); + + Number surface_area = 0; + for (const auto f : cell->face_indices()) + { + fe_face_values.reinit(cell, f); + const Number factor = + (cell->at_boundary(f) && !cell->has_periodic_neighbor(f)) ? 1. : + 0.5; + for (unsigned int q = 0; q < face_quadrature.size(); ++q) + surface_area += fe_face_values.JxW(q) * factor; + } + + return surface_area / volume; + }; for (const auto &cell_0 : tria.active_cell_iterators()) for (const auto &face_0 : cell_0->face_iterators()) @@ -273,14 +270,18 @@ class PoissonOperator : public Subscriptor for (const auto &p : points) normal.emplace_back(p / p.norm()); - const Number penalty_parameter = std::min( - compute_penalty_parameter(cell_0), - compute_penalty_parameter(cell_1) - ); - + const Number penalty_parameter = + std::min(compute_penalty_parameter(cell_0), + compute_penalty_parameter(cell_1)); + - all_intersections.emplace_back( - JxWs, cell_0, points_0, cell_1, points_1, normal, penalty_parameter); + all_intersections.emplace_back(JxWs, + cell_0, + points_0, + cell_1, + points_1, + normal, + penalty_parameter); } } @@ -330,8 +331,13 @@ class PoissonOperator : public Subscriptor Vector buffer_0; Vector buffer_1; - for (const auto &[JxWs, cell_0, points_0, cell_1, points_1, normals, penalty_parameter] : - all_intersections) + for (const auto &[JxWs, + cell_0, + points_0, + cell_1, + points_1, + normals, + penalty_parameter] : all_intersections) { const auto cell_dof_0 = cell_0->as_dof_handler_iterator(dof_handler); const auto cell_dof_1 = cell_1->as_dof_handler_iterator(dof_handler); @@ -353,7 +359,7 @@ class PoissonOperator : public Subscriptor for (const auto q : phi_m.quadrature_point_indices()) { const auto normal = normals[q]; - const auto JxW = JxWs [q]; + const auto JxW = JxWs[q]; const auto value_m = phi_m.get_value(q); const auto value_p = phi_p.get_value(q); @@ -361,8 +367,9 @@ class PoissonOperator : public Subscriptor const auto gradient_m = phi_m.get_gradient(q); const auto gradient_p = phi_p.get_gradient(q); - const auto jump_value = (value_m - value_p) * 0.5 * JxW; - const auto avg_gradient = normal * (gradient_m + gradient_p) * 0.5 * JxW; + const auto jump_value = (value_m - value_p) * 0.5 * JxW; + const auto avg_gradient = + normal * (gradient_m + gradient_p) * 0.5 * JxW; const double sigma = penalty_parameter * panalty_factor; @@ -452,7 +459,8 @@ class PoissonOperator : public Subscriptor std::vector>, typename Triangulation::active_cell_iterator, std::vector>, - std::vector>, Number>> + std::vector>, + Number>> all_intersections; void @@ -491,7 +499,7 @@ class PoissonOperator : public Subscriptor } mutable TrilinosWrappers::SparseMatrix system_matrix; - const Number panalty_factor; + const Number panalty_factor; mutable bool valid_system; }; diff --git a/prototypes/matrix_free_navier_stokes/matrix_free_navier_stokes.cc b/prototypes/matrix_free_navier_stokes/matrix_free_navier_stokes.cc index 282ccd7e50..02ba927672 100644 --- a/prototypes/matrix_free_navier_stokes/matrix_free_navier_stokes.cc +++ b/prototypes/matrix_free_navier_stokes/matrix_free_navier_stokes.cc @@ -251,7 +251,7 @@ class AnalyticalSolution : public Function template void AnalyticalSolution::vector_value(const Point &p, - Vector & values) const + Vector &values) const { AssertDimension(values.size(), dim + 1); @@ -404,7 +404,7 @@ FullSourceTerm::value(const Point &p, template double -FullSourceTerm::value(const Point & p, +FullSourceTerm::value(const Point &p, const unsigned int component) const { return value(p, component); @@ -415,7 +415,7 @@ FullSourceTerm::value(const Point & p, // to be used for the source terms in the Jacobian and Residual functions. template VectorizedArray -evaluate_function(const Function & function, +evaluate_function(const Function &function, const Point> &p_vectorized) { VectorizedArray result; @@ -434,7 +434,7 @@ evaluate_function(const Function & function, // to be used for the source terms in the Jacobian and Residual functions. template Tensor<1, components, VectorizedArray> -evaluate_function(const Function & function, +evaluate_function(const Function &function, const Point> &p_vectorized) { Tensor<1, components, VectorizedArray> result; @@ -465,19 +465,19 @@ class NavierStokesOperator : public Subscriptor NavierStokesOperator(); - NavierStokesOperator(const MappingQ & mapping, - const DoFHandler & dof_handler, + NavierStokesOperator(const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level); void - reinit(const MappingQ & mapping, - const DoFHandler & dof_handler, + reinit(const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level); void @@ -531,9 +531,9 @@ class NavierStokesOperator : public Subscriptor void do_cell_integral_range( - const MatrixFree & matrix_free, - VectorType & dst, - const VectorType & src, + const MatrixFree &matrix_free, + VectorType &dst, + const VectorType &src, const std::pair &range) const; static IndexSet @@ -567,11 +567,11 @@ NavierStokesOperator::NavierStokesOperator() template NavierStokesOperator::NavierStokesOperator( - const MappingQ & mapping, - const DoFHandler & dof_handler, + const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level) { this->reinit( @@ -581,11 +581,11 @@ NavierStokesOperator::NavierStokesOperator( template void NavierStokesOperator::reinit( - const MappingQ & mapping, - const DoFHandler & dof_handler, + const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level) { this->system_matrix.clear(); @@ -731,7 +731,7 @@ NavierStokesOperator::get_vector_partitioner() const // and evaluating the integrals in the matrix-free way template void -NavierStokesOperator::vmult(VectorType & dst, +NavierStokesOperator::vmult(VectorType &dst, const VectorType &src) const { // save values for edge constrained dofs and set them to 0 in src vector @@ -769,7 +769,7 @@ NavierStokesOperator::vmult(VectorType & dst, // Note: required for compilation but not used at the moment. template void -NavierStokesOperator::Tvmult(VectorType & dst, +NavierStokesOperator::Tvmult(VectorType &dst, const VectorType &src) const { this->vmult(dst, src); @@ -778,7 +778,7 @@ NavierStokesOperator::Tvmult(VectorType & dst, template void NavierStokesOperator::vmult_interface_down( - VectorType & dst, + VectorType &dst, VectorType const &src) const { this->matrix_free.cell_loop( @@ -793,7 +793,7 @@ NavierStokesOperator::vmult_interface_down( template void NavierStokesOperator::vmult_interface_up( - VectorType & dst, + VectorType &dst, VectorType const &src) const { if (has_edge_constrained_indices == false) @@ -1086,9 +1086,9 @@ NavierStokesOperator::do_cell_integral_local( template void NavierStokesOperator::do_cell_integral_range( - const MatrixFree & matrix_free, - VectorType & dst, - const VectorType & src, + const MatrixFree &matrix_free, + VectorType &dst, + const VectorType &src, const std::pair &range) const { FECellIntegrator integrator(matrix_free, range); @@ -1154,14 +1154,14 @@ template static void -gcmg_solve(SolverControl & solver_control, - VectorType & dst, - const VectorType & src, +gcmg_solve(SolverControl &solver_control, + VectorType &dst, + const VectorType &src, const MultigridParameters &mg_data, - const DoFHandler & dof, - const SystemMatrixType & fine_matrix, + const DoFHandler &dof, + const SystemMatrixType &fine_matrix, const MGLevelObject> &mg_matrices, - const MGTransferType & mg_transfer) + const MGTransferType &mg_transfer) { AssertThrow(mg_data.coarse_solver.type == "gmres_with_amg", ExcNotImplemented()); @@ -1230,16 +1230,16 @@ gcmg_solve(SolverControl & solver_control, template void -solve_with_gcmg(SolverControl & solver_control, - const OperatorType & system_matrix, - VectorType & dst, - const VectorType & src, +solve_with_gcmg(SolverControl &solver_control, + const OperatorType &system_matrix, + VectorType &dst, + const VectorType &src, const MultigridParameters &mg_data, const MappingQ mapping, - const DoFHandler & dof_handler, - const QGauss<1> & quadrature, - const Settings & parameters, - const VectorType & solution) + const DoFHandler &dof_handler, + const QGauss<1> &quadrature, + const Settings ¶meters, + const VectorType &solution) { MGLevelObject> dof_handlers; MGLevelObject> operators; @@ -1275,7 +1275,7 @@ solve_with_gcmg(SolverControl & solver_control, for (unsigned int level = minlevel; level <= maxlevel; ++level) { const auto &dof_handler = dof_handlers[level]; - auto & constraint = constraints[level]; + auto &constraint = constraints[level]; const IndexSet locally_relevant_dofs = DoFTools::extract_locally_relevant_dofs(dof_handler); @@ -1380,14 +1380,14 @@ template static void lsmg_solve( - SolverControl & solver_control, - VectorType & dst, - const VectorType & src, - const MultigridParameters & mg_data, - const DoFHandler & dof, - const SystemMatrixType & fine_matrix, + SolverControl &solver_control, + VectorType &dst, + const VectorType &src, + const MultigridParameters &mg_data, + const DoFHandler &dof, + const SystemMatrixType &fine_matrix, const MGLevelObject> &mg_matrices, - const MGTransferType & mg_transfer, + const MGTransferType &mg_transfer, const MGLevelObject> &ls_mg_interface_in, const MGLevelObject> @@ -1470,16 +1470,16 @@ lsmg_solve( template void -solve_with_lsmg(SolverControl & solver_control, - const OperatorType & system_matrix, - VectorType & dst, - const VectorType & src, +solve_with_lsmg(SolverControl &solver_control, + const OperatorType &system_matrix, + VectorType &dst, + const VectorType &src, const MultigridParameters &mg_data, const MappingQ mapping, - const DoFHandler & dof_handler, - const QGauss<1> & quadrature, - const Settings & parameters, - const VectorType & solution) + const DoFHandler &dof_handler, + const QGauss<1> &quadrature, + const Settings ¶meters, + const VectorType &solution) { MGLevelObject> operators; MGTransferMatrixFree mg_transfer; @@ -1605,15 +1605,15 @@ class MatrixFreeNavierStokes void evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const; void local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const; + const std::pair &cell_range) const; void assemble_rhs(); @@ -1692,11 +1692,13 @@ MatrixFreeNavierStokes::make_grid() switch (parameters.geometry) { - case Settings::hypercube: { + case Settings::hypercube: + { GridGenerator::hyper_cube(triangulation, -1.0, 1.0, true); break; } - case Settings::hyperrectangle: { + case Settings::hyperrectangle: + { std::vector repetitions(dim); for (unsigned int i = 0; i < dim - 1; i++) { @@ -1800,7 +1802,7 @@ MatrixFreeNavierStokes::setup_system() template void MatrixFreeNavierStokes::evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const { system_matrix.get_system_matrix_free().cell_loop( @@ -1818,10 +1820,10 @@ MatrixFreeNavierStokes::evaluate_residual( template void MatrixFreeNavierStokes::local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const + const std::pair &cell_range) const { using FECellIntegratorType = FEEvaluation>; @@ -2007,7 +2009,8 @@ MatrixFreeNavierStokes::compute_update() switch (parameters.preconditioner) { - case Settings::amg: { + case Settings::amg: + { TrilinosWrappers::PreconditionAMG preconditioner; TrilinosWrappers::PreconditionAMG::AdditionalData data; @@ -2021,7 +2024,8 @@ MatrixFreeNavierStokes::compute_update() gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; } - case Settings::gcmg: { + case Settings::gcmg: + { MultigridParameters mg_data; mg_data.smoother.relaxation = parameters.relaxation_parameter; @@ -2037,7 +2041,8 @@ MatrixFreeNavierStokes::compute_update() solution); break; } - case Settings::lsmg: { + case Settings::lsmg: + { MultigridParameters mg_data; mg_data.smoother.relaxation = parameters.relaxation_parameter; @@ -2053,7 +2058,8 @@ MatrixFreeNavierStokes::compute_update() solution); break; } - case Settings::ilu: { + case Settings::ilu: + { TrilinosWrappers::PreconditionILU preconditioner; TrilinosWrappers::PreconditionILU::AdditionalData data_ilu; preconditioner.initialize(system_matrix.get_system_matrix(), @@ -2062,7 +2068,8 @@ MatrixFreeNavierStokes::compute_update() gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; } - case Settings::none: { + case Settings::none: + { PreconditionIdentity preconditioner; gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; @@ -2430,14 +2437,16 @@ main(int argc, char *argv[]) { switch (parameters.dimension) { - case 2: { + case 2: + { MatrixFreeNavierStokes<2> vector_valued_problem(parameters); vector_valued_problem.run(); break; } - case 3: { + case 3: + { MatrixFreeNavierStokes<3> vector_valued_problem(parameters); vector_valued_problem.run(); break; @@ -2477,4 +2486,4 @@ main(int argc, char *argv[]) } return 0; -} \ No newline at end of file +} diff --git a/prototypes/matrix_free_non_linear_poisson/matrix_free_non_linear_poisson.cc b/prototypes/matrix_free_non_linear_poisson/matrix_free_non_linear_poisson.cc index d6c2991b99..a652dd15e0 100644 --- a/prototypes/matrix_free_non_linear_poisson/matrix_free_non_linear_poisson.cc +++ b/prototypes/matrix_free_non_linear_poisson/matrix_free_non_linear_poisson.cc @@ -267,12 +267,12 @@ class JacobianOperator private: virtual void apply_add( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const override; void - local_apply(const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + local_apply(const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, const std::pair &cell_range) const; @@ -322,10 +322,10 @@ JacobianOperator::evaluate_newton_step( template void JacobianOperator::local_apply( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const + const std::pair &cell_range) const { FECellIntegrator phi(data); @@ -356,7 +356,7 @@ JacobianOperator::local_apply( template void JacobianOperator::apply_add( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const { this->data->cell_loop(&JacobianOperator::local_apply, this, dst, src); @@ -430,15 +430,15 @@ class MatrixFreePoissonProblem void evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const; void local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const; + const std::pair &cell_range) const; void assemble_rhs(); @@ -514,7 +514,8 @@ MatrixFreePoissonProblem::make_grid() switch (parameters.geometry) { - case Settings::hyperball: { + case Settings::hyperball: + { SphericalManifold boundary_manifold; TransfiniteInterpolationManifold inner_manifold; @@ -530,11 +531,13 @@ MatrixFreePoissonProblem::make_grid() break; } - case Settings::hypercube: { + case Settings::hypercube: + { GridGenerator::hyper_cube(triangulation); break; } - case Settings::hyperrectangle: { + case Settings::hyperrectangle: + { std::vector repetitions(dim); for (unsigned int i = 0; i < dim - 1; i++) { @@ -656,7 +659,7 @@ MatrixFreePoissonProblem::setup_gmg() template void MatrixFreePoissonProblem::evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const { auto matrix_free = system_matrix.get_matrix_free(); @@ -668,10 +671,10 @@ MatrixFreePoissonProblem::evaluate_residual( template void MatrixFreePoissonProblem::local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const + const std::pair &cell_range) const { FEEvaluation phi(data); SourceTerm source_term_function; @@ -1104,24 +1107,28 @@ main(int argc, char *argv[]) { switch (parameters.dimension) { - case 2: { + case 2: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixFreePoissonProblem<2, 1> non_linear_poisson_problem( parameters); non_linear_poisson_problem.run(); break; } - case 2: { + case 2: + { MatrixFreePoissonProblem<2, 2> non_linear_poisson_problem( parameters); non_linear_poisson_problem.run(); break; } - case 3: { + case 3: + { MatrixFreePoissonProblem<2, 3> non_linear_poisson_problem( parameters); non_linear_poisson_problem.run(); @@ -1132,24 +1139,28 @@ main(int argc, char *argv[]) break; } - case 3: { + case 3: + { switch (parameters.element_order) { - case 1: { + case 1: + { MatrixFreePoissonProblem<3, 1> non_linear_poisson_problem( parameters); non_linear_poisson_problem.run(); break; } - case 2: { + case 2: + { MatrixFreePoissonProblem<3, 2> non_linear_poisson_problem( parameters); non_linear_poisson_problem.run(); break; } - case 3: { + case 3: + { MatrixFreePoissonProblem<3, 3> non_linear_poisson_problem( parameters); non_linear_poisson_problem.run(); diff --git a/prototypes/matrix_free_stokes/matrix_free_stokes.cc b/prototypes/matrix_free_stokes/matrix_free_stokes.cc index 5d65ead0ef..dee2e9cdff 100644 --- a/prototypes/matrix_free_stokes/matrix_free_stokes.cc +++ b/prototypes/matrix_free_stokes/matrix_free_stokes.cc @@ -239,7 +239,7 @@ class AnalyticalSolution : public Function template void AnalyticalSolution::vector_value(const Point &p, - Vector & values) const + Vector &values) const { AssertDimension(values.size(), dim + 1); @@ -310,7 +310,7 @@ FullSourceTerm::value(const Point &p, template double -FullSourceTerm::value(const Point & p, +FullSourceTerm::value(const Point &p, const unsigned int component) const { return value(p, component); @@ -319,7 +319,7 @@ FullSourceTerm::value(const Point & p, // Matrix-free helper function template VectorizedArray -evaluate_function(const Function & function, +evaluate_function(const Function &function, const Point> &p_vectorized) { VectorizedArray result; @@ -336,7 +336,7 @@ evaluate_function(const Function & function, // Matrix-free helper function template Tensor<1, components, VectorizedArray> -evaluate_function(const Function & function, +evaluate_function(const Function &function, const Point> &p_vectorized) { Tensor<1, components, VectorizedArray> result; @@ -367,19 +367,19 @@ class StokesOperator : public Subscriptor StokesOperator(); - StokesOperator(const MappingQ & mapping, - const DoFHandler & dof_handler, + StokesOperator(const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level); void - reinit(const MappingQ & mapping, - const DoFHandler & dof_handler, + reinit(const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level); void @@ -430,9 +430,9 @@ class StokesOperator : public Subscriptor void do_cell_integral_range( - const MatrixFree & matrix_free, - VectorType & dst, - const VectorType & src, + const MatrixFree &matrix_free, + VectorType &dst, + const VectorType &src, const std::pair &range) const; static IndexSet @@ -460,11 +460,11 @@ StokesOperator::StokesOperator() template StokesOperator::StokesOperator( - const MappingQ & mapping, - const DoFHandler & dof_handler, + const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level) { this->reinit( @@ -474,11 +474,11 @@ StokesOperator::StokesOperator( template void StokesOperator::reinit( - const MappingQ & mapping, - const DoFHandler & dof_handler, + const MappingQ &mapping, + const DoFHandler &dof_handler, const AffineConstraints &constraints, - const QGauss<1> & quadrature, - const Settings & parameters, + const QGauss<1> &quadrature, + const Settings ¶meters, const unsigned int mg_level) { this->system_matrix.clear(); @@ -664,7 +664,7 @@ StokesOperator::vmult(VectorType &dst, const VectorType &src) const // TODO: implement this correctly (let's start with something symetric) template void -StokesOperator::Tvmult(VectorType & dst, +StokesOperator::Tvmult(VectorType &dst, const VectorType &src) const { this->vmult(dst, src); @@ -672,7 +672,7 @@ StokesOperator::Tvmult(VectorType & dst, template void -StokesOperator::vmult_interface_down(VectorType & dst, +StokesOperator::vmult_interface_down(VectorType &dst, VectorType const &src) const { this->matrix_free.cell_loop( @@ -686,7 +686,7 @@ StokesOperator::vmult_interface_down(VectorType & dst, template void -StokesOperator::vmult_interface_up(VectorType & dst, +StokesOperator::vmult_interface_up(VectorType &dst, VectorType const &src) const { if (has_edge_constrained_indices == false) @@ -854,9 +854,9 @@ StokesOperator::do_cell_integral_local( template void StokesOperator::do_cell_integral_range( - const MatrixFree & matrix_free, - VectorType & dst, - const VectorType & src, + const MatrixFree &matrix_free, + VectorType &dst, + const VectorType &src, const std::pair &range) const { FECellIntegrator integrator(matrix_free, range); @@ -922,14 +922,14 @@ template static void -gcmg_solve(SolverControl & solver_control, - VectorType & dst, - const VectorType & src, +gcmg_solve(SolverControl &solver_control, + VectorType &dst, + const VectorType &src, const MultigridParameters &mg_data, - const DoFHandler & dof, - const SystemMatrixType & fine_matrix, + const DoFHandler &dof, + const SystemMatrixType &fine_matrix, const MGLevelObject> &mg_matrices, - const MGTransferType & mg_transfer) + const MGTransferType &mg_transfer) { AssertThrow(mg_data.coarse_solver.type == "gmres_with_amg", ExcNotImplemented()); @@ -998,15 +998,15 @@ gcmg_solve(SolverControl & solver_control, template void -solve_with_gcmg(SolverControl & solver_control, - const OperatorType & system_matrix, - VectorType & dst, - const VectorType & src, +solve_with_gcmg(SolverControl &solver_control, + const OperatorType &system_matrix, + VectorType &dst, + const VectorType &src, const MultigridParameters &mg_data, const MappingQ mapping, - const DoFHandler & dof_handler, - const QGauss<1> & quadrature, - const Settings & parameters) + const DoFHandler &dof_handler, + const QGauss<1> &quadrature, + const Settings ¶meters) { MGLevelObject> dof_handlers; MGLevelObject> operators; @@ -1040,7 +1040,7 @@ solve_with_gcmg(SolverControl & solver_control, for (unsigned int level = minlevel; level <= maxlevel; ++level) { const auto &dof_handler = dof_handlers[level]; - auto & constraint = constraints[level]; + auto &constraint = constraints[level]; const IndexSet locally_relevant_dofs = DoFTools::extract_locally_relevant_dofs(dof_handler); @@ -1120,14 +1120,14 @@ template static void lsmg_solve( - SolverControl & solver_control, - VectorType & dst, - const VectorType & src, - const MultigridParameters & mg_data, - const DoFHandler & dof, - const SystemMatrixType & fine_matrix, + SolverControl &solver_control, + VectorType &dst, + const VectorType &src, + const MultigridParameters &mg_data, + const DoFHandler &dof, + const SystemMatrixType &fine_matrix, const MGLevelObject> &mg_matrices, - const MGTransferType & mg_transfer, + const MGTransferType &mg_transfer, const MGLevelObject> &ls_mg_interface_in, const MGLevelObject> @@ -1211,15 +1211,15 @@ lsmg_solve( template void -solve_with_lsmg(SolverControl & solver_control, - const OperatorType & system_matrix, - VectorType & dst, - const VectorType & src, +solve_with_lsmg(SolverControl &solver_control, + const OperatorType &system_matrix, + VectorType &dst, + const VectorType &src, const MultigridParameters &mg_data, const MappingQ mapping, - const DoFHandler & dof_handler, - const QGauss<1> & quadrature, - const Settings & parameters) + const DoFHandler &dof_handler, + const QGauss<1> &quadrature, + const Settings ¶meters) { MGLevelObject> operators; MGTransferMatrixFree mg_transfer; @@ -1333,15 +1333,15 @@ class MatrixFreeStokes void evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const; void local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const; + const std::pair &cell_range) const; void assemble_rhs(); @@ -1420,11 +1420,13 @@ MatrixFreeStokes::make_grid() switch (parameters.geometry) { - case Settings::hypercube: { + case Settings::hypercube: + { GridGenerator::hyper_cube(triangulation, -1.0, 1.0, true); break; } - case Settings::hyperrectangle: { + case Settings::hyperrectangle: + { std::vector repetitions(dim); for (unsigned int i = 0; i < dim - 1; i++) { @@ -1519,7 +1521,7 @@ MatrixFreeStokes::setup_system() template void MatrixFreeStokes::evaluate_residual( - LinearAlgebra::distributed::Vector & dst, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src) const { system_matrix.get_system_matrix_free().cell_loop( @@ -1529,10 +1531,10 @@ MatrixFreeStokes::evaluate_residual( template void MatrixFreeStokes::local_evaluate_residual( - const MatrixFree & data, - LinearAlgebra::distributed::Vector & dst, + const MatrixFree &data, + LinearAlgebra::distributed::Vector &dst, const LinearAlgebra::distributed::Vector &src, - const std::pair & cell_range) const + const std::pair &cell_range) const { using FECellIntegratorType = FEEvaluation>; @@ -1661,7 +1663,8 @@ MatrixFreeStokes::compute_update() switch (parameters.preconditioner) { - case Settings::amg: { + case Settings::amg: + { TrilinosWrappers::PreconditionAMG preconditioner; TrilinosWrappers::PreconditionAMG::AdditionalData data; @@ -1675,7 +1678,8 @@ MatrixFreeStokes::compute_update() gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; } - case Settings::gcmg: { + case Settings::gcmg: + { MultigridParameters mg_data; solve_with_gcmg(solver_control, @@ -1689,7 +1693,8 @@ MatrixFreeStokes::compute_update() parameters); break; } - case Settings::lsmg: { + case Settings::lsmg: + { MultigridParameters mg_data; solve_with_lsmg(solver_control, @@ -1703,7 +1708,8 @@ MatrixFreeStokes::compute_update() parameters); break; } - case Settings::ilu: { + case Settings::ilu: + { TrilinosWrappers::PreconditionILU preconditioner; TrilinosWrappers::PreconditionILU::AdditionalData data_ilu; preconditioner.initialize(system_matrix.get_system_matrix(), @@ -1712,7 +1718,8 @@ MatrixFreeStokes::compute_update() gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; } - case Settings::none: { + case Settings::none: + { PreconditionIdentity preconditioner; gmres.solve(system_matrix, newton_update, system_rhs, preconditioner); break; @@ -2058,14 +2065,16 @@ main(int argc, char *argv[]) { switch (parameters.dimension) { - case 2: { + case 2: + { MatrixFreeStokes<2> vector_valued_problem(parameters); vector_valued_problem.run(); break; } - case 3: { + case 3: + { MatrixFreeStokes<3> vector_valued_problem(parameters); vector_valued_problem.run(); break; diff --git a/prototypes/modified_zonal_approach/modified_zonal_approach.cc b/prototypes/modified_zonal_approach/modified_zonal_approach.cc index 387c546222..1729f1f052 100644 --- a/prototypes/modified_zonal_approach/modified_zonal_approach.cc +++ b/prototypes/modified_zonal_approach/modified_zonal_approach.cc @@ -256,7 +256,7 @@ main() if (t == n_times - 1) write_distances(case_1.second, distances, "random.dat"); } - } + } { unsigned int n_times = 1e5;