MPS-Basic
Loading...
Searching...
No Matches
Weight Class Reference

Provides a weight function. More...

#include <weight.hpp>

Public Member Functions

 Weight ()=default
 
 Weight (WeightType weightType)
 
double weightFn (double dis, double re)
 Weight function for MPS method.
 

Private Attributes

WeightType weightType
 

Detailed Description

Provides a weight function.

The class supports different types of weight calculations, as specified by the WeightType enumeration.

See also
WeightType

Definition at line 15 of file weight.hpp.

Constructor & Destructor Documentation

◆ Weight() [1/2]

Weight::Weight ( )
default

◆ Weight() [2/2]

Weight::Weight ( WeightType weightType)

Definition at line 6 of file weight.cpp.

6 {
8}
WeightType weightType
Definition weight.hpp:17

Member Function Documentation

◆ weightFn()

double Weight::weightFn ( double dis,
double re )

Weight function for MPS method.

The weight function is defined as:

  • \[w(r) = \frac{r_e}{r} - 1\]

    for semi-implicit method
  • \[w(r) = \frac{r_e}{r} - \frac{r}{r_e}\]

    for the gradient calculations in explicit method
  • \[w(r) = \frac{r_e}{r} + \frac{r}{r_e} - 2\]

    for the other calculations in explicit method

Weight function for semi-implicit method is presented by Koshizuka and Oka, 1996 Weight functions for explicit method is presented by Yamada, et al., 2011

Parameters
disdistance of each particle \(r\). It must be positive.
reeffective radius \(r_e\)
Returns
weight

Definition at line 10 of file weight.cpp.

10 {
11 assert(dis > 0.0);
12
13 if (dis >= re) {
14 return 0.0;
15 } else {
17 return (re / dis) - 1.0;
18 } else if (weightType == WeightType::Explicit) {
19 return (re / dis) + (dis / re) - 2.0;
21 return (re / dis) - (dis / re);
22 }
23 std::cerr << "ERROR: Unknown weight type." << std::endl;
24 std::exit(-1);
25 }
26}
Here is the caller graph for this function:

Member Data Documentation

◆ weightType

WeightType Weight::weightType
private

Definition at line 17 of file weight.hpp.


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