oomph::MinModLimiter Class Reference

#include <dg_elements.h>

+ Inheritance diagram for oomph::MinModLimiter:

Public Member Functions

 MinModLimiter (const double &m=0.0, const bool &muscl=false)
 
virtual ~MinModLimiter ()
 Empty destructor. More...
 
double minmod (Vector< double > &args)
 The basic minmod function. More...
 
double minmodB (Vector< double > &args, const double &h)
 The modified minmod function. More...
 
void limit (const unsigned &i, const Vector< DGElement * > &required_element_pt)
 The limit function. More...
 
- Public Member Functions inherited from oomph::SlopeLimiter
 SlopeLimiter ()
 Empty constructor. More...
 
virtual ~SlopeLimiter ()
 virtual destructor More...
 

Private Attributes

double M
 
bool MUSCL
 Boolean flag to indicate a MUSCL or straight min-mod limiter. More...
 

Constructor & Destructor Documentation

◆ MinModLimiter()

oomph::MinModLimiter::MinModLimiter ( const double m = 0.0,
const bool muscl = false 
)
inline

Constructor takes a value for the modification parameter M (default to zero — classic min mod) and a flag to indicate whether we use MUSCL limiting or not — default false

557  : SlopeLimiter(), M(m), MUSCL(muscl)
558  {
559  }
bool MUSCL
Boolean flag to indicate a MUSCL or straight min-mod limiter.
Definition: dg_elements.h:550
double M
Definition: dg_elements.h:547
SlopeLimiter()
Empty constructor.
Definition: dg_elements.h:528
int * m
Definition: level2_cplx_impl.h:294

◆ ~MinModLimiter()

virtual oomph::MinModLimiter::~MinModLimiter ( )
inlinevirtual

Empty destructor.

562 {}

Member Function Documentation

◆ limit()

void oomph::MinModLimiter::limit ( const unsigned i,
const Vector< DGElement * > &  required_element_pt 
)
virtual

The limit function.

Implement the limiter function for the basic MinModlimiter.

Reimplemented from oomph::SlopeLimiter.

824  {
825  // Set the tolerance
826  const double tol = 1.0e-16;
827 
828  // Find the geometric parameters of the element
829  const unsigned n_node = required_element_pt[0]->nnode();
830  const double x_l = required_element_pt[0]->node_pt(0)->x(0);
831  const double x_r = required_element_pt[0]->node_pt(n_node - 1)->x(0);
832  const double h = x_r - x_l;
833  const double x0 = 0.5 * (x_l + x_r);
834  // Find the average value
835  const double u_av = required_element_pt[0]->average_value(i);
836 
837  // Storage for the gradients to the minmod function
838  Vector<double> arg;
839  arg.reserve(3);
840 
841  // Add the approximation for the element's left flux
842  arg.push_back(u_av - required_element_pt[0]->node_pt(0)->value(i));
843 
844  // If there is a left element add the approximate gradient
845  // to the argument vector
846  if (required_element_pt[1] != required_element_pt[0])
847  {
848  arg.push_back(u_av - required_element_pt[1]->average_value(i));
849  }
850  // If there is a right element add the approximate gradient
851  // to the argument vector
852  if (required_element_pt[2] != required_element_pt[0])
853  {
854  arg.push_back(required_element_pt[2]->average_value(i) - u_av);
855  }
856 
857  // Set the left value
858  const double u_l = u_av - this->minmod(arg);
859 
860  // Now replace the first term in the argument list with the
861  // approximation for the element's right flux
862  arg.front() = required_element_pt[0]->node_pt(n_node - 1)->value(i) - u_av;
863 
864  // Set the right value
865  const double u_r = u_av + this->minmod(arg);
866 
867  // If the basic limited values are different from
868  // the unlimited values then limit
869  if ((std::fabs(u_l - required_element_pt[0]->node_pt(0)->value(i)) > tol) &&
870  (std::fabs(
871  u_r - required_element_pt[0]->node_pt(n_node - 1)->value(i)) > tol))
872  {
873  // Find the centre of the element on the left
874  const double x0_l =
875  0.5 * (required_element_pt[1]
876  ->node_pt(required_element_pt[1]->nnode() - 1)
877  ->x(0) +
878  required_element_pt[1]->node_pt(0)->x(0));
879  // Find the centre of the element on the right
880  const double x0_r =
881  0.5 * (required_element_pt[2]
882  ->node_pt(required_element_pt[2]->nnode() - 1)
883  ->x(0) +
884  required_element_pt[2]->node_pt(0)->x(0));
885 
886  // Clear the argument list and reserve its size to
887  arg.clear();
888  arg.reserve(3);
889 
890  // Approximate the gradient over the whole cell
891  arg.push_back((required_element_pt[0]->node_pt(n_node - 1)->value(i) -
892  required_element_pt[0]->node_pt(0)->value(i)) /
893  h);
894 
895  // Adjust the estimates for the gradient calculated from neighbouring
896  // averages for the straight min-mod and MUSCL limiters
897  double gradient_factor = 0.5;
898  if (MUSCL)
899  {
900  gradient_factor = 1.0;
901  }
902 
903  // If there is a left element, form the gradient
904  if (required_element_pt[0] != required_element_pt[1])
905  {
906  arg.push_back((u_av - required_element_pt[1]->average_value(i)) /
907  (gradient_factor * (x0 - x0_l)));
908  }
909 
910  // If there is a right element, form the gradient
911  if (required_element_pt[0] != required_element_pt[2])
912  {
913  arg.push_back((required_element_pt[2]->average_value(i) - u_av) /
914  (gradient_factor * (x0_r - x0)));
915  }
916 
917  // Calculate the limited gradient of these three
918  double limited_gradient = this->minmodB(arg, h);
919 
920  // Loop over the nodes and limit
921  for (unsigned n = 0; n < n_node; n++)
922  {
923  double x = required_element_pt[0]->node_pt(n)->x(0) - x0;
924  required_element_pt[0]->node_pt(n)->set_value(
925  i, u_av + x * limited_gradient);
926  }
927  }
928  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
double minmod(Vector< double > &args)
The basic minmod function.
Definition: dg_elements.cc:740
double minmodB(Vector< double > &args, const double &h)
The modified minmod function.
Definition: dg_elements.cc:800
squared absolute value
Definition: GlobalFunctions.h:87
double u_r(const double &time, const Vector< double > &x)
Calculate the time dependent form of the r-component of displacement.
Definition: axisym_linear_elasticity/cylinder/cylinder.cc:130
Vector< double > x0(2, 0.0)
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
list x
Definition: plotDoE.py:28

References boost::multiprecision::fabs(), i, minmod(), minmodB(), MUSCL, n, Global_Parameters::u_r(), Eigen::value, plotDoE::x, and Global::x0.

◆ minmod()

double oomph::MinModLimiter::minmod ( Vector< double > &  args)

The basic minmod function.

Helper minmod function.

741  {
742  const unsigned n_arg = args.size();
743  // If no arguments return zero
744  if (n_arg == 0)
745  {
746  return 0.0;
747  }
748 
749  // Initialise the sign from the sign of the first entry
750  int sign = 0;
751  if (args[0] < 0.0)
752  {
753  sign = -1;
754  }
755  else if (args[0] > 0.0)
756  {
757  sign = 1;
758  }
759  else
760  {
761  return 0.0;
762  }
763 
764  // Initialise the minimum value
765  double min = std::fabs(args[0]);
766 
767  // Now loop over the rest of the values
768  for (unsigned i = 1; i < n_arg; i++)
769  {
770  if (sign == 1)
771  {
772  if (args[i] < 0.0)
773  {
774  return 0.0;
775  }
776  else if (args[i] < min)
777  {
778  min = args[i];
779  }
780  }
781  else if (sign == -1)
782  {
783  if (args[i] > 0.0)
784  {
785  return 0.0;
786  }
787  else if (std::fabs(args[i]) < min)
788  {
789  min = std::fabs(args[i]);
790  }
791  }
792  }
793 
794  // Make sure to return the sign multiplied by the minimum value
795  return sign * min;
796  }
#define min(a, b)
Definition: datatypes.h:22
T sign(T x)
Definition: cxx11_tensor_builtins_sycl.cpp:172
args
Definition: compute_granudrum_aor.py:143

References compute_granudrum_aor::args, boost::multiprecision::fabs(), i, min, and SYCL::sign().

Referenced by limit(), and minmodB().

◆ minmodB()

double oomph::MinModLimiter::minmodB ( Vector< double > &  args,
const double h 
)

The modified minmod function.

Modified minmod limiter to fix behaviour in smooth regions.

801  {
802  const unsigned n_arg = args.size();
803  // If no arguments return zero
804  if (n_arg == 0)
805  {
806  return 0.0;
807  }
808 
809  // Modification to fix extrema
810  if (std::fabs(args[0]) < this->M * h * h)
811  {
812  return args[0];
813  }
814  // Otherwise just return the usual minmod
815  else
816  {
817  return minmod(args);
818  }
819  }
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186

References compute_granudrum_aor::args, boost::multiprecision::fabs(), and minmod().

Referenced by limit().

Member Data Documentation

◆ M

double oomph::MinModLimiter::M
private

Constant that is used in the modified min-mod function to provide better properties at extrema

◆ MUSCL

bool oomph::MinModLimiter::MUSCL
private

Boolean flag to indicate a MUSCL or straight min-mod limiter.

Referenced by limit().


The documentation for this class was generated from the following files: